提交 | 用户 | age
|
483170
|
1 |
/** |
Q |
2 |
****************************************************************************** |
|
3 |
* @file : PLCfunctions.h |
|
4 |
* @brief : Header for PLCfunctions.c file. |
|
5 |
* This file contains the user functions defines of the application. |
|
6 |
****************************************************************************** |
|
7 |
*/ |
|
8 |
#ifndef __PLCFUNCTIONS_H__ |
|
9 |
#define __PLCFUNCTIONS_H__ |
|
10 |
#include "GlobalDef.h" |
|
11 |
#include "KMachine.h" |
|
12 |
|
|
13 |
#define TICK_OF_MS (10) //1ms |
|
14 |
#define TICK_OF_RS (100) //10mS |
|
15 |
#define TICK_OF_XS (1000) //100mS |
|
16 |
#define TICK_OF_YS (10000) //1S |
|
17 |
|
|
18 |
#pragma anon_unions |
|
19 |
|
|
20 |
typedef struct tagPLCMem |
|
21 |
{ |
|
22 |
int bPLCRunning; |
|
23 |
int nScanCount; |
|
24 |
unsigned short ProgTrace[256]; |
|
25 |
|
|
26 |
}stPLCMem; |
|
27 |
extern stPLCMem PLCMem; |
|
28 |
|
|
29 |
int InitPLC(void); |
|
30 |
int StartPLC(void); |
|
31 |
int StopPLC(void); |
|
32 |
|
|
33 |
enum enPLCOPs |
|
34 |
{ |
|
35 |
OP_NONE = 0, |
|
36 |
OP_NOP = 0, |
|
37 |
OP_ST = 1, // |
|
38 |
OP_ST_ = 2, // |
|
39 |
OP_AN = 3, // |
|
40 |
OP_AN_ = 4, // |
|
41 |
OP_OR = 5, // |
|
42 |
OP_OR_ = 6, // |
|
43 |
OP_NOT = 7, // |
|
44 |
OP_ANS = 8, // |
|
45 |
OP_ORS = 9, // |
|
46 |
|
|
47 |
OP_PSHS = 10, // |
|
48 |
OP_RDS = 11, // |
|
49 |
OP_POPS = 12, // |
|
50 |
|
|
51 |
OP_OUT = 16, // |
|
52 |
OP_SET = 17, // |
|
53 |
OP_RESET = 18, // |
|
54 |
OP_DF = 19, // |
|
55 |
OP_DF_ = 20, // |
|
56 |
|
|
57 |
OP_ST_EQ, // |
|
58 |
OP_ST_LT, // |
|
59 |
OP_ST_GT, // |
|
60 |
OP_ST_LE, // |
|
61 |
OP_ST_GE, // |
|
62 |
OP_ST_NE, // |
|
63 |
OP_AN_EQ, // |
|
64 |
OP_AN_LT, // |
|
65 |
OP_AN_GT, |
|
66 |
OP_AN_LE, |
|
67 |
OP_AN_GE, |
|
68 |
OP_AN_NE, |
|
69 |
OP_OR_EQ, |
|
70 |
OP_OR_LT, |
|
71 |
OP_OR_GT, |
|
72 |
OP_OR_LE, |
|
73 |
OP_OR_GE, |
|
74 |
OP_OR_NE, |
|
75 |
|
|
76 |
|
|
77 |
OP_MV = 51, |
|
78 |
OP_INC = 52, |
|
79 |
OP_ADD2 = 53, |
|
80 |
OP_ADD3 = 54, |
|
81 |
OP_DEC = 55, |
|
82 |
OP_SUB2 = 56, |
|
83 |
OP_SUB3 = 57, |
|
84 |
OP_MUL = 58, |
|
85 |
OP_DIV = 59, |
|
86 |
OP_BKMV = 60, |
|
87 |
OP_COPY = 61, |
|
88 |
OP_CLR = 62, |
|
89 |
|
|
90 |
OP_BRK, |
|
91 |
OP_PAUSE, |
|
92 |
OP_JP, |
|
93 |
OP_CALL, |
|
94 |
|
|
95 |
OP_TML = 0xC8, // |
|
96 |
OP_TMR = 0xDC, // |
|
97 |
OP_TMX = 0xDD, // |
|
98 |
OP_TMY = 0xFA, // |
|
99 |
|
|
100 |
}; |
|
101 |
/* |
|
102 |
typedef struct tagPLCPROG |
|
103 |
{ |
|
104 |
unsigned char OP; |
|
105 |
unsigned char AddrType; |
|
106 |
unsigned short Addr; |
|
107 |
}stPLCPROG; |
|
108 |
*/ |
|
109 |
typedef struct stBinProg1 |
|
110 |
{ |
|
111 |
unsigned char nOp; |
|
112 |
unsigned char nParamType; |
|
113 |
unsigned short nParamAddr; |
|
114 |
}stBinProg1; |
|
115 |
typedef struct stBinProg15 |
|
116 |
{ //??? |
|
117 |
// |
|
118 |
unsigned char nOp; |
|
119 |
unsigned char nOpNum; |
|
120 |
unsigned short nParamAddr1; |
|
121 |
unsigned char nParamType1; |
|
122 |
unsigned char resvr1; |
|
123 |
unsigned short resvr2; |
|
124 |
}stBinProg15; |
|
125 |
typedef struct stBinProg2 |
|
126 |
{ //???? |
|
127 |
// |
|
128 |
unsigned char nOp; |
|
129 |
unsigned char nOpNum; |
|
130 |
unsigned short nParamAddr1; |
|
131 |
unsigned char nParamType1; |
|
132 |
unsigned char nParamType2; |
|
133 |
unsigned short nParamAddr2; |
|
134 |
}stBinProg2; |
|
135 |
typedef struct stBinProg3 |
|
136 |
{ //??????? |
|
137 |
unsigned char nOp; |
|
138 |
unsigned char nOpNum; |
|
139 |
unsigned short nParamAddr1; |
|
140 |
unsigned char nParamType1; |
|
141 |
unsigned char nParamType2; |
|
142 |
unsigned short nParamAddr2; |
|
143 |
unsigned char resvr1; |
|
144 |
unsigned char nParamType3; |
|
145 |
unsigned short nParamAddr3; |
|
146 |
}stBinProg3; |
|
147 |
|
|
148 |
|
|
149 |
extern stBinProg1 const prog1[]; |
|
150 |
extern int nSizeProg1; |
|
151 |
|
|
152 |
//extern unsigned char CurVAL; |
|
153 |
//extern unsigned char CurVALs[TOTAL_CurVAL]; |
|
154 |
//extern unsigned short DFs[TOTAL_WDFS]; |
|
155 |
|
|
156 |
//extern unsigned short WX[13]; |
|
157 |
//extern unsigned short WY[13]; |
|
158 |
//extern unsigned short WR[64]; |
|
159 |
//extern unsigned short DT[256]; |
|
160 |
//extern unsigned short SDT[256]; |
|
161 |
//extern const unsigned short bitMasks[16]; |
|
162 |
//extern stTimer Timers[TOTALTIMERS]; |
|
163 |
|
|
164 |
///* |
|
165 |
|
|
166 |
|
|
167 |
//*/ |
|
168 |
|
|
169 |
int InitTimer(int nIndex, int nType); |
|
170 |
int RunTimer(int nIndex , int SV); |
|
171 |
int StopTimer(int nIndex); |
|
172 |
int ResetTimer(int nIndex); |
|
173 |
int SetTimerValue(int nIndex, int bSet, int SV); |
|
174 |
int ProcessTimer(int nIndex); |
|
175 |
int IsTimerOn(int nIndex); |
|
176 |
int GetTimerSV(int nIndex); |
|
177 |
int GetTimerEV(int nIndex); |
|
178 |
|
|
179 |
int PushInVal(void); |
|
180 |
int PopOutVal(void); |
|
181 |
|
|
182 |
int ProcessPLCBinProg(const stBinProg1 * pBinprog, int nSize); |
|
183 |
//int ProcessPLCPROG(const stBinProg1 * prog,int nSize); |
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
#endif /* __PLCFUNCTIONS_H__ */ |