WCS_PLC.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. using SqlSugar;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading;
  7. using WCS.Data;
  8. using WCS.Data.Models;
  9. using WCS.Data.Utils;
  10. using WCS.PLC.Model.Equipment;
  11. namespace WCS.PLC
  12. {
  13. public class WCS_PLC
  14. {
  15. #region 变量
  16. private int _readSignals = 0;
  17. #endregion;
  18. #region 属性
  19. [SugarColumn(IsPrimaryKey = true)]
  20. public string PLC_NAME { get; set; }
  21. public string PLC_IP { get; set; }
  22. public string PLC_EQUIPMENTTYPE { get; set; }
  23. public bool PLC_ISENABLE { get; set; }
  24. public bool PLC_CONNECTSTATUS { get; set; }
  25. public int PLC_PORT { get; set; }
  26. public int PLC_SLOT { get; set; }
  27. public int PLC_RACK { get; set; }
  28. /// <summary>
  29. /// WCS系统
  30. /// </summary>
  31. public string PLC_WCSSYSTEM { get; set; }
  32. /// <summary>
  33. /// plc实例数量
  34. /// </summary>
  35. public int PLC_INSTANCECOUNT { get; set; }
  36. public string PLC_NOTES { get; set; }
  37. /// <summary>
  38. /// 未完成任务
  39. /// </summary>
  40. public int? PLC_UNEXECUTETASK { get; set; }
  41. /// <summary>
  42. /// 最后完成时间
  43. /// </summary>
  44. public DateTime? PLC_LASTFINISHTIME { get; set; }
  45. [SugarColumn(IsIgnore = true)]
  46. public PLC Plc
  47. {
  48. get
  49. {
  50. return PlcInstanceSet.FirstOrDefault();
  51. }
  52. }
  53. /// <summary>
  54. /// PLC实例列表
  55. /// </summary>
  56. public List<PLC> PlcInstanceSet = new List<PLC>();
  57. [SugarColumn(IsIgnore = true)]
  58. public PLC Plc2 { get; set; }
  59. //PLC是否连接成功
  60. [SugarColumn(IsIgnore = true)]
  61. public bool IsConnSuccess { get; set; }
  62. //DB集合
  63. public List<WCS_DBDEFINITION> WCS_DBSet = new List<WCS_DBDEFINITION>();
  64. //扫描的条码集合
  65. [SugarColumn(IsIgnore = true)]
  66. public List<WCS_SCANN> WCS_ScannSet { get; set; }
  67. //设备信号集合
  68. [SugarColumn(IsIgnore = true)]
  69. public List<WCS_EQUIPMENTINFO> WCS_EquipmentInfoSet { get; set; }
  70. //DB名称
  71. [SugarColumn(IsIgnore = true)]
  72. public int WriteDBName
  73. {
  74. get
  75. {
  76. return WCS_DBSet.FirstOrDefault(v => v.DB_TypeCh == DB_TypeEnum.WCS可读可写DB).DB_NAME;
  77. }
  78. }
  79. [SugarColumn(IsIgnore = true)]
  80. public Base_EquPlc EquPlc { get; set; }
  81. #endregion;
  82. #region 函数
  83. public void Init()
  84. {
  85. //foreach (var item in WCS_DBSet)
  86. //{
  87. // item.DB_EQUDATA = new byte[item.DB_TOLLENGTH];
  88. //}
  89. }
  90. /// <summary>
  91. /// 读取PLC信号
  92. /// </summary>
  93. public void ExecuteWcs_Workflow()
  94. {
  95. if (Interlocked.Exchange(ref _readSignals, 1) == 0)
  96. {
  97. try
  98. {
  99. //连接PLC
  100. //ThreadHelper.TaskThread(ConnectPLC);
  101. ConnectPLCS();
  102. //更新plc连接状态
  103. UpdatePLCConnStatus();
  104. if (IsConnSuccess == false) return;
  105. //Log4netHelper.Logger_Info.InfoFormat(string.Format("开始:PLC[{0}]读取信号到数据库。",PLC_NAME));
  106. //读取Plc到缓存
  107. ReadPlcToCache();
  108. //Log4netHelper.Logger_Info.InfoFormat(string.Format("结束:PLC[{0}]读取信号到数据库。", PLC_NAME));
  109. //读取扫码缓存数据到实体
  110. ReadScannBarCodeCacheToEntity();
  111. //读取PLC信号到数据库
  112. ThreadHelper.TaskThread(ReadPlcInfoToDataBase);
  113. if (EquPlc != null) EquPlc.Run();
  114. }
  115. catch (Exception ex)
  116. {
  117. LogMessageHelper.RecordLogMessage(ex);
  118. //Log4netHelper.Logger_Error.ErrorFormat(ex.ToString());
  119. }
  120. finally
  121. {
  122. Interlocked.Exchange(ref _readSignals, 0);
  123. }
  124. }
  125. }
  126. private void StopPlcAction()
  127. {
  128. IsConnSuccess = false;
  129. }
  130. /// <summary>
  131. /// 连接电控设备
  132. /// </summary>
  133. //private void ConnectPLC()
  134. //{
  135. // try
  136. // {
  137. // if (Plc == null || Plc._splc.Connected == false || IsConnSuccess == false)
  138. // {
  139. // if (Plc != null)
  140. // {
  141. // Plc.PlcStop();
  142. // Plc = null;
  143. // }
  144. // IsConnSuccess = false;
  145. // Plc = new PLC();
  146. // if (Plc.Connect(PLC_IP, PLC_RACK, PLC_SLOT, PLC_NAME))
  147. // {
  148. // Plc.RegisterStopPlcEvent(StopPlcAction);
  149. // Log4netHelper.Logger_Info.InfoFormat(string.Format("连接PLC_IP:[{0}]成功!", PLC_IP));
  150. // IsConnSuccess = true;
  151. // }
  152. // else
  153. // {
  154. // LogMessageHelper.RecordLogMessage(string.Format("连接PLC_IP:[{0}]失败!", PLC_IP));
  155. // //Log4netHelper.Logger_Error.ErrorFormat();
  156. // if (Plc != null)
  157. // {
  158. // Plc.PlcStop();
  159. // Plc = null;
  160. // }
  161. // Thread.Sleep(300);
  162. // }
  163. // }
  164. // else
  165. // {
  166. // IsConnSuccess = true;
  167. // }
  168. // }
  169. // catch (Exception ex)
  170. // {
  171. // IsConnSuccess = false;
  172. // Log4netHelper.Logger_Error.ErrorFormat(ex.ToString());
  173. // }
  174. //}
  175. private void ConnectPLCS()
  176. {
  177. for (int i = 0; i < PlcInstanceSet.Count; i++)
  178. {
  179. var plcitem = PlcInstanceSet[i];
  180. PlcInstanceSet[i] = ConnectPLC(plcitem, i);
  181. }
  182. }
  183. /// <summary>
  184. /// 连接电控设备
  185. /// </summary>
  186. private PLC ConnectPLC(PLC plcitem,int index)
  187. {
  188. try
  189. {
  190. if (plcitem == null || plcitem._splc.Connected == false || IsConnSuccess == false)
  191. {
  192. if (plcitem != null)
  193. {
  194. plcitem.PlcStop();
  195. plcitem = null;
  196. }
  197. IsConnSuccess = false;
  198. plcitem = new PLC();
  199. if (plcitem.Connect(PLC_IP, PLC_RACK, PLC_SLOT, PLC_NAME))
  200. {
  201. plcitem.RegisterStopPlcEvent(StopPlcAction);
  202. Log4netHelper.Logger_Info.InfoFormat(string.Format("连接PLC_IP:[{0}]实例[{1}]成功!", PLC_IP, index));
  203. IsConnSuccess = true;
  204. }
  205. else
  206. {
  207. LogMessageHelper.RecordLogMessage(string.Format("连接PLC_IP:[{0}]实例[{1}]失败!", PLC_IP, index));
  208. //Log4netHelper.Logger_Error.ErrorFormat();
  209. if (plcitem != null)
  210. {
  211. plcitem.PlcStop();
  212. plcitem = null;
  213. }
  214. Thread.Sleep(300);
  215. }
  216. }
  217. else
  218. {
  219. IsConnSuccess = true;
  220. }
  221. }
  222. catch (Exception ex)
  223. {
  224. IsConnSuccess = false;
  225. Log4netHelper.Logger_Error.ErrorFormat(ex.ToString());
  226. }
  227. return plcitem;
  228. }
  229. /// <summary>
  230. /// 连接电控设备
  231. /// </summary>
  232. private void ConnectPLC2()
  233. {
  234. try
  235. {
  236. if (PLC_NAME != "conveyor02") return;
  237. if (Plc2 == null || Plc2._splc.Connected == false || IsConnSuccess == false)
  238. {
  239. if (Plc2 != null)
  240. {
  241. Plc2.PlcStop();
  242. Plc2 = null;
  243. }
  244. IsConnSuccess = false;
  245. Plc2 = new PLC();
  246. if (Plc2.Connect(PLC_IP, PLC_RACK, PLC_SLOT, PLC_NAME))
  247. {
  248. Plc2.RegisterStopPlcEvent(StopPlcAction);
  249. Log4netHelper.Logger_Info.InfoFormat(string.Format("连接PLC2_IP:[{0}]成功!", PLC_IP));
  250. IsConnSuccess = true;
  251. }
  252. else
  253. {
  254. Log4netHelper.Logger_Error.ErrorFormat(string.Format("连接PLC2_IP:[{0}]失败!", PLC_IP));
  255. if (Plc2 != null)
  256. {
  257. Plc2.PlcStop();
  258. Plc2 = null;
  259. }
  260. Thread.Sleep(300);
  261. }
  262. }
  263. else
  264. {
  265. IsConnSuccess = true;
  266. }
  267. }
  268. catch (Exception ex)
  269. {
  270. IsConnSuccess = false;
  271. Log4netHelper.Logger_Error.ErrorFormat(ex.ToString());
  272. }
  273. }
  274. private void UpdatePLCConnStatus()
  275. {
  276. if (PLC_CONNECTSTATUS != IsConnSuccess)
  277. {
  278. PLC_CONNECTSTATUS = IsConnSuccess;
  279. SugarBase.DB.Updateable<WCS_PLC>(it => new WCS_PLC() { PLC_CONNECTSTATUS = IsConnSuccess }).Where(it => it.PLC_NAME == PLC_NAME).ExecuteCommand();
  280. }
  281. }
  282. private void ReadPlcToCache()
  283. {
  284. foreach (var item in WCS_DBSet)
  285. {
  286. byte[] DB_Data = null;//new byte[item.DB_EQUDATA.Length];
  287. bool result = Plc.ReadByteArea((ushort)item.DB_NAME, (ushort)item.DB_STARTADDRESS, (ushort)item.DB_TOLLENGTH, ref DB_Data);
  288. if (result == false)
  289. {
  290. Log4netHelper.Logger_Error.ErrorFormat(string.Format("PLC[{0}]DB[{1}]读取失败。", item.DB_PLCNAME, item.DB_NAME));
  291. }
  292. else
  293. {
  294. //if (item.DB_NAME == 537)
  295. //{
  296. // string alaram = PlcHelper.ReadAlaramCodeByBytes(DB_Data);
  297. // Current.Logger_Info.InfoFormat(string.Format("报警信息:[{0}]", alaram));
  298. //}
  299. if (item.DB_EQUDATA != DB_Data) item.DB_EQUDATA = DB_Data;
  300. }
  301. }
  302. }
  303. /// <summary>
  304. /// 读取缓存信号到实体
  305. /// </summary>
  306. private void ReadScannBarCodeCacheToEntity()
  307. {
  308. //扫码PLC
  309. var WCS_DBSCAN = WCS_DBSet.Where(it => it.DB_TypeCh == DB_TypeEnum.WCS读取扫码DB).ToList();
  310. foreach (var item in WCS_DBSCAN)
  311. {
  312. var scannSet = WCS_ScannSet.Where(v => v.SCANN_DB_ID == item.DB_ID).OrderBy(v => v.SCANN_SEQUENCE);
  313. foreach (var scann in scannSet)
  314. {
  315. byte[] dbsann = item.DB_EQUDATA.Skip(scann.SCANN_STARTADDRESS).Take(scann.SCANN_LENGTH).ToArray();
  316. string barcode = ExtendsUtil.GetBarCodeStr(dbsann).Replace("\r", "").Replace("\0", "").Trim();
  317. if (scann.SCANN_BARCODE != barcode)
  318. {
  319. scann.SCANN_BARCODE = barcode;
  320. scann.SCANN_UPDATETIME = DateTime.Now;
  321. }
  322. }
  323. }
  324. }
  325. private int readPlcInfoToDataBase = 0;
  326. public void ReadPlcInfoToDataBase()
  327. {
  328. if (Interlocked.Exchange(ref readPlcInfoToDataBase, 1) == 0)
  329. {
  330. try
  331. {
  332. Thread.Sleep(1000);//1秒中更新一次
  333. SugarBase.Exec((db) => {
  334. #region 更新PLC DB信息
  335. var dbdefinitionSet = db.Queryable<WCS_DBDEFINITION>().Where(v => v.DB_PLCNAME == PLC_NAME).ToList();
  336. foreach (var item in WCS_DBSet)
  337. {
  338. var dbdefinition = dbdefinitionSet.FirstOrDefault(v => v.DB_ID == item.DB_ID);
  339. if (dbdefinition.DB_EQUDATA == item.DB_EQUDATA) continue;
  340. dbdefinition.DB_EQUDATA = item.DB_EQUDATA;
  341. db.Updateable(dbdefinition).UpdateColumns(it => new { it.DB_EQUDATA }).ExecuteCommand();
  342. }
  343. #endregion;
  344. #region 写入设备实时报警和条码信息
  345. var equipmentInfoSet = db.Queryable<WCS_EQUIPMENTINFO>().Where(v => v.Equ_PlcName == PLC_NAME).ToList();
  346. foreach (var item in WCS_EquipmentInfoSet)
  347. {
  348. var equipmentInfo = equipmentInfoSet.FirstOrDefault(v => v.Equ_No == item.Equ_No && v.Equ_Area == item.Equ_Area);
  349. if (item.Equ_Type == EquipmentType.srm.ToString())
  350. {
  351. try
  352. {
  353. var srmMode = (SrmMode)Enum.Parse(typeof(SrmMode), item.EquSignal_Srm.DB521_Auto_status.ToString());
  354. var srmStatus = (SrmStatus)Enum.Parse(typeof(SrmStatus), item.EquSignal_Srm.DB521_Srm_Status.ToString());
  355. if (equipmentInfo.Equ_AlaramsMsg == item.EquSignal_Srm.SrmFault &&
  356. equipmentInfo.Equ_WorkMode == srmMode.ToString() &&
  357. equipmentInfo.Equ_SystemStatus == srmStatus.ToString())
  358. continue;
  359. equipmentInfo.Equ_WorkMode = srmMode.ToString();
  360. equipmentInfo.Equ_SystemStatus = srmStatus.ToString();
  361. }
  362. catch (Exception ex)
  363. {
  364. Log4netHelper.Logger_Error.ErrorFormat(ex.ToString());
  365. }
  366. equipmentInfo.Equ_AlaramsMsg = item.EquSignal_Srm.SrmFault;
  367. db.Updateable(equipmentInfo).UpdateColumns(it => new { it.Equ_AlaramsMsg, it.Equ_SystemStatus, it.Equ_WorkMode }).ExecuteCommand();
  368. }
  369. if (item.Equ_Type == EquipmentType.conveyor.ToString())
  370. {
  371. string fault = string.Empty;
  372. if (item.Equ_No == "1044")
  373. {
  374. if (item.EquSignal_Conv.Conv1044Fault > 0)
  375. {
  376. fault = item.EquSignal_Conv.Conv1044Fault.ToString();
  377. }
  378. }
  379. else
  380. {
  381. if (item.EquSignal_Conv.ConvFault > 0)
  382. {
  383. fault = item.EquSignal_Conv.ConvFault.ToString();
  384. }
  385. }
  386. if (equipmentInfo.Equ_AlaramsMsg == fault &&
  387. equipmentInfo.Equ_BarCode == item.EquSignal_Conv.BarCodeStr)
  388. continue;
  389. equipmentInfo.Equ_AlaramsMsg = fault;
  390. equipmentInfo.Equ_BarCode = item.EquSignal_Conv.BarCodeStr;
  391. db.Updateable(equipmentInfo).UpdateColumns(it => new { it.Equ_AlaramsMsg, it.Equ_BarCode }).ExecuteCommand();
  392. }
  393. if (item.Equ_Type == EquipmentType.rgv.ToString())
  394. {
  395. try
  396. {
  397. var rgvMode = (RgvMode)Enum.Parse(typeof(RgvMode), item.EquSignal_Rgv.DB521_WorkMode.ToString());
  398. var rgvStatus = (RgvStatus)Enum.Parse(typeof(RgvStatus), item.EquSignal_Rgv.DB521_SystemStatus.ToString());
  399. if (equipmentInfo.Equ_AlaramsMsg == item.EquSignal_Rgv.AlarmFault &&
  400. equipmentInfo.Equ_WorkMode == rgvMode.ToString() &&
  401. equipmentInfo.Equ_SystemStatus == rgvStatus.ToString())
  402. continue;
  403. equipmentInfo.Equ_WorkMode = rgvMode.ToString();
  404. equipmentInfo.Equ_SystemStatus = rgvStatus.ToString();
  405. }
  406. catch (Exception ex)
  407. {
  408. Log4netHelper.Logger_Error.ErrorFormat(ex.ToString());
  409. }
  410. equipmentInfo.Equ_AlaramsMsg = item.EquSignal_Rgv.AlarmFault;
  411. db.Updateable(equipmentInfo).UpdateColumns(it => new { it.Equ_AlaramsMsg,it.Equ_SystemStatus,it.Equ_WorkMode }).ExecuteCommand();
  412. }
  413. //插入报警记录
  414. WriteAlaram(db, item);
  415. //插入超宽超高等报警
  416. WriteLedAlaram(db, item);
  417. }
  418. #endregion;
  419. #region 写入读码信息到数据库
  420. var scannSet = db.Queryable<WCS_SCANN>().Where(v => v.SCANN_PLCNAME == PLC_NAME).ToList();
  421. foreach (var item in scannSet)
  422. {
  423. var scannitem = WCS_ScannSet.FirstOrDefault(v => v.SCANN_ID == item.SCANN_ID);
  424. if (scannitem.SCANN_BARCODE == item.SCANN_BARCODE) continue;
  425. item.SCANN_BARCODE = scannitem.SCANN_BARCODE;
  426. item.SCANN_UPDATETIME = DateTime.Now;
  427. db.Updateable(item).UpdateColumns(it => new { it.SCANN_BARCODE, it.SCANN_UPDATETIME }).ExecuteCommand();
  428. }
  429. #endregion;
  430. return string.Empty;
  431. });
  432. }
  433. catch (Exception ex)
  434. {
  435. Log4netHelper.Logger_Error.ErrorFormat(ex.ToString());
  436. }
  437. finally
  438. {
  439. Interlocked.Exchange(ref readPlcInfoToDataBase, 0);
  440. }
  441. }
  442. }
  443. /// <summary>
  444. /// 记录报警信息
  445. /// </summary>
  446. private void WriteAlaram(SqlSugarClient db, WCS_EQUIPMENTINFO item)
  447. {
  448. // 查询报警记录信息
  449. var alaramRecord = db.Queryable<WCS_ALARAMRECORD>().First(v => v.ALARAMR_EQUNO == item.Equ_No && v.ALARAMR_EQUSTATUS == 2);
  450. if (string.IsNullOrWhiteSpace(item.Equ_AlaramsMsg))
  451. {
  452. if (alaramRecord != null)
  453. {
  454. //结束报警消息
  455. alaramRecord.ALARAMR_EQUSTATUS = 1;
  456. alaramRecord.ALARAMR_ALARAMENDTIME = db.GetDate();
  457. db.Updateable(alaramRecord).UpdateColumns(it => new { it.ALARAMR_EQUSTATUS, it.ALARAMR_ALARAMENDTIME }).ExecuteCommand();
  458. }
  459. }
  460. else
  461. {
  462. bool isInsert = false;
  463. if(alaramRecord == null)
  464. {
  465. isInsert = true;
  466. }
  467. else
  468. {
  469. if (alaramRecord.ALARAMR_ALARAMMSG != item.Equ_AlaramsMsg)
  470. {
  471. //结束上一个报警消息
  472. alaramRecord.ALARAMR_EQUSTATUS = 1;
  473. alaramRecord.ALARAMR_ALARAMENDTIME = db.GetDate();
  474. db.Updateable(alaramRecord).UpdateColumns(it => new { it.ALARAMR_EQUSTATUS, it.ALARAMR_ALARAMENDTIME }).ExecuteCommand();
  475. isInsert = true;
  476. }
  477. }
  478. if (isInsert)
  479. {
  480. //添加新的报警消息
  481. var alaramrecord = new WCS_ALARAMRECORD();
  482. alaramrecord.ALARAMR_ID = Guid.NewGuid().ToString();
  483. alaramrecord.ALARAMR_TYPE = "0";
  484. alaramrecord.ALARAMR_EQUNO = item.Equ_No;
  485. alaramrecord.ALARAMR_EQUTYPE = item.Equ_Type;
  486. alaramrecord.ALARAMR_EQUSTATUS = 2;
  487. alaramrecord.ALARAMR_ALARAMMSG = item.Equ_AlaramsMsg;
  488. alaramrecord.ALARAMR_ALARAMSTARTTIME = DateTime.Now;
  489. if (item.Equ_Type == EquipmentType.srm.ToString())
  490. alaramrecord.ALARAMR_WCSTASKID = Convert.ToInt32(item.EquSignal_Srm.DB520_TaskID);
  491. else if (item.Equ_Type == EquipmentType.conveyor.ToString())
  492. alaramrecord.ALARAMR_WCSTASKID = Convert.ToInt32(item.EquSignal_Conv.DB521_Tasknum);
  493. else if (item.Equ_Type == EquipmentType.rgv.ToString())
  494. alaramrecord.ALARAMR_WCSTASKID = Convert.ToInt32(item.EquSignal_Rgv.DB521_TaskID_1 == 0 ? item.EquSignal_Rgv.DB521_TaskID_2 : item.EquSignal_Rgv.DB521_TaskID_1);
  495. db.Insertable(alaramrecord).ExecuteCommand();
  496. }
  497. }
  498. }
  499. private void WriteLedAlaram(SqlSugarClient db, WCS_EQUIPMENTINFO item)
  500. {
  501. int task_no = 0;
  502. string alaram = string.Empty;
  503. if (item.Equ_Type.ToLower() == EquipmentType.conveyor.ToString())
  504. {
  505. if (item.Equ_No == "1104") return;
  506. task_no = Convert.ToInt32(item.EquSignal_Conv.DB521_Tasknum);
  507. StringBuilder sb = new StringBuilder();
  508. if (item.EquSignal_Conv.DB521_Goods_Err)
  509. {
  510. sb.Append(",外形/条码故障");
  511. }
  512. if (item.EquSignal_Conv.DB521_F_Outside)
  513. {
  514. sb.Append(",前超长");
  515. }
  516. if (item.EquSignal_Conv.DB521_B_Outside)
  517. {
  518. sb.Append(",后超长");
  519. }
  520. if (item.EquSignal_Conv.DB521_L_Outside)
  521. {
  522. sb.Append(",左超宽");
  523. }
  524. if (item.EquSignal_Conv.DB521_R_Outside)
  525. {
  526. sb.Append(",右超宽");
  527. }
  528. //if (item.StackerData.DB521_H_Outside)
  529. //{
  530. // sb.Append(",超高");
  531. //}
  532. if (item.EquSignal_Conv.DB521_BCR_Noread)
  533. {
  534. sb.Append(",条码未读出");
  535. }
  536. if (item.EquSignal_Conv.DB521_Overload)
  537. {
  538. sb.Append(",超重");
  539. }
  540. alaram = sb.ToString().TrimStart(',');
  541. }
  542. //else if (item.STA_TYPE.ToLower() == EquipmentType.rgv.ToString())
  543. //{
  544. // task_no = item.RGVSignalItem.DB521_TaskID_1;
  545. // StringBuilder sb = new StringBuilder();
  546. // if ((int)item.RGVSignalItem.AlarmFault1 != 0)
  547. // {
  548. // sb.Append(string.Format(",{0}", item.RGVSignalItem.AlarmFault1));
  549. // }
  550. // if ((int)item.RGVSignalItem.AlarmFault2 != 0)
  551. // {
  552. // sb.Append(string.Format(",{0}", item.RGVSignalItem.AlarmFault2));
  553. // }
  554. // if ((int)item.RGVSignalItem.AlarmFault3 != 0)
  555. // {
  556. // sb.Append(string.Format(",{0}", item.RGVSignalItem.AlarmFault3));
  557. // }
  558. //}
  559. if (!string.IsNullOrWhiteSpace(alaram))
  560. {
  561. string msg = string.Format("[{0}][{1}]", item.Equ_No, alaram);
  562. BaseWorkflow.AddLedErrorMsg(db, item.Equ_No, msg, task_no);
  563. //ThreadHelper.TaskThread(BaseWorkflow.UploadExcTask, new { EquipmentNo = item.STA_EQUIPMENTNO, Alaram = alaram });
  564. }
  565. }
  566. #endregion;
  567. }
  568. public class WCS_PLCList
  569. {
  570. public static void ExecuteWcs_Workflow()
  571. {
  572. foreach (var item in Current.PlcSet)
  573. {
  574. if (item.PLC_ISENABLE)
  575. {
  576. //不同PLC CPU多线程读取信号
  577. ThreadHelper.TaskThread(item.ExecuteWcs_Workflow);
  578. }
  579. }
  580. }
  581. }
  582. }