Skip to content

Commit

Permalink
Merge branch 'master' into Bug-ECS-4719
Browse files Browse the repository at this point in the history
  • Loading branch information
NSLentz authored May 16, 2024
2 parents 267e9f7 + db6ce93 commit 77289e8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lcls-twincat-motion/Library/Library.plcproj
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,10 @@
<DefaultResolution>Tc2_Utilities, * (Beckhoff Automation GmbH)</DefaultResolution>
<Namespace>Tc2_Utilities</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="Tc3_IPCDiag">
<DefaultResolution>Tc3_IPCDiag, * (Beckhoff Automation GmbH)</DefaultResolution>
<Namespace>Tc3_IPCDiag</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="Tc3_JsonXml">
<DefaultResolution>Tc3_JsonXml, * (Beckhoff Automation GmbH)</DefaultResolution>
<Namespace>Tc3_JsonXml</Namespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ VAR_INPUT
// Set to TRUE to cause an extra read.
bRefresh: BOOL;
// Directory where the DB is stored.
sDirectory: STRING := '/Hard Disk/ftp/PMPS/';
sDirectory: STRING := '';
END_VAR
VAR_OUTPUT
{attribute 'pytmc' := '
Expand All @@ -42,6 +42,11 @@ VAR
fbTime : FB_LocalSystemTime := ( bEnable := TRUE, dwCycle := 1 );
fbTime_to_UTC: FB_TzSpecificLocalTimeToSystemTime;
fbGetTimeZone: FB_GetTimeZoneInformation;
fbIPCReg: FB_IPCDiag_Register;
fbCheckOS: FB_IPCDiag_ReadParameter;
sOSName: STRING := '';
nCheckOSTries: UINT := 3;
END_VAR
]]></Declaration>
<Implementation>
Expand All @@ -62,9 +67,44 @@ IF rtEnable.Q OR rtRefresh.Q THEN
bExecute := TRUE;
END_IF
IF sDirectory = '' THEN
// Check OS for default directory
fbIPCReg(
bExecute:=TRUE,
tTimeout:=T#1s,
);
fbCheckOS(
bExecute:=fbIPCReg.bValid,
eParameterKey:=E_IPCDiag_ParameterKey.OS_Name,
fbRegister:=fbIPCReg,
);
IF fbIPCReg.bError OR fbCheckOS.bError THEN
IF nCheckOSTries <= 0 THEN
// Retry counter down to zero: set to error name to try old default
sOSName := 'Error';
ELSE
// Decrement retry counter
nCheckOSTries := nCheckOSTries - 1;
// Reset FBs
fbCheckOS(bExecute:=FALSE, fbRegister:=fbIPCReg);
fbIPCReg(bExecute:=FALSE);
END_IF
ELSIF fbCheckOS.bValid THEN
fbCheckOS.GetParameter(
pBuffer:=ADR(sOSName),
nBufferSize:=SIZEOF(sOSName),
);
END_IF
IF sOSName = 'TwinCAT/BSD' THEN
sDirectory := '/home/ecs-user/pmpsdb/';
ELSIF sOSName <> '' THEN
sDirectory := '/Hard Disk/ftp/PMPS/';
END_IF
END_IF
MOTION_GVL.fbPmpsFileReader(
io_fbFFHWO:=io_fbFFHWO,
bExecute:=bExecute,
bExecute:=bExecute AND sDirectory <> '',
sSrcPathName:=CONCAT(CONCAT(sDirectory, sPlcName), '.json'),
sPLCName:=sPLCName,
PMPS_jsonDoc=>PMPS_GVL.BP_jsonDoc,
Expand Down

0 comments on commit 77289e8

Please sign in to comment.