BatchAxisController.cs
2.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
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.DeviceLibrary
{
/// <summary>
/// 批量上下料 轴,检测料盘检测信号处理
/// </summary>
public class BatchAxisController
{
private static bool IsStop = false;
private static System.Timers.Timer checkTimer = null;
private static string TargetIoType = IO_Type.TrayCheck_LoadMaterial;
public static bool StartCheck(string targetIo)
{
if (checkTimer == null)
{
checkTimer = new System.Timers.Timer();
checkTimer.AutoReset = true;
checkTimer.Interval += 49;
checkTimer.Elapsed += CheckTimer_Elapsed;
checkTimer.Enabled = false;
}
TargetIoType = targetIo;
checkTimer.Start();
return true;
}
public static bool StopCheck()
{
if (!(checkTimer == null))
{
checkTimer.Stop();
}
return true;
}
private static bool IsInProcess = false;
private static DateTime preTime = DateTime.Now;
private static void CheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (IsInProcess) { return; }
IsInProcess = true;
bool result = false;
if (IOManager.IOValue(TargetIoType).Equals(IO_VALUE.HIGH))
{
LogUtil.info("批量上料轴,检测到【" + TargetIoType + "】信号,可以停止运动");
result = true;
}
//TimeSpan span = DateTime.Now - preTime;
//if (span.TotalMilliseconds > 100)
//{
else if (IOManager.IOValue(IO_Type.BatchAxis_Limit).Equals(IO_VALUE.HIGH))
//if (ACServerManager.GetLimitPositiveSingle(StoreManager.Config.Batch_Axis).Equals(1))
{
LogUtil.info("批量上料轴,检测到正极限信号,可以停止运动");
result = true;
}
if (result)
{
//AutoAxisIsMove = 0;
LogUtil.debug("批量上料轴, 停止运动");
ACServerManager.SuddenStop(StoreManager.Config.Batch_Axis.DeviceName, StoreManager.Config.Batch_Axis.GetAxisValue());
StopCheck();
}
preTime = DateTime.Now;
IsInProcess = false;
}
}
}