StockInfo.cs
4.5 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
using PUSICANLibrary;
using System;
using System.Collections.Generic;
using System.Threading;
using TSA_V.Common;
using TSA_V.LoadCSVLibrary;
namespace TSA_V.DeviceLibrary
{
/// <summary>
/// 备料信息
/// </summary>
public class StockInfo
{
/// <summary>
/// 是否在工作中,在插件中,会接受信号移动位置
/// </summary>
public bool IsWorking = false;
public TSAVPosition currPosition = null;
public bool IsWaitMove = false;
public List<WaitResultInfo> waitList = new List<WaitResultInfo>();
public DateTime endWorkTime = DateTime.Now;
public DateTime LastSetpTime = DateTime.Now;
public uint PreNodeId = 0;
private List<int> PreRgbLed = new List<int>();
public void StartWork()
{
//开始工作
IsWorking = true;
endWorkTime = DateTime.Now;
IsWaitMove = false;
}
public void StopWork()
{
PUSICANControl.StopMove(PreNodeId);
//把上次的旋转轴转回待机点
if (PreNodeId > 0)
{
//上一个节点返回原点
PUSICANControl.AbsMove(PreNodeId, TSAVBean.RotateNode_DefaultPosition);
}
if (PreLabel != null)
{
LedLabelController.CloseLed(PreLabel.ip, PreLabel.mac);
}
if (PreRgbLed.Count > 0)
{
RgbLedController.CloseAll();
}
Thread.Sleep(500);
endWorkTime = DateTime.Now;
IsWorking = false;
IsWaitMove = false;
}
public void EndWait()
{
endWorkTime = DateTime.Now;
IsWaitMove = false;
waitList = new List<WaitResultInfo>();
}
private LabelInfo PreLabel = null;
public void MoveToBag(TSAVPosition position, ComponetInfo componet)
{
try
{
currPosition = position;
waitList = new List<WaitResultInfo>();
IsWaitMove = true;
LastSetpTime = DateTime.Now;
if (PreLabel != null)
{
LedLabelController.CloseLed(PreLabel.ip, PreLabel.mac);
Thread.Sleep(300);
}
if (PreRgbLed.Count > 0)
{
RgbLedController.CloseAll();
}
if (position.IsNodePos())
{
NodeInfo moveNode = position.GetNode(TSAVBean.RotateMap);
if (moveNode != null)
{
if (PreNodeId > 0 && !(moveNode.NodeId.Equals(PreNodeId)))
{
//上一个节点返回原点
PUSICANControl.AbsMove(PreNodeId, TSAVBean.RotateNode_DefaultPosition);
Thread.Sleep(50);
}
PUSICANControl.AbsMove(moveNode.NodeId, position.RotatePosition);
waitList.Add(WaitResultInfo.WaitNode(moveNode, position.RotatePosition));
PreNodeId = moveNode.NodeId;
}
else
{
LogUtil.error("positionNum=" + position.PositionNum + ",未找到对应的运动轴!");
}
}
else if (position.IsLedLabel())
{
if (PreNodeId > 0)
{
PUSICANControl.AbsMove(PreNodeId, TSAVBean.RotateNode_DefaultPosition);
}
PreNodeId = 0;
LabelInfo label = LedLabelController.GetLabel(position, componet, true);
LedLabelController.UpdateScreen(label);
PreLabel = label;
}
else if (position.IsRgbLed())
{
if (PreNodeId > 0)
{
PUSICANControl.AbsMove(PreNodeId, TSAVBean.RotateNode_DefaultPosition);
}
PreNodeId = 0;
RgbLedController.OpenPosLed(position);
PreRgbLed = position.getLedList();
waitList.Add(WaitResultInfo.WaitTime(500));
}
}
catch (Exception ex)
{
LogUtil.error("MoveToBag 出错:" + ex.ToString());
}
}
}
}