Skip to content

Commit

Permalink
Merge pull request #10 from simatic-ax/test
Browse files Browse the repository at this point in the history
Add Code example
  • Loading branch information
DavidDKo authored Oct 30, 2023
2 parents f6262d1 + 735cceb commit 3c6e45b
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 6 deletions.
123 changes: 122 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,128 @@ Simatic.Ax.LAcycCom;

## Example

<please provide a working 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

Expand Down
28 changes: 28 additions & 0 deletions src/Blocks/Drives/classReadDriveParams.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 0 additions & 5 deletions src/Blocks/Drives/classWriteDriveSingleParams.st
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3c6e45b

Please sign in to comment.