终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2472 lines
163 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.Helper;
  3. using BPASmartClient.JXJFoodSmallStation.Model.GVL;
  4. using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
  5. using BPASmartClient.JXJFoodSmallStation.Model.RawMaterial;
  6. using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
  7. using BPASmartClient.JXJFoodSmallStation.Model.WindSend;
  8. using BPASmartClient.Modbus;
  9. using System;
  10. using System.Collections.Concurrent;
  11. using System.Collections.Generic;
  12. using System.Collections.ObjectModel;
  13. using System.Configuration;
  14. using System.Linq;
  15. using System.Reflection;
  16. using System.Text;
  17. using System.Threading;
  18. using System.Threading.Tasks;
  19. namespace BPASmartClient.JXJFoodSmallStation.Model
  20. {
  21. public class ProcessControl
  22. {
  23. private volatile static ProcessControl _Instance;
  24. public static ProcessControl GetInstance => _Instance ?? (_Instance = new ProcessControl());
  25. private ProcessControl() { }
  26. /// <summary>
  27. /// 配方数据
  28. /// </summary>
  29. public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>();
  30. /// <summary>
  31. /// 原料的名称和料仓的位置对应
  32. /// </summary>
  33. public Dictionary<string, short> RawMaterialsNamePos = new Dictionary<string, short>();
  34. public ObservableCollection<RawMaterialStockBin> RawMaterialsInfo => Json<DevicePar>.Data.rawMaterialStockBin;
  35. /// <summary>
  36. /// 配方队列
  37. /// </summary>
  38. public ConcurrentQueue<string> RecipeQueueTray1 = new ConcurrentQueue<string>();
  39. public ConcurrentQueue<string> RecipeQueueTray2 = new ConcurrentQueue<string>();
  40. public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
  41. public HKDeviceStatus HKDevice = new HKDeviceStatus();
  42. public WindSendDeviceStatus WindSendDevice = new WindSendDeviceStatus();
  43. public ObservableCollection<PlcInfos> CommData { get; set; } = new ObservableCollection<PlcInfos>();
  44. public ObservableCollection<PlcInfos> ProcessVar { get; set; } = new ObservableCollection<PlcInfos>();
  45. XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB();
  46. /// <summary>
  47. /// 风送PLC的DB块
  48. /// </summary>
  49. WindSend_Write WindSendData = new WindSend_Write();
  50. /// <summary>
  51. /// 接收原料数据
  52. /// </summary>
  53. public RecipeRawMaterial RawMaterial;
  54. public DateTime StockBinAlarmTime = DateTime.Now;
  55. public string? HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
  56. public string? Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
  57. public string? WindSend_PLC_IP = ConfigurationManager.AppSettings["WindSend_IP"];
  58. public void Init()
  59. {
  60. PlcVarMonitor();
  61. StockBinNameWithPos();
  62. RawMaterialNameWithCode();
  63. RegisterInit();
  64. DeviceConnect();
  65. //Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
  66. ThreadManage.GetInstance().StartLong(new Action(() =>
  67. {
  68. if (HKDevice.IsConnected)
  69. {
  70. GVL_SmallStation.GetInstance.HeartBeatToPlc = !GVL_SmallStation.GetInstance.HeartBeatToPlc;
  71. HKDevice.HK_PLC_S7.Write("DB4.DBX0.0", GVL_SmallStation.GetInstance.HeartBeatToPlc);
  72. GVL_SmallStation.GetInstance.HeartBeatFromPlc = HKDevice.HK_PLC_S7.Read<bool>("DB45.DBX0.0");
  73. if (DeviceInquire.GetInstance.devices.Count < 15 && HKDevice.IsConnected && Json<RemoteRecipeDataColl>.Data.Recipes.Count > 0 && GVL_SmallStation.GetInstance.DisEnableStockBinAlarm == false && DateTime.Now.Subtract(StockBinAlarmTime).TotalSeconds >= 60)
  74. {
  75. HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
  76. App.Current.Dispatcher.Invoke(() =>
  77. {
  78. MessageNotify.GetInstance.ShowDialog($"未读取到15个柔性味魔方料仓", DialogType.Error);
  79. StockBinAlarmTime = DateTime.Now;
  80. });
  81. HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
  82. }
  83. }
  84. Thread.Sleep(200);
  85. }), "海科plc通信心跳", true);
  86. ThreadManage.GetInstance().StartLong(new Action(() =>
  87. {
  88. if (GVL_SmallStation.GetInstance.Order_Cancel)
  89. {
  90. CancelOrder();//订单取消,不执行配方流程
  91. }
  92. else
  93. {
  94. ReceviceData();//配方请求
  95. RecipeInfoToHKPLC();//配方配料
  96. }
  97. Thread.Sleep(10);
  98. }), "小料站流程控制", true);
  99. ThreadManage.GetInstance().StartLong(new Action(() =>
  100. {
  101. RealTimeData();
  102. foreach (var item in Json<DevicePar>.Data.windSendRawMaterial)
  103. {
  104. if (GVL_SmallStation.GetInstance.RawMaterialsNameCode.ContainsKey(item.RawMaterialName))
  105. {
  106. item.RawMaterialChineseName = GVL_SmallStation.GetInstance.RawMaterialsNameCode[item.RawMaterialName];
  107. }
  108. else
  109. {
  110. item.RawMaterialChineseName = "";
  111. }
  112. }
  113. Thread.Sleep(10);
  114. }), "西门子PLC和小料站PLC的实时数据交互流程", true);
  115. ThreadManage.GetInstance().StartLong(new Action(() =>
  116. {
  117. HKPlcRead();
  118. GetStatus();
  119. Thread.Sleep(10);
  120. }), "海科PLC实时数据", true);
  121. }
  122. /// <summary>
  123. /// 气缸的传感器值
  124. /// </summary>
  125. private void GetStatus()
  126. {
  127. for (int i = 0; i < 8; i++)
  128. {
  129. GVL_SmallStation.GetInstance.Cylinder_JackInfo[i] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX0." + i);
  130. }
  131. for (int i = 0; i < 7; i++)
  132. {
  133. GVL_SmallStation.GetInstance.Cylinder_JackInfo[i + 8] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX1." + i);
  134. }
  135. GVL_SmallStation.GetInstance.Cylinder_JackInfo[20] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX3.6");//进料桶气缸
  136. GVL_SmallStation.GetInstance.Cylinder_JackInfo[21] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX3.7");//出料筒气缸1
  137. GVL_SmallStation.GetInstance.Cylinder_JackInfo[22] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX4.0");//出料筒气缸2
  138. GVL_SmallStation.GetInstance.Cylinder_JackInfo[23] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX4.1");//出料筒气缸3
  139. GVL_SmallStation.GetInstance.Cylinder_JackInfo[24] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX4.2");//托盘1_1气缸
  140. GVL_SmallStation.GetInstance.Cylinder_JackInfo[25] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX4.3");//托盘1_2气缸
  141. GVL_SmallStation.GetInstance.Cylinder_JackInfo[26] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX4.4");//托盘2_1气缸
  142. GVL_SmallStation.GetInstance.Cylinder_JackInfo[27] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX4.5");//托盘2_2气缸
  143. }
  144. /// <summary>
  145. /// DB块的变量实时值
  146. /// </summary>
  147. private void HKPlcRead()
  148. {
  149. if (HKDevice.IsConnected)
  150. {
  151. foreach (PropertyInfo item in typeof(PlcReadAddressDB3).GetProperties())
  152. {
  153. int index = Array.FindIndex(CommData.ToArray(), p => p.Name == item.Name);
  154. if (index >= 0)
  155. {
  156. CommData.ElementAt(index).Value = GVL_SmallStation.GetInstance.plcReadDataDB3.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.GetInstance.plcReadDataDB3, null).ToString();
  157. }
  158. }
  159. }
  160. foreach (PropertyInfo item in typeof(GVL_SmallStation).GetProperties())
  161. {
  162. int index = Array.FindIndex(ProcessVar.ToArray(), p => p.Name == item.Name);
  163. if (index >= 0)
  164. {
  165. ProcessVar.ElementAt(index).Value = GVL_SmallStation.GetInstance.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.GetInstance, null).ToString();
  166. }
  167. }
  168. }
  169. /// <summary>
  170. /// 小料站和西门子PLC之间的实时数据
  171. /// </summary>
  172. private void RealTimeData()
  173. {
  174. if (HKDevice.IsConnected)
  175. {
  176. //获取系统状态
  177. GVL_SmallStation.GetInstance.PlcSystemIsAutoRun = HKDevice.HK_PLC_S7.Read<bool>("DB44.DBX0.0");//系统启停
  178. GVL_SmallStation.GetInstance.PlcSystemMode = HKDevice.HK_PLC_S7.Read<bool>("DB44.DBX0.1");//系统模式
  179. GVL_SmallStation.GetInstance.PlcSystemIsPause = HKDevice.HK_PLC_S7.Read<bool>("DB44.DBX0.2");//系统暂停
  180. GVL_SmallStation.GetInstance.Station1HaveTray = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX0.7");//工站1 有货架
  181. GVL_SmallStation.GetInstance.Station2HaveTray = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.0");//工站2 有货架
  182. if (GVL_SmallStation.GetInstance.WindSendDosingComple)
  183. {
  184. HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.7", true);
  185. GVL_SmallStation.GetInstance.WindSendDosingComple = false;
  186. MessageNotify.GetInstance.ShowRunLog("风送配料完成信号,发给产线plc信号");
  187. }
  188. if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1"))
  189. {
  190. HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.7", false);
  191. }
  192. if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.7"))//允许下配方1或者允许下配方2
  193. {
  194. GVL_SmallStation.GetInstance.IsAllowSiemensSendRecipe = true;
  195. }
  196. GVL_SmallStation.GetInstance.Station1Sensor = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.1");
  197. GVL_SmallStation.GetInstance.Station2Sensor = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.2");
  198. GVL_SmallStation.GetInstance.Station1Cylinder = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.3");
  199. GVL_SmallStation.GetInstance.Station2Cylinder = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.4");
  200. GVL_SmallStation.GetInstance.RobotStatus = HKDevice.HK_PLC_S7.Read<ushort>("DB3.DBW100");
  201. GVL_SmallStation.GetInstance.RobotProgramNum = HKDevice.HK_PLC_S7.Read<byte>("DB3.DBB102");
  202. }
  203. if (SiemensDevice.IsConnected)
  204. {
  205. ushort TrayCylinder = 0;
  206. ushort TraySensor = 0;
  207. if (GVL_SmallStation.GetInstance.Station1Sensor)
  208. {
  209. TraySensor = TraySensor.SetBitValue(1, true);
  210. }
  211. else
  212. {
  213. TraySensor = TraySensor.SetBitValue(0, false);
  214. }
  215. if (!GVL_SmallStation.GetInstance.Station1Cylinder)
  216. {
  217. TrayCylinder = TrayCylinder.SetBitValue(1, true);
  218. }
  219. else
  220. {
  221. TrayCylinder = TrayCylinder.SetBitValue(0, false);
  222. }
  223. this.SiemensDevice.Siemens_PLC_S7.Write<bool>("DB2231.DBX28.4", GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet);
  224. this.SiemensDevice.Siemens_PLC_S7.Write<ushort>("DB2231.DBW190", TraySensor);//添加工位传感器的信号
  225. this.SiemensDevice.Siemens_PLC_S7.Write<ushort>("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号
  226. ushort AGV_Put = (ushort)SiemensDevice.XL_Status.AgvFinishPut;
  227. if (AGV_Put.Get16bitValue(1))
  228. {
  229. GVL_SmallStation.GetInstance.AGV_PutTray1Finish = true;
  230. }
  231. else
  232. {
  233. GVL_SmallStation.GetInstance.AGV_PutTray1Finish = false;
  234. }
  235. ushort AGV_Get = (ushort)SiemensDevice.XL_Status.AgvFinishGet;
  236. if (AGV_Get.Get16bitValue(1))
  237. {
  238. GVL_SmallStation.GetInstance.AGV_GetTray1Finish = true;
  239. }
  240. else
  241. {
  242. GVL_SmallStation.GetInstance.AGV_GetTray1Finish = false;
  243. }
  244. }
  245. }
  246. public void CancelOrder()
  247. {
  248. if (GVL_SmallStation.GetInstance.Order_Cancel) //订单取消
  249. {
  250. if (!string.IsNullOrEmpty(GVL_SmallStation.GetInstance.Order_CancelRecipeCode))
  251. {
  252. string code = GVL_SmallStation.GetInstance.Order_CancelRecipeCode;
  253. int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == code);
  254. switch (GVL_SmallStation.GetInstance.OrderCancelStep)
  255. {
  256. case 0://前提条件判断
  257. if (index == -1)
  258. {
  259. GVL_SmallStation.GetInstance.OrderCancelStep = 30;
  260. MessageNotify.GetInstance.ShowRunLog($"配方中并未找到订单{code}");
  261. }
  262. else
  263. {
  264. if (RecipeQueueTray1.Contains(GVL_SmallStation.GetInstance.Order_CancelRecipeCode))
  265. {
  266. GVL_SmallStation.GetInstance.OrderCancelStep = 1;
  267. }
  268. else if (RecipeQueueTray2.Contains(GVL_SmallStation.GetInstance.Order_CancelRecipeCode))
  269. {
  270. GVL_SmallStation.GetInstance.OrderCancelStep = 10;
  271. }
  272. else
  273. {
  274. GVL_SmallStation.GetInstance.OrderCancelStep = 20;
  275. }
  276. }
  277. break;
  278. //Case 1-9为
  279. case 1:
  280. if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 != 0)
  281. {
  282. GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
  283. HKDevice.HK_PLC_S7.Write("DB4.DBX2.1", true);
  284. MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}");
  285. GVL_SmallStation.GetInstance.OrderCancelStep = 2;
  286. }
  287. else
  288. {
  289. MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}");
  290. GVL_SmallStation.GetInstance.OrderCancelStep = 3;
  291. }
  292. break;
  293. case 2:
  294. if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.5"))
  295. {
  296. if (GVL_SmallStation.GetInstance.Station1Cylinder == false)
  297. {
  298. GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
  299. GVL_SmallStation.GetInstance.OrderCancelStep = 3;
  300. MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}");
  301. }
  302. }
  303. break;
  304. case 3:
  305. SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
  306. GVL_SmallStation.GetInstance.OrderCancelStep = 4;
  307. break;
  308. case 4:
  309. if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
  310. {
  311. SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
  312. GVL_SmallStation.GetInstance.OrderCancelStep = 9;
  313. MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
  314. }
  315. break;
  316. case 9:
  317. App.Current.Dispatcher.Invoke(() =>
  318. {
  319. Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);
  320. });
  321. RecipeQueueTray1.TryDequeue(out code);
  322. GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
  323. GVL_SmallStation.GetInstance.Order_Cancel = false;
  324. GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
  325. GVL_SmallStation.GetInstance.OrderCancelStep = 0;
  326. break;
  327. case 10:
  328. if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 != 0)
  329. {
  330. GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
  331. HKDevice.HK_PLC_S7.Write("DB4.DBX2.2", true);
  332. MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}");
  333. GVL_SmallStation.GetInstance.OrderCancelStep = 11;
  334. }
  335. else
  336. {
  337. MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}");
  338. GVL_SmallStation.GetInstance.OrderCancelStep = 12;
  339. }
  340. break;
  341. case 11:
  342. if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.6"))
  343. {
  344. if (GVL_SmallStation.GetInstance.Station2Cylinder == false)
  345. {
  346. GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
  347. GVL_SmallStation.GetInstance.OrderCancelStep = 12;
  348. MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}");
  349. }
  350. }
  351. break;
  352. case 12:
  353. SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
  354. GVL_SmallStation.GetInstance.OrderCancelStep = 13;
  355. break;
  356. case 13:
  357. if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
  358. {
  359. SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
  360. GVL_SmallStation.GetInstance.OrderCancelStep = 14;
  361. MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
  362. }
  363. break;
  364. case 19:
  365. App.Current.Dispatcher.Invoke(() =>
  366. {
  367. Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);
  368. });
  369. RecipeQueueTray2.TryDequeue(out code);
  370. GVL_SmallStation.GetInstance.Order_Cancel = false;
  371. GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;
  372. GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
  373. GVL_SmallStation.GetInstance.OrderCancelStep = 0;
  374. break;
  375. //20-29为订单还未下发至PLC
  376. case 20:
  377. SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
  378. GVL_SmallStation.GetInstance.OrderCancelStep = 21;
  379. break;
  380. case 21:
  381. if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
  382. {
  383. SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
  384. GVL_SmallStation.GetInstance.OrderCancelStep = 29;
  385. MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
  386. }
  387. break;
  388. case 29:
  389. App.Current.Dispatcher.Invoke(() =>
  390. {
  391. Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);
  392. });
  393. GVL_SmallStation.GetInstance.Order_Cancel = false;
  394. GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
  395. GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0;
  396. GVL_SmallStation.GetInstance.OrderCancelStep = 0;
  397. break;
  398. //30-39为订单还未下发至上位机
  399. case 30:
  400. SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
  401. GVL_SmallStation.GetInstance.OrderCancelStep = 31;
  402. break;
  403. case 31:
  404. if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
  405. {
  406. SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
  407. GVL_SmallStation.GetInstance.OrderCancelStep = 39;
  408. MessageNotify.GetInstance.ShowRunLog($"西门子取消订单完成,订单号:{code}");
  409. }
  410. break;
  411. case 39:
  412. GVL_SmallStation.GetInstance.Order_Cancel = false;
  413. GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
  414. GVL_SmallStation.GetInstance.OrderCancelStep = 0;
  415. break;
  416. }
  417. }
  418. }
  419. }
  420. /// <summary>
  421. /// 将配方添加到配方队列中
  422. /// </summary>
  423. private void ReceviceData()
  424. {
  425. if (!GVL_SmallStation.GetInstance.IsUseLocalRecipe)
  426. {
  427. RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
  428. if (RemoteRecipes.Count > 0)
  429. {
  430. foreach (var data in RemoteRecipes)
  431. {
  432. if (data.TrayCode == 1)
  433. {
  434. if (!(RecipeQueueTray1.Contains(data.RecipeCode)))
  435. {
  436. if (SiemensDevice.XL_Status is XL_Status_DB status)
  437. {
  438. switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus)
  439. {
  440. case 3:
  441. SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10);
  442. SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true);
  443. GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 4;
  444. MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料");
  445. break;
  446. case 4:
  447. if (SiemensDevice.XL_Status.Dosing_Confirm)
  448. {
  449. SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串
  450. SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
  451. GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 5;
  452. MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料");
  453. }
  454. break;
  455. case 5:
  456. if (SiemensDevice.XL_Status.Dosing_Confirm == false)
  457. {
  458. GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 6;
  459. MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成");
  460. }
  461. break;
  462. case 6:
  463. RecipeQueueTray1.Enqueue(data.RecipeCode);
  464. GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0;
  465. MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},加入队列");
  466. break;
  467. default:
  468. break;
  469. }
  470. }
  471. }
  472. }
  473. else if (data.TrayCode == 2)
  474. {
  475. if (!(RecipeQueueTray2.Contains(data.RecipeCode)))
  476. {
  477. if (SiemensDevice.XL_Status is XL_Status_DB status)
  478. {
  479. switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus)
  480. {
  481. case 3:
  482. SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10);
  483. SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true);
  484. GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 4;
  485. MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料");
  486. break;
  487. case 4:
  488. if (SiemensDevice.XL_Status.Dosing_Confirm)
  489. {
  490. SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串
  491. SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
  492. GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 5;
  493. MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料");
  494. }
  495. break;
  496. case 5:
  497. if (SiemensDevice.XL_Status.Dosing_Confirm == false)
  498. {
  499. GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 6;
  500. MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成");
  501. }
  502. break;
  503. case 6:
  504. RecipeQueueTray2.Enqueue(data.RecipeCode);
  505. GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0;
  506. MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},加入队列");
  507. break;
  508. default:
  509. break;
  510. }
  511. }
  512. }
  513. }
  514. }
  515. }
  516. else
  517. {
  518. RecipeQueueTray1.Clear();
  519. RecipeQueueTray2.Clear();
  520. /*GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
  521. GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;*/
  522. GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
  523. GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
  524. }
  525. }
  526. else
  527. {
  528. RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
  529. if (RemoteRecipes.Count > 0)
  530. {
  531. foreach (var data in RemoteRecipes)
  532. {
  533. if (data.TrayCode == 1)
  534. {
  535. if (!(RecipeQueueTray1.Contains(data.RecipeCode)))
  536. {
  537. RecipeQueueTray1.Enqueue(data.RecipeCode);
  538. }
  539. }
  540. else if (data.TrayCode == 2)
  541. {
  542. if (!(RecipeQueueTray2.Contains(data.RecipeCode)))
  543. {
  544. RecipeQueueTray2.Enqueue(data.RecipeCode);
  545. }
  546. }
  547. }
  548. }
  549. else
  550. {
  551. RecipeQueueTray1.Clear();
  552. RecipeQueueTray2.Clear();
  553. /*GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
  554. GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;*/
  555. GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
  556. GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
  557. }
  558. }
  559. }
  560. /// <summary>
  561. /// 执行配方队列中的第一个配方
  562. /// </summary>
  563. private void RecipeInfoToHKPLC()
  564. {
  565. switch (GVL_SmallStation.GetInstance.Tray1LogicFinish)
  566. {
  567. case 0:
  568. if (GVL_SmallStation.GetInstance.AGV_PutTray1Finish && RecipeQueueTray1.Count > 0)
  569. {
  570. HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", true);
  571. GVL_SmallStation.GetInstance.AGV_PutTray1Finish = false;
  572. GVL_SmallStation.GetInstance.Tray1LogicFinish = 1;
  573. MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc");
  574. }
  575. break;
  576. case 1:
  577. if (GVL_SmallStation.GetInstance.Station1HaveTray)
  578. {
  579. HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", false);
  580. GVL_SmallStation.GetInstance.Tray1LogicFinish = 2;
  581. MessageNotify.GetInstance.ShowRunLog("托盘1有货架");
  582. }
  583. else
  584. {
  585. if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.5") == true)
  586. {
  587. if (GVL_SmallStation.GetInstance.CylinderReset)
  588. {
  589. HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.5", true);
  590. }
  591. MessageNotify.GetInstance.ShowRunLog("气缸收紧错位");
  592. }
  593. else
  594. {
  595. GVL_SmallStation.GetInstance.Tray1LogicFinish = 1;
  596. HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.5", false);
  597. }
  598. }
  599. break;
  600. case 2:
  601. if (GVL_SmallStation.GetInstance.AGV_GetTray1Finish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 0)
  602. {
  603. HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", true);
  604. GVL_SmallStation.GetInstance.Tray1LogicFinish = 3;
  605. MessageNotify.GetInstance.ShowRunLog("AGV取托盘1完成,发送给海科信号后1s后复位");
  606. }
  607. break;
  608. case 3:
  609. if (HKDevice.HK_PLC_S7.Read<bool>("DB4.DBX1.1") == true)
  610. {
  611. Thread.Sleep(1000);
  612. HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", false);
  613. GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
  614. GVL_SmallStation.GetInstance.AGV_GetTray1Finish = false;
  615. MessageNotify.GetInstance.ShowRunLog("AGV取托盘1完成,信号复位");
  616. }
  617. break;
  618. default:
  619. break;
  620. }
  621. switch (GVL_SmallStation.GetInstance.Tray2LogicFinish)
  622. {
  623. case 0:
  624. if (GVL_SmallStation.GetInstance.AGV_PutTray2Finish)
  625. {
  626. HKDevice.HK_PLC_S7.Write("DB4.DBX1.0", true);
  627. GVL_SmallStation.GetInstance.AGV_PutTray2Finish = false;
  628. GVL_SmallStation.GetInstance.Tray2LogicFinish = 1;
  629. MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc");
  630. }
  631. break;
  632. case 1:
  633. if (GVL_SmallStation.GetInstance.Station2HaveTray)
  634. {
  635. HKDevice.HK_PLC_S7.Write("DB4.DBX1.0", false);
  636. GVL_SmallStation.GetInstance.Tray2LogicFinish = 2;
  637. MessageNotify.GetInstance.ShowRunLog("托盘1有货架");
  638. }
  639. else
  640. {
  641. if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.6") == true)
  642. {
  643. if (GVL_SmallStation.GetInstance.CylinderReset)
  644. {
  645. HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.6", true);
  646. }
  647. MessageNotify.GetInstance.ShowRunLog("气缸收紧错位");
  648. }
  649. else
  650. {
  651. GVL_SmallStation.GetInstance.Tray2LogicFinish = 1;
  652. HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.6", false);
  653. }
  654. }
  655. break;
  656. case 2:
  657. if (GVL_SmallStation.GetInstance.AGV_GetTray2Finish && GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 0)
  658. {
  659. HKDevice.HK_PLC_S7.Write("DB4.DBX1.2", true);
  660. GVL_SmallStation.GetInstance.Tray2LogicFinish = 3;
  661. }
  662. break;
  663. case 3:
  664. if (HKDevice.HK_PLC_S7.Read<bool>("DB4.DBX1.2") == true)
  665. {
  666. Thread.Sleep(1000);
  667. HKDevice.HK_PLC_S7.Write("DB4.DBX1.2", false);
  668. GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;
  669. GVL_SmallStation.GetInstance.AGV_GetTray2Finish = false;
  670. }
  671. break;
  672. default:
  673. break;
  674. }
  675. #region 托盘1配料
  676. if (RecipeQueueTray1.Count > 0) /*&& GVL_SmallStation.GetInstance.Tray1LogicFinish == 2*/ //不需要等待AGV到位,就给PLC下发配方
  677. {
  678. int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray1.ElementAt(0));
  679. if (index >= 0 && index < RemoteRecipes.Count)
  680. {
  681. string code = RemoteRecipes.ElementAt(index).RecipeCode;
  682. int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
  683. string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
  684. string windSend = RemoteRecipes.ElementAt(index).ToString();
  685. if (trayCode == 1)
  686. {
  687. //粉料仓下发配方
  688. if (GVL_SmallStation.GetInstance.IsUseWindSend && GVL_SmallStation.GetInstance.Tray1LogicFinish == 2 && GVL_SmallStation.GetInstance.WindSendDosing==false)
  689. {
  690. GVL_SmallStation.GetInstance.WindSendDosing = true;
  691. WindSendData.TargetRecipeCode = code;
  692. WindSendData.IsAllowDosing = true;
  693. foreach (var item in RemoteRecipes.ElementAt(index).WindSend)
  694. {
  695. if (item.RawMaterialName == "0037" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(0).RawMaterialName)
  696. {
  697. WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight;
  698. }
  699. if (item.RawMaterialName == "0038" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(1).RawMaterialName)
  700. {
  701. WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight;
  702. }
  703. if (item.RawMaterialName == "0039" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(2).RawMaterialName)
  704. {
  705. WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight;
  706. }
  707. if (item.RawMaterialName == "0045" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(3).RawMaterialName)
  708. {
  709. WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight;
  710. }
  711. if (item.RawMaterialName == "0046" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(4).RawMaterialName)
  712. {
  713. WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight;
  714. }
  715. }
  716. WindSendDevice.Siemens_PLC_S7.WriteClass<WindSend_Write>(WindSendData, 95);
  717. }
  718. if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 0)
  719. {
  720. StockBinInit();
  721. GVL_SmallStation.GetInstance.StockBinDosing = 0;
  722. foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
  723. {
  724. HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation);
  725. GVL_SmallStation.GetInstance.StockBinDosing= GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)item.RawMaterialLocation,true);//哪些仓位需要配料写入
  726. }
  727. HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
  728. GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 1;
  729. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成");
  730. GVL_SmallStation.GetInstance.time1 = DateTime.Now;
  731. }
  732. bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3");
  733. if ( recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 1)
  734. {
  735. HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", false);
  736. GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 2;
  737. MessageNotify.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成");
  738. }
  739. if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 2)
  740. {
  741. if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
  742. {
  743. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10");
  744. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
  745. if (res > 0 && res is float loc)
  746. {
  747. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  748. float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
  749. if (weight <= 0)
  750. {
  751. int i = (int)loc;
  752. if (i >= 1 && i <= 8)
  753. {
  754. string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  755. MessageNotify.GetInstance.ShowRunLog(commInfo);
  756. }
  757. else if (i >= 9 && i <= 15)
  758. {
  759. string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  760. MessageNotify.GetInstance.ShowRunLog(commInfo1);
  761. }
  762. GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  763. }
  764. else
  765. {
  766. if (loc_index >= 0)
  767. {
  768. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
  769. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  770. }
  771. else
  772. {
  773. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,错误没有找到{(int)loc}号仓的配方");
  774. }
  775. }
  776. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,正在配料");
  777. }
  778. }
  779. else if (RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
  780. {
  781. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
  782. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
  783. if (res > 0 && res is float loc)
  784. {
  785. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  786. float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
  787. if (weight <= 0)
  788. {
  789. int i = (int)loc;
  790. if (i >= 1 && i <= 8)
  791. {
  792. string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  793. MessageNotify.GetInstance.ShowRunLog(commInfo);
  794. }
  795. else if (i >= 9 && i <= 15)
  796. {
  797. string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  798. MessageNotify.GetInstance.ShowRunLog(commInfo1);
  799. }
  800. GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  801. }
  802. else
  803. {
  804. if (loc_index >= 0)
  805. {
  806. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  807. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  808. }
  809. else
  810. {
  811. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,错误没有找到{(int)loc}号仓的配方");
  812. }
  813. }
  814. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,正在配料");
  815. }
  816. }
  817. else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
  818. {
  819. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
  820. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
  821. if (res > 0 && res is float loc)
  822. {
  823. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  824. float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
  825. if (weight <= 0)
  826. {
  827. int i = (int)loc;
  828. if (i >= 1 && i <= 8)
  829. {
  830. string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  831. MessageNotify.GetInstance.ShowRunLog(commInfo);
  832. }
  833. else if (i >= 9 && i <= 15)
  834. {
  835. string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  836. MessageNotify.GetInstance.ShowRunLog(commInfo1);
  837. }
  838. GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  839. }
  840. else
  841. {
  842. if (loc_index >= 0)
  843. {
  844. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  845. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  846. }
  847. else
  848. {
  849. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,错误没有找到{(int)loc}号仓的配方");
  850. }
  851. }
  852. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,正在配料");
  853. }
  854. }
  855. else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
  856. {
  857. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
  858. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
  859. if (res > 0 && res is float loc)
  860. {
  861. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  862. float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
  863. if (weight <= 0)
  864. {
  865. int i = (int)loc;
  866. if (i >= 1 && i <= 8)
  867. {
  868. string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  869. MessageNotify.GetInstance.ShowRunLog(commInfo);
  870. }
  871. else if (i >= 9 && i <= 15)
  872. {
  873. string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  874. MessageNotify.GetInstance.ShowRunLog(commInfo1);
  875. }
  876. GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  877. }
  878. else
  879. {
  880. if (loc_index >= 0)
  881. {
  882. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  883. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  884. }
  885. else
  886. {
  887. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,错误没有找到{(int)loc}号仓的配方");
  888. }
  889. }
  890. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,正在配料");
  891. }
  892. }
  893. for (int i = 1; i < 16; i++)
  894. {
  895. if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
  896. {
  897. int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
  898. if (res >= 0)
  899. {
  900. Thread.Sleep(GVL_SmallStation.GetInstance.Time);
  901. RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
  902. bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
  903. MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}");
  904. float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000);
  905. int iIndex = Array.FindIndex(Json<DevicePar>.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
  906. if (iIndex >= 0)
  907. {
  908. if (Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange)
  909. {
  910. HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
  911. App.Current.Dispatcher.Invoke(() =>
  912. {
  913. MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning);
  914. HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
  915. });
  916. }
  917. }
  918. if (i >= 1 && i <= 8)
  919. {
  920. string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  921. MessageNotify.GetInstance.ShowRunLog(commInfo);
  922. }
  923. else if (i >= 9 && i <= 15)
  924. {
  925. string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  926. MessageNotify.GetInstance.ShowRunLog(commInfo1);
  927. }
  928. }
  929. GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  930. }
  931. }
  932. if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1"))))
  933. {
  934. if (GVL_SmallStation.GetInstance.StockBinDosing > 0)
  935. {
  936. for (int i = 1; i < 17; i++)
  937. {
  938. if (GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
  939. {
  940. MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓");
  941. }
  942. }
  943. }
  944. var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
  945. foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
  946. {
  947. MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g");
  948. }
  949. if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe)
  950. {
  951. RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
  952. RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
  953. RecipeFinishInfo.Job_No = (short)trayCode;
  954. for (int i = 0; i < 20; i++)
  955. {
  956. RecipeFinishInfo.Material[i] = new UDT1();
  957. }
  958. for (int i = 0; i < 10; i++)
  959. {
  960. RecipeFinishInfo.Powder[i] = new UDT2();
  961. }
  962. for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
  963. {
  964. RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
  965. RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
  966. RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001;
  967. }
  968. for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++)
  969. {
  970. RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
  971. }
  972. double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds;
  973. RecipeFinishInfo.Ask_For_Finish = true;
  974. RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
  975. SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
  976. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
  977. }
  978. else
  979. {
  980. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
  981. }
  982. GVL_SmallStation.GetInstance.WindSendDosing = false;
  983. App.Current.Dispatcher.Invoke(() =>
  984. {
  985. Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
  986. });
  987. RecipeQueueTray1.TryDequeue(out code);
  988. HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
  989. GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
  990. }
  991. }
  992. }
  993. }
  994. }
  995. //if (RecipeQueueTray1.Count > 0) /*&& GVL_SmallStation.GetInstance.Tray1LogicFinish == 2*/ //不需要等待AGV到位,就给PLC下发配方
  996. //{
  997. // foreach (var queue in RecipeQueueTray1)
  998. // {
  999. // int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == queue.ToString());
  1000. // if (index >= 0 && index < RemoteRecipes.Count)
  1001. // {
  1002. // int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
  1003. // string code = RemoteRecipes.ElementAt(index).RecipeCode;
  1004. // string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
  1005. // string windSend = RemoteRecipes.ElementAt(index).ToString();
  1006. // if (trayCode == 1)
  1007. // {
  1008. // //粉料仓下发配方
  1009. // if (GVL_SmallStation.GetInstance.IsUseWindSend && GVL_SmallStation.GetInstance.Tray1LogicFinish == 2 && GVL_SmallStation.GetInstance.WindSendDosing == false)
  1010. // {
  1011. // GVL_SmallStation.GetInstance.WindSendDosing = true;
  1012. // WindSendData.TargetRecipeCode = code;
  1013. // WindSendData.IsAllowDosing = true;
  1014. // foreach (var item in RemoteRecipes.ElementAt(index).WindSend)
  1015. // {
  1016. // if (item.RawMaterialName == "0037" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(0).RawMaterialName)
  1017. // {
  1018. // WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight;
  1019. // }
  1020. // if (item.RawMaterialName == "0038" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(1).RawMaterialName)
  1021. // {
  1022. // WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight;
  1023. // }
  1024. // if (item.RawMaterialName == "0039" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(2).RawMaterialName)
  1025. // {
  1026. // WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight;
  1027. // }
  1028. // if (item.RawMaterialName == "0045" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(3).RawMaterialName)
  1029. // {
  1030. // WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight;
  1031. // }
  1032. // if (item.RawMaterialName == "0046" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(4).RawMaterialName)
  1033. // {
  1034. // WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight;
  1035. // }
  1036. // }
  1037. // WindSendDevice.Siemens_PLC_S7.WriteClass<WindSend_Write>(WindSendData, 95);
  1038. // }
  1039. // if (GVL_SmallStation.GetInstance.RecipeProcessStatus[0] == 0)
  1040. // {
  1041. // StockBinInit();
  1042. // GVL_SmallStation.GetInstance.StockBinDosing = 0;
  1043. // HKDevice.IssueRecipeToPlc(RemoteRecipes.ElementAt(index).RawMaterial, 1);
  1044. // HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
  1045. // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 1;
  1046. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成");
  1047. // GVL_SmallStation.GetInstance.time1 = DateTime.Now;
  1048. // }
  1049. // bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3");
  1050. // if (recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 1)
  1051. // {
  1052. // HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", false);
  1053. // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 2;
  1054. // MessageNotify.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成");
  1055. // }
  1056. // if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 2)
  1057. // {
  1058. // if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
  1059. // {
  1060. // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10");
  1061. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
  1062. // if (res > 0 && res is float loc)
  1063. // {
  1064. // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  1065. // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
  1066. // if (weight <= 0)
  1067. // {
  1068. // int i = (int)loc;
  1069. // if (i >= 1 && i <= 8)
  1070. // {
  1071. // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  1072. // MessageNotify.GetInstance.ShowRunLog(commInfo);
  1073. // }
  1074. // else if (i >= 9 && i <= 15)
  1075. // {
  1076. // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  1077. // MessageNotify.GetInstance.ShowRunLog(commInfo1);
  1078. // }
  1079. // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  1080. // }
  1081. // else
  1082. // {
  1083. // if (loc_index >= 0)
  1084. // {
  1085. // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
  1086. // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  1087. // }
  1088. // else
  1089. // {
  1090. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,错误没有找到{(int)loc}号仓的配方");
  1091. // }
  1092. // }
  1093. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,正在配料");
  1094. // }
  1095. // }
  1096. // else if (RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
  1097. // {
  1098. // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
  1099. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
  1100. // if (res > 0 && res is float loc)
  1101. // {
  1102. // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  1103. // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
  1104. // if (weight <= 0)
  1105. // {
  1106. // int i = (int)loc;
  1107. // if (i >= 1 && i <= 8)
  1108. // {
  1109. // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  1110. // MessageNotify.GetInstance.ShowRunLog(commInfo);
  1111. // }
  1112. // else if (i >= 9 && i <= 15)
  1113. // {
  1114. // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  1115. // MessageNotify.GetInstance.ShowRunLog(commInfo1);
  1116. // }
  1117. // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  1118. // }
  1119. // else
  1120. // {
  1121. // if (loc_index >= 0)
  1122. // {
  1123. // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  1124. // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  1125. // }
  1126. // else
  1127. // {
  1128. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,错误没有找到{(int)loc}号仓的配方");
  1129. // }
  1130. // }
  1131. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,正在配料");
  1132. // }
  1133. // }
  1134. // else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
  1135. // {
  1136. // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
  1137. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
  1138. // if (res > 0 && res is float loc)
  1139. // {
  1140. // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  1141. // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
  1142. // if (weight <= 0)
  1143. // {
  1144. // int i = (int)loc;
  1145. // if (i >= 1 && i <= 8)
  1146. // {
  1147. // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  1148. // MessageNotify.GetInstance.ShowRunLog(commInfo);
  1149. // }
  1150. // else if (i >= 9 && i <= 15)
  1151. // {
  1152. // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  1153. // MessageNotify.GetInstance.ShowRunLog(commInfo1);
  1154. // }
  1155. // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  1156. // }
  1157. // else
  1158. // {
  1159. // if (loc_index >= 0)
  1160. // {
  1161. // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  1162. // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  1163. // }
  1164. // else
  1165. // {
  1166. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,错误没有找到{(int)loc}号仓的配方");
  1167. // }
  1168. // }
  1169. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,正在配料");
  1170. // }
  1171. // }
  1172. // else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
  1173. // {
  1174. // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
  1175. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
  1176. // if (res > 0 && res is float loc)
  1177. // {
  1178. // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  1179. // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
  1180. // if (weight <= 0)
  1181. // {
  1182. // int i = (int)loc;
  1183. // if (i >= 1 && i <= 8)
  1184. // {
  1185. // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  1186. // MessageNotify.GetInstance.ShowRunLog(commInfo);
  1187. // }
  1188. // else if (i >= 9 && i <= 15)
  1189. // {
  1190. // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  1191. // MessageNotify.GetInstance.ShowRunLog(commInfo1);
  1192. // }
  1193. // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  1194. // }
  1195. // else
  1196. // {
  1197. // if (loc_index >= 0)
  1198. // {
  1199. // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  1200. // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  1201. // }
  1202. // else
  1203. // {
  1204. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,错误没有找到{(int)loc}号仓的配方");
  1205. // }
  1206. // }
  1207. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,正在配料");
  1208. // }
  1209. // }
  1210. // for (int i = 1; i < 16; i++)
  1211. // {
  1212. // if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
  1213. // {
  1214. // int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
  1215. // if (res >= 0)
  1216. // {
  1217. // Thread.Sleep(GVL_SmallStation.GetInstance.Time);
  1218. // RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
  1219. // bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
  1220. // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}");
  1221. // float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000);
  1222. // int iIndex = Array.FindIndex(Json<DevicePar>.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
  1223. // if (iIndex >= 0)
  1224. // {
  1225. // if (Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange)
  1226. // {
  1227. // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
  1228. // App.Current.Dispatcher.Invoke(() =>
  1229. // {
  1230. // MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning);
  1231. // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
  1232. // });
  1233. // }
  1234. // }
  1235. // if (i >= 1 && i <= 8)
  1236. // {
  1237. // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  1238. // MessageNotify.GetInstance.ShowRunLog(commInfo);
  1239. // }
  1240. // else if (i >= 9 && i <= 15)
  1241. // {
  1242. // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  1243. // MessageNotify.GetInstance.ShowRunLog(commInfo1);
  1244. // }
  1245. // }
  1246. // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  1247. // }
  1248. // }
  1249. // if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1"))))
  1250. // {
  1251. // if (GVL_SmallStation.GetInstance.StockBinDosing > 0)
  1252. // {
  1253. // for (int i = 1; i < 17; i++)
  1254. // {
  1255. // if (GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
  1256. // {
  1257. // MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓");
  1258. // }
  1259. // }
  1260. // }
  1261. // var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
  1262. // foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
  1263. // {
  1264. // MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g");
  1265. // }
  1266. // if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe)
  1267. // {
  1268. // RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
  1269. // RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
  1270. // RecipeFinishInfo.Job_No = (short)trayCode;
  1271. // for (int i = 0; i < 20; i++)
  1272. // {
  1273. // RecipeFinishInfo.Material[i] = new UDT1();
  1274. // }
  1275. // for (int i = 0; i < 10; i++)
  1276. // {
  1277. // RecipeFinishInfo.Powder[i] = new UDT2();
  1278. // }
  1279. // for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
  1280. // {
  1281. // RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
  1282. // RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
  1283. // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001;
  1284. // }
  1285. // for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++)
  1286. // {
  1287. // RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
  1288. // }
  1289. // double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds;
  1290. // RecipeFinishInfo.Ask_For_Finish = true;
  1291. // RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
  1292. // SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
  1293. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
  1294. // }
  1295. // else
  1296. // {
  1297. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
  1298. // }
  1299. // GVL_SmallStation.GetInstance.WindSendDosing = false;
  1300. // App.Current.Dispatcher.Invoke(() =>
  1301. // {
  1302. // Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
  1303. // });
  1304. // RecipeQueueTray1.TryDequeue(out code);
  1305. // HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
  1306. // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
  1307. // }
  1308. // }
  1309. // }
  1310. // }
  1311. // }
  1312. //} //if (RecipeQueueTray1.Count > 0) /*&& GVL_SmallStation.GetInstance.Tray1LogicFinish == 2*/ //不需要等待AGV到位,就给PLC下发配方
  1313. //{
  1314. // foreach (var queue in RecipeQueueTray1)
  1315. // {
  1316. // int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == queue.ToString());
  1317. // if (index >= 0 && index < RemoteRecipes.Count)
  1318. // {
  1319. // int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
  1320. // string code = RemoteRecipes.ElementAt(index).RecipeCode;
  1321. // string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
  1322. // string windSend = RemoteRecipes.ElementAt(index).ToString();
  1323. // if (trayCode == 1)
  1324. // {
  1325. // //粉料仓下发配方
  1326. // if (GVL_SmallStation.GetInstance.IsUseWindSend && GVL_SmallStation.GetInstance.Tray1LogicFinish == 2 && GVL_SmallStation.GetInstance.WindSendDosing == false)
  1327. // {
  1328. // GVL_SmallStation.GetInstance.WindSendDosing = true;
  1329. // WindSendData.TargetRecipeCode = code;
  1330. // WindSendData.IsAllowDosing = true;
  1331. // foreach (var item in RemoteRecipes.ElementAt(index).WindSend)
  1332. // {
  1333. // if (item.RawMaterialName == "0037" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(0).RawMaterialName)
  1334. // {
  1335. // WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight;
  1336. // }
  1337. // if (item.RawMaterialName == "0038" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(1).RawMaterialName)
  1338. // {
  1339. // WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight;
  1340. // }
  1341. // if (item.RawMaterialName == "0039" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(2).RawMaterialName)
  1342. // {
  1343. // WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight;
  1344. // }
  1345. // if (item.RawMaterialName == "0045" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(3).RawMaterialName)
  1346. // {
  1347. // WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight;
  1348. // }
  1349. // if (item.RawMaterialName == "0046" || item.RawMaterialName == Json<DevicePar>.Data.windSendRawMaterial.ElementAt(4).RawMaterialName)
  1350. // {
  1351. // WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight;
  1352. // }
  1353. // }
  1354. // WindSendDevice.Siemens_PLC_S7.WriteClass<WindSend_Write>(WindSendData, 95);
  1355. // }
  1356. // if (GVL_SmallStation.GetInstance.RecipeProcessStatus[0] == 0)
  1357. // {
  1358. // StockBinInit();
  1359. // GVL_SmallStation.GetInstance.StockBinDosing = 0;
  1360. // HKDevice.IssueRecipeToPlc(RemoteRecipes.ElementAt(index).RawMaterial, 1);
  1361. // HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
  1362. // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 1;
  1363. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成");
  1364. // GVL_SmallStation.GetInstance.time1 = DateTime.Now;
  1365. // }
  1366. // bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3");
  1367. // if (recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 1)
  1368. // {
  1369. // HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", false);
  1370. // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 2;
  1371. // MessageNotify.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成");
  1372. // }
  1373. // if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 2)
  1374. // {
  1375. // if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
  1376. // {
  1377. // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10");
  1378. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
  1379. // if (res > 0 && res is float loc)
  1380. // {
  1381. // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  1382. // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
  1383. // if (weight <= 0)
  1384. // {
  1385. // int i = (int)loc;
  1386. // if (i >= 1 && i <= 8)
  1387. // {
  1388. // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  1389. // MessageNotify.GetInstance.ShowRunLog(commInfo);
  1390. // }
  1391. // else if (i >= 9 && i <= 15)
  1392. // {
  1393. // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  1394. // MessageNotify.GetInstance.ShowRunLog(commInfo1);
  1395. // }
  1396. // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  1397. // }
  1398. // else
  1399. // {
  1400. // if (loc_index >= 0)
  1401. // {
  1402. // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
  1403. // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  1404. // }
  1405. // else
  1406. // {
  1407. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,错误没有找到{(int)loc}号仓的配方");
  1408. // }
  1409. // }
  1410. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,正在配料");
  1411. // }
  1412. // }
  1413. // else if (RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
  1414. // {
  1415. // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
  1416. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
  1417. // if (res > 0 && res is float loc)
  1418. // {
  1419. // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  1420. // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
  1421. // if (weight <= 0)
  1422. // {
  1423. // int i = (int)loc;
  1424. // if (i >= 1 && i <= 8)
  1425. // {
  1426. // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  1427. // MessageNotify.GetInstance.ShowRunLog(commInfo);
  1428. // }
  1429. // else if (i >= 9 && i <= 15)
  1430. // {
  1431. // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  1432. // MessageNotify.GetInstance.ShowRunLog(commInfo1);
  1433. // }
  1434. // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  1435. // }
  1436. // else
  1437. // {
  1438. // if (loc_index >= 0)
  1439. // {
  1440. // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  1441. // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  1442. // }
  1443. // else
  1444. // {
  1445. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,错误没有找到{(int)loc}号仓的配方");
  1446. // }
  1447. // }
  1448. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,正在配料");
  1449. // }
  1450. // }
  1451. // else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
  1452. // {
  1453. // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
  1454. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
  1455. // if (res > 0 && res is float loc)
  1456. // {
  1457. // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  1458. // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
  1459. // if (weight <= 0)
  1460. // {
  1461. // int i = (int)loc;
  1462. // if (i >= 1 && i <= 8)
  1463. // {
  1464. // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  1465. // MessageNotify.GetInstance.ShowRunLog(commInfo);
  1466. // }
  1467. // else if (i >= 9 && i <= 15)
  1468. // {
  1469. // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  1470. // MessageNotify.GetInstance.ShowRunLog(commInfo1);
  1471. // }
  1472. // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  1473. // }
  1474. // else
  1475. // {
  1476. // if (loc_index >= 0)
  1477. // {
  1478. // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  1479. // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  1480. // }
  1481. // else
  1482. // {
  1483. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,错误没有找到{(int)loc}号仓的配方");
  1484. // }
  1485. // }
  1486. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,正在配料");
  1487. // }
  1488. // }
  1489. // else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
  1490. // {
  1491. // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
  1492. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
  1493. // if (res > 0 && res is float loc)
  1494. // {
  1495. // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  1496. // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
  1497. // if (weight <= 0)
  1498. // {
  1499. // int i = (int)loc;
  1500. // if (i >= 1 && i <= 8)
  1501. // {
  1502. // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  1503. // MessageNotify.GetInstance.ShowRunLog(commInfo);
  1504. // }
  1505. // else if (i >= 9 && i <= 15)
  1506. // {
  1507. // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  1508. // MessageNotify.GetInstance.ShowRunLog(commInfo1);
  1509. // }
  1510. // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  1511. // }
  1512. // else
  1513. // {
  1514. // if (loc_index >= 0)
  1515. // {
  1516. // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  1517. // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  1518. // }
  1519. // else
  1520. // {
  1521. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,错误没有找到{(int)loc}号仓的配方");
  1522. // }
  1523. // }
  1524. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,正在配料");
  1525. // }
  1526. // }
  1527. // for (int i = 1; i < 16; i++)
  1528. // {
  1529. // if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
  1530. // {
  1531. // int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
  1532. // if (res >= 0)
  1533. // {
  1534. // Thread.Sleep(GVL_SmallStation.GetInstance.Time);
  1535. // RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
  1536. // bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
  1537. // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}");
  1538. // float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000);
  1539. // int iIndex = Array.FindIndex(Json<DevicePar>.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
  1540. // if (iIndex >= 0)
  1541. // {
  1542. // if (Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange)
  1543. // {
  1544. // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
  1545. // App.Current.Dispatcher.Invoke(() =>
  1546. // {
  1547. // MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning);
  1548. // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
  1549. // });
  1550. // }
  1551. // }
  1552. // if (i >= 1 && i <= 8)
  1553. // {
  1554. // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  1555. // MessageNotify.GetInstance.ShowRunLog(commInfo);
  1556. // }
  1557. // else if (i >= 9 && i <= 15)
  1558. // {
  1559. // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  1560. // MessageNotify.GetInstance.ShowRunLog(commInfo1);
  1561. // }
  1562. // }
  1563. // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
  1564. // }
  1565. // }
  1566. // if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1"))))
  1567. // {
  1568. // if (GVL_SmallStation.GetInstance.StockBinDosing > 0)
  1569. // {
  1570. // for (int i = 1; i < 17; i++)
  1571. // {
  1572. // if (GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
  1573. // {
  1574. // MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓");
  1575. // }
  1576. // }
  1577. // }
  1578. // var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
  1579. // foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
  1580. // {
  1581. // MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g");
  1582. // }
  1583. // if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe)
  1584. // {
  1585. // RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
  1586. // RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
  1587. // RecipeFinishInfo.Job_No = (short)trayCode;
  1588. // for (int i = 0; i < 20; i++)
  1589. // {
  1590. // RecipeFinishInfo.Material[i] = new UDT1();
  1591. // }
  1592. // for (int i = 0; i < 10; i++)
  1593. // {
  1594. // RecipeFinishInfo.Powder[i] = new UDT2();
  1595. // }
  1596. // for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
  1597. // {
  1598. // RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
  1599. // RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
  1600. // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001;
  1601. // }
  1602. // for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++)
  1603. // {
  1604. // RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
  1605. // }
  1606. // double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds;
  1607. // RecipeFinishInfo.Ask_For_Finish = true;
  1608. // RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
  1609. // SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
  1610. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
  1611. // }
  1612. // else
  1613. // {
  1614. // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
  1615. // }
  1616. // GVL_SmallStation.GetInstance.WindSendDosing = false;
  1617. // App.Current.Dispatcher.Invoke(() =>
  1618. // {
  1619. // Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
  1620. // });
  1621. // RecipeQueueTray1.TryDequeue(out code);
  1622. // HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
  1623. // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
  1624. // }
  1625. // }
  1626. // }
  1627. // }
  1628. // }
  1629. //}
  1630. #endregion
  1631. #region 托盘2配料 ---硬件不具备条件,不使用
  1632. //if (RecipeQueueTray2.Count > 0 && GVL_SmallStation.GetInstance.Tray2LogicFinish == 2)
  1633. //{
  1634. // int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray2.ElementAt(0));
  1635. // if (index >= 0 && index < RemoteRecipes.Count)
  1636. // {
  1637. // string code = RemoteRecipes.ElementAt(index).RecipeCode;
  1638. // int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
  1639. // string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
  1640. // if (trayCode == 2)
  1641. // {
  1642. // if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 0)
  1643. // {
  1644. // StockBinInit();
  1645. // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},初始化");
  1646. // foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
  1647. // {
  1648. // HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation, 2);
  1649. // }
  1650. // HKDevice.HK_PLC_S7.Write("DB4.DBX1.4", true);
  1651. // GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 1;
  1652. // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},下发完成");
  1653. // }
  1654. // if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.4") && GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 1)
  1655. // {
  1656. // HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", false);
  1657. // GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 2;
  1658. // MessageNotify.GetInstance.ShowRunLog($"配方:{recipeName},plc端 配方接收完成");
  1659. // }
  1660. // if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 2)
  1661. // {
  1662. // if (RTrig.GetInstance("DB3.DBX50.4").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.4")))
  1663. // {
  1664. // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD26");
  1665. // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{res}料仓,允许配料");
  1666. // if (res > 0 && res is float loc)
  1667. // {
  1668. // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  1669. // double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  1670. // if (loc_index >= 0)
  1671. // {
  1672. // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量
  1673. // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  1674. // }
  1675. // GVL_SmallStation.GetInstance.DosingTray2 = true;
  1676. // GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
  1677. // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成");
  1678. // }
  1679. // }
  1680. // else if (RTrig.GetInstance("DB3.DBX50.5").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.5")))
  1681. // {
  1682. // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD30");
  1683. // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},2号桶,{res}料仓,允许配料");
  1684. // if (res > 0 && res is float loc)
  1685. // {
  1686. // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  1687. // double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  1688. // if (loc_index >= 0)
  1689. // {
  1690. // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
  1691. // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  1692. // }
  1693. // GVL_SmallStation.GetInstance.DosingTray2 = true;
  1694. // GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
  1695. // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成");
  1696. // }
  1697. // }
  1698. // else if (RTrig.GetInstance("DB3.DBX50.6").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.6")))
  1699. // {
  1700. // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD34");
  1701. // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},3号桶,{res}料仓,允许配料");
  1702. // if (res > 0 && res is float loc)
  1703. // {
  1704. // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  1705. // double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  1706. // if (loc_index >= 0)
  1707. // {
  1708. // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
  1709. // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  1710. // }
  1711. // GVL_SmallStation.GetInstance.DosingTray2 = true;
  1712. // GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
  1713. // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成");
  1714. // }
  1715. // }
  1716. // else if (RTrig.GetInstance("DB3.DBX50.7").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.7")))
  1717. // {
  1718. // var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD38");
  1719. // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},4号桶,{res}料仓,允许配料");
  1720. // if (res > 0 && res is float loc)
  1721. // {
  1722. // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  1723. // double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  1724. // if (loc_index >= 0)
  1725. // {
  1726. // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
  1727. // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  1728. // }
  1729. // GVL_SmallStation.GetInstance.DosingTray2 = true;
  1730. // GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
  1731. // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成");
  1732. // }
  1733. // }
  1734. // if (GVL_SmallStation.GetInstance.DosingTray2 == true && GVL_SmallStation.GetInstance.DosingTray1 == false && GVL_SmallStation.GetInstance.DosingTray2Loc > 0 && GVL_SmallStation.GetInstance.DosingTray2Loc < 16)
  1735. // {
  1736. // Thread.Sleep(GVL_SmallStation.GetInstance.Time);
  1737. // int i = GVL_SmallStation.GetInstance.DosingTray2Loc;
  1738. // if (RTrig.GetInstance("Tray2StatusDevice" + i).Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
  1739. // {
  1740. // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{recipeName},{i}号仓,配料完成");
  1741. // int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
  1742. // RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
  1743. // bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
  1744. // float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight);
  1745. // int iIndex = Array.FindIndex(Json<DevicePar>.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
  1746. // if (iIndex >= 0)
  1747. // {
  1748. // if (Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange)
  1749. // {
  1750. // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
  1751. // App.Current.Dispatcher.Invoke(() =>
  1752. // {
  1753. // MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json<DevicePar>.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning);
  1754. // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
  1755. // });
  1756. // }
  1757. // }
  1758. // if (info)
  1759. // {
  1760. // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送成功");
  1761. // }
  1762. // else
  1763. // {
  1764. // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送失败");
  1765. // }
  1766. // if (i >= 1 && i <= 8)
  1767. // {
  1768. // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
  1769. // MessageNotify.GetInstance.ShowRunLog(commInfo);
  1770. // }
  1771. // else if (i >= 9 && i <= 15)
  1772. // {
  1773. // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
  1774. // MessageNotify.GetInstance.ShowRunLog(commInfo1);
  1775. // }
  1776. // GVL_SmallStation.GetInstance.DosingTray2 = false;
  1777. // GVL_SmallStation.GetInstance.DosingTray2Loc = 0;
  1778. // }
  1779. // }
  1780. // if (RTrig.GetInstance("DB3.DBX1.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.2")))
  1781. // {
  1782. // var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
  1783. // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方{res.RecipeName},配料完成");
  1784. // RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
  1785. // RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
  1786. // for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
  1787. // {
  1788. // RecipeFinishInfo.Material[i] = new UDT1();
  1789. // RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
  1790. // RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
  1791. // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
  1792. // }
  1793. // if (SiemensDevice.IsConnected)
  1794. // {
  1795. // RecipeFinishInfo.Ask_For_Finish = true;
  1796. // SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
  1797. // }
  1798. // App.Current.Dispatcher.Invoke(() =>
  1799. // {
  1800. // Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
  1801. // });
  1802. // RecipeQueueTray2.TryDequeue(out code);
  1803. // HKDevice.HK_PLC_S7.Write("DB3.DBX1.2", false);
  1804. // GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
  1805. // }
  1806. // }
  1807. // }
  1808. // }
  1809. //}
  1810. #endregion
  1811. }
  1812. private void StockBinInit()
  1813. {
  1814. for (int i = 1; i < 16; i++)
  1815. {
  1816. if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)
  1817. {
  1818. DeviceInquire.GetInstance.GetDevice(i).StatusReset();
  1819. }
  1820. }
  1821. }
  1822. /// <summary>
  1823. /// 料仓的位置和原料名称的对应
  1824. /// </summary>
  1825. public void StockBinNameWithPos()
  1826. {
  1827. RawMaterialsNamePos.Clear();
  1828. foreach (var material in RawMaterialsInfo)
  1829. {
  1830. if (!string.IsNullOrEmpty(material.RawMaterialName))
  1831. {
  1832. if (!RawMaterialsNamePos.ContainsKey(material.RawMaterialName))
  1833. {
  1834. RawMaterialsNamePos.Add(material.RawMaterialName, (short)material.RawMaterialLocation);
  1835. }
  1836. }
  1837. }
  1838. }
  1839. /// <summary>
  1840. /// PLC的DB3变量列表
  1841. /// </summary>
  1842. public void PlcVarMonitor()
  1843. {
  1844. foreach (PropertyInfo item in typeof(PlcReadAddressDB3).GetProperties())
  1845. {
  1846. if (Attribute.IsDefined(item, typeof(VarCommAttribute)))
  1847. {
  1848. CommData.Add(new PlcInfos()
  1849. {
  1850. Count = CommData.Count + 1,
  1851. Name = item.Name,
  1852. Address = item.GetCustomAttribute<VarCommAttribute>().Address,
  1853. Type = item.PropertyType.ToString(),
  1854. Describe = item.GetCustomAttribute<VarCommAttribute>().Describe,
  1855. Value = item.GetValue(GVL_SmallStation.GetInstance.plcReadDataDB3).ToString(),
  1856. });
  1857. }
  1858. }
  1859. foreach (PropertyInfo item in typeof(GVL_SmallStation).GetProperties())
  1860. {
  1861. if (Attribute.IsDefined(item, typeof(VarCommAttribute)))
  1862. {
  1863. ProcessVar.Add(new PlcInfos()
  1864. {
  1865. Count = ProcessVar.Count + 1,
  1866. Name = item.Name,
  1867. Type = item.PropertyType.ToString(),
  1868. Address = item.GetCustomAttribute<VarCommAttribute>().Address,
  1869. Describe = item.GetCustomAttribute<VarCommAttribute>().Describe,
  1870. Value = item.GetValue(GVL_SmallStation.GetInstance).ToString()
  1871. });
  1872. }
  1873. }
  1874. }
  1875. public void RegisterInit()
  1876. {
  1877. //手动控制气缸 DB5.DBX0.0~DB5.DBX4.5
  1878. ActionManage.GetInstance.Register(new Action<object>((o) =>
  1879. {
  1880. if (o != null)
  1881. {
  1882. if (o.ToString().Contains("升降气缸"))
  1883. {
  1884. int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2));
  1885. if (index >= 1 && index <= 15)
  1886. {
  1887. string address = "DB5.DBX" + (index / 8) + "." + (index % 8 - 1);
  1888. if (index == 8) address = "DB5.DBX0.7";
  1889. HKDevice.HK_PLC_S7.Write<bool>(address, true);
  1890. MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:{address},值:true");
  1891. }
  1892. }
  1893. else if (o.ToString().Contains("阻挡气缸"))
  1894. {
  1895. int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2));
  1896. if (index >= 1 && index <= 15)
  1897. {
  1898. string address = "";
  1899. if (index == 1) address = "DB5.DBX1.7";
  1900. if (index == 2) address = "DB5.DBX2.0";
  1901. if (index == 3) address = "DB5.DBX2.1";
  1902. if (index == 4) address = "DB5.DBX2.2";
  1903. if (index == 5) address = "DB5.DBX2.3";
  1904. if (index == 6) address = "DB5.DBX2.4";
  1905. if (index == 7) address = "DB5.DBX2.5";
  1906. if (index == 8) address = "DB5.DBX2.6";
  1907. if (index == 9) address = "DB5.DBX2.7";
  1908. if (index == 10) address = "DB5.DBX3.0";
  1909. if (index == 11) address = "DB5.DBX3.1";
  1910. if (index == 12) address = "DB5.DBX3.2";
  1911. if (index == 13) address = "DB5.DBX3.3";
  1912. if (index == 14) address = "DB5.DBX3.4";
  1913. if (index == 15) address = "DB5.DBX3.5";
  1914. HKDevice.HK_PLC_S7.Write<bool>(address, true);
  1915. }
  1916. }
  1917. else if (o.ToString().Contains("进料桶顶升气缸"))
  1918. {
  1919. HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", false);//默认顶升
  1920. MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.6,值:false");
  1921. }
  1922. else if (o.ToString().Contains("出料桶顶升气缸1"))
  1923. {
  1924. HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", true);
  1925. MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.7,值:true");
  1926. }
  1927. else if (o.ToString().Contains("出料桶顶升气缸2"))
  1928. {
  1929. HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", true);
  1930. MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.0,值:true");
  1931. }
  1932. else if (o.ToString().Contains("出料桶顶升气缸3"))
  1933. {
  1934. HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", true);
  1935. MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.1,值:true");
  1936. }
  1937. else if (o.ToString().Contains("托盘气缸1_1"))
  1938. {
  1939. HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", false);//默认伸出
  1940. }
  1941. else if (o.ToString().Contains("托盘气缸1_2"))
  1942. {
  1943. HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", false);
  1944. }
  1945. else if (o.ToString().Contains("托盘气缸2_1"))
  1946. {
  1947. HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", false);
  1948. }
  1949. else if (o.ToString().Contains("托盘气缸2_2"))
  1950. {
  1951. HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", false);
  1952. }
  1953. }
  1954. }), "ManualOpen", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
  1955. ActionManage.GetInstance.Register(new Action<object>((o) =>
  1956. {
  1957. if (o != null)
  1958. {
  1959. if (o.ToString().Contains("升降气缸"))
  1960. {
  1961. int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2));
  1962. if (index >= 1 && index <= 15)
  1963. {
  1964. string address = "DB5.DBX" + (index / 8) + "." + (index % 8 - 1);
  1965. if (index == 8) address = "DB5.DBX0.7";
  1966. HKDevice.HK_PLC_S7.Write<bool>(address, false);
  1967. MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:{address},值:false");
  1968. }
  1969. }
  1970. else if (o.ToString().Contains("阻挡气缸"))
  1971. {
  1972. int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2));
  1973. if (index >= 1 && index <= 15)
  1974. {
  1975. string address = "";
  1976. if (index == 1) address = "DB5.DBX1.7";
  1977. if (index == 2) address = "DB5.DBX2.0";
  1978. if (index == 3) address = "DB5.DBX2.1";
  1979. if (index == 4) address = "DB5.DBX2.2";
  1980. if (index == 5) address = "DB5.DBX2.3";
  1981. if (index == 6) address = "DB5.DBX2.4";
  1982. if (index == 7) address = "DB5.DBX2.5";
  1983. if (index == 8) address = "DB5.DBX2.6";
  1984. if (index == 9) address = "DB5.DBX2.7";
  1985. if (index == 10) address = "DB5.DBX3.0";
  1986. if (index == 11) address = "DB5.DBX3.1";
  1987. if (index == 12) address = "DB5.DBX3.2";
  1988. if (index == 13) address = "DB5.DBX3.3";
  1989. if (index == 14) address = "DB5.DBX3.4";
  1990. if (index == 15) address = "DB5.DBX3.5";
  1991. HKDevice.HK_PLC_S7.Write<bool>(address, false);
  1992. }
  1993. }
  1994. else if (o.ToString().Contains("进料桶顶升气缸"))
  1995. {
  1996. HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", true);
  1997. MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.6,值:true");
  1998. }
  1999. else if (o.ToString().Contains("出料桶顶升气缸1"))
  2000. {
  2001. HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", false);
  2002. MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.7,值:false");
  2003. }
  2004. else if (o.ToString().Contains("出料桶顶升气缸2"))
  2005. {
  2006. HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", false);
  2007. MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.0,值:false");
  2008. }
  2009. else if (o.ToString().Contains("出料桶顶升气缸3"))
  2010. {
  2011. HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", false);
  2012. MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.1,值:false");
  2013. }
  2014. else if (o.ToString().Contains("托盘气缸1_1"))
  2015. {
  2016. HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", true);
  2017. }
  2018. else if (o.ToString().Contains("托盘气缸1_2"))
  2019. {
  2020. HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", true);
  2021. }
  2022. else if (o.ToString().Contains("托盘气缸2_1"))
  2023. {
  2024. HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", true);
  2025. }
  2026. else if (o.ToString().Contains("托盘气缸2_2"))
  2027. {
  2028. HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", true);
  2029. }
  2030. }
  2031. }), "ManualClose", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
  2032. //手动控制电机轴 DB5.DBX4.6~DB5.DBX5.2
  2033. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX4.6", true); }), "StartAxisLoadCommand", true);
  2034. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX4.6", false); }), "StopAxisLoadCommand", true);
  2035. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX4.7", true); }), "StartAxisMidCommand", true);
  2036. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX4.7", false); }), "StopAxisMidCommand", true);
  2037. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX5.0", true); }), "StartAxisUnLoadCommand", true);
  2038. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX5.0", false); }), "StopAxisUnLoadCommand", true);
  2039. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX5.1", true); }), "StartAxis1Command", true);
  2040. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX5.1", false); }), "StopAxis1Command", true);
  2041. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX5.2", true); }), "StartAxis2Command", true);
  2042. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX5.2", false); }), "StopAxis2Command", true);
  2043. //西门子配方处理
  2044. ActionManage.GetInstance.Register(new Action<object>((res) =>
  2045. {
  2046. ObservableCollection<RemoteRecipeRawMaterial> RawMaterials = new ObservableCollection<RemoteRecipeRawMaterial>();
  2047. ObservableCollection<WindSendRawMaterial> WindSendData = new ObservableCollection<WindSendRawMaterial>();
  2048. if (SiemensDevice.IsConnected)
  2049. {
  2050. if (res != null && res is XL_Start_DB recipe)
  2051. {
  2052. if (!string.IsNullOrEmpty(recipe.RecipeCode))
  2053. {
  2054. RawMaterials.Clear();
  2055. for (int i = 0; i < GVL_SmallStation.Max_DosingSotckBinNum; i++)
  2056. {
  2057. if (!string.IsNullOrEmpty(recipe.Material[i].Material_Name))
  2058. {
  2059. if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name))
  2060. {
  2061. RawMaterials.Add(new RemoteRecipeRawMaterial()
  2062. {
  2063. RawMaterialName = recipe.Material[i].Material_Name,
  2064. RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum,
  2065. RawMaterialWeight = recipe.Material[i].Material_Weight,
  2066. RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name]
  2067. });
  2068. }
  2069. else
  2070. {
  2071. MessageNotify.GetInstance.ShowRunLog($"原料:{recipe.Material[i].Material_Name},不在配料表");
  2072. }
  2073. }
  2074. else
  2075. {
  2076. break;
  2077. }
  2078. }
  2079. for (int i = 0; i < GVL_SmallStation.Max_PowderSotckBinNum; i++)
  2080. {
  2081. if (!string.IsNullOrEmpty(recipe.Powder[i].Powder_Name))
  2082. {
  2083. WindSendData.Add(new WindSendRawMaterial()
  2084. {
  2085. RawMaterialName = recipe.Powder[i].Powder_Name,
  2086. RawMaterialWeight = recipe.Powder[i].Powder_Weight
  2087. });
  2088. }
  2089. else
  2090. {
  2091. break;
  2092. }
  2093. }
  2094. App.Current.Dispatcher.Invoke(() => {
  2095. Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
  2096. {
  2097. RecipeName = recipe.RecipeName,
  2098. RecipeCode = recipe.RecipeCode,
  2099. RawMaterial = RawMaterials,
  2100. TrayCode = recipe.StockCode,
  2101. WindSend = WindSendData
  2102. });
  2103. });
  2104. }
  2105. }
  2106. }
  2107. }), "SiemensRecipeRecive", true);
  2108. ActionManage.GetInstance.Register(new Action<object>((res) =>
  2109. {
  2110. // if (SiemensDevice.IsConnected)
  2111. // {
  2112. // if (res != null && res is RemoteRecipeData recipe)
  2113. // {
  2114. // RecipeFinishInfo.Order_No = recipe.RecipeCode;
  2115. // RecipeFinishInfo.Product_Code = recipe.RecipeName;
  2116. // RecipeFinishInfo.Job_No = (short)recipe.TrayCode;
  2117. // for (int i = 0; i < recipe.RawMaterial.Count; i++)
  2118. // {
  2119. // RecipeFinishInfo.Material[i] = new UDT1();
  2120. // RecipeFinishInfo.Material[i].Material_Name = recipe.RawMaterial.ElementAt(i).RawMaterialName;
  2121. // RecipeFinishInfo.Material[i].Material_BarrelNum = recipe.RawMaterial.ElementAt(i).RawMaterialBarrelNum;
  2122. // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = recipe.RawMaterial.ElementAt(i).Laying_Off_Weight;
  2123. // }
  2124. // for (int i = 0; i < recipe.WindSend.Count; i++)
  2125. // {
  2126. // RecipeFinishInfo.Powder[i] = new UDT2();
  2127. // RecipeFinishInfo.Powder[i].Powder_Name = recipe.RawMaterial.ElementAt(i).RawMaterialName;
  2128. // RecipeFinishInfo.Powder[i].Powder_Weight = recipe.RawMaterial.ElementAt(i).Laying_Off_Weight;
  2129. // }
  2130. // if (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus == 6)
  2131. // {
  2132. // GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 7;
  2133. // RecipeFinishInfo.Ask_For_Finish = true;
  2134. // SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
  2135. // }
  2136. // }
  2137. // }
  2138. }), "SiemensRecipeFinish", true);
  2139. //将本地配方发送到西门子配方里,执行配料
  2140. ActionManage.GetInstance.Register(new Action<Object>((res) =>
  2141. {
  2142. if (res != null && res is RemoteRecipeData recipe)
  2143. {
  2144. Json<RemoteRecipeDataColl>.Data.Recipes.Add(recipe);
  2145. }
  2146. }), "LocalSimulationRecipeIssue", true);
  2147. //手动控制系统模式
  2148. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.0", true); }), "SystemStart", true);
  2149. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.0", false); }), "SystemStop", true);
  2150. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.2", true); }), "SystemPause", true);
  2151. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.2", false); }), "SystemReset", true);
  2152. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.1", false); }), "SystemAutoMode", true);
  2153. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.1", true); }), "SystemDebugMode", true);
  2154. //流程控制
  2155. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.3", true); }), "ManualSystemReset", true);
  2156. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.4", true); }), "CLearRecipeInfo", true);
  2157. ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX0.7", true); }), "AGVPutTrayFinish", true);
  2158. ActionManage.GetInstance.Register(new Action(() =>
  2159. {
  2160. Json<RemoteRecipeDataColl>.Data.Recipes.Clear();
  2161. GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0;
  2162. GVL_SmallStation.GetInstance.Order_Cancel = false;
  2163. GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
  2164. GVL_SmallStation.GetInstance.OrderCancelStep = 0;
  2165. RecipeQueueTray1.Clear();
  2166. RecipeQueueTray2.Clear();
  2167. GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
  2168. GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
  2169. GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
  2170. GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;
  2171. StockBinInit();
  2172. MessageNotify.GetInstance.ShowRunLog("系统流程复位,等待西门子重新下发订单");
  2173. }), "BPASystemReset", true);
  2174. //往海科PLC写值
  2175. ActionManage.GetInstance.Register(new Action<Object>((o) =>
  2176. {
  2177. if (o != null && o is HKDeviceWrite data)
  2178. {
  2179. if (data.PlcVarType == PlcVarType.Bool)
  2180. {
  2181. bool value = (bool)data.Value;
  2182. HKDevice.HK_PLC_S7.Write<bool>(data.Address , value);
  2183. }
  2184. else if (data.PlcVarType == PlcVarType.Byte)
  2185. {
  2186. byte value = (byte)data.Value;
  2187. HKDevice.HK_PLC_S7.Write<byte>(data.Address, value);
  2188. }
  2189. else if (data.PlcVarType == PlcVarType.Int)
  2190. {
  2191. short value = (short)data.Value;
  2192. HKDevice.HK_PLC_S7.Write<short>(data.Address, value);
  2193. }
  2194. else if (data.PlcVarType == PlcVarType.Dint)
  2195. {
  2196. int value = (int)data.Value;
  2197. HKDevice.HK_PLC_S7.Write<int>(data.Address, value);
  2198. }
  2199. else if (data.PlcVarType == PlcVarType.Real)
  2200. {
  2201. float value = (float)data.Value;
  2202. HKDevice.HK_PLC_S7.Write<float>(data.Address, value);
  2203. }
  2204. }
  2205. }), "PLCWrite", true);
  2206. //电机速度
  2207. ActionManage.GetInstance.Register(new Action<object>((o) =>
  2208. {
  2209. if (o != null && o is short value)
  2210. {
  2211. HKDevice.HK_PLC_S7.Write("DB47.DBW8", value);
  2212. }
  2213. }), "AxisLoadSpeedSet", true);
  2214. ActionManage.GetInstance.Register(new Action<object>((o) =>
  2215. {
  2216. if (o != null && o is short value)
  2217. {
  2218. HKDevice.HK_PLC_S7.Write("DB47.DBW10", value);
  2219. }
  2220. }), "AxisMidSpeedSet", true);
  2221. ActionManage.GetInstance.Register(new Action<object>((o) =>
  2222. {
  2223. if (o != null && o is short value)
  2224. {
  2225. HKDevice.HK_PLC_S7.Write("DB47.DBW12", value);
  2226. }
  2227. }), "AxisUnLoadSpeedSet", true);
  2228. ActionManage.GetInstance.Register(new Action<object>((o) =>
  2229. {
  2230. if (o != null && o is float value)
  2231. {
  2232. HKDevice.HK_PLC_S7.Write("DB47.DBD0", value);
  2233. }
  2234. }), "Axis1SpeedSet", true);
  2235. ActionManage.GetInstance.Register(new Action<object>((o) =>
  2236. {
  2237. if (o != null && o is float value)
  2238. {
  2239. HKDevice.HK_PLC_S7.Write("DB47.DBD4", value);
  2240. }
  2241. }), "Axis2SpeedSet", true);
  2242. //机器人的操作
  2243. ActionManage.GetInstance.Register(new Action<object>((o) =>
  2244. {
  2245. if (o != null && o is string address)
  2246. {
  2247. HKDevice.HK_PLC_S7.Write(address, true);
  2248. }
  2249. }), "RobotSendTrueCommand", true);
  2250. ActionManage.GetInstance.Register(new Action<object>((o) =>
  2251. {
  2252. if (o != null && o is string address)
  2253. {
  2254. HKDevice.HK_PLC_S7.Write(address, false);
  2255. }
  2256. }), "RobotSendFalseCommand", true);
  2257. ActionManage.GetInstance.Register(new Action<object>((o) =>
  2258. {
  2259. if (o != null && o is short Value)
  2260. {
  2261. HKDevice.HK_PLC_S7.Write("DB4.DBB102", (byte)Value);
  2262. }
  2263. }), "RobotSetProgramNum", true);
  2264. }
  2265. public void DeviceConnect()
  2266. {
  2267. try
  2268. {
  2269. if (Json<DevicePar>.Data.deviceConnectPar.HKPlcConnect)
  2270. {
  2271. HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
  2272. if (HKDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科plc连接成功");
  2273. }
  2274. }
  2275. catch (Exception ex)
  2276. {
  2277. MessageNotify.GetInstance.ShowAlarmLog("海科plc连接失败,等待重新连接");
  2278. }
  2279. finally
  2280. {
  2281. HKDevice.Init();
  2282. MessageNotify.GetInstance.ShowRunLog("海科plc初始化完成");
  2283. }
  2284. try
  2285. {
  2286. if (Json<DevicePar>.Data.deviceConnectPar.SiemensConnect)
  2287. {
  2288. SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
  2289. if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功");
  2290. }
  2291. }
  2292. catch (Exception ex)
  2293. {
  2294. MessageNotify.GetInstance.ShowAlarmLog("西门子plc连接失败,等待重新连接");
  2295. }
  2296. finally
  2297. {
  2298. SiemensDevice.Init();
  2299. MessageNotify.GetInstance.ShowRunLog("西门子plc初始化完成");
  2300. }
  2301. try
  2302. {
  2303. if (Json<DevicePar>.Data.deviceConnectPar.WindSendConnect)
  2304. {
  2305. WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP);
  2306. if (WindSendDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("风送plc连接成功");
  2307. }
  2308. }
  2309. catch (Exception ex)
  2310. {
  2311. MessageNotify.GetInstance.ShowAlarmLog("粉料plc连接失败,等待重新连接");
  2312. }
  2313. finally
  2314. {
  2315. WindSendDevice.Init();
  2316. MessageNotify.GetInstance.ShowRunLog("风送粉料plc初始化完成");
  2317. }
  2318. ThreadManage.GetInstance().StartLong(new Action(() =>
  2319. {
  2320. try
  2321. {
  2322. if (!HKDevice.IsConnected && Json<DevicePar>.Data.deviceConnectPar.HKPlcConnect)
  2323. {
  2324. HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
  2325. if (HKDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接成功");
  2326. }
  2327. }
  2328. catch (Exception ex)
  2329. {
  2330. }
  2331. try
  2332. {
  2333. if (!SiemensDevice.IsConnected && Json<DevicePar>.Data.deviceConnectPar.SiemensConnect)
  2334. {
  2335. SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
  2336. if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子PLC重新连接成功");
  2337. }
  2338. }
  2339. catch (Exception ex)
  2340. {
  2341. }
  2342. try
  2343. {
  2344. if (!WindSendDevice.IsConnected && Json<DevicePar>.Data.deviceConnectPar.WindSendConnect)
  2345. {
  2346. WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP);
  2347. if (WindSendDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("风送plc重新连接成功");
  2348. }
  2349. }
  2350. catch (Exception ex)
  2351. {
  2352. }
  2353. Thread.Sleep(50);
  2354. }), "设备连接", true);
  2355. }
  2356. private void DosingDevice(int Index, int DeviceID)
  2357. {
  2358. if (RTrig.GetInstance("Tray2StatusDevice" + DeviceID).Start(DeviceInquire.GetInstance.GetDevice(DeviceID).deviceStatus.RunStatus == 3))
  2359. {
  2360. MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{RemoteRecipes.ElementAt(Index).RecipeName},{DeviceID}号仓,配料完成");
  2361. int res = Array.FindIndex(RemoteRecipes.ElementAt(Index).RawMaterial.ToArray(), p => p.RawMaterialLocation == DeviceID);
  2362. RemoteRecipes.ElementAt(Index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(DeviceID).deviceStatus.CutWeightFeedback;
  2363. DeviceInquire.GetInstance.GetDevice(DeviceID).StatusReset();
  2364. if (DeviceID >= 1 && DeviceID <= 8)
  2365. {
  2366. HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (DeviceID - 1), true);
  2367. }
  2368. else if (DeviceID >= 9 && DeviceID <= 15)
  2369. {
  2370. HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (DeviceID - 9), true);
  2371. }
  2372. }
  2373. }
  2374. public void RawMaterialNameWithCode()
  2375. {
  2376. GVL_SmallStation.GetInstance.RawMaterialsNameCode.Clear();
  2377. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0001", "色拉油");
  2378. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0002", "一级菜油");
  2379. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0003", "菜籽油");
  2380. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0004", "青花椒油");
  2381. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0005", "卤牛肉丁");
  2382. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0006", "冻鸡肉丁");
  2383. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0007", "香菇丁");
  2384. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0008", "高水分糍粑海椒");
  2385. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0009", "低水分糍粑海椒");
  2386. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0010", "辣豆瓣");
  2387. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0011", "整豆豉");
  2388. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0012", "豆豉细粒");
  2389. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0013", "卤黄豆");
  2390. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0014", "野山椒粒");
  2391. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0015", "竹笋丁");
  2392. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0016", "香辣酱辣椒酱");
  2393. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0017", "芽菜粒");
  2394. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0018", "榨菜丁");
  2395. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0019", "盐菜");
  2396. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0020", "洋葱丁");
  2397. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0021", "番茄酱");
  2398. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0022", "甜豆瓣");
  2399. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0023", "甜面酱");
  2400. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0024", "芝麻酱");
  2401. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0025", "炸花生");
  2402. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0026", "盐渍青椒丁");
  2403. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0027", "备料剁红椒");
  2404. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0028", "萝卜丁");
  2405. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0029", "油芝麻");
  2406. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0030", "生姜");
  2407. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0031", "大蒜");
  2408. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0032", "榨菜酱");
  2409. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0033", "炸碗豆");
  2410. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0034", "大头菜丁");
  2411. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0035", "酱油");
  2412. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0036", "I+G");
  2413. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0037", "味精");
  2414. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0038", "白糖");
  2415. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0039", "食盐");
  2416. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0040", "花椒酱");
  2417. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0041", "调味膏2");
  2418. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0042", "调味膏5");
  2419. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0043", "十三香调味膏");
  2420. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0044", "酱香膏");
  2421. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0045", "芽菜香料粉");
  2422. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0046", "香料A");
  2423. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0047", "香料D");
  2424. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0048", "猪肉精膏");
  2425. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0049", "调味膏3");
  2426. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0050", "柠檬酸粉");
  2427. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0051", "辣椒红");
  2428. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0052", "辣椒油树脂");
  2429. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0053", "水态混和酸");
  2430. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0054", "加水稀释后防腐剂");
  2431. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0055", "异维C钠粉");
  2432. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0056", "琼脂粉");
  2433. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0057", "香葱油");
  2434. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0058", "水态甜味剂");
  2435. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0059", "孜然粉");
  2436. GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0060", "孜然油");
  2437. }
  2438. }
  2439. }