Commit 999ff99e 几米阳光

增加新温湿度

1 个父辈 17c99dc5
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
<add key ="OutStoreWaitSeconds" value ="10"/> <add key ="OutStoreWaitSeconds" value ="10"/>
<!--压紧轴对应1mm的脉冲--> <!--压紧轴对应1mm的脉冲-->
<add key="ComAxisChangeValue" value="2400" /> <add key="ComAxisChangeValue" value="2400" />
<!--温控器类型,0=壁挂王字壳温湿度变送器,1=妙昕温湿度记录仪-->
<add key ="HumitureControllerType" value ="1"/>
</appSettings> </appSettings>
<log4net> <log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
......
...@@ -207,6 +207,17 @@ ...@@ -207,6 +207,17 @@
this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage1 = new System.Windows.Forms.TabPage();
this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage();
this.groupBox7 = new System.Windows.Forms.GroupBox(); this.groupBox7 = new System.Windows.Forms.GroupBox();
this.btnSelHistory = new System.Windows.Forms.Button();
this.txtHistoryTime = new System.Windows.Forms.TextBox();
this.label30 = new System.Windows.Forms.Label();
this.txtHistoryHum = new System.Windows.Forms.TextBox();
this.label26 = new System.Windows.Forms.Label();
this.txtHistoryTemp = new System.Windows.Forms.TextBox();
this.label22 = new System.Windows.Forms.Label();
this.txtCurrCount = new System.Windows.Forms.TextBox();
this.label23 = new System.Windows.Forms.Label();
this.txtHistoryCount = new System.Windows.Forms.TextBox();
this.label24 = new System.Windows.Forms.Label();
this.btnSelTemp = new System.Windows.Forms.Button(); this.btnSelTemp = new System.Windows.Forms.Button();
this.txtHum = new System.Windows.Forms.TextBox(); this.txtHum = new System.Windows.Forms.TextBox();
this.label29 = new System.Windows.Forms.Label(); this.label29 = new System.Windows.Forms.Label();
...@@ -235,6 +246,7 @@ ...@@ -235,6 +246,7 @@
this.button4 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button();
this.btnClearL = new System.Windows.Forms.Button(); this.btnClearL = new System.Windows.Forms.Button();
this.btnLogDebug = new System.Windows.Forms.Button(); this.btnLogDebug = new System.Windows.Forms.Button();
this.groupHistory = new System.Windows.Forms.GroupBox();
this.groupAxis.SuspendLayout(); this.groupAxis.SuspendLayout();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.groupInout.SuspendLayout(); this.groupInout.SuspendLayout();
...@@ -251,6 +263,7 @@ ...@@ -251,6 +263,7 @@
this.tabPage4.SuspendLayout(); this.tabPage4.SuspendLayout();
this.tabPage5.SuspendLayout(); this.tabPage5.SuspendLayout();
this.tabPage6.SuspendLayout(); this.tabPage6.SuspendLayout();
this.groupHistory.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// timer1 // timer1
...@@ -2377,6 +2390,7 @@ ...@@ -2377,6 +2390,7 @@
// //
// groupBox7 // groupBox7
// //
this.groupBox7.Controls.Add(this.groupHistory);
this.groupBox7.Controls.Add(this.btnSelTemp); this.groupBox7.Controls.Add(this.btnSelTemp);
this.groupBox7.Controls.Add(this.txtHum); this.groupBox7.Controls.Add(this.txtHum);
this.groupBox7.Controls.Add(this.label29); this.groupBox7.Controls.Add(this.label29);
...@@ -2388,18 +2402,138 @@ ...@@ -2388,18 +2402,138 @@
this.groupBox7.Controls.Add(this.btnTempInit); this.groupBox7.Controls.Add(this.btnTempInit);
this.groupBox7.Location = new System.Drawing.Point(7, 299); this.groupBox7.Location = new System.Drawing.Point(7, 299);
this.groupBox7.Name = "groupBox7"; this.groupBox7.Name = "groupBox7";
this.groupBox7.Size = new System.Drawing.Size(544, 134); this.groupBox7.Size = new System.Drawing.Size(544, 321);
this.groupBox7.TabIndex = 272; this.groupBox7.TabIndex = 272;
this.groupBox7.TabStop = false; this.groupBox7.TabStop = false;
this.groupBox7.Text = "温控器调试"; this.groupBox7.Text = "温控器调试";
// //
// btnSelHistory
//
this.btnSelHistory.Location = new System.Drawing.Point(369, 106);
this.btnSelHistory.Name = "btnSelHistory";
this.btnSelHistory.Size = new System.Drawing.Size(137, 33);
this.btnSelHistory.TabIndex = 259;
this.btnSelHistory.Text = "查询记录信息";
this.btnSelHistory.UseVisualStyleBackColor = true;
this.btnSelHistory.Click += new System.EventHandler(this.btnSelHistory_Click);
//
// txtHistoryTime
//
this.txtHistoryTime.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtHistoryTime.Location = new System.Drawing.Point(103, 109);
this.txtHistoryTime.MaxLength = 10;
this.txtHistoryTime.Name = "txtHistoryTime";
this.txtHistoryTime.Size = new System.Drawing.Size(224, 26);
this.txtHistoryTime.TabIndex = 258;
this.txtHistoryTime.Text = "0";
//
// label30
//
this.label30.AutoSize = true;
this.label30.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label30.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label30.Location = new System.Drawing.Point(29, 114);
this.label30.Name = "label30";
this.label30.Size = new System.Drawing.Size(68, 17);
this.label30.TabIndex = 257;
this.label30.Text = "记录时间:";
this.label30.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtHistoryHum
//
this.txtHistoryHum.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtHistoryHum.Location = new System.Drawing.Point(103, 65);
this.txtHistoryHum.MaxLength = 10;
this.txtHistoryHum.Name = "txtHistoryHum";
this.txtHistoryHum.Size = new System.Drawing.Size(87, 26);
this.txtHistoryHum.TabIndex = 256;
this.txtHistoryHum.Text = "0";
//
// label26
//
this.label26.AutoSize = true;
this.label26.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label26.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label26.Location = new System.Drawing.Point(17, 72);
this.label26.Name = "label26";
this.label26.Size = new System.Drawing.Size(80, 17);
this.label26.TabIndex = 255;
this.label26.Text = "记录湿度值:";
this.label26.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtHistoryTemp
//
this.txtHistoryTemp.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtHistoryTemp.Location = new System.Drawing.Point(103, 25);
this.txtHistoryTemp.MaxLength = 10;
this.txtHistoryTemp.Name = "txtHistoryTemp";
this.txtHistoryTemp.Size = new System.Drawing.Size(87, 26);
this.txtHistoryTemp.TabIndex = 254;
this.txtHistoryTemp.Text = "0";
//
// label22
//
this.label22.AutoSize = true;
this.label22.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label22.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label22.Location = new System.Drawing.Point(17, 32);
this.label22.Name = "label22";
this.label22.Size = new System.Drawing.Size(80, 17);
this.label22.TabIndex = 253;
this.label22.Text = "记录温度值:";
this.label22.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtCurrCount
//
this.txtCurrCount.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtCurrCount.Location = new System.Drawing.Point(324, 64);
this.txtCurrCount.MaxLength = 10;
this.txtCurrCount.Name = "txtCurrCount";
this.txtCurrCount.Size = new System.Drawing.Size(87, 26);
this.txtCurrCount.TabIndex = 252;
this.txtCurrCount.Text = "0";
//
// label23
//
this.label23.AutoSize = true;
this.label23.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label23.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label23.Location = new System.Drawing.Point(226, 68);
this.label23.Name = "label23";
this.label23.Size = new System.Drawing.Size(92, 17);
this.label23.TabIndex = 251;
this.label23.Text = "当前指针位置:";
this.label23.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtHistoryCount
//
this.txtHistoryCount.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtHistoryCount.Location = new System.Drawing.Point(324, 23);
this.txtHistoryCount.MaxLength = 10;
this.txtHistoryCount.Name = "txtHistoryCount";
this.txtHistoryCount.Size = new System.Drawing.Size(87, 26);
this.txtHistoryCount.TabIndex = 250;
this.txtHistoryCount.Text = "0";
//
// label24
//
this.label24.AutoSize = true;
this.label24.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label24.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label24.Location = new System.Drawing.Point(226, 32);
this.label24.Name = "label24";
this.label24.Size = new System.Drawing.Size(80, 17);
this.label24.TabIndex = 249;
this.label24.Text = "记录总条数:";
this.label24.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btnSelTemp // btnSelTemp
// //
this.btnSelTemp.Location = new System.Drawing.Point(212, 82); this.btnSelTemp.Location = new System.Drawing.Point(212, 82);
this.btnSelTemp.Name = "btnSelTemp"; this.btnSelTemp.Name = "btnSelTemp";
this.btnSelTemp.Size = new System.Drawing.Size(100, 33); this.btnSelTemp.Size = new System.Drawing.Size(157, 33);
this.btnSelTemp.TabIndex = 248; this.btnSelTemp.TabIndex = 248;
this.btnSelTemp.Text = "查询"; this.btnSelTemp.Text = "查询实时数据";
this.btnSelTemp.UseVisualStyleBackColor = true; this.btnSelTemp.UseVisualStyleBackColor = true;
this.btnSelTemp.Click += new System.EventHandler(this.btnSelTemp_Click); this.btnSelTemp.Click += new System.EventHandler(this.btnSelTemp_Click);
// //
...@@ -2713,6 +2847,26 @@ ...@@ -2713,6 +2847,26 @@
this.btnLogDebug.UseVisualStyleBackColor = true; this.btnLogDebug.UseVisualStyleBackColor = true;
this.btnLogDebug.Click += new System.EventHandler(this.开启DEBUGToolStripMenuItem_Click); this.btnLogDebug.Click += new System.EventHandler(this.开启DEBUGToolStripMenuItem_Click);
// //
// groupHistory
//
this.groupHistory.Controls.Add(this.txtHistoryTemp);
this.groupHistory.Controls.Add(this.btnSelHistory);
this.groupHistory.Controls.Add(this.label24);
this.groupHistory.Controls.Add(this.txtHistoryTime);
this.groupHistory.Controls.Add(this.txtHistoryCount);
this.groupHistory.Controls.Add(this.label30);
this.groupHistory.Controls.Add(this.label23);
this.groupHistory.Controls.Add(this.txtHistoryHum);
this.groupHistory.Controls.Add(this.txtCurrCount);
this.groupHistory.Controls.Add(this.label26);
this.groupHistory.Controls.Add(this.label22);
this.groupHistory.Location = new System.Drawing.Point(6, 138);
this.groupHistory.Name = "groupHistory";
this.groupHistory.Size = new System.Drawing.Size(532, 177);
this.groupHistory.TabIndex = 260;
this.groupHistory.TabStop = false;
this.groupHistory.Text = "历史记录";
//
// FrmStoreBox // FrmStoreBox
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
...@@ -2757,6 +2911,8 @@ ...@@ -2757,6 +2911,8 @@
this.tabPage4.PerformLayout(); this.tabPage4.PerformLayout();
this.tabPage5.ResumeLayout(false); this.tabPage5.ResumeLayout(false);
this.tabPage6.ResumeLayout(false); this.tabPage6.ResumeLayout(false);
this.groupHistory.ResumeLayout(false);
this.groupHistory.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
...@@ -2975,6 +3131,18 @@ ...@@ -2975,6 +3131,18 @@
private System.Windows.Forms.Button btnClearL; private System.Windows.Forms.Button btnClearL;
private System.Windows.Forms.Button btnStoreStart; private System.Windows.Forms.Button btnStoreStart;
private System.Windows.Forms.Button btnDebug; private System.Windows.Forms.Button btnDebug;
private System.Windows.Forms.TextBox txtHistoryTemp;
private System.Windows.Forms.Label label22;
private System.Windows.Forms.TextBox txtCurrCount;
private System.Windows.Forms.Label label23;
private System.Windows.Forms.TextBox txtHistoryCount;
private System.Windows.Forms.Label label24;
private System.Windows.Forms.TextBox txtHistoryTime;
private System.Windows.Forms.Label label30;
private System.Windows.Forms.TextBox txtHistoryHum;
private System.Windows.Forms.Label label26;
private System.Windows.Forms.Button btnSelHistory;
private System.Windows.Forms.GroupBox groupHistory;
} }
} }
...@@ -158,6 +158,14 @@ namespace OnlineStore.ACSingleStore ...@@ -158,6 +158,14 @@ namespace OnlineStore.ACSingleStore
HideForm(); HideForm();
this.Opacity = 1; this.Opacity = 1;
txtTempPort.Text = store.Config.Humiture_Port; txtTempPort.Text = store.Config.Humiture_Port;
if (HumitureController.HumitureControllerType.Equals(1))
{
groupHistory.Visible = true;
}
else
{
groupHistory.Visible = false;
}
} }
private DateTime preReadModblsTime = DateTime.Now; private DateTime preReadModblsTime = DateTime.Now;
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
...@@ -1454,5 +1462,22 @@ namespace OnlineStore.ACSingleStore ...@@ -1454,5 +1462,22 @@ namespace OnlineStore.ACSingleStore
DebugStatus(false); DebugStatus(false);
} }
} }
private void btnSelHistory_Click(object sender, EventArgs e)
{
int count = HumitureController.QueryHistoryCount();
txtHistoryCount.Text = count.ToString();
int cuCount = HumitureController.QueryCurrCount();
txtCurrCount.Text = cuCount.ToString();
List<object> data = HumitureController.QueryHistory();
if (data.Count >= 3)
{
txtHistoryTemp.Text = data[0].ToString();
txtHistoryHum.Text = data[1].ToString();
txtHistoryTime.Text = data[2].ToString();
}
}
} }
} }
...@@ -61,8 +61,14 @@ ...@@ -61,8 +61,14 @@
20190326修改: 20190326修改:
伺服若已在原点但未回过原点,需要匀速走1500秒,再回原点 伺服若已在原点但未回过原点,需要匀速走1500秒,再回原点
20190410
如果是7*32的料格,升降轴先上升,压紧轴再运动
增加新温控器:妙昕温湿度记录仪文档
20190411
增加相机重新加载功能
增加新的温湿度代码。
......
...@@ -79,5 +79,10 @@ namespace OnlineStore.Common ...@@ -79,5 +79,10 @@ namespace OnlineStore.Common
/// 压紧轴1mm对应的脉冲 /// 压紧轴1mm对应的脉冲
/// </summary> /// </summary>
public static string ComAxisChangeValue = "ComAxisChangeValue"; public static string ComAxisChangeValue = "ComAxisChangeValue";
/// <summary>
/// 温控器类型,0=壁挂王字壳温湿度变送器,1=妙昕温湿度记录仪
/// </summary>
public static string HumitureControllerType = "HumitureControllerType";
} }
} }
...@@ -23,8 +23,9 @@ namespace OnlineStore.Common ...@@ -23,8 +23,9 @@ namespace OnlineStore.Common
private static int dataBits = 8;//数据位 private static int dataBits = 8;//数据位
private static StopBits stopBits = StopBits.One; //停止位 private static StopBits stopBits = StopBits.One; //停止位
private static AcSerialBean sb = null; private static AcSerialBean sb = null;
private static string LogName = ""; private static string LogName = "";
public static int HumitureControllerType = ConfigAppSettings.GetIntValue(Setting_Init.HumitureControllerType);
public static bool Init(string port) public static bool Init(string port)
{ {
if (IsRun && port.Equals(serialPort)) if (IsRun && port.Equals(serialPort))
...@@ -40,6 +41,10 @@ namespace OnlineStore.Common ...@@ -40,6 +41,10 @@ namespace OnlineStore.Common
if (sb == null) if (sb == null)
{ {
serialPort = port; serialPort = port;
if (HumitureControllerType.Equals(1))
{
bautRate = 9600;//波特率
}
sb = new AcSerialBean(serialPort, bautRate, parity, dataBits, stopBits); sb = new AcSerialBean(serialPort, bautRate, parity, dataBits, stopBits);
} }
try try
...@@ -102,14 +107,21 @@ namespace OnlineStore.Common ...@@ -102,14 +107,21 @@ namespace OnlineStore.Common
} }
byte[] sendData = new byte[8]; byte[] sendData = new byte[8];
sendData[0] = 0x01; sendData[0] = 0x01;
if (HumitureControllerType.Equals(1))
{
sendData[1] = 0x04;
}
else
{
sendData[1] = 0x03; sendData[1] = 0x03;
}
sendData[2] = 0x00; sendData[2] = 0x00;
sendData[3] = 0x00; sendData[3] = 0x00;
sendData[4] = 0x00; sendData[4] = 0x00;
sendData[5] = 0x02; sendData[5] = 0x02;
sendData[6] = 0x00; sendData[6] = 0x00;
sendData[7] = 0x00; sendData[7] = 0x00;
sendData = buildCheckData(sendData, sendData.Length-2); sendData = buildCheckData(sendData, sendData.Length - 2);
string str = AcSerialBean.byteToHexStr(sendData); string str = AcSerialBean.byteToHexStr(sendData);
LogUtil.debug("温湿度控制器发送数据:" + str); LogUtil.debug("温湿度控制器发送数据:" + str);
byte[] reviceData = new byte[9]; byte[] reviceData = new byte[9];
...@@ -119,12 +131,124 @@ namespace OnlineStore.Common ...@@ -119,12 +131,124 @@ namespace OnlineStore.Common
} }
public static int QueryHistoryCount()
{
if (IsRun.Equals(false) || HumitureControllerType.Equals(2).Equals(false))
{
return -1;
}
byte[] sendData = new byte[8];
sendData[0] = 0x01;
sendData[1] = 0x04;
sendData[2] = 0x20;
sendData[3] = 0x00;
byte[] addrByte = AcSerialBean.StringToByte("2000");
if (addrByte.Length == 1)
{
sendData[2] = 0x00;
sendData[3] = addrByte[0];
}
else if (addrByte.Length == 2)
{
sendData[3] = addrByte[1];
sendData[2] = addrByte[0];
}
sendData[4] = 0x00;
sendData[5] = 0x02;
sendData[6] = 0x00;
sendData[7] = 0x00;
sendData = buildCheckData(sendData, sendData.Length - 2);
string str = AcSerialBean.byteToHexStr(sendData);
LogUtil.debug("温湿度控制器发送数据:" + str);
byte[] reviceData = new byte[9];
bool isOk = false;
sb.SendCommand(sendData, ref reviceData, 100, out isOk);
return getReviceIntData(reviceData);
}
public static int QueryCurrCount()
{
if (IsRun.Equals(false) || HumitureControllerType.Equals(2).Equals(false))
{
return -1;
}
byte[] sendData = new byte[8];
sendData[0] = 0x01;
sendData[1] = 0x04;
sendData[2] = 0x20;
sendData[3] = 0x02;
sendData[4] = 0x00;
sendData[5] = 0x02;
sendData[6] = 0x00;
sendData[7] = 0x00;
sendData = buildCheckData(sendData, sendData.Length - 2);
string str = AcSerialBean.byteToHexStr(sendData);
LogUtil.debug("温湿度控制器发送数据:" + str);
byte[] reviceData = new byte[9];
bool isOk = false;
sb.SendCommand(sendData, ref reviceData, 100, out isOk);
return getReviceIntData(reviceData);
}
public static List<object> QueryHistory()
{
List<object> list = new List<object>();
if (IsRun.Equals(false)||HumitureControllerType.Equals(2).Equals(false))
{
return list;
}
byte[] sendData = new byte[8];
sendData[0] = 0x01;
sendData[1] = 0x04;
sendData[2] = 0x20;
sendData[3] = 0x04;
sendData[4] = 0x00;
sendData[5] = 0x05;
sendData[6] = 0x00;
sendData[7] = 0x00;
sendData = buildCheckData(sendData, sendData.Length - 2);
string str = AcSerialBean.byteToHexStr(sendData);
LogUtil.debug("温湿度控制器发送数据:" + str);
byte[] reviceData = new byte[15];
bool isOk = false;
sb.SendCommand(sendData, ref reviceData, 100, out isOk);
try
{
if (reviceData != null && reviceData.Length >= 9)
{
string temp = String.Format("{0:X2}", reviceData[3]) + String.Format("{0:X2}", reviceData[4]);
string hum = String.Format("{0:X2}", reviceData[5]) + String.Format("{0:X2}", reviceData[6]);
double tempV = (double)Convert.ToInt32(temp, 16) / 10;
double humV = (double)Convert.ToInt32(hum, 16) / 10;
int year = Convert.ToInt32(String.Format("{0:X2}", reviceData[7]), 16);
int mouth = Convert.ToInt32(String.Format("{0:X2}", reviceData[8]), 16);
int day = Convert.ToInt32(String.Format("{0:X2}", reviceData[9]), 16);
int hour = Convert.ToInt32(String.Format("{0:X2}", reviceData[10]), 16);
int minute = Convert.ToInt32(String.Format("{0:X2}", reviceData[11]), 16);
int second = Convert.ToInt32(String.Format("{0:X2}", reviceData[12]), 16);
DateTime time = new DateTime(year, mouth, day, hour, minute, second);
list.Add(tempV);
list.Add(humV);
list.Add(time);
}
}
catch (Exception ex)
{
LOGGER.Info(LogName + "转换出错:" + ex.ToString());
}
return list;
}
private static byte[] buildCheckData(byte[] sendData, int length) private static byte[] buildCheckData(byte[] sendData, int length)
{ {
ushort pChecksum = 0; ushort pChecksum = 0;
AcSerialBean.CalculateCRC(sendData, length, out pChecksum); AcSerialBean.CalculateCRC(sendData, length, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16); string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = AcSerialBean.StringToByte(checkStr); byte[] checkByte = AcSerialBean.StringToByte(checkStr);
if (checkByte.Length == 1) if (checkByte.Length == 1)
{ {
sendData[length] = checkByte[0]; sendData[length] = checkByte[0];
...@@ -138,6 +262,28 @@ namespace OnlineStore.Common ...@@ -138,6 +262,28 @@ namespace OnlineStore.Common
return sendData; return sendData;
} }
private static int getReviceIntData(byte[] dataArray)
{
List<double> list = new List<double>();
try
{
if (dataArray == null)
{
return -1;
}
if (dataArray.Length >= 9)
{
string data = String.Format("{0:X2}", dataArray[5]) + String.Format("{0:X2}", dataArray[6]+String.Format("{0:X2}", dataArray[3]) + String.Format("{0:X2}", dataArray[4]) );
int tempV = Convert.ToInt32(data, 16);
return tempV;
}
}
catch (Exception ex)
{
LOGGER.Info(LogName + "转换出错:" + ex.ToString());
}
return -1;
}
private static List<double> getReviceData(byte[] dataArray) private static List<double> getReviceData(byte[] dataArray)
{ {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!