Commit bb5a8e0d 刘韬

添加项目文件。

1 个父辈 5d428bc4
正在显示 80 个修改的文件 包含 13050 行增加0 行删除
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<appSettings>
<!--是否开机自动启动料仓-->
<add key="App_AutoRun" value="1" />
<add key="CameraName" value="GigE:acA3800-10gc (23124327)#" />
<add key="Config_Pwd" value="123456" />
</appSettings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs/AutoScanAndLabel.log" />
<param name="Encoding" value="UTF-8" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" />
</layout>
</appender>
<logger name="RollingLogFileAppender">
<level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
</logger>
<logger name="HCBOARD">
<level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
</logger>
<!--<root>
<level value="Info" />
<appender-ref ref="RollingLogFileAppender" />
</root>-->
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{61FDFF14-8BB7-439A-85A0-592E3011F4C4}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>AutoScanAndLabel</RootNamespace>
<AssemblyName>AutoScanAndLabel</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\增广夹爪\Rmaxis\bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="UserFromControl">
<HintPath>..\..\SO775-DUOStore\dll\UserFromControl.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AxisControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="AxisControl.Designer.cs">
<DependentUpon>AxisControl.cs</DependentUpon>
</Compile>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="IOControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="IOControl.Designer.cs">
<DependentUpon>IOControl.cs</DependentUpon>
</Compile>
<Compile Include="MainControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="MainControl.Designer.cs">
<DependentUpon>MainControl.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="AxisControl.resx">
<DependentUpon>AxisControl.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="IOControl.resx">
<DependentUpon>IOControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainControl.resx">
<DependentUpon>MainControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{43cdd09e-fcf3-4960-a01d-3bbfe9933122}</Project>
<Name>Common</Name>
</ProjectReference>
<ProjectReference Include="..\DeviceLibrary\DeviceLibrary.csproj">
<Project>{bb23296c-aa1d-45c6-9fa6-5a37b2abfe9b}</Project>
<Name>DeviceLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\LoadCVSLibrary\LoadCSVLibrary.csproj">
<Project>{064bebf5-8faa-4ea2-a5f3-a06e6e7d9251}</Project>
<Name>LoadCSVLibrary</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file

namespace AutoScanAndLabel
{
partial class AxisControl
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.btnSavePos = new System.Windows.Forms.Button();
this.axisMoveControl1 = new DeviceLibrary.AxisMoveControl();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// groupBox3
//
this.groupBox3.Controls.Add(this.tableLayoutPanel1);
this.groupBox3.Location = new System.Drawing.Point(565, 3);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(628, 545);
this.groupBox3.TabIndex = 107;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "点位列表";
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tableLayoutPanel1.ColumnCount = 6;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
this.tableLayoutPanel1.Location = new System.Drawing.Point(6, 14);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(616, 525);
this.tableLayoutPanel1.TabIndex = 102;
//
// btnSavePos
//
this.btnSavePos.Location = new System.Drawing.Point(1054, 554);
this.btnSavePos.Name = "btnSavePos";
this.btnSavePos.Size = new System.Drawing.Size(133, 31);
this.btnSavePos.TabIndex = 108;
this.btnSavePos.Text = "全部保存";
this.btnSavePos.UseVisualStyleBackColor = true;
this.btnSavePos.Click += new System.EventHandler(this.btnSavePos_Click);
//
// axisMoveControl1
//
this.axisMoveControl1.Location = new System.Drawing.Point(0, 3);
this.axisMoveControl1.Name = "axisMoveControl1";
this.axisMoveControl1.Size = new System.Drawing.Size(559, 400);
this.axisMoveControl1.TabIndex = 0;
//
// AxisControl
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.btnSavePos);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.axisMoveControl1);
this.Font = new System.Drawing.Font("新宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Name = "AxisControl";
this.Size = new System.Drawing.Size(1274, 602);
this.Load += new System.EventHandler(this.AxisControl_Load);
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private DeviceLibrary.AxisMoveControl axisMoveControl1;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Button btnSavePos;
}
}
using DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoScanAndLabel
{
public partial class AxisControl : UserControl
{
public AxisControl()
{
InitializeComponent();
}
private void AxisControl_Load(object sender, EventArgs e)
{
axisMoveControl1.LoadData(RobotManage.mainMachine);
LoadPosList();
}
void LoadPosList() {
this.tableLayoutPanel1.RowStyles.Clear();
//this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType., 26));
int r = 0;
int c = 0;
int lastSubType = 0;
Random random = new Random(1);
Color color = Color.Black;
foreach (ConfigBase configBase in RobotManage.Config.configList) {
if (configBase.SubType < 10 || configBase.ProType != "PRO")
continue;
if (configBase.SubType != lastSubType)
{
lastSubType = configBase.SubType;
color = Color.FromArgb(random.Next(30,150), random.Next(30, 150), random.Next(30, 150));
}
//this.tableLayoutPanel1.RowCount++;
Button button = new Button();
button.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
button.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
button.Name = configBase.ProName;
button.Size = new System.Drawing.Size(225, 34);
button.Text = configBase.Explain;
button.Click += Button_Click;
button.ForeColor = color;
TextBox textBox = new TextBox();
textBox.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
textBox.Name = configBase.ProName;
textBox.Margin = new Padding(4, 8, 0, 0);
textBox.Size = new System.Drawing.Size(80, 23);
textBox.Text = configBase.ProValue;
textBox.Tag = configBase.SubType - 10;
textBox.KeyPress += TextBox_KeyPress;
textBox.TextChanged += TextBox_TextChanged;
TextBox textBox2 = new TextBox();
textBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
textBox2.Name = configBase.ProName+"_speed";
textBox2.Margin = new Padding(4, 8, 0, 0);
textBox2.Size = new System.Drawing.Size(80, 23);
textBox2.Text = configBase.TargetSpeed.ToString();
textBox2.Tag = configBase.SubType - 10;
textBox2.KeyPress += TextBox_KeyPress;
textBox2.TextChanged += TextBox_TextChanged;
tableLayoutPanel1.Controls.Add(button, c, r);
tableLayoutPanel1.Controls.Add(textBox, c + 1, r);
tableLayoutPanel1.Controls.Add(textBox2, c + 2, r);
r++;
if (r > 12)
{
r = 0;
c += 3;
}
}
}
private void TextBox_TextChanged(object sender, EventArgs e)
{
var s = (sender as TextBox).Text;
if (!int.TryParse(s, out _))
{
(sender as TextBox).Text = lastvalue;
}
}
string lastvalue = "";
private void TextBox_KeyPress(object sender, KeyPressEventArgs e)
{
var s = (sender as TextBox).Text;
if (int.TryParse(s, out _))
lastvalue = s;
}
private void Button_Click(object sender, EventArgs e)
{
var cc = tableLayoutPanel1.Controls.Find(((Button)sender).Name,false);
//Console.WriteLine(cc[1].Name);
//Console.WriteLine(cc[1].Tag);
//Console.WriteLine(cc[1].Text);
ConfigMoveAxis configMoveAxis = getConfigMoveAxis((int)cc[1].Tag);
AxisManager.AbsMove("", configMoveAxis.GetAxisValue(), int.Parse(cc[1].Text), configMoveAxis.TargetSpeed, configMoveAxis.AddSpeed, configMoveAxis.DelSpeed);
}
ConfigMoveAxis getConfigMoveAxis(int Axisid) {
foreach (ConfigMoveAxis configMoveAxis in RobotManage.Config.moveAxisList) {
if (configMoveAxis.GetAxisValue() == Axisid)
return configMoveAxis;
}
return null;
}
private void btnSavePos_Click(object sender, EventArgs e)
{
for (int i = 0; i < tableLayoutPanel1.Controls.Count; i++) {
if (tableLayoutPanel1.Controls[i].GetType().Name != "TextBox")
continue;
TextBox textBox = (TextBox)tableLayoutPanel1.Controls[i];
PropertyInfo pi= RobotManage.Config.GetType().GetProperty(textBox.Name);
pi.SetValue(RobotManage.Config, int.Parse(textBox.Text));
}
CSVConfigReader.SaveConfig(RobotManage.Config.ConfigFilePath, RobotManage.Config);
}
}
}
<?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 \ No newline at end of file

namespace AutoScanAndLabel
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.设备操作ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.启动ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.复位ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.停止ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.退出ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.设备操作ToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2);
this.menuStrip1.Size = new System.Drawing.Size(1342, 29);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// 设备操作ToolStripMenuItem
//
this.设备操作ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.启动ToolStripMenuItem,
this.toolStripSeparator1,
this.复位ToolStripMenuItem,
this.toolStripSeparator2,
this.停止ToolStripMenuItem,
this.toolStripSeparator3,
this.退出ToolStripMenuItem});
this.设备操作ToolStripMenuItem.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.设备操作ToolStripMenuItem.Name = "设备操作ToolStripMenuItem";
this.设备操作ToolStripMenuItem.Size = new System.Drawing.Size(86, 25);
this.设备操作ToolStripMenuItem.Text = "设备操作";
//
// 启动ToolStripMenuItem
//
this.启动ToolStripMenuItem.Name = "启动ToolStripMenuItem";
this.启动ToolStripMenuItem.Size = new System.Drawing.Size(112, 26);
this.启动ToolStripMenuItem.Text = "启动";
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(109, 6);
//
// 复位ToolStripMenuItem
//
this.复位ToolStripMenuItem.Name = "复位ToolStripMenuItem";
this.复位ToolStripMenuItem.Size = new System.Drawing.Size(112, 26);
this.复位ToolStripMenuItem.Text = "复位";
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(109, 6);
//
// 停止ToolStripMenuItem
//
this.停止ToolStripMenuItem.Name = "停止ToolStripMenuItem";
this.停止ToolStripMenuItem.Size = new System.Drawing.Size(112, 26);
this.停止ToolStripMenuItem.Text = "停止";
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(109, 6);
//
// 退出ToolStripMenuItem
//
this.退出ToolStripMenuItem.Name = "退出ToolStripMenuItem";
this.退出ToolStripMenuItem.Size = new System.Drawing.Size(112, 26);
this.退出ToolStripMenuItem.Text = "退出";
//
// tabControl1
//
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tabControl1.Location = new System.Drawing.Point(0, 29);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(1342, 695);
this.tabControl1.TabIndex = 1;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1342, 724);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.menuStrip1);
this.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.MainMenuStrip = this.menuStrip1;
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem 设备操作ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 启动ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem 复位ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem 停止ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 退出ToolStripMenuItem;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
}
}
using DeviceLibrary;
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 AutoScanAndLabel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
LogUtil.info("开始初始化");
MainControl mc = new MainControl();
AddForm("控制", mc);
IOControl ioc = new IOControl();
AddForm("IO调试", ioc);
AxisControl ac = new AxisControl();
AddForm("伺服调试", ac);
}
private void AddForm(string text, UserControl form)
{
//text = text.PadLeft(10, ' ');
TabPage lineTabPage = new TabPage(text);
// lineTabPage.AutoScroll = true;
//lineTabPage.Tag = robot;
Panel linePan = new Panel();
linePan.Dock = DockStyle.Fill;
linePan.AutoScroll = true;
lineTabPage.Controls.Add(linePan);
//form.FormBorderStyle = FormBorderStyle.None;
//form.TopLevel = false;
linePan.Controls.Add(form);
form.Dock = DockStyle.Fill;
linePan.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
form.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
form.Show();
//tabPageList.Add(lineTabPage);
tabControl1.Controls.Add(lineTabPage);
}
}
}
<?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>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file \ No newline at end of file

namespace AutoScanAndLabel
{
partial class IOControl
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnCloseAll = new System.Windows.Forms.Button();
this.btnRelax = new System.Windows.Forms.Button();
this.btnClamp = new System.Windows.Forms.Button();
this.btnLineStop = new System.Windows.Forms.Button();
this.btnLineRun = new System.Windows.Forms.Button();
this.btnDeviceLed = new System.Windows.Forms.Button();
this.btnCamerLed = new System.Windows.Forms.Button();
this.btnTopDown = new System.Windows.Forms.Button();
this.btnTopUp = new System.Windows.Forms.Button();
this.btnOpenDo = new System.Windows.Forms.Button();
this.btnCloseDO = new System.Windows.Forms.Button();
this.txtDOIndex = new System.Windows.Forms.TextBox();
this.label14 = new System.Windows.Forms.Label();
this.txtWriteTime = new System.Windows.Forms.TextBox();
this.btnBack = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label();
this.btn_Stop = new System.Windows.Forms.Button();
this.btn_Down = new System.Windows.Forms.Button();
this.btn_Up = new System.Windows.Forms.Button();
this.btnFoward = new System.Windows.Forms.Button();
this.cmbWriteIO = new System.Windows.Forms.ComboBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.groupBox1.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox1.Controls.Add(this.btnCloseAll);
this.groupBox1.Controls.Add(this.btnRelax);
this.groupBox1.Controls.Add(this.btnClamp);
this.groupBox1.Controls.Add(this.btnLineStop);
this.groupBox1.Controls.Add(this.btnLineRun);
this.groupBox1.Controls.Add(this.btnDeviceLed);
this.groupBox1.Controls.Add(this.btnCamerLed);
this.groupBox1.Controls.Add(this.btnTopDown);
this.groupBox1.Controls.Add(this.btnTopUp);
this.groupBox1.Controls.Add(this.btnOpenDo);
this.groupBox1.Controls.Add(this.btnCloseDO);
this.groupBox1.Controls.Add(this.txtDOIndex);
this.groupBox1.Controls.Add(this.label14);
this.groupBox1.Controls.Add(this.txtWriteTime);
this.groupBox1.Controls.Add(this.btnBack);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.btn_Stop);
this.groupBox1.Controls.Add(this.btn_Down);
this.groupBox1.Controls.Add(this.btn_Up);
this.groupBox1.Controls.Add(this.btnFoward);
this.groupBox1.Controls.Add(this.cmbWriteIO);
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(521, 3);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(361, 655);
this.groupBox1.TabIndex = 108;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "DO写入";
//
// btnCloseAll
//
this.btnCloseAll.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCloseAll.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCloseAll.Location = new System.Drawing.Point(167, 421);
this.btnCloseAll.Name = "btnCloseAll";
this.btnCloseAll.Size = new System.Drawing.Size(125, 34);
this.btnCloseAll.TabIndex = 302;
this.btnCloseAll.Text = "关闭所有DO";
this.btnCloseAll.UseVisualStyleBackColor = false;
this.btnCloseAll.Click += new System.EventHandler(this.btnCloseAll_Click);
//
// btnRelax
//
this.btnRelax.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnRelax.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnRelax.Location = new System.Drawing.Point(167, 363);
this.btnRelax.Name = "btnRelax";
this.btnRelax.Size = new System.Drawing.Size(125, 34);
this.btnRelax.TabIndex = 297;
this.btnRelax.Text = "取料气缸放松";
this.btnRelax.UseVisualStyleBackColor = false;
//
// btnClamp
//
this.btnClamp.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnClamp.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnClamp.Location = new System.Drawing.Point(167, 326);
this.btnClamp.Name = "btnClamp";
this.btnClamp.Size = new System.Drawing.Size(125, 34);
this.btnClamp.TabIndex = 296;
this.btnClamp.Text = "取料气缸夹紧";
this.btnClamp.UseVisualStyleBackColor = false;
//
// btnLineStop
//
this.btnLineStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnLineStop.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnLineStop.Location = new System.Drawing.Point(31, 363);
this.btnLineStop.Name = "btnLineStop";
this.btnLineStop.Size = new System.Drawing.Size(125, 34);
this.btnLineStop.TabIndex = 295;
this.btnLineStop.Text = "线体停止";
this.btnLineStop.UseVisualStyleBackColor = false;
//
// btnLineRun
//
this.btnLineRun.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnLineRun.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnLineRun.Location = new System.Drawing.Point(31, 326);
this.btnLineRun.Name = "btnLineRun";
this.btnLineRun.Size = new System.Drawing.Size(125, 34);
this.btnLineRun.TabIndex = 294;
this.btnLineRun.Text = "线体正转";
this.btnLineRun.UseVisualStyleBackColor = false;
//
// btnDeviceLed
//
this.btnDeviceLed.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnDeviceLed.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnDeviceLed.Location = new System.Drawing.Point(31, 461);
this.btnDeviceLed.Name = "btnDeviceLed";
this.btnDeviceLed.Size = new System.Drawing.Size(125, 34);
this.btnDeviceLed.TabIndex = 293;
this.btnDeviceLed.Text = "打开设备光源";
this.btnDeviceLed.UseVisualStyleBackColor = false;
//
// btnCamerLed
//
this.btnCamerLed.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCamerLed.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCamerLed.Location = new System.Drawing.Point(31, 421);
this.btnCamerLed.Name = "btnCamerLed";
this.btnCamerLed.Size = new System.Drawing.Size(125, 34);
this.btnCamerLed.TabIndex = 290;
this.btnCamerLed.Text = "打开相机光源";
this.btnCamerLed.UseVisualStyleBackColor = false;
//
// btnTopDown
//
this.btnTopDown.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnTopDown.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnTopDown.Location = new System.Drawing.Point(31, 206);
this.btnTopDown.Name = "btnTopDown";
this.btnTopDown.Size = new System.Drawing.Size(125, 34);
this.btnTopDown.TabIndex = 289;
this.btnTopDown.Text = "横移顶升气缸下降";
this.btnTopDown.UseVisualStyleBackColor = false;
//
// btnTopUp
//
this.btnTopUp.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnTopUp.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnTopUp.Location = new System.Drawing.Point(31, 169);
this.btnTopUp.Name = "btnTopUp";
this.btnTopUp.Size = new System.Drawing.Size(125, 34);
this.btnTopUp.TabIndex = 288;
this.btnTopUp.Text = "横移顶升气缸上升";
this.btnTopUp.UseVisualStyleBackColor = false;
//
// btnOpenDo
//
this.btnOpenDo.BackColor = System.Drawing.Color.White;
this.btnOpenDo.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOpenDo.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOpenDo.Location = new System.Drawing.Point(20, 85);
this.btnOpenDo.Name = "btnOpenDo";
this.btnOpenDo.Size = new System.Drawing.Size(125, 34);
this.btnOpenDo.TabIndex = 282;
this.btnOpenDo.Text = "打开";
this.btnOpenDo.UseVisualStyleBackColor = false;
this.btnOpenDo.Click += new System.EventHandler(this.btnOpenDo_Click);
//
// btnCloseDO
//
this.btnCloseDO.BackColor = System.Drawing.Color.White;
this.btnCloseDO.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCloseDO.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCloseDO.Location = new System.Drawing.Point(156, 85);
this.btnCloseDO.Name = "btnCloseDO";
this.btnCloseDO.Size = new System.Drawing.Size(125, 34);
this.btnCloseDO.TabIndex = 281;
this.btnCloseDO.Text = "关闭";
this.btnCloseDO.UseVisualStyleBackColor = false;
this.btnCloseDO.Click += new System.EventHandler(this.btnCloseDO_Click);
//
// txtDOIndex
//
this.txtDOIndex.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtDOIndex.Location = new System.Drawing.Point(58, 54);
this.txtDOIndex.MaxLength = 10;
this.txtDOIndex.Name = "txtDOIndex";
this.txtDOIndex.Size = new System.Drawing.Size(70, 23);
this.txtDOIndex.TabIndex = 242;
this.txtDOIndex.Text = "0";
//
// label14
//
this.label14.AutoSize = true;
this.label14.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label14.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label14.Location = new System.Drawing.Point(20, 57);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(35, 17);
this.label14.TabIndex = 239;
this.label14.Text = "地址:";
this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtWriteTime
//
this.txtWriteTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtWriteTime.Location = new System.Drawing.Point(219, 54);
this.txtWriteTime.MaxLength = 10;
this.txtWriteTime.Name = "txtWriteTime";
this.txtWriteTime.Size = new System.Drawing.Size(72, 23);
this.txtWriteTime.TabIndex = 238;
this.txtWriteTime.Text = "0";
//
// btnBack
//
this.btnBack.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnBack.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnBack.Location = new System.Drawing.Point(167, 206);
this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(125, 34);
this.btnBack.TabIndex = 251;
this.btnBack.Text = "提升线体后退";
this.btnBack.UseVisualStyleBackColor = false;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label5.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label5.Location = new System.Drawing.Point(153, 57);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(60, 17);
this.label5.TabIndex = 237;
this.label5.Text = "定时(ms):";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btn_Stop
//
this.btn_Stop.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_Stop.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_Stop.Location = new System.Drawing.Point(167, 246);
this.btn_Stop.Name = "btn_Stop";
this.btn_Stop.Size = new System.Drawing.Size(125, 34);
this.btn_Stop.TabIndex = 250;
this.btn_Stop.Text = "提升线体停止";
this.btn_Stop.UseVisualStyleBackColor = false;
//
// btn_Down
//
this.btn_Down.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_Down.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_Down.Location = new System.Drawing.Point(167, 286);
this.btn_Down.Name = "btn_Down";
this.btn_Down.Size = new System.Drawing.Size(125, 34);
this.btn_Down.TabIndex = 250;
this.btn_Down.Text = "定位销下降";
this.btn_Down.UseVisualStyleBackColor = false;
//
// btn_Up
//
this.btn_Up.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_Up.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_Up.Location = new System.Drawing.Point(31, 286);
this.btn_Up.Name = "btn_Up";
this.btn_Up.Size = new System.Drawing.Size(125, 34);
this.btn_Up.TabIndex = 250;
this.btn_Up.Text = "定位销上升";
this.btn_Up.UseVisualStyleBackColor = false;
//
// btnFoward
//
this.btnFoward.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnFoward.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnFoward.Location = new System.Drawing.Point(167, 169);
this.btnFoward.Name = "btnFoward";
this.btnFoward.Size = new System.Drawing.Size(125, 34);
this.btnFoward.TabIndex = 250;
this.btnFoward.Text = "提升线体前进";
this.btnFoward.UseVisualStyleBackColor = false;
//
// cmbWriteIO
//
this.cmbWriteIO.DisplayMember = "ProName";
this.cmbWriteIO.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
this.cmbWriteIO.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbWriteIO.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.cmbWriteIO.FormattingEnabled = true;
this.cmbWriteIO.Location = new System.Drawing.Point(6, 18);
this.cmbWriteIO.Name = "cmbWriteIO";
this.cmbWriteIO.Size = new System.Drawing.Size(296, 27);
this.cmbWriteIO.TabIndex = 234;
this.cmbWriteIO.ValueMember = "ProName";
this.cmbWriteIO.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.cmbWriteIO_DrawItem);
this.cmbWriteIO.SelectedIndexChanged += new System.EventHandler(this.cmbWriteIO_SelectedIndexChanged);
//
// groupBox4
//
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox4.Controls.Add(this.tableLayoutPanel2);
this.groupBox4.Location = new System.Drawing.Point(262, 3);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(255, 733);
this.groupBox4.TabIndex = 107;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "DO列表";
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tableLayoutPanel2.AutoScroll = true;
this.tableLayoutPanel2.ColumnCount = 1;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Location = new System.Drawing.Point(5, 14);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 2;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 17F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 17F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(244, 713);
this.tableLayoutPanel2.TabIndex = 103;
//
// groupBox3
//
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox3.Controls.Add(this.tableLayoutPanel1);
this.groupBox3.Location = new System.Drawing.Point(3, 3);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(255, 733);
this.groupBox3.TabIndex = 106;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "DI列表";
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tableLayoutPanel1.AutoScroll = true;
this.tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Location = new System.Drawing.Point(6, 14);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 17F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 17F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(244, 713);
this.tableLayoutPanel1.TabIndex = 102;
//
// IOControl
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Font = new System.Drawing.Font("新宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Name = "IOControl";
this.Size = new System.Drawing.Size(1183, 683);
this.Load += new System.EventHandler(this.IOControl_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox4.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnCloseAll;
private System.Windows.Forms.Button btnRelax;
private System.Windows.Forms.Button btnClamp;
private System.Windows.Forms.Button btnLineStop;
private System.Windows.Forms.Button btnLineRun;
private System.Windows.Forms.Button btnDeviceLed;
private System.Windows.Forms.Button btnCamerLed;
private System.Windows.Forms.Button btnTopDown;
private System.Windows.Forms.Button btnTopUp;
private System.Windows.Forms.Button btnOpenDo;
private System.Windows.Forms.Button btnCloseDO;
private System.Windows.Forms.TextBox txtDOIndex;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.TextBox txtWriteTime;
private System.Windows.Forms.Button btnBack;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Button btn_Stop;
private System.Windows.Forms.Button btn_Down;
private System.Windows.Forms.Button btn_Up;
private System.Windows.Forms.Button btnFoward;
private System.Windows.Forms.ComboBox cmbWriteIO;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
}
}
using DeviceLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
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;
using UserFromControl;
namespace AutoScanAndLabel
{
public partial class IOControl : UserControl
{
readonly Timer t1 = new Timer();
public IOControl()
{
InitializeComponent();
t1.Stop();
t1.Interval = 500;
t1.Tick += T1_Tick;
GC.KeepAlive(t1);
LoadIOList();
}
private void T1_Tick(object sender, EventArgs e)
{
if (this.Visible)
{
ReadIOList();
}
}
Dictionary<string, IOTextControl> DIControlList = new Dictionary<string, IOTextControl>();
Dictionary<string, IOTextControl> DOControlList = new Dictionary<string, IOTextControl>();
private void IOControl_Load(object sender, EventArgs e)
{
}
private void LoadIOList()
{
int roleindex = 0;
this.tableLayoutPanel1.RowStyles.Clear();
this.tableLayoutPanel1.RowCount = RobotManage.Config.DIList.Count;
foreach (ConfigIO ioValue in RobotManage.Config.DIList.Values)
{
//if (ioValue.SubType.Equals(0))
{
this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 26));
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
this.tableLayoutPanel1.Controls.Add(control, 0, roleindex);
roleindex++;
DIControlList.Add(ioValue.ProName, control);
}
}
tableLayoutPanel2.RowStyles.Clear();
this.tableLayoutPanel2.RowCount = RobotManage.Config.DOList.Count;
roleindex = 0;
foreach (ConfigIO ioValue in RobotManage.Config.DOList.Values)
{
//if (ioValue.SubType.Equals(0))
{
this.tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
control.Click += Control_Click;
this.tableLayoutPanel2.Controls.Add(control, 0, roleindex);
roleindex++;
DOControlList.Add(ioValue.ProName, control);
}
}
this.SuspendLayout(); //此处为不闪屏,一定要有的!
cmbWriteIO.DataSource = new List<ConfigIO>(RobotManage.Config.DOList.Values);
cmbWriteIO.ValueMember = "ProName";
cmbWriteIO.DisplayMember = "DisplayStr";
t1.Start();
}
private void ReadIOList()
{
foreach (string key in DIControlList.Keys)
{
IOTextControl control = DIControlList[key];
ConfigIO io = RobotManage.Config.DIList[key];
int iov = (int)IOManager.GetDIValue("", 0, io.GetIOAddr());
if (iov != control.IOValue)
{
control.IOValue = iov;
control.ShowData();
}
}
foreach (string key in this.DOControlList.Keys)
{
IOTextControl control = DOControlList[key];
ConfigIO io = RobotManage.Config.DOList[key];
int iov = (int)IOManager.GetDOValue("", 0, io.GetIOAddr());
if (iov != control.IOValue)
{
control.IOValue = iov;
control.ShowData();
}
}
}
private void Control_Click(object sender, EventArgs e)
{
IOTextControl control = (IOTextControl)sender;
string name = control.Name.Substring(3, control.Name.Length - 3);
List<string> keyList = new List<string>(DOControlList.Keys);
int index = keyList.IndexOf(name);
if (index >= 0)
{
cmbWriteIO.SelectedIndex = index;
}
}
IOTextControl selectControl = null;
private void cmbWriteIO_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbWriteIO.SelectedIndex >= 0)
{
ConfigIO io = GetSelectDO();
if (io != null)
{
// txtIp.Text = io.DeviceName;
txtDOIndex.Text = io.GetIOAddr().ToString();
IOTextControl newControl = DOControlList[io.ProName];
if (selectControl != null) { selectControl.BackColor = Color.White; }
newControl.BackColor = Color.SkyBlue;
selectControl = newControl;
}
}
}
private ConfigIO GetSelectDO()
{
string text = cmbWriteIO.SelectedValue.ToString();
if (RobotManage.Config.DOList.ContainsKey(text))
{
ConfigIO io = RobotManage.Config.DOList[text];
return io;
}
return null;
}
private void btnOpenDo_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.HIGH);
}
private void btnCloseDO_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.LOW);
}
private void WriteDO(IO_VALUE value)
{
int index = FormUtil.GetIntValue(txtDOIndex);
// IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = 0;
if (time > 0)
{
IOManager.WriteSingleDO("HC", (byte)slaveId, (ushort)index, (IO_VALUE)value, time);
}
else
{
IOManager.WriteSingleDO("HC", (byte)slaveId, (ushort)index, (IO_VALUE)value);
}
}
private void cmbWriteIO_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index < 0)
{
return;
}
e.DrawBackground();
e.DrawFocusRectangle();
if (cmbWriteIO.Items.Count > e.Index)
{
ConfigIO io = (ConfigIO)cmbWriteIO.Items[e.Index];
e.Graphics.DrawString(io.DisplayStr, e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3);
}
}
private void btnCloseAll_Click(object sender, EventArgs e)
{
IOManager.CloseAllDO();
}
}
}
<?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 \ No newline at end of file

namespace AutoScanAndLabel
{
partial class MainControl
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btn_run = new System.Windows.Forms.Button();
this.btn_stop = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btn_run
//
this.btn_run.Location = new System.Drawing.Point(57, 46);
this.btn_run.Name = "btn_run";
this.btn_run.Size = new System.Drawing.Size(75, 23);
this.btn_run.TabIndex = 0;
this.btn_run.Text = "启动";
this.btn_run.UseVisualStyleBackColor = true;
//
// btn_stop
//
this.btn_stop.Location = new System.Drawing.Point(153, 46);
this.btn_stop.Name = "btn_stop";
this.btn_stop.Size = new System.Drawing.Size(75, 23);
this.btn_stop.TabIndex = 0;
this.btn_stop.Text = "停止";
this.btn_stop.UseVisualStyleBackColor = true;
//
// MainControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btn_stop);
this.Controls.Add(this.btn_run);
this.Name = "MainControl";
this.Size = new System.Drawing.Size(1001, 470);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button btn_run;
private System.Windows.Forms.Button btn_stop;
}
}
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 AutoScanAndLabel
{
public partial class MainControl : UserControl
{
public MainControl()
{
InitializeComponent();
}
}
}
<?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 \ No newline at end of file
using log4net.Config;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoScanAndLabel
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
XmlConfigurator.Configure();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("SO827-AutoScanAndLabel")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SO827-AutoScanAndLabel")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("61fdff14-8bb7-439a-85a0-592e3011f4c4")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace AutoScanAndLabel.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AutoScanAndLabel.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace AutoScanAndLabel.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{43CDD09E-FCF3-4960-A01D-3BBFE9933122}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.Common</RootNamespace>
<AssemblyName>MyCommon</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\增广夹爪\Rmaxis\bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\dll\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="bean\Bean.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Setting_Init.cs" />
<Compile Include="util\AcSerialBean.cs" />
<Compile Include="util\ConfigAppSettings.cs" />
<Compile Include="util\FormUtil.cs" />
<Compile Include="util\JsonHelper.cs" />
<Compile Include="util\LogUtil.cs" />
<Compile Include="util\MyWebClient.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="util\NetTCPServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="util\CTcpClient.cs" />
<Compile Include="util\TcpServer.cs" />
<Compile Include="util\UdpServer.cs" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file \ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Common")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Common")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("f8eab140-5f98-4df7-842c-0d866e759c9a")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.Common
{
/// <summary>
/// 记录配置的key
/// </summary>
public class Setting_Init
{ /// <summary>
/// 系统启动时自动启动料仓,=1时自动启动,并隐藏窗口,=0时不需要
/// </summary>
public static string App_AutoRun = "App_AutoRun";
/// <summary>
/// 系统主界面标题
/// </summary>
public static string App_Title = "App_Title";
/// <summary>
/// 摄像机名称
/// </summary>
public static string CameraName = "CameraName";
public static string Config_Pwd = "Config_Pwd";
public static string UseBuzzer = "UseBuzzer";
/// <summary>
/// 检测到料串自动入料
/// </summary>
public static string AutoInput = "AutoInput";
/// <summary>
/// 进出轴待机点位,进出轴在此位置时,升降和旋转才可以走
/// </summary>
public static string InoutDefaultPosition = "InoutDefaultPosition";
public static string LabelName = "LabelName";
public static string PrinterName = "PrinterName";
public static string NeedPrintLabel = "NeedPrintLabel";
public static string StickingPosJudgment = "StickingPosJudgment";
public static string GratingSignal = " GratingSignal";
/// <summary>
/// 启用贴标功能
/// </summary>
public static string UseLabel = "UseLabel";
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.Common
{
public class LineGetPosOp
{
public LineGetPosOp(string cids,string code)
{
this.cids = cids;
this.code = code;
}
public string cids = "";
public string code = "";
}
public class LineOperation
{
// //{"result":"0","msg":"","pos":"11#AC1_18_4_28","barcode":"R506072019102200414","cid":"line-ac-11"}
// 返回: {"code": 0, "msg":"ok", data:7}
/// <summary>
/// 0=成功
/// </summary>
public int result;
public string cid;
public string msg = "";
public string pos = "";
public string barcode = "";
}
/// <summary>
/// 与服务器通信用对象
/// </summary>
public class Operation
{
/// <summary>
/// 料仓唯一标识,分号分割
/// </summary>
private string _cid = "";
public string cid
{
get { return _cid; }
set { _cid = value; }
}
/// <summary>
/// 请求序列号
/// </summary>
public int seq { get; set; }
/// <summary>
/// 操作码(0无操作(发送料仓状态给服务器),
/// 1扫码入库(扫码成功后发送给服务器),
/// 2 出库(服务器发送),3表示错误信息 )
/// 4,发送给服务表示二维码扫码入库,收到开始扫码
/// </summary>
public int op { get; set; }
/// <summary>
/// 操作相关数据,
/// op=1时,客户端发送 code 二维码给服务器,服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度
/// 如果需要更新温湿度的报警值,服务器会发送alarmTemperature,alarmHumidity给客户端,客户端缓存,如果没有发送,不处理
/// op=3时,data发送BoxID和AlarmCode
/// =4时扫码入库
/// =5时服务器发送预警温度
/// </summary>
private Dictionary<string, string> _data = new Dictionary<string, string>();
public Dictionary<string, string> data
{
get { return _data; }
set { _data = value; }
}
/// <summary>
/// 整体料仓状态
/// 1=正常运行中
/// 2=急停中
/// 3=故障(气压检测不到等,用msg发送详细故障说明)
/// 4=警告(用msg发送提醒,如出库到达工位但是没有工人操作)
/// </summary>
public int status { get; set; }
/// <summary>
/// 提示消息
/// 出入库错误: BOX正在调试中,不能出入库
/// 出入库错误: 急停了不能出入库
/// 入库错误:料盘过大,放不到指定的位置中去
/// 故障:气压信号检测不到
/// 警告:出库盘到达工位但是没有工人操作
/// </summary>
public string msg { get; set; }
/// <summary>
/// 包含的多个 BOX 的状态信息
/// </summary>
public Dictionary<int, BoxStatus> boxStatus = new Dictionary<int, BoxStatus>();
/// <summary>
/// 报警集合
/// </summary>
public List<AlarmInfo> alarmList = new List<AlarmInfo>();
}
/// <summary>
/// 单台料仓状态(包含流水线)
/// </summary>
public class BoxStatus
{
/// <summary>
/// Box编号,从1开始
/// </summary>
public int boxId { get; set; }
/// <summary>
/// 单台BOX状态
/// 急停,故障,调试中,就绪状态(正常待机)
/// 入库执行中,入库完成,入库失败
/// 出库执行中,出库完成,出库失败
/// </summary>
public int status { get; set; }
/// <summary>
/// 单台BOX的消息
/// 正在调试中,不能出入库
/// 入库失败原因:
/// 出库失败原因:
/// </summary>
public string msg { get; set; }
/// <summary>
/// 温度
/// </summary>
public string temperature { get; set; }
/// <summary>
/// 湿度
/// </summary>
public string humidity { get; set; }
/// <summary>
/// 操作相关数据,
/// 出库完成后发送posId库位编号给服务器
/// </summary>
private Dictionary<string, string> _data = new Dictionary<string, string>();
public Dictionary<string, string> data
{
get { return _data; }
set { _data = value; }
}
}
public class AlarmInfo
{
public AlarmInfo(int StoreID, int aType, string alarmDetial, string WarnMsg, int inoutStatus)
{
// TODO: Complete member initialization
this.boxId = StoreID;
this.alarmType = aType;
this.alarmDetail = alarmDetial;
this.alarmMsg = WarnMsg;
this.inOutStatus = inoutStatus;
}
public AlarmInfo()
{
// TODO: Complete member initialization
}
/// <summary>
/// 料仓ID,0表示流水线
/// </summary>
public int boxId { get; set; }
/// <summary>
/// 报警类型,
/// </summary>
public int alarmType { get; set; }
/// <summary>
/// 报警详情
///AlarmType= 0 消息 "1=原点返回
//AlarmType= 0 消息 2=复位"
//AlarmType=1 总体错误 "1=急停
//AlarmType=1 总体错误 2=没有气压信号
//AlarmType=1 总体错误,3=盘错乱"
//AlarmType=2 运动轴错误 1=第一轴(旋转)
//AlarmType=2 运动轴错误 2=第二轴(上下轴)
//AlarmType=2 运动轴错误 3=第三轴(前进轴)
//AlarmType=2 运动轴错误 4=第四轴(压紧轴)"
//AlarmType=2 电钢报警 5=上下电钢
//AlarmType=3 IO报警,信号超时 io电器定义(电器定义)
/// </summary>
public string alarmDetail { get; set; }
/// <summary>
/// 报警消息
/// </summary>
public string alarmMsg { get; set; }
/// <summary>
/// 0,1=入库,2=出库
/// </summary>
public int inOutStatus { get; set; }
}
public class ParamDefine
{
/// <summary>
/// 库位 ID
/// </summary>
public static string posId = "posId";
/// <summary>
/// 料盘宽
/// </summary>
public static string plateW = "plateW";
/// <summary>
/// 料盘高
/// </summary>
public static string plateH = "plateH";
/// <summary>
/// 料仓ID
/// </summary>
public static string storeId = "storeId";
/// <summary>
/// 报警码
/// </summary>
public static string alarmCode = "alarmCode";
/// <summary>
/// 报警详情或参数
/// </summary>
public static string alarmDetial = "alarmDetial";
/// <summary>
/// 湿度报警值
/// </summary>
public static string maxHumidity = "humi";
/// <summary>
/// 温度报警值
/// </summary>
public static string maxTemperature = "temp";
/// <summary>
/// urgentReel: true 表示紧急料,需要出到料串上
/// </summary>
public static string urgentReel = "urgentReel";
/// <summary>
/// cutReel: true 表示分盘料,需要出到料串上
/// </summary>
public static string cutReel = "cutReel";
/// <summary>
/// smallReel: true 小料(7x8),放置到小料串上
/// </summary>
public static string smallReel = "smallReel";
/// <summary>
/// rfid: 分配的料串RFID
/// </summary>
public static string rfid = "rfid";
/// <summary>
/// rfidLoc: 料串的架位,值为 - 1时,可以自由分配皮带线, 小料时,架位为1 - 46优先走1 / 2号皮带线,47 - 92优先走3 / 4号皮带线,
/// 70,71,72时只能分配到3 / 4号皮带线; 大料时,架位1 - 6优先走1 / 2号皮带线, 7 - 12优先走3 / 4号皮带线
/// </summary>
public static string rfidLoc = "rfidLoc";
public static string barcode = "barcode";
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
namespace OnlineStore.Common
{
public class AcSerialBean
{
#region 全部变量
// public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private SerialPort _serialPort = null;
private object lockObj = new object();
//定义委托
//public delegate void SerialPortDataReceiveEventArgs(string portName, object sender, SerialDataReceivedEventArgs e, byte[] bits);
//定义接收数据事件
//public event SerialPortDataReceiveEventArgs DataReceived;
//定义接收错误事件
//public event SerialErrorReceivedEventHandler Error;
//接收事件是否有效 false表示有效
//public bool ReceiveEventFlag = false;
#endregion
#region 获取串口名
private string protName;
public string PortName
{
get { return _serialPort.PortName; }
set
{
_serialPort.PortName = value;
protName = value;
}
}
#endregion
#region 获取比特率
private int baudRate;
public int BaudRate
{
get { return _serialPort.BaudRate; }
set
{
_serialPort.BaudRate = value;
baudRate = value;
}
}
#endregion
#region 默认构造函数
///// <summary>
///// 默认构造函数,操作COM1,速度为9600,没有奇偶校验,8位字节,停止位为1 "COM1", 9600, Parity.None, 8, StopBits.One
///// </summary>
//public SerialBean()
//{
// _serialPort = new SerialPort();
//}
#endregion
#region 构造函数
///// <summary>
///// 构造函数,
///// </summary>
///// <param name="comPortName"></param>
//public SerialBean(string comPortName)
//{
// _serialPort = new SerialPort(comPortName);
// _serialPort.BaudRate = 9600;
// _serialPort.Parity = Parity.Even;
// _serialPort.DataBits = 8;
// _serialPort.StopBits = StopBits.One;
// _serialPort.Handshake = Handshake.None;
// _serialPort.RtsEnable = true;
// _serialPort.ReadTimeout = 2000;
// setSerialPort();
//}
#endregion
#region 构造函数,可以自定义串口的初始化参数
/// <summary>
/// 构造函数,可以自定义串口的初始化参数
/// </summary>
/// <param name="comPortName">需要操作的COM口名称</param>
/// <param name="baudRate">COM的速度</param>
/// <param name="parity">奇偶校验位</param>
/// <param name="dataBits">数据长度</param>
/// <param name="stopBits">停止位</param>
public AcSerialBean(string comPortName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
{
_serialPort = new SerialPort(comPortName, baudRate, parity, dataBits, stopBits);
_serialPort.RtsEnable = true; //自动请求
_serialPort.ReadTimeout = 3000;//超时
setSerialPort();
}
#endregion
#region 析构函数
/// <summary>
/// 析构函数,关闭串口
/// </summary>
~AcSerialBean()
{
if (_serialPort.IsOpen)
_serialPort.Close();
}
#endregion
#region 设置串口参数
/// <summary>
/// 设置串口参数
/// </summary>
/// <param name="comPortName">需要操作的COM口名称</param>
/// <param name="baudRate">COM的速度</param>
/// <param name="dataBits">数据长度</param>
/// <param name="stopBits">停止位</param>
public void setSerialPort(string comPortName, int baudRate, int dataBits, int stopBits)
{
if (_serialPort.IsOpen)
_serialPort.Close();
_serialPort.PortName = comPortName;
_serialPort.BaudRate = baudRate;
_serialPort.Parity = Parity.None;
_serialPort.DataBits = dataBits;
_serialPort.StopBits = (StopBits)stopBits;
_serialPort.Handshake = Handshake.None;
_serialPort.RtsEnable = false;
_serialPort.ReadTimeout = 3000;
_serialPort.NewLine = "/r/n";
setSerialPort();
}
#endregion
#region 设置接收函数
/// <summary>
/// 设置串口资源,还需重载多个设置串口的函数
/// </summary>
void setSerialPort()
{
if (_serialPort != null)
{
//设置触发DataReceived事件的字节数为1
_serialPort.ReceivedBytesThreshold = 1;
//接收到一个字节时,也会触发DataReceived事件
// _serialPort.DataReceived += new SerialDataReceivedEventHandler(_serialPort_DataReceived);
//接收数据出错,触发事件
_serialPort.ErrorReceived += new SerialErrorReceivedEventHandler(_serialPort_ErrorReceived);
//打开串口
//openPort();
}
}
#endregion
#region 打开串口资源
/// <summary>
/// 打开串口资源
/// <returns>返回bool类型</returns>
/// </summary>
public bool openPort()
{
bool ok = false;
//如果串口是打开的,先关闭
if (_serialPort.IsOpen)
_serialPort.Close();
try
{
//打开串口
_serialPort.Open();
ok = true;
}
catch (Exception Ex)
{
LogUtil.error( Ex.ToString());
//throw Ex;
}
return ok;
}
#endregion
#region 关闭串口
/// <summary>
/// 关闭串口资源,操作完成后,一定要关闭串口
/// </summary>
public void closePort()
{
//如果串口处于打开状态,则关闭
if (_serialPort.IsOpen)
_serialPort.Close();
}
public void clearInBuffer()
{
if (_serialPort.IsOpen)
{
_serialPort.DiscardInBuffer();
}
}
public void clearOutBuffer()
{
if (_serialPort.IsOpen)
{
_serialPort.DiscardOutBuffer();
}
}
#endregion
#region 接收数据出错事件
/// <summary>
/// 接收数据出错事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void _serialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
{
}
#endregion
#region 发送数据string类型
//public void SendData(string data)
//{ //发送数据
// if (_serialPort.IsOpen)
// {
// lock (lockObj)
// {
// _serialPort.Write(data);
// System.Threading.Thread.Sleep(10);
// }
// }
//}
#endregion
#region 发送数据byte类型
///// <summary>
///// 数据发送
///// </summary>
///// <param name="data">要发送的数据字节</param>
//public void SendData(byte[] data, int offset, int count)
//{
// string strSend = "";
// for (int i = 0; i < data.Length; i++)
// {
// strSend += string.Format("{0:X2} ", data[i]);
// }
// LOGGER.Debug("【" + _serialPort.PortName + "】发送数据【" + strSend + "】");
// lock (lockObj)
// {
// try
// {
// if (_serialPort.IsOpen)
// {
// _serialPort.DiscardInBuffer();//清空接收缓冲区
// _serialPort.Write(data, offset, count);
// System.Threading.Thread.Sleep(10);
// }
// }
// catch (Exception ex)
// {
// _serialPort.DiscardOutBuffer();
// LogUtil.error(LOGGER, "SendData ERROR:" + ex.ToString(), 21);
// }
// }
//}
#endregion
#region 发送命令
/// <summary>
/// 发送命令
/// </summary>
/// <param name="SendData">发送数据</param>
/// <param name="ReceiveData">接收数据</param>
/// <param name="Overtime">超时时间</param>
/// <returns></returns>
public int SendCommand(byte[] SendData, ref byte[] ReceiveData, int Overtime,out bool isOk)
{
isOk = false;
if (_serialPort.IsOpen)
{
//lock (lockObj)
if(Monitor.TryEnter(lockObj,Overtime+50))
{
//Monitor.Enter(lockObj);
try
{
_serialPort.DiscardInBuffer(); //清空接收缓冲区
_serialPort.Write(SendData, 0, SendData.Length);
int num = 0, ret = 0;
System.Threading.Thread.Sleep(10);
while (num++ < Overtime)
{
if (_serialPort.BytesToRead >= ReceiveData.Length)
break;
System.Threading.Thread.Sleep(1);
}
if (num >= Overtime)
{
LogUtil.error(PortName + " 发送数据" + ByteToString(SendData) + "等待接受数据超时");
}
if (_serialPort.BytesToRead >= ReceiveData.Length)
{
ret = _serialPort.Read(ReceiveData, 0, ReceiveData.Length);
}
else
{
ret = _serialPort.Read(ReceiveData, 0, _serialPort.BytesToRead);
}
isOk = true;
return ret;
}
catch (Exception ex)
{
isOk = false;
LogUtil.error( "SendCommand ERROR:" + ex.ToString(),108);
}
finally
{
Monitor.Exit(lockObj);
}
}
else
{
LogUtil.error(PortName + " 发送数据" + ByteToString(SendData) + "失败,未得到锁");
}
}
return -1;
}
private byte PreSlvAddr = 0;
/// <summary>
/// 发送命令
/// </summary>
/// <param name="SendData">发送数据</param>
/// <param name="ReceiveData">接收数据</param>
/// <param name="Overtime">超时时间</param>
/// <param name="ReceiveLength">接收数据长度</param>
/// <returns></returns>
public int SendCommand(byte[] SendData, ref byte[] ReceiveData, int Overtime, int ReceiveLength)
{
if (_serialPort == null)
{
LogUtil.error(PortName+" 发送数据"+ByteToString(SendData)+ "失败,_serialPort=null");
return -1;
}
if (_serialPort.IsOpen)
{
if (Monitor.TryEnter(lockObj, Overtime + 80))
{
//Monitor.Enter(lockObj);
try
{
//判断是否需要休眠
if (SendData != null && SendData.Length > 0)
{
if (!SendData[0].Equals(PreSlvAddr))
{
Thread.Sleep(50);
PreSlvAddr = SendData[0];
}
}
_serialPort.DiscardInBuffer(); //清空接收缓冲区
_serialPort.Write(SendData, 0, SendData.Length);
int num = 0, ret = 0;
//System.Threading.Thread.Sleep(10);
if (ReceiveData == null)
{
ReceiveData = new byte[ReceiveLength];
}
while (num++ < Overtime)
{
if (_serialPort.BytesToRead >= ReceiveData.Length)
break;
System.Threading.Thread.Sleep(1);
}
if (num >= Overtime)
{
LogUtil.error(PortName + " 发送数据" + ByteToString(SendData) + "等待接受数据超时");
}
if (_serialPort.BytesToRead >= ReceiveData.Length)
{
ret = _serialPort.Read(ReceiveData, 0, ReceiveData.Length);
}
else
{
ret = _serialPort.Read(ReceiveData, 0, _serialPort.BytesToRead);
}
return ret;
}
catch (Exception ex)
{
LogUtil.error(PortName + " 发送数据" + ByteToString(SendData) + " 出错:"+ex.ToString());
}
finally
{
Monitor.Exit(lockObj);
}
}
else
{
LogUtil.error(PortName + " 发送数据" + ByteToString(SendData) + "失败,未得到锁");
}
}
return -1;
}
#endregion
#region 获取串口
/// <summary>
/// 获取所有已连接短信猫设备的串口
/// </summary>
/// <returns></returns>
public string[] serialsIsConnected()
{
List<string> lists = new List<string>();
string[] seriallist = getSerials();
foreach (string s in seriallist)
{
}
return lists.ToArray();
}
#endregion
#region 获取当前全部串口资源
/// <summary>
/// 获得当前电脑上的所有串口资源
/// </summary>
/// <returns></returns>
public string[] getSerials()
{
return SerialPort.GetPortNames();
}
#endregion
#region 字节型转换16
/// <summary>
/// 把字节型转换成十六进制字符串
/// </summary>
/// <param name="InBytes"></param>
/// <returns></returns>
public static string ByteToString(byte[] InBytes)
{
string StringOut = "";
foreach (byte InByte in InBytes)
{
StringOut = StringOut + String.Format("{0:X2} ", InByte);
}
return StringOut;
}
#endregion
#region 十六进制字符串转字节型
/// <summary>
/// 打包方法,可以将十六制字符串转成byte[] ,字符串没有空格
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static byte[] StringToByte(string s)
{
string temps = ReplaceSpace(s);
if (temps.Length % 2 != 0)
{
temps = "0" + temps;
}
byte[] tempb = new byte[50];
int j = 0;
for (int i = 0; i < temps.Length; i = i + 2, j++)
{
tempb[j] = Convert.ToByte(temps.Substring(i, 2), 16);
}
byte[] send = new byte[j];
Array.Copy(tempb, send, j);
return send;
}
//除去空格
public static string ReplaceSpace(string str)
{
string putout = "";
for (int i = 0; i < str.Length; i++)
{
if (str[i] != ' ')
{ putout += str[i]; }
}
return putout;
}
#endregion
#region 计算校验码
public static void CalculateBCC(byte[] pByte, int nNumberOfBytes, out ushort pChecksum)
{
byte check = 0;
check = (byte)(pByte[0] ^ (pByte[1]));
for (int i = 2; i < pByte.Length; i++)
{
check = (byte)(check ^ (pByte[i]));
}
pChecksum = check;
}
public static void CalculateCRC(byte[] pByte, int nNumberOfBytes, out ushort pChecksum)
{
int nBit;
ushort nShiftedBit;
pChecksum = 0xFFFF;
for (int nByte = 0; nByte < nNumberOfBytes; nByte++)
{
pChecksum ^= pByte[nByte];
for (nBit = 0; nBit < 8; nBit++)
{
if ((pChecksum & 0x1) == 1)
{
nShiftedBit = 1;
}
else
{
nShiftedBit = 0;
}
pChecksum >>= 1;
if (nShiftedBit != 0)
{
pChecksum ^= 0xA001;
}
}
}
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Threading;
namespace OnlineStore.Common
{
public class CTcpClient
{
// public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public delegate void HandleMessage(string message);
private Socket m_clientSocket = null;
private byte[] m_receiveBuffer = new byte[1024];
private HandleMessage onReceived;
public int TimeOutTime = 0;
/// <summary>
/// 当前连接状态
/// </summary>
public bool IsConnected()
{
if (m_clientSocket == null)
{
return false;
}
if (m_clientSocket.Connected)
{
return true;
}
#region remarks
/********************************************************************************************
* 当Socket.Conneted为false时, 如果您需要确定连接的当前状态,请进行非阻塞、零字节的 Send 调用。
* 如果该调用成功返回或引发 WAEWOULDBLOCK 错误代码 (10035),则该套接字仍然处于连接状态;
* 否则,该套接字不再处于连接状态。
* Depending on http://msdn.microsoft.com/zh-cn/library/system.net.sockets.socket.connected.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2
********************************************************************************************/
#endregion
try
{
#region 过程
// This is how you can determine whether a socket is still connected.
bool connectState = true;
bool blockingState = m_clientSocket.Blocking;
try
{
byte[] tmp = new byte[1];
m_clientSocket.Blocking = false;
m_clientSocket.Send(tmp, 0, 0);
//Console.WriteLine("Connected!");
connectState = true; //若Send错误会跳去执行catch体,而不会执行其try体里其之后的代码
}
catch (SocketException e)
{
// 10035 == WSAEWOULDBLOCK
if (e.NativeErrorCode.Equals(10035))
{
connectState = true;
}
else
{
connectState = false;
}
}
finally
{
if (m_clientSocket != null && m_clientSocket.Connected)
{
m_clientSocket.Blocking = blockingState;
}
}
//Console.WriteLine("Connected: {0}", client.Connected);
return connectState;
#endregion
}
catch (Exception ex)
{
LogUtil.error( "出错啦" + ex.ToString());
return false;
}
}
/// <summary>
/// 连接服务器
/// </summary>
public bool connect(string serverIP, int serverPort, HandleMessage HandleMessage)
{
m_clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
if (TimeOutTime <= 0)
{
IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Parse(serverIP), serverPort);
m_clientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
try
{
if (!m_clientSocket.Connected)
{
m_clientSocket.Connect(remoteEndPoint);
}
if (m_clientSocket.Connected)
{
m_clientSocket.BeginReceive(m_receiveBuffer, 0, m_receiveBuffer.Length, 0, new AsyncCallback(ReceiveCallBack), null);
onReceived = HandleMessage;
LogUtil.info( "Connect to " + serverIP + ":" + serverPort + " success!");
return true;
}
else
{
LogUtil.info( "Connect to " + serverIP + ":" + serverPort + " fail!");
}
}
catch (Exception ex)
{
LogUtil.error( "Connect to " + serverIP + ":" + serverPort + " fail!" + ex.ToString(), 103);
//m_clientSocket = null;
}
}
else
{
m_clientSocket.ReceiveTimeout = TimeOutTime;
m_clientSocket.SendTimeout = TimeOutTime;
IAsyncResult connResult = m_clientSocket.BeginConnect(serverIP, serverPort, null, null);
connResult.AsyncWaitHandle.WaitOne(this.TimeOutTime, true); //等待2秒
if (!connResult.IsCompleted || (!m_clientSocket.Connected))
{
LogUtil.info( "Connect to " + serverIP + ":" + serverPort + " fail!");
m_clientSocket.Close();
//处理连接不成功的动作
return false;
}
else
{
//处理连接成功的动作
m_clientSocket.BeginReceive(m_receiveBuffer, 0, m_receiveBuffer.Length, 0, new AsyncCallback(ReceiveCallBack), null);
onReceived = HandleMessage;
LogUtil.info( "Connect to " + serverIP + ":" + serverPort + " success!");
return true;
}
}
return false;
}
/// <summary>
/// 断开连接
/// </summary>
public void close()
{
try
{
if (m_clientSocket != null && m_clientSocket.Connected)
{
m_clientSocket.Shutdown(SocketShutdown.Both);
//Thread.Sleep(300);
//m_clientSocket.Disconnect(true);
//Thread.Sleep(300);
m_clientSocket.Close();
//m_clientSocket = null;
LogUtil.info( "Socket closed!");
}
else
{
LogUtil.error( "No socket is running!");
}
}
catch (Exception ex)
{
LogUtil.error( "close error :" + ex.ToString());
}
}
/// <summary>
/// 发送信息
/// </summary>
public void send(string strSendData)
{
byte[] sendBuffer = new byte[1024];
sendBuffer = Encoding.UTF8.GetBytes(strSendData);
if (m_clientSocket != null && m_clientSocket.Connected)
{
m_clientSocket.Send(sendBuffer);
LogUtil.debug( "Send >> " + strSendData);
}
}
/// <summary>
/// 发送信息
/// </summary>
public void sendLine(string strSendData)
{
if (strSendData.StartsWith("save"))
{
LogUtil.debug( "发送数据:" + strSendData);
}
else
{
LogUtil.info( "发送数据:" + strSendData);
}
strSendData = strSendData + "\r\n";
byte[] sendBuffer = new byte[1024];
sendBuffer = Encoding.UTF8.GetBytes(strSendData);
if (m_clientSocket != null && m_clientSocket.Connected)
{
m_clientSocket.Send(sendBuffer);
LogUtil.debug( "Send >> " + strSendData);
}
}
private void ReceiveCallBack(IAsyncResult ar)
{
try
{
if (m_clientSocket != null && m_clientSocket.Connected)
{
int REnd = m_clientSocket.EndReceive(ar);
string strReceiveData = Encoding.Default.GetString(m_receiveBuffer, 0, REnd);
onReceived(strReceiveData);
Thread.Sleep(100);
//LOGGER.Debug("m_clientSocket:" + m_clientSocket + "\n m_receiveBuffer" + m_receiveBuffer);
m_clientSocket.BeginReceive(m_receiveBuffer, 0, m_receiveBuffer.Length, 0, new AsyncCallback(ReceiveCallBack), null);
}
}
catch (Exception ex)
{
LogUtil.error( "socket received error:" + ex.ToString(), 104);
}
}
}
}
using System;
using System.Configuration;
using System.Threading;
using System.Xml;
using System.Windows.Forms;
namespace OnlineStore.Common
{
public class ConfigAppSettings
{
//public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static int seq = 1;
public static int nextSeq()
{
if (seq.Equals(Int32.MaxValue))
{
LogUtil.info("seq当前值:" + seq + ",重置seq=0");
seq = 0;
}
Interlocked.Increment(ref seq);
return seq;
}
public static string GetValue(string keyStr, string storeStr)
{
string key = keyStr + storeStr;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
return GetValue(keyStr);
}
else
{
return config.AppSettings.Settings[key].Value;
}
}
public static decimal GetNumValue(string keyStr, string storeStr)
{
string key = keyStr + storeStr;
decimal a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
return GetNumValue(keyStr);
}
else
{
{
Decimal.TryParse(config.AppSettings.Settings[key].Value, out a);
}
}
return a;
}
public static int GetIntValue(string keyStr, string storeStr)
{
string key = keyStr + storeStr;
int a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
return GetIntValue(keyStr);
}
else
{
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
} return a;
}
public static string GetValue(string key)
{
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return "";
}
else
{
return config.AppSettings.Settings[key].Value;
}
}
public static decimal GetNumValue(string key)
{
decimal a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
Decimal.TryParse(config.AppSettings.Settings[key].Value, out a);
}
}
return a;
}
public static int GetIntValue(string key)
{
int a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
} return a;
}
public static void SaveValue(string key, int value)
{
SaveValue(key, value.ToString());
}
public static void SaveValue(string key, string value)
{
try
{
if (key.Equals("") || value.Equals(""))
{
return;
}
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
SetValue(key, value);
}
else
{
UpdateConfig(key, value);
}
}
catch (Exception ex)
{
LogUtil.error( "SaveValue保存配置出错:AppKey=" + key + ",AppValue=" + value + ",",ex);
}
}
public static string GetValue(object debugDeviceId)
{
throw new NotImplementedException();
}
/// <summary>
/// 更新配置文件信息
/// </summary>
/// <param name="name">配置文件字段名称</param>
/// <param name="Xvalue">值</param>
private static void UpdateConfig(string name, string Xvalue)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(Application.ExecutablePath + ".config");
XmlNode node = doc.SelectSingleNode(@"//add[@key='" + name + "']");
XmlElement ele = (XmlElement)node;
ele.SetAttribute("value", Xvalue);
doc.Save(Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
LogUtil.error( "UpdateConfig保存配置出错:name=" + name + ",Xvalue=" + Xvalue + ",",ex);
}
}
///<summary>
///向.config文件的appKey结写入信息AppValue 保存设置
///</summary>
///<param name="AppKey">节点名</param>
///<param name="AppValue">值</param>
private static void SetValue(String AppKey, String AppValue)
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
if (xElem1 != null)
xElem1.SetAttribute("value", AppValue);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key", AppKey);
xElem2.SetAttribute("value", AppValue);
xNode.AppendChild(xElem2);
}
xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
LogUtil.error( "SetValue保存配置出错:AppKey=" + AppKey + ",AppValue=" + AppValue + ",",ex);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace OnlineStore.Common
{
public class FormUtil
{
public static string GetValue(TextBox txt)
{
string value = txt.Text;
return value;
}
public static int GetIntValue(TextBox txt)
{
int value = 0;
try
{
value = int.Parse(txt.Text);
}
catch (Exception ex)
{
value = 0;
}
return value;
}
public static short GetShortValue(TextBox txt)
{
short value = 0;
try
{
value = short.Parse(txt.Text);
}
catch (Exception ex)
{
value = 0;
}
return value;
}
public static double getDoubleValue(TextBox txt)
{
double value = 0;
try
{
value = double.Parse(txt.Text);
}
catch (Exception ex)
{
value = 0;
}
return value;
}
public static short get16ShortValue(TextBox txt)
{
short value = 0;
try
{
value = System.Convert.ToInt16(txt.Text,16);
}
catch
{
value = 0;
}
return value;
}
//public static string GetShowStr(double value)
//{
// string wStr = "";
// if (value == (int)value)
// {
// wStr = string.Format("{0:d}", (int)value);
// }
// else
// {
// wStr = string.Format("{0:f}", value);
// }
// return wStr;
//}
public static string GetSpanStr(TimeSpan span)
{
//return Convert.ToDateTime(span.ToString()).ToString("HH:mm:ss");
string seconds = Math.Round(span.TotalSeconds % 60, 1).ToString();
if (seconds.IndexOf(".") >= 0)
{
seconds = seconds.ToString().PadLeft(4, '0');
}
else
{
seconds = seconds.ToString().PadLeft(2, '0');
}
return span.Hours.ToString().PadLeft(2, '0') + ":" + span.Minutes.ToString().PadLeft(2, '0') + ":" + seconds;
}
}
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Collections;
using System.Net;
using System.Net.Security;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Reflection;
using log4net;
namespace OnlineStore.Common
{
public class HttpHelper
{
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static string Post(string url, string paramData)
{
return Post(url, paramData, Encoding.UTF8);
}
private static int isLog = ConfigAppSettings.GetIntValue(Setting_Init.Server_Log_Open);
public static string Post(string url, string paramData, Encoding encoding)
{
if (isLog == 1)
{
LOGGER.Info("给服务器发送数据【" + paramData + "】 ");
}
if (paramData != "null" && paramData != null)
{
// LogUtil.debug(LOGGER, "HTTP POST to " + url + " \n\t >> " + paramData);
}
string result = "";
if (url.ToLower().IndexOf("https", System.StringComparison.Ordinal) > -1)
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback((sender, certificate, chain, errors) => { return true; });
}
try
{
var wc = new MyWebClient(5000);
if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
wc.Encoding = encoding;
result = wc.UploadString(url, "POST", paramData);
//LogUtil.info(result);
}
catch (Exception e)
{
LogUtil.error( "POST ERROR:" + e.StackTrace, 1001);
}
if (!result.Contains("null") && result.Length != 0)
{
//LogUtil.debug(LOGGER,"receive << " + result);
}
if (isLog == 1)
{
LOGGER.Info("收到服务器数据【" + result + "】");
}
return result;
}
public static string Get(string url)
{
return Get(url, Encoding.UTF8);
}
public static string Get(string url, Encoding encoding)
{
try
{
LogUtil.info(LOGGER, "HTTP GET FROM: " + url);
var wc = new WebClient { Encoding = encoding };
var readStream = wc.OpenRead(url);
using (var sr = new StreamReader(readStream, encoding))
{
var result = sr.ReadToEnd();
LogUtil.info(LOGGER, "receive << " + result);
return result;
}
}
catch (Exception e)
{
LogUtil.error( "HTTP GET ERROR:" + e.Message, 1002);
}
return "";
}
}
}
\ No newline at end of file \ No newline at end of file

using log4net;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Reflection;
using System.Text;
namespace OnlineStore.Common
{
/// <summary>
/// 壁挂王字壳温湿度变送器(485型)
/// </summary>
public class HumitureController
{
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static bool IsRun = false;
public static string serialPort = "";
private static int bautRate = 4800;//波特率
private static Parity parity = Parity.None;//校验位
private static int dataBits = 8;//数据位
private static StopBits stopBits = StopBits.One; //停止位
private static AcSerialBean sb = null;
private static string LogName = "";
public static int HumitureControllerType = ConfigAppSettings.GetIntValue(Setting_Init.HumitureControllerType);
public static bool Init(string port)
{
if (IsRun && port.Equals(serialPort))
{
return true;
}
else if (IsRun)
{
Release();
}
LogName = "温湿度传感器[" + port + "]";
if (sb == null)
{
serialPort = port;
if (HumitureControllerType.Equals(1))
{
bautRate = 9600;//波特率
}
sb = new AcSerialBean(serialPort, bautRate, parity, dataBits, stopBits);
}
try
{
if (sb.openPort())
{
IsRun = true;
return true;
}
else
{
LogUtil.error(LOGGER, LogName + "串口打开失败!");
IsRun = false;
return false;
}
}
catch (Exception ex)
{
IsRun = false;
}
return true;
}
/// <summary>
/// 释放资源
/// </summary>
public static void Release()
{
if (sb != null)
{
sb.closePort();
}
IsRun = false;
}
public static ASTemperateParam LastData = new ASTemperateParam(0, 0);
public static ASTemperateParam QueryData()
{
ASTemperateParam param = new ASTemperateParam(0, 0);
List<double> data = queryData();
if (data.Count.Equals(2))
{
param = new ASTemperateParam(data[1], data[0]);
}
LastData = param;
return param;
}
/// <summary>
/// 返回温度和湿度
/// </summary>
/// <returns></returns>
private static List<double> queryData()
{
// 温度计算:
//当温度低于 0 ℃ 时温度数据以补码的形式上传。
//温度:FF9B H(十六进制)= -101 => 温度 = -10.1℃
//湿度计算:
//湿度:292 H(十六进制) = 658 => 湿度 = 65.8 % RH
if (IsRun.Equals(false))
{
return new List<double>();
}
byte[] sendData = new byte[8];
sendData[0] = 0x01;
if (HumitureControllerType.Equals(1))
{
sendData[1] = 0x04;
}
else
{
sendData[1] = 0x03;
}
sendData[2] = 0x00;
sendData[3] = 0x00;
sendData[4] = 0x00;
sendData[5] = 0x02;
sendData[6] = 0x00;
sendData[7] = 0x00;
sendData = buildCheckData(sendData, sendData.Length - 2);
string str = AcSerialBean.byteToHexStr(sendData);
LogUtil.debug("温湿度控制器发送数据:" + str);
byte[] reviceData = new byte[9];
bool isOk = false;
sb.SendCommand(sendData, ref reviceData, 100, out isOk);
return getReviceData(reviceData);
}
public static int QueryHistoryCount()
{
if (IsRun.Equals(false) || HumitureControllerType.Equals(2).Equals(false))
{
return -1;
}
byte[] sendData = new byte[8];
sendData[0] = 0x01;
sendData[1] = 0x04;
sendData[2] = 0x20;
sendData[3] = 0x00;
byte[] addrByte = AcSerialBean.StringToByte("2000");
if (addrByte.Length == 1)
{
sendData[2] = 0x00;
sendData[3] = addrByte[0];
}
else if (addrByte.Length == 2)
{
sendData[3] = addrByte[1];
sendData[2] = addrByte[0];
}
sendData[4] = 0x00;
sendData[5] = 0x02;
sendData[6] = 0x00;
sendData[7] = 0x00;
sendData = buildCheckData(sendData, sendData.Length - 2);
string str = AcSerialBean.byteToHexStr(sendData);
LogUtil.debug("温湿度控制器发送数据:" + str);
byte[] reviceData = new byte[9];
bool isOk = false;
sb.SendCommand(sendData, ref reviceData, 100, out isOk);
return getReviceIntData(reviceData);
}
public static int QueryCurrCount()
{
if (IsRun.Equals(false) || HumitureControllerType.Equals(2).Equals(false))
{
return -1;
}
byte[] sendData = new byte[8];
sendData[0] = 0x01;
sendData[1] = 0x04;
sendData[2] = 0x20;
sendData[3] = 0x02;
sendData[4] = 0x00;
sendData[5] = 0x02;
sendData[6] = 0x00;
sendData[7] = 0x00;
sendData = buildCheckData(sendData, sendData.Length - 2);
string str = AcSerialBean.byteToHexStr(sendData);
LogUtil.debug("温湿度控制器发送数据:" + str);
byte[] reviceData = new byte[9];
bool isOk = false;
sb.SendCommand(sendData, ref reviceData, 100, out isOk);
return getReviceIntData(reviceData);
}
public static List<object> QueryHistory()
{
List<object> list = new List<object>();
if (IsRun.Equals(false)||HumitureControllerType.Equals(2).Equals(false))
{
return list;
}
byte[] sendData = new byte[8];
sendData[0] = 0x01;
sendData[1] = 0x04;
sendData[2] = 0x20;
sendData[3] = 0x04;
sendData[4] = 0x00;
sendData[5] = 0x05;
sendData[6] = 0x00;
sendData[7] = 0x00;
sendData = buildCheckData(sendData, sendData.Length - 2);
string str = AcSerialBean.byteToHexStr(sendData);
LogUtil.debug("温湿度控制器发送数据:" + str);
byte[] reviceData = new byte[15];
bool isOk = false;
sb.SendCommand(sendData, ref reviceData, 100, out isOk);
try
{
if (reviceData != null && reviceData.Length >= 9)
{
string temp = String.Format("{0:X2}", reviceData[3]) + String.Format("{0:X2}", reviceData[4]);
string hum = String.Format("{0:X2}", reviceData[5]) + String.Format("{0:X2}", reviceData[6]);
double tempV = (double)Convert.ToInt32(temp, 16) / 10;
double humV = (double)Convert.ToInt32(hum, 16) / 10;
int year = Convert.ToInt32(String.Format("{0:X2}", reviceData[7]), 16);
int mouth = Convert.ToInt32(String.Format("{0:X2}", reviceData[8]), 16);
int day = Convert.ToInt32(String.Format("{0:X2}", reviceData[9]), 16);
int hour = Convert.ToInt32(String.Format("{0:X2}", reviceData[10]), 16);
int minute = Convert.ToInt32(String.Format("{0:X2}", reviceData[11]), 16);
int second = Convert.ToInt32(String.Format("{0:X2}", reviceData[12]), 16);
DateTime time = new DateTime(year, mouth, day, hour, minute, second);
list.Add(tempV);
list.Add(humV);
list.Add(time);
}
}
catch (Exception ex)
{
LOGGER.Info(LogName + "转换出错:" + ex.ToString());
}
return list;
}
private static byte[] buildCheckData(byte[] sendData, int length)
{
ushort pChecksum = 0;
AcSerialBean.CalculateCRC(sendData, length, out pChecksum);
string checkStr = Convert.ToString(pChecksum, 16);
byte[] checkByte = AcSerialBean.StringToByte(checkStr);
if (checkByte.Length == 1)
{
sendData[length] = checkByte[0];
sendData[length + 1] = 0x00;
}
else
{
sendData[length + 1] = checkByte[0];
sendData[length] = checkByte[1];
}
return sendData;
}
private static int getReviceIntData(byte[] dataArray)
{
List<double> list = new List<double>();
try
{
if (dataArray == null)
{
return -1;
}
if (dataArray.Length >= 9)
{
string data = String.Format("{0:X2}", dataArray[5]) + String.Format("{0:X2}", dataArray[6]+String.Format("{0:X2}", dataArray[3]) + String.Format("{0:X2}", dataArray[4]) );
int tempV = Convert.ToInt32(data, 16);
return tempV;
}
}
catch (Exception ex)
{
LOGGER.Info(LogName + "转换出错:" + ex.ToString());
}
return -1;
}
private static List<double> getReviceData(byte[] dataArray)
{
List<double> list = new List<double>();
try
{
if (dataArray == null)
{
return list;
}
if (dataArray.Length >= 9)
{
string temp = String.Format("{0:X2}", dataArray[3])+ String.Format("{0:X2}", dataArray[4]);
string hum = String.Format("{0:X2}", dataArray[5]) + String.Format("{0:X2}", dataArray[6]);
double tempV = (double)Convert.ToInt32(temp, 16)/10;
double humV =(double) Convert.ToInt32(hum, 16)/10;
list.Add(tempV);
list.Add(humV);
}
}
catch (Exception ex)
{
LOGGER.Info(LogName + "转换出错:" + ex.ToString());
}
return list;
}
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
namespace OnlineStore.Common
{
/// <summary>
/// 奥松温湿度服务器
/// </summary>
public class HumitureServer
{
private static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// 最后一次接受到的温度信息,key=温湿度传感器IP地址
/// </summary>
public static Dictionary<string, ASTemperateParam> TemperateParamMap = new Dictionary<string, ASTemperateParam>();
/// <summary>
/// 根据IP 地址获得最后一次取到的温湿度
/// </summary>
public static ASTemperateParam GetTemperateParam(string ipAddr)
{
ASTemperateParam temperate = null;
TemperateParamMap.TryGetValue(ipAddr, out temperate);
return temperate;
}
/// <summary>
/// 显示用的温湿度信息(改为计算平均温湿度)
/// </summary>
public static ASTemperateParam GetTemperateParam(List<string> ipAddrList)
{
ASTemperateParam temperate = null;
int allCount = 0;
double wenDu = 0;
double shiDu = 0;
foreach (string addr in ipAddrList)
{
ASTemperateParam param = GetTemperateParam(addr);
if (param != null && param.IsValid())
{
allCount++;
wenDu = wenDu + param.Temperate;
shiDu = shiDu + param.Humidity;
}
}
if (allCount > 0)
{
double avgWendu = Math.Round(wenDu / allCount, 1);
double avgShidu = Math.Round(shiDu / allCount, 1);
temperate = new ASTemperateParam(avgWendu, avgShidu);
}
return temperate;
}
public static double GetMaxHumidity(List<string> ipAddrList)
{
double maxValue = 0;
foreach (string addr in ipAddrList)
{
ASTemperateParam param = GetTemperateParam(addr);
if (param != null && param.IsValid())
{
if (param.Humidity > maxValue)
{
maxValue = param.Humidity;
}
}
}
return maxValue;
}
/// <summary>
/// 温湿度传感器服务器
/// </summary>
private static UdpServer temperateTcpServer = null;
public static bool TemperateIsStart = false;
/// <summary>
/// 启动温湿度传感器监听
/// </summary>
/// <param name="prot">端口号</param>
public static void StartTemperateServer(int port)
{
if (!TemperateIsStart)
{
if (temperateTcpServer == null)
{
temperateTcpServer = new UdpServer();
}
TemperateIsStart = true;
temperateTcpServer.Start(port);
LogUtil.info(LOGGER, "温湿度已开始在端口[" + port + "]监听!");
temperateTcpServer.ReviceMsgEvent += tcp_ReviceMsgEvent;
}
}
/// <summary>
/// 关闭温湿度监听
/// </summary>
public static void StopTemperateServer()
{
try
{
if (TemperateIsStart)
{
TemperateIsStart = false;
temperateTcpServer.Stop();
}
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "关闭温湿度监听出错:" + ex.ToString());
}
}
/// <summary>
/// 温湿度传感器 服务器回调函数
/// </summary>
private static void tcp_ReviceMsgEvent(EndPoint remote, string Msg)
{
IPEndPoint clientipe = (IPEndPoint)remote;
string add = clientipe.Address.ToString();
try
{
string[] strList = Msg.Split('+');
if (strList.Length == 12)
{
double wendu = double.Parse(strList[2]) / 10;
double shidu = double.Parse(strList[3]) / 10;
string deviceId = strList[10];
string pwd = strList[11];
LogUtil.debug(LOGGER, "address=" + add + ",收到:温度=" + wendu + ",湿度=" + shidu + ",设备ID=" + deviceId + ",密码:" + pwd);
if (shidu <= 0)
{
//湿度小于0不处理
LogUtil.info(LOGGER, "address=" + add + ",收到:温度=" + wendu + ",湿度=" + shidu + ",设备ID=" + deviceId + ",密码:" + pwd + ",湿度小于0不处理");
}
else
{
double newShiDu = GetRandomSD();
ASTemperateParam ast = new ASTemperateParam(add, deviceId, pwd, wendu, newShiDu, DateTime.Now);
if (TemperateParamMap.ContainsKey(add))
{
TemperateParamMap.Remove(add);
}
TemperateParamMap.Add(add, ast);
}
}
}
catch (Exception ex)
{
LogUtil.error(LOGGER, ex.ToString());
}
}
private static double PreShiDu = 7;
private static double PreWenDu = 25;
public static void RandomData(List<string> ipAddrList)
{
try
{
foreach (string IP in ipAddrList)
{
double newShiDu = GetRandomSD();
double newWenDu = GetRandomWD();
ASTemperateParam ast = new ASTemperateParam(IP, "", "", newWenDu, newShiDu, DateTime.Now);
if (TemperateParamMap.ContainsKey(IP))
{
TemperateParamMap.Remove(IP);
}
TemperateParamMap.Add(IP, ast);
//LogUtil.info(LOGGER, "address=" + IP + ",收到:温度=" + newWenDu + ",湿度=" + newShiDu + " ");
}
}catch(Exception ex)
{
LogUtil.error("温湿度数据保存出错:"+ex.ToString());
}
}
public static double GetRandomWD()
{
Random rd = new Random((int)DateTime.Now.Ticks + 99);
int num = rd.Next(-20, 20);
double newWendu = Math.Round(PreWenDu + (double)num / 1000F, 3);
if (newWendu > 25.5 || newWendu < 24.5)
{
newWendu = PreWenDu;
}
else
{
PreWenDu = newWendu;
}
return newWendu;
}
public static double GetRandomSD()
{
Random rd = new Random((int)DateTime.Now.Ticks);
int num = rd.Next(-100, 100);
double newShiDu = Math.Round(PreShiDu + (double)num / 1000F, 3);
if (newShiDu > 9.8 || newShiDu < 5.6)
{
newShiDu = PreShiDu;
}
else
{
PreShiDu = newShiDu;
}
return newShiDu;
}
}
/// <summary>
/// 奥松温湿度上传参数
/// </summary>
public class ASTemperateParam
{
public ASTemperateParam(string clientipe, string add, string pwd, double wendu, double shidu, DateTime updateTime)
{
this.IpAddress = clientipe;
this.DeviceAddress = add;
this.Password = pwd;
this.Temperate = wendu;
this.Humidity = shidu;
this.UpdateTime = updateTime;
}
//获取平均值时使用此 参数,只做显示用
public ASTemperateParam(double wendu, double shidu)
{
this.IpAddress = "";
this.DeviceAddress = "";
this.Password = "";
this.Temperate = wendu;
this.Humidity = shidu;
this.UpdateTime = DateTime.Now;
}
/// <summary>
/// 判断值是否在有效期内。默认有效期是一分钟
/// </summary>
/// <returns></returns>
public bool IsValid()
{
TimeSpan span = DateTime.Now - UpdateTime;
if (span.TotalMinutes > 3)
{
return false;
}
return true;
}
/// <summary>
/// 更新时间
/// </summary>
public DateTime UpdateTime { get; set; }
/// <summary>
/// IP地址
/// </summary>
public string IpAddress { get; set; }
/// <summary>
/// 设备地址
/// </summary>
public string DeviceAddress { get; set; }
/// <summary>
/// 访问密码
/// </summary>
public string Password { get; set; }
/// <summary>
/// 温度
/// </summary>
public double Temperate { get; set; }
/// <summary>
/// 湿度
/// </summary>
public double Humidity { get; set; }
}
}
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
namespace OnlineStore.Common
{
/// <summary>
/// Json帮助类
/// </summary>
public class JsonHelper
{
/// <summary>
/// 将对象序列化为JSON格式
/// </summary>
/// <param name="o">对象</param>
/// <returns>json字符串</returns>
public static string SerializeObject(object o)
{
string json = JsonConvert.SerializeObject(o);
return json;
}
/// <summary>
/// 解析JSON字符串生成对象实体
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json字符串(eg.{"ID":"112","Name":"石子儿"})</param>
/// <returns>对象实体</returns>
public static T DeserializeJsonToObject<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(T));
T t = o as T;
return t;
}
/// <summary>
/// 解析JSON数组生成对象实体集合
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json数组字符串(eg.[{"ID":"112","Name":"石子儿"}])</param>
/// <returns>对象实体集合</returns>
public static List<T> DeserializeJsonToList<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
List<T> list = o as List<T>;
return list;
}
/// <summary>
/// 反序列化JSON到给定的匿名对象.
/// </summary>
/// <typeparam name="T">匿名对象类型</typeparam>
/// <param name="json">json字符串</param>
/// <param name="anonymousTypeObject">匿名对象</param>
/// <returns>匿名对象</returns>
public static T DeserializeAnonymousType<T>(string json, T anonymousTypeObject)
{
T t = JsonConvert.DeserializeAnonymousType(json, anonymousTypeObject);
return t;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using System.Reflection;
using System.Drawing;
using System.Runtime.ExceptionServices;
using System.Collections.Concurrent;
using System.Threading;
namespace OnlineStore.Common
{
public class LogUtil
{
//public static readonly ILog AIOLog = LogManager.GetLogger("AIOBOX");
//private static LogUtil instance = new LogUtil();
public delegate void ShowLogDelegate(string msg, Color color);
public event ShowLogDelegate ShowLog;
public static readonly ILog LOGGER = LogManager.GetLogger("RollingLogFileAppender");
public static readonly ILog rfidLog = LogManager.GetLogger("RfidLog");
//public static readonly ILog timeCount = LogManager.GetLogger("Count");
public static ConcurrentDictionary<int, DateTime> lastErrorLogTime = new ConcurrentDictionary<int, DateTime>();
public static int showCount = 15;
public static bool debug_opened = false;
public static void info(ILog log, string msg)
{
if (log == null)
{
return;
}
log.Info(msg);
AddToBox(msg, Color.Black);
}
public static void info(ILog log, string msg, Color color)
{
log.Info(msg);
AddToBox(msg, color);
}
public static void debug(ILog log, string msg, Color color)
{
log.Debug(msg);
if (debug_opened)
{
AddToBox(msg, color);
}
}
public static void debug(ILog log, string msg)
{
log.Debug(msg);
if (debug_opened)
{
AddToBox(msg, Color.Gray);
}
}
public static void RfidLog(string msg)
{
rfidLog.Debug(msg);
}
public static void error(string errorMsg, int type, int seconds = 10)
{
try
{
if (lastErrorLogTime.ContainsKey(type))
{
TimeSpan span = DateTime.Now - lastErrorLogTime[type];
if (span.TotalSeconds > seconds)
{
lastErrorLogTime[type] = DateTime.Now;
error(LOGGER, errorMsg);
}
}
else
{
lastErrorLogTime.TryAdd(type, DateTime.Now);
error(LOGGER, errorMsg);
}
}
catch (Exception ex)
{
LOGGER.Error(" 打印日志【" + type + "-" + errorMsg + "】出错:" + ex.ToString());
}
}
public static void error(ILog log, string errorMsg, Exception ex = null)
{
if (errorMsg.Trim().Equals("") && (ex == null))
{
return;
}
if (ex == null)
{
log.Error(errorMsg);
}
else
{
log.Error(errorMsg, ex);
}
AddToBox(errorMsg, Color.Red);
}
private static object lockObj = "";
private static void AddToBox(string msg, Color color)
{
if (Monitor.TryEnter(lockObj, 2))
{
try
{
ShowLogPro(msg, color);
}
catch (Exception ex)
{
LOGGER.Error("出错:", ex);
}
finally
{
Monitor.Exit(lockObj);
}
}
else
{
LOGGER.Debug("ShowLogPro【" + msg + "】失败,未得到锁");
}
}
private static List<string> logList = new List<string>();
public static string LastText = "";
[HandleProcessCorruptedStateExceptions]
private static void ShowLogPro(string msg, Color color)
{
try
{
if (logList.Count >= showCount)
{
logList.RemoveAt(0);
}
string text = "";
foreach (string str in logList)
{
text += str;
}
System.DateTime now = System.DateTime.Now;
logList.Add(now.ToLongTimeString() + " " + msg + Environment.NewLine);
}
catch (AccessViolationException e)
{
LOGGER.Error(" ShowLogPro 出错:" + e.ToString());
}
catch (Exception ex)
{
LOGGER.Error("出错:" + ex.ToString());
}
}
private static DateTime lastTime = DateTime.Now;
public static void debug(string msg)
{
debug(LOGGER, msg);
}
public static void error(string errorMsg, Exception ex = null)
{
error(LOGGER, errorMsg, ex);
}
public static void info(string msg)
{
info(LOGGER, msg);
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Security;
using System.Reflection;
using System.Text;
namespace OnlineStore.Common
{
public class MyWebClient : WebClient
{
private int _timeout;
/// <summary>
/// 超时时间(毫秒)
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public MyWebClient()
{
this._timeout = 60000;
}
public MyWebClient(int timeout)
{
this._timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
HttpWebRequest result = (HttpWebRequest)base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}
}
public class HttpHelper
{
public static bool PingURLIP(string url, int ms = 100)
{
string[] urlArray = url.Split('/');
if (urlArray.Length > 3)
{
string ip = urlArray[2];
Ping pingSender = new Ping();
PingReply reply = pingSender.Send(ip, ms);//第一个参数为ip地址,第二个参数为ping的时间
if (reply.Status == IPStatus.Success)
{
//通
return true;
}
else
{
LogUtil.error("Ping IP " + ip + " : false");
//不通
return false;
}
}
return true;
}
public static string Post(string url, string paramData, int timeOut = 10000)
{
return Post(url, paramData, Encoding.UTF8, timeOut);
}
public static string Post(string url, string paramData, Encoding encoding, int timeOut = 10000)
{
string result = "";
if (url.ToLower().IndexOf("https", System.StringComparison.Ordinal) > -1)
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback((sender, certificate, chain, errors) => { return true; });
}
try
{
using (var wc = new MyWebClient(10000))
{
if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
{
wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
}
wc.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
wc.Encoding = encoding;
result = wc.UploadString(url, "POST", paramData);
}
//LogUtil.info(result);
}
catch (Exception e)
{
LogUtil.error("POST ERROR:" + e.ToString(), 101);
}
return result;
}
public static string Get(string url)
{
return Get(url, Encoding.UTF8);
}
public static string Get(string url, Encoding encoding, int timeOut = 10000)
{
try
{
LogUtil.debug("HTTP GET FROM: " + url);
using (var wc = new MyWebClient { Encoding = encoding })
{
var readStream = wc.OpenRead(url);
using (var sr = new StreamReader(readStream, encoding))
{
var result = sr.ReadToEnd();
LogUtil.debug("receive << " + result);
return result;
}
}
}
catch (Exception e)
{
LogUtil.error("HTTP GET ERROR:" + e.Message, 102);
}
return "";
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Net.Sockets;
using System.Net;
using System.IO;
using log4net;
using System.Text;
using OnlineStore.Common;
namespace OnlineStore
{
public class NetTCPServer
{
// public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// TCP服务端监听
/// </summary>
TcpListener tcpsever = null;
/// <summary>
/// 监听状态
/// </summary>
bool isListen = false;
public BindingList<NewClient> lstClient = new BindingList<NewClient>();
public IPAddress[] getLoacalIPAddress()
{
IPHostEntry ipHostEntry = Dns.GetHostEntry(Dns.GetHostName());
return ipHostEntry.AddressList;
}
public delegate void ReviceData(NewClient client, string ip, byte[] data);
public event ReviceData ReviceDataEvent;
/// <summary>
/// 开启TCP监听
/// </summary>
/// <returns></returns>
public void StartTCPServer(int port)
{
try
{
tcpsever = new TcpListener(IPAddress.Any, port);
tcpsever.Start();
tcpsever.BeginAcceptTcpClient(new AsyncCallback(Acceptor), tcpsever);
isListen = true;
}
catch (Exception ex)
{
}
}
/// <summary>
/// 停止TCP监听
/// </summary>
/// <returns></returns>
public void StopTCPServer()
{
tcpsever.Stop();
isListen = false;
}
/// <summary>
/// 客户端连接初始化
/// </summary>
/// <param name="o"></param>
private void Acceptor(IAsyncResult o)
{
TcpListener server = o.AsyncState as TcpListener;
try
{
//初始化连接的客户端
NewClient newClient = new NewClient();
newClient.tcpClient = server.EndAcceptTcpClient(o);
lstClient.Add(newClient);
newClient.tcpClient.GetStream().BeginRead(newClient.Buffer, 0, newClient.Buffer.Length, new AsyncCallback(TCPCallBack), newClient);
server.BeginAcceptTcpClient(new AsyncCallback(Acceptor), server);//继续监听客户端连接
}
catch (ObjectDisposedException ex)
{ //监听被关闭
}
catch (Exception ex)
{
}
}
/// <summary>
/// 对当前选中的客户端发送数据
/// </summary>
/// <param name="sender"></param>
/// <param name="data"></param>
public bool SendData(NewClient selClient, byte[] data)
{
try
{
selClient.tcpClient.GetStream().Write(data, 0, data.Length);
}
catch (Exception ex)
{
return false;
}
return true;
}
/// <summary>
/// 客户端通讯回调函数
/// </summary>
/// <param name="ar"></param>
private void TCPCallBack(IAsyncResult ar)
{
NewClient client = (NewClient)ar.AsyncState;
if (client.tcpClient.Connected)
{
NetworkStream ns = client.tcpClient.GetStream();
StreamReader sr = new StreamReader(ns);
string str = sr.ReadLine();
LogUtil.info("读取到数据:"+str);
byte[] recdata = new byte[ns.EndRead(ar)];
if (recdata.Length > 0)
{
//Array.Copy(client.Buffer, recdata, recdata.Length);
LogUtil.info("读取到数据1111:" + Encoding.ASCII.GetString(recdata));
//ns.BeginRead(client.Buffer, 0, client.Buffer.Length, new AsyncCallback(TCPCallBack), client);
}
else
{
client.tcpClient.Close();
lstClient.Remove(client);
}
}
}
/// <summary>
/// 清理
/// </summary>
public void ClearSelf()
{
foreach (NewClient client in lstClient)
{
client.tcpClient.Close();
}
lstClient.Clear();
if (tcpsever != null)
{
tcpsever.Stop();
}
}
}
public class NewClient
{
public TcpClient tcpClient { get; set; }
public byte[] Buffer = new byte[1024];
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace OnlineStore.Common
{
/// <summary>
/// 扫码枪连接类
/// </summary>
public class ScanSocket
{
private readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public event ScanRevice OnScanRevice;
public delegate void ScanRevice(string message);
/// <summary>
/// 扫码枪链接
/// </summary>
private TcpClient scannerSocket;
/// <summary>
/// 扫描枪 是否开始运行
/// </summary>
public bool isScannerRun = false;
/// <summary>
/// 连接扫码枪
/// </summary>
/// <param name="serverIp">扫码枪Ip</param>
/// <param name="port">扫码枪端口号</param>
/// <returns>是否连接成功</returns>
public bool ConnectScanner(string serverIp, int port)
{
return StartScanner(serverIp, port, false);
}
/// <summary>
/// 停止扫码枪
/// </summary>
public void StopScanner()
{
try
{
scannerSocket.close();
isScannerRun = false;
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "出错:" + ex);
}
}
/// <summary>
/// 发送扫码命令开始扫码
/// </summary>
public void BeginScannering()
{
string str = ConfigAppSettings.GetValue(Setting_Init.scanner_start_command);
if (str.Equals(""))
{
str = "S";
}
scannerSocket.send(str);
//onCodeReceived("AAAA");
}
/// <summary>
/// 开启扫码枪
/// </summary>
private bool StartScanner(string serverIp, int port, bool isMustCon)
{
bool result = true;
try
{
if (!isScannerRun || isMustCon)
{
if (scannerSocket == null)
{
scannerSocket = new TcpClient();
}
result = scannerSocket.connect(serverIp, port, new TcpClient.HandleMessage(onCodeReceived));
if (result)
{
isScannerRun = true;
}
}
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "出错:" + ex);
}
return result;
}
/// <summary>
/// 扫码枪数据接收
/// </summary>
/// <param name="message"></param>
private void onCodeReceived(string message)
{
try
{
message = ScanCodeManager.ReplaceCode(message);
if (OnScanRevice != null)
{
OnScanRevice.Invoke(message);
}
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "出错:" + ex.ToString());
}
}
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
namespace OnlineStore.Common
{
public class SerialBean
{
#region 全部变量
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private SerialPort _serialPort = null;
//定义委托
public delegate void SerialPortDataReceiveEventArgs(string portName, object sender, SerialDataReceivedEventArgs e, byte[] bits);
//定义接收数据事件
public event SerialPortDataReceiveEventArgs DataReceived;
//定义接收错误事件
//public event SerialErrorReceivedEventHandler Error;
//接收事件是否有效 false表示有效
public bool ReceiveEventFlag = false;
#endregion
#region 获取串口名
private string protName;
public string PortName
{
get { return _serialPort.PortName; }
set
{
_serialPort.PortName = value;
protName = value;
}
}
#endregion
#region 获取比特率
private int baudRate;
public int BaudRate
{
get { return _serialPort.BaudRate; }
set
{
_serialPort.BaudRate = value;
baudRate = value;
}
}
#endregion
#region 默认构造函数
///// <summary>
///// 默认构造函数,操作COM1,速度为9600,没有奇偶校验,8位字节,停止位为1 "COM1", 9600, Parity.None, 8, StopBits.One
///// </summary>
//public SerialBean()
//{
// _serialPort = new SerialPort();
//}
#endregion
#region 构造函数
///// <summary>
///// 构造函数,
///// </summary>
///// <param name="comPortName"></param>
//public SerialBean(string comPortName)
//{
// _serialPort = new SerialPort(comPortName);
// _serialPort.BaudRate = 9600;
// _serialPort.Parity = Parity.Even;
// _serialPort.DataBits = 8;
// _serialPort.StopBits = StopBits.One;
// _serialPort.Handshake = Handshake.None;
// _serialPort.RtsEnable = true;
// _serialPort.ReadTimeout = 2000;
// setSerialPort();
//}
#endregion
#region 构造函数,可以自定义串口的初始化参数
/// <summary>
/// 构造函数,可以自定义串口的初始化参数
/// </summary>
/// <param name="comPortName">需要操作的COM口名称</param>
/// <param name="baudRate">COM的速度</param>
/// <param name="parity">奇偶校验位</param>
/// <param name="dataBits">数据长度</param>
/// <param name="stopBits">停止位</param>
public SerialBean(string comPortName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
{
_serialPort = new SerialPort(comPortName, baudRate, parity, dataBits, stopBits);
_serialPort.RtsEnable = true; //自动请求
_serialPort.ReadTimeout = 3000;//超时
setSerialPort();
}
#endregion
#region 析构函数
/// <summary>
/// 析构函数,关闭串口
/// </summary>
~SerialBean()
{
if (_serialPort.IsOpen)
_serialPort.Close();
}
#endregion
#region 设置串口参数
/// <summary>
/// 设置串口参数
/// </summary>
/// <param name="comPortName">需要操作的COM口名称</param>
/// <param name="baudRate">COM的速度</param>
/// <param name="dataBits">数据长度</param>
/// <param name="stopBits">停止位</param>
public void setSerialPort(string comPortName, int baudRate, int dataBits, int stopBits)
{
if (_serialPort.IsOpen)
_serialPort.Close();
_serialPort.PortName = comPortName;
_serialPort.BaudRate = baudRate;
_serialPort.Parity = Parity.None;
_serialPort.DataBits = dataBits;
_serialPort.StopBits = (StopBits)stopBits;
_serialPort.Handshake = Handshake.None;
_serialPort.RtsEnable = false;
_serialPort.ReadTimeout = 3000;
_serialPort.NewLine = "/r/n";
setSerialPort();
}
#endregion
#region 设置接收函数
/// <summary>
/// 设置串口资源,还需重载多个设置串口的函数
/// </summary>
void setSerialPort()
{
if (_serialPort != null)
{
//设置触发DataReceived事件的字节数为1
_serialPort.ReceivedBytesThreshold = 1;
//接收到一个字节时,也会触发DataReceived事件
_serialPort.DataReceived += new SerialDataReceivedEventHandler(_serialPort_DataReceived);
//接收数据出错,触发事件
_serialPort.ErrorReceived += new SerialErrorReceivedEventHandler(_serialPort_ErrorReceived);
//打开串口
//openPort();
}
}
#endregion
#region 打开串口资源
/// <summary>
/// 打开串口资源
/// <returns>返回bool类型</returns>
/// </summary>
public bool openPort()
{
bool ok = false;
//如果串口是打开的,先关闭
if (_serialPort.IsOpen)
_serialPort.Close();
try
{
//打开串口
_serialPort.Open();
ok = true;
}
catch (Exception Ex)
{
LogUtil.error(LOGGER, Ex.ToString());
//throw Ex;
}
return ok;
}
#endregion
#region 关闭串口
/// <summary>
/// 关闭串口资源,操作完成后,一定要关闭串口
/// </summary>
public void closePort()
{
//如果串口处于打开状态,则关闭
if (_serialPort.IsOpen)
_serialPort.Close();
}
public void clearInBuffer()
{
if (_serialPort.IsOpen)
{
_serialPort.DiscardInBuffer();
}
}
public void clearOutBuffer()
{
if (_serialPort.IsOpen)
{
_serialPort.DiscardOutBuffer();
}
}
#endregion
#region 接收串口数据事件
private object LockReviceObj = "";
/// <summary>
/// 接收串口数据事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void _serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
lock (LockReviceObj)
{
//禁止接收事件时直接退出
if (ReceiveEventFlag)
{
return;
}
try
{
System.Threading.Thread.Sleep(20);
byte[] _data = new byte[_serialPort.BytesToRead];
_serialPort.Read(_data, 0, _data.Length);
if (_data.Length == 0) { return; }
if (DataReceived != null)
{
DataReceived(_serialPort.PortName, sender, e, _data);
}
_serialPort.DiscardInBuffer(); //清空接收缓冲区
}
catch (Exception ex)
{
LogUtil.error(LOGGER, ex.ToString());
}
}
}
#endregion
#region 接收数据出错事件
/// <summary>
/// 接收数据出错事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void _serialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
{
}
#endregion
/// <summary>
/// 发送命令
/// </summary>
/// <param name="SendData">发送数据</param>
/// <param name="ReceiveData">接收数据</param>
/// <param name="Overtime">超时时间</param>
/// <param name="ReceiveLength">接收数据长度</param>
/// <returns></returns>
public int SendCommand(byte[] SendData, ref byte[] ReceiveData, int Overtime, int ReceiveLength)
{
if (_serialPort.IsOpen)
{
try
{
lock (LockReviceObj)
{
ReceiveEventFlag = true; //关闭接收事件
_serialPort.DiscardInBuffer(); //清空接收缓冲区
_serialPort.Write(SendData, 0, SendData.Length);
int num = 0, ret = 0;
System.Threading.Thread.Sleep(10);
ReceiveEventFlag = false; //打开事件
if (ReceiveData == null)
{
ReceiveData = new byte[ReceiveLength];
}
while (num++ < Overtime)
{
if (_serialPort.BytesToRead >= ReceiveData.Length)
break;
System.Threading.Thread.Sleep(10);
}
if (_serialPort.BytesToRead >= ReceiveData.Length)
{
ret = _serialPort.Read(ReceiveData, 0, ReceiveData.Length);
}
else
{
ret = _serialPort.Read(ReceiveData, 0, _serialPort.BytesToRead);
}
ReceiveEventFlag = false; //打开事件
return ret;
}
}
catch (Exception ex)
{
ReceiveEventFlag = false;
throw ex;
}
}
return -1;
}
#region 发送数据string类型
public void SendData(string data)
{ //发送数据
//禁止接收事件时直接退出
if (ReceiveEventFlag)
{
return;
}
if (_serialPort.IsOpen)
{
_serialPort.Write(data);
}
}
#endregion
#region 发送数据byte类型
/// <summary>
/// 数据发送
/// </summary>
/// <param name="data">要发送的数据字节</param>
public void SendData(byte[] data, int offset, int count)
{
string strSend = "";
for (int i = 0; i < data.Length; i++)
{
strSend += string.Format("{0:X2} ", data[i]);
}
LOGGER.Debug("【" + _serialPort.PortName + "】发送数据【" + strSend + "】");
//禁止接收事件时直接退出
if (ReceiveEventFlag)
{
return;
}
try
{
if (_serialPort.IsOpen)
{
//_serialPort.DiscardInBuffer();//清空接收缓冲区
_serialPort.Write(data, offset, count);
}
}
catch (Exception ex)
{
_serialPort.DiscardOutBuffer();
throw ex;
}
}
#endregion
#region 发送命令
/// <summary>
/// 发送命令
/// </summary>
/// <param name="SendData">发送数据</param>
/// <param name="ReceiveData">接收数据</param>
/// <param name="Overtime">超时时间</param>
/// <returns></returns>
public int SendCommand(byte[] SendData, ref byte[] ReceiveData, int Overtime)
{
if (_serialPort.IsOpen)
{
try
{
ReceiveEventFlag = true; //关闭接收事件
_serialPort.DiscardInBuffer(); //清空接收缓冲区
_serialPort.Write(SendData, 0, SendData.Length);
int num = 0, ret = 0;
System.Threading.Thread.Sleep(10);
ReceiveEventFlag = false; //打开事件
while (num++ < Overtime)
{
if (_serialPort.BytesToRead >= ReceiveData.Length)
break;
System.Threading.Thread.Sleep(10);
}
if (_serialPort.BytesToRead >= ReceiveData.Length)
{
ret = _serialPort.Read(ReceiveData, 0, ReceiveData.Length);
}
else
{
ret = _serialPort.Read(ReceiveData, 0, _serialPort.BytesToRead);
}
ReceiveEventFlag = false; //打开事件
return ret;
}
catch (Exception ex)
{
ReceiveEventFlag = false;
throw ex;
}
}
return -1;
}
#endregion
#region 获取串口
/// <summary>
/// 获取所有已连接短信猫设备的串口
/// </summary>
/// <returns></returns>
public string[] serialsIsConnected()
{
List<string> lists = new List<string>();
string[] seriallist = getSerials();
foreach (string s in seriallist)
{
}
return lists.ToArray();
}
#endregion
#region 获取当前全部串口资源
/// <summary>
/// 获得当前电脑上的所有串口资源
/// </summary>
/// <returns></returns>
public string[] getSerials()
{
return SerialPort.GetPortNames();
}
#endregion
#region 字节型转换16
/// <summary>
/// 把字节型转换成十六进制字符串
/// </summary>
/// <param name="InBytes"></param>
/// <returns></returns>
public static string ByteToString(byte[] InBytes)
{
string StringOut = "";
foreach (byte InByte in InBytes)
{
StringOut = StringOut + String.Format("{0:X2} ", InByte);
}
return StringOut;
}
#endregion
#region 十六进制字符串转字节型
/// <summary>
/// 打包方法,可以将十六制字符串转成byte[] ,字符串没有空格
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
//public static byte[] StringToByte(string s)
//{
// string temps = ReplaceSpace(s);
// if (temps.Length % 2 != 0)
// {
// temps = "0" + temps;
// }
// byte[] tempb = new byte[50];
// int j = 0;
// for (int i = 0; i < temps.Length; i = i + 2, j++)
// {
// tempb[j] = Convert.ToByte(temps.Substring(i, 2), 16);
// }
// byte[] send = new byte[j];
// Array.Copy(tempb, send, j);
// return send;
//}
//除去空格
public static string ReplaceSpace(string str)
{
string putout = "";
for (int i = 0; i < str.Length; i++)
{
if (str[i] != ' ')
{ putout += str[i]; }
}
return putout;
}
#endregion
#region 字节型转十六进制字符串
/// <summary>
/// 字节数组转16进制字符串
/// </summary>
/// <param name="bytes"></param>
/// <returns></returns>
public static string byteToHexStr(byte[] bytes)
{
string returnStr = "";
if (bytes != null)
{
for (int i = 0; i < bytes.Length; i++)
{
returnStr += bytes[i].ToString("X2");
}
}
return returnStr;
}
#endregion
#region 计算校验码
public static void CalculateBCC(byte[] pByte, int nNumberOfBytes, out ushort pChecksum)
{
byte check = 0;
check = (byte)(pByte[0] ^ (pByte[1]));
for (int i = 2; i < pByte.Length; i++)
{
check = (byte)(check ^ (pByte[i]));
}
pChecksum = check;
}
//public static void CalculateCRC(byte[] pByte, int nNumberOfBytes, out ushort pChecksum)
//{
// int nBit;
// ushort nShiftedBit;
// pChecksum = 0xFFFF;
// for (int nByte = 0; nByte < nNumberOfBytes; nByte++)
// {
// pChecksum ^= pByte[nByte];
// for (nBit = 0; nBit < 8; nBit++)
// {
// if ((pChecksum & 0x1) == 1)
// {
// nShiftedBit = 1;
// }
// else
// {
// nShiftedBit = 0;
// }
// pChecksum >>= 1;
// if (nShiftedBit != 0)
// {
// pChecksum ^= 0xA001;
// }
// }
// }
//}
#endregion
}
}
using System;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Collections.Concurrent;
namespace OnlineStore.Common
{
public class TcpServer
{
// public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// 接受消息时的间隔
/// </summary>
public static int ReviceMsgMS = 10;
private Thread m_serverThread;
private Socket m_serverSocket;
public delegate void ReviceMsg(TcpClientBean client, string Msg);
public event ReviceMsg ReviceMsgEvent;
private delegate void ReceiveMessageDelegate(TcpClientBean client);
public event AcceptClientDelegate AcceptClientEvent;
public delegate void AcceptClientDelegate(TcpClientBean client);
ReceiveMessageDelegate receiveMessageDelegate;
private bool isRun = true;
private int serverPort = 0;
private void logLocalIp()
{
string[] addresses = GetLocalAddresses();
string iplist = "本机IP:[";
if (addresses.Length > 0)
{
for (int i = 0; i < addresses.Length; i++)
{
if (addresses.Length != 0)
{
iplist = iplist + " " + addresses[i];
}
}
}
LogUtil.info( iplist + "]");
}
/// <summary>
/// 开始服务
/// </summary>
public void Start(int m_serverPort)
{
try
{
isRun = true;
m_serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, m_serverPort);
this.serverPort = m_serverPort;
m_serverSocket.Bind(localEndPoint);
m_serverSocket.Listen(10);
m_serverThread = new Thread(new ThreadStart(ReceiveAccept));
m_serverThread.Start();
LogUtil.info( " Server start listen : " + m_serverPort);
logLocalIp();
//this.AddRunningInfo(">> " + DateTime.Now.ToString() + " Server started.");
}
catch (SocketException se)
{
throw new Exception(se.Message);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
/// <summary>
/// 停止服务
/// </summary>
public void Stop()
{
try
{
isRun = false;
m_serverThread.Interrupt(); // 线程终止
m_serverSocket.Close(); // Socket Close
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
private void ReceiveAccept()
{
while (isRun)
{
TcpClientBean client = new TcpClientBean();
try
{
client.ClientSocket = m_serverSocket.Accept();
IPEndPoint clientipe = (IPEndPoint)client.ClientSocket.RemoteEndPoint;
client.AddStr = clientipe.Address.ToString()+":"+clientipe.Port.ToString();
LogUtil.info( "["+serverPort+"]有新的客户端链接上:[" + client.AddStr+"]");
AcceptClientEvent?.Invoke(client);
receiveMessageDelegate = new ReceiveMessageDelegate(ReceiveMessages);
receiveMessageDelegate.BeginInvoke(client, ReceiveMessagesCallback, "");
}
catch (Exception ex)
{
LogUtil.error( "ReceiveAccept方法,客户端【"+client.AddStr+"】:" + ex.Message);
//throw new Exception(ex.Message);
}
}
}
// private StringBuilder sb = new StringBuilder(); //这个是用来保存:接收到了的,但是还没有结束的消息
private int receiveBufferSize = 1024;
private string terminateString = "\r";
public void ReceiveMessages(TcpClientBean client) //这个函数会被以线程方式运行
{
try
{
StringBuilder sb = new StringBuilder();
Socket socket = (Socket)client.ClientSocket;
while (true)
{
byte[] buffer = new byte[receiveBufferSize]; //buffer大小,此处为1024
int receivedSize = socket.Receive(buffer);
if (receivedSize > 0)
{
string rawMsg = Encoding.ASCII.GetString(buffer, 0, receivedSize);
int rnFixLength = terminateString.Length; //这个是指消息结束符的长度,此处为\r\n
for (int i = 0; i < rawMsg.Length;) //遍历接收到的整个buffer文本
{
if (i <= rawMsg.Length - rnFixLength)
{
if (rawMsg.Substring(i, rnFixLength) != terminateString)//非消息结束符,则加入sb
{
sb.Append(rawMsg[i]);
i++;
}
else
{
this.ReviceMsgEvent.Invoke(client, sb.ToString());//找到了消息结束符,触发消息接收完成事件
sb = new StringBuilder();
i += rnFixLength;
}
}
else
{
sb.Append(rawMsg[i]);
i++;
}
}
}
Thread.Sleep(ReviceMsgMS);
}
}
catch (SocketException e)
{
LogUtil.error("客户端{" + client.AddStr + "]:" + e.ToString(), 106);
}
catch (Exception ex)
{
LogUtil.error("客户端{" + client.AddStr + "]:" + ex.ToString(), 105);
}
}
//private void ReceiveMessages(Client client)
//{
// try
// {
// while (true)
// {
// byte[] receiveBuffer = new byte[1024];
// //int size = ;
// int size = client.ClientSocket.Receive(receiveBuffer);
// string strReceiveData = Encoding.ASCII.GetString(receiveBuffer, 0, size);
// if (!string.IsNullOrEmpty(strReceiveData))
// {
// LogUtil.info(LOGGER, "收到数据:" + strReceiveData);
// // this.AddRunningInfo(">> Receive data from [" + client.ClientSocket.RemoteEndPoint.ToString()+ "]:" + strReceiveData);
// string strSendData = "OK. The content is:" + strReceiveData;
// //LogUtil.info(LOGGER, "OK. The content is:" + strReceiveData);
// int sendBufferSize = Encoding.Unicode.GetByteCount(strSendData);
// byte[] sendBuffer = new byte[sendBufferSize];
// sendBuffer = Encoding.Unicode.GetBytes(strSendData);
// client.ClientSocket.Send(sendBuffer);
// }
// }
// }
// catch (SocketException e)
// {
// LogUtil.error(LOGGER, e.ToString());
// }
// catch (Exception ex)
// {
// LOGGER.Error(ex.ToString());
// }
//}
private void ReceiveMessagesCallback(IAsyncResult AR)
{
try
{
receiveMessageDelegate.EndInvoke(AR);
}
catch (Exception ex)
{
LogUtil.error(ex.ToString());
}
}
/// <summary>
/// 获取本机地址列表
/// </summary>
public string[] GetLocalAddresses()
{
// 获取主机名
string strHostName = Dns.GetHostName();
// 根据主机名进行查找
IPHostEntry iphostentry = Dns.GetHostEntry(strHostName);
string[] retval = new string[iphostentry.AddressList.Length];
int i = 0;
foreach (IPAddress ipaddress in iphostentry.AddressList)
{
if (ipaddress.AddressFamily != AddressFamily.InterNetworkV6)
{
retval[i] = ipaddress.ToString();
i++;
}
}
return retval;
}
}
/// <summary>
/// 客户端会话信息类
/// </summary>
public class TcpClientBean
{
Socket m_clientSocket;
public TcpClientBean() { }
public string AddStr = "";
public Socket ClientSocket
{
get { return m_clientSocket; }
set { this.m_clientSocket = value; }
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace OnlineStore.Common
{
public class UdpServer
{
// public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Thread m_serverThread;
private Socket udpServer;
public delegate void ReviceMsg(EndPoint address, string Msg);
/// <summary>
/// 接受到数据事件
/// </summary>
public event ReviceMsg ReviceMsgEvent;
private bool isRun = true;
private void logLocalIp()
{
string[] addresses = GetLocalAddresses();
string iplist = "本机IP:[";
if (addresses.Length > 0)
{
for (int i = 0; i < addresses.Length; i++)
{
if (addresses.Length != 0)
{
iplist = iplist + " " + addresses[i];
}
}
}
LogUtil.info( iplist + "]");
}
/// <summary>
/// 开始服务
/// </summary>
public void Start(int m_serverPort)
{
try
{
IPEndPoint ipep = new IPEndPoint(IPAddress.Any, m_serverPort);//定义一网络端点
udpServer = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);//定义一个Socket
udpServer.Bind(ipep);//Socket与本地的一个终结点相关联
m_serverThread = new Thread(new ThreadStart(ReceiveData));
m_serverThread.Start();
logLocalIp();
isRun = true;
}
catch (Exception ex)
{
LogUtil.error("启动udpserver出错:" + ex.ToString());
}
}
/// <summary>
/// 停止服务
/// </summary>
public void Stop()
{
try
{
isRun = false;
m_serverThread.Interrupt(); // 线程终止
udpServer.Close(); // Socket Close
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
private StringBuilder sb = new StringBuilder(); //这个是用来保存:接收到了的,但是还没有结束的消息
private int receiveBufferSize = 1024;
private string terminateString = "\r";
private void ReceiveData()
{
try
{
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);//定义要发送的计算机的地址
EndPoint Remote = (EndPoint)(sender);//
while (true)
{
byte[] buffer = new byte[receiveBufferSize];
int receivedSize = udpServer.ReceiveFrom(buffer, ref Remote);
if (receivedSize > 0)
{
string rawMsg = Encoding.ASCII.GetString(buffer, 0, receivedSize);
int rnFixLength = terminateString.Length; //这个是指消息结束符的长度,此处为\r\n
for (int i = 0; i < rawMsg.Length; ) //遍历接收到的整个buffer文本
{
if (i <= rawMsg.Length - rnFixLength)
{
if (rawMsg.Substring(i, rnFixLength) != terminateString)//非消息结束符,则加入sb
{
sb.Append(rawMsg[i]);
i++;
}
else
{
this.ReviceMsgEvent.Invoke(Remote, sb.ToString());//找到了消息结束符,触发消息接收完成事件
sb = new StringBuilder();
i += rnFixLength;
}
}
else
{
sb.Append(rawMsg[i]);
i++;
}
}
}
Thread.Sleep(500);
}
}
catch (Exception ex)
{
LogUtil.error("启动udpserver出错:" + ex.ToString());
}
}
/// <summary>
/// 获取本机地址列表
/// </summary>
public string[] GetLocalAddresses()
{
// 获取主机名
string strHostName = Dns.GetHostName();
// 根据主机名进行查找
IPHostEntry iphostentry = Dns.GetHostEntry(strHostName);
string[] retval = new string[iphostentry.AddressList.Length];
int i = 0;
foreach (IPAddress ipaddress in iphostentry.AddressList)
{
if (ipaddress.AddressFamily != AddressFamily.InterNetworkV6)
{
retval[i] = ipaddress.ToString();
i++;
}
}
return retval;
}
}
}
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class AxisBean
{
public ConfigMoveAxis Config = null;
public static int TimeoutInterval = 500;
/// <summary>
/// 正常工作过程中判断位置是否到达时使用
/// </summary>
public int LastPosition = 0;
public string AxisName;
public AxisBean(ConfigMoveAxis axisConfig, string deviceName)
{
this.Config = axisConfig;
AxisName = deviceName + " " + Config.Explain + "[" + Config.DeviceName + "-" + Config.GetAxisValue() + "]";
}
private bool IsIntSlvBlock = false;
public bool Open(bool isCheck, out string Msg)
{
Msg = "";
string portName = Config.DeviceName;
short slvAddr = Config.GetAxisValue();
AxisManager.AlarmClear(portName, slvAddr);
Thread.Sleep(50);
AxisManager.ServoOn(portName, slvAddr);
Thread.Sleep(1000);
//打开所有轴
if (isCheck)
{
if (!OpenAxis(out Msg))
{
return false;
}
}
IsIntSlvBlock = true;
return true;
}
/// <summary>
/// 打开所有轴
/// </summary>
/// <returns></returns>
private bool OpenAxis(out string msg)
{
msg = "";
//判断轴是否正常
string portName = Config.DeviceName;
short slvAddr = Config.GetAxisValue();
if (AxisManager.IsServeoOn(portName, slvAddr))
{
LogUtil.info(AxisName + "成功打开");
}
else
{
//清理报警,再重新打开一次
LogUtil.info(AxisName + "第一次打开失败,先清理一下报警,再重新打开一次");
AxisManager.AlarmClear(portName, slvAddr);
System.Threading.Thread.Sleep(1000);
AxisManager.ServoOn(portName, slvAddr);
System.Threading.Thread.Sleep(100);
if (AxisManager.IsServeoOn(portName, slvAddr))
{
LogUtil.info(AxisName + "清理报警后重新打卡轴成功:" + Config.Explain);
}
else
{
AxisManager.ServoOff(portName, slvAddr);
msg = "打开轴" + Config.Explain + "失败 ";
LogUtil.info(AxisName + msg);
return false;
}
}
return true;
}
public void ServoOff()
{
LogUtil.info("ServoOff【" + AxisName + "】");
AxisManager.ServoOff(Config.DeviceName, Config.GetAxisValue());
}
public void HomeMove(MoveInfo MoveInfo)
{
Config.TargetPosition = 0;
LogUtil.info(AxisName + "speed[" + Config.HomeHighSpeed + "]开始原点返回");
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(Config, true));
AxisManager.HomeMove(Config.DeviceName, (short)Config.GetAxisValue(), Config.HomeHighSpeed, Config.HomeLowSpeed, Config.HomeAddSpeed);
}
/// <summary>
/// 松下伺服电机运动
/// </summary>
public void AbsMove(MoveInfo MoveInfo, int targetPosition, int targetSpeed)
{
if (MoveInfo == null)
{
AbsMove(targetPosition, targetSpeed);
}
else
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(Config, targetPosition, targetSpeed));
Config.TargetPosition = targetPosition;
AxisManager.AbsMove(Config.DeviceName, Config.GetAxisValue(), targetPosition, targetSpeed, Config.AddSpeed, Config.DelSpeed);
}
}
/// <summary>
/// 判断AC伺服电机轴是否运动完成
/// </summary>
public static bool ACAxisMoveIsEnd(MoveInfo MoveInfo, ConfigMoveAxis axis, int targetPosition, int targetSpeed, out string msg)
{
msg = "";
string deviceName = axis.DeviceName;
short axisNo = axis.GetAxisValue();
bool isOk = AxisManager.GetBusyStatus(deviceName, axisNo).Equals(0);
int outCount = AxisManager.GetActualtPosition(deviceName, axisNo);
int errorCount = Math.Abs(outCount - targetPosition);
if (isOk)
{
if (errorCount <= axis.CanErrorCountMax)
{
return true;
}
//判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0)
{
string clearMsg = "";
//判断轴是否报警
if (MoveInfo.CanWhileCount <= 3)
{
int isAlarm = AxisManager.GetAlarmStatus(deviceName, axisNo);
if (isAlarm.Equals(1))
{
clearMsg = "清理报警,";
AxisManager.AlarmClear(deviceName, axisNo);
Thread.Sleep(200);
AxisManager.ServoOn(deviceName, axisNo);
Thread.Sleep(500);
}
}
if (String.IsNullOrEmpty(clearMsg))
{
AxisManager.SuddenStop(axis.DeviceName, axis.GetAxisValue());
Thread.Sleep(100);
}
LogUtil.error(MoveInfo.Name + axis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount +
"],误差过大," + clearMsg + "重新开始运动,剩余[" + MoveInfo.CanWhileCount + "]次");
AxisManager.AbsMove(axis.DeviceName, axis.GetAxisValue(), targetPosition, targetSpeed, axis.AddSpeed, axis.DelSpeed);
MoveInfo.CanWhileCount--;
Thread.Sleep(200);
}
else
{
msg = " " + MoveInfo.SLog + MoveInfo.Name + axis.DisplayStr + ",目标位置[" + targetPosition + "]当前位置[" + outCount
+ "],误差过大,需要报警";
LogUtil.error(msg, 600);
}
}
return false;
}
public static bool HomeMoveIsEnd(MoveInfo MoveInfo, ConfigMoveAxis axis, out string msg)
{
msg = "";
if (AxisManager.IsHomeMoveEnd(axis.DeviceName, axis.GetAxisValue()))
{
//原点完成并且位置=0
int outCount = AxisManager.GetActualtPosition(axis.DeviceName, axis.GetAxisValue());
int errorCount = Math.Abs(outCount);
if (errorCount <= axis.CanErrorCountMax)
{
return true;
}
//判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0)
{
LogUtil.error(MoveInfo.Name + axis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],重新回原点,剩余[" + MoveInfo.CanWhileCount + "]次");
//LogUtil.error( StoreName + moveAxis.DisplayStr + "重新回原点");
AxisManager.HomeMove(axis.DeviceName, axis.GetAxisValue(), axis.HomeHighSpeed, axis.HomeLowSpeed, axis.HomeAddSpeed);
MoveInfo.CanWhileCount--;
}
else
{
msg = MoveInfo.Name + " " + MoveInfo.SLog + axis.DisplayStr + ",收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警";
LogUtil.error(msg);
}
}
return false;
}
public int GetAclPosition()
{
int p = AxisManager.GetActualtPosition(Config.DeviceName, Config.GetAxisValue());
return p;
}
public bool IsInPosition(int targetP)
{
int currp = GetAclPosition();
int chaz = targetP - currp;
if (Math.Abs(chaz) < Config.CanErrorCountMax)
{
return true;
}
return false;
}
/// <summary>
/// 绝对运动至点,不等待结果
/// </summary>
private void AbsMove(int targetPos, double targetSpeed)
{
if (targetPos.Equals(-1))
{
return;
}
LastPosition = -1;
if (targetSpeed > Config.TargetSpeed || targetSpeed <= 0)
{
targetSpeed = Config.TargetSpeed;
}
//小于1,表示是目标速度的百分比
else if (targetSpeed <= 1)
{
targetSpeed = Config.TargetSpeed * targetSpeed;
}
AxisManager.AbsMove(Config.DeviceName, Config.GetAxisValue(), targetPos, (int)targetSpeed, Config.AddSpeed, Config.DelSpeed);
}
public void SuddenStop()
{
AxisManager.SuddenStop(Config.DeviceName, Config.GetAxisValue());
}
#region 匀速上升处理
private System.Timers.Timer axisCheckTimer = null;
internal string TargetIoType = "";
internal IO_VALUE TargetIoValue = IO_VALUE.HIGH;
public bool BatchAxisStartCheck(string targetIo, IO_VALUE value = IO_VALUE.HIGH)
{
if (String.IsNullOrEmpty(targetIo))
{
targetIo = "";
}
if (axisCheckTimer == null)
{
axisCheckTimer = new System.Timers.Timer();
axisCheckTimer.AutoReset = true;
axisCheckTimer.Interval += 30;
axisCheckTimer.Elapsed += CheckTimer_Elapsed;
axisCheckTimer.Enabled = false;
}
TargetIoValue = value;
TargetIoType = targetIo;
IsInProcess = false;
axisCheckTimer.Start();
return true;
}
public bool StopAxisCheckMove()
{
if (!(axisCheckTimer == null))
{
axisCheckTimer.Stop();
}
return true;
}
private bool IsInProcess = false;
private DateTime lastOkTime = DateTime.Now;
private void CheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
TimeSpan pan = DateTime.Now - lastOkTime;
if (IsInProcess && pan.TotalMilliseconds < 100) { return; }
try
{
IsInProcess = true;
lastOkTime = DateTime.Now;
if (IOManager.IOValue(TargetIoType).Equals(TargetIoValue))
{
StopAxisCheckMove();
LogUtil.info(AxisName + "上料轴,检测到 " + TargetIoType + "=" + TargetIoValue + ",停止运动");
SuddenStop();
}
}
catch (Exception ex)
{
LogUtil.error("CheckTimer_Elapsed出错:", ex);
}
finally
{
IsInProcess = false;
}
}
#endregion
public static bool RunMultiAxis(bool isCheck, out string msg, params AxisBean[] axisArray)
{
msg = "";
foreach (AxisBean axis in axisArray)
{
bool result = axis.Open(false, out msg);
if (!result || (!String.IsNullOrEmpty(msg)))
{
//SetWarnMsg(Name + msg);
//Alarm(AlarmType.AxisAlarm);
return false;
}
}
Thread.Sleep(500);
return true;
}
public static void CloseMultiAxis(params AxisBean[] axisArray)
{
foreach (AxisBean axis in axisArray)
{
axis.SuddenStop();
Thread.Sleep(50);
axis.ServoOff();
}
}
}
}
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public interface IRobot
{
//List<ConfigMoveAxis> moveAxisList { get; set; }
Robot_Config config { get; set; }
string Name { get; set; }
bool canRunning { get; set; }
bool isBusy { get; set; }
bool isAlarm { get; set; }
RunStatus runStatus { get; set; }
void Run();
}
public enum RunStatus
{
Stop,
Running,
HomeReset
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class LabelParam
{
/// <summary>
/// 创建新出入库信息
/// </summary>
/// <param name="type">出入库类型</param>
/// <param name="wareNo">二维码内容</param>
/// <param name="platew">宽度</param>
/// <param name="plateh">高度</param>
/// <param name="IsNg">是否是入库NG料</param>
/// <param name="ngMsg">NG消息</param>
public LabelParam(MoveType type, string wareNo = "", int platew = 0, int plateh = 0, bool _IsNg = false, string ngMsg = "")
{
WareCode = wareNo;
PlateW = platew;
PlateH = plateh;
IsNg = _IsNg;
NgMsg = ngMsg;
moveType = type;
}
public MoveType moveType = MoveType.None;
/// <summary>
/// 物品二维码信息
/// </summary>
public string WareCode { get; set; }
/// <summary>
/// 料盘高度
/// </summary>
public int PlateH { get; set; }
/// <summary>
/// 料盘宽度
/// </summary>
public int PlateW { get; set; }
/// <summary>
/// 是否是入料NG料
/// </summary>
public bool IsNg = false;
/// <summary>
/// 入料NG消息
/// </summary>
public string NgMsg = "";
public string ToStr()
{
if (IsNg)
{
return " 入库失败[BOX_" + "] [" + WareCode + "], [" + PlateW + "x" + PlateH + "] ";
}
else
{
return " 入库 [" + "] [" + WareCode + "], [" + PlateW + "x" + PlateH + "] ";
}
}
}
}
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DeviceLibrary
{
partial class MainMachine
{
void MoveEndProcess()
{
MoveInfo.EndMove();
runStatus = RunStatus.Running;
if (alarmType.Equals(AlarmType.None))
{
WarnMsg = "";
}
}
public void StopMove(bool ServoOff=false)
{
MoveInfo.EndMove();
AxisBean.CloseMultiAxis(new AxisBean[] { Take_Middle_Axis, Take_UpDown_Axis, Left_Batch_Axis, Right_Batch_Axis, Label_X_Axis, Label_Y_Axis, Label_Z_Axis, Label_R_Axis });
if (!ServoOff)
return;
foreach (ConfigMoveAxis configMoveAxis in config.moveAxisList)
AxisManager.ServoOff("", configMoveAxis.GetAxisValue());
}
public void OpenAllServo()
{
AxisBean.RunMultiAxis(true, out _, new AxisBean[] { Take_Middle_Axis, Take_UpDown_Axis, Left_Batch_Axis, Right_Batch_Axis, Label_X_Axis, Label_Y_Axis, Label_Z_Axis, Label_R_Axis });
}
void LogInfo(string logInfo)
{
LogUtil.info(Name + logInfo);
}
int logType = 1000;
string WarnMsg = "";
bool CheckWait()
{
List<WaitResultInfo> list = MoveInfo.WaitList;
//当等待超过一分钟时,需要打印提示
TimeSpan span = DateTime.Now - MoveInfo.LastSetpTime;
string NotOkMsg = "";
if (list.Count <= 0)
{
MoveInfo.EndStepWait();
return false;
}
bool isOk = true;
if (MoveInfo.OneWaitCanEndStep)
{
isOk = false;
}
foreach (WaitResultInfo wait in list)
{
if (wait.IsEnd)
{
if (!wait.WaitType.Equals(WaitEnum.W002_IOValue))
{
continue;
}
}
NotOkMsg = wait.ToStr();
if (wait.WaitType.Equals(WaitEnum.W001_AxisMove))
{
string msg = "";
if (wait.IsHomeMove)
{
wait.IsEnd = AxisBean.HomeMoveIsEnd(MoveInfo, wait.AxisInfo, out msg);
}
else
{
wait.IsEnd = AxisBean.ACAxisMoveIsEnd(MoveInfo, wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
}
if (!msg.Equals(""))
{
isOk = false;
WarnMsg = msg;
Alarm(AlarmType.AxisMoveError, GetAlarmCodeByAxis(wait.AxisInfo).ToString(), WarnMsg, MoveInfo.MoveType);
break;
}
}
else if (wait.WaitType.Equals(WaitEnum.W002_IOValue))
{
ConfigIO io = RobotManage.Config.getWaitIO(wait.IoType);
NotOkMsg = " 等待【" + io.DisplayStr + "】=【" + wait.IoValue + "】";
wait.IsEnd = IOManager.IOValue(wait.IoType).Equals(wait.IoValue);
int timeOutMs = RobotManage.Config.IOSingle_TimerOut;
if (!wait.IsEnd)
{
if (span.TotalMilliseconds > timeOutMs && NoAlarm())
{
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时";
Alarm(AlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, MoveInfo.MoveType);
LogUtil.error(Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时", logType + 14);
if (!MoveInfo.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W003_Time))
{
wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds);
}
else if (wait.WaitType.Equals(WaitEnum.W013_Action))
{
wait.IsEnd = wait.Action.Invoke(wait);
LogUtil.info($"{Name} 自定义等待 IsEnd={wait.IsEnd},Type={wait.Action.GetType()}");
}
if (wait.IsEnd)
{
if (MoveInfo.OneWaitCanEndStep)
{
isOk = true;
break;
}
}
else
{
if (!MoveInfo.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
if (isOk)
{
MoveInfo.EndStepWait();
return false;
}
else if (span.TotalSeconds > MoveInfo.TimeOutSeconds)
{
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "]等待" + NotOkMsg + "超时[" + Math.Round(span.TotalSeconds, 1) + "]秒";
int second = (int)(MoveInfo.TimeOutSeconds / span.TotalSeconds) * 10;
if (second > 120)
{
second = 120;
}
else if (second < 10)
{
second = 10;
}
LogUtil.error(WarnMsg, logType + 100, second);
Alarm(AlarmType.IoSingleTimeOut, "", WarnMsg, MoveInfo.MoveType);
}
return true;
}
/// <summary>
/// 是否再报警中
/// </summary>
AlarmType alarmType = AlarmType.None;
DateTime LastAlarmTime = DateTime.Now;
public void Alarm(AlarmType alarmType, string alarmDetial = "", string alarmMsg = "", MoveType storeMoveType = MoveType.None)
{
if (alarmType.Equals(AlarmType.None).Equals(false))
{
LastAlarmTime = DateTime.Now;
}
//SaveAlarmInfo(alarmType, alarmDetial, alarmMsg, storeMoveType);
if (this.alarmType.Equals(alarmType) && alarmType != AlarmType.SuddenStop && alarmType != AlarmType.NoAirCheck)
{
return;
}
LogUtil.error(Name + " 报警,报警类型:" + alarmType);
this.alarmType = alarmType;
if (alarmType.Equals(AlarmType.AxisAlarm) | alarmType.Equals(AlarmType.AxisMoveError))
{
LogUtil.error(Name + "轴报警, 停止运动, 打开报警灯");
StopMove(true);
}
else if (alarmType == AlarmType.SuddenStop)
{
//isInSuddenDown = true;
LogUtil.error(Name + "收到急停信号,停止运动, 打开报警灯 ");
StopMove(true);
//storeStatus = StoreStatus.SuddenStop;
}
else if (alarmType.Equals(AlarmType.NoAirCheck))
{
//isNoAirCheck = true;
LogUtil.error(Name + " 未检测到气压信号 ,停止运动, 打开报警灯 ");
StopMove(true);
//storeStatus = StoreStatus.SuddenStop;
}
}
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;
*/
return 0;
}
internal bool NoAlarm()
{
//if (isInSuddenDown || isNoAirCheck)
{
return false;
}
if (alarmType.Equals(AlarmType.None))
{
return true;
}
return false;
}
public void CylinderMove(MoveInfo moveInfo, string IoLowType, string IoHighType)
{
IOMove(IoLowType, IO_VALUE.LOW);
IOMove(IoHighType, IO_VALUE.HIGH);
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoLowType, IO_VALUE.LOW));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoHighType, IO_VALUE.HIGH));
}
}
IO_VALUE IOValue(string ioType) {
return IOManager.IOValue(ioType);
}
void IOMove(string IoType, IO_VALUE value, bool isCheck = false, int msTime = 0)
{
if (msTime <= 0)
{
if (isCheck && (IOValue(IoType).Equals(value)))
{
return;
}
IOManager.IOMove(IoType, value);
}
else
{
Task.Factory.StartNew(delegate
{
IOManager.IOMove(IoType, value);
Thread.Sleep(msTime);
IO_VALUE tValue = value.Equals(IO_VALUE.HIGH) ? IO_VALUE.LOW : IO_VALUE.HIGH;
LogUtil.info(Name + "定时回写IO: [" + IoType + "]=[" + value + "],msTime=" + msTime);
IOManager.IOMove(IoType, tValue);
});
}
}
}
}
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
partial class MainMachine
{
void WorkProcess() {
}
}
}
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public partial class MainMachine : IRobot
{
public string Name { get; set; } = "移载";
public bool canRunning { get; set; } = false;
public bool isBusy { get; set; } = false;
public bool isAlarm { get; set; } = false;
public RunStatus runStatus { get; set; } = RunStatus.Stop;
public Robot_Config config { get; set; }
public MoveInfo MoveInfo;
public AxisBean Take_Middle_Axis;
public AxisBean Take_UpDown_Axis;
public AxisBean Left_Batch_Axis;
public AxisBean Right_Batch_Axis;
public AxisBean Label_X_Axis;
public AxisBean Label_Y_Axis;
public AxisBean Label_Z_Axis;
public AxisBean Label_R_Axis;
/// <summary>
/// 开始运行的时间
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 是否在急停中
/// </summary>
public bool isInSuddenDown = false;
public MainMachine(Robot_Config _config) {
config = _config;
Take_Middle_Axis = new AxisBean(config.Take_Middle_Axis, Name);
Take_UpDown_Axis = new AxisBean(config.Take_UpDown_Axis, Name);
Left_Batch_Axis = new AxisBean(config.Left_Batch_Axis, Name);
Right_Batch_Axis = new AxisBean(config.Right_Batch_Axis, Name);
Label_X_Axis = new AxisBean(config.Label_X_Axis, Name);
Label_Y_Axis = new AxisBean(config.Label_Y_Axis, Name);
Label_Z_Axis = new AxisBean(config.Label_Z_Axis, Name);
Label_R_Axis = new AxisBean(config.Label_R_Axis, Name);
}
public void Run() {
while (true) {
canRunning = DeviceCheck();
if (canRunning)
canRunning = SafeCheck();
Thread.Sleep(50);
if (!canRunning)
continue;
if (runStatus == RunStatus.Running)
{
WorkProcess();
}
else if (runStatus == RunStatus.HomeReset)
{
HomeReset();
}
}
}
public void BeginHomeReset() {
StopMove();
Thread.Sleep(500);
OpenAllServo();
alarmType = AlarmType.None;
runStatus = RunStatus.HomeReset;
MoveInfo.NextMoveStep(MoveStep.H01_HomeReset);
LogInfo(MoveInfo.MoveType + ": 开始回原 ");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
void HomeReset()
{
if (CheckWait())
return;
switch (MoveInfo.MoveStep)
{
case MoveStep.H01_HomeReset:
MoveInfo.NextMoveStep(MoveStep.H02_HomeReset);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
LogInfo(MoveInfo.MoveType + ":正在回原");
Take_Middle_Axis.HomeMove(MoveInfo);
Take_UpDown_Axis.HomeMove(MoveInfo);
Left_Batch_Axis.HomeMove(MoveInfo);
Right_Batch_Axis.HomeMove(MoveInfo);
break;
case MoveStep.H02_HomeReset:
MoveInfo.NextMoveStep(MoveStep.H03_HomeReset);
LogInfo(MoveInfo.moveStep + ":正在回原");
Label_Z_Axis.HomeMove(MoveInfo);
Take_Middle_Axis.AbsMove(MoveInfo, config.Take_Middle_P1, config.Take_Middle_P1_speed);
Take_UpDown_Axis.AbsMove(MoveInfo, config.Take_UpDown_P1, config.Take_UpDown_P1_speed);
Right_Batch_Axis.AbsMove(MoveInfo, config.Right_Batch_P1, config.Right_Batch_P1_speed);
Left_Batch_Axis.AbsMove(MoveInfo, config.Left_Batch_P1, config.Left_Batch_P1_speed);
break;
case MoveStep.H03_HomeReset:
MoveInfo.NextMoveStep(MoveStep.H04_HomeReset);
LogInfo(MoveInfo.moveStep + ":正在回原");
Label_Z_Axis.HomeMove(MoveInfo);
Label_X_Axis.HomeMove(MoveInfo);
Label_Y_Axis.HomeMove(MoveInfo);
Label_R_Axis.HomeMove(MoveInfo);
break;
case MoveStep.H04_HomeReset:
MoveInfo.NextMoveStep(MoveStep.H05_HomeReset);
LogInfo(MoveInfo.moveStep + ":正在回原");
Label_Z_Axis.AbsMove(MoveInfo, config.Label_Z_P1, config.Label_Z_P1_speed);
Label_X_Axis.AbsMove(MoveInfo, config.Label_X_P1, config.Label_X_P1_speed);
Label_Y_Axis.AbsMove(MoveInfo, config.Label_Y_P1, config.Label_Y_P1_speed);
Label_R_Axis.AbsMove(MoveInfo, config.Label_R_P1, config.Label_R_P1_speed);
break;
case MoveStep.H05_HomeReset:
MoveInfo.NextMoveStep(MoveStep.HEND_HomeReset);
LogInfo(MoveInfo.moveStep + ":正在回原 阻挡气缸判断");
if (IOManager.IOValue(IO_Type.LeftEnd_Check) == IO_VALUE.LOW)
{
CylinderMove(MoveInfo, IO_Type.LeftStopUP, IO_Type.LeftStopDown);
}
if (IOManager.IOValue(IO_Type.RightEnd_Check) == IO_VALUE.LOW)
{
CylinderMove(MoveInfo, IO_Type.RightStopUP, IO_Type.RightStopDown);
}
break;
case MoveStep.HEND_HomeReset:
LogInfo(MoveInfo.moveStep + ": 完成");
MoveEndProcess();
break;
}
}
bool SafeCheck() {
List<string> msglist = new List<string>();
if (IOValue(IO_Type.GratingSignal_Check).Equals(IO_VALUE.LOW))
{
msglist.Add("安全光栅被遮挡");
}
if (IOValue(IO_Type.HasNgBox).Equals(IO_VALUE.LOW))
{
msglist.Add("没有检测到NG料箱");
}
if (IOValue(IO_Type.HasPrinter).Equals(IO_VALUE.LOW))
{
msglist.Add("没有检测到NG料箱");
}
if (IOValue(IO_Type.LeftBackDoor_Check).Equals(IO_VALUE.LOW))
{
msglist.Add("左后门没有关闭");
}
if (IOValue(IO_Type.RightBackDoor_Check).Equals(IO_VALUE.LOW))
{
msglist.Add("右后门没有关闭");
}
return (msglist.Count == 0);
}
/// <summary>
/// 最后一次气压检测变为0的时间
/// </summary>
DateTime lastAirCloseTime = DateTime.MinValue;
bool DeviceCheck() {
List<string> msglist = new List<string>();
if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
{
msglist.Add("急停中");
}
if (IOValue(IO_Type.Airpressure_Check).Equals(IO_VALUE.LOW))
{
if (lastAirCloseTime == DateTime.MinValue)
lastAirCloseTime = DateTime.Now;
TimeSpan span = DateTime.Now - lastAirCloseTime;
if (span.TotalSeconds > RobotManage.Config.AirCheckSeconds)
{
msglist.Add("急停中");
}
}
else {
lastAirCloseTime = DateTime.MinValue;
}
return (msglist.Count == 0);
}
}
}
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class MoveInfo
{
public int TimeOutSeconds = 60;
public MoveInfo(int storeId, string name)
{
moveType = MoveType.None;
MoveParam = new LabelParam(MoveType.None);
this.storeId = storeId;
this.moveStep = MoveStep.Wait;
IsInWait = false;
this.Name = name;
}
public string Name { get; set; }
public DateTime LastSetpTime { get; set; }
public bool OneWaitCanEndStep = false;
public string SLog
{
get { return " " + MoveStep + " "; }
}
private MoveType moveType = MoveType.None;
public MoveType MoveType
{
get { return moveType; }
}
public LabelParam MoveParam { get; set; }
public int storeId { get; set; }
public bool IsInWait { get; set; }
public MoveStep moveStep;
public int CanWhileCount = 0;
public MoveStep MoveStep
{
get { return moveStep; }
}
public int ErrorLogType { get; internal set; }
public void NextMoveStep(MoveStep step)
{
// PreMoveStep = moveStep;
moveStep = step;
LastSetpTime = DateTime.Now;
IsInWait = true;
WaitList = new List<WaitResultInfo>();
OneWaitCanEndStep = false;
CanWhileCount = 5;
}
/// <summary>
/// 当前步骤执行完成
/// </summary>
public void EndStepWait()
{
IsInWait = false;
WaitList = new List<WaitResultInfo>();
}
public void NewMove(MoveType type, LabelParam param = null)
{
moveStep = MoveStep.Wait;
this.moveType = type;
if (param == null)
{
param = new LabelParam(type);
}
this.MoveParam = param;
LastSetpTime = DateTime.Now;
WaitList = new List<WaitResultInfo>();
}
public void EndMove()
{
this.moveType = MoveType.None;
this.MoveParam = null;
moveStep = MoveStep.Wait;
LastSetpTime = DateTime.Now;
IsInWait = false;
WaitList = new List<WaitResultInfo>();
CanWhileCount = 0;
}
public MoveInfo clone()
{
return (MoveInfo)this.MemberwiseClone();
}
public List<WaitResultInfo> WaitList = new List<WaitResultInfo>();
internal bool IsStep(MoveStep step)
{
return moveStep.Equals(step);
}
public bool IsTimeOut(int timeOutSeconds = 60)
{
TimeSpan span = DateTime.Now - LastSetpTime;
if (span.TotalSeconds > timeOutSeconds)
{
return true;
}
return false;
}
public TimeSpan StepSpan()
{
TimeSpan span = DateTime.Now - LastSetpTime;
return span;
}
}
public class WaitResultInfo
{
private WaitResultInfo()
{
IsEnd = false;
CanWhileMoveCount = 0;
}
public static WaitResultInfo WaitIO(string ioType, IO_VALUE ioValue)
{
WaitResultInfo wait = new WaitResultInfo();
wait.WaitType = WaitEnum.W002_IOValue;
wait.IoType = ioType;
wait.IoValue = ioValue;
return wait;
}
public static WaitResultInfo WaitAxis(ConfigMoveAxis axis, int targetPosition, int targetSpeed)
{
WaitResultInfo wait = new WaitResultInfo();
wait.WaitType = WaitEnum.W001_AxisMove;
wait.AxisInfo = axis;
wait.IsHomeMove = false;
wait.TargetPosition = targetPosition;
wait.TargetSpeed = targetSpeed;
return wait;
}
public static WaitResultInfo WaitAxis(ConfigMoveAxis axis, bool isHomeMove)
{
WaitResultInfo wait = new WaitResultInfo();
wait.WaitType = WaitEnum.W001_AxisMove;
wait.AxisInfo = axis;
wait.IsHomeMove = true;
return wait;
}
public static WaitResultInfo WaitTime(int MScends)
{
WaitResultInfo wait = new WaitResultInfo();
wait.CanWhileMoveCount = 0;
wait.WaitType = WaitEnum.W003_Time;
wait.TimeMSeconds = MScends;
wait.IsEnd = false;
return wait;
}
public static WaitResultInfo WaitAxisOrg(ConfigMoveAxis axis, IO_VALUE value)
{
WaitResultInfo wait = new WaitResultInfo();
wait.WaitType = WaitEnum.W006_AxisOrg;
wait.AxisInfo = axis;
wait.IsHomeMove = true;
wait.IoValue = value;
wait.IsEnd = false;
return wait;
}
public static WaitResultInfo WaitBatchAxisMove(ConfigMoveAxis axis, int targetPosition, int targetSpeed)
{
WaitResultInfo wait = new WaitResultInfo();
wait.WaitType = WaitEnum.W008_BatchAxis;
wait.AxisInfo = axis;
wait.IsHomeMove = false;
wait.TargetPosition = targetPosition;
wait.TargetSpeed = targetSpeed;
return wait;
}
internal static WaitResultInfo WaitScanCode()
{
WaitResultInfo wait = new WaitResultInfo();
wait.WaitType = WaitEnum.W009_ScanCode;
wait.IsHomeMove = false;
return wait;
}
public static WaitResultInfo WaitAction(Func<WaitResultInfo, bool> a)
{
WaitResultInfo wait = new WaitResultInfo();
wait.WaitType = WaitEnum.W013_Action;
wait.Action = a;
return wait;
}
public string ToStr()
{
if (WaitType.Equals(WaitEnum.W001_AxisMove))
{
if (IsHomeMove)
{
return "轴【" + AxisInfo.DisplayStr + "】原点返回";
}
else
{
return "轴【" + AxisInfo.DisplayStr + "】绝对运动,目标位置【" + TargetPosition + "】";
}
}
else if (WaitType.Equals(WaitEnum.W002_IOValue))
{
return "等待【" + IoType + "】=【" + IoValue + "】";
}
else if (WaitType.Equals(WaitEnum.W003_Time))
{
return "时间等待:【" + TimeMSeconds + "】毫秒";
}
else if (WaitType.Equals(WaitEnum.W005_ShuoKe))
{
return "硕科电机目标位置:【" + TargetPosition + "】 ";
}
else if (WaitType.Equals(WaitEnum.W006_AxisOrg))
{
return "轴【" + AxisInfo.DisplayStr + "】ORG信号:【" + IoValue + "】 ";
}
else if (WaitType.Equals(WaitEnum.W007_ReelHeight))
{
return "料盘高度【" + TargetPosition + "】 ";
}
else if (WaitType.Equals(WaitEnum.W008_BatchAxis))
{
return "批量轴上升到上料点";
}
else if (WaitType.Equals(WaitEnum.W009_ScanCode))
{
return "扫码完成";
}
else
{
return "Wait位置类型:WaitType=【" + WaitType + "】";
}
}
/// <summary>
/// 当未结束时可以重复运动的次数
/// </summary>
public int CanWhileMoveCount { get; set; }
/// <summary>
/// 等待结果,1=轴运动,2=IO运动,3=时间,4=电钢,5=硕科电机,6=等待轴原点信号,8=等待压紧轴压紧到位
/// </summary>
public int WaitType { get; set; }
/// <summary>
/// 轴运动时表示轴信息
/// </summary>
public ConfigMoveAxis AxisInfo { get; set; }
/// <summary>
/// 电钢地址
/// </summary>
public byte SlvAddr { get; set; }
/// <summary>
/// IO类型
/// </summary>
public String IoType { get; set; }
/// <summary>
/// IO值
/// </summary>
public IO_VALUE IoValue { get; set; }
/// <summary>
/// 等待的毫秒
/// </summary>
public int TimeMSeconds { get; set; }
/// <summary>
/// 是否是原点返回
/// </summary>
public bool IsHomeMove = false;
/// <summary>
/// 轴目标位置
/// </summary>
public int TargetPosition { get; set; }
/// <summary>
/// 轴目标速度
/// </summary>
public int TargetSpeed { get; set; }
/// <summary>
/// 是否已经结束
/// </summary>
public bool IsEnd { get; set; }
/// <summary>
/// 等待事件代理
/// </summary>
public Func<WaitResultInfo, bool> Action { get; set; }
public int AgvAction = 0;
}
internal class WaitEnum
{
/// <summary>
/// 伺服运动
/// </summary>
internal static int W001_AxisMove = 1;
/// <summary>
/// 信号到达
/// </summary>
internal static int W002_IOValue = 2;
/// <summary>
/// 时间等待
/// </summary>
internal static int W003_Time = 3;
/// <summary>
/// 硕科电机
/// </summary>
internal static int W005_ShuoKe = 5;
/// <summary>
/// 轴原点信号
/// </summary>
internal static int W006_AxisOrg = 6;
/// <summary>
/// 料盘高度
/// </summary>
internal static int W007_ReelHeight = 7;
/// <summary>
/// 批量轴上升到上料点
/// </summary>
internal static int W008_BatchAxis = 8;
/// <summary>
/// 扫码完成
/// </summary>
internal static int W009_ScanCode = 9;
/// <summary>
/// 通用代理等待方法
/// </summary>
internal static int W013_Action = 13;
}
public enum MoveType
{
/// <summary>
/// 没有任何操作
/// </summary>
None = 0,
/// <summary>
/// 入库
/// </summary>
InStore = 1,
/// <summary>
/// 出库
/// </summary>
OutStore = 2,
/// <summary>
/// 原点返回
/// </summary>
ReturnHome = 3,
/// <summary>
/// 重置
/// </summary>
Reset = 4,
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public enum MoveStep
{
Wait,
H01_HomeReset,
H02_HomeReset,
H03_HomeReset,
H04_HomeReset,
H05_HomeReset,
H06_HomeReset,
H07_HomeReset,
HEND_HomeReset,
}
public enum AlarmType
{
/// <summary>
/// 没有报警
/// </summary>
None = 0,
/// <summary>
/// 轴报警
/// </summary>
AxisAlarm = 1,
/// <summary>
/// 收到急停
/// </summary>
SuddenStop = 10,
/// <summary>
/// 没有气压信号
/// </summary>
NoAirCheck = 11,
/// <summary>
/// 轴运动错误,没有达到指定脉冲,但是io判断已停止运动
/// </summary>
AxisMoveError = 20,
/// <summary>
/// io信号超时未收到
/// </summary>
IoSingleTimeOut = 30,
}
}
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceLibrary
{
public static class RobotManage
{
public static MainMachine mainMachine;
public static Robot_Config Config;
public static bool IsLoadOk = false;
static string baseDir = Application.StartupPath;
static Thread mainThread;
static RobotManage() {
CodeManager.LoadConfig();
string configFile = Path.Combine(baseDir, "config\\Config.csv");
Config = new Robot_Config(0, "", configFile);
Config = (Robot_Config)CSVConfigReader.LoadConfig(Config);
mainMachine = new MainMachine(RobotManage.Config);
if (!IOManager.ConnectionIOList(new List<string>())) {
IsLoadOk = false;
return;
}
IsLoadOk = true;
}
static void Start() {
mainThread = new Thread(new ThreadStart(mainMachine.Run));
mainThread.Start();
GC.KeepAlive(mainThread);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class Class1
{
}
}
类型,分类编号,说明,名称,属性值,设备名称,电器定义,目标速度,加速时间,减速时间,原点低速度,原点高速,原点加速度,脉冲最小误差,脉冲最大误差,脉冲最小限位,脉冲最大限位
AXIS,,取料机构旋转轴_SVD01,Take_Middle_Axis,0,HC,,500,1000,1000,100,200,1000,10,1000,0,0
AXIS,,取料机构上下轴_SVD02,Take_UpDown_Axis,1,HC,,1000,1000,1000,200,500,500,10,1000,0,0
AXIS,,左轨道提升轴_SVD04,Left_Batch_Axis,2,HC,,3000,1000,1000,200,1000,200,10,1000,0,0
AXIS,,右轨道提升轴_SVD05,Right_Batch_Axis,3,HC,,3000,1000,1000,200,1000,200,10,1000,0,0
AXIS,,贴标移栽机构X轴_SVD08,Label_X_Axis,4,HC,,100,700,700,50,250,500,10,1000,0,0
AXIS,,贴标移栽机构Y轴_SVD09,Label_Y_Axis,5,HC,,100,700,700,50,150,500,10,1000,0,0
AXIS,,贴标移栽机构Z轴_SVD10,Label_Z_Axis,6,HC,,100,800,800,50,150,500,10,1000,0,0
AXIS,,贴标移栽机构R轴_SVD11,Label_R_Axis,7,HC,,10,2000,2000,1,5,200,500,1000,0,0
,,,,,,,,,,,,,,,,
PRO,0,IO信号超时时间(秒),IOSingle_TimerOut,15,,,,,,,,,,,,
PRO,10,取料旋转轴待机点P1,Take_Middle_P1,1,,,,,,,,,,,,
PRO,10,取料旋转轴右取料点P2,Take_Middle_P2,2,,,,,,,,,,,,
PRO,10,取料旋转轴左取料点P3,Take_Middle_P3,3,,,,,,,,,,,,
PRO,10,取料旋转轴NG放料点P5,Take_Middle_P5,4,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,11,取料上下轴待机点P1,Take_UpDown_P1,6,,,,,,,,,,,,
PRO,11,取料上下轴取料高点P2,Take_UpDown_P2,7,,,,,,,,,,,,
PRO,11,取料上下轴取右料低点P3,Take_UpDown_P3,8,,,,,,,,,,,,
PRO,11,取料上下轴取左料低点P4,Take_UpDown_P4,9,,,,,,,,,,,,
PRO,11,取料上下轴NG放料点P5,Take_UpDown_P5,10,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,12,右提升轴低点P1,Right_Batch_P1,12,,,,,,,,,,,,
PRO,12,右提升轴高点P2,Right_Batch_P2,13,,,,,,,,,,,,
PRO,12,左提升轴低点P1,Left_Batch_P1,14,,,,,,,,,,,,
PRO,12,左提升轴高点P2,Left_Batch_P2,15,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,13,贴标X轴待机点P1,Label_X_P1,17,,,,,,,,,,,,
PRO,13,贴标X轴取标点P2,Label_X_P2,18,,,,,,,,,,,,
PRO,13,贴标X轴贴标点P3,Label_X_P3,19,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,14,贴标Y轴待机点P1,Label_Y_P1,21,,,,,,,,,,,,
PRO,14,贴标Y轴取标点P2,Label_Y_P2,22,,,,,,,,,,,,
PRO,14,贴标Y轴贴标点P3,Label_Y_P3,23,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,15,贴标Z轴待机点P1,Label_Z_P1,25,,,,,,,,,,,,
PRO,15,贴标Z轴取标点P2,Label_Z_P2,26,,,,,,,,,,,,
PRO,15,贴标Z轴贴标点P3,Label_Z_P3,27,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,16,贴标R轴待机点P1,Label_R_P1,29,,,,,,,,,,,,
PRO,16,贴标R轴取标点P2,Label_R_P2,30,,,,,,,,,,,,
PRO,16,贴标R轴360度脉冲,Label_R_P3,31,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
DI,0,急停,SuddenStop_BTN,0,HC,X00,,,,,,,,,,
DI,0,进料口确认按钮,Reset_BTN,1,HC,X01,,,,,,,,,,
DI,0,出料口确认按钮,Start_BTN,2,HC,X02,,,,,,,,,,
DI,0,后门左门禁,LeftBackDoor_Check,3,HC,X03,,,,,,,,,,
DI,0,后门右门禁,RightBackDoor_Check,4,HC,X04,,,,,,,,,,
DI,0,气压检测,Airpressure_Check,5,HC,X05,,,,,,,,,,
DI,0,光栅信号,GratingSignal_Check,6,HC,X06,,,,,,,,,,
DI,0,NG料箱检测,HasNgBox,7,HC,X07,,,,,,,,,,
DI,0,打印机到位检测,HasPrinter,8,HC,X08,,,,,,,,,,
DI,0,旋转臂进料侧检测,RightArm_Check,9,HC,X09,,,,,,,,,,
DI,0,旋转臂出料侧检测,LeftArm_Check,10,HC,X10,,,,,,,,,,
DI,0,进料口料车检测,RightCar_Check,11,HC,X11,,,,,,,,,,
DI,0,进料口前端料串检测,RightFornt_Check,12,HC,X12,,,,,,,,,,
DI,0,进料口料串到位检测,RightEnd_Check,13,HC,X13,,,,,,,,,,
DI,0,进料口阻挡气缸上升端,RightStopUP,14,HC,X14,,,,,,,,,,
DI,0,进料口阻挡气缸下降端,RightStopDown,15,HC,X15,,,,,,,,,,
DI,0,出料口料车检测,LeftCar_Check,16,HC,X16,,,,,,,,,,
DI,0,出料口前端料串检测,LeftFornt_Check,17,HC,X17,,,,,,,,,,
DI,0,出料口料串到位检测,LeftEnd_Check,18,HC,X18,,,,,,,,,,
DI,0,出料口阻挡气缸上升端,LeftStopUP,19,HC,X19,,,,,,,,,,
DI,0,出料口阻挡气缸下降端,LeftStopDown,20,HC,X20,,,,,,,,,,
DI,0,进料定位料盘检测,RightTop_Check,21,HC,X21,,,,,,,,,,
DI,0,进料定位料盘超限检测,RightOverHead_Check,22,HC,X22,,,,,,,,,,
DI,0,出料定位料盘检测,LeftTop_Check,23,HC,X23,,,,,,,,,,
DI,0,出料定位料盘超限检测,LeftOverHead_Check,24,HC,X24,,,,,,,,,,
DI,0,吸嘴气缸前进端,LabelCylinder_Fwd,25,HC,X25,,,,,,,,,,
DI,0,吸嘴气缸后退端,LabelCylinder_Bck,26,HC,X26,,,,,,,,,,
,,,,,,,,,,,,,,,,
DO,0,自动指示灯,AutoRun_HddLed,0,HC,Y00,,,,,,,,,,
DO,0,故障指示灯,Alarm_HddLed,1,HC,Y01,,,,,,,,,,
DO,0,待机指示灯,RunSign_HddLed,2,HC,Y02,,,,,,,,,,
DO,0,报警蜂鸣器,Alarm_Buzzer,3,HC,Y03,,,,,,,,,,
DO,0,进料口状态指示灯,RightState_Led,4,HC,Y04,,,,,,,,,,
DO,0,出料口状态指示灯,LeftState_Led,5,HC,Y05,,,,,,,,,,
DO,0,设备照明,Device_Led,6,HC,Y06,,,,,,,,,,
DO,0,相机照明,Camera_Led,7,HC,Y07,,,,,,,,,,
DO,0,进料口电机启动,RightMoto_Run,8,HC,Y08,,,,,,,,,,
DO,0,进料口电机反转指令,RightMoto_Reverse,9,HC,Y09,,,,,,,,,,
DO,0,出料口电机启动,LeftMoto_Run,10,HC,Y10,,,,,,,,,,
DO,0,出料口电机反转指令,LeftMoto_Reverse,11,HC,Y11,,,,,,,,,,
DO,0,进料口阻挡气缸上升,RightStopUP,12,HC,Y12,,,,,,,,,,
DO,0,进料口阻挡气缸下降,RightStopDown,13,HC,Y13,,,,,,,,,,
DO,0,出料口阻挡气缸上升,LeftStopUP,14,HC,Y14,,,,,,,,,,
DO,0,出料口阻挡气缸下降,LeftStopDown,15,HC,Y15,,,,,,,,,,
DO,0,吸嘴气缸前进,LabelCylinder_Fwd,16,HC,Y16,,,,,,,,,,
DO,0,吸嘴气缸后退,LabelCylinder_Bck,17,HC,Y17,,,,,,,,,,
DO,0,吸嘴取标,LabelCylinder_Work,18,HC,Y18,,,,,,,,,,
,,,,,,,,,,,,,,,,
类型,分类编号,说明,名称,属性值,设备名称,电器定义,目标速度,加速时间,减速时间,原点低速度,原点高速,原点加速度,脉冲最小误差,脉冲最大误差,脉冲最小限位,脉冲最大限位
AXIS,,取料机构旋转轴_SVD01,Take_Middle_Axis,0,HC,,500,1000,1000,100,200,1000,10,1000,0,0
AXIS,,取料机构上下轴_SVD02,Take_UpDown_Axis,1,HC,,1000,1000,1000,200,500,500,10,1000,0,0
AXIS,,左轨道提升轴_SVD04,Left_Batch_Axis,2,HC,,3000,1000,1000,200,1000,200,10,1000,0,0
AXIS,,右轨道提升轴_SVD05,Right_Batch_Axis,3,HC,,3000,1000,1000,200,1000,200,10,1000,0,0
AXIS,,贴标移栽机构X轴_SVD08,Label_X_Axis,4,HC,,100,700,700,50,250,500,10,1000,0,0
AXIS,,贴标移栽机构Y轴_SVD09,Label_Y_Axis,5,HC,,100,700,700,50,150,500,10,1000,0,0
AXIS,,贴标移栽机构Z轴_SVD10,Label_Z_Axis,6,HC,,100,800,800,50,150,500,10,1000,0,0
AXIS,,贴标移栽机构R轴_SVD11,Label_R_Axis,7,HC,,10,2000,2000,1,5,200,500,1000,0,0
,,,,,,,,,,,,,,,,
PRO,0,IO信号超时时间(秒),IOSingle_TimerOut,15,,,,,,,,,,,,
PRO,0,气压检测超时,AirCheckSeconds,5,,,,,,,,,,,,
PRO,10,取料旋转轴待机点P1,Take_Middle_P1,1,,,99,,,,,,,,,
PRO,10,取料旋转轴右取料点P2,Take_Middle_P2,2,,,99,,,,,,,,,
PRO,10,取料旋转轴左取料点P3,Take_Middle_P3,3,,,99,,,,,,,,,
PRO,10,取料旋转轴NG放料点P5,Take_Middle_P5,4,,,99,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,11,取料上下轴待机点P1,Take_UpDown_P1,6,,,88,,,,,,,,,
PRO,11,取料上下轴取料高点P2,Take_UpDown_P2,7,,,88,,,,,,,,,
PRO,11,取料上下轴取右料低点P3,Take_UpDown_P3,8,,,88,,,,,,,,,
PRO,11,取料上下轴取左料低点P4,Take_UpDown_P4,9,,,88,,,,,,,,,
PRO,11,取料上下轴NG放料点P5,Take_UpDown_P5,10,,,88,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,12,右提升轴低点P1,Right_Batch_P1,12,,,66,,,,,,,,,
PRO,12,右提升轴高点P2,Right_Batch_P2,13,,,66,,,,,,,,,
PRO,12,左提升轴低点P1,Left_Batch_P1,14,,,66,,,,,,,,,
PRO,12,左提升轴高点P2,Left_Batch_P2,15,,,66,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,13,贴标X轴待机点P1,Label_X_P1,17,,,77,,,,,,,,,
PRO,13,贴标X轴取标点P2,Label_X_P2,18,,,77,,,,,,,,,
PRO,13,贴标X轴贴标点P3,Label_X_P3,19,,,77,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,14,贴标Y轴待机点P1,Label_Y_P1,21,,,44,,,,,,,,,
PRO,14,贴标Y轴取标点P2,Label_Y_P2,22,,,44,,,,,,,,,
PRO,14,贴标Y轴贴标点P3,Label_Y_P3,23,,,44,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,15,贴标Z轴待机点P1,Label_Z_P1,25,,,44,,,,,,,,,
PRO,15,贴标Z轴取标点P2,Label_Z_P2,26,,,44,,,,,,,,,
PRO,15,贴标Z轴贴标点P3,Label_Z_P3,27,,,44,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,16,贴标R轴待机点P1,Label_R_P1,29,,,22,,,,,,,,,
PRO,16,贴标R轴取标点P2,Label_R_P2,30,,,22,,,,,,,,,
PRO,16,贴标R轴360度脉冲,Label_R_P3,31,,,22,,,,,,,,,
,,,,,,,,,,,,,,,,
DI,0,急停,SuddenStop_BTN,0,HC,X00,,,,,,,,,,
DI,0,进料口确认按钮,Reset_BTN,1,HC,X01,,,,,,,,,,
DI,0,出料口确认按钮,Start_BTN,2,HC,X02,,,,,,,,,,
DI,0,后门左门禁,LeftBackDoor_Check,3,HC,X03,,,,,,,,,,
DI,0,后门右门禁,RightBackDoor_Check,4,HC,X04,,,,,,,,,,
DI,0,气压检测,Airpressure_Check,5,HC,X05,,,,,,,,,,
DI,0,光栅信号,GratingSignal_Check,6,HC,X06,,,,,,,,,,
DI,0,NG料箱检测,HasNgBox,7,HC,X07,,,,,,,,,,
DI,0,打印机到位检测,HasPrinter,8,HC,X08,,,,,,,,,,
DI,0,旋转臂进料侧检测,RightArm_Check,9,HC,X09,,,,,,,,,,
DI,0,旋转臂出料侧检测,LeftArm_Check,10,HC,X10,,,,,,,,,,
DI,0,进料口料车检测,RightCar_Check,11,HC,X11,,,,,,,,,,
DI,0,进料口前端料串检测,RightFornt_Check,12,HC,X12,,,,,,,,,,
DI,0,进料口料串到位检测,RightEnd_Check,13,HC,X13,,,,,,,,,,
DI,0,进料口阻挡气缸上升端,RightStopUP,14,HC,X14,,,,,,,,,,
DI,0,进料口阻挡气缸下降端,RightStopDown,15,HC,X15,,,,,,,,,,
DI,0,出料口料车检测,LeftCar_Check,16,HC,X16,,,,,,,,,,
DI,0,出料口前端料串检测,LeftFornt_Check,17,HC,X17,,,,,,,,,,
DI,0,出料口料串到位检测,LeftEnd_Check,18,HC,X18,,,,,,,,,,
DI,0,出料口阻挡气缸上升端,LeftStopUP,19,HC,X19,,,,,,,,,,
DI,0,出料口阻挡气缸下降端,LeftStopDown,20,HC,X20,,,,,,,,,,
DI,0,进料定位料盘检测,RightTop_Check,21,HC,X21,,,,,,,,,,
DI,0,进料定位料盘超限检测,RightOverHead_Check,22,HC,X22,,,,,,,,,,
DI,0,出料定位料盘检测,LeftTop_Check,23,HC,X23,,,,,,,,,,
DI,0,出料定位料盘超限检测,LeftOverHead_Check,24,HC,X24,,,,,,,,,,
DI,0,吸嘴气缸前进端,LabelCylinder_Fwd,25,HC,X25,,,,,,,,,,
DI,0,吸嘴气缸后退端,LabelCylinder_Bck,26,HC,X26,,,,,,,,,,
,,,,,,,,,,,,,,,,
DO,0,自动指示灯,AutoRun_HddLed,0,HC,Y00,,,,,,,,,,
DO,0,故障指示灯,Alarm_HddLed,1,HC,Y01,,,,,,,,,,
DO,0,待机指示灯,RunSign_HddLed,2,HC,Y02,,,,,,,,,,
DO,0,报警蜂鸣器,Alarm_Buzzer,3,HC,Y03,,,,,,,,,,
DO,0,进料口状态指示灯,RightState_Led,4,HC,Y04,,,,,,,,,,
DO,0,出料口状态指示灯,LeftState_Led,5,HC,Y05,,,,,,,,,,
DO,0,设备照明,Device_Led,6,HC,Y06,,,,,,,,,,
DO,0,相机照明,Camera_Led,7,HC,Y07,,,,,,,,,,
DO,0,进料口电机启动,RightMoto_Run,8,HC,Y08,,,,,,,,,,
DO,0,进料口电机反转指令,RightMoto_Reverse,9,HC,Y09,,,,,,,,,,
DO,0,出料口电机启动,LeftMoto_Run,10,HC,Y10,,,,,,,,,,
DO,0,出料口电机反转指令,LeftMoto_Reverse,11,HC,Y11,,,,,,,,,,
DO,0,进料口阻挡气缸上升,RightStopUP,12,HC,Y12,,,,,,,,,,
DO,0,进料口阻挡气缸下降,RightStopDown,13,HC,Y13,,,,,,,,,,
DO,0,出料口阻挡气缸上升,LeftStopUP,14,HC,Y14,,,,,,,,,,
DO,0,出料口阻挡气缸下降,LeftStopDown,15,HC,Y15,,,,,,,,,,
DO,0,吸嘴气缸前进,LabelCylinder_Fwd,16,HC,Y16,,,,,,,,,,
DO,0,吸嘴气缸后退,LabelCylinder_Bck,17,HC,Y17,,,,,,,,,,
DO,0,吸嘴取标,LabelCylinder_Work,18,HC,Y18,,,,,,,,,,
,,,,,,,,,,,,,,,,
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BB23296C-AA1D-45C6-9FA6-5A37B2ABFE9B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DeviceLibrary</RootNamespace>
<AssemblyName>DeviceLibrary</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CodeLibrary">
<HintPath>..\..\GeneralClassLibrary\CodeLibraryProject\CodeLibrary\bin\Debug\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="halcondotnet">
<HintPath>..\..\RC1271-DUOStore\dll\halcondotnet.dll</HintPath>
</Reference>
<Reference Include="HuichuanLibrary">
<HintPath>..\..\HuichuanLibrary\HuichuanLibrary\bin\Debug\HuichuanLibrary.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\..\增广夹爪\Rmaxis\bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AutoScanAndLabel\AxisBean.cs" />
<Compile Include="AutoScanAndLabel\LabelParam.cs" />
<Compile Include="AutoScanAndLabel\MoveInfo.cs" />
<Compile Include="AutoScanAndLabel\MoveStep.cs" />
<Compile Include="AutoScanAndLabel\MainMachine _Common.cs" />
<Compile Include="AutoScanAndLabel\MainMachine _WorkProcess.cs" />
<Compile Include="DeviceLibrary\CodeManager.cs" />
<Compile Include="AutoScanAndLabel\RobotManage.cs" />
<Compile Include="AutoScanAndLabel\IRobot.cs" />
<Compile Include="AutoScanAndLabel\MainMachine.cs" />
<Compile Include="Class1.cs" />
<Compile Include="DeviceLibrary\IAxisManager.cs" />
<Compile Include="DeviceLibrary\AxisManager.cs" />
<Compile Include="DeviceLibrary\HC\HCAxisManager.cs" />
<Compile Include="DeviceLibrary\HC\HCIOManager.cs" />
<Compile Include="DeviceLibrary\I_IOManager.cs" />
<Compile Include="DeviceLibrary\IOManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="userControl\AxisMoveControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="userControl\AxisMoveControl.Designer.cs">
<DependentUpon>AxisMoveControl.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="userControl\AxisMoveControl.resx">
<DependentUpon>AxisMoveControl.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{43cdd09e-fcf3-4960-a01d-3bbfe9933122}</Project>
<Name>Common</Name>
</ProjectReference>
<ProjectReference Include="..\LoadCVSLibrary\LoadCSVLibrary.csproj">
<Project>{064bebf5-8faa-4ea2-a5f3-a06e6e7d9251}</Project>
<Name>LoadCSVLibrary</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Config\Config.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="Config\Config - 复制.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class AxisManager
{
public bool IsShowMsg = false;
static IAxisManager instance;
public static bool UseHCBoard = true;
static AxisManager() {
instance = new HCAxisManager();
}
public static bool IsServeoOn(string portName, short slvAddr) {
return instance.IsServeoOn(portName, slvAddr);
}
public static bool OpenCard() {
return instance.OpenCard();
}
public bool CloseCard() {
return instance.CloseCard();
}
public static bool IsHomeMoveEnd(string portName, short slvAddr) {
return instance.IsHomeMoveEnd(portName, slvAddr);
}
public static bool AbsMoveIsEnd(string portName, short axisNo, int targetPosition, int canErrorCount, out bool countError)
{
return instance.AbsMoveIsEnd(portName, axisNo, targetPosition, canErrorCount, out countError);
}
public static void ServoOn(string portName, short slvAddr)
{
instance.ServoOn(portName, slvAddr);
}
public static void ServoOff(string portName, short slvAddr)
{
instance.ServoOff(portName, slvAddr);
}
public static void RelMove(string portName, short slvAddr, int position, int targetSpeed , int ptpAcc , int ptpDec )
{
instance.RelMove(portName, slvAddr, position, targetSpeed, ptpAcc, ptpDec);
}
public static void HomeMove(string portName, short slvAddr, int highVel, int lowVel, int acc)
{
instance.HomeMove(portName, slvAddr, highVel, lowVel, acc);
}
public static void SpeedMove(string portName, short slvAddr, int speed)
{
instance.SpeedMove(portName, slvAddr, speed);
}
public static void SuddenStop(string portName, short slvAddr)
{
instance.SuddenStop(portName, slvAddr);
}
public static bool isInPosition(string portName, short slvAddr, int PPosition, int canErrorCount, bool isLog = false)
{
return instance.isInPosition(portName, slvAddr, PPosition, canErrorCount, isLog);
}
public static void AbsMove(string portName, short slvAddr, int targetPosition, int targetSpeed , int ptpAcc , int ptpDec )
{
instance.AbsMove(portName, slvAddr, targetPosition, targetSpeed, ptpAcc, ptpDec);
}
public static void AlarmClear(string portName, short slvAddr)
{
instance.AlarmClear(portName, slvAddr);
}
public static int GetTargetPosition(string portName, short slvAddr)
{
return instance.GetTargetPosition(portName, slvAddr);
}
public static int GetActualtPosition(string portName, short slvAddr)
{
return instance.GetActualtPosition(portName, slvAddr);
}
public static int GetAlarmStatus(string portName, short slvAddr)
{
return instance.GetAlarmStatus(portName, slvAddr);
}
public static int GetBusyStatus(string portName, short slvAddr)
{
return instance.GetBusyStatus(portName, slvAddr);
}
public static int GetHomeEndStatus(string portName, short slvAddr)
{
return instance.GetHomeEndStatus(portName, slvAddr);
}
public static int GetHomeSingle(string portName, short slvAddr)
{
return instance.GetHomeSingle(portName, slvAddr);
}
/// <summary>
/// 负极限
/// </summary>
public static int GetLimitNegativeSingle(string portName, short slvAddr)
{
return instance.GetLimitNegativeSingle(portName, slvAddr);
}
/// <summary>
/// 正极限
/// </summary>
public static int GetLimitPositiveSingle(string portName, short slvAddr)
{
return instance.GetLimitPositiveSingle(portName, slvAddr);
}
public static short GetErrorCode(string portName, short slvAddr)
{
return instance.GetErrorCode(portName, slvAddr);
}
public static void SuddenStop(ConfigMoveAxis configMoveAxis)
{
SuddenStop(configMoveAxis.DeviceName, configMoveAxis.GetAxisValue());
}
public static int GetActualtPosition(ConfigMoveAxis configMoveAxis) {
return GetActualtPosition(configMoveAxis.DeviceName, configMoveAxis.GetAxisValue());
}
public static bool ServerOnStatus(string portName, short slvAddr) {
return IsServeoOn(portName, slvAddr);
}
public static bool isInPosition(ConfigMoveAxis configMoveAxis, int PPosition, bool isLog = false) {
return isInPosition(configMoveAxis.DeviceName, configMoveAxis.GetAxisValue(), PPosition, configMoveAxis.CanErrorCountMax, isLog);
}
}
}

using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Windows.Forms;
using CodeLibrary;
using System.Drawing.Imaging;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class CodeManager
{
//public static int DeCodeType = ConfigAppSettings.GetIntValue(Setting_Init.DeCodeType);
//private static int QRCodeCount = ConfigAppSettings.GetIntValue(Setting_Init.QRCodeCount);
public static List<string> cameraNameList = new List<string>();
public static List<string> codeTypeList = new List<string>();
public static List<string> hikNameList = new List<string>();
private static char spiltChar = '#';
/// <summary>
/// 初始化摄像机名称和二维码类型
/// </summary>
public static void LoadConfig()
{
string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName);
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());
}
LoadCamera(false);
//如果未加载到配置相机,自动配置
if (cameraNameList.Count <= 0 && hikNameList.Count > 0)
{
cameraNameList = new List<string>(hikNameList);
string cameraStr = "";
foreach (string name in hikNameList)
{
cameraStr += name + spiltChar;
}
cameraStr = cameraStr.Substring(0, cameraStr.Length - 1);
ConfigAppSettings.SaveValue(Setting_Init.CameraName, cameraStr);
LogUtil.info("未配置扫码相机,默认【" + Setting_Init.CameraName + "】=【" + cameraStr + "】");
}
}
catch (Exception ex)
{
LogUtil.error("解析摄像机配置出错:" + ex.StackTrace);
}
}
private static void LoadCamera(bool isReLoad)
{
if (isReLoad || Camera._cam == null)
{
try
{
if (Camera._cam != null)
{
Camera._cam.CloseAll();
}
Camera.Type = CameraType.HIK;
Camera._cam.Load();
}
catch (Exception ex)
{
LogUtil.error("加载HIK相机出错:" + ex.ToString());
}
}
string[] names = Camera._cam.Name;
if (names != null)
{
foreach (string n in names)
{
if (!hikNameList.Contains(n))
{
hikNameList.Add(n);
}
}
// hikNameList.AddRange(names);
foreach (string name in hikNameList)
{
LogUtil.info("加载到HIK相机:" + name);
}
}
}
public static void CloseCamera(string cameraName)
{
Camera._cam.Close(cameraName);
}
public static void CloseAllCamera()
{
Camera._cam.CloseAll();
}
[HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan( )
{
int codeCount = 1;
List<string> codeList = new List<string>();
if (cameraNameList == null || cameraNameList.Count <= 0)
{
return codeList;
}
try
{
//Task[] cameraTask = new Task[cameraNameList.Count()];
for(int i= 0;i < cameraNameList.Count();i++)
{
var cameraName = cameraNameList[i];
//cameraTask[i] = Task.Run(() =>
//{
if (cameraName.Trim().Equals(""))
{
continue;
}
DateTime startTime = DateTime.Now;
LogUtil.info(" 【" + cameraName + "】开始取图片");
HalconDotNet.HObject ho_Image = null;
Bitmap bmp = null;
try
{
bool nohalcon = true;
ho_Image = Camera._cam.CaptureOnImage(cameraName, out bmp, nohalcon);
if (ho_Image == null && !nohalcon)
{
LogUtil.error(" 【" + cameraName + "】取图片失败[" + Camera._cam.ErrInfo + "],关闭相机");
CloseCamera(cameraName);
continue;
}
LogUtil.info(" 【" + cameraName + "】取图片完成,开始扫码");
string r = "";
List<CodeInfo> tlci = EyemDecode.Decoder(ref bmp);
foreach (CodeInfo code in tlci)
{
LogUtil.info(" 【" + cameraName + "】[eyemDecode]" + code.CodeType + "(X: " + code.X + ",Y: " + code.Y + ") " + code.CodeStr);
string str = CodeManager.ReplaceCode(code.CodeStr);
lock (codeList)
{
if (!codeList.Contains(str))
{
codeList.Add(str);
r = r + "##" + str;
}
}
}
/*
* List<CodeInfo> cc = new List<CodeInfo>();
foreach (string codeType in codeTypeList)
{
//判断是否是一维码
if (codeType.ToLower().Equals("barcode"))
{
cc = HDCodeHelper.DecodeBarCode(ho_Image);
}
else
{
cc = HDCodeHelper.DecodeCode(ho_Image, codeType, GetCodeParamFilePath(codeType), codeCount, 2000);
}
foreach (CodeInfo c in cc)
{
string str = CodeManager.ReplaceCode(c.CodeStr);
lock (codeList)
{
if (!codeList.Contains(str))
{
codeList.Add(str);
r = r + "##" + str;
}
}
}
}
*/
if (codeList.Count()==0)
{
SaveImageToFile("mimo", cameraName, bmp);
}
LogUtil.info(" 【" + cameraName + "】" + " 扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】 :" + r);
}
catch (AccessViolationException e)
{
LogUtil.error(" 扫码出现AccessViolationException异常,关闭相机【" + cameraName + "】:" + e.ToString());
Camera._cam.Close(cameraName);
// GC.Collect();
}
catch (Exception ex)
{
LogUtil.error(" 扫码出错:" + ex.ToString());
}
finally
{
if (ho_Image != null)
{
ho_Image.Dispose();
}
if (bmp != null)
bmp.Dispose();
}
// });
//cameraTask[i].Wait();
}
//Task.WaitAll(cameraTask);
}
catch (AccessViolationException e)
{
LogUtil.error( " 扫码出现AccessViolationException异常:" + e.ToString());
// GC.Collect();
}
catch (Exception ex)
{
LogUtil.error( " 扫码出错:" + ex.ToString());
}
return codeList;
}
private static void SaveImageToFile(string deviceName, string cameraName, Bitmap bitmap)
{
string date = DateTime.Now.ToString("HH-mm-ss-") + DateTime.Now.Millisecond;
string dire = @"D:\image\" + deviceName.Trim().Replace('_', '-') + @"\" + cameraName.Trim().Replace('_', '-').Replace(':', '-') + @"\";
string iamgeName = date + ".bmp";
try
{
Bitmap bit = (Bitmap)bitmap.Clone();
if (Directory.Exists(dire).Equals(false))
{
Directory.CreateDirectory(dire);
}
bit.Save(dire + iamgeName, ImageFormat.Bmp);
bit.Dispose();
LogUtil.info(deviceName + " 【" + cameraName + "】扫码失败,保存图片到【" + dire + iamgeName + "】成功");
}
catch (Exception ex)
{
LogUtil.error("保存" + deviceName + " 【" + cameraName + "】的图片到【" + dire + iamgeName + "】出错" + ex.ToString());
}
}
/// <summary>
/// 处理接收后的二维码
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
public static string ReplaceCode(string message)
{
message = message.Trim();
message = message.Replace("\r", "");
message = message.Replace("\n", "");
char a = (char)02;
message = message.Replace(a.ToString(), "");
message = message.Trim();
if (!HasChinese(message))
{
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
byte[] bytes = asciiEncoding.GetBytes(message);
List<byte> newBytes = new List<byte>();
foreach (byte by in bytes)
{
int value = (int)by;
if (value.Equals(24) || value.Equals(30) || value.Equals(29) || value.Equals(4))
{
continue;
}
if (!value.Equals(24))
{
newBytes.Add(by);
}
}
message = asciiEncoding.GetString(newBytes.ToArray());
}
return message;
}
public static bool HasChinese(string str)
{
return Regex.IsMatch(str, @"[\u4e00-\u9fa5]");
}
}
}
using HuichuanLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class HCAxisManager : IAxisManager
{
public bool OpenCard()
{
return HCBoardManager.OpenCard();
}
public bool CloseCard()
{
return HCBoardManager.CloseCard();
}
public void AbsMove(string portName, short slvAddr, int targetPosition, int targetSpeed,int ptpAcc,int ptpDec)
{
HCBoardManager.AbsMove((short)slvAddr, targetPosition, targetSpeed, ptpAcc, ptpDec);
}
public void AlarmClear(string portName, short slvAddr)
{
HCBoardManager.ClearAxisSts((short)slvAddr);
}
public int GetActualtPosition(string portName, short slvAddr)
{
return (int)HCBoardManager.GetAxisCurrPos(slvAddr);
}
public int GetAlarmStatus(string portName, short slvAddr)
{
AxisSts axisS= HCBoardManager.GetAxisSts(slvAddr);
return axisS.ALM;
}
public int GetBusyStatus(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
//HCLogUtil.info(axisS.ToStr());
return axisS.BUSY;
}
public int GetHomeEndStatus(string portName, short slvAddr)
{
return (int) HCBoardManager.GetHomeStatus(slvAddr);
}
public int GetHomeSingle(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.ALM;
}
public int GetLimitNegativeSingle(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.NEL;
}
public int GetLimitPositiveSingle(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.PEL;
}
public int GetTargetPosition(string portName, short slvAddr)
{
return (int)HCBoardManager.GetAxisPrfPos(slvAddr);
}
public void HomeMove(string portName, short slvAddr, int highVel, int lowVel, int acc)
{
HCBoardManager.StartHomeMove(slvAddr,(uint) highVel, (uint)lowVel, (uint)acc);
}
public bool IsHomeMoveEnd(string portName, short slvAddr)
{
return HCBoardManager.HomeingIsEnd(slvAddr);
}
public bool isInPosition(string portName, short slvAddr, int PPosition, int canErrorCount, bool isLog = false)
{
return HCBoardManager.IsInPosition(slvAddr, PPosition,canErrorCount );
}
public void RelMove(string portName, short slvAddr, int position, int targetSpeed, int ptpAcc , int ptpDec )
{
HCBoardManager.RelMove(slvAddr, position, targetSpeed, ptpAcc, ptpDec);
}
public bool IsServeoOn(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.ServoOn.Equals(1);
}
public void ServoOff(string portName, short slvAddr)
{
HCBoardManager.ServoOff(slvAddr);
}
public void ServoOn(string portName, short slvAddr)
{
HCBoardManager.ServoOn(slvAddr);
}
public void SpeedMove(string portName, short slvAddr, int speed)
{
HCBoardManager.SpeedMove(slvAddr, speed);
}
public void SuddenStop(string portName, short slvAddr)
{
HCBoardManager.AxisStop(slvAddr);
}
public bool AbsMoveIsEnd(string portName, short axisNo, int targetPosition, int canErrorCount, out bool countError)
{
countError = false;
bool isOk = HCBoardManager.MoveIsEnd(axisNo);
if (isOk)
{
if (HCBoardManager.IsInPosition(axisNo, targetPosition, canErrorCount))
{
return true;
}
else
{
countError = true;
}
}
return false;
}
public short GetErrorCode(string portName, short slvAddr)
{
return HCBoardManager.GetAxErrCode(slvAddr);
}
}
}
using DeviceLibrary;
using HuichuanLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary.IO
{
public class HCIOManager : I_IOManager
{
public void CloseAllConnection()
{
HCBoardManager.CloseCard();
}
public void CloseAllDO()
{
HCBoardManager.CloseAllDO();
}
public bool ConnectionIOList(List<string> dIODeviceNameList)
{
if (!HCBoardManager.CardInitOk())
{
HCBoardManager.InitConfig("", "", "HCBOARD");
return HCBoardManager.OpenCard();
}
return false;
}
public IO_VALUE GetDIValue(string deviceName, byte slaveID, ushort index)
{
short v = HCBoardManager.GetBitDI((short)index);
return (IO_VALUE)v;
}
public IO_VALUE GetDOValue(string deviceName, byte slaveID, ushort index)
{
short v = HCBoardManager.GetBitDO((short)index);
return (IO_VALUE)v;
}
public IO_VALUE GetIOValue(ConfigIO configIO)
{
short index =(short) configIO.GetIOAddr();
short v;
if (configIO.ProType=="DO")
v= HCBoardManager.GetBitDO(index);
else
v = HCBoardManager.GetBitDI(index);
return (IO_VALUE)v;
}
public void ReadAllDI(string deviceName, byte slaveId)
{
}
public void ReadAllDO(string deviceName, byte slaveId)
{
}
public void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value, int time)
{
try
{
short v = (short)value;
HCBoardManager.SetBitDO((short)index, v);
short targetV = 0;
if (v.Equals((short)0))
{
targetV = 1;
}
//写入之后,等待指定间隔后回写
System.Timers.Timer mytimer = new System.Timers.Timer(time);
mytimer.Elapsed += (o1, e1) =>
{
try
{
HCBoardManager.SetBitDO((short)index, targetV);
}
catch (Exception ex)
{
LogUtil.error("**********定时回写入 出错:" + ex.StackTrace);
}
};
mytimer.AutoReset = false;
mytimer.Enabled = true;
}
catch (Exception ex)
{
LogUtil.error("AIO WriteSingleDO [" + index + "] 出错:" + ex.ToString());
}
}
public void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value)
{
short v = (short)value;
HCBoardManager.SetBitDO((short)index, v);
}
}
}
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public interface IAxisManager
{
bool IsServeoOn(string portName, short slvAddr);
bool OpenCard();
bool CloseCard();
bool IsHomeMoveEnd(string portName, short slvAddr);
bool AbsMoveIsEnd(string portName, short axisNo, int targetPosition, int canErrorCount, out bool countError);
void ServoOn(string portName, short slvAddr);
void ServoOff(string portName, short slvAddr);
void RelMove(string portName, short slvAddr, int position, int targetSpeed , int ptpAcc , int ptpDec );
void HomeMove(string portName, short slvAddr, int highVel, int lowVel, int acc);
void SpeedMove(string portName, short slvAddr, int speed);
void SuddenStop(string portName, short slvAddr);
bool isInPosition(string portName, short slvAddr, int PPosition, int canErrorCount, bool isLog = false);
void AbsMove(string portName, short slvAddr, int targetPosition, int targetSpeed , int ptpAcc , int ptpDec );
void AlarmClear(string portName, short slvAddr);
int GetTargetPosition(string portName, short slvAddr);
int GetActualtPosition(string portName, short slvAddr);
int GetAlarmStatus(string portName, short slvAddr);
int GetBusyStatus(string portName, short slvAddr);
int GetHomeEndStatus(string portName, short slvAddr);
int GetHomeSingle(string portName, short slvAddr);
/// <summary>
/// 负极限
/// </summary>
int GetLimitNegativeSingle(string portName, short slvAddr);
/// <summary>
/// 正极限
/// </summary>
int GetLimitPositiveSingle(string portName, short slvAddr);
short GetErrorCode(string portName, short slvAddr);
}
}
using DeviceLibrary;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary.IO;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace DeviceLibrary
{
using StoreManager = RobotManage;
public class IOManager
{
static I_IOManager instance = null;
static IOManager()
{
instance = new HCIOManager();
}
public static void IOMove(string ioType, IO_VALUE ioValue)
{
if (StoreManager.Config.DOList.ContainsKey(ioType))
{
ConfigIO configIo = StoreManager.Config.DOList[ioType];
instance.WriteSingleDO(configIo.DeviceName, configIo.SlaveID, configIo.GetIOAddr(), ioValue);
Thread.Sleep(60);
}
else
{
LogUtil.error("没有DO=" + ioType);
}
}
public static IO_VALUE IOValue(string ioType)
{
IO_VALUE ioValue = IO_VALUE.LOW;
if (StoreManager.Config.DIList.ContainsKey(ioType))
{
ConfigIO configIo = StoreManager.Config.DIList[ioType];
ioValue = instance.GetDIValue(configIo.DeviceName, configIo.SlaveID, configIo.GetIOAddr());
//UpdateDoValue(ioType, ioValue);
}
else if (StoreManager.Config.DOList.ContainsKey(ioType))
{
ConfigIO configIo = StoreManager.Config.DOList[ioType];
ioValue = instance.GetDOValue(configIo.DeviceName, configIo.SlaveID, configIo.GetIOAddr());
}
else
{
LogUtil.error("没有DO=" + ioType);
}
return ioValue;
}
public static IO_VALUE DOValue(string ioType)
{
IO_VALUE ioValue = IO_VALUE.LOW;
if (StoreManager.Config.DOList.ContainsKey(ioType))
{
ConfigIO configIo = StoreManager.Config.DOList[ioType];
ioValue = instance.GetDOValue(configIo.DeviceName, configIo.SlaveID, configIo.GetIOAddr());
}
else
{
LogUtil.error("没有DO=" + ioType);
}
return ioValue;
}
public static bool ConnectionIOList(List<string> dIODeviceNameList)
{
return instance.ConnectionIOList(dIODeviceNameList);
}
static void ReadAllDI(string deviceName, byte slaveId)
{
instance.ReadAllDI(deviceName, slaveId);
}
static void ReadAllDO(string deviceName, byte slaveId)
{
instance.ReadAllDO(deviceName, slaveId);
}
public static void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value, int time)
{
instance.WriteSingleDO(deviceName, slaveId, index, value, time);
}
public static void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value)
{
instance.WriteSingleDO(deviceName, slaveId, index, value);
}
public static IO_VALUE GetDIValue(string deviceName, byte slaveID, ushort v)
{
return instance.GetDIValue(deviceName, slaveID, v);
}
public static IO_VALUE GetDOValue(string deviceName, byte slaveID, ushort v)
{
return instance.GetDOValue(deviceName, slaveID, v);
}
public static IO_VALUE GetIOValue(ConfigIO configIO)
{
return instance.GetIOValue(configIO);
}
public static void CloseAllDO()
{
instance.CloseAllDO();
}
public static void CloseAllConnection()
{
instance.CloseAllConnection();
}
}
}
using DeviceLibrary;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary.IO;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace DeviceLibrary
{
public interface I_IOManager
{
bool ConnectionIOList(List<string> dIODeviceNameList);
void ReadAllDI(string deviceName, byte slaveId);
void ReadAllDO(string deviceName, byte slaveId);
void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value, int time);
void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value);
IO_VALUE GetDIValue(string deviceName, byte slaveID, ushort v);
IO_VALUE GetDOValue(string deviceName, byte slaveID, ushort v);
IO_VALUE GetIOValue(ConfigIO configIO);
void CloseAllDO();
void CloseAllConnection();
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("DeviceLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DeviceLibrary")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("bb23296c-aa1d-45c6-9fa6-5a37b2abfe9b")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
namespace DeviceLibrary
{
partial class AxisMoveControl
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.groupAxis = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label4 = new System.Windows.Forms.Label();
this.lblhomeSts = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.lblAxEncAcc = new System.Windows.Forms.Label();
this.lblINP = new System.Windows.Forms.Label();
this.lblBUSY = new System.Windows.Forms.Label();
this.lblNEL = new System.Windows.Forms.Label();
this.lblORG = new System.Windows.Forms.Label();
this.lblPEL = new System.Windows.Forms.Label();
this.lblSvOn = new System.Windows.Forms.Label();
this.lblEMG = new System.Windows.Forms.Label();
this.lblWARN = new System.Windows.Forms.Label();
this.lblALM = new System.Windows.Forms.Label();
this.label53 = new System.Windows.Forms.Label();
this.label56 = new System.Windows.Forms.Label();
this.label55 = new System.Windows.Forms.Label();
this.label52 = new System.Windows.Forms.Label();
this.lblAxEncVel = new System.Windows.Forms.Label();
this.lblAxPrfVel = new System.Windows.Forms.Label();
this.lblAxEncPos = new System.Windows.Forms.Label();
this.lblAxPrfPos = new System.Windows.Forms.Label();
this.lblAxisPrfMode = new System.Windows.Forms.Label();
this.label50 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtBusyStatus = new System.Windows.Forms.TextBox();
this.label11 = new System.Windows.Forms.Label();
this.txtHomeStatus = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label24 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.btnGetAlarm = new System.Windows.Forms.Button();
this.txtAlarmStatus = new System.Windows.Forms.TextBox();
this.txtLimit2 = new System.Windows.Forms.TextBox();
this.txtServoStatue = new System.Windows.Forms.TextBox();
this.label22 = new System.Windows.Forms.Label();
this.txtLimit1 = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.txtHomeSingle = new System.Windows.Forms.TextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.comjSpeed = new System.Windows.Forms.ComboBox();
this.btnComAlarmClear = new System.Windows.Forms.Button();
this.btnAxisStop = new System.Windows.Forms.Button();
this.btnAxisReturnHome = new System.Windows.Forms.Button();
this.cmbAxis = new System.Windows.Forms.ComboBox();
this.btnDelMove = new System.Windows.Forms.Button();
this.btnOpenAxis = new System.Windows.Forms.Button();
this.btnCloseAxis = new System.Windows.Forms.Button();
this.btnAddMove = new System.Windows.Forms.Button();
this.txtASpeed = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label47 = new System.Windows.Forms.Label();
this.btnReadPosition = new System.Windows.Forms.Button();
this.btnAxisVMove = new System.Windows.Forms.Button();
this.label8 = new System.Windows.Forms.Label();
this.btnAxisRMove = new System.Windows.Forms.Button();
this.lblCountPulse = new System.Windows.Forms.TextBox();
this.btnAxisAMove = new System.Windows.Forms.Button();
this.label49 = new System.Windows.Forms.Label();
this.txtAPosition = new System.Windows.Forms.TextBox();
this.label46 = new System.Windows.Forms.Label();
this.label48 = new System.Windows.Forms.Label();
this.label45 = new System.Windows.Forms.Label();
this.txtAxisValue = new System.Windows.Forms.TextBox();
this.txtAxisDeviceName = new System.Windows.Forms.TextBox();
this.lblServerOn = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.lblAlarmcode = new System.Windows.Forms.Label();
this.groupAxis.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// groupAxis
//
this.groupAxis.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupAxis.BackColor = System.Drawing.Color.White;
this.groupAxis.Controls.Add(this.groupBox2);
this.groupAxis.Controls.Add(this.groupBox1);
this.groupAxis.Controls.Add(this.panel1);
this.groupAxis.Controls.Add(this.lblServerOn);
this.groupAxis.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupAxis.Location = new System.Drawing.Point(4, 3);
this.groupAxis.Name = "groupAxis";
this.groupAxis.Size = new System.Drawing.Size(692, 395);
this.groupAxis.TabIndex = 218;
this.groupAxis.TabStop = false;
this.groupAxis.Text = "伺服运动";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.lblAlarmcode);
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.lblhomeSts);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.lblAxEncAcc);
this.groupBox2.Controls.Add(this.lblINP);
this.groupBox2.Controls.Add(this.lblBUSY);
this.groupBox2.Controls.Add(this.lblNEL);
this.groupBox2.Controls.Add(this.lblORG);
this.groupBox2.Controls.Add(this.lblPEL);
this.groupBox2.Controls.Add(this.lblSvOn);
this.groupBox2.Controls.Add(this.lblEMG);
this.groupBox2.Controls.Add(this.lblWARN);
this.groupBox2.Controls.Add(this.lblALM);
this.groupBox2.Controls.Add(this.label53);
this.groupBox2.Controls.Add(this.label56);
this.groupBox2.Controls.Add(this.label55);
this.groupBox2.Controls.Add(this.label52);
this.groupBox2.Controls.Add(this.lblAxEncVel);
this.groupBox2.Controls.Add(this.lblAxPrfVel);
this.groupBox2.Controls.Add(this.lblAxEncPos);
this.groupBox2.Controls.Add(this.lblAxPrfPos);
this.groupBox2.Controls.Add(this.lblAxisPrfMode);
this.groupBox2.Controls.Add(this.label50);
this.groupBox2.Location = new System.Drawing.Point(7, 270);
this.groupBox2.Margin = new System.Windows.Forms.Padding(2);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Padding = new System.Windows.Forms.Padding(2);
this.groupBox2.Size = new System.Drawing.Size(540, 118);
this.groupBox2.TabIndex = 303;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "轴状态监控";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(267, 90);
this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(59, 17);
this.label4.TabIndex = 18;
this.label4.Text = "回原状态:";
//
// lblhomeSts
//
this.lblhomeSts.AutoSize = true;
this.lblhomeSts.Location = new System.Drawing.Point(332, 90);
this.lblhomeSts.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblhomeSts.Name = "lblhomeSts";
this.lblhomeSts.Size = new System.Drawing.Size(17, 17);
this.lblhomeSts.TabIndex = 17;
this.lblhomeSts.Text = "...";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(433, 90);
this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(71, 17);
this.label2.TabIndex = 11;
this.label2.Text = "实际加速度:";
this.label2.Visible = false;
//
// lblAxEncAcc
//
this.lblAxEncAcc.AutoSize = true;
this.lblAxEncAcc.Location = new System.Drawing.Point(510, 90);
this.lblAxEncAcc.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblAxEncAcc.Name = "lblAxEncAcc";
this.lblAxEncAcc.Size = new System.Drawing.Size(17, 17);
this.lblAxEncAcc.TabIndex = 12;
this.lblAxEncAcc.Text = "...";
this.lblAxEncAcc.Visible = false;
//
// lblINP
//
this.lblINP.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblINP.Location = new System.Drawing.Point(414, 24);
this.lblINP.Name = "lblINP";
this.lblINP.Size = new System.Drawing.Size(56, 30);
this.lblINP.TabIndex = 10;
this.lblINP.Text = "到位";
this.lblINP.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblBUSY
//
this.lblBUSY.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblBUSY.Location = new System.Drawing.Point(356, 24);
this.lblBUSY.Name = "lblBUSY";
this.lblBUSY.Size = new System.Drawing.Size(56, 30);
this.lblBUSY.TabIndex = 9;
this.lblBUSY.Text = "忙碌";
this.lblBUSY.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblNEL
//
this.lblNEL.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblNEL.Location = new System.Drawing.Point(298, 24);
this.lblNEL.Name = "lblNEL";
this.lblNEL.Size = new System.Drawing.Size(56, 30);
this.lblNEL.TabIndex = 8;
this.lblNEL.Text = "负极限";
this.lblNEL.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblORG
//
this.lblORG.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblORG.Location = new System.Drawing.Point(240, 24);
this.lblORG.Name = "lblORG";
this.lblORG.Size = new System.Drawing.Size(56, 30);
this.lblORG.TabIndex = 7;
this.lblORG.Text = "原点";
this.lblORG.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblPEL
//
this.lblPEL.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblPEL.Location = new System.Drawing.Point(182, 24);
this.lblPEL.Name = "lblPEL";
this.lblPEL.Size = new System.Drawing.Size(56, 30);
this.lblPEL.TabIndex = 6;
this.lblPEL.Text = "正极限";
this.lblPEL.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblSvOn
//
this.lblSvOn.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblSvOn.Location = new System.Drawing.Point(8, 24);
this.lblSvOn.Name = "lblSvOn";
this.lblSvOn.Size = new System.Drawing.Size(56, 30);
this.lblSvOn.TabIndex = 5;
this.lblSvOn.Text = "伺服";
this.lblSvOn.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblEMG
//
this.lblEMG.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblEMG.Location = new System.Drawing.Point(124, 24);
this.lblEMG.Name = "lblEMG";
this.lblEMG.Size = new System.Drawing.Size(56, 30);
this.lblEMG.TabIndex = 4;
this.lblEMG.Text = "急停";
this.lblEMG.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblWARN
//
this.lblWARN.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblWARN.Location = new System.Drawing.Point(472, 24);
this.lblWARN.Name = "lblWARN";
this.lblWARN.Size = new System.Drawing.Size(56, 30);
this.lblWARN.TabIndex = 3;
this.lblWARN.Text = "警告";
this.lblWARN.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblALM
//
this.lblALM.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblALM.Location = new System.Drawing.Point(66, 24);
this.lblALM.Name = "lblALM";
this.lblALM.Size = new System.Drawing.Size(56, 30);
this.lblALM.TabIndex = 2;
this.lblALM.Text = "报警";
this.lblALM.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label53
//
this.label53.AutoSize = true;
this.label53.Location = new System.Drawing.Point(134, 90);
this.label53.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label53.Name = "label53";
this.label53.Size = new System.Drawing.Size(59, 17);
this.label53.TabIndex = 1;
this.label53.Text = "规划速度:";
//
// label56
//
this.label56.AutoSize = true;
this.label56.Location = new System.Drawing.Point(10, 90);
this.label56.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label56.Name = "label56";
this.label56.Size = new System.Drawing.Size(59, 17);
this.label56.TabIndex = 1;
this.label56.Text = "实际速度:";
//
// label55
//
this.label55.AutoSize = true;
this.label55.Location = new System.Drawing.Point(10, 65);
this.label55.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label55.Name = "label55";
this.label55.Size = new System.Drawing.Size(59, 17);
this.label55.TabIndex = 1;
this.label55.Text = "实际位置:";
//
// label52
//
this.label52.AutoSize = true;
this.label52.Location = new System.Drawing.Point(134, 65);
this.label52.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label52.Name = "label52";
this.label52.Size = new System.Drawing.Size(59, 17);
this.label52.TabIndex = 1;
this.label52.Text = "规划位置:";
//
// lblAxEncVel
//
this.lblAxEncVel.AutoSize = true;
this.lblAxEncVel.Location = new System.Drawing.Point(73, 90);
this.lblAxEncVel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblAxEncVel.Name = "lblAxEncVel";
this.lblAxEncVel.Size = new System.Drawing.Size(17, 17);
this.lblAxEncVel.TabIndex = 1;
this.lblAxEncVel.Text = "...";
//
// lblAxPrfVel
//
this.lblAxPrfVel.AutoSize = true;
this.lblAxPrfVel.Location = new System.Drawing.Point(199, 90);
this.lblAxPrfVel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblAxPrfVel.Name = "lblAxPrfVel";
this.lblAxPrfVel.Size = new System.Drawing.Size(17, 17);
this.lblAxPrfVel.TabIndex = 1;
this.lblAxPrfVel.Text = "...";
//
// lblAxEncPos
//
this.lblAxEncPos.AutoSize = true;
this.lblAxEncPos.Location = new System.Drawing.Point(73, 65);
this.lblAxEncPos.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblAxEncPos.Name = "lblAxEncPos";
this.lblAxEncPos.Size = new System.Drawing.Size(17, 17);
this.lblAxEncPos.TabIndex = 1;
this.lblAxEncPos.Text = "...";
//
// lblAxPrfPos
//
this.lblAxPrfPos.AutoSize = true;
this.lblAxPrfPos.Location = new System.Drawing.Point(199, 65);
this.lblAxPrfPos.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblAxPrfPos.Name = "lblAxPrfPos";
this.lblAxPrfPos.Size = new System.Drawing.Size(17, 17);
this.lblAxPrfPos.TabIndex = 1;
this.lblAxPrfPos.Text = "...";
//
// lblAxisPrfMode
//
this.lblAxisPrfMode.AutoSize = true;
this.lblAxisPrfMode.Location = new System.Drawing.Point(332, 65);
this.lblAxisPrfMode.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblAxisPrfMode.Name = "lblAxisPrfMode";
this.lblAxisPrfMode.Size = new System.Drawing.Size(17, 17);
this.lblAxisPrfMode.TabIndex = 1;
this.lblAxisPrfMode.Text = "...";
//
// label50
//
this.label50.AutoSize = true;
this.label50.Location = new System.Drawing.Point(267, 65);
this.label50.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label50.Name = "label50";
this.label50.Size = new System.Drawing.Size(59, 17);
this.label50.TabIndex = 1;
this.label50.Text = "规划模式:";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.txtBusyStatus);
this.groupBox1.Controls.Add(this.label11);
this.groupBox1.Controls.Add(this.txtHomeStatus);
this.groupBox1.Controls.Add(this.label10);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label24);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.btnGetAlarm);
this.groupBox1.Controls.Add(this.txtAlarmStatus);
this.groupBox1.Controls.Add(this.txtLimit2);
this.groupBox1.Controls.Add(this.txtServoStatue);
this.groupBox1.Controls.Add(this.label22);
this.groupBox1.Controls.Add(this.txtLimit1);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.txtHomeSingle);
this.groupBox1.Location = new System.Drawing.Point(553, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(135, 260);
this.groupBox1.TabIndex = 302;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "状态";
//
// txtBusyStatus
//
this.txtBusyStatus.Enabled = false;
this.txtBusyStatus.Location = new System.Drawing.Point(99, 76);
this.txtBusyStatus.Name = "txtBusyStatus";
this.txtBusyStatus.Size = new System.Drawing.Size(25, 23);
this.txtBusyStatus.TabIndex = 288;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(31, 107);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(59, 17);
this.label11.TabIndex = 292;
this.label11.Text = "回零状态:";
//
// txtHomeStatus
//
this.txtHomeStatus.Enabled = false;
this.txtHomeStatus.Location = new System.Drawing.Point(99, 104);
this.txtHomeStatus.Name = "txtHomeStatus";
this.txtHomeStatus.Size = new System.Drawing.Size(25, 23);
this.txtHomeStatus.TabIndex = 291;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(24, 79);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(66, 17);
this.label10.TabIndex = 289;
this.label10.Text = "BUSY状态:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(31, 51);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(59, 17);
this.label3.TabIndex = 286;
this.label3.Text = "报警状态:";
//
// label24
//
this.label24.AutoSize = true;
this.label24.Location = new System.Drawing.Point(19, 191);
this.label24.Name = "label24";
this.label24.Size = new System.Drawing.Size(71, 17);
this.label24.TabIndex = 316;
this.label24.Text = "负极限信号:";
this.label24.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(31, 23);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(59, 17);
this.label5.TabIndex = 328;
this.label5.Text = "伺服状态:";
//
// btnGetAlarm
//
this.btnGetAlarm.BackColor = System.Drawing.Color.White;
this.btnGetAlarm.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnGetAlarm.Location = new System.Drawing.Point(14, 218);
this.btnGetAlarm.Name = "btnGetAlarm";
this.btnGetAlarm.Size = new System.Drawing.Size(110, 34);
this.btnGetAlarm.TabIndex = 284;
this.btnGetAlarm.Text = "读报状态";
this.btnGetAlarm.UseVisualStyleBackColor = false;
this.btnGetAlarm.Click += new System.EventHandler(this.btnGetAlarm_Click);
//
// txtAlarmStatus
//
this.txtAlarmStatus.Enabled = false;
this.txtAlarmStatus.Location = new System.Drawing.Point(99, 48);
this.txtAlarmStatus.Name = "txtAlarmStatus";
this.txtAlarmStatus.Size = new System.Drawing.Size(25, 23);
this.txtAlarmStatus.TabIndex = 285;
//
// txtLimit2
//
this.txtLimit2.Enabled = false;
this.txtLimit2.Location = new System.Drawing.Point(99, 188);
this.txtLimit2.Name = "txtLimit2";
this.txtLimit2.Size = new System.Drawing.Size(25, 23);
this.txtLimit2.TabIndex = 313;
//
// txtServoStatue
//
this.txtServoStatue.Enabled = false;
this.txtServoStatue.Location = new System.Drawing.Point(99, 20);
this.txtServoStatue.Name = "txtServoStatue";
this.txtServoStatue.Size = new System.Drawing.Size(25, 23);
this.txtServoStatue.TabIndex = 327;
//
// label22
//
this.label22.AutoSize = true;
this.label22.Location = new System.Drawing.Point(19, 163);
this.label22.Name = "label22";
this.label22.Size = new System.Drawing.Size(71, 17);
this.label22.TabIndex = 312;
this.label22.Text = "正极限信号:";
this.label22.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtLimit1
//
this.txtLimit1.Enabled = false;
this.txtLimit1.Location = new System.Drawing.Point(99, 160);
this.txtLimit1.Name = "txtLimit1";
this.txtLimit1.Size = new System.Drawing.Size(25, 23);
this.txtLimit1.TabIndex = 309;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(31, 135);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(59, 17);
this.label6.TabIndex = 300;
this.label6.Text = "原点信号:";
//
// txtHomeSingle
//
this.txtHomeSingle.Enabled = false;
this.txtHomeSingle.Location = new System.Drawing.Point(99, 132);
this.txtHomeSingle.Name = "txtHomeSingle";
this.txtHomeSingle.Size = new System.Drawing.Size(25, 23);
this.txtHomeSingle.TabIndex = 297;
//
// panel1
//
this.panel1.Controls.Add(this.linkLabel1);
this.panel1.Controls.Add(this.comjSpeed);
this.panel1.Controls.Add(this.btnComAlarmClear);
this.panel1.Controls.Add(this.btnAxisStop);
this.panel1.Controls.Add(this.btnAxisReturnHome);
this.panel1.Controls.Add(this.cmbAxis);
this.panel1.Controls.Add(this.btnDelMove);
this.panel1.Controls.Add(this.btnOpenAxis);
this.panel1.Controls.Add(this.btnCloseAxis);
this.panel1.Controls.Add(this.btnAddMove);
this.panel1.Controls.Add(this.txtASpeed);
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.label47);
this.panel1.Controls.Add(this.btnReadPosition);
this.panel1.Controls.Add(this.btnAxisVMove);
this.panel1.Controls.Add(this.label8);
this.panel1.Controls.Add(this.btnAxisRMove);
this.panel1.Controls.Add(this.lblCountPulse);
this.panel1.Controls.Add(this.btnAxisAMove);
this.panel1.Controls.Add(this.label49);
this.panel1.Controls.Add(this.txtAPosition);
this.panel1.Controls.Add(this.label46);
this.panel1.Controls.Add(this.label48);
this.panel1.Controls.Add(this.label45);
this.panel1.Controls.Add(this.txtAxisValue);
this.panel1.Controls.Add(this.txtAxisDeviceName);
this.panel1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.panel1.Location = new System.Drawing.Point(7, 17);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(540, 250);
this.panel1.TabIndex = 219;
//
// linkLabel1
//
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(169, 165);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(32, 17);
this.linkLabel1.TabIndex = 336;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "复制";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// comjSpeed
//
this.comjSpeed.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comjSpeed.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.comjSpeed.FormattingEnabled = true;
this.comjSpeed.Location = new System.Drawing.Point(71, 207);
this.comjSpeed.Name = "comjSpeed";
this.comjSpeed.Size = new System.Drawing.Size(95, 28);
this.comjSpeed.TabIndex = 335;
//
// btnComAlarmClear
//
this.btnComAlarmClear.BackColor = System.Drawing.Color.White;
this.btnComAlarmClear.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnComAlarmClear.Location = new System.Drawing.Point(307, 154);
this.btnComAlarmClear.Name = "btnComAlarmClear";
this.btnComAlarmClear.Size = new System.Drawing.Size(110, 34);
this.btnComAlarmClear.TabIndex = 50;
this.btnComAlarmClear.Text = "清除报警";
this.btnComAlarmClear.UseVisualStyleBackColor = false;
this.btnComAlarmClear.Click += new System.EventHandler(this.btnComAlarmClear_Click);
//
// btnAxisStop
//
this.btnAxisStop.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.btnAxisStop.Cursor = System.Windows.Forms.Cursors.Default;
this.btnAxisStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnAxisStop.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAxisStop.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnAxisStop.Location = new System.Drawing.Point(427, 78);
this.btnAxisStop.Name = "btnAxisStop";
this.btnAxisStop.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.btnAxisStop.Size = new System.Drawing.Size(110, 110);
this.btnAxisStop.TabIndex = 246;
this.btnAxisStop.Text = " 停止运动";
this.btnAxisStop.UseVisualStyleBackColor = false;
this.btnAxisStop.Click += new System.EventHandler(this.btnAxisStop_Click);
//
// btnAxisReturnHome
//
this.btnAxisReturnHome.BackColor = System.Drawing.Color.White;
this.btnAxisReturnHome.Cursor = System.Windows.Forms.Cursors.Default;
this.btnAxisReturnHome.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnAxisReturnHome.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAxisReturnHome.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnAxisReturnHome.Location = new System.Drawing.Point(307, 116);
this.btnAxisReturnHome.Name = "btnAxisReturnHome";
this.btnAxisReturnHome.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.btnAxisReturnHome.Size = new System.Drawing.Size(110, 34);
this.btnAxisReturnHome.TabIndex = 247;
this.btnAxisReturnHome.Text = "原点返回";
this.btnAxisReturnHome.UseVisualStyleBackColor = false;
this.btnAxisReturnHome.Click += new System.EventHandler(this.btnAxisReturnHome_Click);
//
// cmbAxis
//
this.cmbAxis.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbAxis.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.cmbAxis.FormattingEnabled = true;
this.cmbAxis.Location = new System.Drawing.Point(71, 6);
this.cmbAxis.Name = "cmbAxis";
this.cmbAxis.Size = new System.Drawing.Size(227, 28);
this.cmbAxis.TabIndex = 301;
this.cmbAxis.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// btnDelMove
//
this.btnDelMove.BackColor = System.Drawing.Color.White;
this.btnDelMove.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnDelMove.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnDelMove.Location = new System.Drawing.Point(321, 199);
this.btnDelMove.Name = "btnDelMove";
this.btnDelMove.Size = new System.Drawing.Size(140, 45);
this.btnDelMove.TabIndex = 332;
this.btnDelMove.Text = "点动-(上升)";
this.btnDelMove.UseVisualStyleBackColor = false;
this.btnDelMove.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnDelMove_MouseDown);
this.btnDelMove.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnDelMove_MouseUp);
//
// btnOpenAxis
//
this.btnOpenAxis.BackColor = System.Drawing.Color.White;
this.btnOpenAxis.Cursor = System.Windows.Forms.Cursors.Default;
this.btnOpenAxis.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOpenAxis.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOpenAxis.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnOpenAxis.Location = new System.Drawing.Point(307, 2);
this.btnOpenAxis.Name = "btnOpenAxis";
this.btnOpenAxis.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.btnOpenAxis.Size = new System.Drawing.Size(110, 34);
this.btnOpenAxis.TabIndex = 253;
this.btnOpenAxis.Text = "打开伺服";
this.btnOpenAxis.UseVisualStyleBackColor = false;
this.btnOpenAxis.Click += new System.EventHandler(this.btnOpenAxis_Click);
//
// btnCloseAxis
//
this.btnCloseAxis.BackColor = System.Drawing.Color.White;
this.btnCloseAxis.Cursor = System.Windows.Forms.Cursors.Default;
this.btnCloseAxis.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCloseAxis.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCloseAxis.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnCloseAxis.Location = new System.Drawing.Point(427, 2);
this.btnCloseAxis.Name = "btnCloseAxis";
this.btnCloseAxis.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.btnCloseAxis.Size = new System.Drawing.Size(110, 34);
this.btnCloseAxis.TabIndex = 252;
this.btnCloseAxis.Text = "关闭伺服";
this.btnCloseAxis.UseVisualStyleBackColor = false;
this.btnCloseAxis.Click += new System.EventHandler(this.btnCloseAxis_Click);
//
// btnAddMove
//
this.btnAddMove.BackColor = System.Drawing.Color.White;
this.btnAddMove.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnAddMove.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAddMove.Location = new System.Drawing.Point(172, 199);
this.btnAddMove.Name = "btnAddMove";
this.btnAddMove.Size = new System.Drawing.Size(140, 45);
this.btnAddMove.TabIndex = 330;
this.btnAddMove.Text = "点动+(上升)";
this.btnAddMove.UseVisualStyleBackColor = false;
this.btnAddMove.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnAddMove_MouseDown);
this.btnAddMove.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnAddMove_MouseUp);
//
// txtASpeed
//
this.txtASpeed.AcceptsReturn = true;
this.txtASpeed.BackColor = System.Drawing.SystemColors.Window;
this.txtASpeed.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtASpeed.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtASpeed.ForeColor = System.Drawing.SystemColors.WindowText;
this.txtASpeed.Location = new System.Drawing.Point(207, 88);
this.txtASpeed.MaxLength = 12;
this.txtASpeed.Name = "txtASpeed";
this.txtASpeed.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtASpeed.Size = new System.Drawing.Size(91, 26);
this.txtASpeed.TabIndex = 251;
this.txtASpeed.Text = "200";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 213);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(68, 17);
this.label1.TabIndex = 329;
this.label1.Text = "点动速度:";
//
// label47
//
this.label47.AutoSize = true;
this.label47.Cursor = System.Windows.Forms.Cursors.Default;
this.label47.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label47.ForeColor = System.Drawing.SystemColors.ControlText;
this.label47.Location = new System.Drawing.Point(142, 93);
this.label47.Name = "label47";
this.label47.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label47.Size = new System.Drawing.Size(59, 17);
this.label47.TabIndex = 250;
this.label47.Text = "目标速度:";
this.label47.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btnReadPosition
//
this.btnReadPosition.BackColor = System.Drawing.Color.White;
this.btnReadPosition.Cursor = System.Windows.Forms.Cursors.Default;
this.btnReadPosition.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnReadPosition.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnReadPosition.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnReadPosition.Location = new System.Drawing.Point(207, 127);
this.btnReadPosition.Name = "btnReadPosition";
this.btnReadPosition.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.btnReadPosition.Size = new System.Drawing.Size(91, 34);
this.btnReadPosition.TabIndex = 278;
this.btnReadPosition.Text = "读取位置";
this.btnReadPosition.UseVisualStyleBackColor = false;
this.btnReadPosition.Click += new System.EventHandler(this.btnReadPosition_Click);
//
// btnAxisVMove
//
this.btnAxisVMove.BackColor = System.Drawing.Color.White;
this.btnAxisVMove.Cursor = System.Windows.Forms.Cursors.Default;
this.btnAxisVMove.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnAxisVMove.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAxisVMove.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnAxisVMove.Location = new System.Drawing.Point(307, 78);
this.btnAxisVMove.Name = "btnAxisVMove";
this.btnAxisVMove.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.btnAxisVMove.Size = new System.Drawing.Size(110, 34);
this.btnAxisVMove.TabIndex = 249;
this.btnAxisVMove.Text = "匀速运动";
this.btnAxisVMove.UseVisualStyleBackColor = false;
this.btnAxisVMove.Click += new System.EventHandler(this.btnAxisVMove_Click);
//
// label8
//
this.label8.AutoSize = true;
this.label8.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label8.Location = new System.Drawing.Point(18, 136);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(59, 17);
this.label8.TabIndex = 255;
this.label8.Text = "实时位置:";
//
// btnAxisRMove
//
this.btnAxisRMove.BackColor = System.Drawing.Color.White;
this.btnAxisRMove.Cursor = System.Windows.Forms.Cursors.Default;
this.btnAxisRMove.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnAxisRMove.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAxisRMove.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnAxisRMove.Location = new System.Drawing.Point(427, 39);
this.btnAxisRMove.Name = "btnAxisRMove";
this.btnAxisRMove.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.btnAxisRMove.Size = new System.Drawing.Size(110, 34);
this.btnAxisRMove.TabIndex = 248;
this.btnAxisRMove.Text = "相对运动";
this.btnAxisRMove.UseVisualStyleBackColor = false;
this.btnAxisRMove.Click += new System.EventHandler(this.btnAxisRMove_Click);
//
// lblCountPulse
//
this.lblCountPulse.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblCountPulse.Location = new System.Drawing.Point(83, 131);
this.lblCountPulse.Name = "lblCountPulse";
this.lblCountPulse.ReadOnly = true;
this.lblCountPulse.Size = new System.Drawing.Size(118, 26);
this.lblCountPulse.TabIndex = 38;
//
// btnAxisAMove
//
this.btnAxisAMove.BackColor = System.Drawing.Color.White;
this.btnAxisAMove.Cursor = System.Windows.Forms.Cursors.Default;
this.btnAxisAMove.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnAxisAMove.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAxisAMove.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnAxisAMove.Location = new System.Drawing.Point(307, 40);
this.btnAxisAMove.Name = "btnAxisAMove";
this.btnAxisAMove.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.btnAxisAMove.Size = new System.Drawing.Size(110, 34);
this.btnAxisAMove.TabIndex = 245;
this.btnAxisAMove.Text = "绝对运动";
this.btnAxisAMove.UseVisualStyleBackColor = false;
this.btnAxisAMove.Click += new System.EventHandler(this.btnAxisAMove_Click);
//
// label49
//
this.label49.AutoSize = true;
this.label49.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label49.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label49.Location = new System.Drawing.Point(10, 11);
this.label49.Name = "label49";
this.label49.Size = new System.Drawing.Size(51, 17);
this.label49.TabIndex = 233;
this.label49.Text = "AC伺服:";
this.label49.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtAPosition
//
this.txtAPosition.BackColor = System.Drawing.SystemColors.Window;
this.txtAPosition.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtAPosition.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtAPosition.ForeColor = System.Drawing.SystemColors.WindowText;
this.txtAPosition.Location = new System.Drawing.Point(207, 48);
this.txtAPosition.MaxLength = 12;
this.txtAPosition.Name = "txtAPosition";
this.txtAPosition.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtAPosition.Size = new System.Drawing.Size(91, 26);
this.txtAPosition.TabIndex = 244;
this.txtAPosition.Text = "3000";
//
// label46
//
this.label46.AutoSize = true;
this.label46.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label46.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label46.Location = new System.Drawing.Point(26, 93);
this.label46.Name = "label46";
this.label46.Size = new System.Drawing.Size(35, 17);
this.label46.TabIndex = 239;
this.label46.Text = "地址:";
this.label46.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label48
//
this.label48.AutoSize = true;
this.label48.Cursor = System.Windows.Forms.Cursors.Default;
this.label48.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label48.ForeColor = System.Drawing.SystemColors.ControlText;
this.label48.Location = new System.Drawing.Point(142, 53);
this.label48.Name = "label48";
this.label48.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label48.Size = new System.Drawing.Size(59, 17);
this.label48.TabIndex = 243;
this.label48.Text = "目标位置:";
this.label48.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label45
//
this.label45.AutoSize = true;
this.label45.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label45.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label45.Location = new System.Drawing.Point(14, 53);
this.label45.Name = "label45";
this.label45.Size = new System.Drawing.Size(47, 17);
this.label45.TabIndex = 240;
this.label45.Text = "端口号:";
this.label45.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtAxisValue
//
this.txtAxisValue.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtAxisValue.Location = new System.Drawing.Point(71, 88);
this.txtAxisValue.MaxLength = 10;
this.txtAxisValue.Name = "txtAxisValue";
this.txtAxisValue.ReadOnly = true;
this.txtAxisValue.Size = new System.Drawing.Size(50, 26);
this.txtAxisValue.TabIndex = 242;
this.txtAxisValue.Text = "0";
//
// txtAxisDeviceName
//
this.txtAxisDeviceName.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtAxisDeviceName.Location = new System.Drawing.Point(71, 48);
this.txtAxisDeviceName.MaxLength = 10;
this.txtAxisDeviceName.Name = "txtAxisDeviceName";
this.txtAxisDeviceName.ReadOnly = true;
this.txtAxisDeviceName.Size = new System.Drawing.Size(50, 26);
this.txtAxisDeviceName.TabIndex = 241;
this.txtAxisDeviceName.Text = "0";
//
// lblServerOn
//
this.lblServerOn.AutoSize = true;
this.lblServerOn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.lblServerOn.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblServerOn.ForeColor = System.Drawing.Color.Red;
this.lblServerOn.Location = new System.Drawing.Point(32, 115);
this.lblServerOn.Name = "lblServerOn";
this.lblServerOn.Size = new System.Drawing.Size(0, 19);
this.lblServerOn.TabIndex = 268;
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// lblAlarmcode
//
this.lblAlarmcode.AutoSize = true;
this.lblAlarmcode.Location = new System.Drawing.Point(433, 65);
this.lblAlarmcode.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblAlarmcode.Name = "lblAlarmcode";
this.lblAlarmcode.Size = new System.Drawing.Size(68, 17);
this.lblAlarmcode.TabIndex = 19;
this.lblAlarmcode.Text = "错误码:160";
this.lblAlarmcode.Visible = false;
//
// AxisMoveControl
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.groupAxis);
this.Name = "AxisMoveControl";
this.Size = new System.Drawing.Size(699, 402);
this.groupAxis.ResumeLayout(false);
this.groupAxis.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupAxis;
private System.Windows.Forms.ComboBox cmbAxis;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txtHomeSingle;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox txtHomeStatus;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox txtBusyStatus;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtAlarmStatus;
private System.Windows.Forms.Button btnGetAlarm;
internal System.Windows.Forms.Button btnReadPosition;
private System.Windows.Forms.Label lblServerOn;
private System.Windows.Forms.Label label8;
internal System.Windows.Forms.Button btnOpenAxis;
internal System.Windows.Forms.Button btnCloseAxis;
private System.Windows.Forms.TextBox lblCountPulse;
internal System.Windows.Forms.TextBox txtASpeed;
internal System.Windows.Forms.Label label47;
internal System.Windows.Forms.Button btnAxisVMove;
internal System.Windows.Forms.Button btnAxisRMove;
internal System.Windows.Forms.Button btnAxisReturnHome;
internal System.Windows.Forms.Button btnAxisAMove;
private System.Windows.Forms.Button btnComAlarmClear;
internal System.Windows.Forms.TextBox txtAPosition;
internal System.Windows.Forms.Label label48;
internal System.Windows.Forms.Button btnAxisStop;
private System.Windows.Forms.TextBox txtAxisValue;
private System.Windows.Forms.TextBox txtAxisDeviceName;
private System.Windows.Forms.Label label45;
private System.Windows.Forms.Label label46;
private System.Windows.Forms.Label label49;
private System.Windows.Forms.Label label24;
private System.Windows.Forms.TextBox txtLimit2;
private System.Windows.Forms.Label label22;
private System.Windows.Forms.TextBox txtLimit1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtServoStatue;
private System.Windows.Forms.Button btnDelMove;
private System.Windows.Forms.Button btnAddMove;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.ComboBox comjSpeed;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label lblhomeSts;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label lblAxEncAcc;
private System.Windows.Forms.Label lblINP;
private System.Windows.Forms.Label lblBUSY;
private System.Windows.Forms.Label lblNEL;
private System.Windows.Forms.Label lblORG;
private System.Windows.Forms.Label lblPEL;
private System.Windows.Forms.Label lblSvOn;
private System.Windows.Forms.Label lblEMG;
private System.Windows.Forms.Label lblWARN;
private System.Windows.Forms.Label lblALM;
private System.Windows.Forms.Label label53;
private System.Windows.Forms.Label label56;
private System.Windows.Forms.Label label55;
private System.Windows.Forms.Label label52;
private System.Windows.Forms.Label lblAxEncVel;
private System.Windows.Forms.Label lblAxPrfVel;
private System.Windows.Forms.Label lblAxEncPos;
private System.Windows.Forms.Label lblAxPrfPos;
private System.Windows.Forms.Label lblAxisPrfMode;
private System.Windows.Forms.Label label50;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Label lblAlarmcode;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OnlineStore.Common;
using System.Threading;
using OnlineStore.LoadCSVLibrary;
using HuichuanLibrary;
namespace DeviceLibrary
{
public partial class AxisMoveControl : UserControl
{
public bool IsHuiChuan = true;
private List<ConfigMoveAxis> axisList = new List<ConfigMoveAxis>();
private IRobot boxBean = null;
private string PortName = "";
private short SlvAddr = 0;
public AxisMoveControl()
{
InitializeComponent();
}
public void LoadData(IRobot equipBase, bool isHc = true)
{
this.boxBean = equipBase;
axisList = new List<ConfigMoveAxis>(equipBase.config.moveAxisList);
if (axisList.Count > 0)
{
cmbAxis.Items.Clear();
foreach (ConfigMoveAxis a in axisList)
{
cmbAxis.Items.Add(a.Explain);
}
cmbAxis.SelectedIndex = 0;
PortName = axisList[0].DeviceName;
SlvAddr = axisList[0].GetAxisValue();
txtAxisDeviceName.Text = PortName;
txtAxisValue.Text = SlvAddr.ToString();
}
btnAddMove.BackColor = Color.White;
btnDelMove.BackColor = Color.White;
this.IsHuiChuan = isHc;
if (IsHuiChuan)
{
groupBox1.Visible = false;
groupBox2.Visible = true;
timer1.Start();
}
else
{
groupBox1.Visible = true;
groupBox2.Visible = false;
}
}
private bool CanMove()
{
if (axis == null)
{
MessageBox.Show("请先选择运动轴", "警告 ", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
return true;
}
private void btnOpenAxis_Click(object sender, EventArgs e)
{
LogUtil.info(boxBean.Name+"点击【打开伺服】,【" + PortName + "_" + SlvAddr + "】 ");
AxisManager.ServoOn(PortName, SlvAddr);
}
private void btnCloseAxis_Click(object sender, EventArgs e)
{
LogUtil.info(boxBean.Name+"点击【关闭伺服】,【" + PortName + "_" + SlvAddr + "】 ");
AxisManager.ServoOff(PortName, SlvAddr);
}
private void btnAxisAMove_Click(object sender, EventArgs e)
{
if (!CanMove())
{
return;
}
int position = FormUtil.GetIntValue(txtAPosition);
int speed = FormUtil.GetIntValue(txtASpeed);
LogUtil.info(boxBean.Name+"点击【绝对运动】,【" + PortName + "_" + SlvAddr + "】位置【" + position + "】速度【" + speed + "】");
AxisManager.AbsMove(PortName, SlvAddr, position, speed,axis.AddSpeed,axis.DelSpeed);
}
private void btnAxisRMove_Click(object sender, EventArgs e)
{
if (!CanMove())
{
return;
}
int position = FormUtil.GetIntValue(txtAPosition);
int speed = FormUtil.GetIntValue(txtASpeed);
LogUtil.info(boxBean.Name+"点击【相对运动】,【" + PortName + "_" + SlvAddr + "】位置【" + position + "】速度【" + speed + "】");
AxisManager.RelMove(PortName, SlvAddr, position, speed,axis.AddSpeed,axis.DelSpeed);
}
private void btnAxisVMove_Click(object sender, EventArgs e)
{
if (!CanMove())
{
return;
}
int speed = FormUtil.GetIntValue(txtASpeed);
LogUtil.info(boxBean.Name+"点击【匀速运动】,【" + PortName + "_" + SlvAddr + "】 速度【" + speed + "】");
AxisManager.SpeedMove(PortName, SlvAddr, speed);
}
private void btnAxisStop_Click(object sender, EventArgs e)
{
LogUtil.info(boxBean.Name+"点击【停止运动】,【" + PortName + "_" + SlvAddr + "】 ");
AxisManager.SuddenStop(PortName, SlvAddr);
if (btnAddMove.BackColor == Color.Green)
{
btnAddMove.BackColor = System.Drawing.SystemColors.Control;
}
if (btnDelMove.BackColor == Color.Green)
{
btnDelMove.BackColor = System.Drawing.SystemColors.Control;
}
btnReadPosition_Click(null, null);
}
private void btnComAlarmClear_Click(object sender, EventArgs e)
{
LogUtil.info(boxBean.Name+"点击【清理报警】,【" + PortName + "_" + SlvAddr + "】 ");
AxisManager.AlarmClear(PortName, SlvAddr);
Thread.Sleep(100);
AxisManager.ServoOn(PortName, SlvAddr);
}
private void btnAxisReturnHome_Click(object sender, EventArgs e)
{
if (!CanMove())
{
return;
}
//int speed = FormUtil.GetIntValue(txtASpeed);
foreach(ConfigMoveAxis a in axisList)
{
if (a.IsSameAxis(PortName, SlvAddr))
{
LogUtil.info(boxBean.Name+"点击【原点返回】,【" + PortName + "_" + SlvAddr + "】 速度【" + a.HomeHighSpeed + "】");
AxisManager.HomeMove(PortName, SlvAddr, a.HomeHighSpeed,a.HomeLowSpeed,a.HomeAddSpeed);
}
}
}
private void btnGetAlarm_Click(object sender, EventArgs e)
{
this.txtAlarmStatus.Text = AxisManager.GetAlarmStatus(PortName, SlvAddr).ToString();
this.txtBusyStatus.Text = AxisManager.GetBusyStatus(PortName, SlvAddr).ToString();
//this.txtStb.Text = AxisManager.instance.GetSTBState(PortName, SlvAddr).ToString();
this.txtHomeStatus.Text = AxisManager.GetHomeEndStatus(PortName, SlvAddr).ToString();
this.txtHomeSingle.Text = AxisManager.GetHomeSingle(PortName, SlvAddr).ToString();
this.txtLimit1.Text = AxisManager.GetLimitPositiveSingle(PortName, SlvAddr).ToString();
this.txtLimit2.Text = AxisManager.GetLimitNegativeSingle(PortName, SlvAddr).ToString();
txtServoStatue.Text = AxisManager.IsServeoOn(PortName, SlvAddr) ? "✔" : "✘";
}
private void btnReadPosition_Click(object sender, EventArgs e)
{
lblCountPulse.Text = AxisManager.GetActualtPosition(PortName, SlvAddr).ToString();
}
private ConfigMoveAxis axis = null;
private List<Color> colorsList = new List<Color>();
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbAxis.SelectedIndex >= 0)
{
axis = axisList[cmbAxis.SelectedIndex];
PortName = axis.DeviceName;
SlvAddr = axis.GetAxisValue();
txtAxisDeviceName.Text = PortName;
txtAxisValue.Text = SlvAddr.ToString();
Color color = Color.Black;
int targetSpeed = axis.TargetSpeed;
comjSpeed.Items.Clear();
for (int i = 1; i <= 10; i++)
{
comjSpeed.Items.Add(targetSpeed * i / 10);
}
comjSpeed.SelectedIndex = 4;
btnAddMove.Text = "点动+ ";
btnDelMove.Text = "点动- ";
txtASpeed.Text = targetSpeed.ToString();
int SelIndex = cmbAxis.SelectedIndex;
if (colorsList.Count <= 0)
{
colorsList.Add(Color.Blue);
colorsList.Add(Color.Red);
colorsList.Add(Color.Green);
colorsList.Add(System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(192))))));
colorsList.Add(System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0))))));
colorsList.Add(Color.BlueViolet);
colorsList.Add(Color.Firebrick);
colorsList.Add(Color.Coral);
}
color = colorsList[SelIndex];
btnOpenAxis.ForeColor = color;
btnCloseAxis.ForeColor = color;
btnAxisAMove.ForeColor = color;
btnAxisRMove.ForeColor = color;
btnAxisVMove.ForeColor = color;
btnAxisReturnHome.ForeColor = color;
btnAxisStop.ForeColor = color;
btnComAlarmClear.ForeColor = color;
btnReadPosition.ForeColor = color;
btnGetAlarm.ForeColor = color;
btnAddMove.ForeColor = color;
btnDelMove.ForeColor = color;
this.txtAlarmStatus.Text = "";
this.txtBusyStatus.Text = "";
this.txtHomeStatus.Text = "";
this.txtHomeSingle.Text = "";
this.txtLimit1.Text = "";
this.txtLimit2.Text = "";
txtServoStatue.Text = "";
}
}
private void AxisMove(int speed)
{
LogUtil.info(boxBean.Name+"【" + PortName + "_" + SlvAddr + "】点动: 速度:" + speed);
AxisManager.SpeedMove(PortName, SlvAddr, speed);
}
private void btnAddMove_MouseDown(object sender, MouseEventArgs e)
{
if (!CanMove())
{
return;
}
if (btnAddMove.BackColor.Equals(Color.White))
{
int speed = Convert.ToInt32(comjSpeed.Text);
if (speed <= 0)
{
MessageBox.Show("提示", "请先输入正确的速度");
return;
}
btnAddMove.BackColor = Color.Green;
AxisMove(speed);
}
}
private void btnAddMove_MouseUp(object sender, MouseEventArgs e)
{
if (btnAddMove.BackColor == Color.Green)
{
btnAddMove.BackColor = Color.White;
AxisManager.SuddenStop(PortName, SlvAddr);
btnReadPosition_Click(null, null);
}
}
private void btnDelMove_MouseDown(object sender, MouseEventArgs e)
{
if (!CanMove())
{
return;
}
if (btnDelMove.BackColor.Equals(Color.White))
{
int speed = Convert.ToInt32(comjSpeed.Text);
if (speed <= 0)
{
MessageBox.Show("提示", "请先输入正确的速度");
return;
}
btnDelMove.BackColor = Color.Green;
AxisMove(-speed);
}
}
private void btnDelMove_MouseUp(object sender, MouseEventArgs e)
{
if (btnDelMove.BackColor == Color.Green)
{
btnDelMove.BackColor = Color.White;
AxisManager.SuddenStop(PortName, SlvAddr);
btnReadPosition_Click(null, null);
}
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Clipboard.SetDataObject(lblCountPulse.Text, true);
}
private void timer1_Tick(object sender, EventArgs e)
{
if (this.Visible)
{
ReadAxisStatus();
}
}
private void ReadAxisStatus()
{
groupBox2.Text = cmbAxis.Text + "-状态监控";
//【1】更新轴号
short axisNo = SlvAddr;
if (axisNo < 0)
{
return;
}
short modeValue = HCBoardManager.GetAxisPrfMode(axisNo);
if (modeValue < 0)
{
return;
}
else
{
string mode = HCBoardManager.AxisPrfMode(modeValue);
lblAxisPrfMode.Text = mode;
}
//【2】读取轴状态,如果读取出错将关闭此定时器
AxisSts sts = HCBoardManager.GetAxisSts(axisNo);
if (sts.ServoOn < 0)
{
return;
}
//【3】更新界面显示
ShowlbSts(lblALM, sts.ALM,true); //报警信号
ShowlbSts(lblWARN, sts.WARN); //警告信号
ShowlbSts(lblEMG, sts.EMG);//急停信号
ShowlbSts(lblSvOn, sts.ServoOn); //使能信号
ShowlbSts(lblBUSY, sts.BUSY); //轴忙信号
ShowlbSts(lblINP, sts.INP); //轴到位信号
if (sts.ORG < 0)
{
return;
}
ShowlbSts(lblPEL, sts.PEL); //正限位信号
ShowlbSts(lblORG, sts.ORG); //原点信号
ShowlbSts(lblNEL, sts.NEL); //负限位信号
//label59.Text = ConvertDecimalToBinary(nTimerAxSts[0]); //轴状态是按bit进行解读,因此这里将AxSts转换为二进制bit进行显示
lblAxPrfPos.Text = HCBoardManager.GetAxisPrfPos(axisNo).ToString();
lblAxPrfVel.Text = HCBoardManager.GetAxisPrfVel(axisNo).ToString();
//label62.Text = nTimerAxPrfAcc[0].ToString();
lblAxEncPos.Text = HCBoardManager.GetAxisCurrPos(axisNo).ToString();
lblAxEncVel.Text = HCBoardManager.GetAxisCurrVel(axisNo).ToString();
lblAxEncAcc.Text = HCBoardManager.GetAxisCurrAcc(axisNo).ToString();
//label65.Text = nTimerAxEncAcc[0].ToString();
short value = HCBoardManager.GetHomeStatus(axisNo);
string homesstr = HCBoardManager.AxisHomeSts(value);
lblhomeSts.Text = homesstr;
}
private void ShowlbSts(Label lbl, int value,bool isAlarm=false )
{
if (value.Equals(1))
{
if (isAlarm)
{
lbl.BackColor = Color.Red ;
lblAlarmcode.Visible = true;
lblAlarmcode.ForeColor = Color.Red;
lblAlarmcode.Text = "错误码:" + HCBoardManager.GetAxErrCode(SlvAddr);
}
else
{
lbl.BackColor = Color.Lime;
}
}
else if (value.Equals(0))
{
lbl.BackColor = Color.LightGray;
if (isAlarm)
{
lblAlarmcode.Visible = false ;
}
}
else
{
lbl.BackColor = this.BackColor;
}
}
public void StopTimer()
{
this.timer1.Stop();
}
}
}
<?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>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file \ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
//这里利用AttributeUsage 来设置我们的自定义属性的应用范围,这里定义的可以用于类,结构和方法的声明
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public class CSVAttribute : Attribute
{
public CSVAttribute(string fieldName)
{
FieldName = fieldName;
}
private string fieldName;
public string FieldName
{
get { return fieldName; }
set { fieldName = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class CVSFieldNotMatchingExection : ApplicationException
{
public CVSFieldNotMatchingExection(string message)
: base(message)
{
}
public override string Message
{
get
{
return base.Message;
}
}
}
public class PositionAlreadyExistingExection : ApplicationException
{
public PositionAlreadyExistingExection(string message)
: base(message)
{
}
public override string Message
{
get
{
return base.Message;
}
}
}
}
using log4net;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class CSVReaderBase
{
public static char Spilt_Char = ',';
// public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// 获取一个类所有的《字段,AttributeName列名》集合
/// </summary>
public static Dictionary<string, string> getProAttributeMap(Type type)
{
Dictionary<string, string> proCsvMap = new Dictionary<string, string>();
PropertyInfo[] props = type.GetProperties();
foreach (PropertyInfo prop in props)
{
object[] array = prop.GetCustomAttributes(false);
if (array.Length > 0)
{
CSVAttribute att = (CSVAttribute)array[0];
if (att != null)
{
string csvName = att.FieldName;
proCsvMap.Add(prop.Name, csvName);
}
}
}
return proCsvMap;
}
/// <summary>
/// 获取一个类所有的《字段,AttributeName列名》集合
/// </summary>
public static Dictionary<string, string> getConfigProAttributeMap(Type type)
{
Dictionary<string, string> proCsvMap = new Dictionary<string, string>();
PropertyInfo[] props = type.GetProperties();
foreach (PropertyInfo prop in props)
{
object[] array = prop.GetCustomAttributes( false);
if (array.Length > 0)
{
ConfigProAttribute att = (ConfigProAttribute)array[0];
if (att != null)
{
string csvName = att.FieldName;
if (proCsvMap.ContainsKey(csvName))
{
}
else
{
proCsvMap.Add(csvName, prop.Name);
}
}
}
}
return proCsvMap;
}
/// <summary>
/// 读取一个csv文件的所有内容
/// </summary>
protected static string[] ReadCSVFile(string filePath)
{
if (!File.Exists(filePath))
{
throw new FileNotFoundException("未找到文件:" + filePath);
}
string[] lines = File.ReadAllLines(filePath, Encoding.GetEncoding("gbk"));
return lines;
}
/// <summary>
/// 把数据写入csv中
/// </summary>
protected static bool WriteCSVFile(string filePath, string[] lines)
{
try
{
//备份保存
try
{
FileInfo file = new FileInfo(filePath);
string date = DateTime.Now.ToString("yyyy-MM-dd");
string targetBackPath = @"C:\configBack\" + date + @"\";
if (!Directory.Exists(targetBackPath))
{
Directory.CreateDirectory(targetBackPath);
}
string fileName = file.Name;
string backFile = targetBackPath + fileName;
if (File.Exists(backFile))
{
File.Delete(backFile);
}
File.Copy(filePath, backFile, true );
// File.WriteAllLines(backFile, lines, Encoding.GetEncoding("gbk"));
}
catch (Exception e)
{
LogUtil.error("出错:", e);
}
if (File.Exists(filePath))
{
File.Delete(filePath);
}
File.WriteAllLines(filePath, lines, Encoding.GetEncoding("gbk"));
}
catch (Exception ex)
{
LogUtil.error(ex.ToString());
return false;
}
return true;
}
protected static Dictionary<string, int> GetAllTitleIndex(string lineValue)
{
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
try
{
var array = lineValue.Split(',');
//验证列
for (int i = 0; i < array.Length; i++)
{
string title = array[i];
titleIndex.Add(title, i);
}
}catch(Exception ex)
{
LogUtil.error("出错:", ex);
}
return titleIndex;
}
protected static Dictionary<string, int> GetTitleIndex(string lineValue, List<string> cvsTitleList)
{
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
var array = lineValue.Split(',');
//验证列
for (int i = 0; i < array.Length; i++)
{
string title = array[i];
if (cvsTitleList.Contains(title))
{
titleIndex.Add(title, i);
}
}
if (titleIndex.Count < cvsTitleList.Count)
{
foreach (string str in cvsTitleList)
{
if (!titleIndex.ContainsKey(str))
{
LogUtil.error("未找到必须列:" + str + ",加载数据失败!");
throw new CVSFieldNotMatchingExection("【"+ lineValue + "】未找到必须列:【" + str + "】,加载数据失败!");
}
}
}
return titleIndex;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.LoadCSVLibrary</RootNamespace>
<AssemblyName>LoadCSVLibrary</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\增广夹爪\Rmaxis\bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CSVExection.cs" />
<Compile Include="storeConfig\ConfigItemBase.cs" />
<Compile Include="storeConfig\ConfigProAttribute.cs" />
<Compile Include="storeConfig\config\Robot_Config.cs" />
<Compile Include="storeConfig\config\IO_Type.cs" />
<Compile Include="CSVAttribute.cs" />
<Compile Include="storeConfig\CSVConfigReader.cs" />
<Compile Include="CSVReaderBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="storeConfig\config\DeviceConfig.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{43cdd09e-fcf3-4960-a01d-3bbfe9933122}</Project>
<Name>Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file \ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("LoadCVSLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LoadCVSLibrary")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("f9998ad1-83a5-4191-8109-7e255e71744e")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
/// <summary>
/// 松下伺服485控制,单台料仓
/// </summary>
public class ACStorePosition : StorePostionBase
{ /// <summary>
/// 对应的料仓ID(流水线料仓需要用此字段区分哪个BOX)
/// </summary>
[CSVAttribute("料仓ID")]
public int StoreId { get; set; }
/// <summary>
/// 中轴位置(旋转轴库位点)P2
/// </summary>
[CSVAttribute("中轴位置P2")]
public int MiddleAxis_Position_P2 { get; set; }
/// <summary>
/// 升降轴(库位出料前点)P5
/// </summary>
[CSVAttribute("升降轴库位出料前点P5")]
public int UpDownAxis_OHPosition_P5 { get; set; }
/// <summary>
/// 升降轴(库位出料缓冲点)P6
/// </summary>
[CSVAttribute("升降轴库位出料缓冲点P6")]
public int UpDownAxis_OLPosition_P6 { get; set; }
/// <summary>
/// 升降轴(库位入料前点)P3
/// </summary>
[CSVAttribute("升降轴库位入料前点P3")]
public int UpDownAxis_IHPosition_P3 { get; set; }
/// <summary>
/// 升降轴(库位入料缓冲点)P4
/// </summary>
[CSVAttribute("升降轴库位入料缓冲点P4")]
public int UpDownAxis_ILPosition_P4 { get; set; }
/// <summary>
/// 进出轴(库位点取料点)P3
/// </summary>
[CSVAttribute("进出轴库位点取料点P3")]
public int InOutAxis_Position_P3 { get; set; }
/// <summary>
/// 压紧轴(压紧点)P2
/// </summary>
[CSVAttribute("压紧轴压紧点P2")]
public int CompressAxis_Position_P2 { get; set; }
/// <summary>
/// 压紧轴(压紧前点)P3
/// </summary>
[CSVAttribute("压紧轴压紧前点P3")]
public int CompressAxis_CPosition_P3 { get; set; }
/// <summary>
/// 轴3(进出轴) 进料口取料点P2
/// </summary>
[CSVAttribute("进出轴进料口取料点P2")]
public int InOutAxis_DoorPosition_P2 { get; set; }
public static bool CheckPosition(ACStorePosition position, AC_SA_Config Config)
{
try
{
if (Config.Middle_Axis.PositionIsHasLimit())
{
int mMin = Config.Middle_Axis.PositionMin;
int mMax = Config.Middle_Axis.PositionMax;
if (mMin > position.MiddleAxis_Position_P2 || mMax < position.MiddleAxis_Position_P2)
{
LogUtil.error(position.PositionNum + " MiddleAxis_Position_P2位置超出" + Config.Middle_Axis.Explain + "上下限(" + mMin + "-" + mMax + ")");
return false;
}
}
if (Config.InOut_Axis.PositionIsHasLimit())
{
int iMin = Config.InOut_Axis.PositionMin;
int iMax = Config.InOut_Axis.PositionMax;
if (iMin > position.InOutAxis_DoorPosition_P2 || iMax < position.InOutAxis_DoorPosition_P2)
{
LogUtil.error(position.PositionNum + " InOutAxis_DoorPosition_P2位置超出" + Config.InOut_Axis.Explain + "上下限(" + iMin + "-" + iMax + ")");
return false;
}
if (iMin > position.InOutAxis_Position_P3 || iMax < position.InOutAxis_Position_P3)
{
LogUtil.error(position.PositionNum + " InOutAxis_Position_P3位置超出" + Config.InOut_Axis.Explain + "上下限(" + iMin + "-" + iMax + ")");
return false;
}
}
if (Config.UpDown_Axis.PositionIsHasLimit())
{
int uMin = Config.UpDown_Axis.PositionMin;
int uMax = Config.UpDown_Axis.PositionMax;
if (uMin > position.UpDownAxis_IHPosition_P3 || uMax < position.UpDownAxis_IHPosition_P3)
{
LogUtil.error(position.PositionNum + " UpDownAxis_IHPosition_P3位置超出" + Config.UpDown_Axis.Explain + "上下限(" + uMin + "-" + uMax + ")");
return false;
}
if (uMin > position.UpDownAxis_ILPosition_P4 || uMax < position.UpDownAxis_ILPosition_P4)
{
LogUtil.error(position.PositionNum + " UpDownAxis_ILPosition_P4位置超出" + Config.UpDown_Axis.Explain + "上下限(" + uMin + "-" + uMax + ")");
return false;
}
if (uMin > position.UpDownAxis_OHPosition_P5 || uMax < position.UpDownAxis_OHPosition_P5)
{
LogUtil.error(position.PositionNum + " UpDownAxis_OHPosition_P5位置超出" + Config.UpDown_Axis.Explain + "上下限(" + uMin + "-" + uMax + ")");
return false;
}
if (uMin > position.UpDownAxis_OLPosition_P6 || uMax < position.UpDownAxis_OLPosition_P6)
{
LogUtil.error(position.PositionNum + " UpDownAxis_OLPosition_P6位置超出" + Config.UpDown_Axis.Explain + "上下限(" + uMin + "-" + uMax + ")");
return false;
}
}
}
catch (Exception ex)
{
LogUtil.error("验证" + position.PositionNum + "的位置范围出错:" + ex.ToString());
}
return true;
}
///// <summary>
///// 升降轴进料口出料前点P2
///// </summary>
//[CSVAttribute("升降轴进料口出料前点P2")]
//public int UpDownAxis_P2 { get; set; }
///// <summary>
///// 升降轴进料口取料缓冲点P7
///// </summary>
//[CSVAttribute("升降轴进料口取料缓冲点P7")]
//public int UpDownAxis_P7 { get; set; }
}
}

using log4net;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class CSVPositionReader<T> : CSVReaderBase where T : StorePostionBase
{
/// <summary>
/// 所有的位置集合,key=位置
/// </summary>
public static Dictionary<string, T> allPositionMap = new Dictionary<string, T>();
public static List<string> hasReadFileList = new List<string>();
/// <summary>
/// 重新加载配置,会删除之前的所有信息,重新读取
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static Dictionary<String, T> ReloadCSVFile(string filePath)
{
allPositionMap = new Dictionary<string, T>();
hasReadFileList = new List<string>();
return AddCSVFile(filePath);
}
public static List<string> getPositionKeyList()
{
return new List<string>(allPositionMap.Keys);
}
public static List<T> getPositionList()
{
List<T> list = new List<T>(allPositionMap.Values);
return list;
}
/// <summary>
/// 添加一个csv文件的数据到位置集合中
/// </summary>
/// <param name="filePath">cvs文件路径+文件名</param>
/// <returns></returns>
public static Dictionary<String, T> AddCSVFile(string filePath)
{
if (hasReadFileList.Contains(filePath))
{
LOGGER.Error("文件" + filePath + "已经加载过,直接返回null");
return null;
}
Type type = typeof(T);
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T));
if (proTitleMap.Count <= 4)
{
LOGGER.Error(typeof(T).ToString() + "只读取到" + proTitleMap.Count + "个属性");
}
List<string> cvsTitleList = new List<string>(proTitleMap.Values);
List<string> propertyList = new List<string>(proTitleMap.Keys);
Dictionary<String, T> result = new Dictionary<String, T>();
string[] lines =ReadCSVFile(filePath);
int index = 0;
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
foreach (var line in lines)
{
var array = line.Split(Spilt_Char);
if (index == 0)
{
titleIndex = GetTitleIndex(line, cvsTitleList);
}
else
{
try
{
if (array.Length >= titleIndex.Count)
{
if (array.Length > 0 && array[0].Equals(""))
{
continue;
}
var bllIns = type.Assembly.CreateInstance(type.FullName);
//取得属性集合
PropertyInfo[] props = type.GetProperties();
int listIndex = 0;
string PositionNum = "";
foreach (string key in cvsTitleList)
{
int titIndex = titleIndex[key];
string value = array[titIndex];
string proName = propertyList[listIndex];
PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性
if (prop != null)
{//如果属性存在
prop.SetValue(bllIns, Convert.ChangeType(value, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
if (proName.Equals("PositionNum"))
{
PositionNum = value;
}
listIndex++;
}
result.Add(PositionNum, (T)bllIns);
if (allPositionMap.ContainsKey(PositionNum))
{
throw new PositionAlreadyExistingExection("仓位:" + PositionNum + "已存在!");
}
allPositionMap.Add(PositionNum, (T)bllIns);
}
else
{
LOGGER.Error("读取csv,index=" + index + ",数据格式不匹配!,line=" + line);
}
}
catch (Exception ex)
{
LOGGER.Debug( "CSV 读取行【" + line + "】行转换失败");
}
}
index++;
}
return result;
}
/// <summary>
/// 根据Key获得一个位置信息
/// </summary>
public static T GetPositon(string positionNum)
{
if (positionNum == null)
{
return null;
}
StorePostionBase result = null;
if (allPositionMap.ContainsKey(positionNum))
{
result = allPositionMap[positionNum];
return (T)result;
}
else
{
return null;
}
}
public static bool SavePostion(string filePath, T position)
{
Type type = typeof(T);
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T));
if (proTitleMap.Count <= 4)
{
LOGGER.Error(typeof(T).ToString() + "只读取到" + proTitleMap.Count + "个属性");
}
List<string> cvsTitleList = new List<string>(proTitleMap.Values);
List<string> propertyList = new List<string>(proTitleMap.Keys);
int positionNumIndex = propertyList.IndexOf("PositionNum");
int csvIndex = -1;
string[] lines = ReadCSVFile(filePath);
int index = 0;
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
foreach (var line in lines)
{
var array = line.Split(',');
if (index == 0)
{
titleIndex = GetTitleIndex(line, cvsTitleList);
}
else
{
if (array.Length == titleIndex.Count)
{
if (csvIndex < 0)
{
csvIndex = titleIndex[cvsTitleList[positionNumIndex]];
}
string value = array[csvIndex];
if (value.Equals(position.PositionNum))
{
//更新缓存
allPositionMap.Remove(position.PositionNum);
allPositionMap.Add(position.PositionNum, position);
string newValue = PostionToString(position, titleIndex, proTitleMap);
lines[index] = newValue;
return WriteCSVFile(filePath, lines);
}
}
}
index++;
}
return true;
}
private static string PostionToString(StorePostionBase position, Dictionary<string, int> titleIndex, Dictionary<string, string> proTitleMap)
{
//取得属性集合
PropertyInfo[] props = typeof(T).GetProperties();
List<string> cvsTitleList = new List<string>(proTitleMap.Values);
List<string> propertyList = new List<string>(proTitleMap.Keys);
String[] array = new String[titleIndex.Count];
foreach (string proName in proTitleMap.Keys)
{
PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性
if (prop != null)
{//如果属性存在
string value = prop.GetValue(position, null).ToString();
int index = titleIndex[proTitleMap[proName]];
array[index] = value;
}
}
string newStr = "";
foreach (string str in array)
{
if (newStr.Equals(""))
{
newStr = str;
}
else
{
newStr = newStr+Spilt_Char + str;
}
}
return newStr;
}
//private void ReadTest( )
//{
// Dictionary<string, string> dic = new Dictionary<string, string>();
// string path = Application.StartupPath + @"\Test.csv";
// dic.Add("AxisPosition", "中轴位置");
// dic.Add("ModbusHighPosition", "电钢高位");
// dic.Add("ModbusLowPosition", "电钢低位");
// Dictionary<string, KTKStorePostion> ddd = LoadCVSLibrary.CSVReaderHelper<KTKStorePostion>.ReadCVS(path, dic, typeof(KTKStorePostion));
// if (ddd != null)
// {
// MessageBox.Show("读取成功!");
// }
// else
// {
// MessageBox.Show("读取失败,请检查数据格式!");
// }
//}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class StorePostionBase
{
/// <summary>
/// 位置
/// </summary>
[CSVAttribute("位置")]
public string PositionNum { get; set; }
/// <summary>
/// 优先级
/// </summary>
[CSVAttribute("优先级")]
public int Priority { get; set; }
/// <summary>
/// 高
/// </summary>
[CSVAttribute("高度")]
public int BagHigh { get; set; }
/// <summary>
/// 宽
/// </summary>
[CSVAttribute("宽度")]
public int BagWidth { get; set; }
}
}
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class CSVConfigReader : CSVReaderBase
{
private static Dictionary<Type, Dictionary<string, string>> allItemProTitleMap = null;
/// <summary>
/// 获取一个类所有的《字段,AttributeName列名》集合
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
private static Dictionary<string, string> GetProMapByType(Type type)
{
if (allItemProTitleMap == null)
{
allItemProTitleMap = new Dictionary<Type, Dictionary<string, string>>();
}
if (!allItemProTitleMap.ContainsKey(type))
{
allItemProTitleMap.Add(type, getProAttributeMap(type));
}
return allItemProTitleMap[type];
}
public static List<ConfigBase> ReadConfig(string filePath)
{
List<ConfigBase> configList = new List<ConfigBase>();
string[] lines = ReadCSVFile(filePath);
int index = 0;
Dictionary<string, int> allTitleIndex = new Dictionary<string, int>();
int typeIndex = -1;
foreach (var line in lines)
{
if (index == 0)
{
//根据配置表来读取数据
allTitleIndex = GetAllTitleIndex(line);
//必须有列【类型】
if (allTitleIndex.Count < 0 || !allTitleIndex.ContainsKey("类型"))
{
LogUtil.error("未找到必须列:类型,加载数据失败!");
throw new CVSFieldNotMatchingExection("未找到必须列:类型,加载数据失败!");
}
typeIndex = allTitleIndex["类型"];
}
else
{
var array = line.Split(',');
//每一列必须有类型字段
string typeValue = array[typeIndex];
if (typeValue.Trim().Equals(""))
{
continue;
}
Type type = typeof(ConfigBase);
if (typeValue.Equals(ConfigItemType.DI) || typeValue.Equals(ConfigItemType.DO))
{
type = typeof(ConfigIO);
}
else if (typeValue.Equals(ConfigItemType.AXIS))
{
type = typeof(ConfigMoveAxis);
}
Dictionary<string, string> proTitleMap = getProAttributeMap(type);
ConfigBase bllIns = (ConfigBase)type.Assembly.CreateInstance(type.FullName);
bllIns.ConfigStr = line;
//取得属性集合
PropertyInfo[] props = type.GetProperties();
int listIndex = 0;
List<string> proNameList = new List<string>(proTitleMap.Keys);
List<string> cvsTitleList = new List<string>(proTitleMap.Values);
List<string> checkFiledList = new List<string>(proNameList);
Dictionary<string, int> proIndexMap = new Dictionary<string, int>();
for (int i = 0; i<cvsTitleList.Count; i++)
{
proIndexMap.Add(cvsTitleList[i], i);
}
foreach (string key in cvsTitleList)
{
try
{
if (allTitleIndex.ContainsKey(key))
{
try
{
int titIndex = allTitleIndex[key];
string value = array[titIndex];
//string proName = proNameList[listIndex];
string proName = proNameList[proIndexMap[key]];
checkFiledList.Remove(proName);
PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性
if (prop != null && !value.Equals(""))
{
if (value.Equals("") && prop.PropertyType.Name.ToLower().Contains("int"))
{
prop.SetValue(bllIns, Convert.ChangeType(-1, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
else if (value.Equals("") && prop.PropertyType.Name.ToLower().Contains("byte"))
{
prop.SetValue(bllIns, Convert.ChangeType(0, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
else
{
prop.SetValue(bllIns, Convert.ChangeType(value, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
}
}
catch (Exception ex)
{
LogUtil.error("filepath=" + filePath + ",index=" + index + ",key=" + key + "出错:" + ex.ToString());
}
listIndex++;
}
}
catch (Exception ex)
{
LogUtil.error("filepath=" + filePath + ",index=" + index + ",key=" + key + "出错:" + ex.ToString());
}
}
bllIns.CheckField();
configList.Add(bllIns);
}
index++;
}
return configList;
}
public static DeviceConfig LoadConfig(DeviceConfig config)
{
LogUtil.info("开始读取文件:" + config.ConfigFilePath);
if (config == null || config.ConfigFilePath.Equals(""))
{
return null;
}
List<ConfigBase> configBasesList = ReadConfig(config.ConfigFilePath);
config.LoadConfig(configBasesList);
return config;
}
public static bool SaveConfig(string configStr, DeviceConfig config)
{
var type = config.GetType();
//取得属性集合
PropertyInfo[] props = type.GetProperties();
string[] lines = ReadCSVFile(configStr);
int index = 0;
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
string[] newLines = new string[lines.Length];
// 获取一个类所有的《字段,AttributeName列名》集合
Dictionary<string, string> proMap = GetProMapByType(typeof(ConfigBase));
List<string> proNameList = new List<string>(proMap.Keys);
List<string> csvNameList = new List<string>(proMap.Values);
Dictionary<string, int> allTitleIndex = new Dictionary<string, int>();
foreach (var line in lines)
{
newLines[index] = line;
var array = line.Split(',');
if (index == 0)
{
allTitleIndex = GetAllTitleIndex(line);
newLines[index] = line;
}
else
{
if (array.Length > 0 && array[0].ToString().Equals(ConfigItemType.PRO))
{
string[] newArray = array;
string proName = array[3];
string proValue = array[4];
string proSpeed = array[7];
try
{
PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性
if (prop != null)
{
string newValue = prop.GetValue(config).ToString();
newArray[4] = newValue;
}
if (int.TryParse(proSpeed,out _)) {
PropertyInfo propSpeed = props.First(c => c.Name == proName+"_speed");//获取同名属性
if (prop != null)
{
string newValue = propSpeed.GetValue(config).ToString();
newArray[7] = newValue;
}
}
}
catch (Exception e)
{
LogUtil.error("出错:" + e.ToString());
}
string newLine = "";
foreach (string s in newArray)
{
newLine = newLine + s + ",";
}
newLine = newLine.Substring(0, newLine.Length - 1);
newLines[index] = newLine;
}
}
index++;
}
return WriteCSVFile(configStr, newLines);
}
}
}
using log4net;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class ConfigBase
{
/// <summary>
/// DI=输入IO,DO=输出IO,PRO=属性,AXIS=轴
/// </summary>
[CSVAttribute("类型")]
public string ProType { get; set; }
/// <summary>
/// 说明
/// </summary>
[CSVAttribute("说明")]
public string Explain { get; set; }
/// <summary>
/// 名称
/// </summary>
[CSVAttribute("名称")]
public string ProName { get; set; }
/// <summary>
/// 属性值
/// </summary>
[CSVAttribute("属性值")]
public string ProValue { get; set; }
/// <summary>
/// 分类编号
/// </summary>
[CSVAttribute("分类编号")]
public int SubType { get; set; }
/// <summary>
/// 目标速度
/// </summary>
[CSVAttribute("目标速度")]
public int TargetSpeed { get; set; }
public string ConfigStr { get; set; }
public override string ToString()
{
// return "ConfigBase。" + "类型:" + ProType + ",说明:" + Explain + ",名称:" + ProName + ",属性值:" + ProVale;
return ConfigStr;
}
public virtual void CheckField()
{
if (String.IsNullOrEmpty(ProType) || String.IsNullOrEmpty(ProName) || String.IsNullOrEmpty(ProValue))
{
throw new CVSFieldNotMatchingExection(ConfigStr + ",【类型:" + ProType + "】【名称:" + ProName + "】【属性值:" + ProValue + "】必须配置值!");
}
}
}
/// <summary>
/// 运动轴配置
/// </summary>
public class ConfigMoveAxis : ConfigBase
{
/// <summary>
/// 伺服ON的Do信号
/// </summary>
public string ServerOnDO = "";
/// <summary>
/// 伺服刹车信号
/// </summary>
public string BreakOnDO = "";
[CSVAttribute("设备名称")]
public string DeviceName { get; set; }
[CSVAttribute("目标速度")]
public int TargetSpeed { get; set; }
[CSVAttribute("加速时间")]
public short AddSpeed { get; set; }
[CSVAttribute("减速时间")]
public short DelSpeed { get; set; }
[CSVAttribute("原点低速度")]
public int HomeLowSpeed { get; set; }
[CSVAttribute("原点高速")]
public int HomeHighSpeed { get; set; }
[CSVAttribute("原点加速度")]
public int HomeAddSpeed { get; set; }
[CSVAttribute("脉冲最小误差")]
public int CanErrorCountMin { get; set; }
[CSVAttribute("脉冲最大误差")]
public int CanErrorCountMax { get; set; }
[CSVAttribute("脉冲最小限位")]
public int PositionMin { get; set; }
[CSVAttribute("脉冲最大限位")]
public int PositionMax { get; set; }
public int TargetPosition { get; set; }
public string GetNameStr()
{
return DeviceName + "_" + GetAxisValue();
}
public bool IsSameAxis(string portName, int slv)
{
if (DeviceName.Equals(portName) && slv.Equals(GetAxisValue()))
{
return true;
}
return false;
}
public string DisplayStr
{
get
{
return Explain + "(" + ProName + ")";
}
set
{
}
}
public short GetAxisValue()
{
if (ProValue.Equals("") || ProValue.Equals("-1"))
{
return -1;
}
return (short)Convert.ToInt32(ProValue);
}
public override void CheckField()
{
if (String.IsNullOrEmpty(ProType) || String.IsNullOrEmpty(ProName) || String.IsNullOrEmpty(DeviceName) || String.IsNullOrEmpty(ProValue))
{
throw new CVSFieldNotMatchingExection(ConfigStr + ",【类型:ProType】【名称:ProName】【属性值:ProVale】【设备名称:DeviceName】必须配置值!");
}
}
}
public class ConfigIO : ConfigBase
{
public ConfigIO()
{
SlaveID = 0;
}
[CSVAttribute("设备名称")]
public string DeviceName { get; set; }
[CSVAttribute("电器定义")]
public string ElectricalDefinition { get; set; }
[CSVAttribute("SlaveID")]
public byte SlaveID { get; set; }
public string DisplayStr
{
get
{
return ElectricalDefinition + "-" + Explain + "-" + ProName + "";
}
set
{
}
}
ushort value = 0;
public ushort GetIOAddr()
{
if (value > 0)
{
return value;
}
try
{
value = (ushort)Convert.ToInt32(ProValue);
}
catch (Exception ex)
{
LogUtil.error ("出错:", ex);
}
return value;
}
public override void CheckField()
{
if (String.IsNullOrEmpty(ProType) || String.IsNullOrEmpty(ProName) || String.IsNullOrEmpty(DeviceName) || String.IsNullOrEmpty(ProValue))
{
throw new CVSFieldNotMatchingExection(ConfigStr + ",【类型:ProType】【名称:ProName】【属性值:ProVale】【设备名称:DeviceName】必须配置值!");
}
}
}
public static class ConfigItemType
{
public static string DI = "DI";
public static string DO = "DO";
public static string AXIS = "AXIS";
public static string PRO = "PRO";
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
//这里利用AttributeUsage 来设置我们的自定义属性的应用范围,这里定义的可以用于类,结构和方法的声明
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public class ConfigProAttribute : Attribute
{
public ConfigProAttribute(string fieldName)
{
FieldName = fieldName;
IsMust = true;
}
public ConfigProAttribute(string fieldName,bool ismust)
{
FieldName = fieldName;
IsMust = ismust;
}
private string fieldName;
public string FieldName
{
get { return fieldName; }
set { fieldName = value; }
}
/// <summary>
/// 是否必须的
/// </summary>
public bool IsMust { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class AC_SA_Config : StoreConfig
{
public AC_SA_Config()
: base()
{
}
public AC_SA_Config(int id, string cid, string type, string filepath)
: base(id, cid, type, filepath)
{
}
/// <summary>
/// 预警温度
/// </summary>
[ConfigProAttribute("WarnTemperate")]
public int WarnTemperate { get; set; }
/// <summary>
/// 预警湿度
/// </summary>
[ConfigProAttribute("WarnHumidity")]
public int WarnHumidity { get; set; }
/// <summary>
/// 气压检测IO关闭需要持续的时间(=3表示需要关闭三秒以上才算关闭)
/// </summary>
[ConfigProAttribute("AirCheckSeconds")]
public int AirCheckSeconds { get; set; }
/// <summary>
/// IsHasCompress_Axis是否使用压紧轴
/// </summary>
[ConfigProAttribute("IsHasCompress_Axis")]
public int IsHasCompress_Axis { get; set; }
/// <summary>
/// PRO 是否使用定位气缸 IsHasLocationCylinder 0
/// </summary>
[ConfigProAttribute("IsHasLocationCylinder")]
public int IsHasLocationCylinder { get; set; }
/// <summary>
/// PRO 是否有左右侧门 IsHasDoorLimit 0
/// </summary>
[ConfigProAttribute("IsHasDoorLimit")]
public int IsHasDoorLimit { get; set; }
/// <summary>
/// PRO 扫码枪IP Scanner_Ip 192.168.200.13
/// </summary>
[ConfigProAttribute("Scanner_Ip",false)]
public string Scanner_Ip { get; set; }
/// <summary>
/// PRO 扫码枪端口号 Scanner_Port 51236
/// </summary>
[ConfigProAttribute("Scanner_Port",false)]
public int Scanner_Port { get; set; }
/// <summary>
/// PRO (轴一)旋转轴原点目标速度 MiddleAxis_TargetSpeed 30000
/// </summary>
[ConfigProAttribute("MiddleAxis_TargetSpeed")]
public int MiddleAxis_TargetSpeed { get; set; }
/// <summary>
/// PRO (轴一)旋转轴加速度 MiddleAxis_AddSpeed 500
/// </summary>
[ConfigProAttribute("MiddleAxis_AddSpeed")]
public short MiddleAxis_AddSpeed { get; set; }
/// <summary>
/// PRO (轴一)旋转轴减速度 MiddleAxis_DelSpeed 500
/// </summary>
[ConfigProAttribute("MiddleAxis_DelSpeed")]
public short MiddleAxis_DelSpeed { get; set; }
/// <summary>
/// PRO (轴二)升降轴轴原点目标速度 UpdownAxis_TargetSpeed 120000
/// </summary>
[ConfigProAttribute("UpdownAxis_TargetSpeed")]
public int UpdownAxis_TargetSpeed { get; set; }
/// <summary>
/// PRO (轴二)升降轴轴加速度 UpdownAxis_AddSpeed 200
/// </summary>
[ConfigProAttribute("UpdownAxis_AddSpeed")]
public short UpdownAxis_AddSpeed { get; set; }
/// <summary>
/// PRO (轴二)升降轴轴减速度 UpdownAxis_DelSpeed 200
/// </summary>
[ConfigProAttribute("UpdownAxis_DelSpeed")]
public short UpdownAxis_DelSpeed { get; set; }
/// <summary>
/// PRO (轴三)进出轴原点目标速度 InoutAxis_TargetSpeed 12000
/// </summary>
[ConfigProAttribute("InoutAxis_TargetSpeed")]
public int InoutAxis_TargetSpeed { get; set; }
/// <summary>
/// PRO (轴三)进出轴加速度 InoutAxis_AddSpeed 200
/// </summary>
[ConfigProAttribute("InoutAxis_AddSpeed")]
public short InoutAxis_AddSpeed { get; set; }
/// <summary>
/// PRO (轴三)进出轴减速度 InoutAxis_DelSpeed 200
/// </summary>
[ConfigProAttribute("InoutAxis_DelSpeed")]
public short InoutAxis_DelSpeed { get; set; }
/// <summary>
/// PRO (轴一)旋转轴原点低速度 MiddleAxis_HomeLowSpeed 50
/// </summary>
[ConfigProAttribute("MiddleAxis_HomeLowSpeed")]
public short MiddleAxis_HomeLowSpeed { get; set; }
/// <summary>
/// PRO (轴一)旋转轴原点高速 MiddleAxis_HomeHighSpeed 100
/// </summary>
[ConfigProAttribute("MiddleAxis_HomeHighSpeed")]
public short MiddleAxis_HomeHighSpeed { get; set; }
/// <summary>
/// PRO (轴一)旋转轴原点加速度 MiddleAxis_HomeAddSpeed 30
/// </summary>
[ConfigProAttribute("MiddleAxis_HomeAddSpeed")]
public short MiddleAxis_HomeAddSpeed { get; set; }
/// <summary>
/// PRO (轴二)升降轴轴原点低速度 UpdownAxis_HomeLowSpeed 50
/// </summary>
[ConfigProAttribute("UpdownAxis_HomeLowSpeed")]
public short UpdownAxis_HomeLowSpeed { get; set; }
/// <summary>
/// PRO (轴二)升降轴轴原点高速 UpdownAxis_HomeHighSpeed 100
/// </summary>
[ConfigProAttribute("UpdownAxis_HomeHighSpeed")]
public short UpdownAxis_HomeHighSpeed { get; set; }
/// <summary>
/// PRO (轴二)升降轴轴原点加速度 UpdownAxis_HomeAddSpeed 30
/// </summary>
[ConfigProAttribute("UpdownAxis_HomeAddSpeed")]
public short UpdownAxis_HomeAddSpeed { get; set; }
/// <summary>
/// PRO (轴三)进出轴原点低速 InoutAxis_HomeLowSpeed 50
/// </summary>
[ConfigProAttribute("InoutAxis_HomeLowSpeed")]
public short InoutAxis_HomeLowSpeed { get; set; }
/// <summary>
/// PRO (轴三)进出轴原点高速 InoutAxis_HomeHighSpeed 100
/// </summary>
[ConfigProAttribute("InoutAxis_HomeHighSpeed")]
public short InoutAxis_HomeHighSpeed { get; set; }
/// <summary>
/// PRO (轴三)进出轴原点加速度 InoutAxis_HomeAddSpeed 30
/// </summary>
[ConfigProAttribute("InoutAxis_HomeAddSpeed")]
public short InoutAxis_HomeAddSpeed { get; set; }
/// <summary>
/// PRO 升降轴(轴2)P1速度 UpDownAxis_P1_Speed
/// </summary>
[ConfigProAttribute("UpDownAxis_P1_Speed")]
public int UpDownAxis_P1_Speed { get; set; }
/// <summary>
/// PRO 升降轴(轴2)P2速度 UpDownAxis_P2_Speed
/// </summary>
[ConfigProAttribute("UpDownAxis_P2_Speed")]
public int UpDownAxis_P2_Speed { get; set; }
/// <summary>
/// PRO 升降轴(轴2)P3速度 UpDownAxis_P3_Speed
/// </summary>
[ConfigProAttribute("UpDownAxis_P3_Speed")]
public int UpDownAxis_P3_Speed { get; set; }
/// <summary>
/// PRO 升降轴(轴2)P4速度 UpDownAxis_P4_Speed
/// </summary>
[ConfigProAttribute("UpDownAxis_P4_Speed")]
public int UpDownAxis_P4_Speed { get; set; }
/// <summary>
/// PRO 升降轴(轴2)P5速度 UpDownAxis_P5_Speed
/// </summary>
[ConfigProAttribute("UpDownAxis_P5_Speed")]
public int UpDownAxis_P5_Speed { get; set; }
/// <summary>
/// PRO 升降轴(轴2)P6速度 UpDownAxis_P6_Speed
/// </summary>
[ConfigProAttribute("UpDownAxis_P6_Speed")]
public int UpDownAxis_P6_Speed { get; set; }
/// <summary>
/// PRO 升降轴(轴2)P7速度 UpDownAxis_P7_Speed
/// </summary>
[ConfigProAttribute("UpDownAxis_P7_Speed")]
public int UpDownAxis_P7_Speed { get; set; }
/// <summary>
/// PRO 升降轴(轴2)P8速度 UpDownAxis_P8_Speed
/// </summary>
[ConfigProAttribute("UpDownAxis_P8_Speed")]
public int UpDownAxis_P8_Speed { get; set; }
/// <summary>
/// PRO 旋转轴(轴1)P1速度 MiddleAxis_P1_Speed
/// </summary>
[ConfigProAttribute("MiddleAxis_P1_Speed")]
public int MiddleAxis_P1_Speed { get; set; }
/// <summary>
/// PRO 旋转轴(轴1)P2速度 MiddleAxis_P2_Speed
/// </summary>
[ConfigProAttribute("MiddleAxis_P2_Speed")]
public int MiddleAxis_P2_Speed { get; set; }
/// <summary>
/// PRO 进出轴(轴3)P1速度 InOutAxis_P1_Speed
/// </summary>
[ConfigProAttribute("InOutAxis_P1_Speed")]
public int InOutAxis_P1_Speed { get; set; }
/// <summary>
/// PRO 进出轴(轴3)P2速度 InOutAxis_P2_Speed
/// </summary>
[ConfigProAttribute("InOutAxis_P2_Speed")]
public int InOutAxis_P2_Speed { get; set; }
/// <summary>
/// PRO 进出轴(轴3)P3速度 InOutAxis_P3_Speed
/// </summary>
[ConfigProAttribute("InOutAxis_P3_Speed")]
public int InOutAxis_P3_Speed { get; set; }
/// <summary>
/// PRO (轴一)旋转轴停止时可误差的脉冲数的最小值 MiddleAxis_ErrorCountMin 200
/// </summary>
[ConfigProAttribute("MiddleAxis_ErrorCountMin")]
public int MiddleAxis_ErrorCountMin { get; set; }
/// <summary>
/// PRO (轴二)升降轴轴停止时可误差的脉冲数的最小值 UpdownAxis_ErrorCountMin 200
/// </summary>
[ConfigProAttribute("UpdownAxis_ErrorCountMin")]
public int UpdownAxis_ErrorCountMin { get; set; }
/// <summary>
/// PRO (轴三)进出轴停止时可误差的脉冲数的最小值 InoutAxis_ErrorCountMin 200
/// </summary>
[ConfigProAttribute("InoutAxis_ErrorCountMin")]
public int InoutAxis_ErrorCountMin { get; set; }
/// <summary>
/// PRO (轴一)旋转轴停止时可误差的脉冲数的最大值 MiddleAxis_ErrorCountMax 500
/// </summary>
[ConfigProAttribute("MiddleAxis_ErrorCountMax")]
public int MiddleAxis_ErrorCountMax { get; set; }
/// <summary>
/// PRO (轴二)升降轴轴停止时可误差的脉冲数的最大值 UpdownAxis_ErrorCountMax 500
/// </summary>
[ConfigProAttribute("UpdownAxis_ErrorCountMax")]
public int UpdownAxis_ErrorCountMax { get; set; }
/// <summary>
/// PRO (轴三)进出轴停止时可误差的脉冲数的最大值 InoutAxis_ErrorCountMax 500
/// </summary>
[ConfigProAttribute("InoutAxis_ErrorCountMax")]
public int InoutAxis_ErrorCountMax { get; set; }
/// <summary>
/// PRO,BOX出入库次数多少次时,会自动重置旋转轴,Box_ResetMCount,10,,,,,
/// </summary>
[ConfigProAttribute("Box_ResetMCount")]
public int Box_ResetMCount { get; set; }
/// <summary>
/// PRO,BOX出入库次数多少次时,会自动重置操作(会重置所有轴),Box_ResetACount,100,,,,,
/// </summary>
[ConfigProAttribute("Box_ResetACount")]
public int Box_ResetACount { get; set; }
/// <summary>
/// PRO IO信号超时时间(毫秒) IOSingle_TimerOut 5000
/// </summary>
[ConfigProAttribute("IOSingle_TimerOut", false)]
public int IOSingle_TimerOut { get; set; }
/// <summary>
/// 升降轴 进料口取料点 P1
/// </summary>
[ConfigProAttribute("UpDownAxis_DoorOPosition_P1")]
public int UpDownAxis_DoorOPosition_P1 { get; set; }
/// <summary>
/// 升降轴 进料口出料前点 P2
/// </summary>
[ConfigProAttribute("UpDownAxis_DoorIPosition_P2")]
public int UpDownAxis_DoorIPosition_P2 { get; set; }
/// <summary>
/// 升降轴 进料口取料缓冲点 P7
/// </summary>
[ConfigProAttribute("UpDownAxis_DoorOBPosition_P7")]
public int UpDownAxis_DoorOBPosition_P7 { get; set; }
/// <summary>
/// 升降轴 进料口出料缓冲点 P8
/// </summary>
[ConfigProAttribute("UpDownAxis_DoorIBPosition_P8")]
public int UpDownAxis_DoorIBPosition_P8 { get; set; }
/// <summary>
/// PRO 旋转轴(轴1)P1 待机原位点 MiddleAxis_P1_Position
/// </summary>
[ConfigProAttribute("MiddleAxis_P1_Position")]
public int MiddleAxis_P1_Position { get; set; }
/// <summary>
/// PRO 进出轴(轴3)P1待机原位点 InOutAxis_P1_Position
/// </summary>
[ConfigProAttribute("InOutAxis_P1_Position")]
public int InOutAxis_P1_Position { get; set; }
/// <summary>
/// PRO 押金轴(轴4)P1待机原位点 CompressAxis_P1_Position
/// </summary>
[ConfigProAttribute("CompressAxis_P1_Position")]
public int CompressAxis_P1_Position { get; set; }
/// <summary>
/// PRO 是否使用料盘检测信号 IsUse_Tray_Check
/// </summary>
[ConfigProAttribute("IsUse_Tray_Check")]
public int IsUse_Tray_Check { get; set; }
/// <summary>
/// 设备是否处于调试状态(1=调试,0=正常)
/// </summary>
[ConfigProAttribute("IsInDebug")]
public int IsInDebug { get; set; }
/// <summary>
///轴2升降轴 运动上下轴
/// </summary>
[ConfigProAttribute("UpDown_Axis")]
public ConfigMoveAxis UpDown_Axis { get; set; }
/// <summary>
/// 轴1旋转轴 运动中轴
/// </summary>
[ConfigProAttribute("Middle_Axis")]
public ConfigMoveAxis Middle_Axis { get; set; }
/// <summary>
/// 轴3进出轴
/// </summary>
[ConfigProAttribute("InOut_Axis")]
public ConfigMoveAxis InOut_Axis { get; set; }
/// <summary>
/// 轴3压紧轴
/// </summary>
[ConfigProAttribute("Comp_Axis")]
public ConfigMoveAxis Comp_Axis { get; set; }
/// <summary>
/// PRO (轴四)压紧轴目标速度 CompAxis_TargetSpeed 100
/// </summary>
[ConfigProAttribute("CompAxis_TargetSpeed")]
public int CompAxis_TargetSpeed { get; set; }
/// <summary>
/// PRO (轴四)压紧轴加速度 CompAxis_AddSpeed 300
/// </summary>
[ConfigProAttribute("CompAxis_AddSpeed")]
public short CompAxis_AddSpeed { get; set; }
/// <summary>
/// PRO (轴四)压紧轴减速度 CompAxis_DelSpeed 300
/// </summary>
[ConfigProAttribute("CompAxis_DelSpeed")]
public short CompAxis_DelSpeed { get; set; }
/// <summary>
/// PRO (轴四)压紧轴原点低速 CompAxis_HomeLowSpeed 20
/// </summary>
[ConfigProAttribute("CompAxis_HomeLowSpeed")]
public int CompAxis_HomeLowSpeed { get; set; }
/// <summary>
/// PRO (轴四)压紧轴原点高速 CompAxis_HomeHighSpeed 60
/// </summary>
[ConfigProAttribute("CompAxis_HomeHighSpeed")]
public int CompAxis_HomeHighSpeed { get; set; }
/// <summary>
/// PRO (轴四)压紧轴原点加速度 CompAxis_HomeAddSpeed 200
/// </summary>
[ConfigProAttribute("CompAxis_HomeAddSpeed")]
public int CompAxis_HomeAddSpeed { get; set; }
/// <summary>
/// PRO (轴一)旋转轴最小限位 MiddleAxis_PositionMin
/// </summary>
[ConfigProAttribute("MiddleAxis_PositionMin", false)]
public int MiddleAxis_PositionMin { get; set; }
/// <summary>
/// PRO (轴二)升降轴最小限位 UpdownAxis_PositionMin
/// </summary>
[ConfigProAttribute("UpdownAxis_PositionMin", false)]
public int UpdownAxis_PositionMin { get; set; }
/// <summary>
/// PRO (轴三)进出轴最小限位 InoutAxis_PositionMin
/// </summary>
[ConfigProAttribute("InoutAxis_PositionMin", false)]
public int InoutAxis_PositionMin { get; set; }
/// <summary>
/// PRO (轴一)旋转轴最大限位 MiddleAxis_PositionMax
/// </summary>
[ConfigProAttribute("MiddleAxis_PositionMax", false)]
public int MiddleAxis_PositionMax { get; set; }
/// <summary>
/// PRO (轴二)升降轴最大限位 UpdownAxis_PositionMax
/// </summary>
[ConfigProAttribute("UpdownAxis_PositionMax", false)]
public int UpdownAxis_PositionMax { get; set; }
/// <summary>
/// PRO (轴三)进出轴最大限位 InoutAxis_PositionMax
/// </summary>
[ConfigProAttribute("InoutAxis_PositionMax", false)]
/// <summary>
/// PRO 需要吹气的温度(温度标准) Max_Temperature 10
/// </summary>
[ConfigProAttribute("Max_Temperature", false)]
public int Max_Temperature { get; set; }
/// <summary>
/// PRO 需要吹气的湿度(湿度标准) Max_Humidity 10
/// </summary>
[ConfigProAttribute("Max_Humidity", false)]
public int Max_Humidity { get; set; }
/// <summary>
/// PRO 每次吹气的时间(分钟) BlowAir_Time 10
/// </summary>
[ConfigProAttribute("BlowAir_Time", false)]
public int BlowAir_Time { get; set; }
/// <summary>
/// PRO 两次吹气间隔(分钟) BlowAir_Interval 10
/// </summary>
[ConfigProAttribute("BlowAir_Interval", false)]
public int BlowAir_Interval { get; set; }
public int InoutAxis_PositionMax { get; set; }
/// <summary>
/// PRO,温湿度端口号,Humiture_Port,COM1,,,,,,,
/// </summary>
[ConfigProAttribute("Humiture_Port", true )]
public string Humiture_Port { get; set; }
/// <summary>
/// PRO 模拟量IO模块的IP地址 AIDevice_IP 192.168.200.11
/// </summary>
[ConfigProAttribute("AIDevice_IP", true)]
public string AIDevice_IP { get; set; }
/// <summary>
/// PRO,模拟信号1默认高度,AIDI1_DefaultPosition,1,,,,,,,
/// </summary>
[ConfigProAttribute("AIDI1_DefaultPosition", true)]
public double AIDI1_DefaultPosition { get; set; }
/// <summary>
/// PRO,模拟信号2默认高度,AIDI2_DefaultPosition,1,,,,,,,
/// </summary>
[ConfigProAttribute("AIDI2_DefaultPosition", true)]
public double AIDI2_DefaultPosition { get; set; }
/// <summary>
/// PRO,模拟信号3默认高度,AIDI3_DefaultPosition,1,,,,,,,
/// </summary>
[ConfigProAttribute("AIDI3_DefaultPosition", false )]
public double AIDI3_DefaultPosition { get; set; }
/// <summary>
/// PRO,模拟信号4默认高度,AIDI4_DefaultPosition,1,,,,,,,
/// </summary>
[ConfigProAttribute("AIDI4_DefaultPosition", false )]
public double AIDI4_DefaultPosition { get; set; }
/// <summary>
/// PRO 模拟信号1的地址 AIDI1_Addr 7
/// </summary>
[ConfigProAttribute("AIDI1_Addr", true)]
public int AIDI1_Addr { get; set; }
/// <summary>
/// PRO 模拟信号2的地址 AIDI2_Addr 8
/// </summary>
[ConfigProAttribute("AIDI2_Addr", true)]
public int AIDI2_Addr { get; set; }
/// <summary>
/// PRO 模拟信号3的地址 AIDI3_Addr 5
/// </summary>
[ConfigProAttribute("AIDI3_Addr", false )]
public int AIDI3_Addr { get; set; }
/// <summary>
/// PRO 模拟信号4的地址 AIDI4_Addr 6
/// </summary>
[ConfigProAttribute("AIDI4_Addr", false )]
public int AIDI4_Addr { get; set; }
/// <summary>
/// PRO IO模块对应的DI数量 IO_DILength 192.168.200.10#16;192.168.200.11#4
/// </summary>
[ConfigProAttribute("IO_DILength")]
public string IO_DILength { get; set; }
/// <summary>
/// PRO 模块对应的DO数量 IO_DOLength 192.168.200.10#16;192.168.200.11#4
/// </summary>
[ConfigProAttribute("IO_DOLength")]
public string IO_DOLength { get; set; }
protected override void initMustHavePro()
{
MustHaveDIList = new List<string>();
MustHaveDOList = new List<string>();
MustHaveDIList.Add(IO_Type.SuddenStop_BTN);
MustHaveDIList.Add(IO_Type.Reset_BTN);
MustHaveDIList.Add(IO_Type.AutoRun_Signal);
MustHaveDIList.Add(IO_Type.Airpressure_Check);
MustHaveDIList.Add(IO_Type.TrayCheck_Door);
MustHaveDIList.Add(IO_Type.TrayCheck_Fixture);
MustHaveDIList.Add(IO_Type.Door_Up);
MustHaveDIList.Add(IO_Type.Door_Down);
MustHaveDOList.Add(IO_Type.AutoRun_HddLed);
MustHaveDOList.Add(IO_Type.Alarm_HddLed);
MustHaveDOList.Add(IO_Type.RunSign_HddLed);
MustHaveDOList.Add(IO_Type.StartOrStopBlow);
MustHaveDOList.Add(IO_Type.Run_Signal);
MustHaveDOList.Add(IO_Type.Door_Up);
MustHaveDOList.Add(IO_Type.Door_Down);
MustHaveDOList.Add(IO_Type.Axis_Brake);
}
public static void ConfigAxis(AC_SA_Config Config)
{
Config.Middle_Axis.TargetSpeed = Config.MiddleAxis_TargetSpeed;
Config.Middle_Axis.AddSpeed = Config.MiddleAxis_AddSpeed;
Config.Middle_Axis.DelSpeed = Config.MiddleAxis_DelSpeed;
Config.Middle_Axis.HomeAddSpeed = Config.MiddleAxis_HomeAddSpeed;
Config.Middle_Axis.HomeHighSpeed = Config.MiddleAxis_HomeHighSpeed;
Config.Middle_Axis.HomeLowSpeed = Config.MiddleAxis_HomeLowSpeed;
Config.InOut_Axis.TargetSpeed = Config.InoutAxis_TargetSpeed;
Config.InOut_Axis.DelSpeed = Config.InoutAxis_AddSpeed;
Config.InOut_Axis.AddSpeed = Config.InoutAxis_DelSpeed;
Config.InOut_Axis.HomeAddSpeed = Config.InoutAxis_HomeAddSpeed;
Config.InOut_Axis.HomeHighSpeed = Config.InoutAxis_HomeHighSpeed;
Config.InOut_Axis.HomeLowSpeed = Config.InoutAxis_HomeLowSpeed;
Config.UpDown_Axis.TargetSpeed = Config.UpdownAxis_TargetSpeed;
Config.UpDown_Axis.AddSpeed = Config.UpdownAxis_AddSpeed;
Config.UpDown_Axis.DelSpeed = Config.UpdownAxis_DelSpeed;
Config.UpDown_Axis.HomeAddSpeed = Config.UpdownAxis_HomeAddSpeed;
Config.UpDown_Axis.HomeHighSpeed = Config.UpdownAxis_HomeHighSpeed;
Config.UpDown_Axis.HomeLowSpeed = Config.UpdownAxis_HomeLowSpeed;
Config.Comp_Axis.TargetSpeed = Config.CompAxis_TargetSpeed;
Config.Comp_Axis.AddSpeed = Config.CompAxis_AddSpeed;
Config.Comp_Axis.DelSpeed = Config.CompAxis_DelSpeed;
Config.Comp_Axis.HomeAddSpeed = Config.CompAxis_HomeAddSpeed;
Config.Comp_Axis.HomeHighSpeed = Config.CompAxis_HomeHighSpeed;
Config.Comp_Axis.HomeLowSpeed = Config.CompAxis_HomeLowSpeed;
Config.Middle_Axis.CanErrorCountMin = Config.MiddleAxis_ErrorCountMin;
Config.InOut_Axis.CanErrorCountMin = Config.InoutAxis_ErrorCountMin;
Config.UpDown_Axis.CanErrorCountMin = Config.UpdownAxis_ErrorCountMin;
Config.Middle_Axis.CanErrorCountMax = Config.MiddleAxis_ErrorCountMax;
Config.InOut_Axis.CanErrorCountMax = Config.InoutAxis_ErrorCountMax;
Config.UpDown_Axis.CanErrorCountMax = Config.UpdownAxis_ErrorCountMax;
Config.Middle_Axis.PositionMin = Config.MiddleAxis_PositionMin;
Config.Middle_Axis.PositionMax = Config.MiddleAxis_PositionMax;
Config.InOut_Axis.PositionMin = Config.InoutAxis_PositionMin;
Config.InOut_Axis.PositionMax = Config.InoutAxis_PositionMax;
Config.UpDown_Axis.PositionMin = Config.UpdownAxis_PositionMin;
Config.UpDown_Axis.PositionMax = Config.UpdownAxis_PositionMax;
//Config.InOut_Axis.ResolveSpeed = Config.InoutAxis_ResolveSpeed;
//Config.UpDown_Axis.ResolveSpeed = Config.UpdownAxis_ResolveSpeed;
//Config.Middle_Axis.ResolveSpeed = Config.MiddleAxis_ResolveSpeed;
Config.Middle_Axis.DefaultPosition = Config.MiddleAxis_P1_Position;
Config.InOut_Axis.DefaultPosition = Config.InOutAxis_P1_Position;
Config.UpDown_Axis.DefaultPosition = Config.UpDownAxis_DoorOPosition_P1;
Config.Comp_Axis.DefaultPosition = Config.CompressAxis_P1_Position;
Config.Comp_Axis.CanErrorCountMax = 1000;
Config.Comp_Axis.CanErrorCountMin = 10;
Config.Comp_Axis.PositionMin = 0;
Config.Comp_Axis.PositionMax = 0;
}
private Dictionary<string, ushort> DILengthMap = null;
private Dictionary<string, ushort> DOLengthMap = null;
public ushort GetDILength(string ip)
{
try
{
if (DILengthMap == null)
{
DILengthMap = new Dictionary<string, ushort>();
string[] arrayList = IO_DILength.Split(';');
foreach (string str in arrayList)
{
string[] arrStr = str.Split('#');
if (arrStr.Length == 2)
{
string ioip = arrStr[0];
ushort length = Convert.ToUInt16(arrStr[1]);
DILengthMap.Add(ioip, length);
}
}
}
}
catch (Exception ex)
{
}
if (DILengthMap.ContainsKey(ip))
{
return DILengthMap[ip];
}
return 16;
}
public ushort GetDOLength(string ip)
{
try
{
if (DOLengthMap == null)
{
DOLengthMap = new Dictionary<string, ushort>();
string[] arrayList = IO_DOLength.Split(';');
foreach (string str in arrayList)
{
string[] arrStr = str.Split('#');
if (arrStr.Length == 2)
{
string ioip = arrStr[0];
ushort length = Convert.ToUInt16(arrStr[1]);
DOLengthMap.Add(ioip, length);
}
}
}
}
catch (Exception ex)
{
}
if (DOLengthMap.ContainsKey(ip))
{
return DOLengthMap[ip];
}
return 16;
}
}
}
using log4net;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class DeviceConfig
{
/// <summary>
/// ID
/// </summary>
public int Id { get; set; }
/// <summary>
/// 设备类型
/// </summary>
public string DType { get; set; }
/// <summary>
/// 配置文件路径
/// </summary>
public string ConfigFilePath { get; set; }
public Dictionary<String, ConfigIO> DIList { get; set; }
public Dictionary<String, ConfigIO> DOList { get; set; }
public List<ConfigMoveAxis> moveAxisList;
public List<ConfigBase> configList;
public DeviceConfig()
{
}
public DeviceConfig(int id , string type, string filepath)
{
this.Id = id;
this.DType = type;
this.ConfigFilePath = filepath;
}
public virtual void LoadConfig(List<ConfigBase> configList)
{
this.configList = configList;
List<string> ioTypeList = IO_Type.GetTypeList();
StringBuilder builder = new StringBuilder("\r\n");
StringBuilder proBuilder = new StringBuilder("\r\n");
DIList = new Dictionary<string, ConfigIO>();
DOList = new Dictionary<string, ConfigIO>();
moveAxisList = new List<ConfigMoveAxis>();
//取得属性集合
PropertyInfo[] props = GetType().GetProperties();
Dictionary<string, string> proMap = CSVReaderBase.getConfigProAttributeMap(GetType());
List<string> checkProList = new List<string>(proMap.Keys);//用来检测attribute属性都应该要配置值
foreach (ConfigBase con in configList)
{
try
{
if (con.ProType == ConfigItemType.AXIS || con.ProType == ConfigItemType.PRO)
{
if (proMap.ContainsKey(con.ProName))
{
string proName = proMap[con.ProName];
checkProList.Remove(con.ProName);
PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性
if (prop != null)
{
if (con.ProType == ConfigItemType.AXIS)
{
//如果属性存在
prop.SetValue(this, Convert.ChangeType(con, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
ConfigMoveAxis axis = (ConfigMoveAxis)con;
moveAxisList.Add(axis);
}
else if (con.ProType == ConfigItemType.PRO)
{
prop.SetValue(this, Convert.ChangeType(con.ProValue, prop.PropertyType));//赋值
if (con.TargetSpeed > 0)
{
if (proMap.ContainsKey(proName + "_speed"))
{
checkProList.Remove(proName + "_speed");
PropertyInfo speedprop = props.First(c => c.Name == proName + "_speed");
if (speedprop != null)
{
speedprop.SetValue(this, Convert.ChangeType(con.TargetSpeed, prop.PropertyType));
}
}
else
{
AddProSpeedBuffer(con, proBuilder);
}
}
}
}
else
{
LogUtil.error("配置文件:" + this.ConfigFilePath + ",属性名=" + con.ProName + "的属性未找到匹配字段!");
}
}
else
{
AddProBuffer(con, proBuilder);
LogUtil.error("配置文件:" + this.ConfigFilePath + ",属性名=" + con.ProName + "的属性未找到匹配字段!");
}
}
else if (con.ProType == ConfigItemType.DI)
{
ConfigIO io = (ConfigIO)con;
if (DIList.ContainsKey(io.ProName))
{
LogUtil.debug("配置DI:[" + io.ToString() + "] ProName重复 ");
}
else
{
this.DIList.Add(con.ProName, io);
}
if (!ioTypeList.Contains(con.ProName))
{
AddBuffer(con, builder);
}
}
else if (con.ProType == ConfigItemType.DO)
{
ConfigIO io = (ConfigIO)con;
if (DOList.ContainsKey(io.ProName))
{
LogUtil.debug("配置DO:[" + io.ToString() + "] ProName重复 ");
}
else
{
this.DOList.Add(con.ProName, io);
}
if (!ioTypeList.Contains(con.ProName))
{
AddBuffer(con, builder);
}
}
}catch(Exception ex)
{
LogUtil.error("解析配置【"+con.ConfigStr+"】出错:" + ex.ToString());
}
}
if (String.IsNullOrEmpty(proBuilder.ToString()).Equals(false) && proBuilder.ToString().Equals("\r\n").Equals(false))
{
LogUtil.error(proBuilder.ToString());
}
if (String.IsNullOrEmpty(builder.ToString()).Equals(false) && builder.ToString().Equals("\r\n").Equals(false))
{
LogUtil.error(builder.ToString());
}
if (checkProList.Count >= 0)
{
//常规属性检测
foreach (string str in checkProList)
{
PropertyInfo prop = props.First(c => c.Name == str);//获取同名属性
//判断是否必须要配置
object[] array = prop.GetCustomAttributes(false);
if (array.Length > 0)
{
ConfigProAttribute att = (ConfigProAttribute)array[0];
if (att != null)
{
if (att.IsMust)
{
throw new CVSFieldNotMatchingExection(this.ToString() + "的属性【" + str + "】必须配置值!");
}
else
{
if (prop.PropertyType.Equals(typeof(int)))
{
prop.SetValue(this, Convert.ChangeType(0, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
else
{
prop.SetValue(this, Convert.ChangeType("", prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
}
}
}
}
////DI检测
//foreach (string di in MustHaveDIList)
//{
// if (!DIList.ContainsKey(di))
// {
// throw new CVSFieldNotMatchingExection(this.ToString() + "的DI属性" + di + "必须配置值!");
// }
//}
////DO检测
//foreach (string io in MustHaveDOList)
//{
// if (!this.DOList.ContainsKey(io))
// {
// throw new CVSFieldNotMatchingExection(this.ToString() + "的DO属性" + io + "必须配置值!");
// }
//}
}
}
private void AddProBuffer(ConfigBase con, StringBuilder builder)
{
builder.Append(" /// <summary>\r\n");
builder.Append(" /// " + con.ConfigStr + "\r\n");
builder.Append(" /// </summary>\r\n");
builder.Append(" [ConfigProAttribute(\"" + con.ProName + "\")]\r\n");
builder.Append(" public int " + con.ProName + " { get; set; }\r\n");
}
private void AddProSpeedBuffer(ConfigBase con, StringBuilder builder)
{
builder.Append(" /// <summary>\r\n");
builder.Append(" /// " + con.ConfigStr + "\r\n");
builder.Append(" /// </summary>\r\n");
builder.Append(" [ConfigProAttribute(\"" + con.ProName + "_speed\")]\r\n");
builder.Append(" public int " + con.ProName + "_speed { get; set; }\r\n");
}
private void AddBuffer(ConfigBase con, StringBuilder builder)
{
builder.Append(" /// <summary>\r\n");
builder.Append(" /// " + con.ConfigStr + "\r\n");
builder.Append(" /// </summary>\r\n");
builder.Append(" public static string " + con.ProName + "=\"" + con.ProName + "\";\r\n");
}
public ConfigIO getWaitIO(string ioType)
{
if (DIList.ContainsKey(ioType))
{
return DIList[ioType];
}
else if (DOList.ContainsKey(ioType))
{
return DOList[ioType];
}
return null;
}
}
public class DeviceType
{
/// <summary>
/// 流水线线体
/// </summary>
public static string Line = "Line";
public static string XRay = "MoveEquip";
public static string OutputDevice = "OutputDevice";
public static string InputDevice = "InputDevice";
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.LoadCSVLibrary
{
public class DischargeLine_Config : DeviceConfig
{
public DischargeLine_Config()
: base()
{
}
public DischargeLine_Config(int id, string cid, string type, string filepath)
: base(id, cid, LoadCSVLibrary.DeviceType.DischargeLine, filepath)
{
}
/// <summary>
/// 设备是否处于调试状态(1=调试,0=正常)
/// </summary>
[ConfigProAttribute("IsDebug")]
public int IsDebug { get; set; }
/// <summary>
/// PRO,0,扫码的相机名称(多个用#分隔),CameraNameList,Name1#Name1,,,,,
/// </summary>
[ConfigProAttribute("CameraNameList")]
public string CameraNameList { get; set; }
private List<string> CameraList = null;
public List<string> GetCameraList()
{
if (CameraList == null)
{
CameraList = new List<string>();
string[] arrayList = CameraNameList.Split('#');
foreach (string str in arrayList)
{
string camera = str.Trim();
if (string.IsNullOrEmpty(camera).Equals(false))
{
CameraList.Add(camera);
}
}
}
return CameraList;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class IO_Type
{
private static List<string> TypeList = null;
public static List<string> GetTypeList()
{
if (TypeList == null)
{
TypeList = new List<string>();
var p = typeof(IO_Type).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static);
foreach (var item in p)
{
TypeList.Add(item.Name);
}
}
return TypeList;
}
/// <summary>
/// DI,0,急停,SuddenStop_BTN,0,HC,X00,,,,,,,,,,
/// </summary>
public static string SuddenStop_BTN = "SuddenStop_BTN";
/// <summary>
/// DI,0,进料口确认按钮,Reset_BTN,1,HC,X01,,,,,,,,,,
/// </summary>
public static string Reset_BTN = "Reset_BTN";
/// <summary>
/// DI,0,出料口确认按钮,Start_BTN,2,HC,X02,,,,,,,,,,
/// </summary>
public static string Start_BTN = "Start_BTN";
/// <summary>
/// DI,0,后门左门禁,LeftBackDoor_Check,3,HC,X03,,,,,,,,,,
/// </summary>
public static string LeftBackDoor_Check = "LeftBackDoor_Check";
/// <summary>
/// DI,0,后门右门禁,RightBackDoor_Check,4,HC,X04,,,,,,,,,,
/// </summary>
public static string RightBackDoor_Check = "RightBackDoor_Check";
/// <summary>
/// DI,0,气压检测,Airpressure_Check,5,HC,X05,,,,,,,,,,
/// </summary>
public static string Airpressure_Check = "Airpressure_Check";
/// <summary>
/// DI,0,光栅信号,GratingSignal_Check,6,HC,X06,,,,,,,,,,
/// </summary>
public static string GratingSignal_Check = "GratingSignal_Check";
/// <summary>
/// DI,0,NG料箱检测,HasNgBox,7,HC,X07,,,,,,,,,,
/// </summary>
public static string HasNgBox = "HasNgBox";
/// <summary>
/// DI,0,打印机到位检测,HasPrinter,8,HC,X08,,,,,,,,,,
/// </summary>
public static string HasPrinter = "HasPrinter";
/// <summary>
/// DI,0,旋转臂进料侧检测,RightArm_Check,9,HC,X09,,,,,,,,,,
/// </summary>
public static string RightArm_Check = "RightArm_Check";
/// <summary>
/// DI,0,旋转臂出料侧检测,LeftArm_Check,10,HC,X10,,,,,,,,,,
/// </summary>
public static string LeftArm_Check = "LeftArm_Check";
/// <summary>
/// DI,0,进料口料车检测,RightCar_Check,11,HC,X11,,,,,,,,,,
/// </summary>
public static string RightCar_Check = "RightCar_Check";
/// <summary>
/// DI,0,进料口前端料串检测,RightFornt_Check,12,HC,X12,,,,,,,,,,
/// </summary>
public static string RightFornt_Check = "RightFornt_Check";
/// <summary>
/// DI,0,进料口料串到位检测,RightEnd_Check,13,HC,X13,,,,,,,,,,
/// </summary>
public static string RightEnd_Check = "RightEnd_Check";
/// <summary>
/// DI,0,进料口阻挡气缸上升端,RightStopUP,14,HC,X14,,,,,,,,,,
/// </summary>
public static string RightStopUP = "RightStopUP";
/// <summary>
/// DI,0,进料口阻挡气缸下降端,RightStopDown,15,HC,X15,,,,,,,,,,
/// </summary>
public static string RightStopDown = "RightStopDown";
/// <summary>
/// DI,0,出料口料车检测,LeftCar_Check,16,HC,X16,,,,,,,,,,
/// </summary>
public static string LeftCar_Check = "LeftCar_Check";
/// <summary>
/// DI,0,出料口前端料串检测,LeftFornt_Check,17,HC,X17,,,,,,,,,,
/// </summary>
public static string LeftFornt_Check = "LeftFornt_Check";
/// <summary>
/// DI,0,出料口料串到位检测,LeftEnd_Check,18,HC,X18,,,,,,,,,,
/// </summary>
public static string LeftEnd_Check = "LeftEnd_Check";
/// <summary>
/// DI,0,出料口阻挡气缸上升端,LeftStopUP,19,HC,X19,,,,,,,,,,
/// </summary>
public static string LeftStopUP = "LeftStopUP";
/// <summary>
/// DI,0,出料口阻挡气缸下降端,LeftStopDown,20,HC,X20,,,,,,,,,,
/// </summary>
public static string LeftStopDown = "LeftStopDown";
/// <summary>
/// DI,0,进料定位料盘检测,RightTop_Check,21,HC,X21,,,,,,,,,,
/// </summary>
public static string RightTop_Check = "RightTop_Check";
/// <summary>
/// DI,0,进料定位料盘超限检测,RightOverHead_Check,22,HC,X22,,,,,,,,,,
/// </summary>
public static string RightOverHead_Check = "RightOverHead_Check";
/// <summary>
/// DI,0,出料定位料盘检测,LeftTop_Check,23,HC,X23,,,,,,,,,,
/// </summary>
public static string LeftTop_Check = "LeftTop_Check";
/// <summary>
/// DI,0,出料定位料盘超限检测,LeftOverHead_Check,24,HC,X24,,,,,,,,,,
/// </summary>
public static string LeftOverHead_Check = "LeftOverHead_Check";
/// <summary>
/// DI,0,吸嘴气缸前进端,LabelCylinder_Fwd,25,HC,X25,,,,,,,,,,
/// </summary>
public static string LabelCylinder_Fwd = "LabelCylinder_Fwd";
/// <summary>
/// DI,0,吸嘴气缸后退端,LabelCylinder_Bck,26,HC,X26,,,,,,,,,,
/// </summary>
public static string LabelCylinder_Bck = "LabelCylinder_Bck";
/// <summary>
/// DO,0,自动指示灯,AutoRun_HddLed,0,HC,Y00,,,,,,,,,,
/// </summary>
public static string AutoRun_HddLed = "AutoRun_HddLed";
/// <summary>
/// DO,0,故障指示灯,Alarm_HddLed,1,HC,Y01,,,,,,,,,,
/// </summary>
public static string Alarm_HddLed = "Alarm_HddLed";
/// <summary>
/// DO,0,待机指示灯,RunSign_HddLed,2,HC,Y02,,,,,,,,,,
/// </summary>
public static string RunSign_HddLed = "RunSign_HddLed";
/// <summary>
/// DO,0,报警蜂鸣器,Alarm_Buzzer,3,HC,Y03,,,,,,,,,,
/// </summary>
public static string Alarm_Buzzer = "Alarm_Buzzer";
/// <summary>
/// DO,0,进料口状态指示灯,RightState_Led,4,HC,Y04,,,,,,,,,,
/// </summary>
public static string RightState_Led = "RightState_Led";
/// <summary>
/// DO,0,出料口状态指示灯,LeftState_Led,5,HC,Y05,,,,,,,,,,
/// </summary>
public static string LeftState_Led = "LeftState_Led";
/// <summary>
/// DO,0,设备照明,Device_Led,6,HC,Y06,,,,,,,,,,
/// </summary>
public static string Device_Led = "Device_Led";
/// <summary>
/// DO,0,相机照明,Camera_Led,7,HC,Y07,,,,,,,,,,
/// </summary>
public static string Camera_Led = "Camera_Led";
/// <summary>
/// DO,0,进料口电机启动,RightMoto_Run,8,HC,Y08,,,,,,,,,,
/// </summary>
public static string RightMoto_Run = "RightMoto_Run";
/// <summary>
/// DO,0,进料口电机反转指令,RightMoto_Reverse,9,HC,Y09,,,,,,,,,,
/// </summary>
public static string RightMoto_Reverse = "RightMoto_Reverse";
/// <summary>
/// DO,0,出料口电机启动,LeftMoto_Run,10,HC,Y10,,,,,,,,,,
/// </summary>
public static string LeftMoto_Run = "LeftMoto_Run";
/// <summary>
/// DO,0,出料口电机反转指令,LeftMoto_Reverse,11,HC,Y11,,,,,,,,,,
/// </summary>
public static string LeftMoto_Reverse = "LeftMoto_Reverse";
/*
/// <summary>
/// DO,0,进料口阻挡气缸上升,RightStopUP,12,HC,Y12,,,,,,,,,,
/// </summary>
public static string RightStopUP = "RightStopUP";
/// <summary>
/// DO,0,进料口阻挡气缸下降,RightStopDown,13,HC,Y13,,,,,,,,,,
/// </summary>
public static string RightStopDown = "RightStopDown";
/// <summary>
/// DO,0,出料口阻挡气缸上升,LeftStopUP,14,HC,Y14,,,,,,,,,,
/// </summary>
public static string LeftStopUP = "LeftStopUP";
/// <summary>
/// DO,0,出料口阻挡气缸下降,LeftStopDown,15,HC,Y15,,,,,,,,,,
/// </summary>
public static string LeftStopDown = "LeftStopDown";
/// <summary>
/// DO,0,吸嘴气缸前进,LabelCylinder_Fwd,16,HC,Y16,,,,,,,,,,
/// </summary>
public static string LabelCylinder_Fwd = "LabelCylinder_Fwd";
/// <summary>
/// DO,0,吸嘴气缸后退,LabelCylinder_Bck,17,HC,Y17,,,,,,,,,,
/// </summary>
public static string LabelCylinder_Bck = "LabelCylinder_Bck";
*/
/// <summary>
/// DO,0,吸嘴取标,LabelCylinder_Work,18,HC,Y18,,,,,,,,,,
/// </summary>
public static string LabelCylinder_Work = "LabelCylinder_Work";
}
public enum IO_VALUE
{
/// <summary>
/// 未知
/// </summary>
None = -1,
/// <summary>
/// 低位
/// </summary>
LOW = 0,
/// <summary>
/// 高位
/// </summary>
HIGH = 1,
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.LoadCSVLibrary
{
public class Robot_Config : DeviceConfig
{
public Robot_Config()
: base()
{
}
public Robot_Config(int id, string type, string filepath)
: base(id, type, filepath)
{
}
/// <summary>
/// AXIS,,取料机构旋转轴_SVD01,Take_Middle_Axis,0,HC,,500,1000,1000,100,200,1000,10,1000,0,0
/// </summary>
[ConfigProAttribute("Take_Middle_Axis")]
public ConfigMoveAxis Take_Middle_Axis { get; set; }
/// <summary>
/// AXIS,,取料机构上下轴_SVD02,Take_UpDown_Axis,1,HC,,1000,1000,1000,200,500,500,10,1000,0,0
/// </summary>
[ConfigProAttribute("Take_UpDown_Axis")]
public ConfigMoveAxis Take_UpDown_Axis { get; set; }
/// <summary>
/// AXIS,,左轨道提升轴_SVD04,Left_Batch_Axis,2,HC,,3000,1000,1000,200,1000,200,10,1000,0,0
/// </summary>
[ConfigProAttribute("Left_Batch_Axis")]
public ConfigMoveAxis Left_Batch_Axis { get; set; }
/// <summary>
/// AXIS,,右轨道提升轴_SVD05,Right_Batch_Axis,3,HC,,3000,1000,1000,200,1000,200,10,1000,0,0
/// </summary>
[ConfigProAttribute("Right_Batch_Axis")]
public ConfigMoveAxis Right_Batch_Axis { get; set; }
/// <summary>
/// AXIS,,贴标移栽机构X轴_SVD08,Label_X_Axis,4,HC,,100,700,700,50,250,500,10,1000,0,0
/// </summary>
[ConfigProAttribute("Label_X_Axis")]
public ConfigMoveAxis Label_X_Axis { get; set; }
/// <summary>
/// AXIS,,贴标移栽机构Y轴_SVD09,Label_Y_Axis,5,HC,,100,700,700,50,150,500,10,1000,0,0
/// </summary>
[ConfigProAttribute("Label_Y_Axis")]
public ConfigMoveAxis Label_Y_Axis { get; set; }
/// <summary>
/// AXIS,,贴标移栽机构Z轴_SVD10,Label_Z_Axis,6,HC,,100,800,800,50,150,500,10,1000,0,0
/// </summary>
[ConfigProAttribute("Label_Z_Axis")]
public ConfigMoveAxis Label_Z_Axis { get; set; }
/// <summary>
/// AXIS,,贴标移栽机构R轴_SVD11,Label_R_Axis,7,HC,,10,2000,2000,1,5,200,500,1000,0,0
/// </summary>
[ConfigProAttribute("Label_R_Axis")]
public ConfigMoveAxis Label_R_Axis { get; set; }
/// <summary>
/// PRO,0,IO信号超时时间(秒),IOSingle_TimerOut,15,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("IOSingle_TimerOut")]
public int IOSingle_TimerOut { get; set; }
/// <summary>
/// PRO,0,气压检测超时,AirCheckSeconds,5,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("AirCheckSeconds")]
public int AirCheckSeconds { get; set; }
/// <summary>
/// PRO,0,取料旋转轴待机点P1,Take_Middle_P1,1,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_Middle_P1")]
public int Take_Middle_P1 { get; set; }
/// <summary>
/// PRO,0,取料旋转轴右取料点P2,Take_Middle_P2,2,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_Middle_P2")]
public int Take_Middle_P2 { get; set; }
/// <summary>
/// PRO,0,取料旋转轴左取料点P3,Take_Middle_P3,3,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_Middle_P3")]
public int Take_Middle_P3 { get; set; }
/// <summary>
/// PRO,0,取料旋转轴NG放料点P5,Take_Middle_P5,4,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_Middle_P5")]
public int Take_Middle_P5 { get; set; }
/// <summary>
/// PRO,0,取料上下轴待机点P1,Take_UpDown_P1,6,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_UpDown_P1")]
public int Take_UpDown_P1 { get; set; }
/// <summary>
/// PRO,0,取料上下轴取料高点P2,Take_UpDown_P2,7,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_UpDown_P2")]
public int Take_UpDown_P2 { get; set; }
/// <summary>
/// PRO,0,取料上下轴取右料低点P3,Take_UpDown_P3,8,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_UpDown_P3")]
public int Take_UpDown_P3 { get; set; }
/// <summary>
/// PRO,0,取料上下轴取左料低点P4,Take_UpDown_P4,9,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_UpDown_P4")]
public int Take_UpDown_P4 { get; set; }
/// <summary>
/// PRO,0,取料上下轴NG放料点P5,Take_UpDown_P5,10,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_UpDown_P5")]
public int Take_UpDown_P5 { get; set; }
/// <summary>
/// PRO,0,右提升轴低点P1,Right_Batch_P1,12,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Right_Batch_P1")]
public int Right_Batch_P1 { get; set; }
/// <summary>
/// PRO,0,右提升轴高点P2,Right_Batch_P2,13,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Right_Batch_P2")]
public int Right_Batch_P2 { get; set; }
/// <summary>
/// PRO,0,左提升轴低点P1,Left_Batch_P1,14,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Left_Batch_P1")]
public int Left_Batch_P1 { get; set; }
/// <summary>
/// PRO,0,左提升轴高点P2,Left_Batch_P2,15,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Left_Batch_P2")]
public int Left_Batch_P2 { get; set; }
/// <summary>
/// PRO,0,贴标X轴待机点P1,Label_X_P1,17,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_X_P1")]
public int Label_X_P1 { get; set; }
/// <summary>
/// PRO,0,贴标X轴取标点P2,Label_X_P2,18,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_X_P2")]
public int Label_X_P2 { get; set; }
/// <summary>
/// PRO,0,贴标X轴贴标点P3,Label_X_P3,19,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_X_P3")]
public int Label_X_P3 { get; set; }
/// <summary>
/// PRO,0,贴标Y轴待机点P1,Label_Y_P1,21,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_Y_P1")]
public int Label_Y_P1 { get; set; }
/// <summary>
/// PRO,0,贴标Y轴取标点P2,Label_Y_P2,22,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_Y_P2")]
public int Label_Y_P2 { get; set; }
/// <summary>
/// PRO,0,贴标Y轴贴标点P3,Label_Y_P3,23,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_Y_P3")]
public int Label_Y_P3 { get; set; }
/// <summary>
/// PRO,0,贴标Z轴待机点P1,Label_Z_P1,25,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_Z_P1")]
public int Label_Z_P1 { get; set; }
/// <summary>
/// PRO,0,贴标Z轴取标点P2,Label_Z_P2,26,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_Z_P2")]
public int Label_Z_P2 { get; set; }
/// <summary>
/// PRO,0,贴标Z轴贴标点P3,Label_Z_P3,27,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_Z_P3")]
public int Label_Z_P3 { get; set; }
/// <summary>
/// PRO,0,贴标R轴待机点P1,Label_R_P1,29,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_R_P1")]
public int Label_R_P1 { get; set; }
/// <summary>
/// PRO,0,贴标R轴取标点P2,Label_R_P2,30,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_R_P2")]
public int Label_R_P2 { get; set; }
/// <summary>
/// PRO,0,贴标R轴360度脉冲,Label_R_P3,31,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_R_P3")]
public int Label_R_P3 { get; set; }
/// <summary>
/// PRO,10,取料旋转轴待机点P1,Take_Middle_P1,1,,,99,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_Middle_P1_speed")]
public int Take_Middle_P1_speed { get; set; }
/// <summary>
/// PRO,10,取料旋转轴右取料点P2,Take_Middle_P2,2,,,99,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_Middle_P2_speed")]
public int Take_Middle_P2_speed { get; set; }
/// <summary>
/// PRO,10,取料旋转轴左取料点P3,Take_Middle_P3,3,,,99,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_Middle_P3_speed")]
public int Take_Middle_P3_speed { get; set; }
/// <summary>
/// PRO,10,取料旋转轴NG放料点P5,Take_Middle_P5,4,,,99,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_Middle_P5_speed")]
public int Take_Middle_P5_speed { get; set; }
/// <summary>
/// PRO,11,取料上下轴待机点P1,Take_UpDown_P1,6,,,88,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_UpDown_P1_speed")]
public int Take_UpDown_P1_speed { get; set; }
/// <summary>
/// PRO,11,取料上下轴取料高点P2,Take_UpDown_P2,7,,,88,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_UpDown_P2_speed")]
public int Take_UpDown_P2_speed { get; set; }
/// <summary>
/// PRO,11,取料上下轴取右料低点P3,Take_UpDown_P3,8,,,88,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_UpDown_P3_speed")]
public int Take_UpDown_P3_speed { get; set; }
/// <summary>
/// PRO,11,取料上下轴取左料低点P4,Take_UpDown_P4,9,,,88,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_UpDown_P4_speed")]
public int Take_UpDown_P4_speed { get; set; }
/// <summary>
/// PRO,11,取料上下轴NG放料点P5,Take_UpDown_P5,10,,,88,,,,,,,,,
/// </summary>
[ConfigProAttribute("Take_UpDown_P5_speed")]
public int Take_UpDown_P5_speed { get; set; }
/// <summary>
/// PRO,12,右提升轴低点P1,Right_Batch_P1,12,,,66,,,,,,,,,
/// </summary>
[ConfigProAttribute("Right_Batch_P1_speed")]
public int Right_Batch_P1_speed { get; set; }
/// <summary>
/// PRO,12,右提升轴高点P2,Right_Batch_P2,13,,,66,,,,,,,,,
/// </summary>
[ConfigProAttribute("Right_Batch_P2_speed")]
public int Right_Batch_P2_speed { get; set; }
/// <summary>
/// PRO,12,左提升轴低点P1,Left_Batch_P1,14,,,66,,,,,,,,,
/// </summary>
[ConfigProAttribute("Left_Batch_P1_speed")]
public int Left_Batch_P1_speed { get; set; }
/// <summary>
/// PRO,12,左提升轴高点P2,Left_Batch_P2,15,,,66,,,,,,,,,
/// </summary>
[ConfigProAttribute("Left_Batch_P2_speed")]
public int Left_Batch_P2_speed { get; set; }
/// <summary>
/// PRO,13,贴标X轴待机点P1,Label_X_P1,17,,,77,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_X_P1_speed")]
public int Label_X_P1_speed { get; set; }
/// <summary>
/// PRO,13,贴标X轴取标点P2,Label_X_P2,18,,,77,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_X_P2_speed")]
public int Label_X_P2_speed { get; set; }
/// <summary>
/// PRO,13,贴标X轴贴标点P3,Label_X_P3,19,,,77,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_X_P3_speed")]
public int Label_X_P3_speed { get; set; }
/// <summary>
/// PRO,14,贴标Y轴待机点P1,Label_Y_P1,21,,,44,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_Y_P1_speed")]
public int Label_Y_P1_speed { get; set; }
/// <summary>
/// PRO,14,贴标Y轴取标点P2,Label_Y_P2,22,,,44,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_Y_P2_speed")]
public int Label_Y_P2_speed { get; set; }
/// <summary>
/// PRO,14,贴标Y轴贴标点P3,Label_Y_P3,23,,,44,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_Y_P3_speed")]
public int Label_Y_P3_speed { get; set; }
/// <summary>
/// PRO,15,贴标Z轴待机点P1,Label_Z_P1,25,,,44,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_Z_P1_speed")]
public int Label_Z_P1_speed { get; set; }
/// <summary>
/// PRO,15,贴标Z轴取标点P2,Label_Z_P2,26,,,44,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_Z_P2_speed")]
public int Label_Z_P2_speed { get; set; }
/// <summary>
/// PRO,15,贴标Z轴贴标点P3,Label_Z_P3,27,,,44,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_Z_P3_speed")]
public int Label_Z_P3_speed { get; set; }
/// <summary>
/// PRO,16,贴标R轴待机点P1,Label_R_P1,29,,,22,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_R_P1_speed")]
public int Label_R_P1_speed { get; set; }
/// <summary>
/// PRO,16,贴标R轴取标点P2,Label_R_P2,30,,,22,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_R_P2_speed")]
public int Label_R_P2_speed { get; set; }
/// <summary>
/// PRO,16,贴标R轴360度脉冲,Label_R_P3,31,,,22,,,,,,,,,
/// </summary>
[ConfigProAttribute("Label_R_P3_speed")]
public int Label_R_P3_speed { get; set; }
}
}

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30907.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadCSVLibrary", "LoadCVSLibrary\LoadCSVLibrary.csproj", "{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{43CDD09E-FCF3-4960-A01D-3BBFE9933122}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoScanAndLabel", "AutoScanAndLabel\AutoScanAndLabel.csproj", "{61FDFF14-8BB7-439A-85A0-592E3011F4C4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceLibrary", "DeviceLibrary\DeviceLibrary.csproj", "{BB23296C-AA1D-45C6-9FA6-5A37B2ABFE9B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}.Debug|Any CPU.Build.0 = Debug|Any CPU
{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}.Release|Any CPU.ActiveCfg = Release|Any CPU
{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}.Release|Any CPU.Build.0 = Release|Any CPU
{43CDD09E-FCF3-4960-A01D-3BBFE9933122}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43CDD09E-FCF3-4960-A01D-3BBFE9933122}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43CDD09E-FCF3-4960-A01D-3BBFE9933122}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43CDD09E-FCF3-4960-A01D-3BBFE9933122}.Release|Any CPU.Build.0 = Release|Any CPU
{61FDFF14-8BB7-439A-85A0-592E3011F4C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{61FDFF14-8BB7-439A-85A0-592E3011F4C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61FDFF14-8BB7-439A-85A0-592E3011F4C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61FDFF14-8BB7-439A-85A0-592E3011F4C4}.Release|Any CPU.Build.0 = Release|Any CPU
{BB23296C-AA1D-45C6-9FA6-5A37B2ABFE9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BB23296C-AA1D-45C6-9FA6-5A37B2ABFE9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BB23296C-AA1D-45C6-9FA6-5A37B2ABFE9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BB23296C-AA1D-45C6-9FA6-5A37B2ABFE9B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BA4F2116-5AFF-4DE1-9860-4A389EDBD60D}
EndGlobalSection
EndGlobal
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!