uc_boxdebug.cs
27.6 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
using log4net;
using OnlineStore.AutoInOutStore;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using static OnlineStore.AutoInOutStore.ResourceCulture;
namespace OnlineStore.ACSingleStore.useControl
{
public partial class uc_boxdebug : UserControl
{
static AxisManager ACServerManager = AxisManager.instance;
private AC_SA_BoxBean store;
private string StartAuto = ResourceCulture.GetString("开始自动出入库");
private string StopAuto = ResourceCulture.GetString("停止自动出入库");
private string AutoOut = ResourceCulture.GetString("自动出库:");
private string AutoIn = ResourceCulture.GetString("自动入库:");
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
Dictionary<string,PosState> posState = new Dictionary<string, PosState>();
//如果总配置文件存在,保存到总的配置文件
static string appPath = Application.StartupPath;
static string positionConfigFile = appPath + ConfigAppSettings.GetValue(Setting_Init.Store_Position_Config);
class PosState {
public int InStoreCheck = 0;
public int OutStoreCheck = 0;
}
public uc_boxdebug()
{
InitializeComponent();
}
public void Init(AC_SA_BoxBean store)
{
this.store = this.store = store;
if (store == null)
{
LogUtil.error(LOGGER, "找不到对应的料仓");
return;
}
StartAuto = ResourceCulture.GetString("开始自动出入库");
StopAuto = ResourceCulture.GetString("停止自动出入库");
AutoOut = ResourceCulture.GetString("自动出库:");
AutoIn = ResourceCulture.GetString("自动入库:");
FillBoxPos();
store.InOutEndProcessEvent += Store_InOutEndProcessEvent;
timer1.Enabled = true;
setAxisPopup(txtUpDownP3, btnUpDownP3, store.Config.UpDown_Axis);
setAxisPopup(txtUpDownP4, btnUpDownP4, store.Config.UpDown_Axis);
setAxisPopup(txtUpDownP5, btnUpDownP5, store.Config.UpDown_Axis);
setAxisPopup(txtUpDownP6, btnUpDownP6, store.Config.UpDown_Axis);
setAxisPopup(txtMiddleP2, btnMiddleP2, store.Config.Middle_Axis);
setAxisPopup(txtInOutP2, btnInOutP2, store.Config.InOut_Axis);
setAxisPopup(txtInOutP3, btnInOutP3, store.Config.InOut_Axis);
setAxisPopup(txtComP2, btnComP2, store.Config.Comp_Axis);
setAxisPopup(txtComP3, btnComP3, store.Config.Comp_Axis);
return;
}
private void Store_InOutEndProcessEvent(string arg1, StoreMoveType arg2, bool arg3)
{
//LogUtil.info($"出入库完成状态:{arg2},库位:{arg1}");
int InStoreCheck = 0;
int OutStoreCheck = 0;
if (arg2 == StoreMoveType.InStore)
InStoreCheck = 1;
else if (arg2 == StoreMoveType.OutStore)
OutStoreCheck = 1;
var pps = SavePosCheck(arg1, InStoreCheck, OutStoreCheck);
if (htpp.ContainsKey(arg1))
{
var pp = (PosPos)htpp[arg1];
var cells = dataGridView1.Rows[pp.row].Cells[pp.col];
cells.Style = GetStyle(arg1);
}
checkVerify();
}
DataGridViewCellStyle GetStyle(string posid) {
if (htpp.ContainsKey(posid) && posState.ContainsKey(posid))
{
var pp = (PosPos)htpp[posid];
var pps = (PosState)posState[posid];
var cells = dataGridView1.Rows[pp.row].Cells[pp.col];
cells.Selected = true;
if (pps.InStoreCheck == 1 && pps.OutStoreCheck == 1)
return dgv_ok;
else if (pps.InStoreCheck == 1)
return dgv_oin;
else if (pps.OutStoreCheck == 1)
return dgv_oout;
}
return dgv_none;
}
Hashtable htpp = new Hashtable();
class PosPos {
public string Posid;
public int index;
public int row;
public int col;
}
int PosCompare(string a, string b)
{
if (a.StartsWith("fix"))
return -1;
if (b.StartsWith("fix"))
return 1;
string[] pa = a.Split('_');
string[] pb = b.Split('_');
if (int.TryParse(pa[1], out _))
pa[1] += "A";
if (int.TryParse(pb[1], out _))
pb[1] += "A";
var pa1 = pa[1][0] + (pa[1][1].Equals('A') ? "1" : "2");
var pb1 = pb[1][0] + (pb[1][1].Equals('A') ? "1" : "2");
var pa2 = pa[2];
var pb2 = pb[2];
if (pa[2].Length == 2)
{
if (pa[2][1].Equals('A') || pa[2][1].Equals('B'))
{
pa2 = (pa[2][1].Equals('A') ? "1" : "2") + pa[2][0];
}
else if (pa[2][1].Equals('1') || pa[2][1].Equals('2'))
{
pa2 = (pa[2][1].Equals('1') ? "1" : "2") + pa[2][0];
}
}
if (pb[2].Length == 2)
{
if ((pb[2][1].Equals('A') || pb[2][1].Equals('B')))
{
pb2 = (pb[2][1].Equals('A') ? "1" : "2") + pb[2][0];
}
else if ((pb[2][1].Equals('1') || pb[2][1].Equals('2')))
{
pb2 = (pb[2][1].Equals('1') ? "1" : "2") + pb[2][0];
}
}
var isa = Regex.Replace(pa[1], @"[^\d]*", "") + pa1 + pa2 + pa[3].PadLeft(2, '0');
var isb = Regex.Replace(pb[1], @"[^\d]*", "") + pb1 + pb2 + pb[3].PadLeft(2, '0');
if (int.Parse(isa) == int.Parse(isb))
return 0;
else if (int.Parse(isa) > int.Parse(isb))
return 1;
else
return -1;
}
void LoadPosCheck() {
var poscheckfile = positionConfigFile + ".check";
if (File.Exists(poscheckfile))
{
try
{
posState = JsonHelper.DeserializeJsonToObject<Dictionary<string, PosState>>(File.ReadAllText(poscheckfile));
File.Copy(poscheckfile, poscheckfile + ".backup", true);
}
catch {
if (File.Exists(poscheckfile + ".backup"))
{
File.Copy(poscheckfile + ".backup", poscheckfile, true);
File.Delete(poscheckfile + ".backup");
LoadPosCheck();
}
}
}
else
{
File.WriteAllText(poscheckfile, JsonHelper.SerializeObject(posState));
}
}
PosState SavePosCheck(string posid,int inStoreCheck,int outStoreCheck) {
if (!posState.ContainsKey(posid))
posState.Add(posid, new PosState());
if (inStoreCheck>0)
posState[posid].InStoreCheck = inStoreCheck;
if (outStoreCheck > 0)
posState[posid].OutStoreCheck = outStoreCheck;
var poscheckfile = positionConfigFile + ".check";
File.WriteAllText(poscheckfile, JsonHelper.SerializeObject(posState));
return posState[posid];
}
static Font font = new Font("宋体",10);
DataGridViewCellStyle dgv_ok = new DataGridViewCellStyle() { BackColor = Color.LightGreen, Font = font };
DataGridViewCellStyle dgv_oin = new DataGridViewCellStyle() { BackColor = Color.LightGray, Font = font };
DataGridViewCellStyle dgv_oout = new DataGridViewCellStyle() { BackColor = Color.LightSeaGreen, Font = font };
DataGridViewCellStyle dgv_none = new DataGridViewCellStyle() { BackColor = Color.White,Font= font };
void FillBoxPos() {
LoadPosCheck();
Comparison<string> comparison = new Comparison<string>(PosCompare);
store.PositionNumList.Sort(comparison);
//store.PositionNumList.Reverse();
string[] posstr = store.PositionNumList[store.PositionNumList.Count-1].Split('_');
int colcount = 0;
if (!int.TryParse(posstr[1],out colcount))
colcount= int.Parse(posstr[1][0].ToString());
colcount++;
for (int i = 0; i < colcount; i++)
{
dataGridView1.Columns.Add("Col" + i + "_A", "Col" + i + "_A");
dataGridView1.Columns.Add("Col" + i + "_B", "Col" + i + "_B");
}
for (int i = 0; i < dataGridView1.Columns.Count; i++)
{
dataGridView1.Columns[i].Width = 64;
dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
}
dataGridView1.Rows.Add();
int currentRowIndex = 0;
int lastcol = -1;
string lastAB = "";
for (int i = 0; i < store.PositionNumList.Count; i++)
{
int ci = store.PositionNumList.Count-1 - i;
string posname = store.PositionNumList[ci];
if (posname.StartsWith("fix"))
continue;
string[] _posstr = posname.Split('_');
int col = 0;
if (!int.TryParse(_posstr[1],out col))
col = int.Parse(_posstr[1][0].ToString());
string ab = "A";
if (_posstr[2].Length > 1)
ab = _posstr[2][1].ToString();
if (ab != "A" && ab != "B")
{
if (ab == "1")
ab = "A";
else if (ab == "2")
ab = "B";
else
ab = "A";
}
if (col != lastcol || lastAB!= ab)
currentRowIndex = 0;
lastcol = col;
lastAB = ab;
if (currentRowIndex >= dataGridView1.Rows.Count-1)
{
int x = dataGridView1.Rows.Add();
}
var currentRow = dataGridView1.Rows[currentRowIndex];
int currentColIndex = col * 2;
if (ab.ToLower() == "b")
currentColIndex++;
currentRow.Cells[currentColIndex].Value = $"{_posstr[1]}_{_posstr[2]}_{_posstr[3]}";
currentRow.Cells[currentColIndex].Tag = posname;
htpp.Add(posname, new PosPos() { Posid = posname, index = i, row = currentRowIndex, col = currentColIndex });
currentRow.Cells[currentColIndex].Style = GetStyle(posname);
currentRowIndex++;
}
dataGridView1.Rows.RemoveAt(dataGridView1.Rows.Count - 1);
for (int i = 0; i < dataGridView1.Columns.Count; i++)
{
if (dataGridView1.Rows[0].Cells[i].Value == null)
{
dataGridView1.Columns[i].Width = 0;
}
}
if (dataGridView1.Rows[0].Cells[dataGridView1.Columns.Count - 1].Value != null)
{
dataGridView1.Rows[0].Cells[dataGridView1.Columns.Count - 1].Selected = true;
}
else if (dataGridView1.Rows[0].Cells[dataGridView1.Columns.Count - 2].Value != null)
{
dataGridView1.Rows[0].Cells[dataGridView1.Columns.Count - 2].Selected = true;
}
if (dataGridView1.SelectedCells.Count > 0)
setData(dataGridView1.SelectedCells[0].Tag.ToString());
checkVerify();
}
void setData(string posid) {
AutoStorePosition ktkPosition = CSVPositionReader<AutoStorePosition>.GetPositon(posid);
cmbPosition.Text = posid;
if (ktkPosition != null)
{
txtMiddleP2.Text = ktkPosition.MiddleAxis_Position_P2.ToString();
txtUpDownP3.Text = ktkPosition.UpDownAxis_IHPosition_P3.ToString();
txtUpDownP4.Text = ktkPosition.UpDownAxis_ILPosition_P4.ToString();
txtUpDownP5.Text = ktkPosition.UpDownAxis_OHPosition_P5.ToString();
txtUpDownP6.Text = ktkPosition.UpDownAxis_OLPosition_P6.ToString();
txtComP2.Text = ktkPosition.CompressAxis_Position_P2.ToString();
txtComP3.Text = ktkPosition.CompressAxis_CPosition_P3.ToString();
txtInOutP3.Text = ktkPosition.InOutAxis_Position_P3.ToString();
txtInOutP2.Text = ktkPosition.InOutAxis_DoorOutPosition_P4.ToString();
}
}
private void btnInStore_Click(object sender, EventArgs e)
{
if (store.storeRunStatus >= StoreRunStatus.HomeMoving)
{
string selectPositionNum = cmbPosition.Text;
LineMoveP ktk = LoadPostion();
store.StartInStoreMove(new InOutStoreParam("", selectPositionNum, ktk));
}
else
{
MyMessage.Show("请先启动料仓!");
}
}
private void btnOutStore_Click(object sender, EventArgs e)
{
if (store.storeRunStatus >= StoreRunStatus.HomeMoving)
{
string selectPositionNum = cmbPosition.Text;
LineMoveP ktk = LoadPostion();
store.StartOutStoreMove(new InOutStoreParam("", selectPositionNum, ktk),false);
}
else
{
MyMessage.Show("请先启动料仓!");
}
}
private void btnStartAuTo_Click(object sender, EventArgs e)
{
if (store.storeRunStatus >= StoreRunStatus.HomeMoving)
{
if (store.autoNext)
{
store.autoNext = false;
//btnStart.Text = StartAuto;
}
else
{
DialogResult res = MessageBox.Show(ResourceCulture.GetString("确定开始自动出入库?", "确定开始自动出入库?"), ResourceCulture.GetString(ResourceCulture.MsgTitle, "提示"), MessageBoxButtons.YesNo);
if (res.Equals(DialogResult.Yes))
{
int jiange = int.Parse(txtJiange.Text);
store.autoJiange = jiange;
if (cmbPosition.Text.Length >= 0)
{
int currIndex = store.PositionNumList.FindIndex(new Predicate<string>((pos)=>{ return pos == cmbPosition.Text; }));
store.autoPositionIndex = currIndex;
store.AutoStartIndex = currIndex;
string poText = cmbPosition.Text;
ConfigAppSettings.SaveValue(Setting_Init.DebugPosId, poText);
store.autoMsg = ResourceCulture.GetString("自动出入库", "自动出入库") + ":" + poText;
store.autoNext = true;
LogUtil.info(LOGGER, store.StoreName + "开启自动出入库模式,开始位置【" + poText + "】(索引=" + currIndex + "),间隔=" + jiange + "");
//btnStart.Text = StopAuto;
//DebugStatus(false);
string msg = AutomaticBaiting.doStartBatchIn();
LogUtil.info("自动出入库: 开始自动入库:库位号【" + poText + "】,开始入库,结果:" + msg);
}
}
}
}
else
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.PleaseStartStore, "请先启动料仓!"));
}
}
void checkVerify()
{
int finish = 0;
for (int i = 0; i < store.PositionNumList.Count; i++)
{
var posid = store.PositionNumList[i];
if (htpp.ContainsKey(posid) && posState.ContainsKey(posid))
{
var pps = (PosState)posState[posid];
if (pps.InStoreCheck == 1 && pps.OutStoreCheck == 1)
{
finish++;
}
}
}
double s = (double)finish / store.PositionNumList.Count*100;
label_verify.Text = s.ToString("0.0") + "%";
}
private LineMoveP LoadPostion()
{
LineMoveP ktk = new LineMoveP();
//ktk.ComPress_P1 = FormUtil.GetIntValue(txtComP1);
ktk.ComPress_P1 = store.Config.CompressAxis_P1_Position;
ktk.ComPress_P2 = FormUtil.GetIntValue(txtComP2);
ktk.ComPress_P3 = FormUtil.GetIntValue(txtComP3);
//ktk.InOut_P1 = FormUtil.GetIntValue(txtInOutP1);
ktk.InOut_P1 = store.Config.InOutAxis_P1_Position;
ktk.InOut_P2 = FormUtil.GetIntValue(txtInOutP2);
ktk.InOut_P3 = FormUtil.GetIntValue(txtInOutP3);
//ktk.Middle_P1 = FormUtil.GetIntValue(txtMiddleP1);
ktk.Middle_P1 = store.Config.MiddleAxis_P1_Position;
ktk.Middle_P2 = FormUtil.GetIntValue(txtMiddleP2);
//ktk.UpDown_P1 = FormUtil.GetIntValue(txtUpDownP1);
//ktk.UpDown_P1 = store.Config.UpDownAxis_DoorOPosition_P1;
//ktk.UpDown_P2 = FormUtil.GetIntValue(txtUpDownP2);
//ktk.UpDown_P2 = store.Config.UpDownAxis_DoorIPosition_P2;
ktk.UpDown_P3 = FormUtil.GetIntValue(txtUpDownP3);
ktk.UpDown_P4 = FormUtil.GetIntValue(txtUpDownP4);
ktk.UpDown_P5 = FormUtil.GetIntValue(txtUpDownP5);
ktk.UpDown_P6 = FormUtil.GetIntValue(txtUpDownP6);
//ktk.UpDown_P7 = FormUtil.GetIntValue(txtUpDownP7);
//ktk.UpDown_P7 = store.Config.UpDownAxis_DoorOBPosition_P7;
//ktk.UpDown_P8 = FormUtil.GetIntValue(txtUpDownP8);
//ktk.UpDown_P8 = store.Config.UpDownAxis_DoorIBPosition_P8;
return ktk;
}
private void AxisABSMove(ConfigMoveAxis moveAxis, int targetPosition, int targetSpeed)
{
moveAxis.TargetPosition = targetPosition;
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed, targetSpeed * 4, targetSpeed * 4);
}
/// <summary>
/// 判断进出轴是否在P1点
/// </summary>
private bool InOutIsIsP1()
{
int InOutDefaultPosition = ConfigAppSettings.GetIntValue(Setting_Init.InOutDefaultPosition);
int currValue = ACServerManager.GetActualtPosition(store.Config.InOut_Axis.DeviceName, store.Config.InOut_Axis.GetAxisValue());
if (currValue <= InOutDefaultPosition)
{
return true;
}
MyMessage.Show("叉子不在待机位,请先将叉子退回待机位(" + InOutDefaultPosition + ")", "警告(叉子在待机位时,才能移动升降轴和旋转轴) ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return false;
}
private void btnUpDownP3_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtUpDownP3);
AxisABSMove(store.Config.UpDown_Axis, value, store.Config.UpDownAxis_P3_Speed);
}
}
private void btnUpDownP4_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtUpDownP4);
AxisABSMove(store.Config.UpDown_Axis, value, store.Config.UpDownAxis_P4_Speed);
}
}
private void btnUpDownP5_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtUpDownP5);
AxisABSMove(store.Config.UpDown_Axis, value, store.Config.UpDownAxis_P5_Speed);
}
}
private void btnUpDownP6_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtUpDownP6);
AxisABSMove(store.Config.UpDown_Axis, value, store.Config.UpDownAxis_P6_Speed);
}
}
private void btnMiddleP2_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtMiddleP2);
AxisABSMove(store.Config.Middle_Axis, value, store.Config.MiddleAxis_P2_Speed);
}
}
private void btnInOutP3_Click(object sender, EventArgs e)
{
//if (store.InOutAxisCanMove().Equals(false))
//{
// MyMessage.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
//}
int value = FormUtil.GetIntValue(txtInOutP3);
AxisABSMove(store.Config.InOut_Axis, value, store.Config.InOutAxis_P3_Speed);
}
private void btnInOutP2_Click(object sender, EventArgs e)
{
//if (store.InOutAxisCanMove().Equals(false))
//{
// MyMessage.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
//}
int value = FormUtil.GetIntValue(txtInOutP2);
AxisABSMove(store.Config.InOut_Axis, value, store.Config.InOutAxis_P2_Speed);
}
private void btnComP2_Click(object sender, EventArgs e)
{
int value = FormUtil.GetIntValue(txtComP2);
AxisABSMove(store.Config.Comp_Axis, value, store.Config.CompAxis_P2_Speed);
//ShuoKeControls.AbsMove(store.Config.CompressAxis_Slv, value);
}
private void btnComP3_Click(object sender, EventArgs e)
{
int value = FormUtil.GetIntValue(txtComP3);
AxisABSMove(store.Config.Comp_Axis, value, store.Config.CompAxis_P3_Speed);
//ShuoKeControls.AbsMove(store.Config.CompressAxis_Slv, value);
}
private void btnSavePosition_Click(object sender, EventArgs e)
{
//料仓格子位置保存
string selectPositionNum = cmbPosition.Text;
AutoStorePosition ktkPosition = CSVPositionReader<AutoStorePosition>.GetPositon(selectPositionNum);
if (ktkPosition != null)
{
ktkPosition.MiddleAxis_Position_P2 = FormUtil.GetIntValue(txtMiddleP2);
ktkPosition.UpDownAxis_IHPosition_P3 = FormUtil.GetIntValue(txtUpDownP3);
ktkPosition.UpDownAxis_ILPosition_P4 = FormUtil.GetIntValue(txtUpDownP4);
ktkPosition.UpDownAxis_ILPosition_P4 = FormUtil.GetIntValue(txtUpDownP4);
ktkPosition.InOutAxis_Position_P3 = FormUtil.GetIntValue(txtInOutP3);
ktkPosition.CompressAxis_CPosition_P3 = FormUtil.GetIntValue(txtComP3);
ktkPosition.UpDownAxis_OHPosition_P5 = FormUtil.GetIntValue(txtUpDownP5);
ktkPosition.UpDownAxis_OLPosition_P6 = FormUtil.GetIntValue(txtUpDownP6);
ktkPosition.CompressAxis_Position_P2 = FormUtil.GetIntValue(txtComP2);
//ktkPosition.InOutAxis_DoorPosition_P4 = FormUtil.GetIntValue(txtInOutP2);
}
//位置配置
if (!File.Exists(positionConfigFile))
{
positionConfigFile = appPath + ConfigAppSettings.GetValue(Setting_Init.Store_Position_Config, "_" + store.StoreID.ToString());
}
bool result = CSVPositionReader<AutoStorePosition>.SavePostion(positionConfigFile, ktkPosition);
if (!result)
{
MyMessage.Show("保存位置失败!");
}
}
bool preOpen = false;
private void timer1_Tick(object sender, EventArgs e)
{
if (!Visible)
return;
if (store.storeRunStatus == StoreRunStatus.Wait)
{
btnStartAuTo.Text = StartAuto;
return;
}
if (store.autoNext)
{
string msg = store.autoMsg;
lblMsg.Text = msg;
if (btnStartAuTo.Text.Equals(StartAuto))
{
btnStartAuTo.Text = StopAuto;
}
try
{
msg = msg.Replace(AutoOut, "");
msg = msg.Replace(AutoIn, "");
if (htpp.ContainsKey(msg))
{
var pp = (PosPos)htpp[msg];
dataGridView1.Rows[pp.row].Cells[pp.col].Selected=true;
setData(msg);
}
}
catch (Exception ex) { }
}
else
{
// lblMsg.Text = "没有开启自动出入库";
if (btnStartAuTo.Text.Equals(StopAuto))
{
btnStartAuTo.Text = StartAuto;
}
}
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex<0 || dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag == null)
return;
var posid = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag.ToString();
setData(posid);
}
private void checkBox_Double_Alternate_CheckedChanged(object sender, EventArgs e)
{
var obj = sender as CheckBox;
//store.Double_Alternate = obj.Checked;
if (obj.Checked)
{
txtJiange.Text = "1";
txtJiange.Enabled = false;
}
else
txtJiange.Enabled = true;
}
private void btnInOutP1_Click(object sender, EventArgs e)
{
//if (store.InOutAxisCanMove().Equals(false))
//{
// MyMessage.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
//}
AxisABSMove(store.Config.InOut_Axis, store.Config.InOutAxis_P1_Position, store.Config.InOutAxis_P1_Speed);
}
private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.RowIndex < 0 || dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag == null)
return;
var posid = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag.ToString();
setData(posid);
}
void setAxisPopup(Control c, Control title, ConfigMoveAxis configMoveAxis)
{
c.Tag = "A";
c.Click += (cc, e) =>
{
AxisTipControl axisTipControl = new AxisTipControl();
axisTipControl.ShowTips((Control)cc, title.Text, configMoveAxis.GetAxisValue(), configMoveAxis.TargetSpeed);
};
}
}
}