Skip to content

Commit

Permalink
ENH: check PLC OS to set new default dir for BSD PLCs
Browse files Browse the repository at this point in the history
  • Loading branch information
ZLLentz committed Mar 22, 2024
1 parent b9ecaa7 commit 64b3ccf
Show file tree
Hide file tree
Showing 2 changed files with 31 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 @@ -631,6 +631,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,10 @@ 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;
END_VAR
]]></Declaration>
<Implementation>
Expand All @@ -62,9 +66,30 @@ IF rtEnable.Q OR rtRefresh.Q THEN
bExecute := TRUE;
END_IF
IF sDirectory = '' THEN
// Check OS for default directory
fbIPCReg(bExecute:=TRUE);
fbCheckOS(
bExecute:=NOT fbIPCReg.bBusy,
eParameterKey:=E_IPCDiag_ParameterKey.OS_Name,
fbRegister:=fbIPCReg,
);
IF 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 64b3ccf

Please sign in to comment.