Commit 49c28c58 LN

1

1 个父辈 0fbcb89e
正在显示 48 个修改的文件 包含 954 行增加452 行删除
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
<?xml version="1.0"?>
<doc>
<assembly>
<name>Asa.RFID</name>
</assembly>
<members>
<member name="T:Asa.RFID.Reader">
<summary>
RFID读卡器
</summary>
</member>
<member name="E:Asa.RFID.Reader.Data_Received">
<summary>
自动扫描接收到的数据
</summary>
</member>
<member name="M:Asa.RFID.Reader.#ctor">
<summary>
RFID读卡器
</summary>
</member>
<member name="P:Asa.RFID.Reader.LocalIP">
<summary>
本地IP地址,用于查找或修改远程IP
</summary>
</member>
<member name="P:Asa.RFID.Reader.RemoteIP">
<summary>
远程IP地址
</summary>
</member>
<member name="P:Asa.RFID.Reader.IsConn">
<summary>
是否连接
</summary>
</member>
<member name="P:Asa.RFID.Reader.IsAutoScan">
<summary>
是否自动扫描
</summary>
</member>
<member name="P:Asa.RFID.Reader.IsExist">
<summary>
是否存在ID卡
</summary>
</member>
<member name="M:Asa.RFID.Reader.Connect">
<summary>
连接
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.Close">
<summary>
关闭
</summary>
</member>
<member name="M:Asa.RFID.Reader.FindRFID">
<summary>
查找电子标签
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.AutoScan(System.Boolean,System.Int32)">
<summary>
自动读取扫描,使用查找模式
</summary>
<param name="open">扫描模式开启,true扫描</param>
<param name="time">间隔时间</param>
</member>
<member name="M:Asa.RFID.Reader.AutoScan(System.Boolean)">
<summary>
自动读取扫描,使用扫描模式,扫描模式只读
</summary>
<param name="open">扫描模式开启,true扫描</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.Read">
<summary>
读取电子标签
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.Read(System.Int32,System.Int32)">
<summary>
读取电子标签
</summary>
<param name="start"></param>
<param name="len"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.Write(System.Byte[])">
<summary>
写入数据到电子标签
</summary>
<param name="buff">数据,必须小于等于112字节</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.Write(System.Byte[],System.Int32)">
<summary>
写入数据到电子标签
</summary>
<param name="buff"></param>
<param name="start"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.FindIP">
<summary>
查找IP地址,需要设置LocalIP
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.ModifyIP(System.String)">
<summary>
修改IP地址
</summary>
<param name="IP"></param>
</member>
<member name="M:Asa.RFID.Reader.Receive(System.Object)">
<summary>
自动扫描接受数据事件
</summary>
<param name="param"></param>
</member>
<member name="M:Asa.RFID.Reader.Receive2">
<summary>
自动扫描接受数据事件
</summary>
</member>
<member name="M:Asa.RFID.Reader.ReadRFID">
<summary>
读取电子标签内所有数据
</summary>
</member>
<member name="M:Asa.RFID.Reader.ReadRFID(System.Int32)">
<summary>
读取电子标签指定块
</summary>
<param name="num"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.WriteRFID(System.Int32)">
<summary>
写入指定块数据到电子标签
</summary>
<param name="num"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.InitBuff(System.Int32,System.Int32)">
<summary>
初始buff为0
</summary>
<param name="start"></param>
<param name="len"></param>
</member>
<member name="T:Asa.RFID.ReaderInfo">
<summary>
读卡设备信息
</summary>
</member>
<member name="F:Asa.RFID.ReaderInfo.IP">
<summary>
IP地址
</summary>
</member>
<member name="F:Asa.RFID.ReaderInfo.Mac">
<summary>
MAC地址
</summary>
</member>
<member name="F:Asa.RFID.ReaderInfo.Port">
<summary>
端口
</summary>
</member>
</members>
</doc>
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<add key ="LineServerPort" value ="5246"/> <add key ="LineServerPort" value ="5246"/>
<!--是否调试状态--> <!--是否调试状态-->
<add key ="IsInDebug" value ="1"/> <add key ="IsInDebug" value ="1"/>
<add key ="UseBuzzer" value ="1"/>
</appSettings> </appSettings>
<log4net> <log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
......
...@@ -13,7 +13,7 @@ namespace OnlineStore.ACPackingStore ...@@ -13,7 +13,7 @@ namespace OnlineStore.ACPackingStore
{ {
public partial class FrmBase : Form public partial class FrmBase : Form
{ {
internal static string GetVersion() internal static string GetVersion(bool isShow=false)
{ {
string str = ""; string str = "";
string version = ""; string version = "";
...@@ -38,7 +38,10 @@ namespace OnlineStore.ACPackingStore ...@@ -38,7 +38,10 @@ namespace OnlineStore.ACPackingStore
str = version; str = version;
LogUtil.error("解析版本号【" + str + "】出错:" + ex.ToString()); LogUtil.error("解析版本号【" + str + "】出错:" + ex.ToString());
} }
LogUtil.info("版本号[" + version + "][" + str + "][" + GetCodeNum() + "]"); if (isShow)
{
LogUtil.info("版本号[" + version + "][" + str + "][" + GetCodeNum() + "]");
}
return str; return str;
} }
internal static string GetCodeNum(string codeName = "RC1250-ACPackingStore") internal static string GetCodeNum(string codeName = "RC1250-ACPackingStore")
......
...@@ -2093,8 +2093,7 @@ ...@@ -2093,8 +2093,7 @@
this.Name = "FrmBox"; this.Name = "FrmBox";
this.Opacity = 0D; this.Opacity = 0D;
this.Text = "AC_SA_料仓"; this.Text = "AC_SA_料仓";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmTest_FormClosing);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmTest_FormClosing);
this.Load += new System.EventHandler(this.FrmTest_Load); this.Load += new System.EventHandler(this.FrmTest_Load);
this.Shown += new System.EventHandler(this.FrmStoreBox_Shown); this.Shown += new System.EventHandler(this.FrmStoreBox_Shown);
this.groupAxis.ResumeLayout(false); this.groupAxis.ResumeLayout(false);
......
...@@ -39,7 +39,12 @@ namespace OnlineStore.ACPackingStore ...@@ -39,7 +39,12 @@ namespace OnlineStore.ACPackingStore
this.StoreId = store.DeviceID; this.StoreId = store.DeviceID;
LoadIOList(); LoadIOList();
} }
private void FrmStoreIOStatus_Load(object sender, EventArgs e)
{
//KNDAIManager.NeedShow = true;
this.Text = boxBean.Name + "_IO查看";
}
Dictionary<string, IOTextControl> DIControlList = new Dictionary<string, IOTextControl>(); Dictionary<string, IOTextControl> DIControlList = new Dictionary<string, IOTextControl>();
Dictionary<string, IOTextControl> DOControlList = new Dictionary<string, IOTextControl>(); Dictionary<string, IOTextControl> DOControlList = new Dictionary<string, IOTextControl>();
private void LoadIOList() private void LoadIOList()
...@@ -72,7 +77,6 @@ namespace OnlineStore.ACPackingStore ...@@ -72,7 +77,6 @@ namespace OnlineStore.ACPackingStore
cmbWriteIO.DataSource = new List<ConfigIO>(boxBean.Config.DOList.Values); cmbWriteIO.DataSource = new List<ConfigIO>(boxBean.Config.DOList.Values);
cmbWriteIO.ValueMember = "ProName"; cmbWriteIO.ValueMember = "ProName";
cmbWriteIO.DisplayMember = "DisplayStr"; cmbWriteIO.DisplayMember = "DisplayStr";
cmbWriteValue.SelectedIndex = 0;
} }
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
...@@ -99,22 +103,6 @@ namespace OnlineStore.ACPackingStore ...@@ -99,22 +103,6 @@ namespace OnlineStore.ACPackingStore
LogUtil.error(LOGGER, ex.StackTrace); LogUtil.error(LOGGER, ex.StackTrace);
} }
} }
private void btnWriteSingleDO_Click(object sender, EventArgs e)
{
string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex);
IO_VALUE value = (IO_VALUE)cmbWriteValue.SelectedIndex;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
if (time > 0)
{
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value, time);
}
else
{
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value);
}
}
private ConfigIO GetSelectDO() private ConfigIO GetSelectDO()
{ {
...@@ -144,10 +132,6 @@ namespace OnlineStore.ACPackingStore ...@@ -144,10 +132,6 @@ namespace OnlineStore.ACPackingStore
} }
} }
private void FrmStoreIOStatus_Load(object sender, EventArgs e)
{
//KNDAIManager.NeedShow = true;
}
private void cmbWriteIO_DrawItem(object sender, DrawItemEventArgs e) private void cmbWriteIO_DrawItem(object sender, DrawItemEventArgs e)
{ {
...@@ -164,19 +148,6 @@ namespace OnlineStore.ACPackingStore ...@@ -164,19 +148,6 @@ namespace OnlineStore.ACPackingStore
} }
} }
private void cmbWriteValue_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index < 0)
{
return;
}
e.DrawBackground();
e.DrawFocusRectangle();
if (cmbWriteValue.Items.Count > e.Index)
{
e.Graphics.DrawString(cmbWriteValue.Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3);
}
}
private void btnReadIO_Click(object sender, EventArgs e) private void btnReadIO_Click(object sender, EventArgs e)
{ {
...@@ -194,7 +165,8 @@ namespace OnlineStore.ACPackingStore ...@@ -194,7 +165,8 @@ namespace OnlineStore.ACPackingStore
control.IOValue = iov; control.IOValue = iov;
control.ShowData(); control.ShowData();
} }
} foreach (string key in this.DOControlList.Keys) }
foreach (string key in this.DOControlList.Keys)
{ {
IOTextControl control = DOControlList[key]; IOTextControl control = DOControlList[key];
int iov = (int)IOManager.DOValue(key); int iov = (int)IOManager.DOValue(key);
...@@ -204,57 +176,74 @@ namespace OnlineStore.ACPackingStore ...@@ -204,57 +176,74 @@ namespace OnlineStore.ACPackingStore
control.ShowData(); control.ShowData();
} }
} }
} }
protected void BtnMove(Button btn, string defaultText, string targetText, string ioHighType)
private void btnReadAllDi_Click(object sender, EventArgs e)
{ {
string deviceName = txtDoName.Text; LogUtil.info("点击【" + btn.Text + "】 ");
IO_VALUE value = (IO_VALUE)cmbWriteValue.SelectedIndex; if (btn.Text.Equals(defaultText))
int time = FormUtil.GetIntValue(txtWriteTime); {
int slaveId = FormUtil.GetIntValue(txtSlaveId); boxBean.IOMove(ioHighType, IO_VALUE.HIGH);
IOManager.instance.ReadAllDI(deviceName, (byte)slaveId ); btn.Text = targetText;
} btn.BackColor = Color.Aqua;
private void btnReadAllDo_Click(object sender, EventArgs e) }
else
{
boxBean.IOMove(ioHighType, IO_VALUE.LOW);
btn.Text = defaultText;
btn.BackColor = Color.White;
}
}
protected void BtnMove(Button btn, string defaultText, string targetText, string ioLowType, string ioHighType)
{ {
string deviceName = txtDoName.Text; LogUtil.info("点击【" + btn.Text + "】 ");
if (btn.Text.Equals(defaultText))
{
boxBean.CylinderMove(null, ioLowType, ioHighType);
btn.Text = targetText;
btn.BackColor = Color.Aqua;
}
else
{
boxBean.CylinderMove(null, ioHighType, ioLowType);
btn.Text = defaultText;
btn.BackColor = Color.SkyBlue;
}
}
IO_VALUE value = (IO_VALUE)cmbWriteValue.SelectedIndex;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
IOManager.instance.ReadAllDO(deviceName, (byte)slaveId );
}
private void btnOpenDoor_Click(object sender, EventArgs e) private void btnOpenDoor_Click(object sender, EventArgs e)
{ {
} boxBean.CylinderMove(null, IO_Type.EntranceDoor_Close, IO_Type.EntranceDoor_Open);
}
private void btnCloseDoor_Click(object sender, EventArgs e) private void btnCloseDoor_Click(object sender, EventArgs e)
{ {
boxBean.CylinderMove(null, IO_Type.EntranceDoor_Open, IO_Type.EntranceDoor_Close);
} }
private void btnLocationUp_Click(object sender, EventArgs e) private void btnLocationUp_Click(object sender, EventArgs e)
{ {
IOManager.IOMove(IO_Type.LocationCylinder_Down, IO_VALUE.LOW);
IOManager.IOMove(IO_Type.LocationCylinder_Up, IO_VALUE.HIGH); boxBean.CylinderMove(null, IO_Type.LocationCylinder_Down, IO_Type.LocationCylinder_Up);
} }
private void btnLocationDown_Click(object sender, EventArgs e) private void btnLocationDown_Click(object sender, EventArgs e)
{ {
IOManager.IOMove(IO_Type.LocationCylinder_Down, IO_VALUE.HIGH); boxBean.CylinderMove(null, IO_Type.LocationCylinder_Up, IO_Type.LocationCylinder_Down);
IOManager.IOMove(IO_Type.LocationCylinder_Up, IO_VALUE.LOW);
} }
private void FrmIOStatus_Shown(object sender, EventArgs e) private void FrmIOStatus_Shown(object sender, EventArgs e)
{ {
timer1.Start(); timer1.Start();
} }
private void btnOpenAxisBreak_Click(object sender, EventArgs e) private void btnOpenAxisBreak_Click(object sender, EventArgs e)
{ {
IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.HIGH); BtnMove(btnOpenAxisBreak, "打开刹车", "关闭刹车", IO_Type.Axis_Brake);
} }
private void btnCloseAxisBreak_Click(object sender, EventArgs e) private void btnCloseAxisBreak_Click(object sender, EventArgs e)
{ {
IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW); IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
} }
...@@ -263,6 +252,65 @@ namespace OnlineStore.ACPackingStore ...@@ -263,6 +252,65 @@ namespace OnlineStore.ACPackingStore
this.Close(); this.Close();
} }
private void btnOpenDo_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.HIGH);
}
private void btnWriteSingleDO_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.LOW);
}
private void WriteDO(IO_VALUE value)
{
string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex);
// IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
if (time > 0)
{
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value, time);
}
else
{
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value);
}
}
private void btnTopUp_Click(object sender, EventArgs e)
{
boxBean.CylinderMove(null, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
}
private void btnTopDown_Click(object sender, EventArgs e)
{
boxBean.CylinderMove(null, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
private void btnNGDoorUp_Click(object sender, EventArgs e)
{
boxBean.CylinderMove(null, IO_Type.NGDoorCylinder_Down, IO_Type.NGDoowCylinder_Up);
}
private void btnNGDoorDown_Click(object sender, EventArgs e)
{
boxBean.CylinderMove(null, IO_Type.NGDoowCylinder_Up, IO_Type.NGDoorCylinder_Down);
}
private void btnCamerLed_Click(object sender, EventArgs e)
{
BtnMove(btnCamerLed, "打开光源", "关闭光源", IO_Type.Camera_Led);
}
private void button4_Click(object sender, EventArgs e)
{
BtnMove(button4, "线体正转", "线体反转", IO_Type.Line_Run, IO_Type.Line_BackRun);
}
private void btnStopMove_Click(object sender, EventArgs e)
{
boxBean.IOMove(IO_Type.Line_Run, IO_VALUE.LOW);
boxBean.IOMove(IO_Type.Line_BackRun, IO_VALUE.LOW);
}
} }
} }
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmStore)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmStore));
this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage1 = new System.Windows.Forms.TabPage();
this.chbUseBuzzer = new System.Windows.Forms.CheckBox();
this.chkDebug = new System.Windows.Forms.CheckBox(); this.chkDebug = new System.Windows.Forms.CheckBox();
this.chbAutoRun = new System.Windows.Forms.CheckBox(); this.chbAutoRun = new System.Windows.Forms.CheckBox();
this.btnCopyLog = new System.Windows.Forms.Button(); this.btnCopyLog = new System.Windows.Forms.Button();
...@@ -85,6 +86,7 @@ ...@@ -85,6 +86,7 @@
// //
// tabPage1 // tabPage1
// //
this.tabPage1.Controls.Add(this.chbUseBuzzer);
this.tabPage1.Controls.Add(this.chkDebug); this.tabPage1.Controls.Add(this.chkDebug);
this.tabPage1.Controls.Add(this.chbAutoRun); this.tabPage1.Controls.Add(this.chbAutoRun);
this.tabPage1.Controls.Add(this.btnCopyLog); this.tabPage1.Controls.Add(this.btnCopyLog);
...@@ -97,6 +99,18 @@ ...@@ -97,6 +99,18 @@
this.tabPage1.Text = " 日志信息 "; this.tabPage1.Text = " 日志信息 ";
this.tabPage1.UseVisualStyleBackColor = true; this.tabPage1.UseVisualStyleBackColor = true;
// //
// chbUseBuzzer
//
this.chbUseBuzzer.AutoSize = true;
this.chbUseBuzzer.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbUseBuzzer.Location = new System.Drawing.Point(623, 31);
this.chbUseBuzzer.Name = "chbUseBuzzer";
this.chbUseBuzzer.Size = new System.Drawing.Size(98, 24);
this.chbUseBuzzer.TabIndex = 195;
this.chbUseBuzzer.Text = "启用蜂鸣器";
this.chbUseBuzzer.UseVisualStyleBackColor = true;
this.chbUseBuzzer.CheckedChanged += new System.EventHandler(this.chbUseBuzzer_CheckedChanged);
//
// chkDebug // chkDebug
// //
this.chkDebug.AutoSize = true; this.chkDebug.AutoSize = true;
...@@ -298,7 +312,7 @@ ...@@ -298,7 +312,7 @@
// 版本号ToolStripMenuItem // 版本号ToolStripMenuItem
// //
this.版本号ToolStripMenuItem.Name = "版本号ToolStripMenuItem"; this.版本号ToolStripMenuItem.Name = "版本号ToolStripMenuItem";
this.版本号ToolStripMenuItem.Size = new System.Drawing.Size(180, 26); this.版本号ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.版本号ToolStripMenuItem.Text = "关于软件"; this.版本号ToolStripMenuItem.Text = "关于软件";
this.版本号ToolStripMenuItem.Click += new System.EventHandler(this.版本号ToolStripMenuItem_Click); this.版本号ToolStripMenuItem.Click += new System.EventHandler(this.版本号ToolStripMenuItem_Click);
// //
...@@ -401,6 +415,7 @@ ...@@ -401,6 +415,7 @@
private System.Windows.Forms.ToolStripMenuItem 退出ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 退出ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
private System.Windows.Forms.CheckBox chbUseBuzzer;
} }
} }
...@@ -54,6 +54,7 @@ namespace OnlineStore.ACPackingStore ...@@ -54,6 +54,7 @@ namespace OnlineStore.ACPackingStore
this.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title); this.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
chbAutoRun.Checked = ConfigAppSettings.GetValue(Setting_Init.App_AutoRun).Equals(1); chbAutoRun.Checked = ConfigAppSettings.GetValue(Setting_Init.App_AutoRun).Equals(1);
HideForm(); HideForm();
chbAutoRun.Checked = store.UseBuzzer;
LoadOk = true; LoadOk = true;
} }
...@@ -386,5 +387,26 @@ namespace OnlineStore.ACPackingStore ...@@ -386,5 +387,26 @@ namespace OnlineStore.ACPackingStore
toolStripMenuItem2.Text = "启用调试"; toolStripMenuItem2.Text = "启用调试";
} }
} }
private void chbUseBuzzer_CheckedChanged(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
if (chbUseBuzzer.Checked)
{
store.UseBuzzer = true;
ConfigAppSettings.SaveValue(Setting_Init.UseBuzzer, 1);
LogUtil.info("勾选:启用蜂鸣器");
}
else
{
store.UseBuzzer = false;
ConfigAppSettings.SaveValue(Setting_Init.UseBuzzer, 0);
LogUtil.info("去掉:启用蜂鸣器");
}
}
} }
} }
此文件的差异太大,无法显示。
...@@ -85,5 +85,7 @@ namespace OnlineStore.Common ...@@ -85,5 +85,7 @@ namespace OnlineStore.Common
public static string ACBaudRate = "ACBaudRate"; public static string ACBaudRate = "ACBaudRate";
public static string Store_ConfigPath = "Store_ConfigPath"; public static string Store_ConfigPath = "Store_ConfigPath";
public static string UseBuzzer = "UseBuzzer";
} }
} }
...@@ -323,7 +323,7 @@ namespace OnlineStore.Common ...@@ -323,7 +323,7 @@ namespace OnlineStore.Common
catch (Exception ex) catch (Exception ex)
{ {
isOk = false; isOk = false;
LogUtil.error(LOGGER, "SendCommand ERROR:" + ex.ToString(), 20); LogUtil.error( "SendCommand ERROR:" + ex.ToString(), 20);
} }
finally finally
{ {
......
...@@ -111,7 +111,7 @@ namespace OnlineStore.Common ...@@ -111,7 +111,7 @@ namespace OnlineStore.Common
} }
catch (Exception e) catch (Exception e)
{ {
LogUtil.error(LOGGER, "POST ERROR:" + e.StackTrace, 1); LogUtil.error( "POST ERROR:" + e.StackTrace, 1);
} }
if (!result.Contains("null") && result.Length != 0) if (!result.Contains("null") && result.Length != 0)
{ {
...@@ -145,7 +145,7 @@ namespace OnlineStore.Common ...@@ -145,7 +145,7 @@ namespace OnlineStore.Common
} }
catch (Exception e) catch (Exception e)
{ {
LogUtil.error(LOGGER, "HTTP GET ERROR:" + e.Message, 2); LogUtil.error( "HTTP GET ERROR:" + e.Message, 2);
} }
return ""; return "";
} }
......
...@@ -77,7 +77,7 @@ namespace OnlineStore.Common ...@@ -77,7 +77,7 @@ namespace OnlineStore.Common
private static List<string> lasErrorLogList = new List<string>(); private static List<string> lasErrorLogList = new List<string>();
private static int errCount = 5; private static int errCount = 5;
public static void error(ILog log, string errorMsg,int type,int spanSeconds=10) public static void error( string errorMsg,int type,int spanSeconds=10)
{ {
if (lastErrorLogTime.ContainsKey(type)) if (lastErrorLogTime.ContainsKey(type))
{ {
...@@ -90,13 +90,13 @@ namespace OnlineStore.Common ...@@ -90,13 +90,13 @@ namespace OnlineStore.Common
{ {
lastErrorLogTime.Remove(type); lastErrorLogTime.Remove(type);
lastErrorLogTime.Add(type, DateTime.Now); lastErrorLogTime.Add(type, DateTime.Now);
error(log, errorMsg); error(LOGGER, errorMsg);
} }
} }
else else
{ {
lastErrorLogTime.Add(type, DateTime.Now); lastErrorLogTime.Add(type, DateTime.Now);
error(log, errorMsg); error(LOGGER, errorMsg);
} }
} }
public static void error(ILog log, string errorMsg) public static void error(ILog log, string errorMsg)
......
...@@ -112,18 +112,18 @@ namespace OnlineStore.Common ...@@ -112,18 +112,18 @@ namespace OnlineStore.Common
{ {
m_clientSocket.BeginReceive(m_receiveBuffer, 0, m_receiveBuffer.Length, 0, new AsyncCallback(ReceiveCallBack), null); m_clientSocket.BeginReceive(m_receiveBuffer, 0, m_receiveBuffer.Length, 0, new AsyncCallback(ReceiveCallBack), null);
onReceived = HandleMessage; onReceived = HandleMessage;
LogUtil.info(LOGGER, "Connect to " + serverIP + ":" + serverPort + " success!"); LogUtil.info( "Connect to " + serverIP + ":" + serverPort + " success!");
ReConnectTimer.Start(); ReConnectTimer.Start();
return true; return true;
} }
else else
{ {
LogUtil.info(LOGGER, "Connect to " + serverIP + ":" + serverPort + " fail!"); LogUtil.info( "Connect to " + serverIP + ":" + serverPort + " fail!");
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(LOGGER,"Connect to " + serverIP + ":" + serverPort + " fail!" + ex.ToString(),3); LogUtil.error("Connect to " + serverIP + ":" + serverPort + " fail!" + ex.ToString(),3);
m_clientSocket = null; m_clientSocket = null;
} }
...@@ -176,7 +176,7 @@ namespace OnlineStore.Common ...@@ -176,7 +176,7 @@ namespace OnlineStore.Common
catch (Exception ex) catch (Exception ex)
{ {
isInProcess = false; isInProcess = false;
LogUtil.error(LOGGER, "重连处理出错:" + ex.ToString(),9,180); LogUtil.error( "重连处理出错:" + ex.ToString(),9,180);
} }
} }
...@@ -227,7 +227,7 @@ namespace OnlineStore.Common ...@@ -227,7 +227,7 @@ namespace OnlineStore.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(LOGGER,"socket received error:" + ex.ToString(),4); LogUtil.error("socket received error:" + ex.ToString(),4);
} }
} }
} }
......
...@@ -158,11 +158,11 @@ namespace OnlineStore.Common ...@@ -158,11 +158,11 @@ namespace OnlineStore.Common
} }
catch (SocketException e) catch (SocketException e)
{ {
LogUtil.error(LOGGER, e.ToString(), 6); LogUtil.error( e.ToString(), 6);
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(LOGGER, ex.ToString(), 5); LogUtil.error( ex.ToString(), 5);
} }
} }
//private void ReceiveMessages(Client client) //private void ReceiveMessages(Client client)
......
...@@ -39,6 +39,9 @@ ...@@ -39,6 +39,9 @@
<Reference Include="Asa.IOModule.AIOBOX"> <Reference Include="Asa.IOModule.AIOBOX">
<HintPath>..\..\dll\Asa.IOModule.AIOBOX.dll</HintPath> <HintPath>..\..\dll\Asa.IOModule.AIOBOX.dll</HintPath>
</Reference> </Reference>
<Reference Include="Asa.RFID">
<HintPath>..\..\dll\RFID\Asa.RFID.dll</HintPath>
</Reference>
<Reference Include="CodeLibrary"> <Reference Include="CodeLibrary">
<HintPath>..\..\..\RC32-SZBOSCH-ACSingleStore\dll\CodeLibrary.dll</HintPath> <HintPath>..\..\..\RC32-SZBOSCH-ACSingleStore\dll\CodeLibrary.dll</HintPath>
</Reference> </Reference>
...@@ -72,6 +75,7 @@ ...@@ -72,6 +75,7 @@
<Compile Include="device\PanasonicServo\ACCMDManager.cs" /> <Compile Include="device\PanasonicServo\ACCMDManager.cs" />
<Compile Include="device\PanasonicServo\ACServerManager.cs" /> <Compile Include="device\PanasonicServo\ACServerManager.cs" />
<Compile Include="device\PanasonicServo\ACServerManager_Partial.cs" /> <Compile Include="device\PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="device\RFID\RFIDManager.cs" />
<Compile Include="store\LineMoveP.cs" /> <Compile Include="store\LineMoveP.cs" />
<Compile Include="store\LineAlarm.cs"> <Compile Include="store\LineAlarm.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
......
...@@ -120,4 +120,5 @@ PRO,每次吹气的时间(分钟),BlowAir_Time,10,,,,,,, ...@@ -120,4 +120,5 @@ PRO,每次吹气的时间(分钟),BlowAir_Time,10,,,,,,,
PRO,两次吹气间隔(分钟),BlowAir_Interval,10,,,,,,, PRO,两次吹气间隔(分钟),BlowAir_Interval,10,,,,,,,
PRO,温湿度端口号,Humiture_Port,COM2,,,,,,, PRO,温湿度端口号,Humiture_Port,COM2,,,,,,,
PRO,扫码的相机名称(多个用#分隔),CameraNameList,Name1#Name1,,,,, PRO,扫码的相机名称(多个用#分隔),CameraNameList,Name1#Name1,,,,,
PRO,RFID读卡器IP,RFID_IP,192.168.200.11,,,,,,,
PRO,是否是调试状态,IsInDebug,1,,,,,,, PRO,是否是调试状态,IsInDebug,1,,,,,,,
...@@ -122,5 +122,6 @@ PRO,每次吹气的时间(分钟),BlowAir_Time,10,,,,,,, ...@@ -122,5 +122,6 @@ PRO,每次吹气的时间(分钟),BlowAir_Time,10,,,,,,,
PRO,两次吹气间隔(分钟),BlowAir_Interval,10,,,,,,, PRO,两次吹气间隔(分钟),BlowAir_Interval,10,,,,,,,
PRO,温湿度端口号,Humiture_Port,COM2,,,,,,, PRO,温湿度端口号,Humiture_Port,COM2,,,,,,,
PRO,扫码的相机名称(多个用#分隔),CameraNameList,Name1#Name1,,,,, PRO,扫码的相机名称(多个用#分隔),CameraNameList,Name1#Name1,,,,,
PRO,RFID读卡器IP,RFID_IP,192.168.200.11,,,,,,,
PRO,是否是调试状态,IsInDebug,1,,,,,,, PRO,是否是调试状态,IsInDebug,1,,,,,,,
using Asa.IOModule;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace OnlineStore.DeviceLibrary
{
public abstract class AIManager
{
public bool NeedShow = false;
public static AIManager Instance = null;
public static void Init()
{
bool isAIOBox = ConfigAppSettings.GetIntValue(Setting_Init.UseAIOBOX).Equals(1);
if (isAIOBox)
{
Instance = new AIOAIManager();
}
else
{
Instance = new KNDAIManager();
}
}
public static double ConvertAI(double aiValue, double defaultValue)
{
double xishu = (double)StoreManager.Config.AI_ConvertPosition;
double result = Math.Round((aiValue - defaultValue) / xishu, 2);
return result;
}
public abstract void StartConnect(params string[] ioIp);
public abstract void CloseConnect();
public abstract double GetAIValue(string ioiP,int index);
}
}
using Asa.IOModule;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class AIOAIManager:AIManager
{
private object AILock = "";
private List<int> AIValList = null;
private int AILength = 4;
private Asa.IOModule.AIOBOX AIBox = null;
private System.Timers.Timer conTimer = null;
private List<string> needConIp = new List<string>();
public override void StartConnect(params string[] ipList)
{
if (conTimer == null)
{
conTimer = new System.Timers.Timer();
conTimer.AutoReset = true;
conTimer.Interval = 60000;
conTimer.Elapsed += ConTimer_Elapsed;
}
conTimer.Enabled = false;
needConIp = new List<string>(ipList);
foreach (string ip in ipList)
{
bool result = ConnectionIP(ip);
}
if (needConIp.Count > 0)
{
//启动定时器,1一分钟重连一次
conTimer.Start();
}
}
private bool ConnectionIP(string ioIp)
{
int autoMS = 150;
try
{
AIValList = new List<int>();
AIBox = new Asa.IOModule.AIOBOX();
AIBox.IP = ioIp;
// bool rtn = AIBox.AutoIP(ioIp);
AIBox.SetInput(Asa.IOModule.Box_Type.AI, AILength);
AIBox.SetOutput(Asa.IOModule.Box_Type.DO, 0);
AIBox.AutoReadInput(true, autoMS);
AIBox.AI_Changed_Event += Box_AI_Changed_Event;
LogUtil.debug("开始连接AI模块[" + ioIp + "][" + autoMS + "],尝试重连三次");
for (int i = 1; i <= 3; i++)
{
bool result = AIBox.Connect();
if (result)
{
if (needConIp.Contains(ioIp))
{
needConIp.Remove(ioIp);
}
LogUtil.info("第【" + i + "】次连接IO模块[" + ioIp + "][" + autoMS + "]成功:" + AIBox.ErrInfo);
return true;
}
else
{
LogUtil.error("第【" + i + "】次连接IO模块[" + ioIp + "][" + autoMS + "]失败:" + AIBox.ErrInfo + "");
}
Thread.Sleep(10);
}
}
catch (Exception error)
{
LogUtil.error("连接IO模块[" + ioIp + "][" + autoMS + "]出错:" + error.ToString());
}
return false;
}
private void ConTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
List<string> list = new List<string>(needConIp);
if (list.Count > 0)
{
foreach (string ip in list)
{
LogUtil.info("重连AOI AI 模块 :" + ip);
ConnectionIP(ip);
}
}
}
catch (Exception ex)
{
LogUtil.error("AOI AI ConTimer_Elapsed 出错: " + ex.ToString());
}
}
public override void CloseConnect()
{
try
{
if (AIBox != null)
{
AIBox.Close();
}
}
catch (Exception ex)
{
LogUtil.error("断开AI连接出错:" + ex.ToString());
}
}
private void Box_AI_Changed_Event(AIOBOX box, int[] val)
{
try
{
if (val != null && val.Length >= AILength)
{
lock (AILock)
{
AIValList = new List<int>();
AIValList.AddRange(val);
}
}
}
catch (Exception ex)
{
LogUtil.error("Box_AI_Changed_Event出错:" + ex.ToString());
}
}
public override double GetAIValue(string ioiP,int index)
{
if (AIValList != null && AIValList.Count > index)
{
return AIValList[index];
}
return -1;
}
//public override double ConvertAI(double aiValue, double defaultValue)
//{
// double xishu = (double)ConfigAppSettings.GetNumValue(Setting_Init.AI_ConvertPosition);
// double result = Math.Round((aiValue - defaultValue) / xishu, 2);
// return result;
//}
}
}
...@@ -27,6 +27,52 @@ namespace OnlineStore.DeviceLibrary ...@@ -27,6 +27,52 @@ namespace OnlineStore.DeviceLibrary
private object DILock = ""; private object DILock = "";
private object DOLock = ""; private object DOLock = "";
private List<string> IoIPLIst = new List<string>();
private System.Timers.Timer conTimer = null;
public override void ConnectionIOList(List<string> DIONameList)
{
if (conTimer == null)
{
conTimer = new System.Timers.Timer();
conTimer.AutoReset = true;
conTimer.Interval = 60000;
conTimer.Elapsed += ConTimer_Elapsed;
}
conTimer.Enabled = false;
IoIPLIst = new List<string>(DIONameList);
foreach (string ip in DIONameList)
{
ConnectionIP(ip);
}
if (IoIPLIst.Count > 0)
{
//启动定时器,1一分钟重连一次
conTimer.Start();
}
}
private void ConTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
List<string> list = new List<string>(IoIPLIst);
if (list.Count > 0)
{
foreach (string ip in list)
{
LogUtil.info("重连AOI :" + ip);
ConnectionIP(ip);
}
}
}
catch (Exception ex)
{
LogUtil.error("AOI ConTimer_Elapsed 出错: " + ex.ToString());
}
}
public void ConnectionIP(string ioIp) public void ConnectionIP(string ioIp)
{ {
AIOBOX aioBox = null; AIOBOX aioBox = null;
...@@ -49,24 +95,27 @@ namespace OnlineStore.DeviceLibrary ...@@ -49,24 +95,27 @@ namespace OnlineStore.DeviceLibrary
{ {
DOValueMap.Remove(ioIp); DOValueMap.Remove(ioIp);
} }
int DIMS = ConfigAppSettings.GetIntValue("DIMS");
if (DIMS < 20)
{
DIMS = 20;
}
int DOMS = ConfigAppSettings.GetIntValue("DOMS");
if (DOMS < 200)
{
DOMS = 200;
}
int DILength = StoreManager.Config.GetDILength(ioIp);
int DOLength = StoreManager.Config.GetDOLength(ioIp);
string logName = "IO模块[" + ioIp + "] DI[" + DILength + "] DO[" + DOLength + "],[" + DIMS + "] [" + DOMS + "]";
try try
{ {
// Create new modbus master and add event functions // Create new modbus master and add event functions
aioBox = new AIOBOX(); aioBox = new AIOBOX();
aioBox.IP = ioIp; aioBox.IP = ioIp;
int DIMS = ConfigAppSettings.GetIntValue("DIMS");
if (DIMS < 20)
{
DIMS = 20;
}
int DOMS = ConfigAppSettings.GetIntValue("DOMS");
if (DOMS < 200)
{
DOMS = 200;
}
// bool rtn = aioBox.AutoIP(ioIp); // bool rtn = aioBox.AutoIP(ioIp);
int DILength = StoreManager.Config.GetDILength(ioIp);
int DOLength = StoreManager.Config.GetDOLength(ioIp);
aioBox.SetInput(Asa.IOModule.Box_Type.DI, DILength); aioBox.SetInput(Asa.IOModule.Box_Type.DI, DILength);
aioBox.SetOutput(Asa.IOModule.Box_Type.DO, DOLength); aioBox.SetOutput(Asa.IOModule.Box_Type.DO, DOLength);
aioBox.AutoReadInput(true, DIMS); aioBox.AutoReadInput(true, DIMS);
...@@ -75,32 +124,37 @@ namespace OnlineStore.DeviceLibrary ...@@ -75,32 +124,37 @@ namespace OnlineStore.DeviceLibrary
aioBox.DI_Changed_Event += AioBox_DI_Changed_Event; ; aioBox.DI_Changed_Event += AioBox_DI_Changed_Event; ;
aioBox.DO_Changed_Event += AioBox_DO_Changed_Event; aioBox.DO_Changed_Event += AioBox_DO_Changed_Event;
// aioBox.Log_Out_Event += AioBox_Log_Out_Event; // aioBox.Log_Out_Event += AioBox_Log_Out_Event;
//aioBox.Log_RxTx_Event += AioBox_Log_RxTx_Event; //aioBox.Log_RxTx_Event += AioBox_Log_RxTx_Event;
AIOMap.Add(ioIp, aioBox); AIOMap.Add(ioIp, aioBox);
LogUtil.info("开始连接IO模块[" + ioIp + "][" + DIMS + "][" + DOMS + "],尝试重连三次");
LogUtil.debug("开始连接" + logName + ",尝试重连5次");
for (int i = 1; i <= 3; i++) for (int i = 1; i <= 3; i++)
{ {
bool result = aioBox.Connect(); bool result = aioBox.Connect();
if (result) if (result)
{ {
LogUtil.info("第【" + i + "】次连接IO模块【" + ioIp + "】成功:" + aioBox.ErrInfo); LogUtil.info("第【" + i + "】次连接 " + logName + " 成功:" + aioBox.ErrInfo);
Thread.Sleep(10); Thread.Sleep(10);
//读取所有的DO //读取所有的DO
ReadAllDI(ioIp, 0); ReadAllDI(ioIp, 0);
if (IoIPLIst.Contains(ioIp))
{
IoIPLIst.Remove(ioIp);
}
break; break;
} }
else else
{ {
LogUtil.error("第【" + i + "】次连接IO模块【" + ioIp + "】失败:" + aioBox.ErrInfo + ""); LogUtil.error("第【" + i + "】次连接 " + logName + " 失败:" + aioBox.ErrInfo + "");
} }
Thread.Sleep(10); Thread.Sleep(2);
} }
} }
catch (Exception error) catch (Exception error)
{ {
LogUtil.error(LOGGER, "连接IO模块[" + ioIp + "]出错:" + error.ToString()); LogUtil.error(LOGGER, "连接IO模块 " + logName + " 出错:" + error.ToString());
} }
} }
...@@ -123,7 +177,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -123,7 +177,7 @@ namespace OnlineStore.DeviceLibrary
{ {
foreach (string str in s) foreach (string str in s)
{ {
LogUtil.AIOLog.Debug("[" + box.IP + "]" + str); // LogUtil.AIOLog.Debug("[" + box.IP + "]" + str);
} }
} }
...@@ -155,6 +209,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -155,6 +209,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (sta != null && sta.Length >= StoreManager.Config.GetDILength(ip)) if (sta != null && sta.Length >= StoreManager.Config.GetDILength(ip))
{ {
string updateDi = "[" + ip + "]:";
bool needUpdate = false; bool needUpdate = false;
List<Box_Sta> newList = new List<Box_Sta>(); List<Box_Sta> newList = new List<Box_Sta>();
newList.AddRange(sta); newList.AddRange(sta);
...@@ -166,6 +221,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -166,6 +221,14 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
//foreach(Box_Sta s in sta)
//{
// updateDi += s.ToString() + ",";
//}
//if (ip.Equals("192.168.201.61"))
//{
// LogUtil.info(updateDi);
//}
for (int i = 0; i < newList.Count; i++) for (int i = 0; i < newList.Count; i++)
{ {
if (!(oldList[i].Equals(newList[i]))) if (!(oldList[i].Equals(newList[i])))
...@@ -245,13 +308,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -245,13 +308,6 @@ namespace OnlineStore.DeviceLibrary
} }
public override void ConnectionIOList(List<string> DIONameList)
{
foreach (string ip in DIONameList)
{
ConnectionIP(ip);
}
}
//关闭所有的DO //关闭所有的DO
public override void CloseAllDO() public override void CloseAllDO()
...@@ -372,7 +428,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -372,7 +428,7 @@ namespace OnlineStore.DeviceLibrary
AIOBOX aioBox = getAIO(ioIp); AIOBOX aioBox = getAIO(ioIp);
if (aioBox != null) if (aioBox != null)
{ {
// int startIndex = StoreManager.Config.GetDILength(ioIp); // int startIndex = StoreManager.Config.GetDILength(ioIp);
Box_Sta[] allDO = aioBox.ReadDO(0, StoreManager.Config.GetDOLength(ioIp)); Box_Sta[] allDO = aioBox.ReadDO(0, StoreManager.Config.GetDOLength(ioIp));
UpdateAllDO(ioIp, allDO); UpdateAllDO(ioIp, allDO);
} }
...@@ -392,8 +448,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -392,8 +448,8 @@ namespace OnlineStore.DeviceLibrary
{ {
Box_Sta sta = Box_Sta.Off; Box_Sta sta = Box_Sta.Off;
// Box_Addr addr = GetAddr(StartAddress); // Box_Addr addr = GetAddr(StartAddress);
// int index = (int)StartAddress - (int)StoreManager.Config.GetDILength(ioIP); // int index = (int)StartAddress - (int)StoreManager.Config.GetDILength(ioIP);
if (DOValueMap.ContainsKey(ioIP) && DOValueMap[ioIP].Count > StartAddress) if (DOValueMap.ContainsKey(ioIP) && DOValueMap[ioIP].Count > StartAddress)
{ {
sta = DOValueMap[ioIP][StartAddress]; sta = DOValueMap[ioIP][StartAddress];
...@@ -451,11 +507,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -451,11 +507,11 @@ namespace OnlineStore.DeviceLibrary
{ {
if (configIO.ProType.Equals(ConfigItemType.DI)) if (configIO.ProType.Equals(ConfigItemType.DI))
{ {
return GetDIValue(configIO.IO_IP, configIO.SlaveID, configIO.GetIOAddr()); return GetDIValue(configIO.DeviceName, configIO.SlaveID, configIO.GetIOAddr());
} }
else if (configIO.ProType.Equals(ConfigItemType.DO)) else if (configIO.ProType.Equals(ConfigItemType.DO))
{ {
return GetDOValue(configIO.IO_IP, configIO.SlaveID, configIO.GetIOAddr()); return GetDOValue(configIO.DeviceName, configIO.SlaveID, configIO.GetIOAddr());
} }
} }
catch (Exception ex) catch (Exception ex)
......

namespace Asa.IOModule
{
/// <summary>
/// IO模块寄存器
/// </summary>
public class Reg
{
/// <summary>
/// 标识
/// </summary>
public int ID;
/// <summary>
/// 文本,仅用于显示
/// </summary>
public string Text;
/// <summary>
/// 寄存器地址
/// </summary>
public Box_Addr Address;
/// <summary>
/// 当前的状态
/// </summary>
public Box_Sta Status;
/// <summary>
/// 寄存器,文本空,状态OFF
/// </summary>
/// <param name="address">地址</param>
public Reg(Box_Addr address) : this(0, "", address, Box_Sta.Off)
{
}
/// <summary>
/// 寄存器,状态OFF
/// </summary>
/// <param name="text">文本</param>
/// <param name="addr">地址</param>
public Reg(string text, Box_Addr addr) : this(0, text, addr, Box_Sta.Off)
{
}
/// <summary>
/// 寄存器,状态OFF
/// </summary>
/// <param name="id">标志</param>
/// <param name="text">文本</param>
/// <param name="addr">地址</param>
public Reg(int id, string text, Box_Addr addr) : this(id, text, addr, Box_Sta.Off)
{
}
/// <summary>
/// 寄存器
/// </summary>
/// <param name="text">文本</param>
/// <param name="addr">地址</param>
/// <param name="status">状态</param>
public Reg(string text, Box_Addr addr, Box_Sta status) : this(0, text, addr, status)
{
}
/// <summary>
/// 寄存器
/// </summary>
/// <param name="id">标志</param>
/// <param name="text">文本</param>
/// <param name="address">地址</param>
/// <param name="status">状态</param>
public Reg(int id, string text, Box_Addr address, Box_Sta status)
{
ID = id;
Text = text;
Address = address;
Status = status;
}
}
/// <summary>
/// IO模块寄存器地址
/// </summary>
public enum Box_Addr : int
{
/// <summary>
/// 输入点,DI01
/// </summary>
DI_1,
/// <summary>
/// 输入点,DI02
/// </summary>
DI_2,
/// <summary>
/// 输入点,DI03
/// </summary>
DI_3,
/// <summary>
/// 输入点,DI04
/// </summary>
DI_4,
/// <summary>
/// 输入点,DI05
/// </summary>
DI_5,
/// <summary>
/// 输入点,DI06
/// </summary>
DI_6,
/// <summary>
/// 输入点,DI07
/// </summary>
DI_7,
/// <summary>
/// 输入点,DI08
/// </summary>
DI_8,
/// <summary>
/// 输入点,DI09
/// </summary>
DI_9,
/// <summary>
/// 输入点,DI10
/// </summary>
DI_10,
/// <summary>
/// 输入点,DI11
/// </summary>
DI_11,
/// <summary>
/// 输入点,DI12
/// </summary>
DI_12,
/// <summary>
/// 输入点,DI13
/// </summary>
DI_13,
/// <summary>
/// 输入点,DI14
/// </summary>
DI_14,
/// <summary>
/// 输入点,DI15
/// </summary>
DI_15,
/// <summary>
/// 输入点,DI16
/// </summary>
DI_16,
/// <summary>
/// 输出点,DO01
/// </summary>
DO_1,
/// <summary>
/// 输出点,DO02
/// </summary>
DO_2,
/// <summary>
/// 输出点,DO03
/// </summary>
DO_3,
/// <summary>
/// 输出点,DO04
/// </summary>
DO_4,
/// <summary>
/// 输出点,DO05
/// </summary>
DO_5,
/// <summary>
/// 输出点,DO06
/// </summary>
DO_6,
/// <summary>
/// 输出点,DO07
/// </summary>
DO_7,
/// <summary>
/// 输出点,DO08
/// </summary>
DO_8,
/// <summary>
/// 输出点,DO09
/// </summary>
DO_9,
/// <summary>
/// 输出点,DO10
/// </summary>
DO_10,
/// <summary>
/// 输出点,DO11
/// </summary>
DO_11,
/// <summary>
/// 输出点,DO12
/// </summary>
DO_12,
/// <summary>
/// 输出点,DO13
/// </summary>
DO_13,
/// <summary>
/// 输出点,DO14
/// </summary>
DO_14,
/// <summary>
/// 输出点,DO15
/// </summary>
DO_15,
/// <summary>
/// 输出点,DO16
/// </summary>
DO_16,
/// <summary>
/// 无
/// </summary>
NONE = 255
}
/// <summary>
/// IO模块类型
/// </summary>
public enum Box_Type : int
{
/// <summary>
/// 16位,8DI + 8DO
/// </summary>
DIO_16,
/// <summary>
/// 32位,16DI + 16DO
/// </summary>
DIO_32,
/// <summary>
/// 16位DO
/// </summary>
DO_16
}
/// <summary>
/// IO模块寄存器状态
/// </summary>
public enum Box_Sta : int
{
/// <summary>
/// 断开,关闭,低电平
/// </summary>
Off = 0,
/// <summary>
/// 闭合,打开,高电平
/// </summary>
On = 255
}
}
\ No newline at end of file \ No newline at end of file
using Asa.RFID;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class RFIDManager
{
public static Dictionary<string, Reader> RFReaderMap = new Dictionary<string, Reader>();
private static List<string> RfIPList = new List<string>();
private static System.Timers.Timer conTimer = null;
internal static void ConnectRFIOList(List<string> rfioNameList)
{
try {
if (conTimer == null)
{
conTimer = new System.Timers.Timer();
conTimer.AutoReset = true;
conTimer.Interval = 60000;
conTimer.Elapsed += ConTimer_Elapsed;
}
conTimer.Enabled = false;
RfIPList = new List<string>(rfioNameList);
foreach (string ip in rfioNameList)
{
ConnectionIP(ip);
}
if (RfIPList.Count > 0)
{
conTimer.Start();
}
}catch(Exception ex)
{
LogUtil.error("ConnectRFIOList出错:" + ex.ToString());
}
}
private static bool isProcess = false;
private static DateTime lastTime = DateTime.Now;
private static void ConTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
TimeSpan span = DateTime.Now - lastTime;
if (span.TotalMinutes < RfIPList.Count && isProcess)
{
return;
}
isProcess = true;
lastTime = DateTime.Now;
try
{
List<string> list = new List<string>(RfIPList);
if (list.Count > 0)
{
LogUtil.info("开始重连RFIP模块 ------------");
foreach (string ip in list)
{
ConnectionIP(ip);
}
LogUtil.info("结束重连RFIP模块 ------------");
}
GC.Collect();
}
catch (Exception ex)
{
LogUtil.error("RFIP ConTimer_Elapsed 出错: " + ex.ToString());
}
isProcess = false;
}
internal static void ConnectionIP(string rfid)
{
Reader rfidReader = null;
if (RFReaderMap.ContainsKey(rfid))
{
rfidReader = RFReaderMap[rfid];
if (null != rfidReader)
{
rfidReader.Close();
rfidReader = null;
}
RFReaderMap.Remove(rfid);
}
string logName = "RFIP模块[" + rfid + "] ";
try
{
LogUtil.debug("开始连接" + logName + ",尝试重连3次");
for (int i = 1; i <= 3; i++)
{
rfidReader = new Reader();
// rfidReader.LocalIP = "192.168.100.101";
rfidReader.RemoteIP = rfid;
bool result = rfidReader.Connect();
if (result)
{
rfidReader.AutoScan(true);
LogUtil.info("第【" + i + "】次连接 " + logName + " 成功:");
Thread.Sleep(10);
RFReaderMap.Add(rfid, rfidReader);
if (RfIPList.Contains(rfid))
{
RfIPList.Remove(rfid);
}
break;
}
else
{
LogUtil.error("第【" + i + "】次连接 " + logName + " 失败:" + "");
}
Thread.Sleep(5);
}
}
catch (Exception error)
{
LogUtil.error("连接RFIP模块 " + logName + " 出错:" + error.ToString());
}
}
internal static void CloseAllConnection()
{
foreach (Reader reader in RFReaderMap.Values)
{
reader.Close();
}
}
public static bool WriteData(string IP, RFIDData obj)
{
byte[] sendData = obj.ToData();
return WriteData(IP, sendData, 3);
}
public static RFIDData ReadData(string IP)
{
byte[] reviceData = ReadData(IP, 3);
if (reviceData != null)
{
return new RFIDData(reviceData);
}
return null;
}
public static string SearchIP(string localIp)
{
string ip = "";
try
{
Reader rfReader = new Reader();
rfReader.LocalIP = localIp;
ip = rfReader.FindIP();
}
catch (Exception ex)
{
}
return ip;
}
public static bool FindRFID(string IP)
{
try
{
Reader rfReader = getRfReader(IP);
if (rfReader != null)
{
return rfReader.FindRFID();
}
}
catch (Exception ex)
{
LogUtil.error("RFIP FindRFID [" + IP + "] 出错 :" + ex.ToString());
}
return false;
}
public static byte[] ReadData(string IP, int reReadCount = 1,int startIndex=0,int readLength=8)
{
try
{
Reader rfReader = getRfReader(IP);
if (rfReader == null)
{
return null;
}
for (int i = 1; i <= reReadCount; i++)
{
byte[] reviceData = rfReader.Read(startIndex, readLength);
if (reviceData != null)
{
return reviceData;
}
LogUtil.error("RFIP ReadData [" + IP + "] 第" + i + "次失败 ");
}
}
catch (Exception ex)
{
LogUtil.error("RFIP ReadData [" + IP + "] 出错 :" + ex.ToString());
}
return null;
}
public static bool WriteData(string IP, byte[] data, int reWriteCount = 1)
{
try
{
Reader rfReader = getRfReader(IP);
if (rfReader == null)
{
return false;
}
for (int i = 1; i <= reWriteCount; i++)
{
bool result = rfReader.Write(data);
if (result)
{
return result;
}
LogUtil.error("RFIP WriteData [" + IP + "] 第" + i + "次失败:");
}
}
catch (Exception ex)
{
LogUtil.error("RFIP WriteData [" + IP + "] 出错 :" + ex.ToString());
}
return false;
}
private static Reader getRfReader(string IP)
{
Reader rfReader = null;
if (RFReaderMap.ContainsKey(IP))
{
rfReader = RFReaderMap[IP];
}
else
{
LogUtil.error("getRfReader 没有连接RFIP模块:" + IP);
}
return rfReader;
}
}
public class RFIDData
{
/// <summary>
/// RFID类型,区分是料架还是托盘,托盘=E
/// </summary>
public char RFType= 'E';
/// <summary>
/// 托盘编号,从1-32
/// </summary>
public int Num = 0;
public RFIDData (int num,char t='E')
{
this.RFType = t;
this.Num = num;
}
public RFIDData(byte[] data)
{
try
{
RFType =(char)data[1];
Num = Convert.ToInt32(data[2]);
}
catch (Exception ex)
{
LogUtil.error("RFIP 数据【" + data + "】 获取编码失败");
}
}
public byte[] ToData(int dataLength=10)
{
byte[] sendData = new byte[dataLength];
for (int i = 0; i < sendData.Length; i++)
{
sendData[i] = 0x00;
}
sendData[0] = (byte)RFType;
sendData[1] = (byte)Num;
return sendData;
}
public string ToStr()
{
return "Type=["+RFType+"],Num=["+Num+"]";
}
}
}
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
namespace OnlineStore.DeviceLibrary
{
/// <summary>
/// 压紧机构计量检测信号处理
/// </summary>
public class MeteringSignal
{
public static int ComAxisChangeValue = ConfigAppSettings.GetIntValue(Setting_Init.ComAxisChangeValue);
/// <summary>
/// 信号变化次数
/// </summary>
public static int SignalChangeCount=0;
public static int TragetChangeCount = 0;
public static IO_VALUE PreSignalValue = IO_VALUE.LOW;
private static System.Timers.Timer timer = null;
public static void StartCheck(int targetPositon, int currPosition)
{
int chazhi = Math.Abs(targetPositon - currPosition);
int count = chazhi / ComAxisChangeValue;
if (count > 0 && chazhi > ComAxisChangeValue)
{
StartCheck(count);
}
}
private static void StartCheck(int targetCount)
{
TragetChangeCount = targetCount;
if (timer == null)
{
timer = new System.Timers.Timer();
timer.Interval = 50;
timer.AutoReset = true;
timer.Elapsed += Timer_Elapsed;
timer.Enabled = false;
}
LogUtil.debug("开始压紧轴计量检测,预计变化" + TragetChangeCount + "次");
IsInProcess = false;
PreSignalValue = IO_VALUE.LOW;
SignalChangeCount = 0;
timer.Start();
}
public static void StopCheck()
{
if(timer==null)
{ return; }
timer.Stop();
}
private static bool IsInProcess = false;
protected static void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
if (IsInProcess) { return; }
IsInProcess = true;
IO_VALUE value = StoreManager.Store.KNDIOValue(IO_Type.CompressAxis_Check);
if (value.Equals(IO_VALUE.HIGH) && PreSignalValue.Equals(IO_VALUE.LOW))
{
SignalChangeCount++;
LogUtil.debug("检测到信号变化,已经变化" + SignalChangeCount + "次");
}
PreSignalValue = value;
if (TragetChangeCount <= SignalChangeCount)
{
timer.Stop();
}
IsInProcess = false;
}
}
}
...@@ -30,8 +30,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -30,8 +30,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 日志颜色 /// 日志颜色
/// </summary> /// </summary>
protected static Color storeMoveColor = Color.Blue; protected static Color storeMoveColor = Color.Blue;
protected static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public string Name { get; set; } public string Name { get; set; }
public int DeviceID { get; set; } public int DeviceID { get; set; }
public BaseConfig baseConfig = null; public BaseConfig baseConfig = null;
...@@ -99,7 +98,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -99,7 +98,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LOGGER.Error(ex.ToString()); LogUtil.error(ex.ToString());
} }
} }
...@@ -238,7 +237,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -238,7 +237,7 @@ namespace OnlineStore.DeviceLibrary
protected void ACAxisHomeMove(ConfigMoveAxis moveAxis) protected void ACAxisHomeMove(ConfigMoveAxis moveAxis)
{ {
moveAxis.TargetPosition = 0; moveAxis.TargetPosition = 0;
LogUtil.info(LOGGER, moveAxis.DisplayStr + "speed[" + moveAxis.TargetSpeed + "]开始原点返回"); LogUtil.info(Name+ moveAxis.DisplayStr + "speed[" + moveAxis.TargetSpeed + "]开始原点返回");
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, true)); MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, true));
ACServerManager.HomeMove(moveAxis.DeviceName, (short)moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed); ACServerManager.HomeMove(moveAxis.DeviceName, (short)moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed);
} }
...@@ -274,7 +273,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -274,7 +273,7 @@ namespace OnlineStore.DeviceLibrary
//判断是否需要重新运动 //判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0) if (MoveInfo.CanWhileCount > 0)
{ {
LogUtil.error(LOGGER, moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount + LogUtil.error(Name+ moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount +
"],误差过大,重新开始运动,剩余[" + MoveInfo.CanWhileCount + "]次"); "],误差过大,重新开始运动,剩余[" + MoveInfo.CanWhileCount + "]次");
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed); ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed);
MoveInfo.CanWhileCount--; MoveInfo.CanWhileCount--;
...@@ -283,7 +282,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -283,7 +282,7 @@ namespace OnlineStore.DeviceLibrary
{ {
msg = Name + " storeMoveStep=" + MoveInfo.MoveStep + moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount msg = Name + " storeMoveStep=" + MoveInfo.MoveStep + moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount
+ "],误差过大,需要报警"; + "],误差过大,需要报警";
LogUtil.error(LOGGER, msg); LogUtil.error(Name+ msg);
} }
} }
return false; return false;
...@@ -303,7 +302,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -303,7 +302,7 @@ namespace OnlineStore.DeviceLibrary
//判断是否需要重新运动 //判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0) if (MoveInfo.CanWhileCount > 0)
{ {
LogUtil.error(LOGGER, moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],重新回原点,剩余[" + MoveInfo.CanWhileCount + "]次"); LogUtil.error(Name+ moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],重新回原点,剩余[" + MoveInfo.CanWhileCount + "]次");
//LogUtil.error(LOGGER, StoreName + moveAxis.DisplayStr + "重新回原点"); //LogUtil.error(LOGGER, StoreName + moveAxis.DisplayStr + "重新回原点");
ACServerManager.HomeMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed); ACServerManager.HomeMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed);
MoveInfo.CanWhileCount--; MoveInfo.CanWhileCount--;
...@@ -311,7 +310,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -311,7 +310,7 @@ namespace OnlineStore.DeviceLibrary
else else
{ {
msg = Name + " storeMoveStep=" + MoveInfo.MoveStep + moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警"; msg = Name + " storeMoveStep=" + MoveInfo.MoveStep + moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警";
LogUtil.error(LOGGER, msg); LogUtil.error(Name+ msg);
} }
} }
return false; return false;
...@@ -477,6 +476,29 @@ namespace OnlineStore.DeviceLibrary ...@@ -477,6 +476,29 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.info(Name + logInfo); LogUtil.info(Name + logInfo);
} }
protected int GetAlarmCodeByAxis(ConfigMoveAxis axis)
{
int alarmCode = LineAlarm.InOutAxisAlarm;
int axisType = axis.GetAxisValue() % 4;
if (axisType == 1)
{
alarmCode = LineAlarm.MiddleAxisAlarm;
}
else if (axisType == 2)
{
alarmCode = LineAlarm.UpDownAxisAlarm;
}
else if (axisType == 3)
{
alarmCode = LineAlarm.InOutAxisAlarm;
}
else
{
alarmCode = LineAlarm.CompressAxisAlarm;
}
return alarmCode;
}
} }
} }
...@@ -441,7 +441,11 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -441,7 +441,11 @@ namespace OnlineStore.LoadCSVLibrary
[ConfigProAttribute("CameraNameList")] [ConfigProAttribute("CameraNameList")]
public string CameraNameList { get; set; } public string CameraNameList { get; set; }
/// <summary>
/// PRO,RFID读卡器IP,RFID_IP,192.168.200.11,,,,,,,
/// </summary>
[ConfigProAttribute("RFID_IP")]
public string RFID_IP { get; set; }
/// <summary> /// <summary>
/// PRO,是否是调试状态,IsInDebug,1,,,,,,, /// PRO,是否是调试状态,IsInDebug,1,,,,,,,
/// </summary> /// </summary>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!