GlobalPara.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Configuration;
  7. using AGV_WPF.Models;
  8. using HslCommunication.Profinet.Siemens;
  9. using System.Data;
  10. using Newtonsoft.Json.Linq;
  11. using HslCommunication.LogNet;
  12. namespace AGV_WPF_Global
  13. {
  14. class GlobalPara
  15. {
  16. public static string ByteToHexString(byte[] buffer)
  17. {
  18. if (buffer != null)
  19. {
  20. StringBuilder builder = new StringBuilder(buffer.Length * 3);
  21. foreach (byte data in buffer)
  22. {
  23. builder.Append(Convert.ToString(data, 16).PadLeft(2, '0').PadRight(3, ' '));
  24. }
  25. if (builder != null)
  26. {
  27. return builder.ToString().ToUpper();
  28. }
  29. else return "";
  30. }
  31. return "";
  32. }
  33. public static void LoadData()
  34. {
  35. Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  36. //读卡检测开关
  37. if (!config.AppSettings.Settings.AllKeys.Contains(strOpenReadCheck))
  38. {
  39. config.AppSettings.Settings.Add(strOpenReadCheck, "False");
  40. GlobalPara.IsEnableReadCheck = false;
  41. }
  42. else
  43. {
  44. bool temp;
  45. if (bool.TryParse(config.AppSettings.Settings[strOpenReadCheck].Value, out temp))
  46. {
  47. GlobalPara.IsEnableReadCheck = temp;
  48. }
  49. else
  50. GlobalPara.IsEnableReadCheck = false;
  51. }
  52. if (!config.AppSettings.Settings.AllKeys.Contains(strStartParallel))
  53. {
  54. config.AppSettings.Settings.Add(strOpenReadCheck, "False");
  55. GlobalPara.IsEnablePallel = false;
  56. }
  57. else
  58. {
  59. bool temp;
  60. if (bool.TryParse(config.AppSettings.Settings[strStartParallel].Value, out temp))
  61. {
  62. GlobalPara.IsEnablePallel = temp;
  63. }
  64. else
  65. GlobalPara.IsEnablePallel = false;
  66. }
  67. /*启用路线显示*/
  68. if (!config.AppSettings.Settings.AllKeys.Contains(strRouteView))
  69. {
  70. config.AppSettings.Settings.Add(strOpenReadCheck, "False");
  71. GlobalPara.IsEnableRouteView = false;
  72. }
  73. else
  74. {
  75. bool temp;
  76. if (bool.TryParse(config.AppSettings.Settings[strRouteView].Value, out temp))
  77. {
  78. GlobalPara.IsEnableRouteView = temp;
  79. }
  80. else
  81. GlobalPara.IsEnableRouteView = false;
  82. }
  83. //漏读检测开关
  84. if (!config.AppSettings.Settings.AllKeys.Contains(strOpenMissReadCheck))
  85. {
  86. config.AppSettings.Settings.Add(strOpenMissReadCheck, "False");
  87. GlobalPara.IsEnableMissReadCheck = false;
  88. }
  89. else
  90. {
  91. bool temp;
  92. if (bool.TryParse(config.AppSettings.Settings[strOpenMissReadCheck].Value, out temp))
  93. {
  94. GlobalPara.IsEnableMissReadCheck = temp;
  95. }
  96. else
  97. GlobalPara.IsEnableMissReadCheck = false;
  98. }
  99. //多读检测开关
  100. if (!config.AppSettings.Settings.AllKeys.Contains(strOpenExtraReadCheck))
  101. {
  102. config.AppSettings.Settings.Add(strOpenExtraReadCheck, "False");
  103. GlobalPara.IsEnableExtraReadCheck = false;
  104. }
  105. else
  106. {
  107. bool temp;
  108. if (bool.TryParse(config.AppSettings.Settings[strOpenExtraReadCheck].Value, out temp))
  109. {
  110. GlobalPara.IsEnableExtraReadCheck = temp;
  111. }
  112. else
  113. GlobalPara.IsEnableExtraReadCheck = false;
  114. }
  115. //离线检测开关
  116. if (!config.AppSettings.Settings.AllKeys.Contains(strOpenOffLineCheck))
  117. {
  118. config.AppSettings.Settings.Add(strOpenOffLineCheck, "False");
  119. GlobalPara.IsEnableOffLineCheck = false;
  120. }
  121. else
  122. {
  123. bool temp;
  124. if (bool.TryParse(config.AppSettings.Settings[strOpenOffLineCheck].Value, out temp))
  125. {
  126. GlobalPara.IsEnableOffLineCheck = temp;
  127. }
  128. else
  129. GlobalPara.IsEnableOffLineCheck = false;
  130. }
  131. //连接恢复检测开关
  132. if (!config.AppSettings.Settings.AllKeys.Contains(strOpenRecoverCheck))
  133. {
  134. config.AppSettings.Settings.Add(strOpenRecoverCheck, "False");
  135. GlobalPara.IsEnableRecoverCheck = false;
  136. }
  137. else
  138. {
  139. bool temp;
  140. if (bool.TryParse(config.AppSettings.Settings[strOpenRecoverCheck].Value, out temp))
  141. {
  142. GlobalPara.IsEnableRecoverCheck = temp;
  143. }
  144. else
  145. GlobalPara.IsEnableRecoverCheck = false;
  146. }
  147. //通信方式
  148. if (!config.AppSettings.Settings.AllKeys.Contains(strCommType))
  149. {
  150. config.AppSettings.Settings.Add(strCommType, "1");
  151. GlobalPara.type = 1;
  152. }
  153. else
  154. {
  155. int temp;
  156. if (int.TryParse(config.AppSettings.Settings[strCommType].Value, out temp))
  157. {
  158. GlobalPara.type = temp;
  159. }
  160. else
  161. GlobalPara.type = 1;
  162. }
  163. //Wifi通信方式,主机IP
  164. if (!config.AppSettings.Settings.AllKeys.Contains(strHostIP))
  165. {
  166. config.AppSettings.Settings.Add(strHostIP, "127.0.0.1");
  167. GlobalPara.HostIP = "127.0.0.1";
  168. }
  169. else
  170. {
  171. string str = "127.0.0.1";
  172. if (Regex.IsMatch(config.AppSettings.Settings[strHostIP].Value, @"^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$"))
  173. {
  174. GlobalPara.HostIP = config.AppSettings.Settings[strHostIP].Value;
  175. }
  176. else
  177. {
  178. GlobalPara.HostIP = str;
  179. }
  180. }
  181. if (!config.AppSettings.Settings.AllKeys.Contains(strHostIPSPS))
  182. {
  183. config.AppSettings.Settings.Add(strHostIPSPS, "127.0.0.1");
  184. GlobalPara.strHostIPSPS = "127.0.0.1";
  185. }
  186. else
  187. {
  188. string str = "127.0.0.1";
  189. if (Regex.IsMatch(config.AppSettings.Settings[strHostIPSPS].Value, @"^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$"))
  190. {
  191. GlobalPara.HostIPSPS = config.AppSettings.Settings[strHostIPSPS].Value;
  192. }
  193. else
  194. {
  195. GlobalPara.HostIPSPS = str;
  196. }
  197. }
  198. if (!config.AppSettings.Settings.AllKeys.Contains(strMesURL))
  199. {
  200. config.AppSettings.Settings.Add(strMesURL, "http://10.140.4.15:9090/aisEsbApi/pmc/core/interf/PmcCoreHjReportStation");
  201. GlobalPara.MesURL = "http://10.140.4.15:9090/aisEsbApi/pmc/core/interf/PmcCoreHjReportStation";
  202. }
  203. else
  204. {
  205. {
  206. GlobalPara.MesURL = config.AppSettings.Settings[strMesURL].Value;
  207. }
  208. }
  209. if (!config.AppSettings.Settings.AllKeys.Contains(strSPSURL))
  210. {
  211. config.AppSettings.Settings.Add(strSPSURL, "http://10.140.35.21:10010/AGV/AGVLeave");
  212. GlobalPara.SPSURL = "http://10.140.35.21:10010/AGV/AGVLeave";
  213. }
  214. else
  215. {
  216. {
  217. GlobalPara.SPSURL = config.AppSettings.Settings[strSPSURL].Value;
  218. }
  219. }
  220. if (!config.AppSettings.Settings.AllKeys.Contains(strTrafficAreaRequestURL))
  221. {
  222. config.AppSettings.Settings.Add(strTrafficAreaRequestURL, "http://URLValue/AGVAPI?do=Requery&region=RegionValue");
  223. GlobalPara.TrafficAreaRequestURL = @"http://URLValue/AGVAPI?do=Requery&region=RegionValue";
  224. // GlobalPara.TrafficAreaRequestURL = "http://URLValue/AGVAPI";
  225. }
  226. else
  227. {
  228. {
  229. GlobalPara.TrafficAreaRequestURL = config.AppSettings.Settings[strTrafficAreaRequestURL].Value;
  230. }
  231. }
  232. if (!config.AppSettings.Settings.AllKeys.Contains(strTrafficAreaResponseURL))
  233. {
  234. config.AppSettings.Settings.Add(strTrafficAreaResponseURL, "http://URLValue/AGVAPI?do=SetAGVState&region=RegionValue&oper=OperValue");
  235. GlobalPara.TrafficAreaResponseURL = @"http://URLValue/AGVAPI?do=SetAGVState&region=RegionValue&oper=OperValue";
  236. //GlobalPara.TrafficAreaResponseURL = "http://URLValue/AGVAPI";
  237. }
  238. else
  239. {
  240. {
  241. GlobalPara.TrafficAreaResponseURL = config.AppSettings.Settings[strTrafficAreaResponseURL].Value;
  242. }
  243. }
  244. //WCF服务主机IP
  245. if (!config.AppSettings.Settings.AllKeys.Contains(strWcfServerIP))
  246. {
  247. config.AppSettings.Settings.Add(strWcfServerIP, "127.0.0.1");
  248. GlobalPara.WcfServerIP = "127.0.0.1";
  249. }
  250. else
  251. {
  252. string str = "127.0.0.1";
  253. if (Regex.IsMatch(config.AppSettings.Settings[strWcfServerIP].Value, @"^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$"))
  254. {
  255. GlobalPara.WcfServerIP = config.AppSettings.Settings[strWcfServerIP].Value;
  256. }
  257. else
  258. {
  259. GlobalPara.WcfServerIP = str;
  260. }
  261. }
  262. //Excel文件路径
  263. if (!config.AppSettings.Settings.AllKeys.Contains(strExcelFile))
  264. {
  265. config.AppSettings.Settings.Add(strExcelFile, @"数据.xls");
  266. GlobalPara.excelFile = @"数据.xls";
  267. }
  268. else
  269. {
  270. GlobalPara.excelFile = config.AppSettings.Settings[strExcelFile].Value;
  271. }
  272. //区域名称
  273. if (!config.AppSettings.Settings.AllKeys.Contains(strAreaName))
  274. {
  275. config.AppSettings.Settings.Add(strAreaName, @"区域1");
  276. GlobalPara.areaName = @"区域1";
  277. }
  278. else
  279. {
  280. GlobalPara.areaName = config.AppSettings.Settings[strAreaName].Value;
  281. }
  282. //掉线计数
  283. if (!config.AppSettings.Settings.AllKeys.Contains(strOffLineCount))
  284. {
  285. config.AppSettings.Settings.Add(strOffLineCount, "8");
  286. GlobalPara.OffLineCount = 0;
  287. }
  288. else
  289. {
  290. int temp;
  291. if (int.TryParse(config.AppSettings.Settings[strOffLineCount].Value, out temp))
  292. {
  293. GlobalPara.OffLineCount = temp;
  294. }
  295. else
  296. GlobalPara.OffLineCount = 8;
  297. }
  298. //是否异常截图
  299. if (!config.AppSettings.Settings.AllKeys.Contains(strSavePic))
  300. {
  301. config.AppSettings.Settings.Add(strSavePic, "False");
  302. GlobalPara.IsExceptionSavePic = false;
  303. }
  304. else
  305. {
  306. bool temp;
  307. if (bool.TryParse(config.AppSettings.Settings[strSavePic].Value, out temp))
  308. {
  309. GlobalPara.IsExceptionSavePic = temp;
  310. }
  311. else
  312. GlobalPara.IsExceptionSavePic = false;
  313. }
  314. //AGV图标宽
  315. if (!config.AppSettings.Settings.AllKeys.Contains(strAgvIconW))
  316. {
  317. config.AppSettings.Settings.Add(strAgvIconW, "24");
  318. GlobalPara.AgvIconW = 24;
  319. }
  320. else
  321. {
  322. int temp;
  323. if (int.TryParse(config.AppSettings.Settings[strAgvIconW].Value, out temp))
  324. {
  325. GlobalPara.AgvIconW = temp;
  326. }
  327. else
  328. GlobalPara.AgvIconW = 24;
  329. }
  330. //AGV图标高
  331. if (!config.AppSettings.Settings.AllKeys.Contains(strAgvIconH))
  332. {
  333. config.AppSettings.Settings.Add(strAgvIconH, "24");
  334. GlobalPara.AgvIconH = 24;
  335. }
  336. else
  337. {
  338. int temp;
  339. if (int.TryParse(config.AppSettings.Settings[strAgvIconH].Value, out temp))
  340. {
  341. GlobalPara.AgvIconH = temp;
  342. }
  343. else
  344. GlobalPara.AgvIconH = 24;
  345. }
  346. //通信周期
  347. if (!config.AppSettings.Settings.AllKeys.Contains(strComCycle))
  348. {
  349. config.AppSettings.Settings.Add(strComCycle, "550");
  350. GlobalPara.ComCycle = 550;
  351. }
  352. else
  353. {
  354. int temp;
  355. if (int.TryParse(config.AppSettings.Settings[strComCycle].Value, out temp))
  356. {
  357. GlobalPara.ComCycle = temp;
  358. }
  359. else
  360. GlobalPara.ComCycle = 550;
  361. }
  362. //通讯端口
  363. if (!config.AppSettings.Settings.AllKeys.Contains(strUDPPort))
  364. {
  365. config.AppSettings.Settings.Add(strUDPPort, "8899");
  366. GlobalPara.UdpComPort = 8899;
  367. }
  368. else
  369. {
  370. int temp;
  371. if (int.TryParse(config.AppSettings.Settings[strUDPPort].Value, out temp))
  372. {
  373. GlobalPara.UdpComPort = temp;
  374. }
  375. else
  376. GlobalPara.UdpComPort = 8899;
  377. }
  378. //通讯端口
  379. if (!config.AppSettings.Settings.AllKeys.Contains(strUDPPort))
  380. {
  381. config.AppSettings.Settings.Add(strUDPPort, "8899");
  382. GlobalPara.UdpComPort = 8899;
  383. }
  384. else
  385. {
  386. int temp;
  387. if (int.TryParse(config.AppSettings.Settings[strUDPPort].Value, out temp))
  388. {
  389. GlobalPara.UdpComPort = temp;
  390. }
  391. else
  392. GlobalPara.UdpComPort = 8899;
  393. }
  394. //通讯端口
  395. if (!config.AppSettings.Settings.AllKeys.Contains(strHostSPSPort))
  396. {
  397. config.AppSettings.Settings.Add(strHostSPSPort, "63300");
  398. GlobalPara.HostIPSPSPort = 63300;
  399. }
  400. else
  401. {
  402. int temp;
  403. if (int.TryParse(config.AppSettings.Settings[strHostSPSPort].Value, out temp))
  404. {
  405. GlobalPara.HostIPSPSPort = temp;
  406. }
  407. else
  408. GlobalPara.HostIPSPSPort = 63300;
  409. }
  410. //测试开关
  411. if (!config.AppSettings.Settings.AllKeys.Contains(strTryFlag))
  412. {
  413. config.AppSettings.Settings.Add(strTryFlag, "False");
  414. GlobalPara.TryFlag = false;
  415. }
  416. else
  417. {
  418. bool temp;
  419. if (bool.TryParse(config.AppSettings.Settings[strTryFlag].Value, out temp))
  420. {
  421. GlobalPara.TryFlag = temp;
  422. }
  423. else
  424. GlobalPara.TryFlag = false;
  425. }
  426. //测试用远程主机IP
  427. if (!config.AppSettings.Settings.AllKeys.Contains(strTryIP))
  428. {
  429. config.AppSettings.Settings.Add(strTryIP, "127.0.0.1");
  430. GlobalPara.TryIP = "127.0.0.1";
  431. }
  432. else
  433. {
  434. string str = "127.0.0.1";
  435. if (Regex.IsMatch(config.AppSettings.Settings[strTryIP].Value, @"^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$"))
  436. {
  437. GlobalPara.TryIP = config.AppSettings.Settings[strTryIP].Value;
  438. }
  439. else
  440. {
  441. GlobalPara.TryIP = str;
  442. }
  443. }
  444. //远程客户端使能
  445. if (!config.AppSettings.Settings.AllKeys.Contains(strEnableRemote))
  446. {
  447. config.AppSettings.Settings.Add(strEnableRemote, GlobalPara.IsEnableRemote.ToString());
  448. //GlobalPara.IsEnableRecoverCheck = false;
  449. }
  450. else
  451. {
  452. bool temp;
  453. if (bool.TryParse(config.AppSettings.Settings[strEnableRemote].Value, out temp))
  454. {
  455. GlobalPara.IsEnableRemote = temp;
  456. }
  457. else
  458. GlobalPara.IsEnableRemote = false;
  459. }
  460. //新版数据分享使能
  461. if (!config.AppSettings.Settings.AllKeys.Contains(strEnableDataShare))
  462. {
  463. config.AppSettings.Settings.Add(strEnableDataShare, GlobalPara.IsEnableDataShare.ToString());
  464. //GlobalPara.IsEnableRecoverCheck = false;
  465. }
  466. else
  467. {
  468. bool temp;
  469. if (bool.TryParse(config.AppSettings.Settings[strEnableDataShare].Value, out temp))
  470. {
  471. GlobalPara.IsEnableDataShare = temp;
  472. }
  473. else
  474. GlobalPara.IsEnableDataShare = false;
  475. }
  476. //使用新版协议还是旧版协议
  477. if (!config.AppSettings.Settings.AllKeys.Contains(strUseNewProtrol))
  478. {
  479. config.AppSettings.Settings.Add(strUseNewProtrol, GlobalPara.UseNewProtrol.ToString());
  480. //GlobalPara.IsEnableRecoverCheck = false;
  481. }
  482. else
  483. {
  484. bool temp;
  485. if (bool.TryParse(config.AppSettings.Settings[strUseNewProtrol].Value, out temp))
  486. {
  487. GlobalPara.UseNewProtrol = temp;
  488. }
  489. else
  490. GlobalPara.UseNewProtrol = false;
  491. }
  492. //Eol 停站判断时间
  493. if (!config.AppSettings.Settings.AllKeys.Contains(strEOLCheckSecs))
  494. {
  495. config.AppSettings.Settings.Add(strEOLCheckSecs, GlobalPara.EOLCheckSecs.ToString());
  496. //GlobalPara.IsEnableRecoverCheck = false;
  497. }
  498. else
  499. {
  500. int temp;
  501. if (int.TryParse(config.AppSettings.Settings[strEOLCheckSecs].Value, out temp))
  502. {
  503. GlobalPara.EOLCheckSecs = temp;
  504. }
  505. else
  506. GlobalPara.EOLCheckSecs = 5;
  507. }
  508. //远程调试使能
  509. if (!config.AppSettings.Settings.AllKeys.Contains(strDebugFlag))
  510. {
  511. config.AppSettings.Settings.Add(strDebugFlag, GlobalPara.DebugFlag.ToString());
  512. //GlobalPara.IsEnableRecoverCheck = false;
  513. }
  514. else
  515. {
  516. bool temp;
  517. if (bool.TryParse(config.AppSettings.Settings[strDebugFlag].Value, out temp))
  518. {
  519. GlobalPara.DebugFlag = temp;
  520. }
  521. else
  522. GlobalPara.DebugFlag = false;
  523. }
  524. //远程调试IP
  525. if (!config.AppSettings.Settings.AllKeys.Contains(strDebugIP))
  526. {
  527. config.AppSettings.Settings.Add(strDebugIP, "127.0.0.1");
  528. GlobalPara.DebugIP = "127.0.0.1";
  529. }
  530. else
  531. {
  532. string str = "127.0.0.1";
  533. if (Regex.IsMatch(config.AppSettings.Settings[strDebugIP].Value, @"^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$"))
  534. {
  535. GlobalPara.DebugIP = config.AppSettings.Settings[strDebugIP].Value;
  536. }
  537. else
  538. {
  539. GlobalPara.DebugIP = str;
  540. }
  541. }
  542. //数据处理类型
  543. if (!config.AppSettings.Settings.AllKeys.Contains(strDataHandleType))
  544. {
  545. config.AppSettings.Settings.Add(strDataHandleType, "0");
  546. GlobalPara.DataHandleType = 0;
  547. }
  548. else
  549. {
  550. int temp;
  551. if (int.TryParse(config.AppSettings.Settings[strDataHandleType].Value, out temp))
  552. {
  553. GlobalPara.DataHandleType = temp;
  554. }
  555. else
  556. GlobalPara.DataHandleType = 0;
  557. }
  558. //电池查询周期
  559. if (!config.AppSettings.Settings.AllKeys.Contains(strBatteryQueryTime))
  560. {
  561. config.AppSettings.Settings.Add(strBatteryQueryTime, "4000");
  562. GlobalPara.BatteryQueryTime = 4000;
  563. }
  564. else
  565. {
  566. int temp;
  567. if (int.TryParse(config.AppSettings.Settings[strBatteryQueryTime].Value, out temp))
  568. {
  569. GlobalPara.BatteryQueryTime = temp;
  570. }
  571. else
  572. GlobalPara.DataHandleType = 4000;
  573. }
  574. //Log文件存放目录
  575. if (!config.AppSettings.Settings.AllKeys.Contains(strLogDirectory))
  576. {
  577. config.AppSettings.Settings.Add(strLogDirectory, @"C:\Log");
  578. GlobalPara.LogDirectory = @"C:\Log";
  579. }
  580. else
  581. {
  582. GlobalPara.LogDirectory = config.AppSettings.Settings[strLogDirectory].Value;
  583. }
  584. if (!config.AppSettings.Settings.AllKeys.Contains(strIsNeedToReplyPLCImmediately))
  585. {
  586. config.AppSettings.Settings.Add(strIsNeedToReplyPLCImmediately, GlobalPara.IsNeedToReplyPLCImmediately.ToString());
  587. //GlobalPara.IsEnableRecoverCheck = false;
  588. }
  589. else
  590. {
  591. bool temp;
  592. if (bool.TryParse(config.AppSettings.Settings[strIsNeedToReplyPLCImmediately].Value, out temp))
  593. {
  594. GlobalPara.IsNeedToReplyPLCImmediately = temp;
  595. }
  596. else
  597. GlobalPara.IsNeedToReplyPLCImmediately = false;
  598. }
  599. //最后保存设置
  600. config.Save();
  601. }
  602. #region 配置项字符串
  603. public static string strControlCOMName = "ControlCOMName";
  604. public static string strOpenReadCheck = "OpenReadCheck";
  605. public static string strOpenMissReadCheck = "OpenMissReadCheck";
  606. public static string strOpenExtraReadCheck = "OpenExtraReadCheck";
  607. public static string strOpenOffLineCheck = "OpenOffLineCheck";
  608. public static string strOpenRecoverCheck = "OpenRecoverCheck";
  609. public static string strCommType = "CommType";
  610. public static string strHostIP = "HostIP";
  611. public static string strHostIPSPS = "HostIPSPS";
  612. public static string strMesURL = "MesURL";
  613. public static string strSPSURL = "SPSURL";
  614. public static string strTrafficAreaRequestURL = "TrafficAreaRequestURL";
  615. public static string strTrafficAreaResponseURL = "TrafficAreaResponseURL";
  616. public static string strWcfServerIP = "WcfServerIP";
  617. public static string strExcelFile = "ExcelFile";
  618. public static string strAreaName = "AREANAME";
  619. public static string strOffLineCount = "OFFLINECOUNT";
  620. public static string strSavePic = "SAVEPIC";
  621. public static string strAgvIconW = "AGVICONW";
  622. public static string strAgvIconH = "AGVICONH";
  623. public static string strComCycle = "ComCycle";
  624. public static string strUDPPort = "UDPPort";
  625. public static string strHostSPSPort = "HostSPSPort";
  626. public static string strTryFlag = "TryFlag";
  627. public static string strTryIP = "TryIP";
  628. public static string strEnableRemote = "EnableRemote";
  629. public static string strDebugFlag = "DebugFlag";
  630. public static string strDebugIP = "DebugIP";
  631. public static string strDataHandleType = "HandleType";
  632. public static string strLogDirectory = "LogDir";
  633. public static string strBatteryQueryTime = "BatteryQueryTime";
  634. public static string strStartParallel = "StartParallel";//是否启用平行标志
  635. public static string strRouteView = "RouteView";//以路线的形式显示。
  636. public static string strEnableDataShare = "EnableDataShare";//TCP共享数据
  637. public static string strUseNewProtrol = "UseNewProtrol";
  638. public static string strEOLCheckSecs = "EOLCheckSecs";
  639. public static string strIsNeedToReplyPLCImmediately = "IsNeedToReplyPLCImmediately";
  640. #endregion
  641. #region 共享变量,不保存配置
  642. public static string strName;
  643. public static string userid;
  644. public static bool IsManager = true;
  645. public static string linkDirectory = "Link";
  646. public static string readCheckRecordName = "漏读记录";
  647. public static int LocalTcpPort = 9999;//远程访问本地TCP端口
  648. public static int LocalTcpPort1 = 8059;//远程访问本地TCP端口
  649. public static int RetransportUdpPort = 10000;//转发用UDP端口
  650. public static Services.CommunicationBase communication;
  651. public static DataTable DtWirelessBox = new DataTable();
  652. public static LogNetDateTime logNetDateTimeTrans; //透传结果记录
  653. public static AGV_WPF.WirelessDockingSystem wirelessDockingSystem;
  654. public static List<JObject> ListBoxData = new List<JObject>();
  655. #endregion
  656. #region 共享变量,保存配置
  657. public static string Gcontrolcomname = "COM1";
  658. public static List<string> ComNameList = new List<string>();
  659. public static string excelFile = @"数据.xls";
  660. public static int type = 0;
  661. public static bool IsExceptionSavePic = false;
  662. public static string areaName = "区域1";
  663. public static int OffLineCount = 8;
  664. public static int AgvIconW = 24;
  665. public static int AgvIconH = 24;
  666. public static bool IsEnableReadCheck = false;//读卡检测功能开关
  667. public static bool IsEnableExtraReadCheck = false;//多读卡检测功能开关
  668. public static bool IsEnableMissReadCheck = false;//漏读卡检测功能开关
  669. public static bool IsEnableOffLineCheck = false;//离线检测功能开关
  670. public static bool IsEnableRecoverCheck = false;//连接恢复检测功能开关
  671. public static bool IsEnablePallel = false;//启用平行路线管制
  672. public static bool IsEnableRouteView = false;//启用路线的形式显示
  673. public static string HostIP;
  674. public static string HostIPSPS;
  675. public static string WcfServerIP;
  676. public static int ComCycle = 550;//通信周期
  677. public static bool TryFlag = false;
  678. public static string TryIP = "127.0.0.1";
  679. public static bool DebugFlag = false;//可以作废,胡文辉20170405
  680. public static string DebugIP = "127.0.0.1";//可以作废,胡文辉20170405
  681. public static bool IsEnableRemote = false;
  682. public static int DataHandleType = 0;//数据处理方式,0为事件中解析数据,1单独线程处理
  683. public static string LogDirectory = @"C:\Log";//日志文件存放位置
  684. public static int BatteryQueryTime = 4000;//电池信息查询周期
  685. public static bool IsEnableDataShare = false;//是否开启远程数据共享
  686. public static bool UseNewProtrol = false;
  687. public static int EOLCheckSecs = 5;
  688. public static List<byte[]> dispatchList = new List<byte[]>();
  689. public static SiemensS7Net s701;
  690. public static List<string> BoxMarkLists;
  691. public static Dictionary<string, bool> EmStopMark = new Dictionary<string, bool>();
  692. public static DataTable dtSKQPLCs;
  693. public static SiemensS7Net s702;
  694. public static List<string> ReleaseMarkList = new List<string>();
  695. public static bool Gloal1063Flag;
  696. public static int UdpComPort = 8899;//网络方式通信,本地UDP端口
  697. public static int HostIPSPSPort = 63300;
  698. public static AGV_WPF.Tools.CConfigData gs_configInfo = new AGV_WPF.Tools.CConfigData();
  699. public static List<byte[]> SendBytesList = new List<byte[]>();
  700. public static bool IsNeedToReplyPLCImmediately = false;
  701. public static string MesURL = "http://10.140.4.15:9090/aisEsbApi/pmc/core/interf/PmcCoreHjReportStation";
  702. public static string SPSURL = "http://10.140.35.21:10010/AGV/AGVLeave";
  703. public static string TrafficAreaRequestURL = @"http://URLValue/AGVAPI?do=Requery&region=RegionValue";
  704. public static string TrafficAreaResponseURL = @"http://URLValue/AGVAPI?do=SetAGVState&region=RegionValue&oper=OperValue";
  705. public enum DBControlValues:int
  706. {
  707. NoAction=0,
  708. OKRelease=1,
  709. NGRelease=2,
  710. StopImmediate=3,
  711. StopRelease=4
  712. }
  713. public enum DBRunValues
  714. {
  715. Unknow = 0,
  716. Running = 1,
  717. Pause = 2,
  718. StopOnStation = 3,
  719. EmergencyStop=4
  720. }
  721. #endregion
  722. #region 自己添加的键值对,用于缓存数据
  723. public static Dictionary<int, AGVInfoModel> AgvInfoDic = new Dictionary<int, AGVInfoModel>();//建立10M的缓存区存放AGV动态信息
  724. public static Dictionary<string, SiemensS7Net> PLCTestDic = new Dictionary<string, SiemensS7Net>();//建立10M的缓存区存放AGV动态信息
  725. public static Dictionary<int, TrafficAreaModel> TrafficBuffer = new Dictionary<int, TrafficAreaModel>();//该缓存区用于存放AGV管制区信息
  726. public static Dictionary<int, int> TrafficMarkBuffer = new Dictionary<int, int>();//存放现有管制区的地标卡号对应表信息
  727. public static Dictionary<int, byte[]> dicAGVBytes = new Dictionary<int, byte[]>();
  728. public static bool IsRealOpenSystem = false;
  729. public static Dictionary<int, AGVInfoModel> dicTraffic = new Dictionary<int, AGVInfoModel>();//启动系统前管制就位情况
  730. public static Dictionary<int, decimal> dicAGVPower = new Dictionary<int, decimal>();
  731. public static bool IsOneKeySleep = false;//是否已休眠 休眠状态下不分配
  732. public static List<int> SleepAGVNumList = new List<int>(); //一键休眠中的agv
  733. public static List<int> WakeUpAGVNumList = new List<int>(); //一键唤醒中的agv
  734. public static int SingleSWAGVNum = -1; //单台休眠/唤醒的agv
  735. public static bool isSingleControl = false; //单台或批量操作
  736. public static List<string> lastReadMarkList = new List<string>();//AGV最后读卡记录
  737. public static Dictionary<DataRow, SiemensS7Net> plcs = new Dictionary<DataRow, SiemensS7Net>();
  738. public static List<AGVInfoModel> ListReleaseObj = new List<AGVInfoModel>();
  739. #endregion
  740. #region CRC 字节值表
  741. public static byte[] auchCRCHi = {
  742. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
  743. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
  744. 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
  745. 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
  746. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
  747. 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
  748. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
  749. 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
  750. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
  751. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
  752. 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
  753. 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
  754. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
  755. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
  756. 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
  757. 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
  758. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
  759. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
  760. 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
  761. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
  762. 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
  763. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
  764. 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
  765. 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
  766. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
  767. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40
  768. };
  769. /* CRC低位字节值表*/
  770. public static byte[] auchCRCLo = {
  771. 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06,
  772. 0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD,
  773. 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09,
  774. 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A,
  775. 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4,
  776. 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,
  777. 0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3,
  778. 0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4,
  779. 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A,
  780. 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29,
  781. 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED,
  782. 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,
  783. 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60,
  784. 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67,
  785. 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F,
  786. 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68,
  787. 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E,
  788. 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,
  789. 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71,
  790. 0x70, 0xB0, 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92,
  791. 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C,
  792. 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B,
  793. 0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B,
  794. 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,
  795. 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42,
  796. 0x43, 0x83, 0x41, 0x81, 0x80, 0x40
  797. };
  798. #endregion
  799. }
  800. }