Commit fe0f0af3 LN

增加rfid功能

1 个父辈 653c312f
此文件类型无法预览
......@@ -85,6 +85,12 @@
<Compile Include="FrmAbout.Designer.cs">
<DependentUpon>FrmAbout.cs</DependentUpon>
</Compile>
<Compile Include="FrmRFIPEdit.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmRFIPEdit.Designer.cs">
<DependentUpon>FrmRFIPEdit.cs</DependentUpon>
</Compile>
<Compile Include="FrmStore.cs">
<SubType>Form</SubType>
</Compile>
......@@ -130,6 +136,9 @@
<EmbeddedResource Include="FrmAbout.resx">
<DependentUpon>FrmAbout.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmRFIPEdit.resx">
<DependentUpon>FrmRFIPEdit.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmStore.resx">
<DependentUpon>FrmStore.cs</DependentUpon>
</EmbeddedResource>
......
......@@ -640,7 +640,7 @@
this.groupBox7.Controls.Add(this.btnTempInit);
this.groupBox7.Location = new System.Drawing.Point(11, 6);
this.groupBox7.Name = "groupBox7";
this.groupBox7.Size = new System.Drawing.Size(534, 166);
this.groupBox7.Size = new System.Drawing.Size(561, 154);
this.groupBox7.TabIndex = 272;
this.groupBox7.TabStop = false;
this.groupBox7.Text = "温控器调试";
......
......@@ -781,12 +781,16 @@ namespace OnlineStore.ACPackingStore
{
List<string> codes = CodeManager.CameraScan(BoxBean.Config.GetCameraList());
string result = "";
if (codes.Count > 0)
{
foreach (string s in codes)
{
result += s + "\r\n";
}
MessageBox.Show("扫到二维码:" + result);
LogUtil.info("扫到二维码:" + result);
}
}
private void cmbShelfPosition_SelectedIndexChanged(object sender, EventArgs e)
{
......
......@@ -17,6 +17,7 @@
{
this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.button1 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnBlow = new System.Windows.Forms.Button();
this.btnStoreOn = new System.Windows.Forms.Button();
......@@ -43,8 +44,6 @@
this.cmbWriteIO = new System.Windows.Forms.ComboBox();
this.btnCloseDoor = new System.Windows.Forms.Button();
this.btnOpenDoor = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.chbAutoRead = new System.Windows.Forms.CheckBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.groupBox3 = new System.Windows.Forms.GroupBox();
......@@ -59,6 +58,17 @@
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button1.Location = new System.Drawing.Point(667, 551);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(126, 37);
this.button1.TabIndex = 254;
this.button1.Text = "关闭";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
......@@ -89,9 +99,9 @@
this.groupBox1.Controls.Add(this.btnCloseDoor);
this.groupBox1.Controls.Add(this.btnOpenDoor);
this.groupBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox1.Location = new System.Drawing.Point(485, 12);
this.groupBox1.Location = new System.Drawing.Point(485, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(332, 517);
this.groupBox1.Size = new System.Drawing.Size(332, 527);
this.groupBox1.TabIndex = 105;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "DO写入";
......@@ -393,31 +403,6 @@
this.btnOpenDoor.UseVisualStyleBackColor = false;
this.btnOpenDoor.Click += new System.EventHandler(this.btnOpenDoor_Click);
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button1.Location = new System.Drawing.Point(667, 551);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(126, 37);
this.button1.TabIndex = 254;
this.button1.Text = "关闭";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// chbAutoRead
//
this.chbAutoRead.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.chbAutoRead.AutoSize = true;
this.chbAutoRead.Checked = true;
this.chbAutoRead.CheckState = System.Windows.Forms.CheckState.Checked;
this.chbAutoRead.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbAutoRead.Location = new System.Drawing.Point(558, 560);
this.chbAutoRead.Name = "chbAutoRead";
this.chbAutoRead.Size = new System.Drawing.Size(75, 21);
this.chbAutoRead.TabIndex = 244;
this.chbAutoRead.Text = "自动读取";
this.chbAutoRead.UseVisualStyleBackColor = true;
//
// groupBox4
//
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
......@@ -481,7 +466,6 @@
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.chbAutoRead);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FrmIOStatus";
......@@ -494,7 +478,6 @@
this.groupBox4.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
......@@ -512,7 +495,6 @@
private System.Windows.Forms.TextBox txtWriteTime;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox cmbWriteIO;
private System.Windows.Forms.CheckBox chbAutoRead;
private System.Windows.Forms.TextBox txtDoName;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button btnCloseDoor;
......
......@@ -81,7 +81,7 @@ namespace OnlineStore.ACPackingStore
private void timer1_Tick(object sender, EventArgs e)
{
if (chbAutoRead.Checked)
if (this.Visible)
{
ReadIOList();
}
......

using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.ACPackingStore
{
internal partial class FrmRFIPEdit : FrmBase
{
internal FrmRFIPEdit( )
{
InitializeComponent();
}
private Dictionary<string, string> rfMap = new Dictionary<string, string>();
private void FrmPwd_Load(object sender, EventArgs e)
{
comboxType.Items.Clear();
foreach (AC_BOX_Bean b in StoreManager.Store.BoxMap.Values)
{
string key = b.Name + "-托盘RF";
string value = b.Config.RFID_IP;
rfMap.Add(key, value);
comboxType.Items.Add(key);
}
comboxType.SelectedIndex = 0;
comType.SelectedIndex = 0;
string hostN = Dns.GetHostName();
IPAddress[] addresss = Dns.GetHostAddresses(hostN);
cmbLocalIp.Items.Clear();
if (addresss != null && addresss.Length > 0)
{
foreach (IPAddress ip in addresss)
{
if (ip.AddressFamily.Equals(AddressFamily.InterNetwork))
{
cmbLocalIp.Items.Add(ip.ToString());
}
}
cmbLocalIp.SelectedIndex = 0;
}
}
private void btnBack_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
string ip = txtIP.Text;
RFIDData data = RFIDManager.ReadData(ip);
string resul = "";
if (data != null)
{
resul = data.ToStr();
numNum.Value = data.Num;
int selIndex = data.RFType - 64;
if (selIndex >= 0 && selIndex <= comboxType.Items.Count)
{
comboxType.SelectedIndex = selIndex;
}
}
MessageBox.Show("读取到数据:" + resul);
}
private void comboxType_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboxType.SelectedIndex >= 0)
{
string V = rfMap[comboxType.Text];
if (!txtIP.Text.Equals(V))
{
txtIP.Text = V;
}
}
}
private void btnSearch_Click(object sender, EventArgs e)
{
string text = cmbLocalIp.Text;
string ip = RFIDManager.SearchIP(text);
txtSearchIp.Text = ip;
}
}
}
此文件的差异太大,无法显示。
......@@ -55,6 +55,7 @@
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
this.二维码学习ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.托盘编码ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.帮助ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.版本号ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
......@@ -62,6 +63,7 @@
this.显示ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.menuStrip1.SuspendLayout();
......@@ -273,7 +275,8 @@
this.toolStripMenuItem2,
this.toolStripSeparator6,
this.二维码学习ToolStripMenuItem,
this.toolStripSeparator7});
this.toolStripSeparator7,
this.托盘编码ToolStripMenuItem});
this.设置TToolStripMenuItem.Name = "设置TToolStripMenuItem";
this.设置TToolStripMenuItem.Size = new System.Drawing.Size(91, 25);
this.设置TToolStripMenuItem.Text = "设备调试 ";
......@@ -302,6 +305,13 @@
this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(157, 6);
//
// 托盘编码ToolStripMenuItem
//
this.托盘编码ToolStripMenuItem.Name = "托盘编码ToolStripMenuItem";
this.托盘编码ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
this.托盘编码ToolStripMenuItem.Text = "托盘编码";
this.托盘编码ToolStripMenuItem.Click += new System.EventHandler(this.托盘编码ToolStripMenuItem_Click);
//
// 帮助ToolStripMenuItem
//
this.帮助ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
......@@ -330,21 +340,22 @@
this.contextMenuStrip1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.显示ToolStripMenuItem,
this.toolStripSeparator8,
this.toolStripMenuItem1});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(113, 56);
this.contextMenuStrip1.Size = new System.Drawing.Size(181, 84);
//
// 显示ToolStripMenuItem
//
this.显示ToolStripMenuItem.Name = "显示ToolStripMenuItem";
this.显示ToolStripMenuItem.Size = new System.Drawing.Size(112, 26);
this.显示ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.显示ToolStripMenuItem.Text = "显示";
this.显示ToolStripMenuItem.Click += new System.EventHandler(this.显示ToolStripMenuItem_Click);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(112, 26);
this.toolStripMenuItem1.Size = new System.Drawing.Size(180, 26);
this.toolStripMenuItem1.Text = "退出";
this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
//
......@@ -353,6 +364,11 @@
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// toolStripSeparator8
//
this.toolStripSeparator8.Name = "toolStripSeparator8";
this.toolStripSeparator8.Size = new System.Drawing.Size(177, 6);
//
// FrmStore
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
......@@ -417,6 +433,8 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
private System.Windows.Forms.CheckBox chbUseBuzzer;
private System.Windows.Forms.ToolStripMenuItem 托盘编码ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator8;
}
}
......@@ -130,6 +130,7 @@ namespace OnlineStore.ACPackingStore
HumitureController.CloseAllPort();
//AIManager.CloseConnect();
ACServerManager.CloseAllPort();
CodeManager.CloseAllCamera();
//this.Close();
System.Environment.Exit(System.Environment.ExitCode);
}
......@@ -414,5 +415,11 @@ namespace OnlineStore.ACPackingStore
LogUtil.debug_opened = chkDebug.Checked;
LogUtil.info("debug_opened:" + chkDebug.Checked);
}
private void 托盘编码ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmRFIPEdit frm = new FrmRFIPEdit();
frm.ShowDialog();
}
}
}
......@@ -63,6 +63,30 @@ namespace OnlineStore.ACPackingStore
IOManager.Init();
IOManager.instance.ConnectionIOList(new List<string> { /*IoIp*/ });
}
P3Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P3_Offset);
P4Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P4_Offset);
P5Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P5_Offset);
P6Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P6_Offset);
int tSpeed = ConfigAppSettings.GetIntValue(Setting_Init.Tool_TargetSpeed);
int tPosition = ConfigAppSettings.GetIntValue(Setting_Init.Tool_TargetPosition);
if (P3Offset.Equals(0)) P3Offset = 6000;
if (P4Offset.Equals(0)) P4Offset = -6000;
if (P5Offset.Equals(0)) P5Offset = -6000;
if (P6Offset.Equals(0)) P6Offset = 6000;
if (tSpeed.Equals(0)) tSpeed = 20;
if (tPosition.Equals(0)) tPosition = 6000;
txtP3Offset.Text = P3Offset.ToString();
txtP4Offset.Text = P4Offset.ToString();
txtP5Offset.Text = P5Offset.ToString();
txtP6Offset.Text = P6Offset.ToString();
txtSpeed.Text = tSpeed.ToString();
txtPosition.Text = tPosition.ToString();
SaveConfig(tSpeed, tPosition);
//判断伺服是否已经打开
bool isOn = ACServerManager.ServerOnStatus(PortName, SlvAddr);
formStatus(isOn);
......@@ -168,6 +192,16 @@ namespace OnlineStore.ACPackingStore
txtActualPosition.Text = value.ToString();
}
private void SaveConfig(int speed, int position)
{
//保存配置
ConfigAppSettings.SaveValue(Setting_Init.Tool_P3_Offset, P3Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_P4_Offset, P4Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_P5_Offset, P5Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_P6_Offset, P6Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_TargetSpeed, speed);
ConfigAppSettings.SaveValue(Setting_Init.Tool_TargetPosition, position);
}
private void btnAbsMove_Click(object sender, EventArgs e)
{
int speed = Convert.ToInt32(txtSpeed.Text);
......@@ -184,6 +218,11 @@ namespace OnlineStore.ACPackingStore
P4Offset = FormUtil.GetIntValue(txtP4Offset);
P5Offset = FormUtil.GetIntValue(txtP5Offset);
P6Offset = FormUtil.GetIntValue(txtP6Offset);
SaveConfig(speed, position);
LastValue = IO_VALUE.LOW;
string fileName = txtFileName.Text;
string filePath = Application.StartupPath + @"\logs\" + fileName;
......
......@@ -88,5 +88,16 @@ namespace OnlineStore.Common
public static string UseBuzzer = "UseBuzzer";
public static string Shelf_Position_Config = "Shelf_Position_Config";
public static string Tool_P3_Offset = "Tool_P3_Offset";
public static string Tool_P4_Offset = "Tool_P4_Offset";
public static string Tool_P5_Offset = "Tool_P5_Offset";
public static string Tool_P6_Offset = "Tool_P6_Offset";
public static string Tool_TargetSpeed = "Tool_TargetSpeed";
public static string Tool_TargetPosition = "Tool_TargetPosition";
}
}
......@@ -136,6 +136,11 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public override bool StartRun()
{
if (!StoreManager.Store.canStart)
{
LogUtil.error(Name + "启动失败:设备未初始化完成");
return false;
}
LogInfo("开始启动,启动时间:" + StartTime.ToString());
AutoInout.StopAuto();
......
......@@ -45,7 +45,14 @@ namespace OnlineStore.DeviceLibrary
//读取RFID
RFIDData data = RFIDManager.ReadData(Config.RFID_IP);
//TODO 判断料架是否正确
if (data.RFType.Equals("A"))
{
}
else
{
LogUtil.error(Name + "读取RFID数据错误:" + data.ToStr());
}
MoveInfo.NewMove(StoreMoveType.InStore, new InOutParam());
MoveInfo.MoveParam.MoveP = new LineMoveP();
......@@ -214,7 +221,7 @@ namespace OnlineStore.DeviceLibrary
Task.Factory.StartNew(delegate
{
IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
LastScanCodes = CodeManager.CameraScan();
LastScanCodes = CodeManager.CameraScan(Config.GetCameraList());
IOMove(IO_Type.Camera_Led, IO_VALUE.LOW);
});
}
......
......@@ -32,7 +32,7 @@ namespace OnlineStore.DeviceLibrary
public bool UseBuzzer = ConfigAppSettings.GetIntValue(Setting_Init.UseBuzzer).Equals(1);
#region 初始化
private bool canStart = false;
internal bool canStart = false;
public PackingStoreBean(Store_Config lineConfig, Dictionary<int, AC_BOX_Config> configList)
{
BoxConfigMap = new Dictionary<int, AC_BOX_Config>();
......
......@@ -42,8 +42,9 @@
<Reference Include="Asa.RFID">
<HintPath>..\..\dll\RFID\Asa.RFID.dll</HintPath>
</Reference>
<Reference Include="CodeLibrary">
<HintPath>..\..\..\RC32-SZBOSCH-ACSingleStore\dll\CodeLibrary.dll</HintPath>
<Reference Include="CodeLibrary, Version=1.0.6995.29021, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\RC1250-AssemblyLine\dll\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="halcondotnet">
<HintPath>..\..\..\RC32-SZBOSCH-ACSingleStore\dll\halcondotnet.dll</HintPath>
......
......@@ -116,9 +116,7 @@ PRO,(轴二)升降轴最大限位,UpdownAxis_PositionMax,0,,,,,,,
PRO,(轴三)进出轴最大限位,InoutAxis_PositionMax,0,,,,,,,
,,,,,,,,, ,
,,,,,,,,, ,
,,,,,,,,,,
PRO,气压检测IO关闭需要持续的时间,AirCheckSeconds,3,,,,,,,
,,,,,,,,,,
PRO,预警温度,WarnTemperate,80,,,,,, ,
PRO,预警湿度,WarnHumidity,80,,,,,, ,
PRO,出入库多少次,会自动重置旋转轴,Box_ResetMCount,1000,,,,,,,
......@@ -128,7 +126,8 @@ PRO,需要吹气的温度(温度标准),Max_Temperature,0,,,,,,,
PRO,需要吹气的湿度(湿度标准),Max_Humidity,10,,,,,,,
PRO,每次吹气的时间(分钟),BlowAir_Time,10,,,,,,,
PRO,两次吹气间隔(分钟),BlowAir_Interval,10,,,,,,,
,,,,,,,,,,
PRO,温湿度端口号,Humiture_Port,COM2,,,,,,,
PRO,扫码的相机名称(多个用#分隔),CameraNameList,Name1#Name1,,,,,,,
PRO,RFID读卡器IP,RFID_IP,192.168.200.11,,,,,,,
PRO,RFID读卡器IP,RFID_IP,192.168.106.101,,,,,,,
PRO,是否是调试状态,IsInDebug,1,,,,,,,
......@@ -106,9 +106,6 @@ PRO,(轴三)进出轴停止时可误差的脉冲数的最小值,InoutAxis_ErrorCountMin,10,,,,,,,
PRO,(轴一)旋转轴停止时可误差的脉冲数的最大值,MiddleAxis_ErrorCountMax,1000,,,,,,,
PRO,(轴二)升降轴轴停止时可误差的脉冲数的最大值,UpdownAxis_ErrorCountMax,1000,,,,,,,
PRO,(轴三)进出轴停止时可误差的脉冲数的最大值,InoutAxis_ErrorCountMax,1000,,,,,,,
PRO,出入库多少次,会自动重置旋转轴,Box_ResetMCount,1000,,,,,,,
PRO,出入库多少次,会自动重置所有轴操作,Box_ResetACount,100,,,,,,,
PRO,IO信号超时时间(毫秒),IOSingle_TimerOut,10000,,,,,,,
PRO,(轴一)旋转轴最小限位,MiddleAxis_PositionMin,0,,,,,,,
PRO,(轴二)升降轴最小限位,UpdownAxis_PositionMin,0,,,,,,,
PRO,(轴三)进出轴最小限位,InoutAxis_PositionMin,0,,,,,,,
......@@ -128,7 +125,8 @@ PRO,需要吹气的湿度(湿度标准),Max_Humidity,10,,,,,,,
PRO,每次吹气的时间(分钟),BlowAir_Time,10,,,,,,,
PRO,两次吹气间隔(分钟),BlowAir_Interval,10,,,,,,,
PRO,温湿度端口号,Humiture_Port,COM2,,,,,,,
,,,,,,,,,,
PRO,扫码的相机名称(多个用#分隔),CameraNameList,Name1#Name1,,,,,
PRO,RFID读卡器IP,RFID_IP,192.168.200.11,,,,,,,
PRO,RFID读卡器IP,RFID_IP,192.168.106.102,,,,,,,
PRO,是否是调试状态,IsInDebug,1,,,,,,,
类型,说明,名称,属性值,设备名称,默认值,描述,电器定义,代码定义,SlaveID,
PRO,IO模块对应的DI数量,IO_DILength,192.168.100.30#8;192.168.100.32#8;192.168.100.34#8;192.168.100.36#8;192.168.100.38#8;,,,,,
PRO,IO模块对应的DO数量,IO_DOLength,192.168.100.30#8;192.168.100.32#8;192.168.100.34#8;192.168.100.36#8;192.168.100.38#8;,,,,,
PRO,IO模块IP,PRO_AOI_IP_1,192.168.200.11,,,,,,,
PRO,IO模块IP,PRO_AOI_IP_2,192.168.200.12,,,,,,,
PRO,IO模块IP,PRO_AOI_IP_3,192.168.200.13,,,,,,,
PRO,IO模块对应的DI数量,IO_DILength,192.168.104.21#16;192.168.104.22#16;192.168.104.23#16,,,,,
PRO,IO模块对应的DO数量,IO_DOLength,192.168.104.21#16;192.168.104.22#16;192.168.104.23#16,,,,,
PRO,第一块IO模块IP,PRO_AOI_IP_1,192.168.104.21,,,,,,,
PRO,第二块IO模块IP,PRO_AOI_IP_2,192.168.104.22,,,,,,,
PRO,第三块IO模块IP,PRO_AOI_IP_3,192.168.104.23,,,,,,,
,,,,,,,,,,
,,,,,,,,,,
DI,急停,SuddenStop_BTN,0,PRO_AOI_IP_1,0,急停,X01,DI-01,0,
......
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;
//}
}
}
......@@ -7,6 +7,7 @@ using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.DeviceLibrary
......@@ -14,9 +15,8 @@ namespace OnlineStore.DeviceLibrary
public class CodeManager
{
// public static List<string> cameraNameList = new List<string>();
public static List<string> codeTypeList = new List<string>();
public static List<string> codeTypeList = new List<string>();
public static List<string> balserNameList = new List<string>();
public static List<string> hikNameList = new List<string>();
......@@ -26,23 +26,11 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public static void LoadConfig()
{
// string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName);
string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType);
// cameraNameList = new List<string>();
codeTypeList = new List<string>();
HDLogUtil.LogName = "RollingLogFileAppender";
try
{
//string[] nameArray = nameStr.Split(spiltChar);
//foreach (string str in nameArray)
//{
// if (str.Trim().Equals(""))
// {
// continue;
// }
// //LogUtil.info("加载到配置摄像机名称:" + str.Trim());
// cameraNameList.Add(str.Trim());
//}
string[] codeArray = codeStr.Split(spiltChar);
foreach (string str in codeArray)
{
......@@ -56,7 +44,6 @@ namespace OnlineStore.DeviceLibrary
LoadCamera(false);
CodeLibrary.HDCodeLearnHelper.LoadConfig("", codeStr);
}
catch (Exception ex)
{
......@@ -69,7 +56,7 @@ namespace OnlineStore.DeviceLibrary
{
try
{
CodeLibrary.HIKCamera.Instance.Load();
CodeLibrary.HIKCManager.Load();
}
catch (Exception ex)
{
......@@ -77,14 +64,14 @@ namespace OnlineStore.DeviceLibrary
}
try
{
CodeLibrary.BaslerCamera.Instance.Load();
CodeLibrary.BaslerCManager.Load();
}
catch (Exception ex)
{
LogUtil.error("加载Basler相机出错:" + ex.ToString());
}
}
string[] names = CodeLibrary.HIKCamera.Instance.CameraName;
string[] names = CodeLibrary.HIKCManager.CameraName;
if (names != null)
......@@ -95,7 +82,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info("加载到HIK相机:" + name);
}
}
names = CodeLibrary.BaslerCamera.Instance.CameraName;
names = CodeLibrary.BaslerCManager.CameraName;
if (names != null)
{
balserNameList.AddRange(names);
......@@ -105,10 +92,23 @@ namespace OnlineStore.DeviceLibrary
}
}
}
public static void CloseCamera()
public static void CloseCamera(string name)
{
//BaslerCamera.Instance.Close();
//HIKCamera.Instance.Close();
if (HIKCManager.CameraName.Contains(name))
{
HIKCManager.Close(name);
}
else
{
BaslerCManager.Close(name);
}
}
public static void CloseAllCamera()
{
BaslerCamera.Instance.Close();
HIKCamera.Instance.Close();
HIKCManager.CloseAll();
BaslerCManager.CloseAll();
}
public static Bitmap GetCamerImage(string cameraName)
......@@ -118,13 +118,15 @@ namespace OnlineStore.DeviceLibrary
{
if (balserNameList.Contains(cameraName))
{
bool result = BaslerCamera.Instance.Open(cameraName);
bool result = true;
if (!BaslerCManager.IsOpen(cameraName))
{
result = BaslerCManager.Open(cameraName);
}
// LogUtil.info("打开相机:" + cameraName + "(" + result + ")");
if (result)
{
BaslerCamera.Instance.GrabOne();
bitm = BaslerCamera.Instance.Image;
BaslerCamera.Instance.Close();
bitm = BaslerCManager.GrabOne(cameraName);
}
else
{
......@@ -133,13 +135,16 @@ namespace OnlineStore.DeviceLibrary
}
else if (hikNameList.Contains(cameraName))
{
bool result = HIKCamera.Instance.Open(cameraName);
bool result = true;
if (!HIKCManager.IsOpen(cameraName))
{
result = HIKCManager.Open(cameraName);
}
// LogUtil.info("打开相机:" + cameraName + "(" + result + ")");
if (result)
{
HIKCamera.Instance.GrabOne();
bitm = HIKCamera.Instance.Image;
HIKCamera.Instance.Close();
bitm = HIKCManager.GrabOne(cameraName);
}
else
{
......@@ -165,25 +170,23 @@ namespace OnlineStore.DeviceLibrary
}
[HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan(List<string> cameraNameList = null)
public static List<string> CameraScan(List<string> cameraNameList)
{
List<string> codeList = new List<string>();
//List<CodeInfo> allCodeList = new List<CodeInfo>();
if (cameraNameList == null)
{
return codeList;
}
try
{
List<Task<List<CodeInfo>>> taskList = new List<Task<List<CodeInfo>>>();
foreach (string cameraName in cameraNameList)
{
Task.Factory.StartNew(delegate ()
{
using (Bitmap bitmap = GetCamerImage(cameraName))
{
if (bitmap == null)
{
LogUtil.error(" 摄像机【" + cameraName + "】获取图片失败,关闭相机");
CloseCamera();
continue;
CloseCamera(cameraName);
return;
}
LogUtil.debug(" 摄像机【" + cameraName + "】获取图片完成");
......@@ -193,15 +196,20 @@ namespace OnlineStore.DeviceLibrary
List<CodeInfo> cc = new List<CodeInfo>();
foreach (string codeType in codeTypeList)
{
//判断是否是一维码
if (codeType.ToLower().Equals("barcode"))
Task<List<CodeInfo>> typeDeCode = Task.Factory.StartNew(delegate ()
{
cc = HDCodeHelper.DecodeBarCode(ho_Image);
return DeCode(ho_Image, codeType);
});
taskList.Add(typeDeCode);
}
else
{
cc = HDCodeHelper.DecodeCode(ho_Image, 1, GetCodeParamFilePath(codeType), codeType);
}
});
}
Task.WaitAll(taskList.ToArray());
foreach (Task<List<CodeInfo>> t in taskList)
{
List<CodeInfo> cc = t.Result;
if (cc.Count > 0)
{
string r = "";
......@@ -210,9 +218,7 @@ namespace OnlineStore.DeviceLibrary
codeList.Add(c.CodeStr);
r = r + "##" + c.CodeStr;
}
LogUtil.debug(" 【" + cameraName + "】【" + codeType + "】扫码完成:"+r);
}
}
}
}
}
......@@ -228,6 +234,30 @@ namespace OnlineStore.DeviceLibrary
return codeList;
}
private static List<CodeInfo> DeCode(HalconDotNet.HObject ho_Image, string codeType)
{
List<CodeInfo> cc = new List<CodeInfo>();
//判断是否是一维码
if (codeType.ToLower().Equals("barcode"))
{
cc = HDCodeHelper.DecodeBarCode(ho_Image);
}
else
{
cc = HDCodeHelper.DecodeCode(ho_Image, 1, GetCodeParamFilePath(codeType), codeType);
}
//if (cc.Count > 0)
//{
// string r = "";
// foreach (CodeInfo c in cc)
// {
// codeList.Add(c.CodeStr);
// r = r + "##" + c.CodeStr;
// }
// LogUtil.debug(" 【" + cameraName + "】【" + codeType + "】扫码完成:" + r);
//}
return cc;
}
public static string GetCodeParamFilePath(string codePath)
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!