当前位置:首页 > 沁工-PLC梯形图转指令表的算法源代码
172. {}
173. OR():IOPOINT() 174. {
175. setcode(\); 176. }
177. void put_img(int x,int y,CDC *pDC); 178. void print(int x,int y,CDC *pDC); 179. };
180. class ORI :public IOPOINT 181. { 182. public:
183. ORI(int x,int y,int flg,CString cd=\,CString nm=\,CString ad=\) 184. :IOPOINT(x,y,flg,cd,nm,ad) 185. {}
186. ORI():IOPOINT() 187. {
188. setcode(\); 189. }
190. void put_img(int x,int y,CDC *pDC); 191. void print(int x,int y,CDC *pDC); 192. };
193. class HOR :public IOPOINT 194. { 195. public:
196. HOR(int x,int y,int flg,CString cd=\,CString nm=\,CString ad=\) 197. :IOPOINT(x,y,flg,cd,nm,ad) 198. {}
199. HOR():IOPOINT() 200. {}
201. int testaddr();
202. void print(int x,int y,CDC *pDC); 203. };
204. class ERECT :public IOPOINT 205. { 206. public:
207. ERECT(int x,int y,int flg,CString cd=\,CString nm=\,CString ad=\
\)
208. :IOPOINT(x,y,flg,cd,nm,ad) 209. {}
210. ERECT():IOPOINT() 211. {}
212. int testaddr() 213. {
214. return 0;
215. }
216. void print(int x,int y,CDC *pDC); 217. };
218. class OUTPOINT :public IOPOINT 219. { 220. public:
221. OUTPOINT(int x,int y,int flg,CString cd=\,CString nm=\,CString ad=
\)
222. :IOPOINT(x,y,flg,cd,nm,ad) 223. {}
224. OUTPOINT():IOPOINT() 225. {
226. setcode(\); 227. }
228. int testaddr() 229. {
230. return 0; 231. }
232. void put_img(int x,int y,CDC *pDC); 233. void print(int x,int y,CDC *pDC); 234. };
235. class ADDTION:public IOPOINT 236. { 237. public:
238. ADDTION(int x,int y,int flg,CString cd=\,CString nm=\,CString ad=\)
239. :IOPOINT(x,y,flg,cd,nm,ad) 240. {}
241. ADDTION():IOPOINT() 242. {}
243. int testaddr();
244. void put_img(int x,int y,CDC *pDC); 245. void print(int x,int y,CDC *pDC); 246. };
247. class LIST:public CObject 248. {
249. friend class PLC; 250. private:
251. IOPOINT *root; 252. public: 253. LIST() 254. {
255. root=0; 256. }
257. IOPOINT * ANBtest(IOPOINT *p);
258. IOPOINT * ANBcompile(IOPOINT *p,IOPOINT *endpoint); 259. IOPOINT * ORBtest(IOPOINT *p,IOPOINT *q); 260. IOPOINT * ORBcompile(IOPOINT *p); 261. int compile(IOPOINT *); 262. };
263. class PLC:public CObject 264. {
265. friend class CLADDoc; 266. private: 267. int Cols; 268. int Rows;
269. IOPOINT * point_array[m_nAreRow][m_nAreCol]; 270. LIST list_array[20]; 271. int step; 272. public:
273. IOPOINT * getpoint(int row,int col); 274. int getcols(); 275. int getrows();
276. void SetRowCol(int row,int col); 277. PLC();
278. void getstep();
279. int syntax(CString &m_strlist); 280. int testpoint(int row,int col); 281. void insert_point(IOPOINT *n); 282. void remove_point(int x,int y); 283. int compiled(CString &m_strlist); 284. void newfile(); 285. }; 286. #endif
IOPOINT.cpp
[cpp] view plain copy print?
1. //FILE:iopoint.CPP 2. #include \ 3. #include \ 4. //extern int CurrentCols; 5. extern FILE *fp; 6. extern int CurH;
7. extern int CurW;
8. extern CString filename; 9. IMPLEMENT_SERIAL(CIO,CObject,1) 10. CIO::CIO() 11. {
12. name=\; 13. addr=\; 14. code=\; 15. Rows=0; 16. Cols=0; 17. flag=0; 18. fiveflag=0; 19. xpoint=0; 20. ypoint=0; 21. } 22. /*
23. IOPOINT 判断无件地址是否有效 24. */
25. int IOPOINT::testaddr() 26. {
27. char ch;
28. if ((addr.GetLength()!=4)
29. || addr[2]>'7' || addr[3]>'7') 30. return 1; 31. else 32. {
33. ch=addr[0]; 34. switch (ch) 35. {
36. case 'X':
37. if (addr<\ || addr>\) 38. return 1; 39. else
40. break; 41. case 'Y':
42. if (addr<\ || addr>\) 43. return 1; 44. else 45. break; 46. case 'M':
47. if (addr<\ || addr>\) 48. return 1; 49. else 50. break;
共分享92篇相关文档