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