diff --git a/README.md b/README.md index 58f6463..8c129e4 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,128 @@ Simatic.Ax.LAcycCom; ## Example - +```cli +PROGRAM MyProgram + VAR + Resourcemanager : OOPLAcycCom_ResourceManager; + WriteParameterSingle : LAcycCom_classWriteDriveSingleParams; + ReadParameterSingle : LAcycCom_classReadDriveSingleParams; + WriteParameter : LAcycCom_classWriteDriveParams; + ReadParameter : LAcycCom_classReadDriveParams; + diagnostic : LAcycCom_ooptypeDrivediagnostics; + RVALUEp304 : real; + RVALUEp305 : real; + RVALUEp310 : real; + FirstCycle : Bool := TRUE; + datasetitemread : LAcycCom_typeDriveDataset; + datasetitemwrite : LAcycCom_typeDriveDataset; + elements : int; + END_VAR + + Resourcemanager.execute(); + + ReadParameter.execute(); + ReadParameterSingle.execute(); + WriteParameter.execute(); + WriteParameterSingle.execute(); + + If FirstCycle Then + ReadParameter.Config(requestBuffer := Resourcemanager); + ReadParameterSingle.Config(requestBuffer := Resourcemanager); + WriteParameter.Config(requestBuffer := Resourcemanager); + WriteParameterSingle.Config(requestBuffer := Resourcemanager); + end_IF; + + CASE ReadParameter.Status() OF + LAcycComstate_def#BUSY : + ; + + LAcycComstate_def#IDLE : + datasetitemread.parameterNumber := uint#304; + elements := ReadParameter.AddatasetItem(datasetItem := datasetitemread, + element_no := -1); + + datasetitemread.parameterNumber := uint#305; + elements := ReadParameter.AddatasetItem(datasetItem := datasetitemread, + element_no := -1); + + ReadParameter.Start(driveObjectId := uint#5, + hardwareId := word#269); + + LAcycComstate_def#DONE : + datasetitemread := ReadParameter.ReaddatasetItem(element_no := 0); + RVALUEp304 := datasetitemread.value; + datasetitemread := ReadParameter.ReaddatasetItem(element_no := 1); + RVALUEp305 := datasetitemread.value; + + LAcycComstate_def#ERROR : + diagnostic := ReadParameter.errordiagnostics(); + END_CASE; + + CASE ReadParameterSingle.Status() OF + LAcycComstate_def#BUSY : + ; + + LAcycComstate_def#IDLE : + ReadParameterSingle.Start( driveObjectId := uint#5, + hardwareId := word#269, + parameterNumber := uint#310, + index := uint#0); + + LAcycComstate_def#DONE : + RVALUEp310 := ReadParameterSingle.GetValueREAL(); + + LAcycComstate_def#ERROR : + diagnostic := ReadParameterSingle.errordiagnostics(); + END_CASE; + + CASE WriteParameter.Status() OF + LAcycComstate_def#BUSY : + ; + + LAcycComstate_def#IDLE : + + datasetitemwrite.parameterNumber := uint#2900; + datasetitemwrite.value := real#12.3; + elements := WriteParameter.AddatasetItem(datasetItem := datasetitemwrite, + element_no := -1); + + datasetitemwrite.parameterNumber := uint#2901; + datasetitemwrite.value := real#45.6; + elements := WriteParameter.AddatasetItem(datasetItem := datasetitemwrite, + element_no := -1); + + WriteParameter.Start(driveObjectId := uint#5, + hardwareId := word#269); + + LAcycComstate_def#DONE : + ; + + LAcycComstate_def#ERROR : + diagnostic := WriteParameter.errordiagnostics(); + END_CASE; + + CASE WriteParameterSingle.Status() OF + LAcycComstate_def#BUSY : + ; + + LAcycComstate_def#IDLE : + WriteParameterSingle.Start( driveObjectId := uint#5, + hardwareId := word#269, + parameterNumber := uint#2930, + value := REAL#78.9, + index := uint#0); + + LAcycComstate_def#DONE : + ; + + LAcycComstate_def#ERROR : + diagnostic := WriteParameterSingle.errordiagnostics(); + END_CASE; + + FirstCycle := False; +END_PROGRAM +``` ## Contribution diff --git a/src/Blocks/Drives/classReadDriveParams.st b/src/Blocks/Drives/classReadDriveParams.st index 1622a83..078446a 100644 --- a/src/Blocks/Drives/classReadDriveParams.st +++ b/src/Blocks/Drives/classReadDriveParams.st @@ -468,5 +468,33 @@ NAMESPACE Simatic.Ax.LAcycCom End_Method + Method public ReaddatasetValue : real + VAR_INPUT + element_no : int := int#0; + end_VAR + VAR_TEMP + tempLoopIndex : Int; + end_VAR + + If element_no >= 0 and element_no <= typeconstantsint#LACYCCOM_READ_PARAMETERS_UPPER_LIM Then + ReaddatasetValue := dataset[element_no].value; + end_if; + + End_Method + + Method public ReaddatasetDWValue : DWORD + VAR_INPUT + element_no : int := int#0; + end_VAR + VAR_TEMP + tempLoopIndex : Int; + end_VAR + + If element_no >= 0 and element_no <= typeconstantsint#LACYCCOM_READ_PARAMETERS_UPPER_LIM Then + ReaddatasetDWValue := dataset[element_no].DWvalue; + end_if; + + End_Method + END_CLASS END_NAMESPACE \ No newline at end of file diff --git a/src/Blocks/Drives/classWriteDriveSingleParams.st b/src/Blocks/Drives/classWriteDriveSingleParams.st index 780d25c..fe1673a 100644 --- a/src/Blocks/Drives/classWriteDriveSingleParams.st +++ b/src/Blocks/Drives/classWriteDriveSingleParams.st @@ -528,10 +528,5 @@ NAMESPACE Simatic.Ax.LAcycCom END_IF; END_METHOD - METHOD PUBLIC ReqReadParameter : LAcycCom_TypestatstatReqParameter - - ReqReadParameter := statReqReadParameter; - END_METHOD - END_CLASS END_NAMESPACE \ No newline at end of file