Commit 1cc651a5 几米阳光

去掉不需要的diam

1 个父辈 1d5a6205
......@@ -40,7 +40,7 @@
</appSettings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs/LDACStore.log" />
<file value="logs/ZHACStore.log" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
......
......@@ -56,8 +56,6 @@
<Compile Include="Setting_Init.cs" />
<Compile Include="util\AcSerialBean.cs" />
<Compile Include="util\ConfigAppSettings.cs" />
<Compile Include="util\CSVFileHelper.cs" />
<Compile Include="util\CSVReaderControl.cs" />
<Compile Include="util\FormUtil.cs" />
<Compile Include="util\HttpHelper.cs" />
<Compile Include="util\HumitureController.cs" />
......@@ -71,14 +69,9 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="util\ScanCodeManager.cs" />
<Compile Include="util\ScanSocket.cs" />
<Compile Include="util\SerialBean.cs" />
<Compile Include="util\TcpClient.cs" />
<Compile Include="util\TcpServer.cs" />
<Compile Include="util\UdpServer.cs" />
<Compile Include="xml\ModblsPositionXML.cs" />
<Compile Include="xml\XMLCache.cs" />
<Compile Include="xml\XmlData.cs" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
......
using log4net;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
namespace OnLineStore.Common
{
public class CSVFileHelper
{
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// 将DataTable中数据写入到CSV文件中
/// </summary>
/// <param name="dt">提供保存数据的DataTable</param>
/// <param name="fileName">CSV的文件路径</param>
public static void SaveCSV(DataTable dt, string fullPath)
{
FileInfo fi = new FileInfo(fullPath);
if (!fi.Directory.Exists)
{
fi.Directory.Create();
}
FileStream fs = new FileStream(fullPath, System.IO.FileMode.Create, System.IO.FileAccess.Write);
//StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default);
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);
string data = "";
//写出列名称
for (int i = 0; i < dt.Columns.Count; i++)
{
data += dt.Columns[i].ColumnName.ToString();
if (i < dt.Columns.Count - 1)
{
data += ",";
}
}
sw.WriteLine(data);
//写出各行数据
for (int i = 0; i < dt.Rows.Count; i++)
{
data = "";
for (int j = 0; j < dt.Columns.Count; j++)
{
string str = dt.Rows[i][j].ToString();
str = str.Replace("\"", "\"\"");//替换英文冒号 英文冒号需要换成两个冒号
if (str.Contains(',') || str.Contains('"')
|| str.Contains('\r') || str.Contains('\n')) //含逗号 冒号 换行符的需要放到引号中
{
str = string.Format("\"{0}\"", str);
}
data += str;
if (j < dt.Columns.Count - 1)
{
data += ",";
}
}
sw.WriteLine(data);
}
sw.Close();
fs.Close();
DialogResult result = MessageBox.Show("CSV文件保存成功!");
}
public static string[][] Read(string fullname)
{
if (!File.Exists(fullname)) return new string[][] { };
var lines = File.ReadAllLines(fullname).Skip(1);
var list=new List<string[]>();
var builder = new StringBuilder();
foreach (var line in lines)
{
builder=new StringBuilder ();
var comma = false;
var array = line.ToCharArray();
var values = new List<string>();
var length = array.Length - 1;
var index = 0;
while (index < length)
{
var item = array[index++];
switch (item)
{
case ',':
if (comma)
{
builder.Append(item);
}
else
{
values.Add(builder.ToString());
builder = new StringBuilder();
}
break;
case '"':
comma = !comma;
break;
default:
builder.Append(item);
break;
}
}
var count = values.Count;
if (count == 0) continue;
list.Add(values.ToArray());
}
return list.ToArray();
}
//public static List<StoreBagConfig> ReadList(string fullname)
//{
// List<StoreBagConfig> result = new List<StoreBagConfig>();
// if (!File.Exists(fullname)) {
// return result;
// }
// var lines = File.ReadAllLines(fullname).Skip(1);
// var list = new List<string[]>();
// int index=0;
// foreach (var line in lines)
// {
// var array = line.Split(',');
// var length = array.Length ;
// if (length == 5)
// {
// int col = Int32.Parse(array[0]);
// int row = Int32.Parse(array[1]);
// int axisPosition = Int32.Parse(array[2]);
// int highPosition = Int32.Parse(array[3]);
// int lowPosition = Int32.Parse(array[4]);
// StoreBagConfig config = new StoreBagConfig();
// config.AxisPostion = axisPosition;
// config.BagColoum = col;
// config.CsvRowIndex = index;
// config.HighPostion = highPosition;
// config.LowPosition = lowPosition;
// config.BagRow = row;
// result.Add(config);
// }
// else
// {
// LogUtil.error(LOGGER,"读取csv,index="+index+",数据格式不匹配!,line="+line);
// }
// index++;
// }
// return result;
//}
}
}
......@@ -9,6 +9,9 @@ using System.Text;
namespace OnlineStore.Common
{
/// <summary>
/// 壁挂王字壳温湿度变送器(485型)
/// </summary>
public class HumitureController
{
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
......@@ -116,9 +119,9 @@ namespace OnlineStore.Common
private static byte[] buildCheckData(byte[] sendData, int length)
{
ushort pChecksum = 0;
SerialBean.CalculateCRC(sendData, length, out pChecksum);
AcSerialBean.CalculateCRC(sendData, length, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = SerialBean.StringToByte(checkStr);
byte[] checkByte = AcSerialBean.StringToByte(checkStr);
if (checkByte.Length == 1)
{
sendData[length] = checkByte[0];
......
......@@ -461,23 +461,23 @@ namespace OnlineStore.Common
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static byte[] StringToByte(string s)
{
string temps = ReplaceSpace(s);
if (temps.Length % 2 != 0)
{
temps = "0" + temps;
}
byte[] tempb = new byte[50];
int j = 0;
for (int i = 0; i < temps.Length; i = i + 2, j++)
{
tempb[j] = Convert.ToByte(temps.Substring(i, 2), 16);
}
byte[] send = new byte[j];
Array.Copy(tempb, send, j);
return send;
}
//public static byte[] StringToByte(string s)
//{
// string temps = ReplaceSpace(s);
// if (temps.Length % 2 != 0)
// {
// temps = "0" + temps;
// }
// byte[] tempb = new byte[50];
// int j = 0;
// for (int i = 0; i < temps.Length; i = i + 2, j++)
// {
// tempb[j] = Convert.ToByte(temps.Substring(i, 2), 16);
// }
// byte[] send = new byte[j];
// Array.Copy(tempb, send, j);
// return send;
//}
//除去空格
public static string ReplaceSpace(string str)
......@@ -525,33 +525,33 @@ namespace OnlineStore.Common
pChecksum = check;
}
public static void CalculateCRC(byte[] pByte, int nNumberOfBytes, out ushort pChecksum)
{
int nBit;
ushort nShiftedBit;
pChecksum = 0xFFFF;
//public static void CalculateCRC(byte[] pByte, int nNumberOfBytes, out ushort pChecksum)
//{
// int nBit;
// ushort nShiftedBit;
// pChecksum = 0xFFFF;
for (int nByte = 0; nByte < nNumberOfBytes; nByte++)
{
pChecksum ^= pByte[nByte];
for (nBit = 0; nBit < 8; nBit++)
{
if ((pChecksum & 0x1) == 1)
{
nShiftedBit = 1;
}
else
{
nShiftedBit = 0;
}
pChecksum >>= 1;
if (nShiftedBit != 0)
{
pChecksum ^= 0xA001;
}
}
}
}
// for (int nByte = 0; nByte < nNumberOfBytes; nByte++)
// {
// pChecksum ^= pByte[nByte];
// for (nBit = 0; nBit < 8; nBit++)
// {
// if ((pChecksum & 0x1) == 1)
// {
// nShiftedBit = 1;
// }
// else
// {
// nShiftedBit = 0;
// }
// pChecksum >>= 1;
// if (nShiftedBit != 0)
// {
// pChecksum ^= 0xA001;
// }
// }
// }
//}
#endregion
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.Common
{
public class ModblsPositionXML : XmlData
{
public int num { get; set; }
public int type { get; set; }
public int position { get; set; }
/// <summary>
/// 获取电缸移动到的位置
/// </summary>
/// <param name="num">层数,1000表示料口的位置</param>
/// <param name="type">1=低位置,2=高位置</param>
/// <returns></returns>
public static ModblsPositionXML getByNumAndType(int num, int type)
{
Dictionary<int, ModblsPositionXML> allDic = XMLCache<ModblsPositionXML>.getAllData(typeof(ModblsPositionXML));
foreach (ModblsPositionXML mo in allDic.Values)
{
if (mo.num == num && mo.type == type)
{
return mo;
}
}
return null;
}
public static List<ModblsPositionXML> getSortList()
{
List<ModblsPositionXML> list = new List<ModblsPositionXML>();
Dictionary<int, ModblsPositionXML> allDic = XMLCache<ModblsPositionXML>.getAllData(typeof(ModblsPositionXML));
list = (from m in allDic.Values.ToList<ModblsPositionXML>() orderby m.num ascending, m.type ascending, m.id descending select m).ToList<ModblsPositionXML>();
return list;
}
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml;
namespace OnlineStore.Common
{
public class XMLCache<T>
{
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static Dictionary<string, Dictionary<int, T>> xmlCache = new Dictionary<string, Dictionary<int, T>>();
public static Dictionary<int, T> getAllData(Type type)
{
if (!xmlCache.ContainsKey(type.Name))
{
if (type == null)
{
return null;
}
loadXml(type);
}
Dictionary<int, T> allData = xmlCache[type.Name];
return allData;
}
private static Dictionary<int, T> loadXml(Type type)
{
string className = type.Name;
Dictionary<int, T> data = new Dictionary<int, T>();
// Type type = Assembly.Load("testTool.xml." + className).GetType();
string nodeName = className.Substring(0, className.Length - 3);
string parNodeName = nodeName + "Info";
string xmlName = className.Substring(0, className.Length - 3) + "Info.xml";
XmlDocument xmlDoc = new XmlDocument();
string xmlPath = System.Windows.Forms.Application.StartupPath + @"\data\";
xmlDoc.Load(xmlPath + xmlName);
XmlNode parNode = xmlDoc.SelectSingleNode(parNodeName);
XmlNodeList xmlNodeList = parNode.ChildNodes;
for (int i = 0; i < xmlNodeList.Count; i++)
{
XmlNode node = xmlNodeList.Item(i);
XmlAttributeCollection collo = node.Attributes;
XmlAttribute[] list = new XmlAttribute[collo.Count];
collo.CopyTo(list, 0);
var bllIns = type.Assembly.CreateInstance(type.FullName);
//取得属性集合
PropertyInfo[] props = type.GetProperties();
int id = 0;
foreach (XmlAttribute xmlA in list)
{
try
{
var prop = props.First(c => c.Name == xmlA.Name);//获取同名属性
if (prop != null)
{//如果属性存在
prop.SetValue(bllIns, Convert.ChangeType(xmlA.Value, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
if (xmlA.Name.Equals("id"))
{
id = int.Parse(xmlA.Value);
}
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "出现错误:" + ex.Message);
}
}
if (!data.ContainsKey(id))
{
data.Add(id, (T)bllIns);
}
}
xmlCache.Add(className, data);
return data;
}
internal static T getXmlById(Type type, int id)
{
if (!xmlCache.ContainsKey(type.Name))
{
if (type == null)
{
return default(T);
}
loadXml(type);
}
Dictionary<int, T> allData = xmlCache[type.Name];
if (!allData.ContainsKey(id))
{
System.Windows.Forms.MessageBox.Show("找不到ID=" + id + "的" + type.Name);
}
return allData[id];
}
public static void SaveXml(Type type, XmlData mo)
{
string className = type.Name;
//判断xml是否已经存在
string xmlName = className.Substring(0, className.Length - 3) + "Info.xml";
XmlDocument xmlDoc = new XmlDocument();
string xmlPath = System.Windows.Forms.Application.StartupPath + @"\data\";
xmlDoc.Load(xmlPath + xmlName);
string nodeName = className.Substring(0, className.Length - 3);
string parNodeName = nodeName + "Info";
XmlNode parNode = xmlDoc.SelectSingleNode(parNodeName);
XmlNodeList xmlNodeList = parNode.ChildNodes;
//新增
if (mo.id == 0)
{
Dictionary<int, T> dic = getAllData(type);
int id = 0;
foreach (int key in dic.Keys)
{
if (key >= id)
{
id = key + 1;
}
}
mo.id = id;
XmlNode node = xmlNodeList.Item(xmlNodeList.Count - 1);
XmlNode newNode = node.CloneNode(true);
XmlAttributeCollection collo = node.Attributes;
XmlAttribute[] list = new XmlAttribute[collo.Count];
collo.CopyTo(list, 0);
//取得属性集合
PropertyInfo[] props = type.GetProperties();
// parNode.RemoveChild(node);
foreach (XmlAttribute xmlA in list)
{
var prop = props.First(c => c.Name == xmlA.Name);//获取同名属性
if (prop != null)
{
node.Attributes.Remove(xmlA);
xmlA.Value = prop.GetValue(mo,null).ToString();
node.Attributes.Append(xmlA);
}
}
parNode.InsertBefore(newNode, node);
}
//修改
else
{
xmlCache[className].Remove(mo.id);
for (int i = 0; i < xmlNodeList.Count; i++)
{
XmlNode node = xmlNodeList.Item(i);
XmlAttributeCollection collo = node.Attributes;
XmlAttribute[] list = new XmlAttribute[collo.Count];
collo.CopyTo(list, 0);
bool isRight = false;
foreach (XmlAttribute xmlA in list)
{
try
{
if (xmlA.Name.Equals("id"))
{
int id = int.Parse(xmlA.Value);
if (id.Equals(mo.id))
{
isRight = true;
}
break;
}
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "出现错误:" + ex.StackTrace);
}
}
if (isRight)
{ //取得属性集合
PropertyInfo[] props = type.GetProperties();
// parNode.RemoveChild(node);
foreach (XmlAttribute xmlA in list)
{
var prop = props.First(c => c.Name == xmlA.Name);//获取同名属性
if (prop != null)
{
node.Attributes.Remove(xmlA);
xmlA.Value = prop.GetValue(mo, null).ToString();
node.Attributes.Append(xmlA);
}
}
parNode.ReplaceChild(node, node);
break;
}
}
}
xmlDoc.Save(xmlPath + xmlName);
xmlCache[className].Add(mo.id, (T)(object)mo);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.Common
{
public class XmlData
{
public int id { get; set; }
}
}
......@@ -179,7 +179,7 @@ namespace OnlineStore.DeviceLibrary
data[5] = 6; // Message size
data[6] = slaveId; // Slave address //必须设置为"1": 2012.04-24 覃发光;
data[7] = function; ; // Function code
byte[] _adr = SerialBean.StringToByte(address);
byte[] _adr = AcSerialBean.StringToByte(address);
data[8] = _adr[0]; // Start address
data[9] = _adr[1]; // Start address
byte[] _length = BitConverter.GetBytes((short)1);
......@@ -206,7 +206,7 @@ namespace OnlineStore.DeviceLibrary
data[5] = 6; // Message size
data[6] = SlaveID; // Slave address //必须设置为"1": 2012.04-24 覃发光;
data[7] = function; // Function code
byte[] _adr = SerialBean.StringToByte(startAddress);
byte[] _adr = AcSerialBean.StringToByte(startAddress);
if (_adr.Length .Equals( 2))
{
data[8] = _adr[0]; // Start address
......
......@@ -260,6 +260,7 @@ namespace OnlineStore.DeviceLibrary
string strFromat = "{0:X2}";
string msg = "";
for (int index = 0; index < DefaultAILength; index++)
{
string str1 = String.Format(strFromat, values[index * 4 + 2]) + String.Format(strFromat, values[index * 4 + 3])
......@@ -271,8 +272,10 @@ namespace OnlineStore.DeviceLibrary
{
Console.WriteLine(str1 + " float convert = {0}", value);
}
msg += "【" + index + "=" + value + "】";
kndList.Add(io);
}
LogUtil.info(msg);
lock (AIMapLock)
{
if (AIValueMap.ContainsKey(ioIp))
......@@ -281,23 +284,23 @@ namespace OnlineStore.DeviceLibrary
}
AIValueMap.Add(ioIp, kndList);
}
try
{
//每次上传后验证下
int v1 = (int)GetAIValue(ioIp, 1);
int v2 = (int)GetAIValue(ioIp, 2);
int v3 = (int)GetAIValue(ioIp, 3);
if (v1.Equals(0) && v2.Equals(0) && v3.Equals(0))
{
string value = AcSerialBean.ByteToString(values);
LogUtil.error("收到【" + ioIp + "】的数据【" + value + "】,三个高度都为0,断开重新连接");
ConnectionIP(ioIp);
}
}
catch (Exception ex)
{
LogUtil.error("验证数据出错:" + ex.StackTrace);
}
//try
//{
// //每次上传后验证下
// int v1 = (int)GetAIValue(ioIp, 1);
// int v2 = (int)GetAIValue(ioIp, 2);
// int v3 = (int)GetAIValue(ioIp, 3);
// if (v1.Equals(0) && v2.Equals(0) && v3.Equals(0))
// {
// string value = AcSerialBean.ByteToString(values);
// LogUtil.error("收到【" + ioIp + "】的数据【" + value + "】,三个高度都为0,断开重新连接");
// ConnectionIP(ioIp);
// }
//}
//catch (Exception ex)
//{
// LogUtil.error("验证数据出错:" + ex.StackTrace);
//}
}
}
catch (Exception ex)
......@@ -331,7 +334,7 @@ namespace OnlineStore.DeviceLibrary
break;
}
}
LOGGER.Debug ("Read data:【" + reviceMsg + "】 ");
// LOGGER.Info ("Read data:【" + reviceMsg + "】 ");
if (ID == 0xFF)
{
return;
......
......@@ -123,15 +123,10 @@ namespace OnlineStore.DeviceLibrary
if (!clinet.ISConnection())
{
ushort port = 502;
ConnectionIP(io, port);
//ConnectionIP(io, port);
LogUtil.error(LOGGER, io + "当前没有连上,重连" + io);
}
}
//if (DBStoreManager.StoreBoxMap != null && DBStoreManager.StoreBoxMap.Count > 0 && !FileLister.isConnect)
//{
// string RemoteURL = ConfigAppSettings.GetValue(Setting_Init.RemoteURL);
// FileGenerated.StartListerDirectory(RemoteURL, "*.*");
//}
}
}
catch (Exception ex)
{
......
......@@ -132,9 +132,9 @@ namespace OnlineStore.DeviceLibrary
public static byte[] buildCheckData(byte[] sendData, int length)
{
ushort pChecksum = 0;
SerialBean.CalculateCRC(sendData, length, out pChecksum);
AcSerialBean.CalculateCRC(sendData, length, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = SerialBean.StringToByte(checkStr);
byte[] checkByte = AcSerialBean.StringToByte(checkStr);
if (checkByte.Length == 1)
{
sendData[length] = checkByte[0];
......@@ -177,7 +177,7 @@ namespace OnlineStore.DeviceLibrary
byte[] sendData = new byte[8];
sendData[0] = (byte)slvAddr;
sendData[1] = CMD_WriteCoil;
byte[] addrByte = SerialBean.StringToByte(addr.ToString());
byte[] addrByte = AcSerialBean.StringToByte(addr.ToString());
if (addrByte.Length == 1)
{
sendData[2] = 0x00;
......@@ -189,7 +189,7 @@ namespace OnlineStore.DeviceLibrary
sendData[2] = addrByte[0];
}
byte[] dataByte = SerialBean.StringToByte(dataValue);
byte[] dataByte = AcSerialBean.StringToByte(dataValue);
if (dataByte.Length == 1)
{
sendData[4] = 0x00;
......@@ -210,7 +210,7 @@ namespace OnlineStore.DeviceLibrary
byte[] sendData = new byte[8];
sendData[0] = (byte)slvAddr;
sendData[1] = CMD_ReadCoil;
byte[] addrByte = SerialBean.StringToByte(addr.ToString());
byte[] addrByte = AcSerialBean.StringToByte(addr.ToString());
if (addrByte.Length == 1)
{
sendData[2] = 0x00;
......@@ -222,7 +222,7 @@ namespace OnlineStore.DeviceLibrary
sendData[2] = addrByte[0];
}
byte[] dataByte = SerialBean.StringToByte(length.ToString());
byte[] dataByte = AcSerialBean.StringToByte(length.ToString());
if (dataByte.Length == 1)
{
sendData[4] = 0x00;
......@@ -253,7 +253,7 @@ namespace OnlineStore.DeviceLibrary
byte[] sendData = new byte[8 ];
sendData[0] = (byte)slvAddr;
sendData[1] = CMD_ReadRegisters;
byte[] addrByte = SerialBean.StringToByte(addr.ToString());
byte[] addrByte = AcSerialBean.StringToByte(addr.ToString());
if (addrByte.Length == 1)
{
sendData[2] = 0x00;
......@@ -265,7 +265,7 @@ namespace OnlineStore.DeviceLibrary
sendData[2] = addrByte[0];
}
byte[] dataByte = SerialBean.StringToByte(length.ToString());
byte[] dataByte = AcSerialBean.StringToByte(length.ToString());
if (dataByte.Length == 1)
{
sendData[4] = 0x00;
......@@ -295,7 +295,7 @@ namespace OnlineStore.DeviceLibrary
byte[] sendData = new byte[8];
sendData[0] = (byte)slvAddr;
sendData[1] = CMD_WriteRegisters;
byte[] addrByte = SerialBean.StringToByte(addr.ToString());
byte[] addrByte = AcSerialBean.StringToByte(addr.ToString());
if (addrByte.Length == 1)
{
sendData[2] = 0x00;
......@@ -307,7 +307,7 @@ namespace OnlineStore.DeviceLibrary
sendData[2] = addrByte[0];
}
byte[] dataByte = SerialBean.StringToByte(dataValue);
byte[] dataByte = AcSerialBean.StringToByte(dataValue);
if (dataByte.Length == 1)
{
sendData[4] = 0x00;
......
......@@ -247,8 +247,8 @@ namespace OnlineStore.DeviceLibrary
public static void RelMove(string portName, int slvAddr, int position)
{
//int position = Convert.ToInt32(txtPosition.Text);
byte[] positionData = SerialBean.StringToByte(position.ToString("X8"));
byte[] data = SerialBean.StringToByte("0110480C 000408 10000111EC78FFFF ffff");
byte[] positionData = AcSerialBean.StringToByte(position.ToString("X8"));
byte[] data = AcSerialBean.StringToByte("0110480C 000408 10000111EC78FFFF ffff");
data[0] = (byte)slvAddr;
data[data.Length - 1] = 0x00;
data[data.Length - 2] = 0x00;
......@@ -387,8 +387,8 @@ namespace OnlineStore.DeviceLibrary
public static void AbsMove(string portName, int slvAddr, int position)
{
//int position = Convert.ToInt32(txtPosition.Text, 10);
byte[] positionData = SerialBean.StringToByte(position.ToString("X8"));
byte[] data = SerialBean.StringToByte("01104808 000408 10000211 EC78FFFF ffff");
byte[] positionData = AcSerialBean.StringToByte(position.ToString("X8"));
byte[] data = AcSerialBean.StringToByte("01104808 000408 10000211 EC78FFFF ffff");
data[0] = (byte)slvAddr;
data[data.Length - 1] = 0x00;
data[data.Length - 2] = 0x00;
......
......@@ -40,7 +40,7 @@ namespace OnlineStore.DeviceLibrary
//}
public static void SendStrAndSleep(string portName, string str, int sleepS)
{
byte[] data = SerialBean.StringToByte(str);
byte[] data = AcSerialBean.StringToByte(str);
data[data.Length - 1] = 0x00;
data[data.Length - 2] = 0x00;
data = ACCMDManager.buildCheckData(data, data.Length - 2);
......@@ -49,7 +49,7 @@ namespace OnlineStore.DeviceLibrary
}
public static void SendStr(string portName, string str)
{
byte[] data = SerialBean.StringToByte(str);
byte[] data = AcSerialBean.StringToByte(str);
data[data.Length - 1] = 0x00;
data[data.Length - 2] = 0x00;
data = ACCMDManager.buildCheckData(data, data.Length - 2);
......@@ -282,7 +282,7 @@ namespace OnlineStore.DeviceLibrary
public static void SendStr(string portName, int slvAddr, string str)
{
//string str = txtSendStr.Text;
byte[] data = SerialBean.StringToByte(str);
byte[] data = AcSerialBean.StringToByte(str);
data[data.Length - 1] = 0x00;
data[data.Length - 2] = 0x00;
data = ACCMDManager.buildCheckData(data, data.Length - 2);
......
......@@ -134,9 +134,9 @@ namespace OnlineStore.DeviceLibrary
//校验
ushort pChecksum = 0;
SerialBean.CalculateCRC(bits, bits.Length - 2, out pChecksum);
AcSerialBean.CalculateCRC(bits, bits.Length - 2, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = SerialBean.StringToByte(checkStr);
byte[] checkByte = AcSerialBean.StringToByte(checkStr);
if (checkByte.Length == 1)
{
if (!bits[bits.Length - 2].Equals(checkByte[0]))
......@@ -179,9 +179,9 @@ namespace OnlineStore.DeviceLibrary
}
//校验
ushort pChecksum = 0;
SerialBean.CalculateCRC(bits, bits.Length - 2, out pChecksum);
AcSerialBean.CalculateCRC(bits, bits.Length - 2, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = SerialBean.StringToByte(checkStr);
byte[] checkByte = AcSerialBean.StringToByte(checkStr);
if (checkByte.Length == 1)
{
if (!bits[bits.Length - 2].Equals(checkByte[0]))
......@@ -213,7 +213,7 @@ namespace OnlineStore.DeviceLibrary
int slvAddr = (int)bits[0];
byte[] positionData = new byte[4];
Array.Copy(bits, 3, positionData, 0, 4);
string a = SerialBean.byteToHexStr(positionData);
string a = AcSerialBean.byteToHexStr(positionData);
absValue = Convert.ToInt32(a, 16);
LogUtil.debug(LOGGER, "收到驱动器【" + slvAddr + "】绝对位置【" + absValue + "】");
if (shuokeMap.ContainsKey(slvAddr))
......@@ -393,7 +393,7 @@ namespace OnlineStore.DeviceLibrary
sendData[5] = 0x00;
sendData[6] = 0x00;
string speed = Convert.ToString(position, 16);
byte[] speedByte = SerialBean.StringToByte(speed);
byte[] speedByte = AcSerialBean.StringToByte(speed);
for (int i = 0; i < speedByte.Length; i++)
{
......@@ -444,7 +444,7 @@ namespace OnlineStore.DeviceLibrary
sendData[5] = 0x00;
sendData[6] = 0x00;
string speed = Convert.ToString(dataValue, 16);
byte[] speedByte = SerialBean.StringToByte(speed);
byte[] speedByte = AcSerialBean.StringToByte(speed);
for (int i = 0; i < speedByte.Length; i++)
{
......@@ -462,9 +462,9 @@ namespace OnlineStore.DeviceLibrary
private static byte[] buildCheckData(byte[] sendData, int length)
{
ushort pChecksum = 0;
SerialBean.CalculateCRC(sendData, length, out pChecksum);
AcSerialBean.CalculateCRC(sendData, length, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = SerialBean.StringToByte(checkStr);
byte[] checkByte = AcSerialBean.StringToByte(checkStr);
if (checkByte.Length == 1)
{
sendData[length] = checkByte[0];
......
......@@ -90,7 +90,7 @@ namespace OnlineStore.DeviceLibrary
string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName);
string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType);
CodeManager.LoadConfig(nameStr,codeStr);
//初始化 //连接设备
KNDManager.ConnectionKND(Config.DIODeviceNameList);
KNDAIManager.ConnectionIP(Config.AIDevice_IP);
......
......@@ -2,7 +2,6 @@
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using OnLineStore.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!