Commit c95797a2 authored by Claes Sjofors's avatar Claes Sjofors

Profinet configurator, fix for non consecutive modules (refs #240)

parent eb5cc397
......@@ -168,98 +168,40 @@ int pndevice_save_cb( void *sctx)
ldh_eName_Hierarchy, name, sizeof(name), &size);
if ( EVEN(sts)) goto return_now;
// Do a temporary rename all module object to avoid name collisions
#if 0
// Check that Slot attribute corresponds to the and module_oid
for ( unsigned int i = 1; i < ctx->attr->attrnav->dev_data.slot_data.size(); i++)
ctx->attr->attrnav->dev_data.slot_data[i]->module_oid = pwr_cNOid;
for ( sts = ldh_GetChild( ctx->ldhses, ctx->aref.Objid, &oid);
ODD(sts);
sts = ldh_GetNextSibling( ctx->ldhses, oid, &oid)) {
sts = ldh_ObjidToName( ctx->ldhses, oid, cdh_mName_object, name,
sizeof(name), &size);
if ( EVEN(sts)) goto return_now;
strcat( name, "__tmp");
sts = ldh_ChangeObjectName( ctx->ldhses, oid, name);
if ( EVEN(sts)) goto return_now;
}
#endif
unsigned int *slotnumberp, slotnumber;
for ( unsigned int i = 1; i < ctx->attr->attrnav->dev_data.slot_data.size(); i++) {
GsdmlSlotData *slot = ctx->attr->attrnav->dev_data.slot_data[i];
pwr_tCid cid;
pwr_tOid prev;
pwr_tObjName mname;
sts = ldh_GetObjectPar( ctx->ldhses, oid, "RtBody",
"Slot", (char **)&slotnumberp, &size);
if ( EVEN(sts)) {
MsgWindow::message( 'E', "Not a Profinet module object", msgw_ePop_Yes, oid);
continue;
}
slotnumber = *slotnumberp;
free( slotnumberp);
int found = 0;
sprintf( mname, "M%d", slot->slot_idx);
if ( slotnumber >= ctx->attr->attrnav->dev_data.slot_data.size()) {
MsgWindow::message( 'E', "Slot too large", msgw_ePop_Yes, oid);
continue;
}
if ( cdh_ObjidIsNotNull( slot->module_oid)) {
if ( cdh_ObjidIsNotNull( ctx->attr->attrnav->dev_data.slot_data[slotnumber]->module_oid)) {
MsgWindow::message( 'E', "Slot already used", msgw_ePop_Yes, oid);
continue;
}
// Find module object
sts = ldh_GetObjectClass( ctx->ldhses, slot->module_oid, &cid);
if ( ODD(sts)) {
if ( cid == slot->module_class) {
// Module object found and class is ok
found = 1;
if ( ctx->attr->attrnav->dev_data.slot_data[slotnumber]->module_class == pwr_cNCid)
// Should be removed
continue;
// Check if name is changed
sts = ldh_ObjidToName( ctx->ldhses, slot->module_oid, cdh_mName_object, name,
sizeof(name), &size);
if ( EVEN(sts)) goto return_now;
#if 0
if ( strcmp( name, mname) != 0) {
// Change name
sts = ldh_ChangeObjectName( ctx->ldhses, slot->module_oid, mname);
if ( EVEN(sts)) goto return_now;
}
#endif
// Check that sibling position is right
sts = ldh_GetPreviousSibling( ctx->ldhses, slot->module_oid, &prev);
if ( i == 0) {
// Should be first sibling
if ( ODD(sts)) {
// Move to first sibling
sts = ldh_MoveObject( ctx->ldhses, slot->module_oid, ctx->aref.Objid, ldh_eDest_IntoFirst);
}
}
else {
if ( (ODD(sts) &&
cdh_ObjidIsNotEqual( ctx->attr->attrnav->dev_data.slot_data[i-1]->module_oid, prev)) ||
EVEN(sts)) {
// Move to next to i-1
sts = ldh_MoveObject( ctx->ldhses, slot->module_oid,
ctx->attr->attrnav->dev_data.slot_data[i-1]->module_oid,
ldh_eDest_After);
}
}
}
else {
// New class, delete current object, reuse the name
sts = ldh_ObjidToName( ctx->ldhses, slot->module_oid,
ldh_eName_Object, mname, sizeof(mname), &size);
if ( EVEN(sts)) goto return_now;
sts = ldh_DeleteObjectTree( ctx->ldhses, slot->module_oid, 0);
if ( EVEN(sts)) goto return_now;
}
}
}
if ( !found && slot->module_class != pwr_cNCid) {
// Create a new module object
if ( i == 1)
sts = ldh_CreateObject( ctx->ldhses, &slot->module_oid, mname, slot->module_class,
ctx->aref.Objid, ldh_eDest_IntoFirst);
else
sts = ldh_CreateObject( ctx->ldhses, &slot->module_oid, mname, slot->module_class,
ctx->attr->attrnav->dev_data.slot_data[i-1]->module_oid,
ldh_eDest_After);
if ( EVEN(sts)) {
printf( "Error creating module object, %d\n", sts);
sts = 0;
goto return_now;
}
}
ctx->attr->attrnav->dev_data.slot_data[slotnumber]->module_oid = oid;
}
// Remove modules that wasn't configured any more
......@@ -287,6 +229,54 @@ int pndevice_save_cb( void *sctx)
for ( int i = 0; i < mcnt; i++)
sts = ldh_DeleteObjectTree( ctx->ldhses, moid[i], 0);
// Create new module objects
for ( unsigned int i = 0; i < ctx->attr->attrnav->dev_data.slot_data.size(); i++) {
GsdmlSlotData *slot = ctx->attr->attrnav->dev_data.slot_data[i];
if ( cdh_ObjidIsNull( slot->module_oid) && slot->module_class != pwr_cNCid) {
char mname[20];
sprintf( mname, "M%d", i);
if ( i == 1)
sts = ldh_CreateObject( ctx->ldhses, &slot->module_oid, mname, slot->module_class,
ctx->aref.Objid, ldh_eDest_IntoFirst);
else {
// Find sibling
pwr_tOid dest_oid = pwr_cNOid;
int dest_found = 0;
for ( int j = i - 1; j > 0; j--) {
if ( cdh_ObjidIsNotNull( ctx->attr->attrnav->dev_data.slot_data[j]->module_oid)) {
dest_oid = ctx->attr->attrnav->dev_data.slot_data[j]->module_oid;
dest_found = 1;
break;
}
}
if ( !dest_found)
sts = ldh_CreateObject( ctx->ldhses, &slot->module_oid, mname, slot->module_class,
ctx->aref.Objid, ldh_eDest_IntoFirst);
else
sts = ldh_CreateObject( ctx->ldhses, &slot->module_oid, mname, slot->module_class,
dest_oid, ldh_eDest_After);
}
if ( EVEN(sts)) {
MsgWindow::message( 'E', "Error creating module object", mname);
sts = 0;
goto return_now;
}
pwr_tAttrRef aaref;
pwr_tAttrRef modulearef = cdh_ObjidToAref( slot->module_oid);
// Set Slot
pwr_tUInt32 slotnumber = i;
sts = ldh_ArefANameToAref( ctx->ldhses, &modulearef, "Slot", &aaref);
if ( EVEN(sts)) goto return_now;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, &slotnumber, sizeof(slotnumber));
if ( EVEN(sts)) goto return_now;
}
}
for ( unsigned int i = 0; i < ctx->attr->attrnav->dev_data.slot_data.size(); i++) {
GsdmlSlotData *slot = ctx->attr->attrnav->dev_data.slot_data[i];
......@@ -810,12 +800,12 @@ pwr_tStatus pndevice_create_ctx( ldh_tSession ldhses, pwr_tAttrRef aref,
pwr_tStatus pndevice_init( device_sCtx *ctx)
{
pwr_tOid module_oid;
int corrupt = 1;
int corrupt = 0;
unsigned int idx;
pwr_tStatus sts;
// Identify module objects
#if 0
int size;
pwr_tObjName module_name;
......@@ -836,7 +826,7 @@ pwr_tStatus pndevice_init( device_sCtx *ctx)
}
ctx->attr->attrnav->dev_data.slot_data[idx]->module_oid = module_oid;
}
#endif
if ( corrupt) {
corrupt = 0;
......
......@@ -3840,7 +3840,7 @@ Volume Profibus $ClassVolume 0.0.250.7
Object RtBody $ObjBodyDef 1 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr StructName = "PnModule"
Attr NextAix = "_X22"
Attr NextAix = "_X23"
EndBody
!/**
! Description of this module.
......@@ -3873,6 +3873,17 @@ Volume Profibus $ClassVolume 0.0.250.7
EndBody
EndObject
!/**
! Slot number. Used by the Profinet configurator.
!*/
Object Slot $Attribute 22 09-DEC-2016 14:42:22.14
Body SysBody 09-DEC-2016 14:43:00.76
Attr PgmName = "Slot"
Attr Size = 40
Attr Flags = 1024
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! @Summary Process that handles the module. Plc(1), rt_io_comm(2) or application process(4).
! Process that handles the module.
!
......@@ -3979,7 +3990,7 @@ Volume Profibus $ClassVolume 0.0.250.7
! There are two SAP types reflecting the different characteristics of Master Stations and
! Slave Stations. Usually, "regular" SAP's are activated o Master Stations whereas Responder
! SAP's (RSAP's) are activated on Slave Stations. However both can be used on either one.
!
!
! A (R)SAP is defined by an address in the interval 0-63. A SAP is used to issue data transfers
! to a remote SAP or RSAP. A SAP can also be used to request data from a remote RSAP.
! A RSAP cannot request data from a remote (R)SAP. It is used to respond on a data request
......@@ -3988,16 +3999,16 @@ Volume Profibus $ClassVolume 0.0.250.7
! This object defines a SAP or RSAP and it's address. Also defined is the slave address
! of the node that this SAP will exchange data with. It should be created as a child to a
! Pb_Profiboard.
!
!
! See Proview documentation 'Guide to I/O Systems' for more information.
!
! @bConfiguration
! Instances of the class Pb_FDL_DataTransfer are created as children to the Pb_FDL_SAP object.
!
!
! For the SAP more than one instance can be created of the types SDA, SDN and SRD. These
! different type are used to send data to a remote SAP (types SDA and SDN) or to request data and
! if needed, at the same time send, data (type SRD). See more on class Pb_FDL_DataTransfer.
!
!
! For a RSAP instance only one instance can be created of type RUM used to recieve data and to update
! the data that will be sent back by a SRD request.
!
......@@ -4257,37 +4268,37 @@ Volume Profibus $ClassVolume 0.0.250.7
!
! With Profibus FDL Service Access Points data transfer services between nodes on a Profibus
! network is made possible.
!
!
! There are two SAP types reflecting the different characteristics of Master Stations and
! Slave Stations. Usually, "regular" SAP's are activated on Master Stations whereas Responder
! SAP's (RSAP's) are activated on Slave Stations. However both can be used on either one.
!
!
! There are five types of data transfer services that can be configured. Three for sending and/or
! requesting data and two for preparing reply data (only one supported).
!
!
! The first three of them are used from a SAP and cannot be used with a responder SAP (RSAP). These
! are SDA (Send Data with Acknowledge), SDN (Send Data with No acknowledge) and SRD (Send and Request
! Data with reply). When requesting data no data need to be sent.
!
!
! The other two services are used together with a responder SAP (RSAP) to prepare the reply data
! that will be sent back to a SAP upon the receipt of a SDA, SDN or SRD. These are RU (Reply-Update,
! this one is not supported) and RUM (Reply-Update-Multiple)
!
!
! Each data transfer is configured with the destination address (address of remote (R)SAP).
!
!
! The data that is to be sent or received are created as standard I/O channels which should be
! created as children to the Pb_FDL_DataTransfer-object. When receiveing data, the data will always
! be directed to the first (top) Pb_FDL_DataTransfer-object found as a child to the
! Pb_FDL_SAP-object.
!
!
! See Proview documentation 'Guide to I/O Systems' for more information.
!
! @bConfiguration
! Instances of the class Pb_FDL_DataTransfer are created as children to the Pb_FDL_SAP object.
!
!
! I/O-channels are created as children to the Pb_FDL_DataTransfer-object to represent the
! data being sent and/or received.
!
!
! For a RSAP instance only one instance can be created of type RUM used to recieve data and to update
! the data that will be sent back by a SRD request.
!
......@@ -4341,11 +4352,11 @@ Volume Profibus $ClassVolume 0.0.250.7
! FDLIF_SRD - Send and Request Data with reply
! FDLIF_RU - Reply Update (not supprted, RUM will always be used)
! FDLIF_RUM - Reply Update Multiple
!
!
! SDA and SDN can also receive data explictly sent with a SDA or SDN service from a
! remote SAP. If more than one Pb_FDL_DataTransfer objects have been created for a single
! SAP then the first child will receive the data.
!*/
!*/
Object Type $Attribute 16 14-AUG-2014 15:43:27.65
Body SysBody 14-AUG-2014 15:44:26.58
Attr PgmName = "Type"
......@@ -4356,7 +4367,7 @@ Volume Profibus $ClassVolume 0.0.250.7
!/**
! Result of operation.
! FDL_OK - If no error was reported during operation.
!*/
!*/
Object Result $Attribute 18 21-AUG-2014 14:33:17.09
Body SysBody 21-AUG-2014 15:06:59.67
Attr PgmName = "Result"
......@@ -4367,7 +4378,7 @@ Volume Profibus $ClassVolume 0.0.250.7
!/**
! Send request.
! Setting of this flag will trigger the data transfer service.
!*/
!*/
Object SendReq $Attribute 17 14-AUG-2014 15:58:41.14
Body SysBody 14-AUG-2014 15:58:47.91
Attr PgmName = "SendReq"
......
......@@ -628,7 +628,7 @@ usage()
{
cat << EOF
upgrade.sh Upgrade from V5.3.1 to V5.4.0
upgrade.sh Upgrade from V5.4 to V5.5
Pass
......@@ -636,7 +636,7 @@ usage()
savedirectory Save directory volume.
classvolumes Create loadfiles for classvolumes.
updateclasses Update classes.
cnvobjects Create OpPlaceWeb objects.
cnvobjects Update Profinet modules.
compile Compile all plcprograms in the database
createload Create new loadfiles.
buildnodes Build all nodes in the project.
......
!** Invisible: Script for to create OpPlaceWeb from WebHandler objects during upgrading from V5.3 to V5.4
!** Invisible: Script for upgrading Profinet modules during upgrading from V5.4 to V5.5
!
# Proview Open Source Process Control.
# Copyright (C) 2005-2016 SSAB EMEA AB.
......@@ -35,234 +35,102 @@
# General Public License plus this exception.
!
!
! Script to create OpPlaceWeb objects during upgrading from V5.3 to V5.4,
! Script for upgrading Profinet modules during upgrading from V5.4 to V5.5,
!
! Find all WebHandler objects and create an OpPlaceWeb.
! Sets the Slot attribute.
!
main()
function int is_numeric( string s)
string s1;
int ret = 0;
int len;
s1 = extract( 1, 1, s);
if ( s1 == "0" || s1 == "1" || s1 == "2" || s1 == "3" || s1 == "4" || s1 == "5" || s1 == "6" || s1 == "7" || s1 == "8" || s1 == "9")
ret = 1;
endif
len = strlen(s);
if ( len > 1)
s1 = extract( 2, 1, s);
if ( s1 == "0" || s1 == "1" || s1 == "2" || s1 == "3" || s1 == "4" || s1 == "5" || s1 == "6" || s1 == "7" || s1 == "8" || s1 == "9")
ret = 1;
endif
endif
return ret;
endfunction
function int set_slot( string mclass)
string name;
string opname;
string aname;
string aopname;
string attrstr;
int attrint;
string sname;
string snum;
int num;
string attr;
string parent;
string child;
string prevchild;
string class;
string nchild;
string nclass;
int idx;
int sts;
verify(0);
name = GetClassListAttrRef("WebHandler");
while ( name != "")
idx = strrchr( name, "-") - 1;
opname = extract( 1, idx, name);
opname = opname + "-OpWeb";
printf( "--\n");
printf( "-- Creating OpPlaceWeb object %s\n", opname);
printf( "--\n");
sts = CreateObject( "OpWeb", "OpPlaceWeb", name, 3);
if ( EVEN(sts))
printf( "** Unable to create object %s, sts %d\n", opname, sts);
quit
endif
aname = name + ".FileName";
aopname = opname + ".FileName";
attrstr = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrstr);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
aname = name + ".Title";
aopname = opname + ".Title";
attrstr = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrstr);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
aname = name + ".Text";
aopname = opname + ".Text";
attrstr = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrstr);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
aname = name + ".EnableLanguage";
aopname = opname + ".EnableLanguage";
attrint = GetAttribute( aname, sts);
sts = SetAttribute( aopname, attrint);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
aname = name + ".EnableLogin";
aopname = opname + ".EnableLogin";
attrint = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrint);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
aname = name + ".EnableAlarmList";
aopname = opname + ".EnableAlarmList";
attrint = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrint);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
aname = name + ".EnableEventLog";
aopname = opname + ".EnableEventLog";
attrint = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrint);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
aname = name + ".DisableHelp";
aopname = opname + ".DisableHelp";
attrint = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrint);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
aname = name + ".DisableProview";
aopname = opname + ".DisableProview";
attrint = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrint);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
aname = name + ".Language";
aopname = opname + ".Language";
attrint = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrint);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
aname = name + ".StyleSheet";
aopname = opname + ".StyleSheet";
attrstr = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrstr);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
name = GetClassList( mclass);
while ( name != "")
sname = CutObjectName( name, 1);
snum = extract( 2, 5, sname);
num = is_numeric( snum);
if ( num == 1)
num = snum;
attr = name + ".Slot";
SetAttribute( attr, num);
printf( "%s %d\n", name, num);
else
# Count siblings
parent = GetParent( name);
child = GetChild( parent);
num = 1;
while ( child != "")
if ( child == name)
attr = name + ".Slot";
SetAttribute( attr, num);
printf( "%s %d\n", name, num);
break;
endif
aname = name + ".StartURL";
aopname = opname + ".StartURL";
attrstr = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrstr);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
child = GetNextSibling( child);
num++;
endwhile
endif
aname = name + ".LoadArchives";
aopname = opname + ".LoadArchives";
attrstr = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrstr);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
name = GetNextObject( name);
endwhile
return 1;
endfunction
aname = name + ".PwrHost";
aopname = opname + ".PwrHost";
attrstr = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrstr);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
aname = name + ".AppletSignature";
aopname = opname + ".AppletSignature";
attrstr = GetAttribute( aname, sts);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aname);
endif
sts = SetAttribute( aopname, attrstr);
if ( EVEN(sts))
printf( "Attribute error: %s\n", aopname);
endif
main()
# Move WebGraph, WebLink, AppGraph and AppLink objects
child = GetChild( name);
prevchild = "";
while ( child != "")
class = GetObjectClass( child);
if ( class == "WebGraph" || class == "WebLink" || class == "AppGraph" || class == "AppLink")
MoveObject( child, opname, 2);
child = prevchild;
endif
if ( class == "$NodeHier")
nchild = GetChild( child);
if ( nchild != "")
nclass = GetObjectClass( nchild);
if ( nclass == "WebGraph" || nclass == "WebLink" || nclass == "AppGraph" || nclass == "AppLink")
MoveObject( child, opname, 2);
child = prevchild;
endif
endif
endif
prevchild = child;
if ( child == "")
child = GetChild( name);
else
child = GetNextSibling( child);
endif
endwhile
name = GetNextAttrRef( "WebHandler", name);
endwhile
save
set_slot( "PnModule");
set_slot( "BaseFcPPO3PnModule");
set_slot( "ABB_ACS880_PnModule");
set_slot( "Siemens_Di4_PnModule");
set_slot( "Siemens_Di2_PnModule");
set_slot( "Siemens_Do4_PnModule");
set_slot( "Siemens_Do2_PnModule");
set_slot( "Siemens_Di32_PnModule");
set_slot( "Siemens_D16_PnModule");
set_slot( "Siemens_Dx16_PnModule");
set_slot( "Siemens_Di8_PnModule");
set_slot( "Siemens_Do32_PnModule");
set_slot( "Siemens_Do16_PnModule");
set_slot( "Siemens_Do8_PnModule");
set_slot( "Siemens_Ai8_PnModule");
set_slot( "Siemens_Ai4_PnModule");
set_slot( "Siemens_Ai2_PnModule");
set_slot( "Siemens_Ao8_PnModule");
set_slot( "Siemens_Ao4_PnModule");
set_slot( "Sinamics_Tgm1_PnModule");
endmain
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