Commit 7cc71f8b 几米阳光

1.扫码模块修改,获取相机图片后再使用halcon扫码。

2.联电料仓修改的BUG代码合并:显示界面需要输入密码。光栅功能修改。进出轴不在待机点时旋转轴和升降轴不能运动。
1 个父辈 0b14a6da
此文件类型无法预览
此文件类型无法预览
......@@ -73,18 +73,18 @@
<Compile Include="FrmBase.Designer.cs">
<DependentUpon>FrmBase.cs</DependentUpon>
</Compile>
<Compile Include="FrmCamera.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmCamera.Designer.cs">
<DependentUpon>FrmCamera.cs</DependentUpon>
</Compile>
<Compile Include="FrmIOStatus.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmIOStatus.Designer.cs">
<DependentUpon>FrmIOStatus.cs</DependentUpon>
</Compile>
<Compile Include="FrmPwd.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmPwd.Designer.cs">
<DependentUpon>FrmPwd.cs</DependentUpon>
</Compile>
<Compile Include="FrmStoreBox.cs">
<SubType>Form</SubType>
</Compile>
......@@ -100,12 +100,12 @@
<EmbeddedResource Include="FrmBase.resx">
<DependentUpon>FrmBase.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmCamera.resx">
<DependentUpon>FrmCamera.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmIOStatus.resx">
<DependentUpon>FrmIOStatus.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmPwd.resx">
<DependentUpon>FrmPwd.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmStoreBox.resx">
<DependentUpon>FrmStoreBox.cs</DependentUpon>
</EmbeddedResource>
......
......@@ -31,6 +31,8 @@
<!--二维码参数文件所在路径,文件名与二维码类型名一样-->
<add key="CodeParamPath" value="\CodeParam\" />
<add key ="AI_ConvertPosition" value ="55"/>
<add key ="InOutDefaultPosition" value ="3000"/>
<add key ="Config_Pwd" value ="123456"/>
</appSettings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
......
......@@ -51,9 +51,31 @@ namespace OnlineStore.ACSingleStore
txtComSpeed.Text = ACStoreManager.store.Config.CompressAxis_EndSpeed.ToString();
timer1.Start();
}
/// <summary>
/// 判断进出轴是否在P1点
/// </summary>
private bool InOutIsIsP1()
{
int InOutDefaultPosition = ConfigAppSettings.GetIntValue(Setting_Init.InOutDefaultPosition);
if (InOutDefaultPosition > 3000 || InOutDefaultPosition.Equals(0))
{
InOutDefaultPosition = 3000;
}
int currValue = ACServerManager.GetActualtPosition(inout.DeviceName, inout.GetAxisValue());
if (currValue <= InOutDefaultPosition)
{
return true;
}
MessageBox.Show("叉子不在待机位,请先将叉子退回待机位!", "警告(叉子在待机位时,才能移动升降轴和旋转轴) ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return false;
}
private void btnMiddleMove_MouseDown(object sender, MouseEventArgs e)
{
if (!InOutIsIsP1())
{
return;
}
if (btnMiddleMove.BackColor.Equals(System.Drawing.SystemColors.Control))
{
int speed = FormUtil.GetIntValue(txtMiddleSpeed);
......@@ -79,6 +101,10 @@ namespace OnlineStore.ACSingleStore
private void btnUpDownMove_MouseDown(object sender, MouseEventArgs e)
{
if (!InOutIsIsP1())
{
return;
}
if (btnUpDownMove.BackColor.Equals(System.Drawing.SystemColors.Control))
{
int speed = FormUtil.GetIntValue(txtUpDownSpeed);
......@@ -133,6 +159,10 @@ namespace OnlineStore.ACSingleStore
}
private void btnMiddleMovej_MouseDown(object sender, MouseEventArgs e)
{
if (!InOutIsIsP1())
{
return;
}
if (btnMiddleMovej.BackColor.Equals(System.Drawing.SystemColors.Control))
{
int speed = FormUtil.GetIntValue(txtMiddleSpeed);
......@@ -158,6 +188,10 @@ namespace OnlineStore.ACSingleStore
private void btnUpDownMovej_MouseDown(object sender, MouseEventArgs e)
{
if (!InOutIsIsP1())
{
return;
}
if (btnUpDownMovej.BackColor .Equals( System.Drawing.SystemColors.Control))
{
int speed = FormUtil.GetIntValue(txtUpDownSpeed);
......
namespace OnlineStore.ACSingleStore
{
partial class FrmPwd
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.btnNext = new System.Windows.Forms.Button();
this.btnBack = new System.Windows.Forms.Button();
this.txtPwd = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(153, 61);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(126, 25);
this.label1.TabIndex = 0;
this.label1.Text = "请输入密码:";
//
// btnNext
//
this.btnNext.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.btnNext.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnNext.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnNext.Location = new System.Drawing.Point(221, 163);
this.btnNext.Name = "btnNext";
this.btnNext.Size = new System.Drawing.Size(120, 45);
this.btnNext.TabIndex = 275;
this.btnNext.Text = "确定";
this.btnNext.UseVisualStyleBackColor = false;
this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
//
// btnBack
//
this.btnBack.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.btnBack.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnBack.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnBack.Location = new System.Drawing.Point(95, 163);
this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(120, 45);
this.btnBack.TabIndex = 274;
this.btnBack.Text = "返回";
this.btnBack.UseVisualStyleBackColor = false;
this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
//
// txtPwd
//
this.txtPwd.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtPwd.Location = new System.Drawing.Point(112, 97);
this.txtPwd.Name = "txtPwd";
this.txtPwd.PasswordChar = '*';
this.txtPwd.Size = new System.Drawing.Size(215, 33);
this.txtPwd.TabIndex = 276;
this.txtPwd.Text = "123456";
this.txtPwd.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtPwd_KeyDown);
//
// FrmPwd
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(437, 268);
this.Controls.Add(this.txtPwd);
this.Controls.Add(this.btnNext);
this.Controls.Add(this.btnBack);
this.Controls.Add(this.label1);
this.Name = "FrmPwd";
this.Text = "请输入密码";
this.Load += new System.EventHandler(this.FrmPwd_Load);
this.Shown += new System.EventHandler(this.FrmPwd_Shown);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FrmPwd_KeyDown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnNext;
private System.Windows.Forms.Button btnBack;
private System.Windows.Forms.TextBox txtPwd;
}
}
\ No newline at end of file

using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.ACSingleStore
{
public partial class FrmPwd : FrmBase
{
public delegate void PwdOK(int type);
public event PwdOK PwdOKFun;
private int OpenType = 0;
public FrmPwd(int type)
{
OpenType = type;
InitializeComponent();
}
private void FrmPwd_Load(object sender, EventArgs e)
{
this.DialogResult = DialogResult.None;
}
private void btnNext_Click(object sender, EventArgs e)
{
string pwd = txtPwd.Text;
string configPwd = ConfigAppSettings.GetValue(Setting_Init.Config_Pwd);
if (configPwd.Equals(""))
{
configPwd = "123456";
ConfigAppSettings.SaveValue(Setting_Init.Config_Pwd,configPwd);
}
if (pwd.Equals(configPwd))
{
this.DialogResult = DialogResult.OK;
//if (OpenType.Equals(1))
//{
// FrmDebugMenu main = new FrmDebugMenu();
// main.ShowDialog();
//}
//else if (OpenType.Equals(2))
//{
// FrmProgramList board = new FrmProgramList();
// board.ShowDialog();
//}
//else if (OpenType.Equals(3))
//{
// FrmBoardList board = new FrmBoardList();
// board.ShowDialog();
//}
PwdOKFun?.Invoke(OpenType);
this.DialogResult = DialogResult.OK;
this.Close();
}
else
{
// this.DialogResult = DialogResult.No;
MessageBox.Show("请输入正确的密码");
txtPwd.Focus();
}
}
private void btnBack_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private void FrmPwd_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode.Equals(Keys.Enter))
{
btnNext_Click(null, null);
}
}
private void txtPwd_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode.Equals(Keys.Enter))
{
btnNext_Click(null, null);
}else if (e.KeyCode.Equals(Keys.Escape))
{
btnBack_Click(null, null);
}
}
private void FrmPwd_Shown(object sender, EventArgs e)
{
txtPwd.Focus();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
......@@ -162,7 +162,6 @@
this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
this.摄像机调试ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator11 = 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.日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
......@@ -220,6 +219,7 @@
this.lblWarnMsg.Size = new System.Drawing.Size(462, 40);
this.lblWarnMsg.TabIndex = 224;
this.lblWarnMsg.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.lblWarnMsg.Click += new System.EventHandler(this.lblWarnMsg_Click);
//
// groupBox5
//
......@@ -1821,8 +1821,7 @@
this.扫码测试ToolStripMenuItem,
this.toolStripSeparator10,
this.摄像机调试ToolStripMenuItem,
this.toolStripSeparator11,
this.学习二维码ToolStripMenuItem});
this.toolStripSeparator11});
this.设备调试ToolStripMenuItem.Name = "设备调试ToolStripMenuItem";
this.设备调试ToolStripMenuItem.Size = new System.Drawing.Size(86, 25);
this.设备调试ToolStripMenuItem.Text = "设备调试";
......@@ -1830,45 +1829,38 @@
// 轴卡点动ToolStripMenuItem
//
this.轴卡点动ToolStripMenuItem.Name = "轴卡点动ToolStripMenuItem";
this.轴卡点动ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
this.轴卡点动ToolStripMenuItem.Size = new System.Drawing.Size(192, 26);
this.轴卡点动ToolStripMenuItem.Text = "轴卡点动";
this.轴卡点动ToolStripMenuItem.Click += new System.EventHandler(this.轴卡点动ToolStripMenuItem_Click);
//
// toolStripSeparator9
//
this.toolStripSeparator9.Name = "toolStripSeparator9";
this.toolStripSeparator9.Size = new System.Drawing.Size(157, 6);
this.toolStripSeparator9.Size = new System.Drawing.Size(189, 6);
//
// 扫码测试ToolStripMenuItem
//
this.扫码测试ToolStripMenuItem.Name = "扫码测试ToolStripMenuItem";
this.扫码测试ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
this.扫码测试ToolStripMenuItem.Size = new System.Drawing.Size(192, 26);
this.扫码测试ToolStripMenuItem.Text = "扫码测试";
this.扫码测试ToolStripMenuItem.Click += new System.EventHandler(this.扫码测试ToolStripMenuItem_Click);
//
// toolStripSeparator10
//
this.toolStripSeparator10.Name = "toolStripSeparator10";
this.toolStripSeparator10.Size = new System.Drawing.Size(157, 6);
this.toolStripSeparator10.Size = new System.Drawing.Size(189, 6);
//
// 摄像机调试ToolStripMenuItem
//
this.摄像机调试ToolStripMenuItem.Name = "摄像机调试ToolStripMenuItem";
this.摄像机调试ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
this.摄像机调试ToolStripMenuItem.Text = "摄像机调试";
this.摄像机调试ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.摄像机调试ToolStripMenuItem.Text = "二维码学习";
this.摄像机调试ToolStripMenuItem.Click += new System.EventHandler(this.摄像机调试ToolStripMenuItem_Click);
//
// toolStripSeparator11
//
this.toolStripSeparator11.Name = "toolStripSeparator11";
this.toolStripSeparator11.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);
this.toolStripSeparator11.Size = new System.Drawing.Size(189, 6);
//
// 配置信息ToolStripMenuItem
//
......@@ -2003,9 +1995,9 @@
this.groupBox4.Controls.Add(this.label25);
this.groupBox4.Controls.Add(this.comboBoxPortName);
this.groupBox4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox4.Location = new System.Drawing.Point(510, 563);
this.groupBox4.Location = new System.Drawing.Point(510, 562);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(512, 187);
this.groupBox4.Size = new System.Drawing.Size(512, 160);
this.groupBox4.TabIndex = 271;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "压紧轴";
......@@ -2380,7 +2372,6 @@
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ToolStripMenuItem 退出ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 摄像机调试ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 学习二维码ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
......
......@@ -515,6 +515,13 @@ namespace OnlineStore.ACSingleStore
MessageBox.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else if (portName.Equals(store.Config.Middle_Axis.DeviceName) || portName.Equals(store.Config.UpDown_Axis.DeviceName))
{
if (!InOutIsIsP1())
{
return;
}
}
LogUtil.info("点击【绝对运动】,端口号【"+ portName + "】地址【" + SlvAddr + "】位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed );
}
......@@ -529,6 +536,13 @@ namespace OnlineStore.ACSingleStore
MessageBox.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else if (portName.Equals(store.Config.Middle_Axis.DeviceName) || portName.Equals(store.Config.UpDown_Axis.DeviceName))
{
if (!InOutIsIsP1())
{
return;
}
}
LogUtil.info("点击【匀速运动】,端口号【" + portName + "】地址【" + SlvAddr + "】 速度【" + speed + "】");
ACServerManager.SpeedMove(portName, SlvAddr, speed);
}
......@@ -553,6 +567,13 @@ namespace OnlineStore.ACSingleStore
MessageBox.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else if (portName.Equals(store.Config.Middle_Axis.DeviceName) || portName.Equals(store.Config.UpDown_Axis.DeviceName))
{
if (!InOutIsIsP1())
{
return;
}
}
LogUtil.info("点击【相对运动】,端口号【" + portName + "】地址【" + SlvAddr + "】位置【" + position + "】速度【" + speed + "】");
ACServerManager.RelMove(portName, SlvAddr, position, speed);
}
......@@ -688,7 +709,24 @@ namespace OnlineStore.ACSingleStore
Thread.Sleep(100);
ACServerManager.ServoOn(portName, SlvAddr);
}
/// <summary>
/// 判断进出轴是否在P1点
/// </summary>
private bool InOutIsIsP1()
{
int InOutDefaultPosition = ConfigAppSettings.GetIntValue(Setting_Init.InOutDefaultPosition);
if (InOutDefaultPosition > 3000 || InOutDefaultPosition.Equals(0))
{
InOutDefaultPosition = 3000;
}
int currValue = ACServerManager.GetActualtPosition(store.Config.InOut_Axis.DeviceName, store.Config.InOut_Axis.GetAxisValue());
if (currValue <= InOutDefaultPosition)
{
return true;
}
MessageBox.Show("叉子不在待机位,请先将叉子退回待机位!", "警告(叉子在待机位时,才能移动升降轴和旋转轴) ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return false;
}
private void btnCloseAxis_Click(object sender, EventArgs e)
{
string portName = txtAxisDeviceName.Text;
......@@ -703,64 +741,92 @@ namespace OnlineStore.ACSingleStore
}
private void btnUpDownP1_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtUpDownP1);
AxisABSMove(store.Config.UpDown_Axis, value, store.Config.UpDownAxis_P1_Speed);
}
}
private void btnUpDownP2_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtUpDownP2);
AxisABSMove(store.Config.UpDown_Axis, value, store.Config.UpDownAxis_P2_Speed);
}
}
private void btnUpDownP7_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtUpDownP7);
AxisABSMove(store.Config.UpDown_Axis, value, store.Config.UpDownAxis_P7_Speed);
}
}
private void btnUpDownP8_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtUpDownP8);
AxisABSMove(store.Config.UpDown_Axis, value, store.Config.UpDownAxis_P8_Speed);
}
}
private void btnUpDownP3_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtUpDownP3);
AxisABSMove(store.Config.UpDown_Axis, value, store.Config.UpDownAxis_P3_Speed);
}
}
private void btnUpDownP4_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtUpDownP4);
AxisABSMove(store.Config.UpDown_Axis, value, store.Config.UpDownAxis_P4_Speed);
}
}
private void btnUpDownP5_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtUpDownP5);
AxisABSMove(store.Config.UpDown_Axis, value, store.Config.UpDownAxis_P5_Speed);
}
}
private void btnUpDownP6_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtUpDownP6);
AxisABSMove(store.Config.UpDown_Axis, value, store.Config.UpDownAxis_P6_Speed);
}
}
private void btnMiddleP1_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtMiddleP1);
AxisABSMove(store.Config.Middle_Axis, value, store.Config.MiddleAxis_P1_Speed);
}
}
private void btnMiddleP2_Click(object sender, EventArgs e)
{
if (InOutIsIsP1())
{
int value = FormUtil.GetIntValue(txtMiddleP2);
AxisABSMove(store.Config.Middle_Axis, value, store.Config.MiddleAxis_P2_Speed);
}
}
private void btnInOutP1_Click(object sender, EventArgs e)
{
......@@ -933,11 +999,16 @@ namespace OnlineStore.ACSingleStore
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string message = "";
string outMsg = "";
List<string> codeList = HDevelopExport.CameraScan(out outMsg);
//List<string> codeList = HDevelopExport.CameraScan(out outMsg);
//foreach (string str in codeList)
//{
// string code = HDevelopExport.SubStrCode(str);
// message = message + code + "##";
//}
List<string> codeList = CodeManager.CameraScan();
foreach (string str in codeList)
{
string code = HDevelopExport.SubStrCode(str);
message = message + code + "##";
message = message + str + "##";
}
LogUtil.info("扫码测试收到二维码【"+outMsg+"】:" + message);
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
......@@ -1101,6 +1172,19 @@ namespace OnlineStore.ACSingleStore
{
string portName = txtAxisDeviceName.Text;
short SlvAddr = FormUtil.GetShortValue(txtAxisValue);
if (portName.Equals(store.Config.InOut_Axis.DeviceName) && (store.InOutAxisCanMove().Equals(false)))
{
MessageBox.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else if (portName.Equals(store.Config.Middle_Axis.DeviceName) || portName.Equals(store.Config.UpDown_Axis.DeviceName))
{
if (!InOutIsIsP1())
{
return;
}
}
int speed = FormUtil.GetIntValue(txtASpeed);
LogUtil.info("点击【原点返回】,端口号【" + portName + "】地址【" + SlvAddr + "】 速度【" + speed + "】");
ACServerManager.HomeMove(portName, SlvAddr, speed);
......@@ -1159,6 +1243,13 @@ namespace OnlineStore.ACSingleStore
private void 显示ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmPwd fw = new FrmPwd(10);
DialogResult result = fw.ShowDialog();
if (!result.Equals(DialogResult.OK))
{
LogUtil.info("切换界面显示时,没有正确输入密码");
return;
}
this.Visible = true;
this.WindowState = FormWindowState.Maximized;
this.notifyIcon1.Visible = false;
......@@ -1223,8 +1314,10 @@ namespace OnlineStore.ACSingleStore
private void 摄像机调试ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmCamera frm = new FrmCamera(store);
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
CodeLibrary.FrmCodeDecode frm = new FrmCodeDecode( );
frm.ShowDialog();
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
}
private void 学习二维码ToolStripMenuItem_Click(object sender, EventArgs e)
......@@ -1309,5 +1402,10 @@ namespace OnlineStore.ACSingleStore
{
}
private void lblWarnMsg_Click(object sender, EventArgs e)
{
}
}
}
120181022新建分支RC26-LDACSingleStore联电料仓

