FrmXLRStore.cs
30.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
using CodeLibrary;
using log4net;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using OnlineStore.XLRStore.inputForm;
using PrintLabel_Test;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.XLRStore
{
internal partial class FrmXLRStore : FrmBase
{
private XLRStoreBean StoreBean = null;
private List<TabPage> tabPageList = new List<TabPage>();
private bool LoadOk = false;
private System.Timers.Timer startTimer = null;
internal FrmXLRStore()
{
CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
startTimer = new System.Timers.Timer();
startTimer.Interval = 1000;
startTimer.Enabled = false;
startTimer.AutoReset = false;
}
private void FrmMain_Load(object sender, EventArgs e)
{
this.Opacity = 0;
this.Cursor = Cursors.WaitCursor;
FrmBase.GetVersion(true);
if (!StoreManager.Init())
{
LogUtil.error("加载配置失败,直接退出程序");
Application.Exit();
return;
}
LoadStoreData();
if (StoreManager.DisSecurityAccess)
{
禁用安全光栅ToolStripMenuItem.Text = gouStr + "禁用安全光栅";
}
else
{
禁用安全光栅ToolStripMenuItem.Text = "禁用安全光栅";
}
if (StoreManager.DisBoxDoorLimit)
{
启用门禁ToolStripMenuItem.Text = gouStr + "禁用门禁";
}
else
{
启用门禁ToolStripMenuItem.Text = "禁用门禁";
}
//tabControl1.TabPages.Remove(tabPage5);
timer1.Start();
this.Opacity = 100;
this.Visible = true;
this.notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
this.Cursor = Cursors.Default;
}
private FrmInputEquip inputEquip = null;
private FrmBoxEquip box = null;
private void LoadStoreData()
{
formLineStatus(false);
string title = ConfigAppSettings.GetValue(Setting_Init.App_Title);
this.Text = title;
this.notifyIcon1.Text = title;
int autoValue = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun);
StoreBean = StoreManager.XLRStore;
if (StoreBean == null)
{
Application.Exit();
return;
}
inputEquip = new FrmInputEquip(StoreManager.XLRStore.inputEquip);
AddForm(" 入料机构 ", inputEquip);
box = new FrmBoxEquip(StoreManager.XLRStore.boxEquip);
AddForm(" 存储机构 ", box);
if (autoValue.Equals(1))
{
开机自动启动ToolStripMenuItem.Text = gouStr + " 开机自动启动";
}
else
{
开机自动启动ToolStripMenuItem.Text = "开机自动启动";
}
if (StoreManager.UseBuzzer)
{
启用蜂鸣器ToolStripMenuItem.Text = gouStr + "启用蜂鸣器";
}
else
{
启用蜂鸣器ToolStripMenuItem.Text = "启用蜂鸣器";
}
LogUtil.logBox = this.logBox;
lastLogTime = DateTime.Now.AddMinutes(-10);
this.Opacity = 100;
ReelControlA1.ShowData("A上暂存区物料", BufferDataManager.AInStoreInfo, IO_VALUE.HIGH);
ReelControlA2.ShowData("A皮带线末端物料", BufferDataManager.AOutStoreInfo, IO_VALUE.LOW);
ReelControlB1.ShowData("B上暂存区物料", BufferDataManager.BInStoreInfo, IO_VALUE.LOW);
ReelControlB2.ShowData("B皮带线末端物料", BufferDataManager.BOutStoreInfo, IO_VALUE.LOW);
ReelControlA1.linkClear.Click += LinkClear_ClickA1;
ReelControlA2.linkClear.Click += LinkClear_ClickA2;
ReelControlB1.linkClear.Click += LinkClear_ClickB1;
ReelControlB2.linkClear.Click += LinkClear_ClickB2;
BoxControl.InitData(StoreManager.XLRStore.boxEquip.Name);
InputControl.InitData(StoreManager.XLRStore.inputEquip.Name);
ShelfAControl.InitData(StoreManager.XLRStore.inputEquip.BatchMove.Name);
BoxControl.DoubleClick += BoxControl_DoubleClick;
InputControl.DoubleClick += InputControl_DoubleClick;
ShelfAControl.DoubleClick += ShelfAControl_DoubleClick;
ShelfBControl.DoubleClick += ShelfBControl_DoubleClick;
LoadOk = true;
}
private void ShelfBControl_DoubleClick(object sender, EventArgs e)
{
tabControl1.SelectedIndex = 2;
inputEquip.tabControl1.SelectedIndex = 4;
}
private void ShelfAControl_DoubleClick(object sender, EventArgs e)
{
tabControl1.SelectedIndex = 2;
inputEquip.tabControl1.SelectedIndex = 3;
}
private void InputControl_DoubleClick(object sender, EventArgs e)
{
tabControl1.SelectedIndex = 2;
inputEquip.tabControl1.SelectedIndex = 0;
}
private void BoxControl_DoubleClick(object sender, EventArgs e)
{
tabControl1.SelectedIndex = 3;
}
private void LinkClear_ClickA1(object sender, EventArgs e)
{
if (BufferDataManager.AInStoreInfo == null)
{
return;
}
DialogResult result = MessageBox.Show("确定清除A上暂存区物料:" + BufferDataManager.AInStoreInfo.ToStr(), "", MessageBoxButtons.OKCancel);
if (result.Equals(DialogResult.OK))
{
LogUtil.info(Name + "手动清除A上暂存区物料:" + BufferDataManager.AInStoreInfo.ToStr());
BufferDataManager.AInStoreInfo = null;
}
}
private void LinkClear_ClickA2(object sender, EventArgs e)
{
if (BufferDataManager.AOutStoreInfo == null)
{
return;
}
DialogResult result = MessageBox.Show("确定清除A皮带线末端物料(同时会屏蔽该物料所在库位):" + BufferDataManager.AOutStoreInfo.ToStr(), "", MessageBoxButtons.OKCancel);
if (result.Equals(DialogResult.OK))
{
DisablePos(BufferDataManager.AOutStoreInfo.PosId, BufferDataManager.AOutStoreInfo.barcode);
LogUtil.info(Name + "手动清除A皮带线末端物料,并屏蔽该物料所在库位:" + BufferDataManager.AOutStoreInfo.ToStr());
BufferDataManager.AOutStoreInfo = null;
}
}
private void LinkClear_ClickB1(object sender, EventArgs e)
{
if (BufferDataManager.BInStoreInfo == null)
{
return;
}
DialogResult result = MessageBox.Show("确定清除B上暂存区物料:" + BufferDataManager.BInStoreInfo.ToStr(), "", MessageBoxButtons.OKCancel);
if (result.Equals(DialogResult.OK))
{
LogUtil.info(Name + "手动清除B上暂存区物料:" + BufferDataManager.BInStoreInfo.ToStr());
BufferDataManager.BInStoreInfo = null;
}
}
private void LinkClear_ClickB2(object sender, EventArgs e)
{
if (BufferDataManager.BOutStoreInfo == null)
{
return;
}
DialogResult result = MessageBox.Show("确定清除B皮带线末端物料(同时会屏蔽该物料所在库位):" + BufferDataManager.BOutStoreInfo.ToStr(), "", MessageBoxButtons.OKCancel);
if (result.Equals(DialogResult.OK))
{
DisablePos(BufferDataManager.BOutStoreInfo.PosId, BufferDataManager.BOutStoreInfo.barcode);
LogUtil.info(Name + "手动清除B皮带线末端物料,并屏蔽该物料所在库位:" + BufferDataManager.BOutStoreInfo.ToStr());
BufferDataManager.BOutStoreInfo = null;
}
}
/// <summary>
/// 屏蔽下暂存区里物料的库位
/// </summary>
/// <param name="posId"></param>
/// <param name="barcode"></param>
private void DisablePos(string posId, string barcode)
{
SServerManager.DisablePos(StoreManager.XLRStore.Name, barcode, posId);
}
private void AddForm(string text, Form form)
{
//text = text.PadRight(10, ' ');
TabPage lineTabPage = new TabPage(text);
// lineTabPage.AutoScroll = true;
lineTabPage.Tag = StoreBean;
Panel linePan = new Panel();
linePan.Dock = DockStyle.Fill;
linePan.AutoScroll = true;
lineTabPage.Controls.Add(linePan);
form.FormBorderStyle = FormBorderStyle.None;
form.TopLevel = false;
linePan.Controls.Add(form);
form.Dock = DockStyle.Fill;
linePan.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
form.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
form.Show();
tabPageList.Add(lineTabPage);
tabControl1.Controls.Add(lineTabPage);
}
private void HideForm()
{
this.Opacity = 0;
this.ShowInTaskbar = false;
this.notifyIcon1.Visible = true;
this.Hide();
GC.Collect();
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.contextMenuStrip1.Show();
}
if (e.Button == MouseButtons.Left)
{
this.Opacity = 100;
this.Visible = true;
//this.WindowState = FormWindowState.Maximized;
this.notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
}
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)//当界面点击窗体右上角X按钮或(Alt + F4)时 发生
{
e.Cancel = true;
HideForm();
}
}
private void ExitApp()
{
DialogResult result = MessageBox.Show("是否确定退出客户端?", "提示", MessageBoxButtons.YesNo);
if (result.Equals(DialogResult.Yes))
{
try
{
//如果料仓还在运行状态,先关闭料仓
if (!StoreBean.runStatus.Equals(RunStatus.Wait))
{
LogUtil.info("即将退出程序,停止" + StoreBean.Name + "运行 ");
StoreBean.StopRun();
}
IOManager.instance.CloseAllDO();
IOManager.instance.CloseAllConnection();
AxisManager.instance.CloseAllPort();
AxisManager.instance.CloseCard();
if (Camera._cam != null)
{
Camera._cam.CloseAll();
}
System.Environment.Exit(System.Environment.ExitCode);
}
catch (Exception ex)
{
LogUtil.error("退出出错:", ex);
}
//this.Close();
}
}
private void 显示ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
FrmPwd fw = new FrmPwd(10);
DialogResult result = fw.ShowDialog();
if (!result.Equals(DialogResult.OK))
{
LogUtil.info("切换界面显示时,没有正确输入密码");
return;
}
this.Opacity = 100;
this.Visible = true;
//this.WindowState = FormWindowState.Maximized;
this.notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
}
catch (Exception ex)
{
LogUtil.error("显示界面出错:", ex);
}
}
private void 启动所有料仓AToolStripMenuItem_Click(object sender, EventArgs e)
{
if (StoreBean.runStatus != RunStatus.Wait)
{
MessageBox.Show(StoreBean.Name + "当前状态:" + StoreBean.runStatus + ",不能启动!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
LogUtil.info("点击 开始启动");
startTimer.Interval = 300;
startTimer.Elapsed += timer_Elapsed;
startTimer.AutoReset = false;
startTimer.Enabled = true;
this.timer1.Start();
}
private delegate void ShowFormDelegate();
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
startTimer.Stop();
if (StoreBean.runStatus > RunStatus.Wait)
{
return;
}
if (StoreBean.StartRun())
{
BeginInvoke(new ShowFormDelegate(ShowStatus));
}
}
private void ShowStatus()
{
formLineStatus(true);
}
private void formLineStatus(bool isStart)
{
启动AToolStripMenuItem.Enabled = !isStart;
停止TToolStripMenuItem.Enabled = isStart;
}
private void 停止所有料仓TToolStripMenuItem_Click(object sender, EventArgs e)
{
if (StoreBean != null)
{
if (StoreBean.runStatus.Equals(RunStatus.Wait))
{
MessageBox.Show(StoreBean.Name + "流水线未启动,不需要停止", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
LogUtil.info(StoreBean.Name + "点击:停止");
if (StoreBean != null)
{
StoreBean.StopRun();
}
formLineStatus(false);
}
}
private void 复位RToolStripMenuItem_Click(object sender, EventArgs e)
{
if (StoreBean.runStatus.Equals(RunStatus.Wait))
{
MessageBox.Show(StoreBean.Name + "流水线未启动,无法复位", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
LogUtil.info(StoreBean.Name + "点击:复位");
StoreBean.Reset();
}
private void FrmLineStore_FormClosed(object sender, FormClosedEventArgs e)
{
if (停止TToolStripMenuItem.Enabled)
{
停止所有料仓TToolStripMenuItem_Click(null, null);
}
//AgvClient.Dispose();
if (IOManager.instance != null)
{
IOManager.instance.CloseAllDO();
IOManager.instance.CloseAllConnection();
}
}
private void btnClearLog_Click(object sender, EventArgs e)
{
LogUtil.ClearLog();
}
private void btnCopyLog_Click(object sender, EventArgs e)
{
Clipboard.SetDataObject(logBox.Text);
MessageBox.Show("已复制日志到粘贴板!");
}
#region 内存回收
[DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
public static void ClearMemory()
{
try
{
GC.Collect();
GC.WaitForPendingFinalizers();
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
}
}
catch (Exception ex)
{
LogUtil.error("ClearMemory 出错:" + ex.ToString());
}
}
#endregion
private DateTime lastLogTime = DateTime.Now;
PerformanceCounter curtime = null;
private void LogM()
{
try
{
TimeSpan sp = DateTime.Now - lastLogTime;
if (sp.TotalMinutes >= 5)
{
lastLogTime = DateTime.Now;
Process process = Process.GetCurrentProcess();
if (curtime == null)
{
curtime = new PerformanceCounter("Process", "% Processor Time", process.ProcessName);
}
if (process != null)
{
StringBuilder sbResult = new StringBuilder();
PerformanceCounter pf1 = new PerformanceCounter("Process", "Working Set - Private", process.ProcessName);
sbResult.AppendFormat(DateTime.Now.ToLongTimeString() + ", 名称:{0} 内存:{1}M ", process.ProcessName, Math.Round(pf1.NextValue() / 1024 / 1024F, 2));
sbResult.AppendFormat(", CPU : {0} %", curtime.NextValue() / Environment.ProcessorCount);
LogUtil.info(sbResult.ToString());
}
}
//ClearMemory();
}
catch (Exception ex)
{
LogUtil.error("LogM Error: ", ex);
}
}
private void timer1_Tick(object sender, EventArgs e)
{
try
{
LogM();
GC.Collect();
string canScanCode = "";
lblStatus.Text = StoreBean.GetRunStr() + canScanCode;
string warnMsg = "";
List<DeviceBase> deviceBases = new List<DeviceBase>() { StoreManager.XLRStore, StoreManager.XLRStore.inputEquip, StoreManager.XLRStore.boxEquip };
//if (StoreManager.XLRStore.runStatus > RunStatus.Wait)
//{
// string time = StoreManager.XLRStore.alarmType.Equals(AlarmType.None) ? "" : StoreManager.XLRStore.LastAlarmTime.ToLongTimeString();
// warnMsg = StoreManager.XLRStore.WarnMsg.Equals("") ? "" : (time + StoreManager.XLRStore.WarnMsg + "\r\n");
//}
foreach (DeviceBase device in deviceBases)
{
if (device.runStatus > RunStatus.Wait)
{
if (!device.WarnMsg.Equals(""))
{
string time = device.alarmType.Equals(AlarmType.None) ? "" : device.LastAlarmTime.ToLongTimeString();
warnMsg += device.WarnMsg.Equals("") ? "" : (time + device.WarnMsg + "\r\n");
}
}
}
lblWarnMsg.Text = warnMsg;
BoxEquip box = StoreManager.XLRStore.boxEquip;
BoxControl.ShowData(box.IsDebug, box.GetRunStr(), box.WarnMsg, box.MoveInfo, box.GetShowColor());
InputEquip input = StoreManager.XLRStore.inputEquip;
InputControl.ShowData(input.IsDebug, input.GetRunStr(), input.WarnMsg, input.MoveInfo, input.GetShowColor());
ShelfAControl.ShowData(true, "", input.BatchMove.WarnMsg, input.BatchMove.MoveInfo, input.BatchMove.GetShowColor(), input.BatchMove.CurrShelf?.ToStr());
ReelControlA1.ShowData("A进料暂存区", BufferDataManager.AInStoreInfo, input.IOValue(IO_Type.FeedA_ReelCheck));
ReelControlA2.ShowData("A出料暂存区", BufferDataManager.AOutStoreInfo, input.IOValue(IO_Type.LineA_ReelInPlaceCheck));
ReelControlB1.ShowData("B进料暂存区", BufferDataManager.BInStoreInfo, input.IOValue(IO_Type.FeedB_ReelCheck));
ReelControlB2.ShowData("B出料暂存区", BufferDataManager.BOutStoreInfo, input.IOValue(IO_Type.LineB_ReelInPlaceCheck));
if (StoreBean.runStatus > RunStatus.Wait)
{
if (启动AToolStripMenuItem.Enabled.Equals(true))
{
formLineStatus(true);
}
if ((StoreBean.runStatus.Equals(RunStatus.HomeMoving) || StoreBean.runStatus.Equals(RunStatus.Reset))
&& StoreBean.alarmType.Equals(AlarmType.None))
{
SetMenuS(复位RToolStripMenuItem, false);
SetMenuS(启动AToolStripMenuItem, false);
}
else
{
SetMenuS(复位RToolStripMenuItem, true);
}
}
else
{
SetMenuS(启动AToolStripMenuItem, true);
SetMenuS(复位RToolStripMenuItem, false);
SetMenuS(停止TToolStripMenuItem, false);
}
}
catch (Exception ex)
{
LogUtil.error("XLRStore timer", ex);
}
}
private void SetMenuS(ToolStripMenuItem toolMenu, bool isEn)
{
if (!toolMenu.Enabled.Equals(isEn))
{
toolMenu.Enabled = isEn;
}
}
private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
{
Font fntTab;
Brush bshBack;
Brush bshFore;
if (e.Index == this.tabControl1.SelectedIndex)
{
fntTab = new Font(e.Font, FontStyle.Regular);
bshBack = new SolidBrush(Color.DodgerBlue);
bshFore = Brushes.Black;
}
else
{
fntTab = e.Font;
bshBack = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, Color.White, Color.White, System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal);
bshFore = new SolidBrush(Color.Black);
}
string tabName = this.tabControl1.TabPages[e.Index].Text;
StringFormat sftTab = new StringFormat();
e.Graphics.FillRectangle(bshBack, e.Bounds);
Rectangle recTab = e.Bounds;
recTab = new Rectangle(recTab.X, recTab.Y + 4, recTab.Width, recTab.Height - 4);
e.Graphics.DrawString(tabName, fntTab, bshFore, recTab, sftTab);
}
private void 版本号ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmAbout about = new FrmAbout();
about.ShowDialog();
}
private void 二维码学习ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Camera._cam != null)
{
Camera._cam.CloseAll();
}
CodeLibrary.FrmCodeDecode frm = new CodeLibrary.FrmCodeDecode(false);
frm.ShowDialog();
frm.Dispose();
}
private void 退出ToolStripMenuItem_Click_1(object sender, EventArgs e)
{
LogUtil.info("点击:退出系统");
ExitApp();
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
ExitApp();
}
private void logBox_VisibleChanged(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
if (logBox.Visible)
{
LogUtil.UpdateLogbox();
}
}
private void 清空日志ToolStripMenuItem_Click(object sender, EventArgs e)
{
LogUtil.ClearLog();
}
private void 复制日志ToolStripMenuItem_Click(object sender, EventArgs e)
{
Clipboard.SetDataObject(logBox.Text);
MessageBox.Show("已复制日志到粘贴板!");
}
private string gouStr = "✔";
private void 开机自动启动ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
if (开机自动启动ToolStripMenuItem.Text.Contains(gouStr))
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 0);
ManagerUtil.AutoRun(Application.ExecutablePath, false);
开机自动启动ToolStripMenuItem.Text = "开机自动启动";
}
else
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 1);
ManagerUtil.AutoRun(Application.ExecutablePath, true);
开机自动启动ToolStripMenuItem.Text = gouStr + "开机自动启动";
}
LogUtil.info(Name + " 点击:" + 开机自动启动ToolStripMenuItem.Text);
}
private void 启用蜂鸣器ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
bool result = !启用蜂鸣器ToolStripMenuItem.Text.Contains(gouStr);
if (result.Equals(StoreManager.UseBuzzer))
{
return;
}
StoreManager.UseBuzzer = result;
ConfigAppSettings.SaveValue(Setting_Init.UseBuzzer, (StoreManager.UseBuzzer ? 1 : 0));
if (result)
{
启用蜂鸣器ToolStripMenuItem.Text = gouStr + " 启用蜂鸣器";
}
else
{
启用蜂鸣器ToolStripMenuItem.Text = "启用蜂鸣器";
}
LogUtil.info(Name + " 点击:" + 启用蜂鸣器ToolStripMenuItem.Text);
}
private void aGVCancelStateToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
bool result = !aGVCancelStateToolStripMenuItem.Text.Contains(gouStr);
if (result.Equals(AgvClient.CurrCancelState))
{
return;
}
AgvClient.SetCancelState(result);
if (result)
{
aGVCancelStateToolStripMenuItem.Text = gouStr + " AGV信号屏蔽";
}
else
{
aGVCancelStateToolStripMenuItem.Text = "AGV信号屏蔽";
}
LogUtil.info(Name + " 点击:" + aGVCancelStateToolStripMenuItem.Text);
}
private void toolStripMenuItem3_Click(object sender, EventArgs e)
{
try
{
FrmCrispTray tray = new FrmCrispTray();
tray.ShowDialog();
}
catch (Exception ex)
{
LogUtil.error("FrmCrispTray 出错:" + ex.ToString());
}
}
private void timer2_Tick(object sender, EventArgs e)
{
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
if (inputEquip != null)
{
inputEquip.FrmInputEquip_VisibleChanged(null, null);
}
}
private void 启用安全光栅ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
bool result = !禁用安全光栅ToolStripMenuItem.Text.Contains(gouStr);
if (result.Equals(StoreManager.DisSecurityAccess))
{
return;
}
StoreManager.DisSecurityAccess = result;
//ConfigAppSettings.SaveValue(Setting_Init.DisSecurityAccess, (StoreManager.DisSecurityAccess ? 1 : 0));
if (result)
{
禁用安全光栅ToolStripMenuItem.Text = gouStr + " 禁用安全光栅";
}
else
{
禁用安全光栅ToolStripMenuItem.Text = "禁用安全光栅";
}
LogUtil.info(Name + " 点击:" + 禁用安全光栅ToolStripMenuItem.Text);
}
private void 启用门禁ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
bool result = !启用门禁ToolStripMenuItem.Text.Contains(gouStr);
if (result.Equals(StoreManager.DisBoxDoorLimit))
{
return;
}
StoreManager.DisBoxDoorLimit = result;
//ConfigAppSettings.SaveValue(Setting_Init.DisSecurityAccess, (StoreManager.DisSecurityAccess ? 1 : 0));
if (result)
{
启用门禁ToolStripMenuItem.Text = gouStr + " 禁用门禁";
IOManager.IOMove(IO_Type.DisDoorLimit, IO_VALUE.HIGH);
}
else
{
启用门禁ToolStripMenuItem.Text = "禁用门禁";
IOManager.IOMove(IO_Type.DisDoorLimit, IO_VALUE.LOW);
}
LogUtil.info(Name + " 点击:" + 启用门禁ToolStripMenuItem.Text);
}
private void RFIDReadWrite_Click(object sender, EventArgs e)
{
FrmRFIPEdit frmRFIPEdit = new FrmRFIPEdit();
frmRFIPEdit.Show();
}
private void 打印机调试ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmPrinter frmPrinter = new FrmPrinter();
frmPrinter.Show();
}
private void 机器人调试ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmRobot frmRobot = new FrmRobot();
frmRobot.Show();
}
private void 贴标调试ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmLabelEdit frmLabelEdit = new FrmLabelEdit();
frmLabelEdit.Show();
}
}
}