2.4 Order of PLC Procedure
After the above three functions of PLC, PLC.CPP should be able to understand the overall situation, in fact, PLC.CPP writing method is a certain specification to follow: If you want to use any one of the C language resources, you must first use the resource content from #include sources.
If external program and variable missing declare, error occurs during compiling and no generates *.dlm. The clear structure of C language can prevent any wrong result of code.
After #include, #define and variables, the PLC is then written in the order of plcOpen, plcRun, and plcClose.
#include "..\mplc\mplc.h"
.
.
#define iXALM (plc.svi1.bit.xsalm)
.
.
int fSpindleFlag;
struct timer{
int timer;
int flag;}
void PLCAPI plcOpen(struct Status &sts, struct PlcBlock &plc,
unsigned short *PlcData, long *PlcLongData){ }
void PLCAPI plcRun(struct Status &sts, struct PlcBlock &plc){ }
void PLCAPI plcClose(struct Status &sts, struct PlcBlock &plc){ }