[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [certi-dev] ForwardSim HLA Blockset: data coding
From: |
Jean-Philippe Lebel |
Subject: |
Re: [certi-dev] ForwardSim HLA Blockset: data coding |
Date: |
Wed, 18 Jul 2012 15:54:29 -0400 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 |
Hi Jon,
I'm the lead developer of the HLA Toolbox.
You can manually decode the received value by using the following code
union{
double ds;
char cs[8];
}before;
before.cs= Your received 8 bytes array here;
You can then access the double by using before.ds
Depending on the endianess, you might need to swap bytes.
for(int i=0;i<8;i++) newarray[i] = before.cs[8-1-i] ;
Good luck
JPL
On 18/07/2012 9:08 AM, REGUEIRO Jon wrote:
Hi,
I don't know if someone has worked on this before but I will try...
I have just begun to work with HLA Blockset for Simulink, a commercial
product developed by ForwardSim. There are two federates. The federate
in Simulink is updating 5 attributes that the federate in Linux is
subscribed to.
This Simulink model uses a block called "encode" to convert double
variables to values usable by RTI. The following data types can be
chosen:
-------------
HLAoctet
HLAbyte
HLAoctetPairBE
HLAinteger16BE
HLAinteger32BE
HLAinteger64BE
HLAfloat32BE
HLAfloat64BE
HLAoctetPairLE
HLAinteger16LE
HLAinteger32LE
HLAinteger64LE
HLAfloat32LE
HLAfloat64LE
--------------
The federate written in C++ uses the class called "MessageBuffer" to
manage data. I am using the function called "read_double()" [without
s] to read the buffer, but it gives an error and stops the execution.
Both machines are little endian, so I have been coding data to
"HLAfloat64LE". I have tried with different combinations but I still
have not found my mistake.
Than you in advance!
Jon Regueiro
--
Jean-Philippe Lebel, ing., MBA
ForwardSim inc.
Tel.: 418-650-3493 ext 6001
Fax.: 418-650-5661