Skip to content

Commit

Permalink
fast Testversion
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidDKo committed Sep 5, 2024
1 parent d72b6e7 commit 41e01e3
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 12 deletions.
10 changes: 9 additions & 1 deletion apax-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"dependencies": {
"@ax/system-timer": "7.0.17",
"@ax/simatic-1500-distributedio": "7.0.1",
"@ax/system-serde": "7.0.17"
"@ax/system-serde": "7.0.17",
"@ax/simatic-1500-clocks": "^7.0.4"
},
"devDependencies": {
"@ax/sdk": "2405.0.0",
Expand Down Expand Up @@ -74,6 +75,13 @@
"@ax/system-strings": "7.0.17"
}
},
"@ax/simatic-1500-clocks": {
"name": "@ax/simatic-1500-clocks",
"version": "7.0.4",
"integrity": "sha512-tJ9zlHOYpAsr9RYZEhpQojmSqw6Ja8aYPpZH94OCXaEggSdArpgQWr4Kyvw7w2NHx5TC3LnmED/BoBCilwCBaA==",
"resolved": "https://registry.simatic-ax.siemens.io/@ax/simatic-1500-clocks/-/simatic-1500-clocks-7.0.4.tgz",
"dependencies": {}
},
"@ax/apax-build": {
"name": "@ax/apax-build",
"version": "1.0.0",
Expand Down
1 change: 1 addition & 0 deletions apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies:
"@ax/system-timer": 7.0.17
"@ax/simatic-1500-distributedio": 7.0.1
"@ax/system-serde": 7.0.17
"@ax/simatic-1500-clocks": ^7.0.4
# Files, which will be shipped with the library
files:
- 'README.md'
Expand Down
177 changes: 166 additions & 11 deletions src/Blocks/Drives/classRtcSinamics.st
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
using system.timer;
USING Siemens.Simatic.S71500.Clocks;
USING System.DateTime;
using siemens.Simatic.S71500.DistributedIO;

NAMESPACE Simatic.Ax.LAcycCom
CLASS LAcycCom_classRtcSinamics
VAR
VAR
statrtcRealTimeSyncPING : bool;
statRetSetrtcRealTimeSyncPING : bool;
statRetResetrtcRealTimeSyncPING : bool;
statdatasetItem : LAcycCom_typeDriveDataset;
statrequestBuffer : Resourcemanager;
statWriteDriveParams : LAcycCom_classWriteDriveParams;
statWriteDrivePara : LAcycCom_classWriteDriveSingleParams;
statFBState : LAcycCom_ReadWriteStatus := LAcycCom_ReadWriteStatus#FB_IDLE; // States in the function block state machine
statFBSubState : LAcycCom_ReadWriteStatus := LAcycCom_ReadWriteStatus#FB_BUSY_PING; // States in the function block during processing (busy state)
statStatus : Word := STATUS_NO_CALL; // Static value for output status
statStateNumber : LAcycCom_ReadWriteStatus; // State of the FB when error occurred
stathardwareId : HW_IO;
statsystemDateTime : LDATE_AND_TIME;
statWritepara : LAcycCom_classWriteDriveSingleParams;
statactmilisecond : DWORD;
end_VAR

VAR CONSTANT
Expand Down Expand Up @@ -74,25 +80,166 @@ NAMESPACE Simatic.Ax.LAcycCom
END_METHOD

Method PRIVATE Busy
VAR
actDays : INT;
actMonth : INT;
actYear : INT;
actHour : INT;
actMinute : INT;
actSecond : INT;
actMillisecond : INT;
elapsedYears : INT;
elapsedDays : DINT;
loop : DINT;
END_VAR

CASE statFBSubState OF
LAcycCom_ReadWriteStatus#FB_BUSY_PING_RESET:
If statRetResetrtcRealTimeSyncPING then
statFBSubState := LAcycCom_ReadWriteStatus#FB_BUSY_PING;
statFBSubState := LAcycCom_ReadWriteStatus#FB_BUSY_WRREC;
statWriteDriveParams.execute();
statWriteDriveParams.Start(driveObjectId := uint#1,
hardwareId := stathardwareId,
parameterCount := 2);
END_IF;


LAcycCom_ReadWriteStatus#FB_BUSY_WRREC:
statWriteDriveParams.execute();

If statWriteDriveParams.Status() = LAcycComstateDef#DONE Then
statFBSubState := LAcycCom_ReadWriteStatus#FB_BUSY_PING;

end_IF;

LAcycCom_ReadWriteStatus#FB_BUSY_PING:
statrtcRealTimeSyncPING := TRUE;
If statRetSetrtcRealTimeSyncPING then
statFBSubState := LAcycCom_ReadWriteStatus#FB_BUSY_WRREC;
END_IF;
LAcycCom_ReadWriteStatus#FB_BUSY_WRREC:

GetSystemDateTime(value => statsystemDateTime);

SplitDateAndTime(value := statsystemDateTime,
year => actYear,
month => actMonth,
day => actDays,
hour => actHour,
minute => actMinute,
second => actSecond,
millisecond => actMillisecond);

//add number of days from full years, subtracting the current year
FOR loop := 1992 TO (actYear - 1) DO
IF loop MOD 4 = 0 AND loop <> 2100 THEN
elapsedDays := elapsedDays + 366;
ELSE
elapsedDays := elapsedDays + 365;
END_IF;
END_FOR;

//add days from full months of the current year
IF actMonth > 1 THEN
elapsedDays := elapsedDays + 31;
END_IF;
IF actMonth > 2 THEN
IF actYear MOD 4 = 0 AND NOT (actYear = 2100) THEN
elapsedDays := elapsedDays + 29;
ELSE
elapsedDays := elapsedDays + 28;
END_IF;
END_IF;
IF actMonth > 3 THEN
elapsedDays := elapsedDays + 31;
END_IF;
IF actMonth > 4 THEN
elapsedDays := elapsedDays + 30;
END_IF;
IF actMonth > 5 THEN
elapsedDays := elapsedDays + 31;
END_IF;
IF actMonth > 6 THEN
elapsedDays := elapsedDays + 30;
END_IF;
IF actMonth > 7 THEN
elapsedDays := elapsedDays + 31;
END_IF;
IF actMonth > 8 THEN
elapsedDays := elapsedDays + 31;
END_IF;
IF actMonth > 9 THEN
elapsedDays := elapsedDays + 30;
END_IF;
IF actMonth > 10 THEN
elapsedDays := elapsedDays + 31;
END_IF;
IF actMonth > 11 THEN
elapsedDays := elapsedDays + 30;
END_IF;

//add days from current month
elapsedDays := elapsedDays + actDays;
statactmilisecond :=TO_DWORD (TO_UDINT(actMillisecond) + UDINT#1000 * (TO_UDINT(actSecond) + UDINT#60 * (TO_UDINT(actMinute + 60 * ( actHour)))));

statWriteDriveParams.DeleteList();

statdatasetItem.parameterNumber := uint#3101; //date
statdatasetItem.index := uint#1;
// statdatasetItem.Rvalue := LWORD_TO_LREAL(LDATE_TO_LWORD(LDATE_AND_TIME_TO_LDATE(statsystemDateTime)));
statWriteDriveParams.AddatasetItem(datasetItem := statdatasetItem);


statFBSubState := LAcycCom_ReadWriteStatus#FB_BUSY_WRREC_1;
statWriteDriveParams.execute();
statWriteDrivePara.execute();
statWriteDrivePara.Start(driveObjectId := UINT#1, // Optional: Identification number of the drive object (value =0: driveObjectId is not used, i.e. the corresponding drive object is only addressed via the hardwareId)
hardwareId := word#266, // Hardware identifier of the hardware module
parameterNumber := UInt#3101, // Number of the parameter
index := uint#1, // Parameter index
value := TO_REAL(elapsedDays+8034),
DWVALUE := dword#0
);
(* statWriteDriveParams.Start(driveObjectId := uint#1,
hardwareId := stathardwareId,
parameterCount := 1); *)
END_IF;

LAcycCom_ReadWriteStatus#FB_BUSY_WRREC_1 :
statWriteDriveParams.execute();
statWriteDriveParams.Start(driveObjectId := uint#1,
hardwareId := stathardwareId,
parameterCount := 2);
If statWriteDriveParams.Status() = LAcycComstateDef#DONE Then
statWriteDrivePara.execute();

If statWriteDrivePara.Status() = LAcycComstateDef#DONE Then

statWriteDriveParams.DeleteList();


statdatasetItem.parameterNumber := uint#3101;//ms
statdatasetItem.index := uint#0;
statdatasetItem.Rvalue := real#288000.0;
statWriteDriveParams.AddatasetItem(datasetItem := statdatasetItem);

statFBSubState := LAcycCom_ReadWriteStatus#FB_BUSY_WRREC_1;
statWriteDriveParams.execute();
statWriteDrivePara.execute();
statWriteDrivePara.Start(driveObjectId := UINT#1, // Optional: Identification number of the drive object (value =0: driveObjectId is not used, i.e. the corresponding drive object is only addressed via the hardwareId)
hardwareId := word#266, // Hardware identifier of the hardware module
parameterNumber := UInt#3101, // Number of the parameter
index := uint#0, // Parameter index
value := real#0.0,
DWVALUE := statactmilisecond

);
(* statWriteDriveParams.Start(driveObjectId := uint#1,
hardwareId := stathardwareId,
parameterCount := 1);
*)
end_IF;

LAcycCom_ReadWriteStatus#FB_BUSY_WRREC_2 :
statWriteDriveParams.execute();
statWriteDrivePara.execute();
If statWriteDrivePara.Status() = LAcycComstateDef#DONE Then
statFBState := LAcycCom_ReadWriteStatus#FB_DONE;
end_IF;
statrtcRealTimeSyncPING := FALSE;
end_IF;
END_CASE;

END_METHOD
Expand All @@ -114,7 +261,7 @@ NAMESPACE Simatic.Ax.LAcycCom

end_if;
statWriteDriveParams.Config(requestBuffer := statrequestBuffer);

statWriteDrivePara.Config(requestBuffer := statrequestBuffer);
end_METHOD

METHOD PUBLIC getPing : bool
Expand All @@ -138,6 +285,14 @@ NAMESPACE Simatic.Ax.LAcycCom

END_METHOD

METHOD PUBLIC status : LAcycCom_ReadWriteStatus
status := statFBSubState;
END_METHOD

METHOD PUBLIC diag : LAcycCom_ooptypeDrivediagnostics
diag := statWriteDriveParams.errordiagnostics();
END_METHOD

END_CLASS

END_NAMESPACE

0 comments on commit 41e01e3

Please sign in to comment.