/**
|
******************************************************************************
|
* @file : PLCfunctions.c
|
* @brief : PLC funcstions program body
|
******************************************************************************
|
*/
|
//#include "globaldef.h"
|
#include "PLCfunctions.h"
|
#include "string.h"
|
#include "stm32f0xx_hal.h"
|
#include <core_cmInstr.h>
|
|
#if (ENABLE_PLC)
|
extern __IO uint32_t uwTick;
|
|
//unsigned short WDFs[TOTAL_WDFS];
|
|
inline unsigned int GetTick(void)
|
{
|
// unsigned short Clk1=SysTick->VAL;
|
return uwTick;
|
}
|
|
//unsigned char CurVAL;
|
//unsigned char CurVALs[TOTAL_CurVAL];
|
//stTimer Timers[TOTALTIMERS];
|
|
//unsigned short WX[13];
|
//unsigned short WY[13];
|
//unsigned short WR[64];
|
//unsigned short DT[256];
|
|
//unsigned short SDT[256];
|
|
stPLCMem PLCMem;
|
|
int InitTimer(int nIndex, int nType)
|
{
|
if (nIndex >= TOTALTIMERS) return -1;
|
PLCMem.Timers[nIndex].StatByte = 0x0010 | nType;
|
// Timers[nIndex].nType = 0;
|
PLCMem.SV[nIndex] = 0;
|
PLCMem.EV[nIndex] = 0;
|
PLCMem.Timers[nIndex].LastActTime = GetTick();
|
return 0;
|
}
|
|
int RunTimer(int nIndex , int SV)
|
{
|
if (nIndex >= TOTALTIMERS) return -1;
|
if (!PLCMem.Timers[nIndex].bSet)
|
{
|
PLCMem.SV[nIndex] = SV;
|
PLCMem.EV[nIndex]= 0;
|
PLCMem.Timers[nIndex].LastActTime = GetTick();
|
PLCMem.Timers[nIndex].bSet = 1;
|
}
|
return 0;
|
}
|
|
int StopTimer(int nIndex)
|
{
|
if (nIndex >= TOTALTIMERS) return -1;
|
if (PLCMem.Timers[nIndex].bSet)
|
{
|
PLCMem.EV[nIndex] = 0;
|
PLCMem.Timers[nIndex].LastActTime = GetTick();
|
PLCMem.Timers[nIndex].bSet = 0;
|
}
|
return 0;
|
}
|
int ResetTimer(int nIndex)
|
{
|
if (nIndex >= TOTALTIMERS) return -1;
|
PLCMem.EV[nIndex] = 0;
|
PLCMem.Timers[nIndex].bTon = 0;
|
PLCMem.Timers[nIndex].LastActTime=GetTick();
|
return 0;
|
}
|
|
int SetTimerValue(int nIndex, int bSet, int SV)
|
{
|
if (nIndex >= TOTALTIMERS) return -1;
|
if (bSet) {RunTimer(nIndex, SV);}
|
else {StopTimer(nIndex);}
|
return PLCMem.Timers[nIndex].bTon;
|
}
|
|
int ProcessTimer(int nIndex)
|
{
|
if (nIndex >= TOTALTIMERS) return -1;
|
if (!PLCMem.Timers[nIndex].nInited) return 0;
|
if (PLCMem.Timers[nIndex].bSet) // bSet =1;
|
{
|
if (!PLCMem.Timers[nIndex].bTon)
|
{
|
int nScale = TICK_OF_MS;
|
if (PLCMem.Timers[nIndex].nScale == 0)
|
{nScale = TICK_OF_MS;
|
}else if (PLCMem.Timers[nIndex].nScale == 1)
|
{nScale = TICK_OF_RS;
|
}else if (PLCMem.Timers[nIndex].nScale == 2)
|
{nScale = TICK_OF_XS;
|
}else if (PLCMem.Timers[nIndex].nScale == 3)
|
{nScale = TICK_OF_YS;
|
}else {}
|
|
int TimeDiff = GetTick() - PLCMem.Timers[nIndex].LastActTime;
|
if (TimeDiff < 0) { TimeDiff = nScale;}
|
if (TimeDiff >= nScale)
|
{
|
int TimeDiffmS = TimeDiff / nScale;
|
unsigned short NextEV = PLCMem.EV[nIndex] + TimeDiffmS;
|
PLCMem.Timers[nIndex].LastActTime += TimeDiffmS*nScale;
|
|
if (NextEV >= PLCMem.SV[nIndex])
|
{
|
NextEV = PLCMem.SV[nIndex];
|
PLCMem.Timers[nIndex].bTon =1;
|
}
|
PLCMem.EV[nIndex] = NextEV;
|
}
|
}
|
}else //bSet=0;
|
{
|
if(PLCMem.Timers[nIndex].bTon)
|
{
|
PLCMem.Timers[nIndex].bTon = 0;
|
}
|
}
|
SetCoilValue(KLCoilTypeT, nIndex, PLCMem.Timers[nIndex].bTon);
|
return PLCMem.Timers[nIndex].bTon;
|
}
|
|
int IsTimerOn(int nIndex)
|
{
|
if (nIndex >= TOTALTIMERS) return 0;
|
ProcessTimer(nIndex);
|
return PLCMem.Timers[nIndex].bTon;
|
|
}
|
|
int GetTimerSV(int nIndex)
|
{
|
if (nIndex >= TOTALTIMERS) return 0;
|
// ProcessTimer(nIndex);
|
return PLCMem.SV[nIndex];
|
// return 0;
|
}
|
int GetTimerEV(int nIndex)
|
{
|
if (nIndex >= TOTALTIMERS) return 0;
|
// ProcessTimer(nIndex);
|
return PLCMem.EV[nIndex];
|
// return 0;
|
}
|
|
int PushInVal(void)
|
{
|
for (int i=TOTAL_CurVAL -1 ;i>0;i--)
|
{
|
PLCMem.CurVALs[i]=PLCMem.CurVALs[i-1];
|
}
|
PLCMem.CurVALs[0]=PLCMem.CurVAL;
|
return PLCMem.CurVAL;
|
}
|
|
int PopOutVal(void)
|
{
|
unsigned char theVAL=PLCMem.CurVALs[0];
|
for (int i=0;i<TOTAL_CurVAL-1;i++)
|
{
|
PLCMem.CurVALs[i]=PLCMem.CurVALs[i+1];
|
}
|
return theVAL;
|
}
|
|
|
int InitPLC()
|
{
|
PLCMem.nScanCount=0;
|
for (int i=0;i<256;i++){PLCMem.ProgTrace[i]=0;}
|
for (int i=0;i<16;i++) {
|
KMem.WR[i]=0;
|
}
|
for (int i=0;i<256;i++) {
|
KMem.DT[i]=0;
|
}
|
return 0;
|
}
|
|
int StartPLC()
|
{
|
PLCMem.nScanCount = 0;
|
for (int i=0;i<256;i++){PLCMem.ProgTrace[i]=0;}
|
for (int i=0;i<16;i++) {
|
KMem.WR[i]=0;
|
}
|
for (int i=0;i<256;i++) {
|
KMem.DT[i]=0;
|
}
|
for (int i=0;i<TOTALTIMERS;i++){
|
PLCMem.Timers[i].nInited=0;
|
}
|
|
PLCMem.bPLCRunning=1;
|
KMRunStat.WorkMode2=PLCMem.bPLCRunning;
|
return 0;
|
}
|
|
int StopPLC()
|
{
|
PLCMem.bPLCRunning=0;
|
for (int i=0;i<KLDataWXCount;i++) KMem.WY[i]=0;
|
for (int i=0;i<KLDataWLCount;i++) KMem.WLY[i]=0;
|
KMRunStat.WorkMode2=PLCMem.bPLCRunning;
|
return 0;
|
}
|
|
inline void SetAddrBit(unsigned short * pW, unsigned char bitAddr)
|
{
|
(*pW)|=1<<(bitAddr&0xf);
|
}
|
|
inline void ResetBit(unsigned short * pW, unsigned char bitAddr)
|
{
|
(*pW)&=~(1<<(bitAddr&0xf));
|
}
|
static inline void SetBitValue(unsigned short * pW, unsigned char bitAddr, unsigned char Value)
|
{
|
if (Value) { SetAddrBit(pW, bitAddr);}
|
else {ResetBit(pW, bitAddr);}
|
}
|
|
static inline unsigned char GetBitValue(unsigned short W, unsigned char bitAddr)
|
{
|
if (W&(1<<(bitAddr&0xf))) return 1;
|
else return 0;
|
}
|
|
|
int ProcessPLCBinProg(const stBinInstrcn1 * pBinProg, int nProgSteps)
|
{
|
if (!PLCMem.bPLCRunning) return 0;
|
|
if (PLCMem.nScanCount == 0) {
|
SetCoilValue(KLCoilTypeSR, 0, 0);
|
SetCoilValue(KLCoilTypeSR, 1, 1);
|
SetCoilValue(KLCoilTypeSR, 10, 1);
|
SetCoilValue(KLCoilTypeSR, 11, 0);
|
SetCoilValue(KLCoilTypeSR, 13, 1);
|
}
|
else
|
{
|
SetCoilValue(KLCoilTypeSR, 0, 0);
|
SetCoilValue(KLCoilTypeSR, 1, 1);
|
SetCoilValue(KLCoilTypeSR, 10, 1);
|
SetCoilValue(KLCoilTypeSR, 11, 0);
|
SetCoilValue(KLCoilTypeSR, 13, 0);
|
}
|
for (int i = 0; i < TOTAL_CurVAL; i++) {
|
PLCMem.CurVALs[i] = 0;
|
}
|
int CurPos = 0;
|
// stBinInstrcn1 * pBinInstrcn1;
|
stBinInstrcn15 * pBinInstrcn15;
|
stBinInstrcn2 * pBinInstrcn2;
|
stBinInstrcn3 * pBinInstrcn3;
|
|
int lastScanInputVal = 1;//??????,????????,? ?? ???
|
|
const stBinInstrcn1 * pBinInstrcn = pBinProg;
|
|
while (CurPos < nProgSteps)
|
{
|
unsigned int nNextPos = 1;
|
unsigned int thisOP = pBinInstrcn[CurPos].nOp;
|
// unsigned int nParamCount = 0
|
unsigned char thisAddrType = pBinInstrcn[CurPos].nParamType;
|
unsigned short thisAddr = pBinInstrcn[CurPos].nParamAddr;
|
|
|
switch (thisOP)
|
{
|
// case OP_NONE:
|
// break;
|
case OP_NOP:
|
break;
|
//??? ??
|
case OP_END:
|
nNextPos = nProgSteps;
|
break;
|
case OP_NOT:
|
case OP_ANS:
|
case OP_ORS:
|
case OP_PSHS:
|
case OP_RDS:
|
case OP_POPS:
|
case OP_DF:
|
case OP_DF_:
|
switch (thisOP)
|
{
|
case OP_NOT:
|
PLCMem.CurVAL = !PLCMem.CurVAL;
|
break;
|
case OP_ANS:
|
PLCMem.CurVAL = PopOutVal() && PLCMem.CurVAL;
|
break;
|
case OP_ORS:
|
PLCMem.CurVAL = PopOutVal() || PLCMem.CurVAL;
|
break;
|
case OP_PSHS:
|
PushInVal();
|
break;
|
case OP_RDS:
|
PLCMem.CurVAL = PLCMem.CurVALs[0] != 0;
|
break;
|
case OP_POPS:
|
PLCMem.CurVAL = PopOutVal();
|
break;
|
case OP_DF:
|
PLCMem.CurVAL = PLCMem.CurVAL && !lastScanInputVal;
|
break;
|
case OP_DF_:
|
PLCMem.CurVAL = !PLCMem.CurVAL && lastScanInputVal;
|
break;
|
|
default:
|
break;
|
}
|
break;
|
// 1????
|
case OP_ST:
|
case OP_ST_:
|
case OP_AN:
|
case OP_AN_:
|
case OP_OR:
|
case OP_OR_:
|
switch (thisOP)
|
{
|
case OP_ST:
|
PushInVal();
|
PLCMem.CurVAL = GetCoilValue(thisAddrType, thisAddr);
|
break;
|
case OP_ST_:
|
PushInVal();
|
PLCMem.CurVAL = !GetCoilValue(thisAddrType, thisAddr);
|
break;
|
case OP_AN:
|
PLCMem.CurVAL = PLCMem.CurVAL&&GetCoilValue(thisAddrType, thisAddr);
|
break;
|
case OP_AN_:
|
PLCMem.CurVAL = PLCMem.CurVAL && (!GetCoilValue(thisAddrType, thisAddr));
|
break;
|
case OP_OR:
|
PLCMem.CurVAL = PLCMem.CurVAL || GetCoilValue(thisAddrType, thisAddr);
|
break;
|
case OP_OR_:
|
PLCMem.CurVAL = PLCMem.CurVAL || (!GetCoilValue(thisAddrType, thisAddr));
|
break;
|
default:
|
break;
|
}
|
break;
|
// 1 ?? ??
|
case OP_OUT:
|
case OP_SET:
|
case OP_RESET:
|
switch (thisOP)
|
{
|
case OP_OUT:
|
SetCoilValue(thisAddrType, thisAddr, PLCMem.CurVAL);
|
break;
|
case OP_SET:
|
if (PLCMem.CurVAL) SetCoilValue(thisAddrType, thisAddr, 1);
|
break;
|
case OP_RESET:
|
if (PLCMem.CurVAL) SetCoilValue(thisAddrType, thisAddr, 0);
|
break;
|
default:
|
break;
|
}
|
break;
|
// ????
|
case OP_ST_EQ:
|
case OP_ST_NE:
|
case OP_ST_LT:
|
case OP_ST_GT:
|
case OP_ST_LE:
|
case OP_ST_GE:
|
case OP_AN_EQ:
|
case OP_AN_NE:
|
case OP_AN_LT:
|
case OP_AN_GT:
|
case OP_AN_LE:
|
case OP_AN_GE:
|
case OP_OR_EQ:
|
case OP_OR_NE:
|
case OP_OR_LT:
|
case OP_OR_GT:
|
case OP_OR_LE:
|
case OP_OR_GE:
|
pBinInstrcn2 = (stBinInstrcn2 *)&pBinInstrcn[CurPos];
|
thisAddrType = pBinInstrcn2->nParamType1;
|
|
switch (thisOP)
|
{
|
case OP_ST_EQ:
|
PushInVal();
|
PLCMem.CurVAL = (GetVarData(thisAddrType, thisAddr) == GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_ST_NE:
|
PushInVal();
|
PLCMem.CurVAL = (GetVarData(thisAddrType, thisAddr) != GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_ST_LT:
|
PushInVal();
|
PLCMem.CurVAL = (GetVarData(thisAddrType, thisAddr) < GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_ST_GT:
|
PushInVal();
|
PLCMem.CurVAL = (GetVarData(thisAddrType, thisAddr) > GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_ST_LE:
|
PushInVal();
|
PLCMem.CurVAL = (GetVarData(thisAddrType, thisAddr) <= GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_ST_GE:
|
PushInVal();
|
PLCMem.CurVAL = (GetVarData(thisAddrType, thisAddr) >= GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_AN_EQ:
|
PLCMem.CurVAL = PLCMem.CurVAL && (GetVarData(thisAddrType, thisAddr) == GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_AN_NE:
|
PLCMem.CurVAL = PLCMem.CurVAL && (GetVarData(thisAddrType, thisAddr) != GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_AN_LT:
|
PLCMem.CurVAL = PLCMem.CurVAL && (GetVarData(thisAddrType, thisAddr) < GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_AN_GT:
|
PLCMem.CurVAL = PLCMem.CurVAL && (GetVarData(thisAddrType, thisAddr) > GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_AN_LE:
|
PLCMem.CurVAL = PLCMem.CurVAL && (GetVarData(thisAddrType, thisAddr) <= GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_AN_GE:
|
PLCMem.CurVAL = PLCMem.CurVAL && (GetVarData(thisAddrType, thisAddr) >= GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
|
case OP_OR_EQ:
|
PLCMem.CurVAL = PLCMem.CurVAL || (GetVarData(thisAddrType, thisAddr) == GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_OR_NE:
|
PLCMem.CurVAL = PLCMem.CurVAL || (GetVarData(thisAddrType, thisAddr) != GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_OR_LT:
|
PLCMem.CurVAL = PLCMem.CurVAL || (GetVarData(thisAddrType, thisAddr) < GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_OR_GT:
|
PLCMem.CurVAL = PLCMem.CurVAL || (GetVarData(thisAddrType, thisAddr) > GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_OR_LE:
|
PLCMem.CurVAL = PLCMem.CurVAL || (GetVarData(thisAddrType, thisAddr) <= GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
case OP_OR_GE:
|
PLCMem.CurVAL = PLCMem.CurVAL || (GetVarData(thisAddrType, thisAddr) >= GetVarData(pBinInstrcn2->nParamType2, pBinInstrcn2->nParamAddr2));
|
break;
|
|
default:
|
break;
|
}
|
nNextPos = 2;
|
break;
|
// ???
|
case OP_TML:
|
case OP_TMR:
|
case OP_TMX:
|
case OP_TMY:
|
pBinInstrcn15 = (stBinInstrcn15 *)(&pBinInstrcn[CurPos]);
|
{
|
unsigned char thisNum= pBinInstrcn15->nOpNum;
|
thisAddrType = pBinInstrcn15->nParamType1;
|
thisAddr = pBinInstrcn15->nParamAddr1;
|
switch (thisOP)
|
{
|
case OP_TML:
|
if (!PLCMem.Timers[thisNum].nInited) InitTimer(thisNum, 0);
|
if (PLCMem.CurVAL) RunTimer(thisNum, GetVarData(thisAddrType, thisAddr));
|
else StopTimer(thisNum);
|
PLCMem.CurVAL = ProcessTimer(thisNum);
|
|
break;
|
case OP_TMR:
|
if (!PLCMem.Timers[thisNum].nInited) InitTimer(thisNum, 1);
|
if (PLCMem.CurVAL) RunTimer(thisNum, GetVarData(thisAddrType, thisAddr));
|
else StopTimer(thisNum);
|
PLCMem.CurVAL = ProcessTimer(thisNum);
|
break;
|
case OP_TMX:
|
if (!PLCMem.Timers[thisNum].nInited) InitTimer(thisNum, 2);
|
if (PLCMem.CurVAL) RunTimer(thisNum, GetVarData(thisAddrType, thisAddr));
|
else StopTimer(thisNum);
|
PLCMem.CurVAL = ProcessTimer(thisNum);
|
|
break;
|
case OP_TMY:
|
if (!PLCMem.Timers[thisNum].nInited) InitTimer(thisNum, 3);
|
if (PLCMem.CurVAL) RunTimer(thisNum, GetVarData(thisAddrType, thisAddr));
|
else StopTimer(thisNum);
|
PLCMem.CurVAL = ProcessTimer(thisNum);
|
break;
|
default:
|
break;
|
}
|
|
}
|
nNextPos = 2;
|
break;
|
// 1 ??????
|
case OP_INC:
|
case OP_DEC:
|
pBinInstrcn15 = (stBinInstrcn15 *)(&pBinInstrcn[CurPos]);
|
thisAddrType = pBinInstrcn15->nParamType1;
|
thisAddr = pBinInstrcn15->nParamAddr1;
|
nNextPos = 2;
|
switch (thisOP)
|
{
|
case OP_INC:
|
if (PLCMem.CurVAL) SetVarData(thisAddrType, thisAddr, GetVarData(thisAddrType, thisAddr) + 1);
|
break;
|
case OP_DEC:
|
if (PLCMem.CurVAL) SetVarData(thisAddrType, thisAddr, GetVarData(thisAddrType, thisAddr) - 1);
|
break;
|
|
default:
|
break;
|
}
|
break;
|
// 2??????
|
case OP_MV:
|
case OP_ADD2:
|
case OP_SUB2:
|
pBinInstrcn2 = (stBinInstrcn2 *)(&pBinInstrcn[CurPos]);
|
{
|
int nParamType2, nParamAddr2;
|
thisAddrType = pBinInstrcn2->nParamType1;
|
thisAddr = pBinInstrcn2->nParamAddr1;
|
nParamType2 = pBinInstrcn2->nParamType2;
|
nParamAddr2 = pBinInstrcn2->nParamAddr2;
|
|
switch (thisOP)
|
{
|
case OP_MV:
|
if (PLCMem.CurVAL) SetVarData(nParamType2, nParamAddr2, GetVarData(thisAddrType, thisAddr));
|
break;
|
case OP_ADD2:
|
if (PLCMem.CurVAL) SetVarData(nParamType2, nParamAddr2, GetVarData(thisAddrType, thisAddr) + GetVarData(nParamType2, nParamAddr2));
|
break;
|
case OP_SUB2:
|
if (PLCMem.CurVAL) SetVarData(nParamType2, nParamAddr2, GetVarData(nParamType2, nParamAddr2) - GetVarData(thisAddrType, thisAddr));
|
break;
|
|
default:
|
break;
|
}
|
|
}
|
nNextPos = 2;
|
break;
|
// 3 ??????
|
case OP_ADD3:
|
case OP_SUB3:
|
case OP_MUL:
|
case OP_DIV:
|
pBinInstrcn3 = (stBinInstrcn3 *)(&pBinInstrcn[CurPos]);
|
int nParamType2, nParamAddr2;
|
int nParamType3, nParamAddr3;
|
thisAddrType = pBinInstrcn3->nParamType1;
|
thisAddr = pBinInstrcn3->nParamAddr1;
|
nParamType2 = pBinInstrcn3->nParamType2;
|
nParamAddr2 = pBinInstrcn3->nParamAddr2;
|
nParamType3 = pBinInstrcn3->nParamType3;
|
nParamAddr3 = pBinInstrcn3->nParamAddr3;
|
switch (thisOP)
|
{
|
case OP_ADD3:
|
if (PLCMem.CurVAL) SetVarData(nParamType3, nParamAddr3, GetVarData(thisAddrType, thisAddr) + GetVarData(nParamType2, nParamAddr2));
|
break;
|
case OP_SUB3:
|
if (PLCMem.CurVAL) SetVarData(nParamType3, nParamAddr3, GetVarData(thisAddrType, thisAddr) - GetVarData(nParamType2, nParamAddr2));
|
break;
|
case OP_MUL:
|
if (PLCMem.CurVAL) {
|
short multiplicand = GetVarData(thisAddrType, thisAddr);
|
short multiplier = GetVarData(nParamType2, nParamAddr2);
|
int product = multiplicand * multiplier;
|
SetVarData(nParamType3, nParamAddr3, product);
|
SetVarData(nParamType3, nParamAddr3 + 1, product >> 16);
|
}
|
break;
|
case OP_DIV:
|
if (PLCMem.CurVAL) {
|
short dividend = GetVarData(thisAddrType, thisAddr);
|
short divisor = GetVarData(nParamType2, nParamAddr2);
|
short quotient = dividend / divisor;
|
short remainder = dividend % divisor;
|
SetVarData(nParamType3, nParamAddr3, quotient);
|
SetVarData(nParamType3, nParamAddr3 + 1, remainder);
|
}
|
break;
|
|
default:
|
break;
|
}
|
nNextPos = 3;
|
break;
|
|
default:
|
break;
|
}
|
lastScanInputVal = GetBitValue( PLCMem.ProgTrace[CurPos>>4],CurPos&0xf); //GetBitValue(PLCMem.WDFs);
|
SetBitValue( &PLCMem.ProgTrace[CurPos>>4],CurPos&0xf, PLCMem.CurVAL);
|
|
// lastScanInputVal = PLCMem.ProgTrace[CurPos]; //GetBitValue(PLCMem.WDFs);
|
// PLCMem.ProgTrace[CurPos] = PLCMem.CurVAL;
|
CurPos += nNextPos;
|
}
|
PLCMem.nScanCount++;
|
return CurPos;
|
}
|
#endif // ENABLE_PLC
|