From 64b3ccfebccecc7991231fbf40ac35895b3e19f7 Mon Sep 17 00:00:00 2001 From: Zachary Lentz Date: Fri, 22 Mar 2024 14:52:47 -0700 Subject: [PATCH] ENH: check PLC OS to set new default dir for BSD PLCs --- lcls-twincat-motion/Library/Library.plcproj | 4 +++ .../POUs/Motion/PMPS/FB_Standard_PMPSDB.TcPOU | 29 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lcls-twincat-motion/Library/Library.plcproj b/lcls-twincat-motion/Library/Library.plcproj index 20dde9f1..9429903f 100644 --- a/lcls-twincat-motion/Library/Library.plcproj +++ b/lcls-twincat-motion/Library/Library.plcproj @@ -631,6 +631,10 @@ Tc2_Utilities, * (Beckhoff Automation GmbH) Tc2_Utilities + + Tc3_IPCDiag, * (Beckhoff Automation GmbH) + Tc3_IPCDiag + Tc3_JsonXml, * (Beckhoff Automation GmbH) Tc3_JsonXml diff --git a/lcls-twincat-motion/Library/POUs/Motion/PMPS/FB_Standard_PMPSDB.TcPOU b/lcls-twincat-motion/Library/POUs/Motion/PMPS/FB_Standard_PMPSDB.TcPOU index 06d04dd3..0b0190ed 100644 --- a/lcls-twincat-motion/Library/POUs/Motion/PMPS/FB_Standard_PMPSDB.TcPOU +++ b/lcls-twincat-motion/Library/POUs/Motion/PMPS/FB_Standard_PMPSDB.TcPOU @@ -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' := ' @@ -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 ]]> @@ -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,