Commit 09f407ca authored by Marcus Nordenberg's avatar Marcus Nordenberg

update gsdml parser

parent c65141e0
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
class pn_gsdml; class pn_gsdml;
class gsdml_Valuelist; class gsdml_Valuelist;
typedef struct { typedef struct
{
char name[32]; char name[32];
pwr_tCid cid; pwr_tCid cid;
} gsdml_sModuleClass; } gsdml_sModuleClass;
...@@ -56,18 +57,21 @@ typedef char* gsdml_tAllocatedString; ...@@ -56,18 +57,21 @@ typedef char* gsdml_tAllocatedString;
typedef char gsdml_tNormalizedString[80]; typedef char gsdml_tNormalizedString[80];
typedef char gsdml_tToken[80]; typedef char gsdml_tToken[80];
typedef char gsdml_tTokenList[80]; typedef char gsdml_tTokenList[80];
typedef struct { typedef struct
{
char str[160]; char str[160];
gsdml_Valuelist* list; gsdml_Valuelist* list;
} gsdml_tValueList; } gsdml_tValueList;
typedef char gsdml_tEnum[80]; typedef char gsdml_tEnum[80];
typedef char gsdml_tId[80]; typedef char gsdml_tId[80];
typedef char gsdml_tIdT[256]; typedef char gsdml_tIdT[256];
typedef struct { typedef struct
{
gsdml_tIdT ref; gsdml_tIdT ref;
void* p; void* p;
} gsdml_tRefIdT; } gsdml_tRefIdT;
typedef struct { typedef struct
{
char ref[80]; char ref[80];
void* p; void* p;
} gsdml_tRefId; } gsdml_tRefId;
...@@ -233,16 +237,19 @@ typedef enum { ...@@ -233,16 +237,19 @@ typedef enum {
gsdml_eTag_Language, gsdml_eTag_Language,
gsdml_eTag_Text, gsdml_eTag_Text,
gsdml_eTag_CertificationInfo, gsdml_eTag_CertificationInfo,
gsdml_eTag_ParameterRef,
gsdml_eTag_MenuList,
gsdml_eTag_MenuItem,
gsdml_eTag_MenuRef,
gsdml_eTag__ gsdml_eTag__
} gsdml_eTag; } gsdml_eTag;
#define VL_END 0xffffffff #define VL_END 0xffffffff
class gsdml_ValuelistValue { class gsdml_ValuelistValue
{
public: public:
gsdml_ValuelistValue(unsigned int v) : value1(v), is_range(false) gsdml_ValuelistValue(unsigned int v) : value1(v), is_range(false) {}
{
}
gsdml_ValuelistValue(unsigned int v1, unsigned int v2) gsdml_ValuelistValue(unsigned int v1, unsigned int v2)
: value1(v1), value2(v2), is_range(true) : value1(v1), value2(v2), is_range(true)
{ {
...@@ -252,7 +259,8 @@ public: ...@@ -252,7 +259,8 @@ public:
bool is_range; bool is_range;
}; };
class gsdml_Valuelist { class gsdml_Valuelist
{
public: public:
gsdml_Valuelist(char* str); gsdml_Valuelist(char* str);
std::vector<gsdml_ValuelistValue> value; std::vector<gsdml_ValuelistValue> value;
...@@ -261,13 +269,11 @@ public: ...@@ -261,13 +269,11 @@ public:
void sort(); void sort();
int parse(char* str); int parse(char* str);
bool in_list(unsigned int); bool in_list(unsigned int);
unsigned int sts() unsigned int sts() { return status; }
{
return status;
}
}; };
class gsdml_ValuelistIterator { class gsdml_ValuelistIterator
{
public: public:
gsdml_ValuelistIterator(gsdml_Valuelist* vl) gsdml_ValuelistIterator(gsdml_Valuelist* vl)
: valuelist(vl), current_value(0), initiated(false) : valuelist(vl), current_value(0), initiated(false)
...@@ -276,10 +282,7 @@ public: ...@@ -276,10 +282,7 @@ public:
gsdml_Valuelist* valuelist; gsdml_Valuelist* valuelist;
unsigned int next(); unsigned int next();
unsigned int begin(); unsigned int begin();
unsigned int end() unsigned int end() { return VL_END; }
{
return VL_END;
}
unsigned int current_value; unsigned int current_value;
unsigned int current_idx; unsigned int current_idx;
bool initiated; bool initiated;
...@@ -287,11 +290,10 @@ public: ...@@ -287,11 +290,10 @@ public:
#define VLS_END 0xefffffff #define VLS_END 0xefffffff
class gsdml_SValuelistValue { class gsdml_SValuelistValue
{
public: public:
gsdml_SValuelistValue(int v) : value1(v), is_range(false) gsdml_SValuelistValue(int v) : value1(v), is_range(false) {}
{
}
gsdml_SValuelistValue(int v1, int v2) : value1(v1), value2(v2), is_range(true) gsdml_SValuelistValue(int v1, int v2) : value1(v1), value2(v2), is_range(true)
{ {
} }
...@@ -300,7 +302,8 @@ public: ...@@ -300,7 +302,8 @@ public:
bool is_range; bool is_range;
}; };
class gsdml_SValuelist { class gsdml_SValuelist
{
public: public:
gsdml_SValuelist(char* str); gsdml_SValuelist(char* str);
std::vector<gsdml_SValuelistValue> value; std::vector<gsdml_SValuelistValue> value;
...@@ -309,13 +312,11 @@ public: ...@@ -309,13 +312,11 @@ public:
void sort(); void sort();
int parse(char* str); int parse(char* str);
bool in_list(int); bool in_list(int);
unsigned int sts() unsigned int sts() { return status; }
{
return status;
}
}; };
class gsdml_SValuelistIterator { class gsdml_SValuelistIterator
{
public: public:
gsdml_SValuelistIterator(gsdml_SValuelist* vl) gsdml_SValuelistIterator(gsdml_SValuelist* vl)
: valuelist(vl), current_value(0), initiated(false) : valuelist(vl), current_value(0), initiated(false)
...@@ -324,20 +325,16 @@ public: ...@@ -324,20 +325,16 @@ public:
gsdml_SValuelist* valuelist; gsdml_SValuelist* valuelist;
int next(); int next();
int begin(); int begin();
int end() int end() { return VL_END; }
{
return VL_END;
}
int current_value; int current_value;
unsigned int current_idx; unsigned int current_idx;
bool initiated; bool initiated;
}; };
class gsdml_FValuelistValue { class gsdml_FValuelistValue
{
public: public:
gsdml_FValuelistValue(double v) : value1(v), is_range(false) gsdml_FValuelistValue(double v) : value1(v), is_range(false) {}
{
}
gsdml_FValuelistValue(double v1, double v2) gsdml_FValuelistValue(double v1, double v2)
: value1(v1), value2(v2), is_range(true) : value1(v1), value2(v2), is_range(true)
{ {
...@@ -347,7 +344,8 @@ public: ...@@ -347,7 +344,8 @@ public:
bool is_range; bool is_range;
}; };
class gsdml_FValuelist { class gsdml_FValuelist
{
public: public:
gsdml_FValuelist(char* str); gsdml_FValuelist(char* str);
std::vector<gsdml_FValuelistValue> value; std::vector<gsdml_FValuelistValue> value;
...@@ -356,25 +354,25 @@ public: ...@@ -356,25 +354,25 @@ public:
void sort(); void sort();
int parse(char* str); int parse(char* str);
bool in_list(double val); bool in_list(double val);
unsigned int sts() unsigned int sts() { return status; }
{
return status;
}
}; };
typedef struct { typedef struct
{
gsdml_tString80 Version; gsdml_tString80 Version;
gsdml_tString80 Encoding; gsdml_tString80 Encoding;
} gsdml_sXml; } gsdml_sXml;
class gsdml_Xml { class gsdml_Xml
{
public: public:
gsdml_Xml(pn_gsdml* g); gsdml_Xml(pn_gsdml* g);
gsdml_sXml Body; gsdml_sXml Body;
pn_gsdml* gsdml; pn_gsdml* gsdml;
}; };
typedef struct { typedef struct
{
gsdml_tString80 ProfileIdentification; gsdml_tString80 ProfileIdentification;
gsdml_tString80 ProfileRevision; gsdml_tString80 ProfileRevision;
gsdml_tString80 ProfileName; gsdml_tString80 ProfileName;
...@@ -385,7 +383,8 @@ typedef struct { ...@@ -385,7 +383,8 @@ typedef struct {
gsdml_tString80 ProfileTechnology; gsdml_tString80 ProfileTechnology;
} gsdml_sProfileHeader; } gsdml_sProfileHeader;
class gsdml_ProfileHeader { class gsdml_ProfileHeader
{
public: public:
gsdml_ProfileHeader(pn_gsdml* g); gsdml_ProfileHeader(pn_gsdml* g);
gsdml_sProfileHeader Body; gsdml_sProfileHeader Body;
...@@ -393,14 +392,16 @@ public: ...@@ -393,14 +392,16 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16hex VendorID; gsdml_tUnsigned16hex VendorID;
gsdml_tUnsigned16hex DeviceID; gsdml_tUnsigned16hex DeviceID;
gsdml_tRefIdT InfoText; gsdml_tRefIdT InfoText;
gsdml_tToken VendorName; gsdml_tToken VendorName;
} gsdml_sDeviceIdentity; } gsdml_sDeviceIdentity;
class gsdml_DeviceIdentity { class gsdml_DeviceIdentity
{
public: public:
gsdml_DeviceIdentity(pn_gsdml* g); gsdml_DeviceIdentity(pn_gsdml* g);
gsdml_sDeviceIdentity Body; gsdml_sDeviceIdentity Body;
...@@ -409,12 +410,14 @@ public: ...@@ -409,12 +410,14 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tString80 MainFamily; gsdml_tString80 MainFamily;
gsdml_tString80 ProductFamily; gsdml_tString80 ProductFamily;
} gsdml_sDeviceFunction; } gsdml_sDeviceFunction;
class gsdml_DeviceFunction { class gsdml_DeviceFunction
{
public: public:
gsdml_DeviceFunction(pn_gsdml* g); gsdml_DeviceFunction(pn_gsdml* g);
gsdml_sDeviceFunction Body; gsdml_sDeviceFunction Body;
...@@ -422,7 +425,8 @@ public: ...@@ -422,7 +425,8 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tRefIdT CategoryRef; gsdml_tRefIdT CategoryRef;
gsdml_tRefIdT SubCategory1Ref; gsdml_tRefIdT SubCategory1Ref;
gsdml_tRefIdT Name; gsdml_tRefIdT Name;
...@@ -435,7 +439,8 @@ typedef struct { ...@@ -435,7 +439,8 @@ typedef struct {
gsdml_tString ProductFamily; gsdml_tString ProductFamily;
} gsdml_sModuleInfo; } gsdml_sModuleInfo;
class gsdml_ModuleInfo { class gsdml_ModuleInfo
{
public: public:
gsdml_ModuleInfo(pn_gsdml* g); gsdml_ModuleInfo(pn_gsdml* g);
gsdml_sModuleInfo Body; gsdml_sModuleInfo Body;
...@@ -444,30 +449,35 @@ public: ...@@ -444,30 +449,35 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16 Value; gsdml_tUnsigned16 Value;
gsdml_tBoolean AdjustSupported; gsdml_tBoolean AdjustSupported;
} gsdml_sMAUTypeItem; } gsdml_sMAUTypeItem;
typedef struct { typedef struct
{
gsdml_tString ConformanceClass; gsdml_tString ConformanceClass;
gsdml_tString ApplicationClass; gsdml_tString ApplicationClass;
gsdml_tString NetloadClass; gsdml_tString NetloadClass;
} gsdml_sCertificationInfo; } gsdml_sCertificationInfo;
class gsdml_CertificationInfo { class gsdml_CertificationInfo
{
public: public:
gsdml_CertificationInfo(pn_gsdml* g); gsdml_CertificationInfo(pn_gsdml* g);
gsdml_sCertificationInfo Body; gsdml_sCertificationInfo Body;
pn_gsdml* gsdml; pn_gsdml* gsdml;
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16 SubslotNumber; gsdml_tUnsigned16 SubslotNumber;
gsdml_tRefId TextId; gsdml_tRefId TextId;
} gsdml_sSubslotItem; } gsdml_sSubslotItem;
class gsdml_SubslotItem { class gsdml_SubslotItem
{
public: public:
gsdml_SubslotItem(pn_gsdml* g); gsdml_SubslotItem(pn_gsdml* g);
gsdml_sSubslotItem Body; gsdml_sSubslotItem Body;
...@@ -475,11 +485,10 @@ public: ...@@ -475,11 +485,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_SubslotList { class gsdml_SubslotList
{
public: public:
gsdml_SubslotList(pn_gsdml* g) : gsdml(g) gsdml_SubslotList(pn_gsdml* g) : gsdml(g) {}
{
}
~gsdml_SubslotList(); ~gsdml_SubslotList();
std::vector<gsdml_SubslotItem*> SubslotItem; std::vector<gsdml_SubslotItem*> SubslotItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
...@@ -487,13 +496,15 @@ public: ...@@ -487,13 +496,15 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16 MaxInputLength; gsdml_tUnsigned16 MaxInputLength;
gsdml_tUnsigned16 MaxOutputLength; gsdml_tUnsigned16 MaxOutputLength;
gsdml_tUnsigned16 MaxDataLength; gsdml_tUnsigned16 MaxDataLength;
} gsdml_sIOConfigData; } gsdml_sIOConfigData;
class gsdml_IOConfigData { class gsdml_IOConfigData
{
public: public:
gsdml_IOConfigData(pn_gsdml* g); gsdml_IOConfigData(pn_gsdml* g);
gsdml_sIOConfigData Body; gsdml_sIOConfigData Body;
...@@ -501,14 +512,16 @@ public: ...@@ -501,14 +512,16 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tRefId ModuleItemTarget; gsdml_tRefId ModuleItemTarget;
gsdml_tValueList AllowedInSlots; gsdml_tValueList AllowedInSlots;
gsdml_tValueList UsedInSlots; gsdml_tValueList UsedInSlots;
gsdml_tValueList FixedInSlots; gsdml_tValueList FixedInSlots;
} gsdml_sModuleItemRef; } gsdml_sModuleItemRef;
class gsdml_ModuleItemRef { class gsdml_ModuleItemRef
{
public: public:
gsdml_ModuleItemRef(pn_gsdml* g); gsdml_ModuleItemRef(pn_gsdml* g);
gsdml_sModuleItemRef Body; gsdml_sModuleItemRef Body;
...@@ -518,11 +531,10 @@ public: ...@@ -518,11 +531,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_UseableModules { class gsdml_UseableModules
{
public: public:
gsdml_UseableModules(pn_gsdml* g) : gsdml(g) gsdml_UseableModules(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_ModuleItemRef*> ModuleItemRef; std::vector<gsdml_ModuleItemRef*> ModuleItemRef;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_UseableModules(); ~gsdml_UseableModules();
...@@ -530,12 +542,14 @@ public: ...@@ -530,12 +542,14 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned8 BitOffset; gsdml_tUnsigned8 BitOffset;
gsdml_tRefIdT TextId; gsdml_tRefIdT TextId;
} gsdml_sBitDataItem; } gsdml_sBitDataItem;
class gsdml_BitDataItem { class gsdml_BitDataItem
{
public: public:
gsdml_BitDataItem(pn_gsdml* g); gsdml_BitDataItem(pn_gsdml* g);
gsdml_sBitDataItem Body; gsdml_sBitDataItem Body;
...@@ -544,14 +558,16 @@ public: ...@@ -544,14 +558,16 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tEnum DataType; gsdml_tEnum DataType;
gsdml_tUnsigned16 Length; gsdml_tUnsigned16 Length;
gsdml_tBoolean UseAsBits; gsdml_tBoolean UseAsBits;
gsdml_tRefIdT TextId; gsdml_tRefIdT TextId;
} gsdml_sDataItem; } gsdml_sDataItem;
class gsdml_DataItem { class gsdml_DataItem
{
public: public:
gsdml_DataItem(pn_gsdml* g); gsdml_DataItem(pn_gsdml* g);
gsdml_sDataItem Body; gsdml_sDataItem Body;
...@@ -562,11 +578,13 @@ public: ...@@ -562,11 +578,13 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tEnum Consistency; gsdml_tEnum Consistency;
} gsdml_sInput; } gsdml_sInput;
class gsdml_Input { class gsdml_Input
{
public: public:
gsdml_Input(pn_gsdml* g); gsdml_Input(pn_gsdml* g);
gsdml_sInput Body; gsdml_sInput Body;
...@@ -577,11 +595,13 @@ public: ...@@ -577,11 +595,13 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tEnum Consistency; gsdml_tEnum Consistency;
} gsdml_sOutput; } gsdml_sOutput;
class gsdml_Output { class gsdml_Output
{
public: public:
gsdml_Output(pn_gsdml* g); gsdml_Output(pn_gsdml* g);
gsdml_sOutput Body; gsdml_sOutput Body;
...@@ -592,14 +612,16 @@ public: ...@@ -592,14 +612,16 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned8 IOPS_Length; gsdml_tUnsigned8 IOPS_Length;
gsdml_tUnsigned8 IOCS_Length; gsdml_tUnsigned8 IOCS_Length;
gsdml_tUnsigned8 F_IO_StructureDescVersion; gsdml_tUnsigned8 F_IO_StructureDescVersion;
gsdml_tUnsigned32 F_IO_StructureDescCRC; gsdml_tUnsigned32 F_IO_StructureDescCRC;
} gsdml_sIOData; } gsdml_sIOData;
class gsdml_IOData { class gsdml_IOData
{
public: public:
gsdml_IOData(pn_gsdml* g); gsdml_IOData(pn_gsdml* g);
gsdml_sIOData Body; gsdml_sIOData Body;
...@@ -611,7 +633,8 @@ public: ...@@ -611,7 +633,8 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tRefId ValueItemTarget; gsdml_tRefId ValueItemTarget;
gsdml_tUnsigned32 ByteOffset; gsdml_tUnsigned32 ByteOffset;
gsdml_tInteger BitOffset; gsdml_tInteger BitOffset;
...@@ -623,9 +646,11 @@ typedef struct { ...@@ -623,9 +646,11 @@ typedef struct {
gsdml_tBoolean Visible; gsdml_tBoolean Visible;
gsdml_tRefIdT TextId; gsdml_tRefIdT TextId;
gsdml_tUnsigned16 Length; gsdml_tUnsigned16 Length;
gsdml_tId ID;
} gsdml_sRef; } gsdml_sRef;
class gsdml_Ref { class gsdml_Ref
{
public: public:
gsdml_Ref(pn_gsdml* g); gsdml_Ref(pn_gsdml* g);
gsdml_sRef Body; gsdml_sRef Body;
...@@ -633,12 +658,14 @@ public: ...@@ -633,12 +658,14 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned32 ByteOffset; gsdml_tUnsigned32 ByteOffset;
gsdml_tString1024 Data; gsdml_tString1024 Data;
} gsdml_sConst; } gsdml_sConst;
class gsdml_Const { class gsdml_Const
{
public: public:
gsdml_Const(pn_gsdml* g); gsdml_Const(pn_gsdml* g);
gsdml_sConst Body; gsdml_sConst Body;
...@@ -646,14 +673,16 @@ public: ...@@ -646,14 +673,16 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16 Index; gsdml_tUnsigned16 Index;
gsdml_tUnsigned32 Length; gsdml_tUnsigned32 Length;
gsdml_tUnsigned16 TransferSequence; gsdml_tUnsigned16 TransferSequence;
gsdml_tRefIdT Name; gsdml_tRefIdT Name;
} gsdml_sParameterRecordDataItem; } gsdml_sParameterRecordDataItem;
class gsdml_ParameterRecordDataItem { class gsdml_ParameterRecordDataItem
{
public: public:
gsdml_ParameterRecordDataItem(pn_gsdml* g); gsdml_ParameterRecordDataItem(pn_gsdml* g);
gsdml_sParameterRecordDataItem Body; gsdml_sParameterRecordDataItem Body;
...@@ -665,7 +694,8 @@ public: ...@@ -665,7 +694,8 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16 F_ParamDescCRC; gsdml_tUnsigned16 F_ParamDescCRC;
gsdml_tUnsigned16 Index; gsdml_tUnsigned16 Index;
gsdml_tUnsigned16 TransferSequence; gsdml_tUnsigned16 TransferSequence;
...@@ -711,7 +741,8 @@ typedef struct { ...@@ -711,7 +741,8 @@ typedef struct {
gsdml_tBoolean F_iPar_CRC_Changeable; gsdml_tBoolean F_iPar_CRC_Changeable;
} gsdml_sF_ParameterRecordDataItem; } gsdml_sF_ParameterRecordDataItem;
class gsdml_F_ParameterRecordDataItem { class gsdml_F_ParameterRecordDataItem
{
public: public:
gsdml_F_ParameterRecordDataItem(pn_gsdml* g); gsdml_F_ParameterRecordDataItem(pn_gsdml* g);
gsdml_sF_ParameterRecordDataItem Body; gsdml_sF_ParameterRecordDataItem Body;
...@@ -719,11 +750,10 @@ public: ...@@ -719,11 +750,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_RecordDataList { class gsdml_RecordDataList
{
public: public:
gsdml_RecordDataList(pn_gsdml* g) : F_ParameterRecordDataItem(0), gsdml(g) gsdml_RecordDataList(pn_gsdml* g) : F_ParameterRecordDataItem(0), gsdml(g) {}
{
}
std::vector<gsdml_ParameterRecordDataItem*> ParameterRecordDataItem; std::vector<gsdml_ParameterRecordDataItem*> ParameterRecordDataItem;
gsdml_F_ParameterRecordDataItem* F_ParameterRecordDataItem; gsdml_F_ParameterRecordDataItem* F_ParameterRecordDataItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
...@@ -732,12 +762,14 @@ public: ...@@ -732,12 +762,14 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tEnum Type; gsdml_tEnum Type;
gsdml_tRefId GraphicItemTarget; gsdml_tRefId GraphicItemTarget;
} gsdml_sGraphicItemRef; } gsdml_sGraphicItemRef;
class gsdml_GraphicItemRef { class gsdml_GraphicItemRef
{
public: public:
gsdml_GraphicItemRef(pn_gsdml* g); gsdml_GraphicItemRef(pn_gsdml* g);
gsdml_sGraphicItemRef Body; gsdml_sGraphicItemRef Body;
...@@ -745,11 +777,10 @@ public: ...@@ -745,11 +777,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_Graphics { class gsdml_Graphics
{
public: public:
gsdml_Graphics(pn_gsdml* g) : gsdml(g) gsdml_Graphics(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_GraphicItemRef*> GraphicItemRef; std::vector<gsdml_GraphicItemRef*> GraphicItemRef;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_Graphics(); ~gsdml_Graphics();
...@@ -757,7 +788,8 @@ public: ...@@ -757,7 +788,8 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16 T_DC_Base; gsdml_tUnsigned16 T_DC_Base;
gsdml_tUnsigned16 T_DC_Min; gsdml_tUnsigned16 T_DC_Min;
gsdml_tUnsigned16 T_DC_Max; gsdml_tUnsigned16 T_DC_Max;
...@@ -767,7 +799,8 @@ typedef struct { ...@@ -767,7 +799,8 @@ typedef struct {
gsdml_tBoolean IsochroneModeRequired; gsdml_tBoolean IsochroneModeRequired;
} gsdml_sIsochroneMode; } gsdml_sIsochroneMode;
class gsdml_IsochroneMode { class gsdml_IsochroneMode
{
public: public:
gsdml_IsochroneMode(pn_gsdml* g); gsdml_IsochroneMode(pn_gsdml* g);
gsdml_sIsochroneMode Body; gsdml_sIsochroneMode Body;
...@@ -775,7 +808,8 @@ public: ...@@ -775,7 +808,8 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tId ID; gsdml_tId ID;
gsdml_tUnsigned32hex SubmoduleIdentNumber; gsdml_tUnsigned32hex SubmoduleIdentNumber;
gsdml_tUnsigned32 API; gsdml_tUnsigned32 API;
...@@ -787,7 +821,8 @@ typedef struct { ...@@ -787,7 +821,8 @@ typedef struct {
gsdml_tUnsigned16 MayIssueProcessAlarm; gsdml_tUnsigned16 MayIssueProcessAlarm;
} gsdml_sVirtualSubmoduleItem; } gsdml_sVirtualSubmoduleItem;
class gsdml_VirtualSubmoduleItem { class gsdml_VirtualSubmoduleItem
{
public: public:
gsdml_VirtualSubmoduleItem(pn_gsdml* g); gsdml_VirtualSubmoduleItem(pn_gsdml* g);
gsdml_sVirtualSubmoduleItem Body; gsdml_sVirtualSubmoduleItem Body;
...@@ -802,11 +837,10 @@ public: ...@@ -802,11 +837,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_VirtualSubmoduleList { class gsdml_VirtualSubmoduleList
{
public: public:
gsdml_VirtualSubmoduleList(pn_gsdml* g) : gsdml(g) gsdml_VirtualSubmoduleList(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_VirtualSubmoduleItem*> VirtualSubmoduleItem; std::vector<gsdml_VirtualSubmoduleItem*> VirtualSubmoduleItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_VirtualSubmoduleList(); ~gsdml_VirtualSubmoduleList();
...@@ -814,11 +848,13 @@ public: ...@@ -814,11 +848,13 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tRefIdT TextId; gsdml_tRefIdT TextId;
} gsdml_sDCP_FlashOnceSignalUnit; } gsdml_sDCP_FlashOnceSignalUnit;
class gsdml_DCP_FlashOnceSignalUnit { class gsdml_DCP_FlashOnceSignalUnit
{
public: public:
gsdml_DCP_FlashOnceSignalUnit(pn_gsdml* g); gsdml_DCP_FlashOnceSignalUnit(pn_gsdml* g);
gsdml_sDCP_FlashOnceSignalUnit Body; gsdml_sDCP_FlashOnceSignalUnit Body;
...@@ -826,25 +862,26 @@ public: ...@@ -826,25 +862,26 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_General { class gsdml_General
{
public: public:
gsdml_General(pn_gsdml* g) : DCP_FlashOnceSignalUnit(0), gsdml(g) gsdml_General(pn_gsdml* g) : DCP_FlashOnceSignalUnit(0), gsdml(g) {}
{
}
gsdml_DCP_FlashOnceSignalUnit* DCP_FlashOnceSignalUnit; gsdml_DCP_FlashOnceSignalUnit* DCP_FlashOnceSignalUnit;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_General(); ~gsdml_General();
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16 MaxBridgeDelay; gsdml_tUnsigned16 MaxBridgeDelay;
gsdml_tUnsigned16 MaxNumberIR_FrameData; gsdml_tUnsigned16 MaxNumberIR_FrameData;
gsdml_tString StartupMode; gsdml_tString StartupMode;
gsdml_tString ForwardingMode; gsdml_tString ForwardingMode;
} gsdml_sRT_Class3Properties; } gsdml_sRT_Class3Properties;
class gsdml_RT_Class3Properties { class gsdml_RT_Class3Properties
{
public: public:
gsdml_RT_Class3Properties(pn_gsdml* g); gsdml_RT_Class3Properties(pn_gsdml* g);
gsdml_sRT_Class3Properties Body; gsdml_sRT_Class3Properties Body;
...@@ -852,14 +889,16 @@ public: ...@@ -852,14 +889,16 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tEnum SupportedRole; gsdml_tEnum SupportedRole;
gsdml_tUnsigned16 MaxLocalJitter; gsdml_tUnsigned16 MaxLocalJitter;
gsdml_tUnsigned16 T_PLL_MAX; gsdml_tUnsigned16 T_PLL_MAX;
gsdml_tTokenList SupportedSyncProtocols; gsdml_tTokenList SupportedSyncProtocols;
} gsdml_sSynchronisationMode; } gsdml_sSynchronisationMode;
class gsdml_SynchronisationMode { class gsdml_SynchronisationMode
{
public: public:
gsdml_SynchronisationMode(pn_gsdml* g); gsdml_SynchronisationMode(pn_gsdml* g);
gsdml_sSynchronisationMode Body; gsdml_sSynchronisationMode Body;
...@@ -867,14 +906,16 @@ public: ...@@ -867,14 +906,16 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tValueList SendClock; gsdml_tValueList SendClock;
gsdml_tValueList ReductionRatio; gsdml_tValueList ReductionRatio;
gsdml_tValueList ReductionRatioPow2; gsdml_tValueList ReductionRatioPow2;
gsdml_tValueList ReductionRatioNonPow2; gsdml_tValueList ReductionRatioNonPow2;
} gsdml_sTimingProperties; } gsdml_sTimingProperties;
class gsdml_TimingProperties { class gsdml_TimingProperties
{
public: public:
gsdml_TimingProperties(pn_gsdml* g); gsdml_TimingProperties(pn_gsdml* g);
gsdml_sTimingProperties Body; gsdml_sTimingProperties Body;
...@@ -882,14 +923,16 @@ public: ...@@ -882,14 +923,16 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tValueList SendClock; gsdml_tValueList SendClock;
gsdml_tValueList ReductionRatio; gsdml_tValueList ReductionRatio;
gsdml_tValueList ReductionRatioPow2; gsdml_tValueList ReductionRatioPow2;
gsdml_tValueList ReductionRatioNonPow2; gsdml_tValueList ReductionRatioNonPow2;
} gsdml_sRT_Class3TimingProperties; } gsdml_sRT_Class3TimingProperties;
class gsdml_RT_Class3TimingProperties { class gsdml_RT_Class3TimingProperties
{
public: public:
gsdml_RT_Class3TimingProperties(pn_gsdml* g); gsdml_RT_Class3TimingProperties(pn_gsdml* g);
gsdml_sRT_Class3TimingProperties Body; gsdml_sRT_Class3TimingProperties Body;
...@@ -897,16 +940,19 @@ public: ...@@ -897,16 +940,19 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16 NumberOfAdditionalInputCR; gsdml_tUnsigned16 NumberOfAdditionalInputCR;
gsdml_tUnsigned16 NumberOfAdditionalOutputCR; gsdml_tUnsigned16 NumberOfAdditionalOutputCR;
gsdml_tUnsigned16 NumberOfAdditionalMulticastProviderCR; gsdml_tUnsigned16 NumberOfAdditionalMulticastProviderCR;
gsdml_tUnsigned16 NumberOfMulticastConsumerCR; gsdml_tUnsigned16 NumberOfMulticastConsumerCR;
gsdml_tUnsigned16 NumberOfAR; gsdml_tUnsigned16 NumberOfAR;
gsdml_tBoolean PullModuleAlarmSupported; gsdml_tBoolean PullModuleAlarmSupported;
gsdml_tTokenList StartupMode;
} gsdml_sInterfaceSubmoduleItem_ApplicationRelations; } gsdml_sInterfaceSubmoduleItem_ApplicationRelations;
class gsdml_InterfaceSubmoduleItem_ApplicationRelations { class gsdml_InterfaceSubmoduleItem_ApplicationRelations
{
public: public:
gsdml_InterfaceSubmoduleItem_ApplicationRelations(pn_gsdml* g); gsdml_InterfaceSubmoduleItem_ApplicationRelations(pn_gsdml* g);
gsdml_sInterfaceSubmoduleItem_ApplicationRelations Body; gsdml_sInterfaceSubmoduleItem_ApplicationRelations Body;
...@@ -917,7 +963,8 @@ public: ...@@ -917,7 +963,8 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tBoolean RT_MediaRedundancySupported; gsdml_tBoolean RT_MediaRedundancySupported;
gsdml_tTokenList SupportedRole; gsdml_tTokenList SupportedRole;
gsdml_tBoolean AdditionalProtocolsSupported; gsdml_tBoolean AdditionalProtocolsSupported;
...@@ -925,7 +972,8 @@ typedef struct { ...@@ -925,7 +972,8 @@ typedef struct {
gsdml_tInteger MaxMRP_Instances; gsdml_tInteger MaxMRP_Instances;
} gsdml_sMediaRedundancy; } gsdml_sMediaRedundancy;
class gsdml_MediaRedundancy { class gsdml_MediaRedundancy
{
public: public:
gsdml_MediaRedundancy(pn_gsdml* g); gsdml_MediaRedundancy(pn_gsdml* g);
gsdml_sMediaRedundancy Body; gsdml_sMediaRedundancy Body;
...@@ -933,7 +981,8 @@ public: ...@@ -933,7 +981,8 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tId ID; gsdml_tId ID;
gsdml_tUnsigned16 SubslotNumber; gsdml_tUnsigned16 SubslotNumber;
gsdml_tRefId TextId; gsdml_tRefId TextId;
...@@ -951,7 +1000,8 @@ typedef struct { ...@@ -951,7 +1000,8 @@ typedef struct {
gsdml_tBoolean DelayMeasurementSupported; gsdml_tBoolean DelayMeasurementSupported;
} gsdml_sInterfaceSubmoduleItem; } gsdml_sInterfaceSubmoduleItem;
class gsdml_InterfaceSubmoduleItem { class gsdml_InterfaceSubmoduleItem
{
public: public:
gsdml_InterfaceSubmoduleItem(pn_gsdml* g); gsdml_InterfaceSubmoduleItem(pn_gsdml* g);
gsdml_sInterfaceSubmoduleItem Body; gsdml_sInterfaceSubmoduleItem Body;
...@@ -967,7 +1017,8 @@ public: ...@@ -967,7 +1017,8 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tId ID; gsdml_tId ID;
gsdml_tUnsigned16 SubslotNumber; gsdml_tUnsigned16 SubslotNumber;
gsdml_tRefId TextId; gsdml_tRefId TextId;
...@@ -984,9 +1035,11 @@ typedef struct { ...@@ -984,9 +1035,11 @@ typedef struct {
gsdml_tBoolean IsDefaultRingport; gsdml_tBoolean IsDefaultRingport;
gsdml_tBoolean CheckMAUTypeSupported; gsdml_tBoolean CheckMAUTypeSupported;
gsdml_tBoolean CheckMAUTypeDifferenceSupported; gsdml_tBoolean CheckMAUTypeDifferenceSupported;
gsdml_tValueList Writeable_IM_Records;
} gsdml_sPortSubmoduleItem; } gsdml_sPortSubmoduleItem;
class gsdml_PortSubmoduleItem { class gsdml_PortSubmoduleItem
{
public: public:
gsdml_PortSubmoduleItem(pn_gsdml* g); gsdml_PortSubmoduleItem(pn_gsdml* g);
gsdml_sPortSubmoduleItem Body; gsdml_sPortSubmoduleItem Body;
...@@ -997,11 +1050,10 @@ public: ...@@ -997,11 +1050,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_SystemDefinedSubmoduleList { class gsdml_SystemDefinedSubmoduleList
{
public: public:
gsdml_SystemDefinedSubmoduleList(pn_gsdml* g) : gsdml(g) gsdml_SystemDefinedSubmoduleList(pn_gsdml* g) : gsdml(g) {}
{
}
gsdml_InterfaceSubmoduleItem* InterfaceSubmoduleItem; gsdml_InterfaceSubmoduleItem* InterfaceSubmoduleItem;
std::vector<gsdml_PortSubmoduleItem*> PortSubmoduleItem; std::vector<gsdml_PortSubmoduleItem*> PortSubmoduleItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
...@@ -1010,14 +1062,16 @@ public: ...@@ -1010,14 +1062,16 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16 AR_BlockVersion; gsdml_tUnsigned16 AR_BlockVersion;
gsdml_tUnsigned16 IOCR_BlockVersion; gsdml_tUnsigned16 IOCR_BlockVersion;
gsdml_tUnsigned16 AlarmCR_BlockVersion; gsdml_tUnsigned16 AlarmCR_BlockVersion;
gsdml_tUnsigned16 SubmoduleDataBlockVersion; gsdml_tUnsigned16 SubmoduleDataBlockVersion;
} gsdml_sDeviceAccessPointItem_ApplicationRelations; } gsdml_sDeviceAccessPointItem_ApplicationRelations;
class gsdml_DeviceAccessPointItem_ApplicationRelations { class gsdml_DeviceAccessPointItem_ApplicationRelations
{
public: public:
gsdml_DeviceAccessPointItem_ApplicationRelations(pn_gsdml* g); gsdml_DeviceAccessPointItem_ApplicationRelations(pn_gsdml* g);
gsdml_sDeviceAccessPointItem_ApplicationRelations Body; gsdml_sDeviceAccessPointItem_ApplicationRelations Body;
...@@ -1027,14 +1081,16 @@ public: ...@@ -1027,14 +1081,16 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tRefId SubmoduleItemTarget; gsdml_tRefId SubmoduleItemTarget;
gsdml_tValueList AllowedInSubslots; gsdml_tValueList AllowedInSubslots;
gsdml_tValueList UsedInSubslots; gsdml_tValueList UsedInSubslots;
gsdml_tValueList FixedInSubslots; gsdml_tValueList FixedInSubslots;
} gsdml_sSubmoduleItemRef; } gsdml_sSubmoduleItemRef;
class gsdml_SubmoduleItemRef { class gsdml_SubmoduleItemRef
{
public: public:
gsdml_SubmoduleItemRef(pn_gsdml* g); gsdml_SubmoduleItemRef(pn_gsdml* g);
gsdml_sSubmoduleItemRef Body; gsdml_sSubmoduleItemRef Body;
...@@ -1043,11 +1099,10 @@ public: ...@@ -1043,11 +1099,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_UseableSubmodules { class gsdml_UseableSubmodules
{
public: public:
gsdml_UseableSubmodules(pn_gsdml* g) : gsdml(g) gsdml_UseableSubmodules(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_SubmoduleItemRef*> SubmoduleItemRef; std::vector<gsdml_SubmoduleItemRef*> SubmoduleItemRef;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_UseableSubmodules(); ~gsdml_UseableSubmodules();
...@@ -1055,12 +1110,14 @@ public: ...@@ -1055,12 +1110,14 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16 SlotNumber; gsdml_tUnsigned16 SlotNumber;
gsdml_tRefId TextId; gsdml_tRefId TextId;
} gsdml_sSlotItem; } gsdml_sSlotItem;
class gsdml_SlotItem { class gsdml_SlotItem
{
public: public:
gsdml_SlotItem(pn_gsdml* g); gsdml_SlotItem(pn_gsdml* g);
gsdml_sSlotItem Body; gsdml_sSlotItem Body;
...@@ -1068,11 +1125,10 @@ public: ...@@ -1068,11 +1125,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_SlotList { class gsdml_SlotList
{
public: public:
gsdml_SlotList(pn_gsdml* g) : gsdml(g) gsdml_SlotList(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_SlotItem*> SlotItem; std::vector<gsdml_SlotItem*> SlotItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_SlotList(); ~gsdml_SlotList();
...@@ -1080,13 +1136,15 @@ public: ...@@ -1080,13 +1136,15 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tValueList SlotList; gsdml_tValueList SlotList;
gsdml_tRefId Name; gsdml_tRefId Name;
gsdml_tRefId InfoText; gsdml_tRefId InfoText;
} gsdml_sSlotGroup; } gsdml_sSlotGroup;
class gsdml_SlotGroup { class gsdml_SlotGroup
{
public: public:
gsdml_SlotGroup(pn_gsdml* g); gsdml_SlotGroup(pn_gsdml* g);
gsdml_sSlotGroup Body; gsdml_sSlotGroup Body;
...@@ -1094,18 +1152,18 @@ public: ...@@ -1094,18 +1152,18 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_SlotGroups { class gsdml_SlotGroups
{
public: public:
gsdml_SlotGroups(pn_gsdml* g) : gsdml(g) gsdml_SlotGroups(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_SlotGroup*> SlotGroup; std::vector<gsdml_SlotGroup*> SlotGroup;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_SlotGroups(); ~gsdml_SlotGroups();
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tId ID; gsdml_tId ID;
gsdml_tValueList PhysicalSlots; gsdml_tValueList PhysicalSlots;
gsdml_tUnsigned32hex ModuleIdentNumber; gsdml_tUnsigned32hex ModuleIdentNumber;
...@@ -1136,7 +1194,8 @@ typedef struct { ...@@ -1136,7 +1194,8 @@ typedef struct {
gsdml_tUnsigned16 NumberOfDeviceAccessAR; gsdml_tUnsigned16 NumberOfDeviceAccessAR;
} gsdml_sDeviceAccessPointItem; } gsdml_sDeviceAccessPointItem;
class gsdml_DeviceAccessPointItem { class gsdml_DeviceAccessPointItem
{
public: public:
gsdml_DeviceAccessPointItem(pn_gsdml* g); gsdml_DeviceAccessPointItem(pn_gsdml* g);
gsdml_sDeviceAccessPointItem Body; gsdml_sDeviceAccessPointItem Body;
...@@ -1158,11 +1217,10 @@ public: ...@@ -1158,11 +1217,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_DeviceAccessPointList { class gsdml_DeviceAccessPointList
{
public: public:
gsdml_DeviceAccessPointList(pn_gsdml* g) : gsdml(g) gsdml_DeviceAccessPointList(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_DeviceAccessPointItem*> DeviceAccessPointItem; std::vector<gsdml_DeviceAccessPointItem*> DeviceAccessPointItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_DeviceAccessPointList(); ~gsdml_DeviceAccessPointList();
...@@ -1170,14 +1228,16 @@ public: ...@@ -1170,14 +1228,16 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tId ID; gsdml_tId ID;
gsdml_tUnsigned32hex ModuleIdentNumber; gsdml_tUnsigned32hex ModuleIdentNumber;
gsdml_tString RequiredSchemaVersion; gsdml_tString RequiredSchemaVersion;
gsdml_tValueList PhysicalSubslots; gsdml_tValueList PhysicalSubslots;
} gsdml_sModuleItem; } gsdml_sModuleItem;
class gsdml_ModuleItem { class gsdml_ModuleItem
{
public: public:
gsdml_ModuleItem(pn_gsdml* g); gsdml_ModuleItem(pn_gsdml* g);
gsdml_sModuleItem Body; gsdml_sModuleItem Body;
...@@ -1193,11 +1253,10 @@ public: ...@@ -1193,11 +1253,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_ModuleList { class gsdml_ModuleList
{
public: public:
gsdml_ModuleList(pn_gsdml* g) : gsdml(g) gsdml_ModuleList(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_ModuleItem*> ModuleItem; std::vector<gsdml_ModuleItem*> ModuleItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_ModuleList(); ~gsdml_ModuleList();
...@@ -1205,11 +1264,10 @@ public: ...@@ -1205,11 +1264,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_SubmoduleList { class gsdml_SubmoduleList
{
public: public:
gsdml_SubmoduleList(pn_gsdml* g) : gsdml(g) gsdml_SubmoduleList(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_VirtualSubmoduleItem*> SubmoduleItem; std::vector<gsdml_VirtualSubmoduleItem*> SubmoduleItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_SubmoduleList(); ~gsdml_SubmoduleList();
...@@ -1217,12 +1275,14 @@ public: ...@@ -1217,12 +1275,14 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tString Content; gsdml_tString Content;
gsdml_tRefIdT TextId; gsdml_tRefIdT TextId;
} gsdml_sAssign; } gsdml_sAssign;
class gsdml_Assign { class gsdml_Assign
{
public: public:
gsdml_Assign(pn_gsdml* g); gsdml_Assign(pn_gsdml* g);
gsdml_sAssign Body; gsdml_sAssign Body;
...@@ -1231,23 +1291,24 @@ public: ...@@ -1231,23 +1291,24 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_Assignments { class gsdml_Assignments
{
public: public:
gsdml_Assignments(pn_gsdml* g) : gsdml(g) gsdml_Assignments(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_Assign*> Assign; std::vector<gsdml_Assign*> Assign;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_Assignments(); ~gsdml_Assignments();
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tId ID; gsdml_tId ID;
gsdml_tRefIdT Help; gsdml_tRefIdT Help;
} gsdml_sValueItem; } gsdml_sValueItem;
class gsdml_ValueItem { class gsdml_ValueItem
{
public: public:
gsdml_ValueItem(pn_gsdml* g); gsdml_ValueItem(pn_gsdml* g);
gsdml_sValueItem Body; gsdml_sValueItem Body;
...@@ -1258,11 +1319,10 @@ public: ...@@ -1258,11 +1319,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_ValueList { class gsdml_ValueList
{
public: public:
gsdml_ValueList(pn_gsdml* g) : gsdml(g) gsdml_ValueList(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_ValueItem*> ValueItem; std::vector<gsdml_ValueItem*> ValueItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_ValueList(); ~gsdml_ValueList();
...@@ -1270,13 +1330,15 @@ public: ...@@ -1270,13 +1330,15 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned8 Id; gsdml_tUnsigned8 Id;
gsdml_tEnum DataType; gsdml_tEnum DataType;
gsdml_tUnsigned16 Length; gsdml_tUnsigned16 Length;
} gsdml_sExtChannelAddValue_DataItem; } gsdml_sExtChannelAddValue_DataItem;
class gsdml_ExtChannelAddValue_DataItem { class gsdml_ExtChannelAddValue_DataItem
{
public: public:
gsdml_ExtChannelAddValue_DataItem(pn_gsdml* g); gsdml_ExtChannelAddValue_DataItem(pn_gsdml* g);
gsdml_sExtChannelAddValue_DataItem Body; gsdml_sExtChannelAddValue_DataItem Body;
...@@ -1284,18 +1346,18 @@ public: ...@@ -1284,18 +1346,18 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_ExtChannelAddValue { class gsdml_ExtChannelAddValue
{
public: public:
gsdml_ExtChannelAddValue(pn_gsdml* g) : gsdml(g) gsdml_ExtChannelAddValue(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_ExtChannelAddValue_DataItem*> DataItem; std::vector<gsdml_ExtChannelAddValue_DataItem*> DataItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_ExtChannelAddValue(); ~gsdml_ExtChannelAddValue();
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16 ErrorType; gsdml_tUnsigned16 ErrorType;
gsdml_tTokenList MaintenanceAlarmState; gsdml_tTokenList MaintenanceAlarmState;
gsdml_tUnsigned32 API; gsdml_tUnsigned32 API;
...@@ -1303,7 +1365,8 @@ typedef struct { ...@@ -1303,7 +1365,8 @@ typedef struct {
gsdml_tRefId Help; gsdml_tRefId Help;
} gsdml_sExtChannelDiagItem; } gsdml_sExtChannelDiagItem;
class gsdml_ExtChannelDiagItem { class gsdml_ExtChannelDiagItem
{
public: public:
gsdml_ExtChannelDiagItem(pn_gsdml* g); gsdml_ExtChannelDiagItem(pn_gsdml* g);
gsdml_sExtChannelDiagItem Body; gsdml_sExtChannelDiagItem Body;
...@@ -1313,18 +1376,18 @@ public: ...@@ -1313,18 +1376,18 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_ExtChannelDiagList { class gsdml_ExtChannelDiagList
{
public: public:
gsdml_ExtChannelDiagList(pn_gsdml* g) : gsdml(g) gsdml_ExtChannelDiagList(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_ExtChannelDiagItem*> ExtChannelDiagItem; std::vector<gsdml_ExtChannelDiagItem*> ExtChannelDiagItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_ExtChannelDiagList(); ~gsdml_ExtChannelDiagList();
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16 ErrorType; gsdml_tUnsigned16 ErrorType;
gsdml_tTokenList MaintenanceAlarmState; gsdml_tTokenList MaintenanceAlarmState;
gsdml_tUnsigned32 API; gsdml_tUnsigned32 API;
...@@ -1332,7 +1395,8 @@ typedef struct { ...@@ -1332,7 +1395,8 @@ typedef struct {
gsdml_tRefId Help; gsdml_tRefId Help;
} gsdml_sChannelDiagItem; } gsdml_sChannelDiagItem;
class gsdml_ChannelDiagItem { class gsdml_ChannelDiagItem
{
public: public:
gsdml_ChannelDiagItem(pn_gsdml* g); gsdml_ChannelDiagItem(pn_gsdml* g);
gsdml_sChannelDiagItem Body; gsdml_sChannelDiagItem Body;
...@@ -1343,11 +1407,10 @@ public: ...@@ -1343,11 +1407,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_ChannelDiagList { class gsdml_ChannelDiagList
{
public: public:
gsdml_ChannelDiagList(pn_gsdml* g) : gsdml(g) gsdml_ChannelDiagList(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_ChannelDiagItem*> ChannelDiagItem; std::vector<gsdml_ChannelDiagItem*> ChannelDiagItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_ChannelDiagList(); ~gsdml_ChannelDiagList();
...@@ -1355,12 +1418,14 @@ public: ...@@ -1355,12 +1418,14 @@ public:
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tUnsigned16 UserStructureIdentifier; gsdml_tUnsigned16 UserStructureIdentifier;
gsdml_tUnsigned32 API; gsdml_tUnsigned32 API;
} gsdml_sUnitDiagTypeItem; } gsdml_sUnitDiagTypeItem;
class gsdml_UnitDiagTypeItem { class gsdml_UnitDiagTypeItem
{
public: public:
gsdml_UnitDiagTypeItem(pn_gsdml* g); gsdml_UnitDiagTypeItem(pn_gsdml* g);
gsdml_sUnitDiagTypeItem Body; gsdml_sUnitDiagTypeItem Body;
...@@ -1370,24 +1435,25 @@ public: ...@@ -1370,24 +1435,25 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_UnitDiagTypeList { class gsdml_UnitDiagTypeList
{
public: public:
gsdml_UnitDiagTypeList(pn_gsdml* g) : gsdml(g) gsdml_UnitDiagTypeList(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_UnitDiagTypeItem*> UnitDiagTypeItem; std::vector<gsdml_UnitDiagTypeItem*> UnitDiagTypeItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_UnitDiagTypeList(); ~gsdml_UnitDiagTypeList();
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tId ID; gsdml_tId ID;
gsdml_tString GraphicFile; gsdml_tString GraphicFile;
gsdml_tString Embedded; gsdml_tString Embedded;
} gsdml_sGraphicItem; } gsdml_sGraphicItem;
class gsdml_GraphicItem { class gsdml_GraphicItem
{
public: public:
gsdml_GraphicItem(pn_gsdml* g); gsdml_GraphicItem(pn_gsdml* g);
gsdml_sGraphicItem Body; gsdml_sGraphicItem Body;
...@@ -1395,24 +1461,25 @@ public: ...@@ -1395,24 +1461,25 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_GraphicsList { class gsdml_GraphicsList
{
public: public:
gsdml_GraphicsList(pn_gsdml* g) : gsdml(g) gsdml_GraphicsList(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_GraphicItem*> GraphicItem; std::vector<gsdml_GraphicItem*> GraphicItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_GraphicsList(); ~gsdml_GraphicsList();
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tId ID; gsdml_tId ID;
gsdml_tRefIdT TextId; gsdml_tRefIdT TextId;
gsdml_tRefId InfoText; gsdml_tRefId InfoText;
} gsdml_sCategoryItem; } gsdml_sCategoryItem;
class gsdml_CategoryItem { class gsdml_CategoryItem
{
public: public:
gsdml_CategoryItem(pn_gsdml* g); gsdml_CategoryItem(pn_gsdml* g);
gsdml_sCategoryItem Body; gsdml_sCategoryItem Body;
...@@ -1420,23 +1487,24 @@ public: ...@@ -1420,23 +1487,24 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_CategoryList { class gsdml_CategoryList
{
public: public:
gsdml_CategoryList(pn_gsdml* g) : gsdml(g) gsdml_CategoryList(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_CategoryItem*> CategoryItem; std::vector<gsdml_CategoryItem*> CategoryItem;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_CategoryList(); ~gsdml_CategoryList();
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tIdT TextId; gsdml_tIdT TextId;
gsdml_tAllocatedString Value; gsdml_tAllocatedString Value;
} gsdml_sText; } gsdml_sText;
class gsdml_Text { class gsdml_Text
{
public: public:
gsdml_Text(pn_gsdml* g); gsdml_Text(pn_gsdml* g);
gsdml_sText Body; gsdml_sText Body;
...@@ -1445,22 +1513,23 @@ public: ...@@ -1445,22 +1513,23 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_PrimaryLanguage { class gsdml_PrimaryLanguage
{
public: public:
gsdml_PrimaryLanguage(pn_gsdml* g) : gsdml(g) gsdml_PrimaryLanguage(pn_gsdml* g) : gsdml(g) {}
{
}
std::vector<gsdml_Text*> Text; std::vector<gsdml_Text*> Text;
pn_gsdml* gsdml; pn_gsdml* gsdml;
~gsdml_PrimaryLanguage(); ~gsdml_PrimaryLanguage();
void print(int ind); void print(int ind);
}; };
typedef struct { typedef struct
{
gsdml_tEnum xml_lang; gsdml_tEnum xml_lang;
} gsdml_sLanguage; } gsdml_sLanguage;
class gsdml_Language { class gsdml_Language
{
public: public:
gsdml_Language(pn_gsdml* g); gsdml_Language(pn_gsdml* g);
gsdml_sLanguage Body; gsdml_sLanguage Body;
...@@ -1470,11 +1539,10 @@ public: ...@@ -1470,11 +1539,10 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_ExternalTextList { class gsdml_ExternalTextList
{
public: public:
gsdml_ExternalTextList(pn_gsdml* g) : gsdml(g) gsdml_ExternalTextList(pn_gsdml* g) : gsdml(g) {}
{
}
gsdml_PrimaryLanguage* PrimaryLanguage; gsdml_PrimaryLanguage* PrimaryLanguage;
std::vector<gsdml_Language*> Language; std::vector<gsdml_Language*> Language;
pn_gsdml* gsdml; pn_gsdml* gsdml;
...@@ -1482,7 +1550,8 @@ public: ...@@ -1482,7 +1550,8 @@ public:
void print(int ind); void print(int ind);
}; };
class gsdml_ApplicationProcess { class gsdml_ApplicationProcess
{
public: public:
gsdml_ApplicationProcess(pn_gsdml* g) gsdml_ApplicationProcess(pn_gsdml* g)
: DeviceAccessPointList(0), ModuleList(0), SubmoduleList(0), ValueList(0), : DeviceAccessPointList(0), ModuleList(0), SubmoduleList(0), ValueList(0),
...@@ -1505,7 +1574,40 @@ public: ...@@ -1505,7 +1574,40 @@ public:
void print(int ind); void print(int ind);
}; };
class pn_gsdml { typedef struct
{
gsdml_tRefId ParameterTarget;
} gsdml_sParameterRef;
typedef struct
{
gsdml_tRefId MenuTarget;
} gsdml_sMenuRef;
class gsdml_ParameterRef
{
public:
gsdml_ParameterRef(pn_gsdml* g);
gsdml_sParameterRef Body;
pn_gsdml* gsdml;
~gsdml_ParameterRef();
void build();
void print(int ind);
};
class gsdml_MenuRef
{
public:
gsdml_MenuRef(pn_gsdml* g);
gsdml_sMenuRef Body;
pn_gsdml* gsdml;
~gsdml_MenuRef();
void build();
void print(int ind);
};
class pn_gsdml
{
public: public:
pn_gsdml(); pn_gsdml();
~pn_gsdml(); ~pn_gsdml();
...@@ -1532,10 +1634,10 @@ public: ...@@ -1532,10 +1634,10 @@ public:
unsigned int current_attribute_value_idx; unsigned int current_attribute_value_idx;
unsigned int current_tag_value_idx; unsigned int current_tag_value_idx;
int suppress_msg; int suppress_msg;
gsdml_eTag tag_stack[100]; gsdml_eTag tag_stack[4096];
unsigned int tag_stack_cnt; unsigned int tag_stack_cnt;
void* object_stack[100]; void* object_stack[4096];
gsdml_eTag object_stack_id[100]; gsdml_eTag object_stack_id[4096];
unsigned int object_stack_cnt; unsigned int object_stack_cnt;
void* current_body; void* current_body;
unsigned int current_body_size; unsigned int current_body_size;
...@@ -1561,38 +1663,35 @@ public: ...@@ -1561,38 +1663,35 @@ public:
int object_stack_push(void* o, gsdml_eTag id); int object_stack_push(void* o, gsdml_eTag id);
int object_stack_pull(gsdml_eTag id); int object_stack_pull(gsdml_eTag id);
void set_language(const char* lang); void set_language(const char* lang);
static int ostring_to_data( static int ostring_to_data(unsigned char** data, const char* str, int size,
unsigned char** data, const char* str, int size, int* rsize); int* rsize);
static int data_to_ostring( static int data_to_ostring(unsigned char* data, int size, char* str,
unsigned char* data, int size, char* str, int strsize); int strsize);
static int string_to_value_datatype(char* str, gsdml_eValueDataType* type); static int string_to_value_datatype(char* str, gsdml_eValueDataType* type);
int datavalue_to_string(gsdml_eValueDataType datatype, void* value, int datavalue_to_string(gsdml_eValueDataType datatype, void* value,
unsigned int size, char* str, unsigned int strsize); unsigned int size, char* str, unsigned int strsize);
int string_to_datavalue( int string_to_datavalue(gsdml_eValueDataType datatype, void* value,
gsdml_eValueDataType datatype, void* value, unsigned int size, const char* str); unsigned int size, const char* str);
int get_datavalue_length( int get_datavalue_length(gsdml_eValueDataType datatype, int strlength,
gsdml_eValueDataType datatype, int strlength, unsigned int* len); unsigned int* len);
void set_classes(gsdml_sModuleClass* mclist) void set_classes(gsdml_sModuleClass* mclist) { module_classlist = mclist; }
{ int set_par_record_default(unsigned char* data, int size,
module_classlist = mclist; gsdml_ParameterRecordDataItem* par_record);
}
int set_par_record_default(
unsigned char* data, int size, gsdml_ParameterRecordDataItem* par_record);
bool next_token(); bool next_token();
bool is_space(const char c); bool is_space(const char c);
int find_tag(const char* name, int* idx); int find_tag(const char* name, int* idx);
int find_tag(gsdml_eTag id, int* idx); int find_tag(gsdml_eTag id, int* idx);
int find_tag_attribute( int find_tag_attribute(const char* name, gsdml_eTag id, gsdml_eTag pid,
const char* name, gsdml_eTag id, gsdml_eTag pid, int* idx); int* idx);
void error_message_line(const char* msg); void error_message_line(const char* msg);
void error_message(const char* format, const char* value); void error_message(const char* format, const char* value);
gsdml_eTag get_tag_stack(); gsdml_eTag get_tag_stack();
gsdml_eTag get_tag_stack(int p); gsdml_eTag get_tag_stack(int p);
void* get_object_stack(gsdml_eTag id); void* get_object_stack(gsdml_eTag id);
void* get_object_stack(int p, gsdml_eTag id); void* get_object_stack(int p, gsdml_eTag id);
int string_to_value( int string_to_value(gsdml_eType type, unsigned int size, const char* str,
gsdml_eType type, unsigned int size, const char* str, void* buf); void* buf);
int set_default_values(gsdml_eTag id, void* data, unsigned int size); int set_default_values(gsdml_eTag id, void* data, unsigned int size);
void* object_factory(gsdml_eTag id); void* object_factory(gsdml_eTag id);
void* find_value_ref(char* ref); void* find_value_ref(char* ref);
......
...@@ -53,10 +53,11 @@ ...@@ -53,10 +53,11 @@
#include "rt_io_base.h" #include "rt_io_base.h"
#include "rt_io_bus.h" #include "rt_io_bus.h"
#include "rt_io_msg.h" #include "rt_io_msg.h"
#include "rt_io_pn_locals.h"
#include "rt_io_pnak_locals.h"
#include "rt_pb_msg.h" #include "rt_pb_msg.h"
#include "rt_pn_gsdml_data.h" #include "rt_pn_gsdml_data.h"
#include "rt_io_pnak_locals.h" #include "rt_profinet.h"
#include "rt_io_pn_locals.h"
#define _PN_U32_HIGH_WORD(U32) ((PN_U16)((U32) >> 16)) #define _PN_U32_HIGH_WORD(U32) ((PN_U16)((U32) >> 16))
#define _PN_U32_LOW_WORD(U32) ((PN_U16)(U32)) #define _PN_U32_LOW_WORD(U32) ((PN_U16)(U32))
...@@ -69,19 +70,21 @@ ...@@ -69,19 +70,21 @@
#define _PN_U16_HIGH_BYTE(U16) ((PN_U8)((U16) >> 8)) #define _PN_U16_HIGH_BYTE(U16) ((PN_U8)((U16) >> 8))
#define _PN_U16_LOW_BYTE(U16) ((PN_U8)(U16)) #define _PN_U16_LOW_BYTE(U16) ((PN_U8)(U16))
//#define _HIGH_LOW_WORDS_TO_PN_U32(High, Low) ((((PN_U32)(High)) << 16) + (Low)) //#define _HIGH_LOW_WORDS_TO_PN_U32(High, Low) ((((PN_U32)(High)) << 16) +
//(Low))
#define _HIGH_LOW_BYTES_TO_PN_U16(High, Low) \ #define _HIGH_LOW_BYTES_TO_PN_U16(High, Low) \
((PN_U16)((((PN_U16)(High)) << 8) + (Low))) ((PN_U16)((((PN_U16)(High)) << 8) + (Low)))
#define _HIGH_LOW_BYTES_TO_PN_U32(hwhb, hwlb, lwhb, lwlb) \ #define _HIGH_LOW_BYTES_TO_PN_U32(hwhb, hwlb, lwhb, lwlb) \
((PN_U32)((((PN_U32)(hwhb)) << 24) + (((PN_U32)(hwlb)) << 16) \ ((PN_U32)((((PN_U32)(hwhb)) << 24) + (((PN_U32)(hwlb)) << 16) + \
+ (((PN_U32)(lwhb)) << 8) + (lwlb))) (((PN_U32)(lwhb)) << 8) + (lwlb)))
char file_vect[2][80] = { char file_vect[2][80] = {
"pwr_pn_000_001_099_020_000000a2.xml", "pwr_pn_000_001_099_020_000000e5.xml", "pwr_pn_000_001_099_020_000000a2.xml",
"pwr_pn_000_001_099_020_000000e5.xml",
}; };
void pack_set_ip_settings_req( void pack_set_ip_settings_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
T_PNAK_SERVICE_REQ_RES* ServiceReqRes, PnDeviceInfo* dev_info) PnDeviceInfo* dev_info)
{ {
T_PNAK_SERVICE_DESCRIPTION* service_desc; T_PNAK_SERVICE_DESCRIPTION* service_desc;
T_PN_SERVICE_SET_IP_SETTINGS_REQ* pSISR; T_PN_SERVICE_SET_IP_SETTINGS_REQ* pSISR;
...@@ -91,8 +94,8 @@ void pack_set_ip_settings_req( ...@@ -91,8 +94,8 @@ void pack_set_ip_settings_req(
ServiceReqRes->NumberEntries = 1; ServiceReqRes->NumberEntries = 1;
ServiceReqRes->ServiceEntry[0].ServiceOffset = 0; ServiceReqRes->ServiceEntry[0].ServiceOffset = 0;
service_desc service_desc =
= (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset]; (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset];
service_desc->DeviceRef = 0u; service_desc->DeviceRef = 0u;
service_desc->Instance = PN_SUPERVISOR; service_desc->Instance = PN_SUPERVISOR;
...@@ -136,8 +139,8 @@ void pack_set_ip_settings_req( ...@@ -136,8 +139,8 @@ void pack_set_ip_settings_req(
pSISR->SubnetMaskLowWordHighByte = dev_info->subnetmask[1]; pSISR->SubnetMaskLowWordHighByte = dev_info->subnetmask[1];
pSISR->SubnetMaskLowWordLowByte = dev_info->subnetmask[0]; pSISR->SubnetMaskLowWordLowByte = dev_info->subnetmask[0];
} }
void pack_set_device_name_req( void pack_set_device_name_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
T_PNAK_SERVICE_REQ_RES* ServiceReqRes, PnDeviceInfo* dev_info) PnDeviceInfo* dev_info)
{ {
T_PNAK_SERVICE_DESCRIPTION* service_desc; T_PNAK_SERVICE_DESCRIPTION* service_desc;
T_PN_SERVICE_SET_NAME_REQ* pSNR; T_PN_SERVICE_SET_NAME_REQ* pSNR;
...@@ -148,8 +151,8 @@ void pack_set_device_name_req( ...@@ -148,8 +151,8 @@ void pack_set_device_name_req(
ServiceReqRes->NumberEntries = 1; ServiceReqRes->NumberEntries = 1;
ServiceReqRes->ServiceEntry[0].ServiceOffset = 0; ServiceReqRes->ServiceEntry[0].ServiceOffset = 0;
service_desc service_desc =
= (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset]; (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset];
service_desc->DeviceRef = 0u; service_desc->DeviceRef = 0u;
service_desc->Instance = PN_SUPERVISOR; service_desc->Instance = PN_SUPERVISOR;
...@@ -191,8 +194,8 @@ void pack_set_identification_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes) ...@@ -191,8 +194,8 @@ void pack_set_identification_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes)
ServiceReqRes->NumberEntries = 1; ServiceReqRes->NumberEntries = 1;
ServiceReqRes->ServiceEntry[0].ServiceOffset = 0; ServiceReqRes->ServiceEntry[0].ServiceOffset = 0;
service_desc service_desc =
= (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset]; (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset];
service_desc->DeviceRef = PN_DEVICE_REFERENCE_THIS_STATION; service_desc->DeviceRef = PN_DEVICE_REFERENCE_THIS_STATION;
service_desc->Instance = PN; service_desc->Instance = PN;
...@@ -222,8 +225,8 @@ void pack_set_identification_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes) ...@@ -222,8 +225,8 @@ void pack_set_identification_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes)
pSSIR->IdentAndMaintenanceVersionLowByte = 1; pSSIR->IdentAndMaintenanceVersionLowByte = 1;
} }
void pack_get_device_state_req( void pack_get_device_state_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
T_PNAK_SERVICE_REQ_RES* ServiceReqRes, unsigned short device_ref) unsigned short device_ref)
{ {
unsigned offset = 0u; unsigned offset = 0u;
...@@ -233,8 +236,8 @@ void pack_get_device_state_req( ...@@ -233,8 +236,8 @@ void pack_get_device_state_req(
ServiceReqRes->NumberEntries = 1; ServiceReqRes->NumberEntries = 1;
ServiceReqRes->ServiceEntry[0].ServiceOffset = 0; ServiceReqRes->ServiceEntry[0].ServiceOffset = 0;
service_desc service_desc =
= (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset]; (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset];
service_desc->DeviceRef = device_ref; service_desc->DeviceRef = device_ref;
service_desc->Instance = PN_CONTROLLER; service_desc->Instance = PN_CONTROLLER;
...@@ -261,8 +264,8 @@ void pack_write_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -261,8 +264,8 @@ void pack_write_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
ServiceReqRes->NumberEntries = 1; ServiceReqRes->NumberEntries = 1;
ServiceReqRes->ServiceEntry[0].ServiceOffset = 0; ServiceReqRes->ServiceEntry[0].ServiceOffset = 0;
service_desc service_desc =
= (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset]; (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset];
service_desc->DeviceRef = device_ref; service_desc->DeviceRef = device_ref;
service_desc->Instance = PN_CONTROLLER; service_desc->Instance = PN_CONTROLLER;
...@@ -308,8 +311,8 @@ void pack_get_los_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes) ...@@ -308,8 +311,8 @@ void pack_get_los_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes)
ServiceReqRes->NumberEntries = 1; ServiceReqRes->NumberEntries = 1;
ServiceReqRes->ServiceEntry[0].ServiceOffset = 0; ServiceReqRes->ServiceEntry[0].ServiceOffset = 0;
service_desc service_desc =
= (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset]; (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset];
service_desc->DeviceRef = PN_DEVICE_REFERENCE_THIS_STATION; service_desc->DeviceRef = PN_DEVICE_REFERENCE_THIS_STATION;
service_desc->Instance = PN_SUPERVISOR; service_desc->Instance = PN_SUPERVISOR;
...@@ -335,8 +338,8 @@ void pack_get_alarm_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -335,8 +338,8 @@ void pack_get_alarm_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
ServiceReqRes->NumberEntries = 1; ServiceReqRes->NumberEntries = 1;
ServiceReqRes->ServiceEntry[0].ServiceOffset = 0; ServiceReqRes->ServiceEntry[0].ServiceOffset = 0;
service_desc service_desc =
= (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset]; (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset];
service_desc->DeviceRef = device_ref; service_desc->DeviceRef = device_ref;
service_desc->Instance = PN; service_desc->Instance = PN;
...@@ -356,7 +359,8 @@ void pack_get_alarm_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -356,7 +359,8 @@ void pack_get_alarm_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
} }
void pack_alarm_ack_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, void pack_alarm_ack_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
unsigned short ref, unsigned short prio, unsigned short device_ref) unsigned short ref, unsigned short prio,
unsigned short device_ref)
{ {
unsigned offset = 0u; unsigned offset = 0u;
...@@ -367,8 +371,8 @@ void pack_alarm_ack_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -367,8 +371,8 @@ void pack_alarm_ack_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
ServiceReqRes->NumberEntries = 1; ServiceReqRes->NumberEntries = 1;
ServiceReqRes->ServiceEntry[0].ServiceOffset = 0; ServiceReqRes->ServiceEntry[0].ServiceOffset = 0;
service_desc service_desc =
= (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset]; (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset];
service_desc->DeviceRef = device_ref; service_desc->DeviceRef = device_ref;
service_desc->Instance = PN; service_desc->Instance = PN;
...@@ -416,8 +420,8 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -416,8 +420,8 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
ServiceReqRes->NumberEntries = 1; ServiceReqRes->NumberEntries = 1;
ServiceReqRes->ServiceEntry[0].ServiceOffset = 0; ServiceReqRes->ServiceEntry[0].ServiceOffset = 0;
service_desc service_desc =
= (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset]; (T_PNAK_SERVICE_DESCRIPTION*)&ServiceReqRes->ServiceChannel[offset];
service_desc->DeviceRef = device_ref; service_desc->DeviceRef = device_ref;
// service_desc->DeviceRef = PN_DEVICE_REFERENCE_THIS_STATION; // service_desc->DeviceRef = PN_DEVICE_REFERENCE_THIS_STATION;
...@@ -433,41 +437,53 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -433,41 +437,53 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
/* Calculate num modules */ /* Calculate num modules */
for (ii = 0; ii < dev_data->slot_data.size(); ii++) { for (ii = 0; ii < dev_data->slot_data.size(); ii++)
{
if ((dev_data->slot_data[ii]->module_enum_number != 0) || (ii == 0)) if ((dev_data->slot_data[ii]->module_enum_number != 0) || (ii == 0))
num_modules++; num_modules++;
else else
break; break;
} }
// printf("Number of modules for this slave: %d\n", num_modules);
// num_modules = dev_data->slot_data.size(); // num_modules = dev_data->slot_data.size();
/* Calculate num apis */ /* Calculate num apis */
if (num_iocrs > 0) { if (num_iocrs > 0)
for (ii = 0; ii < num_modules; ii++) { {
for (ii = 0; ii < num_modules; ii++)
{
slot_api = PROFINET_DEFAULT_API; slot_api = PROFINET_DEFAULT_API;
for (jj = 0; jj < dev_data->slot_data[ii]->subslot_data.size(); jj++) { for (jj = 0; jj < dev_data->slot_data[ii]->subslot_data.size(); jj++)
if (dev_data->slot_data[ii]->subslot_data[jj]->api > 0) { {
if (dev_data->slot_data[ii]->subslot_data[jj]->api > 0)
{
slot_api = dev_data->slot_data[ii]->subslot_data[jj]->api; slot_api = dev_data->slot_data[ii]->subslot_data[jj]->api;
break; break;
} }
} }
found = 0; found = 0;
for (kk = 0; kk < apis.size(); kk++) { for (kk = 0; kk < apis.size(); kk++)
if (apis[kk].api == slot_api) { {
if (apis[kk].api == slot_api)
{
found = TRUE; found = TRUE;
break; break;
} }
} }
if (!found) { if (!found)
{
PnApiData api; PnApiData api;
api.api = slot_api; api.api = slot_api;
api.module_index.push_back(ii); api.module_index.push_back(ii);
apis.push_back(api); apis.push_back(api);
} else { }
else
{
apis[kk].module_index.push_back(ii); apis[kk].module_index.push_back(ii);
} }
} }
...@@ -476,15 +492,18 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -476,15 +492,18 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
/* Calculate num sub modules */ /* Calculate num sub modules */
for (ii = 0; ii < num_modules; ii++) { for (ii = 0; ii < num_modules; ii++)
{
num_sm = dev_data->slot_data[ii]->subslot_data.size(); num_sm = dev_data->slot_data[ii]->subslot_data.size();
num_submodules += num_sm; num_submodules += num_sm;
for (jj = 0; jj < num_sm; jj++) { for (jj = 0; jj < num_sm; jj++)
num_datarecords {
+= dev_data->slot_data[ii]->subslot_data[jj]->data_record.size(); num_datarecords +=
dev_data->slot_data[ii]->subslot_data[jj]->data_record.size();
for (kk = 0; for (kk = 0;
kk < dev_data->slot_data[ii]->subslot_data[jj]->data_record.size(); kk < dev_data->slot_data[ii]->subslot_data[jj]->data_record.size();
kk++) { kk++)
{
data_record_length += dev_data->slot_data[ii] data_record_length += dev_data->slot_data[ii]
->subslot_data[jj] ->subslot_data[jj]
->data_record[kk] ->data_record[kk]
...@@ -493,13 +512,16 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -493,13 +512,16 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
} }
} }
length = sizeof(T_PN_SERVICE_DOWNLOAD_REQ) + num_iocrs * sizeof(T_PN_IOCR) //printf("Number of submodules for this slave: %d\n", num_submodules);
+ num_apis * sizeof(T_PN_API) + num_modules * sizeof(T_PN_MODULE) //printf("Data record size for slave: %d\n", data_record_length);
+ num_submodules * sizeof(T_PN_SUBMODULE)
+ num_datarecords * sizeof(T_PN_DATA_RECORD) length = sizeof(T_PN_SERVICE_DOWNLOAD_REQ) + num_iocrs * sizeof(T_PN_IOCR) +
+ (num_iocrs * num_apis + num_modules + num_datarecords) num_apis * sizeof(T_PN_API) + num_modules * sizeof(T_PN_MODULE) +
* sizeof(T_PN_REFERENCE) num_submodules * sizeof(T_PN_SUBMODULE) +
+ data_record_length; num_datarecords * sizeof(T_PN_DATA_RECORD) +
(num_iocrs * num_apis + num_modules + num_datarecords) *
sizeof(T_PN_REFERENCE) +
data_record_length;
pData = (char*)(service_desc + 1); pData = (char*)(service_desc + 1);
...@@ -525,7 +547,8 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -525,7 +547,8 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
T_PN_REFERENCE* pDataRecordReference; T_PN_REFERENCE* pDataRecordReference;
T_PN_DATA_RECORD* pDataRecord; T_PN_DATA_RECORD* pDataRecord;
if (device_ref == 1) { if (device_ref == 1)
{
// printf("sizeof download-struct: %d\n", // printf("sizeof download-struct: %d\n",
// sizeof(T_PN_SERVICE_DOWNLOAD_REQ)); // sizeof(T_PN_SERVICE_DOWNLOAD_REQ));
// printf("sizeof IOCR-struct: %d\n", sizeof(T_PN_IOCR)); // printf("sizeof IOCR-struct: %d\n", sizeof(T_PN_IOCR));
...@@ -536,20 +559,24 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -536,20 +559,24 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
// printf("sizeof REFERENCE-struct: %d\n", sizeof(T_PN_REFERENCE)); // printf("sizeof REFERENCE-struct: %d\n", sizeof(T_PN_REFERENCE));
} }
no_items = sscanf(dev_data->ip_address, "%hhi.%hhi.%hhi.%hhi", no_items =
&high_high_byte, &high_low_byte, &low_high_byte, &low_low_byte); sscanf(dev_data->ip_address, "%hhi.%hhi.%hhi.%hhi", &high_high_byte,
&high_low_byte, &low_high_byte, &low_low_byte);
if (no_items == 4) { if (no_items == 4)
{
pSDR->IpAddressHighWordHighByte = high_high_byte; pSDR->IpAddressHighWordHighByte = high_high_byte;
pSDR->IpAddressHighWordLowByte = high_low_byte; pSDR->IpAddressHighWordLowByte = high_low_byte;
pSDR->IpAddressLowWordHighByte = low_high_byte; pSDR->IpAddressLowWordHighByte = low_high_byte;
pSDR->IpAddressLowWordLowByte = low_low_byte; pSDR->IpAddressLowWordLowByte = low_low_byte;
} }
no_items = sscanf(dev_data->subnet_mask, "%hhi.%hhi.%hhi.%hhi", no_items =
&high_high_byte, &high_low_byte, &low_high_byte, &low_low_byte); sscanf(dev_data->subnet_mask, "%hhi.%hhi.%hhi.%hhi", &high_high_byte,
&high_low_byte, &low_high_byte, &low_low_byte);
if (no_items == 4) { if (no_items == 4)
{
pSDR->SubnetMaskHighWordHighByte = high_high_byte; pSDR->SubnetMaskHighWordHighByte = high_high_byte;
pSDR->SubnetMaskHighWordLowByte = high_low_byte; pSDR->SubnetMaskHighWordLowByte = high_low_byte;
pSDR->SubnetMaskLowWordHighByte = low_high_byte; pSDR->SubnetMaskLowWordHighByte = low_high_byte;
...@@ -558,16 +585,31 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -558,16 +585,31 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
sprintf(pSDR->DeviceName, dev_data->device_name); sprintf(pSDR->DeviceName, dev_data->device_name);
if (device_ref == PN_DEVICE_REFERENCE_THIS_STATION) { if (device_ref == PN_DEVICE_REFERENCE_THIS_STATION)
{
sprintf(pSDR->InterfaceName, dev_data->device_text); sprintf(pSDR->InterfaceName, dev_data->device_text);
pSDR->Flag = PN_SERVICE_DOWNLOAD_FLAG_AUTO_CONTROL_RES; // pSDR->Flag = PN_SERVICE_DOWNLOAD_FLAG_ACTIVATE;
// PN_SERVICE_DOWNLOAD_FLAG_FULL_APPLICATION_IDENT_SUPPORT
// PN_SERVICE_DOWNLOAD_FLAG_DISABLE_DCP_HELLO
// PN_SERVICE_DOWNLOAD_FLAG_CERTIFICATION_ACTIVE
// pSDR->Flag = PN_SERVICE_DOWNLOAD_FLAG_AUTO_CONTROL_RES;
ar_property = 0; ar_property = 0;
pSDR->InstanceLowByte = 0; pSDR->InstanceLowByte = 0;
} else { }
else
{
pSDR->Flag = PN_SERVICE_DOWNLOAD_FLAG_ACTIVATE; pSDR->Flag = PN_SERVICE_DOWNLOAD_FLAG_ACTIVATE;
ar_property = PROFINET_AR_PROPERTY_STATE_PRIMARY // pSDR->Flag = PN_SERVICE_DOWNLOAD_FLAG_DISABLE_DCP_HELLO |
| PROFINET_AR_PROPERTY_PARAMETER_SERVER_CM // PN_SERVICE_DOWNLOAD_FLAG_FULL_APPLICATION_IDENT_SUPPORT;
| PROFINET_AR_PROPERTY_DATA_RATE_100MBIT; ar_property = PROFINET_AR_PROPERTY_STATE_PRIMARY |
PROFINET_AR_PROPERTY_PARAMETER_SERVER_CM |
PROFINET_AR_PROPERTY_DATA_RATE_100MBIT |
PROFINET_AR_PROPERTY_STARTUP_MODE_LEGACY;
// pSDR->AdditionalFlag =
// PN_SERVICE_DOWNLOAD_ADD_FLAG_ENABLE_MULTIPLE_WRITE;
pSDR->InstanceHighByte = _PN_U16_HIGH_BYTE(dev_data->instance); pSDR->InstanceHighByte = _PN_U16_HIGH_BYTE(dev_data->instance);
pSDR->InstanceLowByte = _PN_U16_LOW_BYTE(dev_data->instance); pSDR->InstanceLowByte = _PN_U16_LOW_BYTE(dev_data->instance);
} }
...@@ -620,33 +662,35 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -620,33 +662,35 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
pIOCR = (T_PN_IOCR*)(pSDR + 1); pIOCR = (T_PN_IOCR*)(pSDR + 1);
for (ii = 0; ii < num_iocrs; ii++) { for (ii = 0; ii < num_iocrs; ii++)
{
/* Fill data for IOCR */ /* Fill data for IOCR */
pIOCR->VersionHighByte = pSDR->VersionHighByte; pIOCR->VersionHighByte = pSDR->VersionHighByte;
pIOCR->VersionLowByte = pSDR->VersionLowByte; pIOCR->VersionLowByte = pSDR->VersionLowByte;
pIOCR->TypeHighByte = _PN_U16_HIGH_BYTE(dev_data->iocr_data[ii]->type); pIOCR->TypeHighByte = _PN_U16_HIGH_BYTE(dev_data->iocr_data[ii]->type);
pIOCR->TypeLowByte = _PN_U16_LOW_BYTE(dev_data->iocr_data[ii]->type); pIOCR->TypeLowByte = _PN_U16_LOW_BYTE(dev_data->iocr_data[ii]->type);
pIOCR->PropertiesHighWordHighByte pIOCR->PropertiesHighWordHighByte =
= _PN_U32_HIGH_HIGH_BYTE(dev_data->iocr_data[ii]->properties); _PN_U32_HIGH_HIGH_BYTE(dev_data->iocr_data[ii]->properties);
pIOCR->PropertiesHighWordLowByte pIOCR->PropertiesHighWordLowByte =
= _PN_U32_HIGH_LOW_BYTE(dev_data->iocr_data[ii]->properties); _PN_U32_HIGH_LOW_BYTE(dev_data->iocr_data[ii]->properties);
pIOCR->PropertiesLowWordHighByte pIOCR->PropertiesLowWordHighByte =
= _PN_U32_LOW_HIGH_BYTE(dev_data->iocr_data[ii]->properties); _PN_U32_LOW_HIGH_BYTE(dev_data->iocr_data[ii]->properties);
pIOCR->PropertiesLowWordLowByte pIOCR->PropertiesLowWordLowByte =
= _PN_U32_LOW_LOW_BYTE(dev_data->iocr_data[ii]->properties); _PN_U32_LOW_LOW_BYTE(dev_data->iocr_data[ii]->properties);
pIOCR->SendClockFactorHighByte pIOCR->SendClockFactorHighByte =
= _PN_U16_HIGH_BYTE(dev_data->iocr_data[ii]->send_clock_factor); _PN_U16_HIGH_BYTE(dev_data->iocr_data[ii]->send_clock_factor);
pIOCR->SendClockFactorLowByte pIOCR->SendClockFactorLowByte =
= _PN_U16_LOW_BYTE(dev_data->iocr_data[ii]->send_clock_factor); _PN_U16_LOW_BYTE(dev_data->iocr_data[ii]->send_clock_factor);
if (dev_data->iocr_data[ii]->reduction_ratio < 1) { if (dev_data->iocr_data[ii]->reduction_ratio < 1)
{
dev_data->iocr_data[ii]->reduction_ratio = 1; dev_data->iocr_data[ii]->reduction_ratio = 1;
} }
pIOCR->ReductionRatioHighByte pIOCR->ReductionRatioHighByte =
= _PN_U16_HIGH_BYTE(dev_data->iocr_data[ii]->reduction_ratio); _PN_U16_HIGH_BYTE(dev_data->iocr_data[ii]->reduction_ratio);
pIOCR->ReductionRatioLowByte pIOCR->ReductionRatioLowByte =
= _PN_U16_LOW_BYTE(dev_data->iocr_data[ii]->reduction_ratio); _PN_U16_LOW_BYTE(dev_data->iocr_data[ii]->reduction_ratio);
if (dev_data->iocr_data[ii]->reduction_ratio == 0) if (dev_data->iocr_data[ii]->reduction_ratio == 0)
dev_data->iocr_data[ii]->reduction_ratio = 1; dev_data->iocr_data[ii]->reduction_ratio = 1;
...@@ -690,7 +734,8 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -690,7 +734,8 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
pAPIReference = (T_PN_REFERENCE*)(pIOCR + 1); pAPIReference = (T_PN_REFERENCE*)(pIOCR + 1);
for (jj = 0; jj < num_apis; jj++) { for (jj = 0; jj < num_apis; jj++)
{
pAPIReference->ReferenceHighByte = _PN_U16_HIGH_BYTE(jj); pAPIReference->ReferenceHighByte = _PN_U16_HIGH_BYTE(jj);
pAPIReference->ReferenceLowByte = _PN_U16_LOW_BYTE(jj); pAPIReference->ReferenceLowByte = _PN_U16_LOW_BYTE(jj);
pAPIReference++; pAPIReference++;
...@@ -703,7 +748,8 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -703,7 +748,8 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
T_PN_API* pAPI = (T_PN_API*)pIOCR; T_PN_API* pAPI = (T_PN_API*)pIOCR;
for (ii = 0; ii < num_apis; ii++) { for (ii = 0; ii < num_apis; ii++)
{
/* Fill data for API */ /* Fill data for API */
/* pAPI->APIHighWordHighByte = _PN_U32_HIGH_HIGH_BYTE(15616); /* pAPI->APIHighWordHighByte = _PN_U32_HIGH_HIGH_BYTE(15616);
...@@ -719,21 +765,22 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -719,21 +765,22 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
pAPI->APILowWordHighByte = _PN_U32_LOW_HIGH_BYTE(apis[ii].api); pAPI->APILowWordHighByte = _PN_U32_LOW_HIGH_BYTE(apis[ii].api);
pAPI->APILowWordLowByte = _PN_U32_LOW_LOW_BYTE(apis[ii].api); pAPI->APILowWordLowByte = _PN_U32_LOW_LOW_BYTE(apis[ii].api);
pAPI->NumberOfModulesHighByte pAPI->NumberOfModulesHighByte =
= _PN_U16_HIGH_BYTE(apis[ii].module_index.size()); _PN_U16_HIGH_BYTE(apis[ii].module_index.size());
pAPI->NumberOfModulesLowByte pAPI->NumberOfModulesLowByte =
= _PN_U16_LOW_BYTE(apis[ii].module_index.size()); _PN_U16_LOW_BYTE(apis[ii].module_index.size());
/* Fill references to Modules */ /* Fill references to Modules */
pModuleReference = (T_PN_REFERENCE*)(pAPI + 1); pModuleReference = (T_PN_REFERENCE*)(pAPI + 1);
for (module_ind = 0; module_ind < apis[ii].module_index.size(); for (module_ind = 0; module_ind < apis[ii].module_index.size();
module_ind++) { module_ind++)
pModuleReference->ReferenceHighByte {
= _PN_U16_HIGH_BYTE(apis[ii].module_index[module_ind]); pModuleReference->ReferenceHighByte =
pModuleReference->ReferenceLowByte _PN_U16_HIGH_BYTE(apis[ii].module_index[module_ind]);
= _PN_U16_LOW_BYTE(apis[ii].module_index[module_ind]); pModuleReference->ReferenceLowByte =
_PN_U16_LOW_BYTE(apis[ii].module_index[module_ind]);
pModuleReference++; pModuleReference++;
} }
...@@ -744,35 +791,37 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -744,35 +791,37 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
pModule = (T_PN_MODULE*)pAPI; pModule = (T_PN_MODULE*)pAPI;
for (ii = 0; ii < num_modules; ii++) { for (ii = 0; ii < num_modules; ii++)
{
/* Fill data for MODULE */ /* Fill data for MODULE */
pModule->VersionHighByte = pSDR->VersionHighByte; pModule->VersionHighByte = pSDR->VersionHighByte;
pModule->VersionLowByte = pSDR->VersionLowByte; pModule->VersionLowByte = pSDR->VersionLowByte;
pModule->SlotNumberHighByte pModule->SlotNumberHighByte =
= _PN_U16_HIGH_BYTE(dev_data->slot_data[ii]->slot_number); _PN_U16_HIGH_BYTE(dev_data->slot_data[ii]->slot_number);
pModule->SlotNumberLowByte pModule->SlotNumberLowByte =
= _PN_U16_LOW_BYTE(dev_data->slot_data[ii]->slot_number); _PN_U16_LOW_BYTE(dev_data->slot_data[ii]->slot_number);
pModule->IdentNumberHighWordHighByte pModule->IdentNumberHighWordHighByte =
= _PN_U32_HIGH_HIGH_BYTE(dev_data->slot_data[ii]->module_ident_number); _PN_U32_HIGH_HIGH_BYTE(dev_data->slot_data[ii]->module_ident_number);
pModule->IdentNumberHighWordLowByte pModule->IdentNumberHighWordLowByte =
= _PN_U32_HIGH_LOW_BYTE(dev_data->slot_data[ii]->module_ident_number); _PN_U32_HIGH_LOW_BYTE(dev_data->slot_data[ii]->module_ident_number);
pModule->IdentNumberLowWordHighByte pModule->IdentNumberLowWordHighByte =
= _PN_U32_LOW_HIGH_BYTE(dev_data->slot_data[ii]->module_ident_number); _PN_U32_LOW_HIGH_BYTE(dev_data->slot_data[ii]->module_ident_number);
pModule->IdentNumberLowWordLowByte pModule->IdentNumberLowWordLowByte =
= _PN_U32_LOW_LOW_BYTE(dev_data->slot_data[ii]->module_ident_number); _PN_U32_LOW_LOW_BYTE(dev_data->slot_data[ii]->module_ident_number);
pModule->PropertiesHighByte = 0; pModule->PropertiesHighByte = 0;
pModule->PropertiesLowByte = 0; pModule->PropertiesLowByte = 0;
pModule->NumberOfSubmodulesHighByte pModule->NumberOfSubmodulesHighByte =
= _PN_U16_HIGH_BYTE(dev_data->slot_data[ii]->subslot_data.size()); _PN_U16_HIGH_BYTE(dev_data->slot_data[ii]->subslot_data.size());
pModule->NumberOfSubmodulesLowByte pModule->NumberOfSubmodulesLowByte =
= _PN_U16_LOW_BYTE(dev_data->slot_data[ii]->subslot_data.size()); _PN_U16_LOW_BYTE(dev_data->slot_data[ii]->subslot_data.size());
/* Fill the SUBMODULE's */ /* Fill the SUBMODULE's */
pSubModule = (T_PN_SUBMODULE*)(pModule + 1); pSubModule = (T_PN_SUBMODULE*)(pModule + 1);
for (jj = 0; jj < dev_data->slot_data[ii]->subslot_data.size(); jj++) { for (jj = 0; jj < dev_data->slot_data[ii]->subslot_data.size(); jj++)
{
/* Fill data for the submodule */ /* Fill data for the submodule */
pSubModule->SubSlotNumberHighByte = _PN_U16_HIGH_BYTE( pSubModule->SubSlotNumberHighByte = _PN_U16_HIGH_BYTE(
...@@ -788,15 +837,21 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -788,15 +837,21 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
pSubModule->IdentNumberLowWordLowByte = _PN_U32_LOW_LOW_BYTE( pSubModule->IdentNumberLowWordLowByte = _PN_U32_LOW_LOW_BYTE(
dev_data->slot_data[ii]->subslot_data[jj]->submodule_ident_number); dev_data->slot_data[ii]->subslot_data[jj]->submodule_ident_number);
if ((dev_data->slot_data[ii]->subslot_data[jj]->io_input_length > 0) if ((dev_data->slot_data[ii]->subslot_data[jj]->io_input_length > 0) &&
&& (dev_data->slot_data[ii]->subslot_data[jj]->io_output_length)) { (dev_data->slot_data[ii]->subslot_data[jj]->io_output_length))
{
sub_prop = PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT; sub_prop = PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT;
} else if (dev_data->slot_data[ii]->subslot_data[jj]->io_input_length }
> 0) { else if (dev_data->slot_data[ii]->subslot_data[jj]->io_input_length > 0)
{
sub_prop = PROFINET_IO_SUBMODULE_TYPE_INPUT; sub_prop = PROFINET_IO_SUBMODULE_TYPE_INPUT;
} else if (dev_data->slot_data[ii]->subslot_data[jj]->io_output_length) { }
else if (dev_data->slot_data[ii]->subslot_data[jj]->io_output_length)
{
sub_prop = PROFINET_IO_SUBMODULE_TYPE_OUTPUT; sub_prop = PROFINET_IO_SUBMODULE_TYPE_OUTPUT;
} else { }
else
{
sub_prop = PROFINET_IO_SUBMODULE_TYPE_NO_INPUT_NO_OUTPUT; sub_prop = PROFINET_IO_SUBMODULE_TYPE_NO_INPUT_NO_OUTPUT;
} }
...@@ -823,11 +878,12 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -823,11 +878,12 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
for (kk = 0; for (kk = 0;
kk < dev_data->slot_data[ii]->subslot_data[jj]->data_record.size(); kk < dev_data->slot_data[ii]->subslot_data[jj]->data_record.size();
kk++) { kk++)
pDataRecordReference->ReferenceHighByte {
= _PN_U16_HIGH_BYTE(datarecord_ind); pDataRecordReference->ReferenceHighByte =
pDataRecordReference->ReferenceLowByte _PN_U16_HIGH_BYTE(datarecord_ind);
= _PN_U16_LOW_BYTE(datarecord_ind); pDataRecordReference->ReferenceLowByte =
_PN_U16_LOW_BYTE(datarecord_ind);
pDataRecordReference++; pDataRecordReference++;
datarecord_ind++; datarecord_ind++;
} }
...@@ -842,20 +898,23 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -842,20 +898,23 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
pDataRecord = (T_PN_DATA_RECORD*)pModule; pDataRecord = (T_PN_DATA_RECORD*)pModule;
for (ii = 0; ii < num_modules; ii++) { for (ii = 0; ii < num_modules; ii++)
for (jj = 0; jj < dev_data->slot_data[ii]->subslot_data.size(); jj++) { {
for (jj = 0; jj < dev_data->slot_data[ii]->subslot_data.size(); jj++)
{
for (kk = 0; for (kk = 0;
kk < dev_data->slot_data[ii]->subslot_data[jj]->data_record.size(); kk < dev_data->slot_data[ii]->subslot_data[jj]->data_record.size();
kk++) { kk++)
{
pDataRecord->VersionHighByte = pSDR->VersionHighByte; pDataRecord->VersionHighByte = pSDR->VersionHighByte;
pDataRecord->VersionLowByte = pSDR->VersionLowByte; pDataRecord->VersionLowByte = pSDR->VersionLowByte;
pDataRecord->SequenceHighByte pDataRecord->SequenceHighByte =
= _PN_U16_HIGH_BYTE(dev_data->slot_data[ii] _PN_U16_HIGH_BYTE(dev_data->slot_data[ii]
->subslot_data[jj] ->subslot_data[jj]
->data_record[kk] ->data_record[kk]
->transfer_sequence); ->transfer_sequence);
pDataRecord->SequenceLowByte pDataRecord->SequenceLowByte =
= _PN_U16_LOW_BYTE(dev_data->slot_data[ii] _PN_U16_LOW_BYTE(dev_data->slot_data[ii]
->subslot_data[jj] ->subslot_data[jj]
->data_record[kk] ->data_record[kk]
->transfer_sequence); ->transfer_sequence);
...@@ -923,7 +982,8 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, ...@@ -923,7 +982,8 @@ void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
{ {
if (pSdb->Result == PNAK_RESULT_POS) { if (pSdb->Result == PNAK_RESULT_POS)
{
T_PN_SERVICE_GET_LIST_OF_STATION_CON* pGetLOSCon; T_PN_SERVICE_GET_LIST_OF_STATION_CON* pGetLOSCon;
T_PN_DEVICE_INFO* pDeviceInfo; T_PN_DEVICE_INFO* pDeviceInfo;
PnDeviceInfo* dev_info; PnDeviceInfo* dev_info;
...@@ -934,8 +994,8 @@ int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -934,8 +994,8 @@ int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
pGetLOSCon = (T_PN_SERVICE_GET_LIST_OF_STATION_CON*)(pSdb + 1); pGetLOSCon = (T_PN_SERVICE_GET_LIST_OF_STATION_CON*)(pSdb + 1);
pDeviceInfo = (T_PN_DEVICE_INFO*)(pGetLOSCon + 1); pDeviceInfo = (T_PN_DEVICE_INFO*)(pGetLOSCon + 1);
NumberDevices NumberDevices =
= _HIGH_LOW_BYTES_TO_PN_U16(pGetLOSCon->NumberOfDevicesHighByte, _HIGH_LOW_BYTES_TO_PN_U16(pGetLOSCon->NumberOfDevicesHighByte,
pGetLOSCon->NumberOfDevicesLowByte); pGetLOSCon->NumberOfDevicesLowByte);
/* Find configured device */ /* Find configured device */
...@@ -943,7 +1003,8 @@ int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -943,7 +1003,8 @@ int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
if (NumberDevices == 0) if (NumberDevices == 0)
printf("0\r\n"); printf("0\r\n");
for (ii = 0; ii < NumberDevices; ii++) { for (ii = 0; ii < NumberDevices; ii++)
{
dev_info = new PnDeviceInfo; dev_info = new PnDeviceInfo;
dev_info->ipaddress[3] = pDeviceInfo->Ip.AddressHighWordHighByte; dev_info->ipaddress[3] = pDeviceInfo->Ip.AddressHighWordHighByte;
...@@ -958,15 +1019,15 @@ int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -958,15 +1019,15 @@ int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
dev_info->macaddress[1] = pDeviceInfo->MacAddress.LowHighByte; dev_info->macaddress[1] = pDeviceInfo->MacAddress.LowHighByte;
dev_info->macaddress[0] = pDeviceInfo->MacAddress.LowLowByte; dev_info->macaddress[0] = pDeviceInfo->MacAddress.LowLowByte;
dev_info->deviceid dev_info->deviceid =
= _HIGH_LOW_BYTES_TO_PN_U16(pDeviceInfo->Property.DeviceIdHighByte, _HIGH_LOW_BYTES_TO_PN_U16(pDeviceInfo->Property.DeviceIdHighByte,
pDeviceInfo->Property.DeviceIdLowByte); pDeviceInfo->Property.DeviceIdLowByte);
dev_info->vendorid dev_info->vendorid =
= _HIGH_LOW_BYTES_TO_PN_U16(pDeviceInfo->Property.VendorIdHighByte, _HIGH_LOW_BYTES_TO_PN_U16(pDeviceInfo->Property.VendorIdHighByte,
pDeviceInfo->Property.VendorIdLowByte); pDeviceInfo->Property.VendorIdLowByte);
name_length name_length =
= _HIGH_LOW_BYTES_TO_PN_U16(pDeviceInfo->DeviceNameLengthHighByte, _HIGH_LOW_BYTES_TO_PN_U16(pDeviceInfo->DeviceNameLengthHighByte,
pDeviceInfo->DeviceNameLengthLowByte); pDeviceInfo->DeviceNameLengthLowByte);
printf("no: %d mac: %hhx:%hhx:%hhx:%hhx:%hhx:%hhx\r\n", printf("no: %d mac: %hhx:%hhx:%hhx:%hhx:%hhx:%hhx\r\n",
...@@ -984,11 +1045,13 @@ int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -984,11 +1045,13 @@ int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
local->dev_info.push_back(dev_info); local->dev_info.push_back(dev_info);
pDeviceInfo pDeviceInfo =
= (T_PN_DEVICE_INFO*)((unsigned char*)pDeviceInfo + name_length); (T_PN_DEVICE_INFO*)((unsigned char*)pDeviceInfo + name_length);
} }
return PNAK_OK; return PNAK_OK;
} else if (pSdb->Result == PNAK_RESULT_NEG) { }
else if (pSdb->Result == PNAK_RESULT_NEG)
{
T_PN_SERVICE_ERROR_CON* pErrorCon = (T_PN_SERVICE_ERROR_CON*)(pSdb + 1); T_PN_SERVICE_ERROR_CON* pErrorCon = (T_PN_SERVICE_ERROR_CON*)(pSdb + 1);
printf("channel %d: get_los.con [-] (%d)\r\n" printf("channel %d: get_los.con [-] (%d)\r\n"
...@@ -996,9 +1059,10 @@ int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -996,9 +1059,10 @@ int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
" detail : %d (0x%02x)\r\n" " detail : %d (0x%02x)\r\n"
" add. detail: %d (0x%02x)\r\n" " add. detail: %d (0x%02x)\r\n"
" area : %d (0x%02x)\r\n", " area : %d (0x%02x)\r\n",
0, pSdb->DeviceRef, pErrorCon->Code, pErrorCon->Code, pErrorCon->Detail, 0, pSdb->DeviceRef, pErrorCon->Code, pErrorCon->Code,
pErrorCon->Detail, pErrorCon->AdditionalDetail, pErrorCon->Detail, pErrorCon->Detail, pErrorCon->AdditionalDetail,
pErrorCon->AdditionalDetail, pErrorCon->AreaCode, pErrorCon->AreaCode); pErrorCon->AdditionalDetail, pErrorCon->AreaCode,
pErrorCon->AreaCode);
} }
return -1; return -1;
...@@ -1006,9 +1070,13 @@ int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -1006,9 +1070,13 @@ int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
int unpack_write_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) int unpack_write_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
{ {
if (pSdb->Result == PNAK_RESULT_POS) { if (pSdb->Result == PNAK_RESULT_POS)
{
// printf("Write con...\n");
return PNAK_OK; return PNAK_OK;
} else if (pSdb->Result == PNAK_RESULT_NEG) { }
else if (pSdb->Result == PNAK_RESULT_NEG)
{
T_PN_SERVICE_ERROR_CON* pErrorCon = (T_PN_SERVICE_ERROR_CON*)(pSdb + 1); T_PN_SERVICE_ERROR_CON* pErrorCon = (T_PN_SERVICE_ERROR_CON*)(pSdb + 1);
printf("channel %d: write.con [-] (%d)\r\n" printf("channel %d: write.con [-] (%d)\r\n"
...@@ -1016,18 +1084,20 @@ int unpack_write_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -1016,18 +1084,20 @@ int unpack_write_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
" detail : %d (0x%02x)\r\n" " detail : %d (0x%02x)\r\n"
" add. detail: %d (0x%02x)\r\n" " add. detail: %d (0x%02x)\r\n"
" area : %d (0x%02x)\r\n", " area : %d (0x%02x)\r\n",
0, pSdb->DeviceRef, pErrorCon->Code, pErrorCon->Code, pErrorCon->Detail, 0, pSdb->DeviceRef, pErrorCon->Code, pErrorCon->Code,
pErrorCon->Detail, pErrorCon->AdditionalDetail, pErrorCon->Detail, pErrorCon->Detail, pErrorCon->AdditionalDetail,
pErrorCon->AdditionalDetail, pErrorCon->AreaCode, pErrorCon->AreaCode); pErrorCon->AdditionalDetail, pErrorCon->AreaCode,
pErrorCon->AreaCode);
} }
return -1; return -1;
} }
int unpack_get_alarm_con( int unpack_get_alarm_con(T_PNAK_SERVICE_DESCRIPTION* pSdb,
T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local, io_sAgent* ap) io_sAgentLocal* local, io_sAgent* ap)
{ {
if (pSdb->Result == PNAK_RESULT_POS) { if (pSdb->Result == PNAK_RESULT_POS)
{
T_PN_SERVICE_GET_ALARM_CON* pGAC; T_PN_SERVICE_GET_ALARM_CON* pGAC;
unsigned short alarm_type; unsigned short alarm_type;
...@@ -1049,34 +1119,36 @@ int unpack_get_alarm_con( ...@@ -1049,34 +1119,36 @@ int unpack_get_alarm_con(
alarm_prio = pGAC->AlarmPriority; alarm_prio = pGAC->AlarmPriority;
rem_alarms = pGAC->RemainingAlarms; rem_alarms = pGAC->RemainingAlarms;
alarm_ref = _HIGH_LOW_BYTES_TO_PN_U16( alarm_ref = _HIGH_LOW_BYTES_TO_PN_U16(pGAC->AlarmRefHighByte,
pGAC->AlarmRefHighByte, pGAC->AlarmRefLowByte); pGAC->AlarmRefLowByte);
alarm_type = _HIGH_LOW_BYTES_TO_PN_U16( alarm_type = _HIGH_LOW_BYTES_TO_PN_U16(pGAC->AlarmTypeHighByte,
pGAC->AlarmTypeHighByte, pGAC->AlarmTypeLowByte); pGAC->AlarmTypeLowByte);
slot_number = _HIGH_LOW_BYTES_TO_PN_U16( slot_number = _HIGH_LOW_BYTES_TO_PN_U16(pGAC->SlotNumberHighByte,
pGAC->SlotNumberHighByte, pGAC->SlotNumberLowByte); pGAC->SlotNumberLowByte);
sub_slot_number = _HIGH_LOW_BYTES_TO_PN_U16( sub_slot_number = _HIGH_LOW_BYTES_TO_PN_U16(pGAC->SubSlotNumberHighByte,
pGAC->SubSlotNumberHighByte, pGAC->SubSlotNumberLowByte); pGAC->SubSlotNumberLowByte);
module_ident_number module_ident_number =
= _HIGH_LOW_BYTES_TO_PN_U32(pGAC->ModuleIdentNumberHighWordHighByte, _HIGH_LOW_BYTES_TO_PN_U32(pGAC->ModuleIdentNumberHighWordHighByte,
pGAC->ModuleIdentNumberHighWordLowByte, pGAC->ModuleIdentNumberHighWordLowByte,
pGAC->ModuleIdentNumberLowWordHighByte, pGAC->ModuleIdentNumberLowWordHighByte,
pGAC->ModuleIdentNumberLowWordLowByte); pGAC->ModuleIdentNumberLowWordLowByte);
submodule_ident_number submodule_ident_number =
= _HIGH_LOW_BYTES_TO_PN_U32(pGAC->SubmoduleIdentNumberHighWordHighByte, _HIGH_LOW_BYTES_TO_PN_U32(pGAC->SubmoduleIdentNumberHighWordHighByte,
pGAC->SubmoduleIdentNumberHighWordLowByte, pGAC->SubmoduleIdentNumberHighWordLowByte,
pGAC->SubmoduleIdentNumberLowWordHighByte, pGAC->SubmoduleIdentNumberLowWordHighByte,
pGAC->SubmoduleIdentNumberLowWordLowByte); pGAC->SubmoduleIdentNumberLowWordLowByte);
alarm_spec = _HIGH_LOW_BYTES_TO_PN_U16( alarm_spec = _HIGH_LOW_BYTES_TO_PN_U16(pGAC->SpecifierHighByte,
pGAC->SpecifierHighByte, pGAC->SpecifierLowByte); pGAC->SpecifierLowByte);
data_length data_length =
= _HIGH_LOW_BYTES_TO_PN_U16(pGAC->LengthHighByte, pGAC->LengthLowByte); _HIGH_LOW_BYTES_TO_PN_U16(pGAC->LengthHighByte, pGAC->LengthLowByte);
data = (unsigned char*)(pGAC + 1); data = (unsigned char*)(pGAC + 1);
/* Find the device */ /* Find the device */
for (ii = 0; ii < local->device_data.size(); ii++) { for (ii = 0; ii < local->device_data.size(); ii++)
if (local->device_data[ii]->alarm_ref == alarm_ref) { {
if (local->device_data[ii]->alarm_ref == alarm_ref)
{
device = local->device_data[ii]; device = local->device_data[ii];
device->alarm_data.alarm_type = alarm_type; device->alarm_data.alarm_type = alarm_type;
...@@ -1093,14 +1165,17 @@ int unpack_get_alarm_con( ...@@ -1093,14 +1165,17 @@ int unpack_get_alarm_con(
} }
} }
if (ap) { if (ap)
{
/* Find corresponding device */ /* Find corresponding device */
io_sRack* slave_list; io_sRack* slave_list;
for (slave_list = ap->racklist, jj = 0; for (slave_list = ap->racklist, jj = 0;
(slave_list != NULL) && jj < ii - 1; (slave_list != NULL) && jj < ii - 1;
slave_list = slave_list->next, jj++) { slave_list = slave_list->next, jj++)
{
} }
if (slave_list) { if (slave_list)
{
pwr_sClass_PnDevice* dev; pwr_sClass_PnDevice* dev;
dev = (pwr_sClass_PnDevice*)slave_list->op; dev = (pwr_sClass_PnDevice*)slave_list->op;
...@@ -1113,9 +1188,10 @@ int unpack_get_alarm_con( ...@@ -1113,9 +1188,10 @@ int unpack_get_alarm_con(
dev->Alarm.SubmoduleIdentNumber = submodule_ident_number; dev->Alarm.SubmoduleIdentNumber = submodule_ident_number;
dev->Alarm.Specifier = alarm_spec; dev->Alarm.Specifier = alarm_spec;
dev->Alarm.ManuSpecLength = data_length; dev->Alarm.ManuSpecLength = data_length;
if (data_length > 0) { if (data_length > 0)
memcpy( {
dev->Alarm.Data, data, MIN(data_length, sizeof(dev->Alarm.Data))); memcpy(dev->Alarm.Data, data,
MIN(data_length, sizeof(dev->Alarm.Data)));
} }
} }
} }
...@@ -1131,7 +1207,9 @@ int unpack_get_alarm_con( ...@@ -1131,7 +1207,9 @@ int unpack_get_alarm_con(
alarm_prio, rem_alarms, alarm_type, slot_number, sub_slot_number, alarm_prio, rem_alarms, alarm_type, slot_number, sub_slot_number,
module_ident_number, submodule_ident_number, alarm_spec); module_ident_number, submodule_ident_number, alarm_spec);
return PNAK_OK; return PNAK_OK;
} else if (pSdb->Result == PNAK_RESULT_NEG) { }
else if (pSdb->Result == PNAK_RESULT_NEG)
{
T_PN_SERVICE_ERROR_CON* pErrorCon = (T_PN_SERVICE_ERROR_CON*)(pSdb + 1); T_PN_SERVICE_ERROR_CON* pErrorCon = (T_PN_SERVICE_ERROR_CON*)(pSdb + 1);
printf("channel %d: get_los.con [-] (%d)\r\n" printf("channel %d: get_los.con [-] (%d)\r\n"
...@@ -1139,17 +1217,19 @@ int unpack_get_alarm_con( ...@@ -1139,17 +1217,19 @@ int unpack_get_alarm_con(
" detail : %d (0x%02x)\r\n" " detail : %d (0x%02x)\r\n"
" add. detail: %d (0x%02x)\r\n" " add. detail: %d (0x%02x)\r\n"
" area : %d (0x%02x)\r\n", " area : %d (0x%02x)\r\n",
0, pSdb->DeviceRef, pErrorCon->Code, pErrorCon->Code, pErrorCon->Detail, 0, pSdb->DeviceRef, pErrorCon->Code, pErrorCon->Code,
pErrorCon->Detail, pErrorCon->AdditionalDetail, pErrorCon->Detail, pErrorCon->Detail, pErrorCon->AdditionalDetail,
pErrorCon->AdditionalDetail, pErrorCon->AreaCode, pErrorCon->AreaCode); pErrorCon->AdditionalDetail, pErrorCon->AreaCode,
pErrorCon->AreaCode);
} }
return -1; return -1;
} }
int unpack_get_device_state_con( int unpack_get_device_state_con(T_PNAK_SERVICE_DESCRIPTION* pSdb,
T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local, io_sAgent* ap) io_sAgentLocal* local, io_sAgent* ap)
{ {
if (pSdb->Result == PNAK_RESULT_POS) { if (pSdb->Result == PNAK_RESULT_POS)
{
T_PN_SERVICE_GET_DEVICE_STATE_CON* pGDSC; T_PN_SERVICE_GET_DEVICE_STATE_CON* pGDSC;
T_PN_DIFF_MODULE* pDiffModule; T_PN_DIFF_MODULE* pDiffModule;
...@@ -1168,8 +1248,10 @@ int unpack_get_device_state_con( ...@@ -1168,8 +1248,10 @@ int unpack_get_device_state_con(
/* Find configured device */ /* Find configured device */
for (ii = 0; ii < local->device_data.size(); ii++) { for (ii = 0; ii < local->device_data.size(); ii++)
if (local->device_data[ii]->device_ref == device_ref) { {
if (local->device_data[ii]->device_ref == device_ref)
{
device = local->device_data[ii]; device = local->device_data[ii];
break; break;
} }
...@@ -1186,50 +1268,55 @@ int unpack_get_device_state_con( ...@@ -1186,50 +1268,55 @@ int unpack_get_device_state_con(
pGDSC->NumberOfDiffModulesHighByte, pGDSC->NumberOfDiffModulesLowByte); pGDSC->NumberOfDiffModulesHighByte, pGDSC->NumberOfDiffModulesLowByte);
device->no_diff_modules = no_diff_modules; device->no_diff_modules = no_diff_modules;
device->device_state device->device_state =
= _HIGH_LOW_BYTES_TO_PN_U16(pGDSC->StateHighByte, pGDSC->StateLowByte); _HIGH_LOW_BYTES_TO_PN_U16(pGDSC->StateHighByte, pGDSC->StateLowByte);
// printf("No diff modules: %d \r\n", no_diff_modules); // printf("No diff modules: %d \r\n", no_diff_modules);
for (diff_mod_index = 0u; diff_mod_index < no_diff_modules; for (diff_mod_index = 0u; diff_mod_index < no_diff_modules;
diff_mod_index++) { diff_mod_index++)
T_PN_DIFF_MODULE_API* pDiffModuleAPI {
= (T_PN_DIFF_MODULE_API*)(pDiffModule + 1); T_PN_DIFF_MODULE_API* pDiffModuleAPI =
(T_PN_DIFF_MODULE_API*)(pDiffModule + 1);
PN_U16 no_apis; PN_U16 no_apis;
PN_U16 api_ind; PN_U16 api_ind;
no_apis = _HIGH_LOW_BYTES_TO_PN_U16( no_apis = _HIGH_LOW_BYTES_TO_PN_U16(pDiffModule->NumberOfAPIsHighByte,
pDiffModule->NumberOfAPIsHighByte, pDiffModule->NumberOfAPIsLowByte); pDiffModule->NumberOfAPIsLowByte);
for (api_ind = 0u; api_ind < no_apis; api_ind++) { for (api_ind = 0u; api_ind < no_apis; api_ind++)
T_PN_DIFF_MODULE_SLOT* pModuleSlot {
= (T_PN_DIFF_MODULE_SLOT*)(pDiffModuleAPI + 1); T_PN_DIFF_MODULE_SLOT* pModuleSlot =
(T_PN_DIFF_MODULE_SLOT*)(pDiffModuleAPI + 1);
PN_U16 no_slots; PN_U16 no_slots;
PN_U16 slot_ind; PN_U16 slot_ind;
no_slots no_slots =
= _HIGH_LOW_BYTES_TO_PN_U16(pDiffModuleAPI->NumberOfModulesHighByte, _HIGH_LOW_BYTES_TO_PN_U16(pDiffModuleAPI->NumberOfModulesHighByte,
pDiffModuleAPI->NumberOfModulesLowByte); pDiffModuleAPI->NumberOfModulesLowByte);
for (slot_ind = 0u; slot_ind < no_slots; slot_ind++) { for (slot_ind = 0u; slot_ind < no_slots; slot_ind++)
T_PN_DIFF_MODULE_SUBSLOT* pModuleSubSlot {
= (T_PN_DIFF_MODULE_SUBSLOT*)(pModuleSlot + 1); T_PN_DIFF_MODULE_SUBSLOT* pModuleSubSlot =
(T_PN_DIFF_MODULE_SUBSLOT*)(pModuleSlot + 1);
PN_U16 no_subslots; PN_U16 no_subslots;
PN_U16 subslot_ind; PN_U16 subslot_ind;
PnModuleData* module_data = NULL; PnModuleData* module_data = NULL;
no_subslots = _HIGH_LOW_BYTES_TO_PN_U16( no_subslots =
pModuleSlot->NumberOfSubmodulesHighByte, _HIGH_LOW_BYTES_TO_PN_U16(pModuleSlot->NumberOfSubmodulesHighByte,
pModuleSlot->NumberOfSubmodulesLowByte); pModuleSlot->NumberOfSubmodulesLowByte);
for (ii = 0; ii < device->module_data.size(); ii++) { for (ii = 0; ii < device->module_data.size(); ii++)
{
module_data = device->module_data[ii]; module_data = device->module_data[ii];
if (module_data->slot_number if (module_data->slot_number ==
== _HIGH_LOW_BYTES_TO_PN_U16(pModuleSlot->SlotNumberHighByte, _HIGH_LOW_BYTES_TO_PN_U16(pModuleSlot->SlotNumberHighByte,
pModuleSlot->SlotNumberLowByte)) { pModuleSlot->SlotNumberLowByte))
{
module_data->state = _HIGH_LOW_BYTES_TO_PN_U16( module_data->state = _HIGH_LOW_BYTES_TO_PN_U16(
pModuleSlot->StateHighByte, pModuleSlot->StateLowByte); pModuleSlot->StateHighByte, pModuleSlot->StateLowByte);
module_data->phys_ident_number = _HIGH_LOW_BYTES_TO_PN_U32( module_data->phys_ident_number = _HIGH_LOW_BYTES_TO_PN_U32(
...@@ -1239,7 +1326,8 @@ int unpack_get_device_state_con( ...@@ -1239,7 +1326,8 @@ int unpack_get_device_state_con(
pModuleSlot->IdentNumberLowWordLowByte); pModuleSlot->IdentNumberLowWordLowByte);
// printf(" Slot no: %d, State: %d \r\n", // printf(" Slot no: %d, State: %d \r\n",
// module_data->slot_number, module_data->state); // module_data->slot_number, module_data->state);
if (save_first) { if (save_first)
{
err_slot_number = module_data->slot_number; err_slot_number = module_data->slot_number;
err_module_state = module_data->state; err_module_state = module_data->state;
phys_ident_number = module_data->phys_ident_number; phys_ident_number = module_data->phys_ident_number;
...@@ -1249,18 +1337,22 @@ int unpack_get_device_state_con( ...@@ -1249,18 +1337,22 @@ int unpack_get_device_state_con(
} }
} }
for (subslot_ind = 0; subslot_ind < no_subslots; subslot_ind++) { for (subslot_ind = 0; subslot_ind < no_subslots; subslot_ind++)
{
PnSubmoduleData* submodule_data; PnSubmoduleData* submodule_data;
if (ii < device->module_data.size()) { if (ii < device->module_data.size())
for (jj = 0; jj < module_data->submodule_data.size(); jj++) { {
for (jj = 0; jj < module_data->submodule_data.size(); jj++)
{
submodule_data = module_data->submodule_data[jj]; submodule_data = module_data->submodule_data[jj];
if (submodule_data->subslot_number if (submodule_data->subslot_number ==
== _HIGH_LOW_BYTES_TO_PN_U16( _HIGH_LOW_BYTES_TO_PN_U16(
pModuleSubSlot->SubSlotNumberHighByte, pModuleSubSlot->SubSlotNumberHighByte,
pModuleSubSlot->SubSlotNumberLowByte)) { pModuleSubSlot->SubSlotNumberLowByte))
submodule_data->state {
= _HIGH_LOW_BYTES_TO_PN_U16(pModuleSubSlot->StateHighByte, submodule_data->state =
_HIGH_LOW_BYTES_TO_PN_U16(pModuleSubSlot->StateHighByte,
pModuleSubSlot->StateLowByte); pModuleSubSlot->StateLowByte);
submodule_data->phys_ident_number = _HIGH_LOW_BYTES_TO_PN_U32( submodule_data->phys_ident_number = _HIGH_LOW_BYTES_TO_PN_U32(
pModuleSubSlot->IdentNumberHighWordHighByte, pModuleSubSlot->IdentNumberHighWordHighByte,
...@@ -1282,14 +1374,17 @@ int unpack_get_device_state_con( ...@@ -1282,14 +1374,17 @@ int unpack_get_device_state_con(
pDiffModule = (T_PN_DIFF_MODULE*)pDiffModuleAPI; pDiffModule = (T_PN_DIFF_MODULE*)pDiffModuleAPI;
} }
if (ap) { if (ap)
{
/* Find corresponding device */ /* Find corresponding device */
io_sRack* slave_list; io_sRack* slave_list;
for (slave_list = ap->racklist, jj = 0; for (slave_list = ap->racklist, jj = 0;
(slave_list != NULL) && jj < dev_ind - 1; (slave_list != NULL) && jj < dev_ind - 1;
slave_list = slave_list->next, jj++) { slave_list = slave_list->next, jj++)
{
} }
if (slave_list) { if (slave_list)
{
pwr_sClass_PnDevice* dev; pwr_sClass_PnDevice* dev;
dev = (pwr_sClass_PnDevice*)slave_list->op; dev = (pwr_sClass_PnDevice*)slave_list->op;
dev->NoDiffModules = no_diff_modules; dev->NoDiffModules = no_diff_modules;
...@@ -1297,11 +1392,14 @@ int unpack_get_device_state_con( ...@@ -1297,11 +1392,14 @@ int unpack_get_device_state_con(
dev->Status = PB__NORMAL; dev->Status = PB__NORMAL;
else else
dev->Status = PB__NOCONN; dev->Status = PB__NOCONN;
if (!save_first) { if (!save_first)
{
dev->ErrSlotNumber = err_slot_number; dev->ErrSlotNumber = err_slot_number;
dev->ErrModuleState = err_module_state; dev->ErrModuleState = err_module_state;
dev->PhysIdentNumber = phys_ident_number; dev->PhysIdentNumber = phys_ident_number;
} else { }
else
{
dev->ErrSlotNumber = 0; dev->ErrSlotNumber = 0;
dev->ErrModuleState = 0; dev->ErrModuleState = 0;
dev->PhysIdentNumber = 0; dev->PhysIdentNumber = 0;
...@@ -1310,7 +1408,9 @@ int unpack_get_device_state_con( ...@@ -1310,7 +1408,9 @@ int unpack_get_device_state_con(
} }
return PNAK_OK; return PNAK_OK;
} else if (pSdb->Result == PNAK_RESULT_NEG) { }
else if (pSdb->Result == PNAK_RESULT_NEG)
{
T_PN_SERVICE_ERROR_CON* pErrorCon = (T_PN_SERVICE_ERROR_CON*)(pSdb + 1); T_PN_SERVICE_ERROR_CON* pErrorCon = (T_PN_SERVICE_ERROR_CON*)(pSdb + 1);
printf("channel %d: get_device_state.con [-] (%d)\r\n" printf("channel %d: get_device_state.con [-] (%d)\r\n"
...@@ -1318,9 +1418,10 @@ int unpack_get_device_state_con( ...@@ -1318,9 +1418,10 @@ int unpack_get_device_state_con(
" detail : %d (0x%02x)\r\n" " detail : %d (0x%02x)\r\n"
" add. detail: %d (0x%02x)\r\n" " add. detail: %d (0x%02x)\r\n"
" area : %d (0x%02x)\r\n", " area : %d (0x%02x)\r\n",
0, pSdb->DeviceRef, pErrorCon->Code, pErrorCon->Code, pErrorCon->Detail, 0, pSdb->DeviceRef, pErrorCon->Code, pErrorCon->Code,
pErrorCon->Detail, pErrorCon->AdditionalDetail, pErrorCon->Detail, pErrorCon->Detail, pErrorCon->AdditionalDetail,
pErrorCon->AdditionalDetail, pErrorCon->AreaCode, pErrorCon->AreaCode); pErrorCon->AdditionalDetail, pErrorCon->AreaCode,
pErrorCon->AreaCode);
} }
return -1; return -1;
...@@ -1328,7 +1429,8 @@ int unpack_get_device_state_con( ...@@ -1328,7 +1429,8 @@ int unpack_get_device_state_con(
int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
{ {
if (pSdb->Result == PNAK_RESULT_POS) { if (pSdb->Result == PNAK_RESULT_POS)
{
T_PN_SERVICE_DOWNLOAD_CON* pDownloadCon; T_PN_SERVICE_DOWNLOAD_CON* pDownloadCon;
T_PN_IOCR_INFO* pIOCRInfo; T_PN_IOCR_INFO* pIOCRInfo;
...@@ -1342,8 +1444,10 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -1342,8 +1444,10 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
/* Find configured device */ /* Find configured device */
for (ii = 0; ii < local->device_data.size(); ii++) { for (ii = 0; ii < local->device_data.size(); ii++)
if (local->device_data[ii]->device_ref == device_ref) { {
if (local->device_data[ii]->device_ref == device_ref)
{
device = local->device_data[ii]; device = local->device_data[ii];
break; break;
} }
...@@ -1354,13 +1458,14 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -1354,13 +1458,14 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
pDownloadCon = (T_PN_SERVICE_DOWNLOAD_CON*)(pSdb + 1); pDownloadCon = (T_PN_SERVICE_DOWNLOAD_CON*)(pSdb + 1);
pIOCRInfo = (T_PN_IOCR_INFO*)(pDownloadCon + 1); pIOCRInfo = (T_PN_IOCR_INFO*)(pDownloadCon + 1);
NumberIOCRs = _HIGH_LOW_BYTES_TO_PN_U16( NumberIOCRs = _HIGH_LOW_BYTES_TO_PN_U16(pDownloadCon->NumberOfIOCRHighByte,
pDownloadCon->NumberOfIOCRHighByte, pDownloadCon->NumberOfIOCRLowByte); pDownloadCon->NumberOfIOCRLowByte);
device->alarm_ref = _HIGH_LOW_BYTES_TO_PN_U16( device->alarm_ref = _HIGH_LOW_BYTES_TO_PN_U16(
pDownloadCon->AlarmRefHighByte, pDownloadCon->AlarmRefLowByte); pDownloadCon->AlarmRefHighByte, pDownloadCon->AlarmRefLowByte);
for (IOCRIndex = 0u; IOCRIndex < NumberIOCRs; IOCRIndex++) { for (IOCRIndex = 0u; IOCRIndex < NumberIOCRs; IOCRIndex++)
{
T_PN_API_INFO* pAPIInfo = (T_PN_API_INFO*)(pIOCRInfo + 1); T_PN_API_INFO* pAPIInfo = (T_PN_API_INFO*)(pIOCRInfo + 1);
PN_U16 NumberAPIs; PN_U16 NumberAPIs;
PN_U16 APIIndex; PN_U16 APIIndex;
...@@ -1368,25 +1473,28 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -1368,25 +1473,28 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
unsigned short type; unsigned short type;
type = _HIGH_LOW_BYTES_TO_PN_U16( type = _HIGH_LOW_BYTES_TO_PN_U16(pIOCRInfo->TypeHighByte,
pIOCRInfo->TypeHighByte, pIOCRInfo->TypeLowByte); pIOCRInfo->TypeLowByte);
for (ii = 0; ii < device->iocr_data.size(); ii++) { for (ii = 0; ii < device->iocr_data.size(); ii++)
if (device->iocr_data[ii]->type == type) { {
if (device->iocr_data[ii]->type == type)
{
iocr_data = device->iocr_data[ii]; iocr_data = device->iocr_data[ii];
break; break;
} }
} }
if (ii == device->iocr_data.size()) { if (ii == device->iocr_data.size())
{
/* This iocr is not found, log some thing and continue */ /* This iocr is not found, log some thing and continue */
printf("iocr not found %d \n", type); printf("iocr not found %d \n", type);
continue; continue;
} }
iocr_data->type = _HIGH_LOW_BYTES_TO_PN_U16( iocr_data->type = _HIGH_LOW_BYTES_TO_PN_U16(pIOCRInfo->TypeHighByte,
pIOCRInfo->TypeHighByte, pIOCRInfo->TypeLowByte); pIOCRInfo->TypeLowByte);
iocr_data->identifier = _HIGH_LOW_BYTES_TO_PN_U16( iocr_data->identifier = _HIGH_LOW_BYTES_TO_PN_U16(
pIOCRInfo->IOCRIdentifierHighByte, pIOCRInfo->IOCRIdentifierLowByte); pIOCRInfo->IOCRIdentifierHighByte, pIOCRInfo->IOCRIdentifierLowByte);
iocr_data->io_data_length = _HIGH_LOW_BYTES_TO_PN_U16( iocr_data->io_data_length = _HIGH_LOW_BYTES_TO_PN_U16(
...@@ -1400,10 +1508,11 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -1400,10 +1508,11 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
// _HIGH_LOW_BYTES_TO_PN_U16 (pIOCRInfo->IODataLengthHighByte, // _HIGH_LOW_BYTES_TO_PN_U16 (pIOCRInfo->IODataLengthHighByte,
// pIOCRInfo->IODataLengthLowByte)); // pIOCRInfo->IODataLengthLowByte));
NumberAPIs = _HIGH_LOW_BYTES_TO_PN_U16( NumberAPIs = _HIGH_LOW_BYTES_TO_PN_U16(pIOCRInfo->NumberOfAPIsHighByte,
pIOCRInfo->NumberOfAPIsHighByte, pIOCRInfo->NumberOfAPIsLowByte); pIOCRInfo->NumberOfAPIsLowByte);
for (APIIndex = 0u; APIIndex < NumberAPIs; APIIndex++) { for (APIIndex = 0u; APIIndex < NumberAPIs; APIIndex++)
{
T_PN_DATA_INFO* pDataInfo = (T_PN_DATA_INFO*)(pAPIInfo + 1); T_PN_DATA_INFO* pDataInfo = (T_PN_DATA_INFO*)(pAPIInfo + 1);
PN_U16 NumberIODatas; PN_U16 NumberIODatas;
...@@ -1420,7 +1529,8 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -1420,7 +1529,8 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
NumberIODatas = _HIGH_LOW_BYTES_TO_PN_U16( NumberIODatas = _HIGH_LOW_BYTES_TO_PN_U16(
pAPIInfo->NumberOfIODataHighByte, pAPIInfo->NumberOfIODataLowByte); pAPIInfo->NumberOfIODataHighByte, pAPIInfo->NumberOfIODataLowByte);
for (IODataIndex = 0u; IODataIndex < NumberIODatas; IODataIndex++) { for (IODataIndex = 0u; IODataIndex < NumberIODatas; IODataIndex++)
{
// printf(" slot: %d subslot: %d offset: // printf(" slot: %d subslot: %d offset:
//%d\r\n", //%d\r\n",
// _HIGH_LOW_BYTES_TO_PN_U16 // _HIGH_LOW_BYTES_TO_PN_U16
...@@ -1431,26 +1541,32 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -1431,26 +1541,32 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
// _HIGH_LOW_BYTES_TO_PN_U16 (pDataInfo->OffsetHighByte, // _HIGH_LOW_BYTES_TO_PN_U16 (pDataInfo->OffsetHighByte,
// pDataInfo->OffsetLowByte)); // pDataInfo->OffsetLowByte));
for (ii = 0; ii < device->module_data.size(); ii++) { for (ii = 0; ii < device->module_data.size(); ii++)
{
PnModuleData* module_data; PnModuleData* module_data;
module_data = device->module_data[ii]; module_data = device->module_data[ii];
if (module_data->slot_number if (module_data->slot_number ==
== _HIGH_LOW_BYTES_TO_PN_U16(pDataInfo->SlotNumberHighByte, _HIGH_LOW_BYTES_TO_PN_U16(pDataInfo->SlotNumberHighByte,
pDataInfo->SlotNumberLowByte)) { pDataInfo->SlotNumberLowByte))
for (jj = 0; jj < module_data->submodule_data.size(); jj++) { {
for (jj = 0; jj < module_data->submodule_data.size(); jj++)
{
PnSubmoduleData* submodule_data; PnSubmoduleData* submodule_data;
submodule_data = module_data->submodule_data[jj]; submodule_data = module_data->submodule_data[jj];
if (submodule_data->subslot_number if (submodule_data->subslot_number ==
== _HIGH_LOW_BYTES_TO_PN_U16( _HIGH_LOW_BYTES_TO_PN_U16(pDataInfo->SubSlotNumberHighByte,
pDataInfo->SubSlotNumberHighByte, pDataInfo->SubSlotNumberLowByte))
pDataInfo->SubSlotNumberLowByte)) { {
if (PROFINET_IO_CR_TYPE_INPUT == type) { if (PROFINET_IO_CR_TYPE_INPUT == type)
{
submodule_data->offset_io_in = _HIGH_LOW_BYTES_TO_PN_U16( submodule_data->offset_io_in = _HIGH_LOW_BYTES_TO_PN_U16(
pDataInfo->OffsetHighByte, pDataInfo->OffsetLowByte); pDataInfo->OffsetHighByte, pDataInfo->OffsetLowByte);
} else { }
else
{
submodule_data->offset_io_out = _HIGH_LOW_BYTES_TO_PN_U16( submodule_data->offset_io_out = _HIGH_LOW_BYTES_TO_PN_U16(
pDataInfo->OffsetHighByte, pDataInfo->OffsetLowByte); pDataInfo->OffsetHighByte, pDataInfo->OffsetLowByte);
} }
...@@ -1462,11 +1578,12 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -1462,11 +1578,12 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
} }
// printf (" status\r\n"); // printf (" status\r\n");
NumberIODatas NumberIODatas =
= _HIGH_LOW_BYTES_TO_PN_U16(pAPIInfo->NumberOfIOStatusHighByte, _HIGH_LOW_BYTES_TO_PN_U16(pAPIInfo->NumberOfIOStatusHighByte,
pAPIInfo->NumberOfIOStatusLowByte); pAPIInfo->NumberOfIOStatusLowByte);
for (IODataIndex = 0u; IODataIndex < NumberIODatas; IODataIndex++) { for (IODataIndex = 0u; IODataIndex < NumberIODatas; IODataIndex++)
{
// printf(" slot: %d subslot: %d offset: // printf(" slot: %d subslot: %d offset:
//%d\r\n", //%d\r\n",
// _HIGH_LOW_BYTES_TO_PN_U16 // _HIGH_LOW_BYTES_TO_PN_U16
...@@ -1477,29 +1594,35 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -1477,29 +1594,35 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
// _HIGH_LOW_BYTES_TO_PN_U16 (pDataInfo->OffsetHighByte, // _HIGH_LOW_BYTES_TO_PN_U16 (pDataInfo->OffsetHighByte,
// pDataInfo->OffsetLowByte)); // pDataInfo->OffsetLowByte));
for (ii = 0; ii < device->module_data.size(); ii++) { for (ii = 0; ii < device->module_data.size(); ii++)
{
PnModuleData* module_data; PnModuleData* module_data;
module_data = device->module_data[ii]; module_data = device->module_data[ii];
if (module_data->slot_number if (module_data->slot_number ==
== _HIGH_LOW_BYTES_TO_PN_U16(pDataInfo->SlotNumberHighByte, _HIGH_LOW_BYTES_TO_PN_U16(pDataInfo->SlotNumberHighByte,
pDataInfo->SlotNumberLowByte)) { pDataInfo->SlotNumberLowByte))
for (jj = 0; jj < module_data->submodule_data.size(); jj++) { {
for (jj = 0; jj < module_data->submodule_data.size(); jj++)
{
PnSubmoduleData* submodule_data; PnSubmoduleData* submodule_data;
submodule_data = module_data->submodule_data[jj]; submodule_data = module_data->submodule_data[jj];
if (submodule_data->subslot_number if (submodule_data->subslot_number ==
== _HIGH_LOW_BYTES_TO_PN_U16( _HIGH_LOW_BYTES_TO_PN_U16(pDataInfo->SubSlotNumberHighByte,
pDataInfo->SubSlotNumberHighByte, pDataInfo->SubSlotNumberLowByte))
pDataInfo->SubSlotNumberLowByte)) { {
if (PROFINET_IO_CR_TYPE_INPUT == type) { if (PROFINET_IO_CR_TYPE_INPUT == type)
submodule_data->offset_status_in {
= _HIGH_LOW_BYTES_TO_PN_U16(pDataInfo->OffsetHighByte, submodule_data->offset_status_in =
_HIGH_LOW_BYTES_TO_PN_U16(pDataInfo->OffsetHighByte,
pDataInfo->OffsetLowByte); pDataInfo->OffsetLowByte);
} else { }
submodule_data->offset_status_out else
= _HIGH_LOW_BYTES_TO_PN_U16(pDataInfo->OffsetHighByte, {
submodule_data->offset_status_out =
_HIGH_LOW_BYTES_TO_PN_U16(pDataInfo->OffsetHighByte,
pDataInfo->OffsetLowByte); pDataInfo->OffsetLowByte);
} }
} }
...@@ -1516,7 +1639,9 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -1516,7 +1639,9 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
} }
return PNAK_OK; return PNAK_OK;
} else if (pSdb->Result == PNAK_RESULT_NEG) { }
else if (pSdb->Result == PNAK_RESULT_NEG)
{
T_PN_SERVICE_ERROR_CON* pErrorCon = (T_PN_SERVICE_ERROR_CON*)(pSdb + 1); T_PN_SERVICE_ERROR_CON* pErrorCon = (T_PN_SERVICE_ERROR_CON*)(pSdb + 1);
printf("channel %d: download.con [-] (%d)\r\n" printf("channel %d: download.con [-] (%d)\r\n"
...@@ -1524,9 +1649,10 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local) ...@@ -1524,9 +1649,10 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local)
" detail : %d (0x%02x)\r\n" " detail : %d (0x%02x)\r\n"
" add. detail: %d (0x%02x)\r\n" " add. detail: %d (0x%02x)\r\n"
" area : %d (0x%02x)\r\n", " area : %d (0x%02x)\r\n",
0, pSdb->DeviceRef, pErrorCon->Code, pErrorCon->Code, pErrorCon->Detail, 0, pSdb->DeviceRef, pErrorCon->Code, pErrorCon->Code,
pErrorCon->Detail, pErrorCon->AdditionalDetail, pErrorCon->Detail, pErrorCon->Detail, pErrorCon->AdditionalDetail,
pErrorCon->AdditionalDetail, pErrorCon->AreaCode, pErrorCon->AreaCode); pErrorCon->AdditionalDetail, pErrorCon->AreaCode,
pErrorCon->AreaCode);
} }
return -1; return -1;
...@@ -1540,8 +1666,10 @@ int handle_service_con(io_sAgentLocal* local, io_sAgent* ap) ...@@ -1540,8 +1666,10 @@ int handle_service_con(io_sAgentLocal* local, io_sAgent* ap)
memset(&local->service_con, 0, sizeof(T_PNAK_SERVICE_CON)); memset(&local->service_con, 0, sizeof(T_PNAK_SERVICE_CON));
sts = pnak_get_service_con(0, &local->service_con); sts = pnak_get_service_con(0, &local->service_con);
if (sts == PNAK_NOTIFICATION_RECEIVED) { if (sts == PNAK_NOTIFICATION_RECEIVED)
for (ii = 0; ii < local->service_con.NumberEntries; ii++) { {
for (ii = 0; ii < local->service_con.NumberEntries; ii++)
{
T_PNAK_SERVICE_DESCRIPTION* pSdb; T_PNAK_SERVICE_DESCRIPTION* pSdb;
unsigned int offset; unsigned int offset;
...@@ -1549,54 +1677,75 @@ int handle_service_con(io_sAgentLocal* local, io_sAgent* ap) ...@@ -1549,54 +1677,75 @@ int handle_service_con(io_sAgentLocal* local, io_sAgent* ap)
pSdb = (T_PNAK_SERVICE_DESCRIPTION*)&local->service_con pSdb = (T_PNAK_SERVICE_DESCRIPTION*)&local->service_con
.ServiceChannel[offset]; .ServiceChannel[offset];
if ((pSdb->Instance == PN) || (pSdb->Instance == PN_CONTROLLER)) { if ((pSdb->Instance == PN) || (pSdb->Instance == PN_CONTROLLER))
switch (pSdb->Service) { {
case PN_SERVICE_DOWNLOAD: { switch (pSdb->Service)
{
case PN_SERVICE_DOWNLOAD_EXTENDED:
// printf("EXTENDED DOWNLOAD!\n");
case PN_SERVICE_DOWNLOAD:
{
// printf("unpack_download_con\n");
sts = unpack_download_con(pSdb, local); sts = unpack_download_con(pSdb, local);
break; break;
} }
case PN_SERVICE_SET_IDENTIFICATION: case PN_SERVICE_SET_IDENTIFICATION:
case PN_SERVICE_READ: { case PN_SERVICE_READ:
{
break; break;
} }
case PN_SERVICE_WRITE: { case PN_SERVICE_WRITE_MULTIPLE:
// printf("WRITE MULTIPLE!\n");
case PN_SERVICE_WRITE:
{
// printf("unpack_write_con\n");
sts = unpack_write_con(pSdb, local); sts = unpack_write_con(pSdb, local);
break; break;
} }
case PN_SERVICE_GET_ALARM: { case PN_SERVICE_GET_ALARM:
{
sts = unpack_get_alarm_con(pSdb, local, ap); sts = unpack_get_alarm_con(pSdb, local, ap);
break; break;
} }
case PN_SERVICE_GET_DEVICE_STATE: { case PN_SERVICE_GET_DEVICE_STATE:
{
sts = unpack_get_device_state_con(pSdb, local, ap); sts = unpack_get_device_state_con(pSdb, local, ap);
break; break;
} }
case PN_SERVICE_ALARM_ACK: { case PN_SERVICE_ALARM_ACK:
{
break; break;
} }
default: { default:
{
printf("channel %d: unhandled service confirmation [0x%x]\r\n", 0, printf("channel %d: unhandled service confirmation [0x%x]\r\n", 0,
pSdb->Service); pSdb->Service);
} }
} }
} else if (pSdb->Instance == PN_SUPERVISOR) { }
switch (pSdb->Service) { else if (pSdb->Instance == PN_SUPERVISOR)
case PN_SERVICE_GET_LIST_OF_STATION: { {
switch (pSdb->Service)
{
case PN_SERVICE_GET_LIST_OF_STATION:
{
sts = unpack_get_los_con(pSdb, local); sts = unpack_get_los_con(pSdb, local);
break; break;
} }
case PN_SERVICE_SET_IDENTIFICATION: case PN_SERVICE_SET_IDENTIFICATION:
case PN_SERVICE_SET_IP_SETTINGS: case PN_SERVICE_SET_IP_SETTINGS:
case PN_SERVICE_SET_DEVICE_NAME: { case PN_SERVICE_SET_DEVICE_NAME:
if (pSdb->Result == PNAK_RESULT_NEG) { {
T_PN_SERVICE_ERROR_CON* pErrorCon if (pSdb->Result == PNAK_RESULT_NEG)
= (T_PN_SERVICE_ERROR_CON*)(pSdb + 1); {
T_PN_SERVICE_ERROR_CON* pErrorCon =
(T_PN_SERVICE_ERROR_CON*)(pSdb + 1);
printf("channel %d: get_los.con [-] (%d)\r\n" printf("channel %d: get_los.con [-] (%d)\r\n"
" code : %d (0x%02x)\r\n" " code : %d (0x%02x)\r\n"
...@@ -1611,7 +1760,8 @@ int handle_service_con(io_sAgentLocal* local, io_sAgent* ap) ...@@ -1611,7 +1760,8 @@ int handle_service_con(io_sAgentLocal* local, io_sAgent* ap)
break; break;
} }
default: { default:
{
printf("channel %d: unhandled service confirmation [0x%x]\r\n", 0, printf("channel %d: unhandled service confirmation [0x%x]\r\n", 0,
pSdb->Service); pSdb->Service);
} }
...@@ -1629,25 +1779,21 @@ int wait_service_con(io_sAgentLocal* local, io_sAgent* ap) ...@@ -1629,25 +1779,21 @@ int wait_service_con(io_sAgentLocal* local, io_sAgent* ap)
int sts; int sts;
wait_object = PNAK_WAIT_OBJECT_SERVICE_CON; wait_object = PNAK_WAIT_OBJECT_SERVICE_CON;
//wait_object = PNAK_WAIT_OBJECTS_SERVICE;
sts = pnak_wait_for_multiple_objects(0, &wait_object, PNAK_INFINITE_TIMEOUT); sts = pnak_wait_for_multiple_objects(0, &wait_object, PNAK_INFINITE_TIMEOUT);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
{
sts = handle_service_con(local, ap); sts = handle_service_con(local, ap);
} }
return sts; return sts;
} }
void handle_exception(io_sAgentLocal* local) void handle_exception(io_sAgentLocal* local) { return; }
{
return;
}
void handle_state_changed(io_sAgentLocal* local) void handle_state_changed(io_sAgentLocal* local) { return; }
{
return;
}
void handle_device_state_changed(io_sAgentLocal* local, io_sAgent* ap) void handle_device_state_changed(io_sAgentLocal* local, io_sAgent* ap)
{ {
...@@ -1657,24 +1803,30 @@ void handle_device_state_changed(io_sAgentLocal* local, io_sAgent* ap) ...@@ -1657,24 +1803,30 @@ void handle_device_state_changed(io_sAgentLocal* local, io_sAgent* ap)
sts = pnak_get_device_state_ind(0, &dev_state); sts = pnak_get_device_state_ind(0, &dev_state);
if (sts == PNAK_NOTIFICATION_RECEIVED) { if (sts == PNAK_NOTIFICATION_RECEIVED)
{
/* Check state for all devices */ /* Check state for all devices */
for (ii = 1; ii < local->device_data.size(); ii++) { for (ii = 1; ii < local->device_data.size(); ii++)
{
// printf("Dev_ref %d, State, %d \r\n", ii, dev_state.State[ii]); // printf("Dev_ref %d, State, %d \r\n", ii, dev_state.State[ii]);
// for (ii = 0; ii < 1; ii++) { // for (ii = 0; ii < 1; ii++) {
if (dev_state.State[ii] != local->device_data[ii]->device_state) { if (dev_state.State[ii] != local->device_data[ii]->device_state)
{
local->device_data[ii]->device_state = dev_state.State[ii]; local->device_data[ii]->device_state = dev_state.State[ii];
if (ap) { if (ap)
{
/* Find corresponding device */ /* Find corresponding device */
io_sRack* slave_list; io_sRack* slave_list;
for (slave_list = ap->racklist, jj = 0; for (slave_list = ap->racklist, jj = 0;
(slave_list != NULL) && jj < ii - 1; (slave_list != NULL) && jj < ii - 1;
slave_list = slave_list->next, jj++) { slave_list = slave_list->next, jj++)
{
} }
if (slave_list) { if (slave_list)
{
pwr_sClass_PnDevice* dev; pwr_sClass_PnDevice* dev;
dev = (pwr_sClass_PnDevice*)slave_list->op; dev = (pwr_sClass_PnDevice*)slave_list->op;
dev->State = dev_state.State[ii]; dev->State = dev_state.State[ii];
...@@ -1689,13 +1841,15 @@ void handle_device_state_changed(io_sAgentLocal* local, io_sAgent* ap) ...@@ -1689,13 +1841,15 @@ void handle_device_state_changed(io_sAgentLocal* local, io_sAgent* ap)
} }
} }
if (dev_state.State[ii] == PNAK_DEVICE_STATE_CONNECTED) { if (dev_state.State[ii] == PNAK_DEVICE_STATE_CONNECTED)
pack_get_device_state_req( {
&local->service_req_res, local->device_data[ii]->device_ref); pack_get_device_state_req(&local->service_req_res,
local->device_data[ii]->device_ref);
sts = pnak_send_service_req_res(0, &local->service_req_res); sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
{
sts = wait_service_con(local, ap); sts = wait_service_con(local, ap);
} }
} }
...@@ -1714,11 +1868,14 @@ void handle_alarm_indication(io_sAgentLocal* local, io_sAgent* ap) ...@@ -1714,11 +1868,14 @@ void handle_alarm_indication(io_sAgentLocal* local, io_sAgent* ap)
sts = pnak_get_alarm_ind(0, &pAlarm); sts = pnak_get_alarm_ind(0, &pAlarm);
if (sts == PNAK_NOTIFICATION_RECEIVED) { if (sts == PNAK_NOTIFICATION_RECEIVED)
for (ii = 0; ii < local->device_data.size(); ii++) { {
for (ii = 0; ii < local->device_data.size(); ii++)
{
index = ii / 8; index = ii / 8;
bit_no = ii % 8; bit_no = ii % 8;
if (pAlarm.DeviceReference[index] & (1 << bit_no)) { if (pAlarm.DeviceReference[index] & (1 << bit_no))
{
printf("New alarm for device: %d\r\n", ii); printf("New alarm for device: %d\r\n", ii);
pack_get_alarm_req(&local->service_req_res, pack_get_alarm_req(&local->service_req_res,
...@@ -1727,9 +1884,11 @@ void handle_alarm_indication(io_sAgentLocal* local, io_sAgent* ap) ...@@ -1727,9 +1884,11 @@ void handle_alarm_indication(io_sAgentLocal* local, io_sAgent* ap)
sts = pnak_send_service_req_res(0, &local->service_req_res); sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
{
sts = wait_service_con(local, ap); sts = wait_service_con(local, ap);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
{
pack_alarm_ack_req(&local->service_req_res, pack_alarm_ack_req(&local->service_req_res,
local->device_data[ii]->alarm_ref, local->device_data[ii]->alarm_ref,
local->device_data[ii]->alarm_data.alarm_prio, local->device_data[ii]->alarm_data.alarm_prio,
...@@ -1737,7 +1896,8 @@ void handle_alarm_indication(io_sAgentLocal* local, io_sAgent* ap) ...@@ -1737,7 +1896,8 @@ void handle_alarm_indication(io_sAgentLocal* local, io_sAgent* ap)
sts = pnak_send_service_req_res(0, &local->service_req_res); sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
{
sts = wait_service_con(local, ap); sts = wait_service_con(local, ap);
} }
} }
...@@ -1805,11 +1965,13 @@ void* handle_events(void* ptr) ...@@ -1805,11 +1965,13 @@ void* handle_events(void* ptr)
s = socket(AF_INET, SOCK_DGRAM, 0); s = socket(AF_INET, SOCK_DGRAM, 0);
strncpy(ifr.ifr_name, op->EthernetDevice, sizeof(ifr.ifr_name)); strncpy(ifr.ifr_name, op->EthernetDevice, sizeof(ifr.ifr_name));
if (ioctl(s, SIOCGIFADDR, &ifr) >= 0) { if (ioctl(s, SIOCGIFADDR, &ifr) >= 0)
{
strcpy(dev_data->ip_address, strcpy(dev_data->ip_address,
inet_ntoa(((struct sockaddr_in*)&ifr.ifr_addr)->sin_addr)); inet_ntoa(((struct sockaddr_in*)&ifr.ifr_addr)->sin_addr));
} }
if (ioctl(s, SIOCGIFNETMASK, &ifr) >= 0) { if (ioctl(s, SIOCGIFNETMASK, &ifr) >= 0)
{
strcpy(dev_data->subnet_mask, strcpy(dev_data->subnet_mask,
inet_ntoa(((struct sockaddr_in*)&ifr.ifr_netmask)->sin_addr)); inet_ntoa(((struct sockaddr_in*)&ifr.ifr_netmask)->sin_addr));
} }
...@@ -1839,7 +2001,8 @@ void* handle_events(void* ptr) ...@@ -1839,7 +2001,8 @@ void* handle_events(void* ptr)
/* Iterate over the slaves. */ /* Iterate over the slaves. */
for (slave_list = ap->racklist, ii = 0; slave_list != NULL; for (slave_list = ap->racklist, ii = 0; slave_list != NULL;
slave_list = slave_list->next, ii++) { slave_list = slave_list->next, ii++)
{
dev_data = new GsdmlDeviceData; dev_data = new GsdmlDeviceData;
pn_dev_data = new PnDeviceData; pn_dev_data = new PnDeviceData;
...@@ -1851,46 +2014,52 @@ void* handle_events(void* ptr) ...@@ -1851,46 +2014,52 @@ void* handle_events(void* ptr)
pn_dev_data->device_ref = ii + 1; pn_dev_data->device_ref = ii + 1;
for (jj = 0; jj < dev_data->iocr_data.size(); jj++) { for (jj = 0; jj < dev_data->iocr_data.size(); jj++)
{
pn_iocr_data = new PnIOCRData; pn_iocr_data = new PnIOCRData;
pn_iocr_data->type = dev_data->iocr_data[jj]->type; pn_iocr_data->type = dev_data->iocr_data[jj]->type;
pn_dev_data->iocr_data.push_back(pn_iocr_data); pn_dev_data->iocr_data.push_back(pn_iocr_data);
} }
num_modules = 0; num_modules = 0;
for (jj = 0; jj < dev_data->slot_data.size(); jj++) { for (jj = 0; jj < dev_data->slot_data.size(); jj++)
{
if ((dev_data->slot_data[jj]->module_enum_number != 0) || (jj == 0)) if ((dev_data->slot_data[jj]->module_enum_number != 0) || (jj == 0))
num_modules++; num_modules++;
else else
break; break;
} }
for (jj = 0; jj < num_modules; jj++) { for (jj = 0; jj < num_modules; jj++)
{
pn_slot_data = new PnModuleData; pn_slot_data = new PnModuleData;
pn_slot_data->slot_number = dev_data->slot_data[jj]->slot_number; pn_slot_data->slot_number = dev_data->slot_data[jj]->slot_number;
pn_slot_data->ident_number = dev_data->slot_data[jj]->module_ident_number; pn_slot_data->ident_number = dev_data->slot_data[jj]->module_ident_number;
pn_dev_data->module_data.push_back(pn_slot_data); pn_dev_data->module_data.push_back(pn_slot_data);
for (kk = 0; kk < dev_data->slot_data[jj]->subslot_data.size(); kk++) { for (kk = 0; kk < dev_data->slot_data[jj]->subslot_data.size(); kk++)
{
pn_subslot_data = new PnSubmoduleData; pn_subslot_data = new PnSubmoduleData;
pn_subslot_data->subslot_number pn_subslot_data->subslot_number =
= dev_data->slot_data[jj]->subslot_data[kk]->subslot_number; dev_data->slot_data[jj]->subslot_data[kk]->subslot_number;
pn_subslot_data->ident_number pn_subslot_data->ident_number =
= dev_data->slot_data[jj]->subslot_data[kk]->submodule_ident_number; dev_data->slot_data[jj]->subslot_data[kk]->submodule_ident_number;
pn_subslot_data->api = dev_data->slot_data[jj]->subslot_data[kk]->api; pn_subslot_data->api = dev_data->slot_data[jj]->subslot_data[kk]->api;
if (dev_data->slot_data[jj]->subslot_data[kk]->io_input_length > 0) { if (dev_data->slot_data[jj]->subslot_data[kk]->io_input_length > 0)
pn_subslot_data->io_in_data_length {
= dev_data->slot_data[jj]->subslot_data[kk]->io_input_length; pn_subslot_data->io_in_data_length =
dev_data->slot_data[jj]->subslot_data[kk]->io_input_length;
pn_subslot_data->type = PROFINET_IO_SUBMODULE_TYPE_INPUT; pn_subslot_data->type = PROFINET_IO_SUBMODULE_TYPE_INPUT;
} }
if (dev_data->slot_data[jj]->subslot_data[kk]->io_output_length > 0) { if (dev_data->slot_data[jj]->subslot_data[kk]->io_output_length > 0)
pn_subslot_data->io_out_data_length {
= dev_data->slot_data[jj]->subslot_data[kk]->io_output_length; pn_subslot_data->io_out_data_length =
dev_data->slot_data[jj]->subslot_data[kk]->io_output_length;
pn_subslot_data->type |= PROFINET_IO_SUBMODULE_TYPE_OUTPUT; pn_subslot_data->type |= PROFINET_IO_SUBMODULE_TYPE_OUTPUT;
} }
if ((dev_data->slot_data[jj]->subslot_data[kk]->io_output_length > 0) if ((dev_data->slot_data[jj]->subslot_data[kk]->io_output_length > 0) &&
&& (dev_data->slot_data[jj]->subslot_data[kk]->io_input_length (dev_data->slot_data[jj]->subslot_data[kk]->io_input_length > 0))
> 0)) { {
pn_subslot_data->type |= PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT; pn_subslot_data->type |= PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT;
} }
...@@ -1904,7 +2073,8 @@ void* handle_events(void* ptr) ...@@ -1904,7 +2073,8 @@ void* handle_events(void* ptr)
sts = pnak_start_profistack(0, PNAK_CONTROLLER_MODE); sts = pnak_start_profistack(0, PNAK_CONTROLLER_MODE);
if (sts != PNAK_OK) { if (sts != PNAK_OK)
{
op->Status = PB__INITFAIL; op->Status = PB__INITFAIL;
errh_Error("Starting profistack returned with error code: %d", sts); errh_Error("Starting profistack returned with error code: %d", sts);
// return IO__ERRINIDEVICE; // return IO__ERRINIDEVICE;
...@@ -1912,60 +2082,73 @@ void* handle_events(void* ptr) ...@@ -1912,60 +2082,73 @@ void* handle_events(void* ptr)
/* Download configuration for all devices */ /* Download configuration for all devices */
for (ii = 0; ii < device_vect.size(); ii++) { for (ii = 0; ii < device_vect.size(); ii++)
{
// for (ii = 0; ii < 1; ii++) { // for (ii = 0; ii < 1; ii++) {
pack_download_req(&local->service_req_res, device_vect[ii], pack_download_req(&local->service_req_res, device_vect[ii],
local->device_data[ii]->device_ref); local->device_data[ii]->device_ref);
sts = pnak_send_service_req_res(0, &local->service_req_res); sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
{
sts = wait_service_con(local, ap); sts = wait_service_con(local, ap);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
{
/* Loop through devices and calculate offset for io */ /* Loop through devices and calculate offset for io */
for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++) { for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++)
{
offset_inputs = 0; offset_inputs = 0;
offset_outputs = 0; offset_outputs = 0;
type = local->device_data[ii]->iocr_data[jj]->type; type = local->device_data[ii]->iocr_data[jj]->type;
for (kk = 0; kk < local->device_data[ii]->module_data.size(); kk++) { for (kk = 0; kk < local->device_data[ii]->module_data.size(); kk++)
for (ll = 0; ll < local->device_data[ii] {
->module_data[kk] for (ll = 0;
->submodule_data.size(); ll <
ll++) { local->device_data[ii]->module_data[kk]->submodule_data.size();
ll++)
{
PnSubmoduleData* submodule; PnSubmoduleData* submodule;
submodule submodule =
= local->device_data[ii]->module_data[kk]->submodule_data[ll]; local->device_data[ii]->module_data[kk]->submodule_data[ll];
if ((type == PROFINET_IO_CR_TYPE_INPUT) if ((type == PROFINET_IO_CR_TYPE_INPUT) &&
&& ((submodule->type == PROFINET_IO_SUBMODULE_TYPE_INPUT) ((submodule->type == PROFINET_IO_SUBMODULE_TYPE_INPUT) ||
|| (submodule->type (submodule->type ==
== PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT))) { PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT)))
{
submodule->offset_clean_io_in = offset_inputs; submodule->offset_clean_io_in = offset_inputs;
offset_inputs += submodule->io_in_data_length; offset_inputs += submodule->io_in_data_length;
} else if ((type == PROFINET_IO_CR_TYPE_OUTPUT) }
&& ((submodule->type == PROFINET_IO_SUBMODULE_TYPE_OUTPUT) else if ((type == PROFINET_IO_CR_TYPE_OUTPUT) &&
|| (submodule->type ((submodule->type ==
== PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT))) { PROFINET_IO_SUBMODULE_TYPE_OUTPUT) ||
(submodule->type ==
PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT)))
{
submodule->offset_clean_io_out = offset_outputs; submodule->offset_clean_io_out = offset_outputs;
offset_outputs += submodule->io_out_data_length; offset_outputs += submodule->io_out_data_length;
} }
} }
} }
local->device_data[ii]->iocr_data[jj]->clean_io_data local->device_data[ii]->iocr_data[jj]->clean_io_data =
= (unsigned char*)calloc(1, offset_inputs + offset_outputs); (unsigned char*)calloc(1, offset_inputs + offset_outputs);
local->device_data[ii]->iocr_data[jj]->clean_io_data_length local->device_data[ii]->iocr_data[jj]->clean_io_data_length =
= offset_inputs + offset_outputs; offset_inputs + offset_outputs;
} }
} else { }
else
{
errh_Error("Download of Profinet Device configuration failed for: %s", errh_Error("Download of Profinet Device configuration failed for: %s",
device_vect[ii]->device_name); device_vect[ii]->device_name);
/* Setup a dummy i/o area. Depending on exisiting channels this area /* Setup a dummy i/o area. Depending on exisiting channels this area
* needs to exist */ * needs to exist */
for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++) { for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++)
local->device_data[ii]->iocr_data[jj]->clean_io_data {
= (unsigned char*)calloc(1, PROFINET_IO_DATA_MAX_LENGTH); local->device_data[ii]->iocr_data[jj]->clean_io_data =
(unsigned char*)calloc(1, PROFINET_IO_DATA_MAX_LENGTH);
} }
} }
} }
...@@ -1974,23 +2157,28 @@ void* handle_events(void* ptr) ...@@ -1974,23 +2157,28 @@ void* handle_events(void* ptr)
/* Loop trough devices and set up i/o */ /* Loop trough devices and set up i/o */
for (slave_list = ap->racklist, ii = 0; slave_list != NULL; for (slave_list = ap->racklist, ii = 0; slave_list != NULL;
slave_list = slave_list->next, ii++) { slave_list = slave_list->next, ii++)
{
slave_list->Local = (unsigned char*)calloc(1, sizeof(io_sPnRackLocal)); slave_list->Local = (unsigned char*)calloc(1, sizeof(io_sPnRackLocal));
r_local = (io_sPnRackLocal*)slave_list->Local; r_local = (io_sPnRackLocal*)slave_list->Local;
for (jj = 0; jj < local->device_data[ii + 1]->iocr_data.size(); jj++) { for (jj = 0; jj < local->device_data[ii + 1]->iocr_data.size(); jj++)
if (local->device_data[ii + 1]->iocr_data[jj]->type {
== PROFINET_IO_CR_TYPE_INPUT) { if (local->device_data[ii + 1]->iocr_data[jj]->type ==
r_local->bytes_of_input PROFINET_IO_CR_TYPE_INPUT)
= local->device_data[ii + 1]->iocr_data[jj]->clean_io_data_length; {
r_local->inputs r_local->bytes_of_input =
= local->device_data[ii + 1]->iocr_data[jj]->clean_io_data; local->device_data[ii + 1]->iocr_data[jj]->clean_io_data_length;
} else if (local->device_data[ii + 1]->iocr_data[jj]->type r_local->inputs =
== PROFINET_IO_CR_TYPE_OUTPUT) { local->device_data[ii + 1]->iocr_data[jj]->clean_io_data;
r_local->bytes_of_output }
= local->device_data[ii + 1]->iocr_data[jj]->clean_io_data_length; else if (local->device_data[ii + 1]->iocr_data[jj]->type ==
r_local->outputs PROFINET_IO_CR_TYPE_OUTPUT)
= local->device_data[ii + 1]->iocr_data[jj]->clean_io_data; {
r_local->bytes_of_output =
local->device_data[ii + 1]->iocr_data[jj]->clean_io_data_length;
r_local->outputs =
local->device_data[ii + 1]->iocr_data[jj]->clean_io_data;
} }
} }
} }
...@@ -2001,7 +2189,8 @@ void* handle_events(void* ptr) ...@@ -2001,7 +2189,8 @@ void* handle_events(void* ptr)
sts = pnak_send_service_req_res(0, &local->service_req_res); sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
{
sts = wait_service_con(local, ap); sts = wait_service_con(local, ap);
} }
...@@ -2013,7 +2202,8 @@ void* handle_events(void* ptr) ...@@ -2013,7 +2202,8 @@ void* handle_events(void* ptr)
sts = pnak_set_mode(0, &pMode); sts = pnak_set_mode(0, &pMode);
if (sts != PNAK_OK) { if (sts != PNAK_OK)
{
op->Status = PB__INITFAIL; op->Status = PB__INITFAIL;
errh_Error("Profistack unable to go online, errcode: %d", sts); errh_Error("Profistack unable to go online, errcode: %d", sts);
// return IO__ERRINIDEVICE; // return IO__ERRINIDEVICE;
...@@ -2025,13 +2215,16 @@ void* handle_events(void* ptr) ...@@ -2025,13 +2215,16 @@ void* handle_events(void* ptr)
sts = pnak_wait_for_multiple_objects(0, &wait_object, PNAK_INFINITE_TIMEOUT); sts = pnak_wait_for_multiple_objects(0, &wait_object, PNAK_INFINITE_TIMEOUT);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
{
T_PNAK_EVENT_STATE pState; T_PNAK_EVENT_STATE pState;
sts = pnak_get_state(0, &pState); sts = pnak_get_state(0, &pState);
if (pState.Mode != PNAK_MODE_ONLINE) { if (pState.Mode != PNAK_MODE_ONLINE)
if (sts != PNAK_OK) { {
if (sts != PNAK_OK)
{
op->Status = PB__INITFAIL; op->Status = PB__INITFAIL;
errh_Error("Profistack unable to set state online, errcode: %d", sts); errh_Error("Profistack unable to set state online, errcode: %d", sts);
// return IO__ERRINIDEVICE; // return IO__ERRINIDEVICE;
...@@ -2046,7 +2239,8 @@ void* handle_events(void* ptr) ...@@ -2046,7 +2239,8 @@ void* handle_events(void* ptr)
memset(&set_dev_state, 0, sizeof(set_dev_state)); memset(&set_dev_state, 0, sizeof(set_dev_state));
for (ii = 0; ii < local->device_data.size(); ii++) { for (ii = 0; ii < local->device_data.size(); ii++)
{
index = ii / 8; index = ii / 8;
bit_no = ii % 8; bit_no = ii % 8;
set_dev_state.ActivateDeviceReference[index] |= (1 << bit_no); set_dev_state.ActivateDeviceReference[index] |= (1 << bit_no);
...@@ -2054,7 +2248,8 @@ void* handle_events(void* ptr) ...@@ -2054,7 +2248,8 @@ void* handle_events(void* ptr)
sts = pnak_set_device_state(0, &set_dev_state); sts = pnak_set_device_state(0, &set_dev_state);
if (sts != PNAK_OK) { if (sts != PNAK_OK)
{
op->Status = PB__INITFAIL; op->Status = PB__INITFAIL;
errh_Error("Profistack unable to activate devices, errcode: %d", sts); errh_Error("Profistack unable to activate devices, errcode: %d", sts);
// return IO__ERRINIDEVICE; // return IO__ERRINIDEVICE;
...@@ -2062,14 +2257,16 @@ void* handle_events(void* ptr) ...@@ -2062,14 +2257,16 @@ void* handle_events(void* ptr)
/* Check state for all devices */ /* Check state for all devices */
for (ii = 1; ii < device_vect.size(); ii++) { for (ii = 1; ii < device_vect.size(); ii++)
{
// for (ii = 0; ii < 1; ii++) { // for (ii = 0; ii < 1; ii++) {
pack_get_device_state_req( pack_get_device_state_req(&local->service_req_res,
&local->service_req_res, local->device_data[ii]->device_ref); local->device_data[ii]->device_ref);
sts = pnak_send_service_req_res(0, &local->service_req_res); sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
{
sts = wait_service_con(local, ap); sts = wait_service_con(local, ap);
} }
} }
...@@ -2079,61 +2276,77 @@ void* handle_events(void* ptr) ...@@ -2079,61 +2276,77 @@ void* handle_events(void* ptr)
/* Do forever ... */ /* Do forever ... */
while (1) { while (1)
wait_object = PNAK_WAIT_OBJECTS_EVENT_IND | PNAK_WAIT_OBJECTS_OTHER {
| PNAK_WAIT_OBJECT_SERVICE_CON; // wait_object = PNAK_WAIT_OBJECTS_EVENT_IND | PNAK_WAIT_OBJECTS_OTHER
// | PNAK_WAIT_OBJECT_SERVICE_CON;
wait_object =
PNAK_WAIT_OBJECTS_ALL & ~(PNAK_WAIT_OBJECT_PROVIDER_DATA_UPDATED | PNAK_WAIT_OBJECT_CONSUMER_DATA_CHANGED);
// pthread_mutex_lock(&local->mutex); // pthread_mutex_lock(&local->mutex);
sts = pnak_wait_for_multiple_objects( sts =
0, &wait_object, PNAK_INFINITE_TIMEOUT); pnak_wait_for_multiple_objects(0, &wait_object, PNAK_INFINITE_TIMEOUT);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
if (wait_object & PNAK_WAIT_OBJECT_EXCEPTION) { {
if (wait_object & PNAK_WAIT_OBJECT_EXCEPTION)
{
// printf("Exception !!\n"); // printf("Exception !!\n");
handle_exception(local); handle_exception(local);
} }
if (wait_object & PNAK_WAIT_OBJECT_STATE_CHANGED) { else if (wait_object & PNAK_WAIT_OBJECT_STATE_CHANGED)
// printf("State changed !!"); {
// printf("State changed !!\n");
handle_state_changed(local); handle_state_changed(local);
} }
if (wait_object & PNAK_WAIT_OBJECT_DEVICE_STATE_CHANGED) { else if (wait_object & PNAK_WAIT_OBJECT_DEVICE_STATE_CHANGED)
{
// printf("Device state changed !!\n");
handle_device_state_changed(local, ap); handle_device_state_changed(local, ap);
} }
if (wait_object & PNAK_WAIT_OBJECT_ALARM) { else if (wait_object & PNAK_WAIT_OBJECT_ALARM)
{
// printf("Alarm !!\n"); // printf("Alarm !!\n");
handle_alarm_indication(local, ap); handle_alarm_indication(local, ap);
} }
if (wait_object & PNAK_WAIT_OBJECT_CHANNEL_CLOSED) { // else if (wait_object & PNAK_WAIT_OBJECT_CHANNEL_CLOSED) {
// printf("Channel closed !!"); // // printf("Channel closed !!");
// What to do if channel closes ???; // // What to do if channel closes ???;
} // }
if (wait_object & PNAK_WAIT_OBJECT_ETHERNET_STATE_CHANGED) { // else if (wait_object & PNAK_WAIT_OBJECT_ETHERNET_STATE_CHANGED) {
// printf("Ethernet state changed !!"); // // printf("Ethernet state changed !!");
// What to do if ethernet state changes ???; // // What to do if ethernet state changes ???;
} // }
if (wait_object & PNAK_WAIT_OBJECT_INTERRUPTED) { // else if (wait_object & PNAK_WAIT_OBJECT_INTERRUPTED) {
// printf("Interrupted !!"); // // printf("Interrupted !!");
// What to do if interrupted ???; // // What to do if interrupted ???;
} // }
if (wait_object & PNAK_WAIT_OBJECT_SERVICE_CON) { else if (wait_object & PNAK_WAIT_OBJECT_SERVICE_CON)
// printf("Service con !!"); {
// printf("Service con !!\n");
sts = handle_service_con(local, ap); sts = handle_service_con(local, ap);
} }
// else
} else if ((sts == PNAK_ERR_FATAL_ERROR) // {
|| (sts == PNAK_EXCEPTION_THROWN)) { // printf("Unhandled status!! 0x%02X\n", wait_object);
printf("Err Fatal / Exception !!"); // }
}
else if ((sts == PNAK_ERR_FATAL_ERROR) || (sts == PNAK_EXCEPTION_THROWN))
{
printf("Err Fatal / Exception !!\n");
// user_handle_exception (ChannelId); // user_handle_exception (ChannelId);
} else { }
printf("Running == NOT !!"); else
{
printf("Running == NOT !!\n");
// pThisSmObject->Running = PN_FALSE; // pThisSmObject->Running = PN_FALSE;
} }
......
...@@ -65,8 +65,8 @@ public: ...@@ -65,8 +65,8 @@ public:
co_xml_parser* parser; co_xml_parser* parser;
unsigned int tag_stack[100]; unsigned int tag_stack[100];
unsigned int tag_stack_cnt; unsigned int tag_stack_cnt;
void* object_stack[100]; void* object_stack[2048];
unsigned int object_stack_id[100]; unsigned int object_stack_id[2048];
unsigned int object_stack_cnt; unsigned int object_stack_cnt;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment