DUECA/DUSIME
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
dueca::XmlSnapshot Struct Reference

An XmlSnapshot can be used to communicate RTW module settings (inputs, states, and parameters) from and to RTW modules. More...

#include <XmlSnapshot.hxx>

Inheritance diagram for dueca::XmlSnapshot:
Inheritance graph
[legend]
Collaboration diagram for dueca::XmlSnapshot:
Collaboration graph
[legend]

Public Types

typedef XmlSnapshot __ThisDCOType__
 typedef for internal reference
 
- Public Types inherited from dueca::Snapshot
enum  SnapCoding {
  UnSpecified , Base64 , JSON , XML ,
  Floats , Doubles , BinaryFile , FloatFile ,
  DoubleFile , JSONFile , XMLFile , Base64File
}
 Enumerated type for an automatically generated object class. More...
 
typedef Snapshot __ThisDCOType__
 typedef for internal reference
 

Public Member Functions

 XmlSnapshot ()
 default constructor.
 
 XmlSnapshot (const Snapshot &parent_Snapshot)
 Constructor with arguments.
 
 XmlSnapshot (const XmlSnapshot &o)
 copy constructor.
 
 XmlSnapshot (::dueca::AmorphReStore &r)
 constructor to restore an XmlSnapshot from amorphous storage.
 
 ~XmlSnapshot ()
 destructor.
 
void packData (::dueca::AmorphStore &s) const
 packs the XmlSnapshot into amorphous storage.
 
void packDataDiff (::dueca::AmorphStore &s, const XmlSnapshot &ref) const
 packs the XmlSnapshot into amorphous storage.
 
void unPackData (::dueca::AmorphReStore &s)
 unpacks the XmlSnapshot from an amorphous storage.
 
void unPackDataDiff (::dueca::AmorphReStore &s)
 unpacks the differences for XmlSnapshot from an amorphous storage.
 
bool operator== (const XmlSnapshot &o) const
 Test for equality.
 
bool operator!= (const XmlSnapshot &o) const
 Test for inequality.
 
XmlSnapshotoperator= (const XmlSnapshot &o)
 Assignment operator.
 
std::ostream & print (std::ostream &s) const
 prints the XmlSnapshot to a stream.
 
- Public Member Functions inherited from dueca::Snapshot
 Snapshot ()
 default constructor.
 
 Snapshot (const dueca::smartstring &data, const NameSet &originator, const SnapCoding &coding)
 Constructor with arguments.
 
 Snapshot (const Snapshot &o)
 copy constructor.
 
 Snapshot (::dueca::AmorphReStore &r)
 constructor to restore an Snapshot from amorphous storage.
 
 ~Snapshot ()
 destructor.
 
void packData (::dueca::AmorphStore &s) const
 packs the Snapshot into amorphous storage.
 
void packDataDiff (::dueca::AmorphStore &s, const Snapshot &ref) const
 packs the Snapshot into amorphous storage.
 
void unPackData (::dueca::AmorphReStore &s)
 unpacks the Snapshot from an amorphous storage.
 
void unPackDataDiff (::dueca::AmorphReStore &s)
 unpacks the differences for Snapshot from an amorphous storage.
 
bool operator== (const Snapshot &o) const
 Test for equality.
 
bool operator!= (const Snapshot &o) const
 Test for inequality.
 
Snapshotoperator= (const Snapshot &o)
 Assignment operator.
 
std::ostream & print (std::ostream &s) const
 prints the Snapshot to a stream.
 

Static Public Member Functions

static voidoperator new (size_t size)
 new operator "new", which places objects not on a heap, but in one of the memory arenas.
 
static void operator delete (void *p)
 new operator "delete", to go with the new version of operator new.
 
static voidoperator new (size_t size, XmlSnapshot *&o)
 placement "new", needed for stl.
 
- Static Public Member Functions inherited from dueca::Snapshot
static voidoperator new (size_t size)
 new operator "new", which places objects not on a heap, but in one of the memory arenas.
 
static void operator delete (void *p)
 new operator "delete", to go with the new version of operator new.
 
