MainMachine _IOMonitor.cs
3.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
using CodeLibrary;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceLibrary
{
partial class MainMachine
{
void ioMonitor()
{
if (IOValue(IO_Type.Airpressure_Check).Equals(IO_VALUE.LOW)) {
Msg.add(crc.GetString(L.not_detect_airpressure, "未检测到气压信号."), MsgLevel.warning);
}
if ((StringState >= StringStateE.OutStore) && IOValue(IO_Type.DoorClose_LoadMaterial).Equals(IO_VALUE.LOW)) {
StringState = StringStateE.None;
}
airprocess();
}
public double Current_Humidity = 0;
public double Current_Temperate = 0;
bool airisopen = false;
DateTime lastAirprocesstime = DateTime.Now;
void airprocess()
{
if ((DateTime.Now - lastAirprocesstime).TotalSeconds < 5)
return;
lastAirprocesstime = DateTime.Now;
//var temp = HumitureController.QueryData();
var temp = HumitureController.LastData;
Current_Humidity = temp.Humidity;
Current_Temperate = temp.Temperate;
//var tempIsOK = Current_Temperate < ServerCM.Max_Temperature;
var humiNeedStart = Current_Humidity > ServerCM.Max_Humidity - Setting_Init.Device_HumidityStartOffser;
var humiNeedStop = Current_Humidity < ServerCM.Max_Humidity - Setting_Init.Device_HumidityEndOffser;
if (humiNeedStart && !airisopen)
{
IOMove(IO_Type.NitrogenValve, IO_VALUE.HIGH);
airisopen = true;
LogUtil.info($"开始吹气,当前最大湿度:{Current_Humidity} > {ServerCM.Max_Humidity}-{Setting_Init.Device_HumidityStartOffser}.");
}
else if (humiNeedStop && airisopen)
{
IOMove(IO_Type.NitrogenValve, IO_VALUE.LOW);
airisopen = false;
LogUtil.info($"关闭吹气,当前最大湿度:{Current_Humidity} < {ServerCM.Max_Humidity}-{Setting_Init.Device_HumidityEndOffser}.");
}
}
bool lastTHoutRangeStatus = false;
DateTime lastTHoutRangeTime = DateTime.MaxValue;
bool IsTHoutRange()
{
if (HumitureController.LastData.Humidity > ServerCM.Max_Humidity// || HumitureController.LastData.Humidity < ServerCM.Min_Humidity
|| HumitureController.LastData.Temperate > ServerCM.Max_Temperature)
{
if (!lastTHoutRangeStatus)
lastTHoutRangeTime = DateTime.Now;
lastTHoutRangeStatus = true;
return true;
}
else
{
if (lastTHoutRangeStatus)
lastTHoutRangeTime = DateTime.MaxValue;
lastTHoutRangeStatus = false;
return false;
}
}
bool IsTHoutRangeOver30m() {
return (DateTime.Now - lastTHoutRangeTime).TotalMinutes > 30;
}
}
}