----------------------------------------------------------------------------- -- Name: PMC Module --Created: 03/27/2015 ----------------------------------------------------------------------------- -- This is auto-generated code from PmcEditor. Do not edit this file! Go -- back to the ladder diagram source for changes in the logic -- U_xxx symbols correspond to user-defined names. There is such a symbol -- for every internal relay, variable, timer, and so on in the ladder -- program. I_xxx symbols are internally generated. local Pompgeleiders = {} local pmcvars = {} -- One local variable to conatain all pmc generated variables local hIo, hReg, hSig, rc local mInst = 0 -- Generated function for MachAPI. local function Read_Register(path) hReg, rc = mc.mcRegGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then local value, rc = mc.mcRegGetValue(hReg) if (rc == mc.MERROR_NOERROR) then return value end end return 0 end -- Generated function for MachAPI. local function Write_Register(path, value) hReg, rc = mc.mcRegGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then rc = mc.mcRegSetValue(hReg, value) if (rc == mc.MERROR_NOERROR) then return end end return end -- Generated function for MachAPI. local function Read_Signal(path) hSig = 0 rc = mc.MERROR_NOERROR hSig, rc = mc.mcSignalGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then local state = 0; state, rc = mc.mcSignalGetState(hSig) if (rc == mc.MERROR_NOERROR) then return state end end return 0 end -- Generated function for MachAPI. local function Write_Signal(path, v) hSig = 0 rc = mc.MERROR_NOERROR hSig, rc = mc.mcSignalGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then mc.mcSignalSetState(hSig, v) end end -- Generated function for MachAPI. local function Read_Io(path) hIo = 0 rc = mc.MERROR_NOERROR hIo, rc = mc.mcIoGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then local state = 0 state, rc = mc.mcIoGetState(hIo) if (rc == mc.MERROR_NOERROR) then return state end end return 0 end -- Generated function for MachAPI. local function Write_Io(path, v) hIo, rc = mc.mcIoGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then mc.mcIoSetState(hIo, v) end end pmcvars.I_b_mcr = 0 local function Read_I_b_mcr() return pmcvars.I_b_mcr; end local function Write_I_b_mcr(x) pmcvars.I_b_mcr = x; end pmcvars.I_b_rung_top = 0 local function Read_I_b_rung_top() return pmcvars.I_b_rung_top; end local function Write_I_b_rung_top(x) pmcvars.I_b_rung_top = x; end -- Generated function for signal read. local function Read_U_b_FEnable() return Read_Signal(1018) end -- Generated function for signal write. local function Write_U_b_FEnable(v) Write_Signal(1018, v) end pmcvars.U_b_RReset = 0 local function Read_U_b_RReset() return pmcvars.U_b_RReset; end local function Write_U_b_RReset(x) pmcvars.U_b_RReset = x; end pmcvars.I_b_TEnabletimer = 0 local function Read_I_b_TEnabletimer() return pmcvars.I_b_TEnabletimer; end local function Write_I_b_TEnabletimer(x) pmcvars.I_b_TEnabletimer = x; end -- Generated stop watch declaration pmcvars.U_t_TEnabletimer = wx.wxStopWatch() -- Generated function for I/O read. local function Read_U_b_YOilpump() return Read_Io("CSMIO-IP/Out.11") end -- Generated function for I/O write. local function Write_U_b_YOilpump(v) Write_Io("CSMIO-IP/Out.11", v) end -- Generated function for I/O read. local function Read_U_b_YPompaan() return Read_Io("CSMIO-IP/Out.11") end -- Generated function for I/O write. local function Write_U_b_YPompaan(v) Write_Io("CSMIO-IP/Out.11", v) end pmcvars.I_b_TPompaantimer = 0 local function Read_I_b_TPompaantimer() return pmcvars.I_b_TPompaantimer; end local function Write_I_b_TPompaantimer(x) pmcvars.I_b_TPompaantimer = x; end -- Generated stop watch declaration pmcvars.U_t_TPompaantimer = wx.wxStopWatch() -- Call this function to retrieve the PMC cycle time interval -- that you specified in the PmcEditor. function Pompgeleiders.GetCycleInterval() return 10 end -- Call this function once per PLC cycle. You are responsible for calling -- it at the interval that you specified in the MCU configuration when you -- generated this code. */ function Pompgeleiders.PlcCycle() mInst = mc.mcGetInstance() Write_I_b_mcr(1) -- start rung 1 Write_I_b_rung_top(Read_I_b_mcr()) -- start series [ if(Read_U_b_FEnable() == 0) then Write_I_b_rung_top(0) end if(Read_U_b_RReset() == 1) then Write_I_b_rung_top(0) end if(Read_I_b_rung_top() == 1) then if(Read_I_b_TEnabletimer() == 0) then Write_I_b_TEnabletimer(1) pmcvars.U_t_TEnabletimer:Start() end if(pmcvars.U_t_TEnabletimer:Time() < 10000) then Write_I_b_rung_top(0) else pmcvars.U_t_TEnabletimer:Pause() end else if(Read_I_b_TEnabletimer() == 1) then Write_I_b_TEnabletimer(0) end end Write_U_b_YOilpump(Read_I_b_rung_top()) -- ] finish series -- start rung 2 Write_I_b_rung_top(Read_I_b_mcr()) -- start series [ if(Read_U_b_YPompaan() == 0) then Write_I_b_rung_top(0) end if(Read_I_b_rung_top() == 1) then if(Read_I_b_TPompaantimer() == 0) then Write_I_b_TPompaantimer(1) pmcvars.U_t_TPompaantimer:Start() end if(pmcvars.U_t_TPompaantimer:Time() < 10000) then Write_I_b_rung_top(0) else pmcvars.U_t_TPompaantimer:Pause() end else if(Read_I_b_TPompaantimer() == 1) then Write_I_b_TPompaantimer(0) end end Write_U_b_RReset(Read_I_b_rung_top()) -- ] finish series end return Pompgeleiders