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

AW: Transmit a String to a UserType



David,
thank you for your information and tips. The Format-statement-problem was just an example and does not really fit to my problem. 
Now I've found a solution. It uses a trick and is not really perfect, but it works.
The user-type is defined with one Parameter and the type of this paramter ist 'string'. If a string 'MyString' has to be available in the Fortran-Code, in the parameter-field I enter '1 * MyString'. TRNSYS interpretes this entry as '1', followed by a comment '* MyString'. The user-code then opens the *.dck-File and reads every line until it gets this string. Of course, string manipulations in Fortran are a little complicated, but it works without any errors.
 
There is another question according to this problem:
I open the *.dck file by using the command:
    OPEN( 17, FILE="Project1.dck")
I woult prefer it to get a file number that is generated dynamically. Is there any function implemented that I can use?
The file name "project1.dck" may be wrong if the user saves the *.dck file by using another name. I suppose there must be a way to get access to the actual *.dck-file. Maybe the variable "LUR" is helpful, but when using it I always got errors.
 
I hope I could explain my ideas and questions...
 
Regards
    Jochen
--

Dipl.-Ing. Jochen Wriske
Lehrstuhl für Technische Thermodynamik
RWTH Aachen
Tel. 0241 / 80 98153
Fax. 0241 / 80 92255
  


 -----Ursprüngliche Nachricht-----
Von: owner-trnsys@relay.doit.wisc.edu [mailto:owner-trnsys@relay.doit.wisc.edu]Im Auftrag von David Bradley
Gesendet: Dienstag, 8. April 2003 15:35
An: trnsys@relay.doit.wisc.edu
Betreff: Re: Transmit a String to a UserType



Jochen,
  Unfortunately there is no standard way for a Type to read a special card. In some cases, such as Type9, the special card is passed to the Type as part of a COMMON block. In the case of Type9, the array FOR( ) contains the format statement and is available to the Type as part of the /STRNGS/ common block. In other cases, such as Type25, Type26 and other printing devices, the Types aren't really Types at all but are kernal subroutines that are called with different information than a Type. The limitation is being removed in TRNSYS 16 where Types will be able to receive various kinds of format and labels statements. 

  In cases where I needed to pass string information to my own Type, I have gotten around the problem by defining a numerical parameter that corresponds to the string that I wanted to send. For example, an ON or and OFF can be sent as a 1 or a 0 to the component. If your Type needs to read a formatted data file then perhaps you could define a set of known format statements, put them directly into the code of the component, then choose between them using a parameter value. 
Cheers,
  David

At 01:44 PM 4/8/2003 +0200, you wrote:


Hello,
I'm trying to create a Type where I need to get a user-defined string. As
the component-parameters-card supports only numeric values, I tried to use a
special card. This corresponds to TYPE9, where the FORTRAN-format-statement
is entered in a special card.

But I have two problems:
1) By doing this, the *.dck-File gets the following entry (the string
entered in the special card is written correctly into the *.dck-file)

...
INPUTS 6
* [unconnected] Input1
0,0
* [unconnected] Input2
0,0
* [unconnected] Input3
0,0
* [unconnected] Input4
0,0
* [unconnected] Input5
0,0
* [unconnected] Input6
0,0
*** INITIAL INPUT VALUES
0 0 0 0 0 0
myUserString
*---------------------------------------------------------------------------
---
...

But Trnsys produces an error, because the characters 'myuserString' are
interpreted as another initial Input value. So Trnsys counts 7 Inputs and
that does not fit to the Statement 'INPUTS 6'.

2) The code of TYPE9 is quite complex to me. I don't understand how the
string is read out of the *.dck-file and made available in the Fortran-code.

Does anybody have some ideas?

Thanks!

Jochen

--
Dipl.-Ing. Jochen Wriske
Lehrstuhl für Technische Thermodynamik
RWTH Aachen
Tel. 0241 / 80 98153
Fax. 0241 / 80 92255

********************************************************************************* 
Thermal Energy System Specialists (TESS) 
David BRADLEY                           2916 Marketplace Drive - Suite 104 
Project Engineer                           Madison, WI 53719 
Phone: (608) 274-2577 USA 
Fax: (608) 278-1475 
E-mail: bradley@tess-inc.com 
Web Page:          www.tess-inc.com

"Providing software solutions for today's energy engineering projects" 
**************************************************************************** *****