Commit 4042e400 LN

1.温湿度bug修改。2.增加日志。3.增加温湿度功能勾选功能。

1 个父辈 4e8ef533
......@@ -287,7 +287,7 @@ namespace OnlineStore.Common
if (_serialPort.IsOpen)
{
//lock (lockObj)
if(Monitor.TryEnter(lockObj,10))
if(Monitor.TryEnter(lockObj,1))
{
//Monitor.Enter(lockObj);
try
......

using log4net;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
......@@ -21,6 +22,8 @@ namespace OnlineStore.Common
private static string LogName = "";
private static Dictionary<string, AcSerialBean> serialBeanMap = new Dictionary<string, AcSerialBean>();
private static ConcurrentDictionary<string, HumitureParam> lastDataMap = new ConcurrentDictionary<string, HumitureParam>();
public static int HumitureControllerType = ConfigAppSettings.GetIntValue(Setting_Init.HumitureControllerType);
public static bool Init(string port)
{
......@@ -92,16 +95,30 @@ namespace OnlineStore.Common
return serialBeanMap[portName];
}
return null;
}
// public static ASTemperateParam LastData = new ASTemperateParam(0, 0);
}
public static HumitureParam QueryData(string port)
{
if(lastDataMap.TryGetValue(port ,out HumitureParam lastparam))
{
//1秒以内不需要重新查询
TimeSpan span = DateTime.Now - lastparam.UpdateTime;
if (span.TotalSeconds <= 5)
{
return lastparam;
}
else
{
lastDataMap.TryRemove(port, out lastparam);
}
}
HumitureParam param = new HumitureParam(0, 0);
List<double> data = queryData(port);
if (data.Count.Equals(2))
{
param = new HumitureParam(data[1], data[0]);
}
lastDataMap.TryAdd(port, param);
return param;
}
/// <summary>
......
......@@ -488,8 +488,19 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(Name + " 报警,报警类型:" + alarmType);
this.alarmType = alarmType;
if (alarmType.Equals(StoreAlarmType.AxisAlarm) | alarmType.Equals(StoreAlarmType.AxisMoveError))
if (alarmType.Equals(StoreAlarmType.AxisAlarm) || alarmType.Equals(StoreAlarmType.AxisMoveError))
{
if (MoveInfo.MoveType.Equals(StoreMoveType.InStore) || MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
if (alarmDetial.Equals(LineAlarm.InOutAxisAlarm.ToString()) && MoveInfo.MoveParam != null && MoveInfo.MoveParam.PosInfo != null)
{
string posId = MoveInfo.MoveParam.PosInfo.PosId;
LogUtil.info(Name + " [" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "]" + MoveInfo.MoveParam.PosInfo.ToStr() + " 过程中进出轴报警,记录库位号["+ posId + "]");
//TODO
}
}
LogUtil.error(Name + "轴报警,关闭刹车,停止运动,关闭轴,打开报警灯");
//IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
StopMove();
......@@ -1048,10 +1059,14 @@ namespace OnlineStore.DeviceLibrary
if (isInProcess)
{
TimeSpan span = DateTime.Now - lastConTime;
if (span.TotalSeconds < 60)
if (span.TotalSeconds < 3)
{
return;
}
else
{
LogUtil.error($"{Name}server_connect_timer_Tick 已耗时{span.TotalSeconds}秒,重新处理");
}
}
isInProcess = true;
lastConTime = DateTime.Now;
......@@ -1082,7 +1097,10 @@ namespace OnlineStore.DeviceLibrary
}
}
}
humBean.HumidityProcess(this);
if (StoreManager.Store.UseTemp)
{
humBean.HumidityProcess(this);
}
}
catch (Exception ex)
{
......
......@@ -72,12 +72,10 @@ namespace OnlineStore.DeviceLibrary
{
try
{
if ((DateTime.Now - preLogTime).TotalSeconds > (8 + box.DeviceID))
if ((DateTime.Now - preLogTime).TotalSeconds > (5 + box.DeviceID))
{
preLogTime = DateTime.Now;
//用最大的湿度判断是否需要吹气,开始吹气的值=发过来的值-4
//温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.GetTempAddrList());
HumitureParam param = QueryData();
double humidity = 0;
double temp = 0;
......@@ -87,48 +85,10 @@ namespace OnlineStore.DeviceLibrary
temp = param.Temperate;
currTempStr = Name + ("湿度:" + humidity.ToString() + ",温度:" + temp);
}
//double currMaxHumidity = HumitureServer.GetMaxHumidity(Config.GetTempAddrList());
double currMaxHumidity = param.Humidity;
float startBlowHumidity = Max_Humidity - StartBlowValue;
float stopBlowHumidity = Max_Humidity - StopBlowValue;
////判断是否需要吹气
//if (startBlowHumidity > 0 && startBlowHumidity < currMaxHumidity && IsInBlowing.Equals(false))
//{
// //判断是否距离上次结束指定的时间
// TimeSpan span = DateTime.Now - LastEndBlowTime;
// if (span.TotalMinutes > box.Config.BlowAir_Interval)
// {
// LogUtil.info(Name + "当前最大湿度:" + currMaxHumidity.ToString() + ",开始吹气湿度:" + startBlowHumidity + ",当前不在吹气中,且间隔超过" + box.Config.BlowAir_Interval + "分钟,开始吹气!");
// IsInBlowing = true;
// //Thread.Sleep(100);
// box.IOMove(IO_Type.StartOrStopBlow, IO_VALUE.HIGH);
// LastBeginBlowTime = DateTime.Now;
// LastEndBlowTime = DateTime.Now;
// }
//}
//if (IsInBlowing && stopBlowHumidity > currMaxHumidity)
//{
// LogUtil.info(Name + "当前最大湿度:" + currMaxHumidity.ToString() + ",停止吹气湿度:" + stopBlowHumidity + ",停止吹气!");
// IsInBlowing = false;
// box.IOMove(IO_Type.StartOrStopBlow, IO_VALUE.LOW);
// LastEndBlowTime = DateTime.Now;
//}
//if (IsInBlowing)
//{
// //判断是否需要结束吹气
// TimeSpan span = DateTime.Now - LastBeginBlowTime;
// if (span.TotalMinutes > box.Config.BlowAir_Time)
// {
// LogUtil.info(Name + "已经吹气" + span.TotalMinutes + "分钟,超过配置的吹气时间" + box.Config.BlowAir_Time + "分钟,停止吹气!");
// IsInBlowing = false;
// //Thread.Sleep(100);
// box.IOMove(IO_Type.StartOrStopBlow, IO_VALUE.LOW);
// LastEndBlowTime = DateTime.Now;
// }
//}
bool needAlarm = false;
//如果开始吹气并且当前达到报警值
if (IsInBlowing && humidity > Max_Humidity)
......
......@@ -22,6 +22,7 @@ namespace OnlineStore.DeviceLibrary
public Dictionary<int, BoxConfig> BoxConfigMap { get; set; }
public Dictionary<int, BoxBean> BoxMap = new Dictionary<int, BoxBean>();
public bool UseBuzzer = true;
public bool UseTemp = true;
public StoreConfig Config { get; set; }
#region 初始化
......
......@@ -315,12 +315,13 @@
this.groupBox1.Controls.Add(this.label43);
this.groupBox1.Controls.Add(this.label42);
this.groupBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox1.Location = new System.Drawing.Point(11, 464);
this.groupBox1.Location = new System.Drawing.Point(11, 462);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(476, 136);
this.groupBox1.TabIndex = 217;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "伺服状态";
this.groupBox1.Visible = false;
//
// txt4Target
//
......@@ -494,7 +495,7 @@
this.groupBox2.Controls.Add(this.button6);
this.groupBox2.Controls.Add(this.button3);
this.groupBox2.Controls.Add(this.button5);
this.groupBox2.Location = new System.Drawing.Point(11, 380);
this.groupBox2.Location = new System.Drawing.Point(11, 378);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(476, 78);
this.groupBox2.TabIndex = 276;
......@@ -1444,10 +1445,10 @@
// tabPage1
//
this.tabPage1.Controls.Add(this.panel1);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Location = new System.Drawing.Point(4, 29);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(192, 74);
this.tabPage1.Size = new System.Drawing.Size(1091, 607);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = " IO调试 ";
this.tabPage1.UseVisualStyleBackColor = true;
......
......@@ -55,6 +55,8 @@
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
this.开机自动启动ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator15 = new System.Windows.Forms.ToolStripSeparator();
this.启用蜂鸣器ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator();
this.开启DEBUG日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
......@@ -321,6 +323,8 @@
this.开机自动启动ToolStripMenuItem,
this.toolStripSeparator10,
this.启用蜂鸣器ToolStripMenuItem,
this.toolStripSeparator15,
this.toolStripMenuItem5,
this.toolStripSeparator11,
this.开启DEBUG日志ToolStripMenuItem});
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
......@@ -339,6 +343,18 @@
this.toolStripSeparator10.Name = "toolStripSeparator10";
this.toolStripSeparator10.Size = new System.Drawing.Size(196, 6);
//
// toolStripMenuItem5
//
this.toolStripMenuItem5.Name = "toolStripMenuItem5";
this.toolStripMenuItem5.Size = new System.Drawing.Size(199, 26);
this.toolStripMenuItem5.Text = "启用温湿度";
this.toolStripMenuItem5.Click += new System.EventHandler(this.toolStripMenuItem5_Click);
//
// toolStripSeparator15
//
this.toolStripSeparator15.Name = "toolStripSeparator15";
this.toolStripSeparator15.Size = new System.Drawing.Size(196, 6);
//
// 启用蜂鸣器ToolStripMenuItem
//
this.启用蜂鸣器ToolStripMenuItem.Name = "启用蜂鸣器ToolStripMenuItem";
......@@ -599,6 +615,8 @@
private System.Windows.Forms.ToolStripMenuItem 打开设备照明ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator14;
private System.Windows.Forms.ToolStripMenuItem 关闭设备照明ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator15;
}
}
......@@ -64,6 +64,14 @@ namespace OnlineStore.ACSingleStore
{
启用蜂鸣器ToolStripMenuItem.Text = "启用蜂鸣器";
}
if (store.UseTemp)
{
toolStripMenuItem5.Text = gouStr + " 启用温湿度";
}
else
{
toolStripMenuItem5.Text = "启用温湿度";
}
foreach (BoxBean box in store.BoxMap.Values)
{
FrmBox frm = new FrmBox();
......@@ -661,5 +669,30 @@ namespace OnlineStore.ACSingleStore
{
btnCloseLed_Click(null, null);
}
private void toolStripMenuItem5_Click(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
bool result = !toolStripMenuItem5.Text.Contains(gouStr);
if (result.Equals(store.UseTemp))
{
return;
}
store.UseTemp = result;
if (result)
{
toolStripMenuItem5.Text = gouStr + " 启用温湿度";
}
else
{
toolStripMenuItem5.Text = "启用温湿度";
}
LogUtil.info(store.Name + "勾选:启用温湿度=" + result);
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!