Datafox DFCom - API  04.03.18
Dokumentation zur Datafox Kommunikationsbibliothek (DFComDLL.dll / DFCom_x64.dll)
document_studio.h
gehe zur Dokumentation dieser Datei
1 #ifndef DOCUMENT_STUDIO_H
2 #define DOCUMENT_STUDIO_H
3 
4 #include "file/file_aes.h"
5 #include "file/file_xml.h"
6 #include "interface/table_structure.h"
7 #include "channel/channel_bridge.h"
8 #include <unordered_map>
9 
10 class EntryDevice;
11 class EntryTableRecord;
12 class EntryTable;
13 class EntryTableField;
14 class EntryTableList;
15 class EntryHandling;
16 class EntrySignalProcessing;
17 class EntryEventChains;
18 class EntryIOModule;
19 class EntryAccessControl2;
20 class EntryEnergieSchemes;
21 
23 {
24 public:
25  DocumentStudio( const std::string &studioVersion, const std::string &libraryVersion );
27 
28 // Flags fuer den Dokumentzustand.
29 public:
30  enum class ResultCodes
31  {
32  Success,
52  };
53 
54  struct Result
55  {
57  {
58  }
59 
60  Result( const Result &rhs )
61  {
62  *this = rhs;
63  }
64 
65  Result( ResultCodes resCode )
66  : code( resCode )
67  {
68  }
69 
70  Result( ResultCodes resCode, const std::vector<std::string> &data )
71  : code( resCode )
72  , additionalData( data )
73  {
74  }
75 
76  operator bool() const
77  {
78  return code == ResultCodes::Success;
79  }
80 
81  Result &operator=( const Result &rhs )
82  {
83  if ( this != &rhs )
84  {
85  code = rhs.code;
86  additionalData.clear();
88  }
89  return *this;
90  }
91 
93  std::vector<std::string> additionalData{};
94  };
95 
98 
99 // Dateiname
100 public:
101  const std::string &filePath()
102  {
103  return m_filePath;
104  }
105 
106  void setFilePath( const std::string &fileName )
107  {
108  m_filePath = fileName;
109  }
110 
111 private:
112  std::string m_filePath;
113 
114 // StudioFile
115 public:
116  FileAES &fileAES()
117  {
118  return m_fileAES;
119  }
120  FileXML &fileXML()
121  {
122  return m_fileXML;
123  }
124  FileType currentFileType()
125  {
126  return m_currentFileType;
127  }
128  void setFileType( FileType type )
129  {
130  m_currentFileType = type;
131  }
132 
133  tinyxml2::XMLElement *xmlParentNode()
134  {
135  return m_parentNodeXML;
136  }
137  tinyxml2::XMLElement *setXmlParentNode( tinyxml2::XMLElement *newParent )
138  {
139  auto oldParent = m_parentNodeXML;
140  m_parentNodeXML = newParent;
141  return oldParent;
142  }
143 
144  void setVersions( const std::string &studioVersion, const std::string &libraryVersion );
145  void setVersions( uint32_t studioVersion, uint32_t libraryVersion );
146 
147  std::string studioVersion();
148  std::string minStudioVersion();
149  std::string shouldStudioVersion();
150  std::string minLibraryVersion();
151  std::string shouldLibraryVersion();
152  std::string minFirmware1Version();
153  std::string shouldFirmware1Version();
155  std::string minFirmware2Version();
156  std::string shouldFirmware2Version();
158  std::string minFirmware3Version();
159  std::string shouldFirmware3Version();
161 
162  void SetDocumentDefault( int32_t flags = 0 );
163 
164  std::string fileNameList( int32_t num );
165  void setFileNameList( int32_t num, const std::string &fileName );
166 
167  std::string fileNameListAccessControl( int32_t num );
168  void setFileNameListAccessControl( int32_t num, const std::string &fileName );
169 
170  std::string fileNameExtended( int32_t num );
171  void setFileNameExtended( int32_t num, const std::string &fileName );
172 
173 private:
174  FileAES m_fileAES;
175  FileXML m_fileXML;
176  std::string versionFormat( uint32_t version );
177  tinyxml2::XMLElement *m_parentNodeXML{};
178  FileType m_currentFileType{ FileType::AES_AEL };
179 
180 public:
181  const std::string &errorText()
182  {
183  return m_errorText;
184  }
185 
186  void setErrorText( const std::string &errorText )
187  {
188  m_errorText = errorText;
189  }
190 
191 private:
192  std::string m_errorText;
193 
194 public:
195  std::list<std::string> globalVariablesName();
196  std::unordered_map<std::string, std::string> globalVariablesValueDefault();
197 
198  // Dokumenttree <-> Dokumentfile
199 public:
201  Result MkSetupImage( EntryDevice &root, uint32_t &setupSize );
203  std::string setupTypeName( SetupType setupType )
204  {
205  return SetupTypeName.at( setupType );
206  }
207 
208 private:
209  EntryDevice *m_root;
210  void SetRootDefault( SetupType setupType );
211 
212 public:
214  Result documentOpen( const std::string &filePath, bool ignoreStudioVersion,
215  std::function<bool( const std::string & filePath, const std::string & backupFilePath )> shouldCreateBackup = nullptr,
216  std::function<bool( const std::string & filePath, const SoftwarebuildVersion & version, const std::string & component )> downgradeInfo = nullptr );
217  bool documentSave();
218  bool documentSaveAs( FileType fileType, const std::string &filePath );
219 
220 private:
221  Result documentOpen_AES( const std::string &filePath, bool ignoreStudioVersion,
222  std::function<bool( const std::string & filePath, const std::string & backupFilePath )> shouldCreateBackup,
223  std::function<bool( const std::string & filePath, const SoftwarebuildVersion & version, const std::string & component )> downgradeInfo );
224  Result documentOpen_XML( const std::string &filePath, bool ignoreStudioVersion,
225  std::function<bool( const std::string & filePath, const std::string & backupFilePath )> shouldCreateBackup,
226  std::function<bool( const std::string & filePath, const SoftwarebuildVersion & version, const std::string & component )> downgradeInfo );
227 
228 
229 
230  // Generierte Funktionen für die Meldungstabellen
231 public:
232  int32_t SaveCheck();
233 
234  // Implementierung
235 public:
236  EntryDevice &root();
237  EntryTableRecord &rootTableRecord();
238  EntryTableList &rootTableList();
239  EntryHandling &rootHandling();
240  EntrySignalProcessing &rootSignalProcessing();
241  EntryEventChains &rootEventChains();
242  EntryIOModule &rootIOModule();
243  EntryAccessControl2 &rootAccessControl();
244  EntryEnergieSchemes &rootEnergieSchemes();
245 
246 public:
247  bool IsEmpty();
249  uint32_t GetMDEEKFlashSize();
252  uint32_t GetFlashSetupSize();
254 
261 
262  void GetListName( uint8_t ucNum, char *szBuf );
263  std::string listName( int32_t num );
264 
265  void GetAccessControlListName( uint8_t ucNum, char *szBuf );
266  std::string listNameAccessControl( int32_t num );
267 
268  int32_t globalVariableIndex( uint8_t ucDefNum );
269 
271  std::string globalVariableName( uint8_t num );
272 
273  const char *setupPassword();
274 
275 protected:
276  char *m_setupPassword[17]; // Passwort fuer Kommunikationsschutz
277 
278 public: // Optionen fuer Einspielen des Dokumentes
279  uint8_t m_flagsLoadSetup; // Bit 1: Nach einspielen, die nicht vorbelegten GV's loeschen.
280  // Bit 2: Nach einspielen, die Systemvariablen der digitalen Eingaenge loeschen.
281 
282  // Datensatz und Listenbeschreibungen
283 public:
285  EntryTable *GetRecordTable( uint8_t num );
286  EntryTableField *GetRecordTableField( uint8_t numTable, uint8_t numField );
287 
288  uint8_t GetListTableCount();
289  EntryTable *GetListTable( uint8_t num );
290  EntryTableField *GetListTableField( uint8_t numTable, uint8_t numField );
291 
293  EntryTable *GetAccessControlTable( uint8_t num );
294  EntryTableField *GetAccessControlTableField( uint8_t numTable, uint8_t numField );
295 
296  // TableType
297 #define TT_RECORD 0
298 #define TT_LIST 1
299 #define TT_ACCESS_CONTROL 2
300 
301 public:
302  int32_t GetTableCount( uint8_t typeTable );
303  int32_t GetTable( uint8_t num, StructTable &table, uint8_t typeTable );
304  int32_t GetTableField( uint8_t numTable, uint8_t numField, StructTableField &field, uint8_t typeTable );
305 };
306 
307 class RecordStructure : public ITableStructure
308 {
309 public:
311  {
312  m_document = doc;
313  }
314 
315 public:
316  // Aufbau der Tabelle ermitteln.
317  int32_t count()
318  {
319  return m_document->GetTableCount( TT_RECORD );
320  }
321 
322  int32_t table( uint8_t num, StructTable &table )
323  {
324  return m_document->GetTable( num, table, TT_RECORD );
325  }
326 
327  int32_t field( uint8_t numTable, uint8_t numField, StructTableField &field )
328  {
329  return m_document->GetTableField( numTable, numField, field, TT_RECORD );
330  }
331 
332 private:
333  DocumentStudio *m_document;
334 };
335 
336 class ListStructure : public ITableStructure
337 {
338 public:
340  {
341  m_document = doc;
342  }
343 
344 public:
345  // Aufbau der Tabelle ermitteln.
346  int32_t count()
347  {
348  return m_document->GetTableCount( TT_LIST );
349  }
350 
351  int32_t table( uint8_t num, StructTable &table )
352  {
353  return m_document->GetTable( num, table, TT_LIST );
354  }
355 
356  int32_t field( uint8_t numTable, uint8_t numField, StructTableField &field )
357  {
358  return m_document->GetTableField( numTable, numField, field, TT_LIST );
359  }
360 
361 private:
362  DocumentStudio *m_document;
363 };
364 
365 class ListAccessControlStructure : public ITableStructure
366 {
367 public:
369  {
370  m_document = doc;
371  }
372 
373 public:
374  // Aufbau der Tabelle ermitteln.
375  int32_t count()
376  {
377  return m_document->GetTableCount( TT_ACCESS_CONTROL );
378  }
379 
380  int32_t table( uint8_t num, StructTable &table )
381  {
382  return m_document->GetTable( num, table, TT_ACCESS_CONTROL );
383  }
384 
385  int32_t field( uint8_t numTable, uint8_t numField, StructTableField &field )
386  {
387  return m_document->GetTableField( numTable, numField, field, TT_ACCESS_CONTROL );
388  }
389 
390 private:
391  DocumentStudio *m_document;
392 };
393 
394 #endif // DOCUMENT_STUDIO_H
Definition: document_studio.h:23
void setVersions(uint32_t studioVersion, uint32_t libraryVersion)
EntryDevice & root()
FileType currentFileType()
Definition: document_studio.h:124
EntryHandling & rootHandling()
std::string shouldFirmware1Version()
Sollteversion der zu verwendenden Firmware 04.01.xx.xx, um alle gewaehlten Einstellungen zu unterstue...
bool documentSave()
EntryTable * GetAccessControlTable(uint8_t num)
EntryTableField * GetListTableField(uint8_t numTable, uint8_t numField)
void setVersions(const std::string &studioVersion, const std::string &libraryVersion)
int32_t globalVariableIndex(uint8_t ucDefNum)
EntryTableField * GetRecordTableField(uint8_t numTable, uint8_t numField)
std::string studioVersion()
Studioversion mit der die Datei zuletzt abgespeichert wurde.
int32_t GetTable(uint8_t num, StructTable &table, uint8_t typeTable)
int32_t IsAnalogStatusAvailable()
EntrySignalProcessing & rootSignalProcessing()
int32_t IsCounterAvailable()
std::string shouldFirmware2Version()
Sollteversion der zu verwendenden Firmware 04.02.xx.xx, um alle gewaehlten Einstellungen zu unterstue...
EntryTable * GetListTable(uint8_t num)
uint8_t globalVariableCount()
bool supportFirmware1Version()
Wird die Version 04.01.xx der Firmware unterstützt.
uint8_t GetListTableCount()
void GetAccessControlListName(uint8_t ucNum, char *szBuf)
Result documentNew(SetupType setupType)
uint8_t GetAccessControlTableCount()
bool isAccessControlExtension()
void setFileType(FileType type)
Definition: document_studio.h:128
const char * setupPassword()
std::string minLibraryVersion()
Mindestversion der zu verwendenden DFComDLL fuer die korrekte Uebertragung der Setupdaten.
uint32_t GetFlashSetupSize4_2()
std::string fileNameListAccessControl(int32_t num)
void setFilePath(const std::string &fileName)
Definition: document_studio.h:106
EntryTableList & rootTableList()
std::string listNameAccessControl(int32_t num)
EntryTableRecord & rootTableRecord()
Result MkSetupImage(EntryDevice &root, uint32_t &setupSize)
std::string setupTypeName(SetupType setupType)
Definition: document_studio.h:203
std::string listName(int32_t num)
std::string minFirmware1Version()
Mindestversion der zu verwendenden Firmware 04.01.xx.xx, um alle gewaehlten Einstellungen zu unterstu...
std::string shouldFirmware3Version()
Sollteversion der zu verwendenden Firmware 04.03.xx.xx, um alle gewaehlten Einstellungen zu unterstue...
tinyxml2::XMLElement * xmlParentNode()
Definition: document_studio.h:133
void setFileNameExtended(int32_t num, const std::string &fileName)
const std::string & errorText()
Definition: document_studio.h:181
uint32_t GetFlashSetupSize()
uint32_t GetEntranceEKFlashSize()
ResultCodes
Definition: document_studio.h:31
bool documentSaveAs(FileType fileType, const std::string &filePath)
int32_t IsSystemMessageAvailable()
bool isAccessControl()
Result documentOpen(const std::string &filePath, bool ignoreStudioVersion, std::function< bool(const std::string &filePath, const std::string &backupFilePath)> shouldCreateBackup=nullptr, std::function< bool(const std::string &filePath, const SoftwarebuildVersion &version, const std::string &component)> downgradeInfo=nullptr)
uint8_t m_flagsLoadSetup
Definition: document_studio.h:279
bool supportFirmware2Version()
Wird die Version 04.02.xx der Firmware unterstützt.
int32_t GetTableCount(uint8_t typeTable)
std::string shouldLibraryVersion()
Sollteversion der zu verwendenden DFComDLL fuer die korrekte Uebertragung der Setupdaten.
std::string fileNameList(int32_t num)
std::string fileNameExtended(int32_t num)
std::string minFirmware2Version()
Mindestversion der zu verwendenden Firmware 04.02.xx.xx, um alle gewaehlten Einstellungen zu unterstu...
const std::string & filePath()
Definition: document_studio.h:101
char * m_setupPassword[17]
Definition: document_studio.h:276
int32_t GetTableField(uint8_t numTable, uint8_t numField, StructTableField &field, uint8_t typeTable)
int32_t IsAnalogValueAvailable()
uint32_t GetEntrance2EKFlashSize()
Result BuildRootFromImage(SetupType setupType)
EntryIOModule & rootIOModule()
void setErrorText(const std::string &errorText)
Definition: document_studio.h:186
std::string minFirmware3Version()
Mindestversion der zu verwendenden Firmware 04.03.xx.xx, um alle gewaehlten Einstellungen zu unterstu...
EntryAccessControl2 & rootAccessControl()
uint32_t GetMDEEKFlashSize()
int32_t SaveCheck()
void SetDocumentDefault(int32_t flags=0)
void setFileNameListAccessControl(int32_t num, const std::string &fileName)
bool supportFirmware3Version()
Wird die Version 04.03.xx der Firmware unterstützt.
std::string shouldStudioVersion()
Sollteversion des einzusetzenden Studios, um alle enthaltenen Daten zu unterstuetzen.
DocumentStudio(const std::string &studioVersion, const std::string &libraryVersion)
EntryTableField * GetAccessControlTableField(uint8_t numTable, uint8_t numField)
std::string minStudioVersion()
Mindestversion des einzusetzenden Studios, um alle enthaltenen Daten zu unterstuetzen.
EntryEnergieSchemes & rootEnergieSchemes()
std::string globalVariableName(uint8_t num)
FileAES & fileAES()
Definition: document_studio.h:116
EntryEventChains & rootEventChains()
std::unordered_map< std::string, std::string > globalVariablesValueDefault()
uint8_t GetRecordTableCount()
tinyxml2::XMLElement * setXmlParentNode(tinyxml2::XMLElement *newParent)
Definition: document_studio.h:137
void GetListName(uint8_t ucNum, char *szBuf)
int32_t IsTimerInputChainAvailable()
std::list< std::string > globalVariablesName()
uint32_t GetExtendedFlashSize()
uint32_t m_flashSetupSize
Definition: document_studio.h:200
int32_t IsFunctionAvailable()
void setFileNameList(int32_t num, const std::string &fileName)
EntryTable * GetRecordTable(uint8_t num)
FileXML & fileXML()
Definition: document_studio.h:120
Definition: document_studio.h:366
int32_t field(uint8_t numTable, uint8_t numField, StructTableField &field)
Definition: document_studio.h:385
int32_t table(uint8_t num, StructTable &table)
Definition: document_studio.h:380
int32_t count()
Definition: document_studio.h:375
ListAccessControlStructure(DocumentStudio *doc)
Definition: document_studio.h:368
Definition: document_studio.h:337
int32_t field(uint8_t numTable, uint8_t numField, StructTableField &field)
Definition: document_studio.h:356
int32_t table(uint8_t num, StructTable &table)
Definition: document_studio.h:351
int32_t count()
Definition: document_studio.h:346
ListStructure(DocumentStudio *doc)
Definition: document_studio.h:339
Definition: document_studio.h:308
RecordStructure(DocumentStudio *doc)
Definition: document_studio.h:310
int32_t field(uint8_t numTable, uint8_t numField, StructTableField &field)
Definition: document_studio.h:327
int32_t table(uint8_t num, StructTable &table)
Definition: document_studio.h:322
int32_t count()
Definition: document_studio.h:317
#define TT_RECORD
Definition: document_studio.h:297
#define TT_LIST
Definition: document_studio.h:298
#define TT_ACCESS_CONTROL
Definition: document_studio.h:299
Definition: document_studio.h:55
Result(ResultCodes resCode, const std::vector< std::string > &data)
Definition: document_studio.h:70
ResultCodes code
Definition: document_studio.h:92
std::vector< std::string > additionalData
Definition: document_studio.h:93
Result(const Result &rhs)
Definition: document_studio.h:60
Result()
Definition: document_studio.h:56
Result & operator=(const Result &rhs)
Definition: document_studio.h:81
Result(ResultCodes resCode)
Definition: document_studio.h:65
Diese Struktur ist eine Übergangsstruktur von StructRecordField auf StructTable2Field.
Definition: studio_setup_structs.h:1493
Diese Struktur ist eine Übergangsstruktur von StructRecordDescription auf StructTable2.
Definition: studio_setup_structs.h:1408
SetupType
Da die Setupdateien für unterschiedliche Geräte sein können, wird ein mapping des Gerätetypes auf den...
Definition: studio_setup_structs.h:132

© 2003-2021 Datafox GmbH