----------------------------------------------------------------------------- -- 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 jambo = {} local pmcvars = {} -- One local variable to conatain all pmc generated variables local hIo, hReg, hSig, rc local mInst = 0 -- Generated function for MachAPI. function Read_Register(path) hReg, rc = mc.mcRegGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then local value, rc = mc.mcRegGetValueLong(hReg) if (rc == mc.MERROR_NOERROR) then return value end end return 0 end -- Generated function for MachAPI. function Write_Register(path, value) hReg, rc = mc.mcRegGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then rc = mc.mcRegSetValueLong(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 -- Call this function to retrieve the PMC cycle time interval -- that you specified in the PmcEditor. function jambo.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 jambo.PlcCycle() mInst = mc.mcGetInstance() -- DA QUI ROUTINE DA RIPETERE PER QUANTI I/O SI VUOLE local v_out= mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1) -- per l'output N 1 state_out = mc.mcSignalGetState(v_out) local v_in= mc.mcSignalGetHandle(inst, mc.ISIG_INPUT1) -- per l'input N 1 state_in = mc.mcSignalGetState(v_in) if(state_in==1 and flag1==0)then if(state_out==0)then mc.mcSignalSetState(v_out, 1) else mc.mcSignalSetState(v_out, 0) end flag1=1 end if(state_in==0) then flag1=0 end -- FINE ROUTINE PER UN I/O -- E QUI UN ESEMPIO PER UN SECONO I/O v_out= mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT2) -- per l'output N 2 state_out = mc.mcSignalGetState(v_out) v_in= mc.mcSignalGetHandle(inst, mc.ISIG_INPUT2) -- per l'input N 2 state_in = mc.mcSignalGetState(v_in) if(state_in==1 and flag2==0)then if(state_out==0)then mc.mcSignalSetState(v_out, 1) else mc.mcSignalSetState(v_out, 0) end flag2=1 end if(state_in==0) then flag2=0 end Write_I_b_mcr(1) end return jambo