static voidoperator new (size_t size, Snapshot *&o)
 placement "new", needed for stl.
 

Static Public Attributes

static const char *const classname
 The name of this class.
 
static const uint32_t magic_check_number
 a "magic" number, hashed out of the class definition, that will be used to check consistency of the sent objects across the dueca nodes.
 
- Static Public Attributes inherited from dueca::Snapshot
static const char *const classname
 The name of this class.
 
static const uint32_t magic_check_number
 a "magic" number, hashed out of the class definition, that will be used to check consistency of the sent objects across the dueca nodes.
 

Additional Inherited Members

- Public Attributes inherited from dueca::Snapshot
dueca::smartstring data
 A place for the data, variable size.
 
NameSet originator
 Identifies the object that sent the snapshot.
 
SnapCoding coding
 Snapshot encoding, if specified.
 

Detailed Description

An XmlSnapshot can be used to communicate RTW module settings (inputs, states, and parameters) from and to RTW modules.

Common scenarios are for instance loading a MATLAB generated initial condition for your simulink model into your RTW model, or retrieving the current state of your model to store in an xml file (for instance for later use in MATLAB). DUECA's new-module script gives you the option to generate scripts that you can use to communicate state, input and parameter settings between simulink and DUECA. If you choose to use this, new-module generates MATLAB scripts to export simulink model settings to an xml file, and to import simulink model settings from an xml file. You can choose to edit the generated xml files by and. If you want, you can remove variables from the xml file that you know you will never change. Loading and saving of these xml files in DUECA should be done outside of the actual RTW module: preferably in your 'ECI' module. The following example shows how to load and send an xml snapshot:

// READ FROM FILE
ifstream fin("myxmlsnapshot.xml");
string line, strdata;
while(!fin.eof()) {
}
fin.close();
// SEND SNAPSHOT
XmlSnapshot *snap = new XmlSnapshot(strdata, NameSet(getEntity(), "my-rtw-module", ""));
w_xmlsnap_example.sendEvent(snap, ts);
This is a "light weight object" that enables you to read the latest set of data on a StreamChannelEnd...
Definition StreamReaderLatest.hxx:43
Name tuple as used in DUECA.
Definition NameSet.hxx:65
An XmlSnapshot can be used to communicate RTW module settings (inputs, states, and parameters) from a...
Definition XmlSnapshot.hxx:105
XmlSnapshot()
default constructor.

You can also use xml snapshots to store the current state in an xml file. This is done in two steps: first you send a command to the RTW module to prepare for a snapshot, at a certain time given by you. The RTW module then stores its states at the chosen time, to be sent in an xml snapshot when a second command is given: this is when you send the command to actually send the snapshot. The following three examples show how to retrieve a snapshot from the module with these two commands, and subsequently how to handle the reply:

// Send the command to the RTW module to prepare the snapshot
XmlSnapshot *snap = new XmlSnapshot(XmlSnapshot::PrepareXmlSnapshot, NameSet(getEntity(), "my-rtw-module", ""));
w_xmlsnap_example.sendEvent(snap, ts);
// Send the command to the RTW module to actually send the snapshot
XmlSnapshot *snap = new XmlSnapshot(XmlSnapshot::SendXmlSnapshot, NameSet(getEntity(), "my-rtw-module", ""));
w_xmlsnap_example.sendEvent(snap, ts);
// Act on incoming snapshots
if (r_xmlsnap_example.getNumWaitingEvents(ts))
{
ofstream fout("mynewxmlsnapshot.xml");
fout << in.data().accessData();
fout.close();
}
const T & data()
Access to the data.
Definition DataReader.hxx:456

Member Function Documentation

◆ operator new()

static void * dueca::XmlSnapshot::operator new ( size_t size)
static

new operator "new", which places objects not on a heap, but in one of the memory arenas.

This to speed up memory management.

◆ packDataDiff()

void dueca::XmlSnapshot::packDataDiff ( ::dueca::AmorphStore & s,
const XmlSnapshot & ref ) const

packs the XmlSnapshot into amorphous storage.

only differences with a previous object are packed.


The documentation for this struct was generated from the following file: