[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TRNSYS-users] Stored variables (C++)



Carlos,

 

You are right that C++ does not have the longest tradition in TRNSYS programming, but the point is, no C++ programmer sane in his mind would want to use these functions. In C or C++ you can just declare variables at global scope and write the word ‘static’ in front – why would you want to use a sort of user-defined stack for that, keep track of the stack pointer etc. ?

If you need to store a name in C++ I suppose you would use a string object, and not try to create a Hollerith constant, right? J

 

I wrote a complete library of TRNSYS types for process control, data transmission & data base access in C – it was a lot of fun and works fine (say the clients), including the real time part controlling all sort of complicated equipment. So I would say TRNSYS does support C++, but you have to program it in C++, not try mimic what they did in FORTRAN 30 years ago.

 

Werner

 

De : carlosfloreslenero@gmail.com [mailto:carlosfloreslenero@gmail.com] De la part de Carlos Flores | DECCW. Sydney, Australia
Envoyé : mardi 10 août 2010 23:09
À : keilholz, werner
Cc : trnsys-users@engr.wisc.edu
Objet : Re: [TRNSYS-users] Stored variables (C++)

 

Hey Werner,

 

That is a shame.  It's sad that TRNSYS does not have a proper support for C++, specially when they claim they do.  It made me waste a couple of days of work.

 

Thanks very much for your answer and for helping me not to waste my time any longer.  

 

Kind regards,

 

Carlos

 

 

On Mon, Aug 9, 2010 at 10:11 PM, keilholz, werner <werner.keilholz@cstb.fr> wrote:

Hi Carlos,

 

The setStorageVars problem, too, has been encountered before:

http://www.mail-archive.com/trnsys-users@engr.wisc.edu/msg01920.html

 

Basically, my recommendation is not to use it in C or C++ - it’s a bit like asking where you can get fresh hay for your car...

 

Werner

 

De : carlosfloreslenero@gmail.com [mailto:carlosfloreslenero@gmail.com] De la part de Carlos Flores | DECCW. Sydney, Australia
Envoyé : lundi 9 août 2010 11:03
À : trnsys-users@engr.wisc.edu
Objet : Re: [TRNSYS-users] Stored variables (C++)

 

Hey everyone,

 

I have TRNSYS 16 and I am programming a new module using C++.  I've had absolutely all the problems that have been mentioned in the past with regards to stored variables (such as un-updated TRNSYS.h file) and I've solved most of them, but I have been unable to solve one related to pointers.  


For some reason, in TRNSYS.h the functions setStorageVars and setStorageSize need pointer inputs (int*, double*) to work, as opposed to the simple int or double variables used in FORTRAN.  I have spent a lot of time and I have not being able to work this through, and I need to fix this within the next few days or it will have consequences on the project deadline =(

 

Does anybody have the answer to one of these two questions?

 

1) Do you have any example (*.ccp) of a module programmed in C++ that uses stored variables?  That would probably be easiest way to understand how to insert the correct inputs in the setStorageVars function, or

 

2) Do you know how to insert the 'nitems' and 'stored' array in a way that the setStorageVars function will understand?

 

The template generated for C++ does not address these issues and I am unsure how to fix them.

 

Any help would be highly appreciated!  Thanks!

 

Carlos Flores

Energy Research Program

Universidad de Chile




--

Carlos Flores

Project Officer

BSc, MSc (Mech Eng)

Department of Environment, Climate Change and Water
National Australian Built Environment Rating Scheme (NABERS Energy)

Sydney, Australia
T: (+61) 02 9995 5495
F: (+61) 02 9995 6388
W: www.nabers.com.au