120181022新建分支RC26-LDACSingleStore联电料仓
需要修改内容:
1.使用硕科步进电机作为压紧轴
2.温湿度修改为com通信
......@@ -24,6 +26,11 @@
//机器设备故障(非温湿度)报警 亮 灭 闪
20181123:
1.扫码模块修改,获取相机图片后再使用halcon扫码。
2.联电料仓修改的BUG代码合并:显示界面需要输入密码。光栅功能修改。进出轴不在待机点时旋转轴和升降轴不能运动。
......
......@@ -65,5 +65,11 @@ namespace OnlineStore.Common
/// 高度传感器转换系数
/// </summary>
public static string AI_ConvertPosition = "AI_ConvertPosition";
/// <summary>
/// 进出轴最大待机点,需要小于3000
/// </summary>
public static string InOutDefaultPosition = "InOutDefaultPosition";
public static string Config_Pwd = "Config_Pwd";
}
}
......@@ -59,7 +59,7 @@
<Compile Include="acSingleStore\AC_SA_BoxBean.cs" />
<Compile Include="acSingleStore\AC_SA_BoxBean_Partial.cs" />
<Compile Include="acSingleStore\ACStoreManager.cs" />
<Compile Include="halcon\HDevelopExport.cs" />
<Compile Include="halcon\CodeManager.cs" />
<Compile Include="KangNaiDe\AITcpClient.cs" />
<Compile Include="KangNaiDe\KNDAIManager.cs" />
<Compile Include="KangNaiDe\KNDManager.cs" />
......
......@@ -210,7 +210,7 @@ namespace OnlineStore.DeviceLibrary
return;
}
byte[] returnData = SendCommand(portName, data, 50, 8);
if (returnData!=null)
if (returnData != null)
{
string strSend = "";
for (int i = 0; i < returnData.Length; i++)
......@@ -231,6 +231,10 @@ namespace OnlineStore.DeviceLibrary
/// <returns>返回值的长度</returns>
public static byte[] SendCommand(string portName, byte[] data, int outTime, int reviceLength)
{
if (outTime > 80)
{
outTime = 80;
}
byte[] returnData = null;
try
......
......@@ -181,11 +181,13 @@ namespace OnlineStore.DeviceLibrary
#region 流水线逻辑判断
public static bool IsMoveEnd(int slvAddr,DateTime time)
public static bool IsMoveEnd(int slvAddr,DateTime time, out ShuoKeInfo shuokeInfo)
{
shuokeInfo = null;
if (shuokeMap.ContainsKey(slvAddr))
{
ShuoKeInfo info = shuokeMap[slvAddr];
shuokeInfo = info;
if (info.IsInMove == 0 && info.UpdateTime > time)
{
return true;
......@@ -193,11 +195,13 @@ namespace OnlineStore.DeviceLibrary
}
return false;
}
public static bool IsHomeMoveEnd(int slvAddr, DateTime time)
public static bool IsHomeMoveEnd(int slvAddr, DateTime time,out ShuoKeInfo shuokeInfo)
{
shuokeInfo = null;
if (shuokeMap.ContainsKey(slvAddr))
{
ShuoKeInfo info = shuokeMap[slvAddr];
shuokeInfo = info;
if (info.IsInMove == 0 && info.UpdateTime > time&&info.Org==0)
{
return true;
......@@ -487,5 +491,10 @@ namespace OnlineStore.DeviceLibrary
public int En { get; set; }
public DateTime UpdateTime { get; set; }
public string ToShowStr()
{
return "运动[" + IsInMove + "]左限位[" + LLimit + "]右限位[" + RLimit + "]原点[" + Org + "]使能[" + En + "]["+UpdateTime.ToShortTimeString()+"]";
}
}
}
......@@ -3,6 +3,7 @@ using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
......@@ -88,7 +89,7 @@ namespace OnlineStore.DeviceLibrary
//初始化摄像机配置
string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName);
string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType);
HDevelopExport.LoadConfig(nameStr,codeStr);
CodeManager.LoadConfig(nameStr,codeStr);
//初始化 //连接设备
KNDManager.ConnectionKND(Config.DIODeviceNameList);
......@@ -189,10 +190,10 @@ namespace OnlineStore.DeviceLibrary
//启动温湿度服务器
//HumitureServer.StartTemperateServer(Config.TemperateServer_Port);
HumitureController.Init(Config.Humiture_Port);
Task.Factory.StartNew(delegate ()
{
HDevelopExport.OpenAllCamera();
});
//Task.Factory.StartNew(delegate ()
//{
// HDevelopExport.OpenAllCamera();
//});
ReturnHome();
StartTime = DateTime.Now;
mainTimer.Enabled = true;
......@@ -281,10 +282,10 @@ namespace OnlineStore.DeviceLibrary
autoNext = false;
}
Task.Factory.StartNew(delegate ()
{
HDevelopExport.OpenAllCamera();
});
//Task.Factory.StartNew(delegate ()
//{
// HDevelopExport.OpenAllCamera();
//});
ACServerManager.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
......@@ -677,7 +678,7 @@ namespace OnlineStore.DeviceLibrary
{
ShuoKeControls.ClosePort();
}
HDevelopExport.CloseAllCamera();
//HDevelopExport.CloseAllCamera();
HumitureServer.StopTemperateServer();
LogUtil.info(LOGGER, StoreName + ",停止运行,总运行时间:" + span.ToString());
......@@ -725,27 +726,29 @@ namespace OnlineStore.DeviceLibrary
//}
}
private bool InProcess = false;
private DateTime preProcessTime = DateTime.Now;
//private DateTime preProcessTime = DateTime.Now;
private bool IsChongfu = false;
private Stopwatch stopwatch = new Stopwatch();
protected override void timersTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (InProcess)
{
TimeSpan span = DateTime.Now - preProcessTime;
if (span.TotalMinutes < 1)
//TimeSpan span = DateTime.Now - preProcessTime;
if (stopwatch.Elapsed.TotalMinutes < 1)
{
return;
}
else
{
LogUtil.error("主定时器:InProcess已等待" + span.ToString() + "重新处理");
LogUtil.error("主定时器:InProcess已等待" + stopwatch.Elapsed.ToString() + "重新处理");
IsChongfu = true;
}
}
try
{
InProcess = true;
preProcessTime = DateTime.Now;
//preProcessTime = DateTime.Now;
stopwatch.Restart();
IoCheckProcess();
ShowTimeLog("IoCheckProcess");
TimerProcess();
......@@ -769,7 +772,7 @@ namespace OnlineStore.DeviceLibrary
{
if (IsChongfu)
{
LogUtil.info("【" + info + "】 处理完成,耗时:" + (DateTime.Now - preProcessTime).ToString());
LogUtil.info("【" + info + "】 处理完成,耗时:" + stopwatch.Elapsed.ToString());
}
}
//private void LedProcess()
......@@ -1002,32 +1005,59 @@ namespace OnlineStore.DeviceLibrary
//}
}
private int NeedCheckSafetyLight = 0;
private object safetyInProcess="";
/// <summary>
/// 光栅处理
/// </summary>
private void SafetyLightProcess()
{
if (Monitor.TryEnter(safetyInProcess))
{
try
{
//遮挡光栅信号
if (KNDIOValue(IO_Type.SafetyLightCurtains).Equals(IO_VALUE.LOW))
{
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore)&&StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor))
{
if (NeedCheckSafetyLight.Equals(1))
{
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor))
{
NeedCheckSafetyLight = 2;
LOGGER.Info("出库SO_10_DeviceToDoor运动中,光栅被遮挡,停止进出轴运动");
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
}
else if (StoreMove.MoveType.Equals(StoreMoveType.InStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SI_05_DeviceToDoor))
{
NeedCheckSafetyLight = 2;
LOGGER.Info("入库SI_05_DeviceToDoor运动中,光栅被遮挡,停止进出轴运动");
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
}
}
}
else
{
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor))
{
if (NeedCheckSafetyLight.Equals(2))
{
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor))
{
LOGGER.Info("出库SO_10_DeviceToDoor运动中,光栅已恢复,继续进出轴运动");
SO_10_DeviceToDoorPro();
}
else if (StoreMove.MoveType.Equals(StoreMoveType.InStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SI_05_DeviceToDoor))
{
LOGGER.Info("入库SI_05_DeviceToDoor运动中,光栅已恢复,继续进出轴运动");
SI_05_DeviceToDoor();
}
}
}
}
catch (Exception ex)
{
LogUtil.error("光栅处理出错:" + ex.ToString());
}
finally
{
Monitor.Exit(safetyInProcess);
}
}
}
......@@ -1221,7 +1251,7 @@ namespace OnlineStore.DeviceLibrary
//在回原点,复位,出入库时,检测报警间隔减小
if (storeRunStatus.Equals(StoreRunStatus.Busy) || storeRunStatus.Equals(StoreRunStatus.HomeMoving) || storeRunStatus.Equals(StoreRunStatus.Reset))
{
if (span.TotalSeconds < 0.5)
if (span.TotalSeconds < 1)
{
return false;
}
......@@ -1296,7 +1326,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "StopMove");
KNDIOMove(IO_Type.Door_Down, IO_VALUE.LOW);
KNDIOMove(IO_Type.Door_Up, IO_VALUE.LOW);
HDevelopExport.CloseAllCamera();
//HDevelopExport.CloseAllCamera();
isInPro = false;
}
......@@ -1456,14 +1486,20 @@ namespace OnlineStore.DeviceLibrary
KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string outMsg = "";
string message = "";
List<string> codeList = HDevelopExport.CameraScan(out outMsg);
//List<string> codeList = HDevelopExport.CameraScan(out outMsg);
////= 1 + 123.4x100.5 - 7x12 = CODE
//foreach (string str in codeList)
//{
// string code = HDevelopExport.SubStrCode(str);
// code = "=1+0x0-7x" + height + " =" + code;
// message = message + code + spiltStr;
//}
//= 1 + 123.4x100.5 - 7x12 = CODE
List<string> codeList = CodeManager.CameraScan();
foreach (string str in codeList)
{
string code = HDevelopExport.SubStrCode(str);
code = "=1+0x0-7x" + height + " =" + code;
message = message + code + spiltStr;
message = message + "=1+0x0-7x" + height + " =" + str + spiltStr;
}
if (!outMsg.Equals(""))
{
......
......@@ -173,16 +173,25 @@ namespace OnlineStore.DeviceLibrary
}
else if (wait.WaitType == 5)
{
ShuoKeInfo info = null;
if (wait.IsHomeMove)
{
wait.IsEnd = ShuoKeControls.IsHomeMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime);
wait.IsEnd = ShuoKeControls.IsHomeMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime,out info);
}
else
{
wait.IsEnd = ShuoKeControls.IsMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime);
wait.IsEnd = ShuoKeControls.IsMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime, out info);
}
if (!wait.IsEnd)
{
if (info == null) {
NotOkMsg += "info=null;";
} else
{
NotOkMsg += "" +info.ToShowStr();
}
ShuoKeControls.GetStatus(wait.SlvAddr);
}
}
......@@ -297,6 +306,13 @@ namespace OnlineStore.DeviceLibrary
OpenDoorAndWait();
InOutBackToP1(moveP.InOut_P1);
}
private void SI_05_DeviceToDoor()
{
InStoreLog("入库:SI_05 叉子进入入料口,进出轴至P2(进料口取料点) ");
StoreMove.NextMoveStep(StoreMoveStep.SI_05_DeviceToDoor);
ACAxisMove(Config.InOut_Axis, StoreMove.MoveParam.MoveP.InOut_P2, Config.InOutAxis_P2_Speed);
NeedCheckSafetyLight = 1;
}
protected override void InStoreProcess()
{
LineMoveP moveP = StoreMove.MoveParam.MoveP;
......@@ -350,19 +366,19 @@ namespace OnlineStore.DeviceLibrary
}
else
{
InStoreLog("入库:SI_05 叉子进入入料口,进出轴至P2(进料口取料点) ");
StoreMove.NextMoveStep(StoreMoveStep.SI_05_DeviceToDoor);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
SI_05_DeviceToDoor();
}
}
else if (StoreMove.MoveStep == StoreMoveStep.SI_04_CompressWare)
{
InStoreLog("入库:SI_05 叉子进入入料口,进出轴至P2(进料口取料点) ");
StoreMove.NextMoveStep(StoreMoveStep.SI_05_DeviceToDoor);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
//InStoreLog("入库:SI_05 叉子进入入料口,进出轴至P2(进料口取料点) ");
//StoreMove.NextMoveStep(StoreMoveStep.SI_05_DeviceToDoor);
//ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
SI_05_DeviceToDoor();
}
else if (StoreMove.MoveStep == StoreMoveStep.SI_05_DeviceToDoor)
{
NeedCheckSafetyLight = 0;
InStoreLog("入库:SI_06 拿物品,压紧轴至P2(压紧点)) 升降轴至P7(进料口取料缓冲点) ");
StoreMove.NextMoveStep(StoreMoveStep.SI_06_DoorWarToDevice);
ComMoveToPosition(moveP.ComPress_P2);
......@@ -661,7 +677,7 @@ namespace OnlineStore.DeviceLibrary
{
OutStoreLog("出库:SO_11 放下物品,升降轴至P8(进料口出料缓冲点) ");
StoreMove.NextMoveStep(StoreMoveStep.SO_11_DevicePutWare);
NeedCheckSafetyLight = 0;
ComMoveToPosition(moveP.ComPress_P1);
//if (IsHasCompress_Axis)
//{
......
using CodeLibrary;
using HalconDotNet;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
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> balserNameList = new List<string>();
public static List<string> hikNameList = new List<string>();
private static char spiltChar = '#';
/// <summary>
/// 初始化摄像机名称和二维码类型
/// </summary>
/// <param name="nameStr">摄像机名称,多个用#分割</param>
/// <param name="codeStr">二维码类型,多个用#分割</param>
public static void LoadConfig(string nameStr, string codeStr)
{
cameraNameList = new List<string>();
codeTypeList = new List<string>();
try
{
string[] nameArray = nameStr.Split(spiltChar);
foreach (string str in nameArray)
{
LogUtil.info("加载到配置摄像机名称:" + str.Trim());
cameraNameList.Add(str.Trim());
}
string[] codeArray = codeStr.Split(spiltChar);
foreach (string str in codeArray)
{
LogUtil.info("加载到二维码类型:" + str.Trim());
codeTypeList.Add(str.Trim());
}
string[] names = CodeLibrary.HIKCamera.Instance.CameraName;
hikNameList.AddRange(names);
names = CodeLibrary.BaslerCamera.Instance.CameraName;
balserNameList.AddRange(names);
CodeLibrary.HDCodeLearnHelper.LoadConfig(nameStr, codeStr);
}
catch (Exception ex)
{
LogUtil.error("解析摄像机配置出错:" + ex.ToString());
}
}
public static Bitmap GetCamerImage(string cameraName)
{
Bitmap bitm = null;
if (balserNameList.Contains(cameraName))
{
BaslerCamera.Instance.Open(cameraName);
BaslerCamera.Instance.GrabOne();
bitm = BaslerCamera.Instance.Image;
BaslerCamera.Instance.Close();
}
else if(hikNameList.Contains(cameraName))
{
HIKCamera.Instance.Open(cameraName);
HIKCamera.Instance.GrabOne();
bitm = HIKCamera.Instance.Image;
HIKCamera.Instance.Close();
}
else
{
LogUtil.info("未找到摄像机【"+cameraName+"】无法获取图片");
}
return bitm;
}
public static List<string> CameraScan( )
{
List<string> codeList = new List<string>();
List<CodeInfo> allCodeList = new List<CodeInfo>();
try
{
foreach (string cameraName in cameraNameList)
{
Bitmap bitmap = GetCamerImage(cameraName);
if (bitmap == null)
{
LogUtil.info(" 摄像机【" + cameraName + "】获取图片失败");
}
else
{
HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
List<CodeInfo> cc = new List<CodeInfo>();
foreach (string codeType in codeTypeList)
{
cc = HDCodeHelper.DecodeCode(ho_Image, 1, GetCodeParamFilePath(codeType), codeType);
}
allCodeList.AddRange(cc);
}
}
}
catch (Exception ex)
{
LogUtil.error("扫码出错:" + ex.ToString());
}
foreach(CodeInfo info in allCodeList)
{
codeList.Add(info.CodeStr);
}
return codeList;
}
public static string GetCodeParamFilePath(string codePath)
{
string appPath = Application.StartupPath;
string path = appPath + ConfigAppSettings.GetValue(Setting_Init.CodeParamPath);
string filePath = path + codePath + ".dcm";
if (File.Exists(filePath))
{
return filePath;
}
else
{
return "";
}
}
}
}
......@@ -44,6 +44,8 @@ namespace OnlineStore.DeviceLibrary
/// 是否没有检测到气压
/// </summary>
public bool isNoAirCheck = false;
protected int NeedCheckSafetyLight = 0;
/// <summary>
/// 是否再报警中
/// </summary>
......@@ -93,33 +95,6 @@ namespace OnlineStore.DeviceLibrary
return new TimeSpan(0);
}
}
///// <summary>
///// 获取轴已运行时间
///// </summary>
///// <returns></returns>
//public TimeSpan GetAxisRunTime(int axisNo)
//{
// TimeSpan span = new TimeSpan(0);
// try
// {
// if (AxisRunTimeMap.ContainsKey(axisNo))
// {
// Dictionary<DateTime, DateTime> moveMap = AxisRunTimeMap[axisNo];
// if (moveMap != null && moveMap.Count > 0)
// {
// foreach (DateTime key in moveMap.Keys)
// {
// span += moveMap[key] - key;
// }
// }
// }
// }
// catch (Exception ex)
// {
// LogUtil.error(LOGGER, ex.ToString());
// }
// return span;
//}
protected void AddAxisMoveTime(ConfigMoveAxis axis)
{
......@@ -276,18 +251,36 @@ namespace OnlineStore.DeviceLibrary
string deviceName = moveAxis.DeviceName;
short axisNo = moveAxis.GetAxisValue();
bool isOk = ACServerManager.GetBusyStatus(deviceName, axisNo).Equals(0);
//如果是进出轴,并且光栅被遮挡,直接返回false
if (NeedCheckSafetyLight.Equals(2))
{
if (StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor) ||
StoreMove.MoveStep.Equals(StoreMoveStep.SI_05_DeviceToDoor))
{
return false;
}
}
bool isOk = ACServerManager.GetBusyStatus(deviceName, axisNo).Equals(0);
int outCount = ACServerManager.GetActualtPosition(deviceName, axisNo);
int errorCount = Math.Abs(outCount - targetPosition);
if (isOk)
{
if (errorCount > moveAxis.CanErrorCountMax)
{
if (NeedCheckSafetyLight.Equals(2))
{
if (StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor) ||
StoreMove.MoveStep.Equals(StoreMoveStep.SI_05_DeviceToDoor))
{
return false;
}
}
//判断是否需要重新运动
if (StoreMove.CanWhileCount > 0)
{
LogUtil.error(LOGGER, moveAxis.DisplayStr+ "目标位置[" + targetPosition + "]当前位置[" + outCount +
LogUtil.error(LOGGER, moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount +
"],误差过大,重新开始运动,剩余[" + StoreMove.CanWhileCount + "]次");
//LogUtil.error(LOGGER, StoreName + " storeMoveStep=" + StoreMove.MoveStep + moveAxis.DisplayStr + "目标位置[" + targetPosition + "]重新开始运动");
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!