Commit a5a04c66 张东亮

添加温湿度显示以及上报

1 个父辈 04ccfb05
......@@ -277,5 +277,9 @@ namespace OnlineStore.Common
public static string executeTime = "executeTime ";
public static string code = "code";
/// <summary>
/// 温湿度列表
/// </summary>
public static string humiAndtempList = "humiAndtempList";
}
}
......@@ -11,7 +11,7 @@ AXIS,0,B面移栽旋转轴,MiddleAxis_B,8,HC,,35000,300000,300000,2000,10000,200
AXIS,0,B面移栽压紧轴,ComAxis_B,9,HC,,20000,150000,150000,2000,10000,20000,10,100,0,0
,,,,,,,,,,,,,,,,
PRO,0,设备是否处于调试状态(1=调试,0=正常),IsDebug,0,,,,,,,,,,,,
PRO,0,温湿度端口号,Humiture_Port,0,,,,,,,,,,,,
PRO,0,温湿度端口号,Humiture_Port,COM1#COM2#COM3#COM4,,,,,,,,,,,,
PRO,0,两次吹气间隔(分钟),BlowAir_Interval,0,,,,,,,,,,,,
PRO,0,每次吹气的时间(分钟),BlowAir_Time,0,,,,,,,,,,,,
PRO,0,氮气安全浓度,Nitrogen_Safe_Maximum,80,,,,,,,,,,,,
......
......@@ -67,7 +67,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public AxisBean[] moveAxisArray;
//温湿度
public HumitureBean humBean = null;
//public HumitureBean humBean = null;
public string lastPosId = "";
public string lastBarcode = "";
public string executeTime = "";
......@@ -118,7 +118,9 @@ namespace OnlineStore.DeviceLibrary
IoCheckTimer.Elapsed += IoCheckTimerProcess;
MoveInfo = new DeviceMoveInfo(" 存储机构 ");
//温湿度
humBean = new HumitureBean(config.Humiture_Port, Name);
string[] ports = config.Humiture_Port.Split('#');
HumitureBean.LoadHumitures(ports, Name);
//humBean = new HumitureBean(config.Humiture_Port, Name);
InitRowColumnSig();
InitAllAxis();
InitPosititionNumList();
......
......@@ -47,7 +47,8 @@ namespace OnlineStore.DeviceLibrary
lastConTime = DateTime.Now;
try
{
humBean.HumidityProcess(this);
//humBean.HumidityProcess(this);
HumitureBean.ProcessAllHumidity(this);
if (IsDebug)
{
......@@ -157,18 +158,43 @@ namespace OnlineStore.DeviceLibrary
//温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.Temperate_Serveraddress);
HumitureParam param = humBean.LastData;
if (param != null)
{
boxStatus.humidity = param.Humidity.ToString();
boxStatus.temperature = param.Temperate.ToString();
}
//HumitureParam param = humBean.LastData;
//if (param != null)
//{
// boxStatus.humidity = param.Humidity.ToString();
// boxStatus.temperature = param.Temperate.ToString();
//}
lineOperation.boxStatus.Add(1, boxStatus);
if (!alarmType.Equals(AlarmType.None))
{
lineOperation.alarmList.Add(alarmInfo);
}
//添加温湿度列表
try
{
List<HumitureParam> humitureParams = HumitureBean.GetHumitureParams();
if (humitureParams != null)
{
List<Dictionary<string, string>> valuePairs = new List<Dictionary<string, string>>();
for (int i = 0; i < humitureParams.Count; i++)
{
boxStatus.humidity = humitureParams[i].Humidity.ToString();
boxStatus.temperature = humitureParams[i].Temperate.ToString();
Dictionary<string, string> vals = new Dictionary<string, string>();
vals.Add("id", (i + 1).ToString());
vals.Add("humidity", humitureParams[i].Humidity.ToString());
vals.Add("temperature", humitureParams[i].Temperate.ToString());
valuePairs.Add(vals);
}
boxStatus.data.Add(ParamDefine.humiAndtempList, JsonHelper.SerializeObject(valuePairs));
//LogUtil.info($"上报温湿度数据【{JsonHelper.SerializeObject(valuePairs)}】【{JsonHelper.SerializeObject(boxStatus.data)}】");
}
}
catch(Exception ex)
{
LogUtil.error("上报温湿度数据异常",ex);
}
return lineOperation;
}
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
......@@ -178,7 +204,7 @@ namespace OnlineStore.DeviceLibrary
//构建发送给服务器的对象
Operation lineOperation = getLineBoxStatus();
//如果还没湿度范围,先获取
if (humBean.NeedGetTem())
if (HumitureBean.NeedGetTem())
{
lineOperation.op = 5;
LogUtil.error(Name + "没有湿度预警范围,需要从服务器获取,发送OP=" + lineOperation.op, DeviceID + 105);
......@@ -201,7 +227,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (resultOperation.op.Equals(5))
{
humBean.ProcessHumidityCMD(resultOperation);
HumitureBean.ProcessHumidityCMD(resultOperation);
}
else
{
......
using OnlineStore.Common;
using Emgu.CV.DepthAI;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
......@@ -13,13 +14,20 @@ namespace OnlineStore.DeviceLibrary
private string PortName = "";
private string Name = "";
public HumitureParam LastData = new HumitureParam(0, 0,0);
static List<HumitureBean> humitureBeans = new List<HumitureBean>();
internal HumitureBean(string port,string deviceName)
{
this.Name = deviceName;
this.PortName = port;
HumitureController.Init(this.PortName);
}
public static void LoadHumitures(string[] ports,string deviceName)
{
for (int i = 0; i < ports.Length; i++)
{
humitureBeans.Add(new HumitureBean(ports[i], deviceName + (i + 1)));
}
}
public HumitureParam QueryData()
{
HumitureParam param = HumitureController.QueryData(PortName);
......@@ -27,24 +35,37 @@ namespace OnlineStore.DeviceLibrary
return LastData;
}
internal void ProcessHumidityCMD(Operation resultOperation)
public static double GetMinOxygenV()
{
double maxV=0.0;
foreach (var item in humitureBeans)
{
double val= item.QueryData().OxygenV;
if (val > maxV)
{
maxV = val;
}
}
return maxV;
}
internal static void ProcessHumidityCMD(Operation resultOperation)
{
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.maxHumidity) && data.ContainsKey(ParamDefine.maxTemperature))
{
string maxHumidity = data[ParamDefine.maxHumidity];
string maxTemp = data[ParamDefine.maxTemperature];
LogUtil.info( Name+"收到服务器温湿度预警值:maxHumidity=" + maxHumidity + ",maxTemperature=" + maxTemp);
LogUtil.info("收到服务器温湿度预警值:maxHumidity=" + maxHumidity + ",maxTemperature=" + maxTemp);
try
{
this.Max_Humidity = (float)Convert.ToDouble(maxHumidity);
this.Max_Temperature = (float)Convert.ToDouble(maxTemp);
LogUtil.info(Name+"保存温湿度预警值:Max_Humidity=" + Max_Humidity + ",Max_Temperature=" + Max_Temperature);
Max_Humidity = (float)Convert.ToDouble(maxHumidity);
Max_Temperature = (float)Convert.ToDouble(maxTemp);
LogUtil.info("保存温湿度预警值:Max_Humidity=" + Max_Humidity + ",Max_Temperature=" + Max_Temperature);
}
catch (Exception ex)
{
LogUtil.error(Name+"转换温湿度失败:" + ex.ToString());
LogUtil.error("转换温湿度失败:" + ex.ToString());
}
}
}
......@@ -53,11 +74,11 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 湿度标准,超过后需要报警
/// </summary>
private float Max_Humidity = 0;
static float Max_Humidity = 0;
/// <summary>
/// 温度标准,超过后需要报警
/// </summary>
private float Max_Temperature = 0;
static float Max_Temperature = 0;
private bool IsInBlowing = false;
private DateTime LastBeginBlowTime = DateTime.Now;
private DateTime LastEndBlowTime = new DateTime(1997, 1, 1);
......@@ -69,6 +90,22 @@ namespace OnlineStore.DeviceLibrary
private float StartBlowValue = (float)ConfigAppSettings.GetNumValue(Setting_Init.StartBlowValue);
private float StopBlowValue = (float)ConfigAppSettings.GetNumValue(Setting_Init.StopBlowValue);
public string currTempStr = "";
public static void ProcessAllHumidity(BoxEquip box)
{
foreach (var item in humitureBeans)
{
item.HumidityProcess(box);
}
}
public static List<HumitureParam> GetHumitureParams()
{
List<HumitureParam> humitureParams = new List<HumitureParam>();
foreach (var item in humitureBeans)
{
humitureParams.Add(item.LastData);
}
return humitureParams;
}
internal void HumidityProcess(BoxEquip box)
{
if (IOManager.IOValue(IO_Type.Air_OpenValve, 1).Equals(IO_VALUE.HIGH) || IOManager.IOValue(IO_Type.LeftDoor_Limit, 2).Equals(IO_VALUE.LOW) || IOManager.IOValue(IO_Type.RightDoor_Limit, 2).Equals(IO_VALUE.LOW) || IOManager.IOValue(IO_Type.BackDoor_Limit, 2).Equals(IO_VALUE.LOW))
......@@ -184,7 +221,7 @@ namespace OnlineStore.DeviceLibrary
TempOrHumidityIsAlarm = true;
}
internal bool NeedGetTem()
internal static bool NeedGetTem()
{
if (Max_Humidity <= 0 || (Max_Temperature <= 0))
{
......@@ -255,6 +292,6 @@ namespace OnlineStore.DeviceLibrary
/// 湿度
/// </summary>
public double Humidity { get; set; }
public double OxygenV { get; set; }
public double OxygenV { get; set; } = 100;
}
}
......@@ -102,6 +102,7 @@ namespace OnlineStore.DeviceLibrary
public static HumitureParam QueryData(string port)
{
HumitureParam param = new HumitureParam(0, 0,0);
param.DeviceAddress = port;
List<double> data = queryData(port );
if (data.Count.Equals(3))
{
......
......@@ -588,6 +588,7 @@ namespace OnlineStore.LoadCSVLibrary
/// </summary>
[ConfigProAttribute("Humiture_Port", true)]
public string Humiture_Port { get; set; }
#endregion
#region 列信号开启
......
......@@ -44,8 +44,8 @@ namespace OnlineStore.XLRStore
IOManager.IOMove(IO_Type.Air_OpenValve, IO_VALUE.HIGH,1);
IOManager.IOMove(IO_Type.Nitrogen_OpenValve, IO_VALUE.LOW,1);
var dd= StoreManager.XLRStore.boxEquip.humBean.QueryData();
var nitrogen = 100- dd.OxygenV-1;
var dd= HumitureBean.GetMinOxygenV();
var nitrogen = 100- dd;
if (nitrogen <= StoreManager.XLRStore.boxEquip.Config.Nitrogen_Safe_Maximum) {
IOManager.IOMove(IO_Type.SafeDoor_Close, IO_VALUE.LOW,1);
......
......@@ -97,6 +97,7 @@
<Reference Include="UserFromControl">
<HintPath>..\..\dll\UserFromControl.dll</HintPath>
</Reference>
<Reference Include="XLRStore, Version=1.0.8382.29494, Culture=neutral, PublicKeyToken=null" />
</ItemGroup>
<ItemGroup>
<Compile Include="boxForm\FrmAxisMove.cs">
......@@ -216,6 +217,12 @@
<Compile Include="useControl\EquipControl.Designer.cs">
<DependentUpon>EquipControl.cs</DependentUpon>
</Compile>
<Compile Include="useControl\UCHumitempure.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="useControl\UCHumitempure.Designer.cs">
<DependentUpon>UCHumitempure.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="boxForm\FrmAxisMove.resx">
<DependentUpon>FrmAxisMove.cs</DependentUpon>
</EmbeddedResource>
......@@ -295,6 +302,9 @@
<Content Include="model\sr.prototxt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="useControl\UCHumitempure.resx">
<DependentUpon>UCHumitempure.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.manifest" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
......
......@@ -25,6 +25,7 @@ namespace OnlineStore.XLRStore
FrmAxisMove frmAxisMove = null;
private bool IsLoad = false;
private BoxEquip boxBean;
List<UCHumitempure> humitempures = new List<UCHumitempure>();
internal FrmBoxEquip(BoxEquip moveEquip)
{
this.boxBean = moveEquip;
......@@ -37,7 +38,10 @@ namespace OnlineStore.XLRStore
chbMoveStop.Checked = boxBean.MoveStop;
lblStoreStatus.Text = DeviceBase.GetRunStr(boxBean.runStatus);
lblThisSta.Text = boxBean.WarnMsg;
humitempures.Add(ucHumitempure1);
humitempures.Add(ucHumitempure2);
humitempures.Add(ucHumitempure3);
humitempures.Add(ucHumitempure4);
lblName.Text = boxBean.Name;
this.Text = boxBean.Name;
chbDebug.Checked = boxBean.IsDebug;
......@@ -298,6 +302,14 @@ namespace OnlineStore.XLRStore
//{
// btnHlhasReel.Visible = false;
//}
List<HumitureParam> huparam=HumitureBean.GetHumitureParams();
for (int i = 0; i < humitempures.Count; i++)
{
humitempures[i].Humiti = huparam[i].Humidity;
humitempures[i].Tempure = huparam[i].Temperate;
humitempures[i].Nitrogen = 100-huparam[i].OxygenV;
humitempures[i].HumiName = huparam[i].DeviceAddress;
}
}
catch (Exception ex)
{
......
namespace OnlineStore.XLRStore
{
partial class UCHumitempure
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.lblHumiti = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.lblNitrogen = new System.Windows.Forms.Label();
this.lblTempure = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// lblHumiti
//
this.lblHumiti.AutoSize = true;
this.lblHumiti.Location = new System.Drawing.Point(15, 34);
this.lblHumiti.Name = "lblHumiti";
this.lblHumiti.Size = new System.Drawing.Size(55, 15);
this.lblHumiti.TabIndex = 0;
this.lblHumiti.Text = "label1";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.lblNitrogen);
this.groupBox1.Controls.Add(this.lblTempure);
this.groupBox1.Controls.Add(this.lblHumiti);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox1.Location = new System.Drawing.Point(0, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(194, 118);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "温湿度传感器";
//
// lblNitrogen
//
this.lblNitrogen.AutoSize = true;
this.lblNitrogen.Location = new System.Drawing.Point(15, 88);
this.lblNitrogen.Name = "lblNitrogen";
this.lblNitrogen.Size = new System.Drawing.Size(55, 15);
this.lblNitrogen.TabIndex = 2;
this.lblNitrogen.Text = "label3";
//
// lblTempure
//
this.lblTempure.AutoSize = true;
this.lblTempure.Location = new System.Drawing.Point(15, 61);
this.lblTempure.Name = "lblTempure";
this.lblTempure.Size = new System.Drawing.Size(55, 15);
this.lblTempure.TabIndex = 1;
this.lblTempure.Text = "label2";
//
// UCHumitempure
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.groupBox1);
this.Name = "UCHumitempure";
this.Size = new System.Drawing.Size(194, 118);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Label lblHumiti;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label lblNitrogen;
private System.Windows.Forms.Label lblTempure;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.XLRStore
{
public partial class UCHumitempure : UserControl
{
public UCHumitempure()
{
InitializeComponent();
}
public string HumiName
{
set
{
try
{
this.Invoke(new Action(() =>
{
groupBox1.Text = value;
}));
}
catch { }
}
}
public double Tempure
{
set
{
try
{
this.Invoke(new Action(() =>
{
lblTempure.Text = $"温度:{value}℃";
}));
}
catch { }
}
}
public double Humiti
{
set
{
try
{
this.Invoke(new Action(() =>
{
lblHumiti.Text = $"湿度:{value}%";
}));
}
catch { }
}
}
public double Nitrogen
{
set
{
try
{
this.Invoke(new Action(() =>
{
lblNitrogen.Text = $"氮气:{value}%";
}));
}
catch { }
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!