Commit 2373e218 刘韬

1

2 个父辈 3886d6c2 be188147
此文件类型无法预览
......@@ -126,7 +126,7 @@ namespace ACServoDriveTest
{
//bean.closePort();
ACServerManager.ServoOff(GetPortName(), GetSlaveAddr());
ACServerManager.ColsePort(GetPortName() );
// ACServerManager.ColsePort(GetPortName() );
formStatus(false);
}
private void Form1_Load(object sender, EventArgs e)
......
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.ACSingleStore</RootNamespace>
<AssemblyName>ZHACSingleStore</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
......@@ -92,6 +92,12 @@
<DependentUpon>FrmStoreBox.cs</DependentUpon>
</Compile>
<Compile Include="ManagerUtil.cs" />
<Compile Include="positionTool\FrmPositionTool.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="positionTool\FrmPositionTool.Designer.cs">
<DependentUpon>FrmPositionTool.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FrmAxisDebug.resx">
......@@ -109,6 +115,9 @@
<EmbeddedResource Include="FrmStoreBox.resx">
<DependentUpon>FrmStoreBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="positionTool\FrmPositionTool.resx">
<DependentUpon>FrmPositionTool.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
......@@ -128,79 +137,6 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="Skins\back\DeepCyan.ssk" />
<None Include="Skins\back\DeepGreen.ssk" />
<None Include="Skins\back\DeepOrange.ssk" />
<None Include="Skins\Calmness.ssk" />
<None Include="Skins\CalmnessColor1.ssk" />
<None Include="Skins\CalmnessColor2.ssk" />
<None Include="Skins\DiamondBlue.ssk" />
<None Include="Skins\DiamondGreen.ssk" />
<None Include="Skins\DiamondOlive.ssk" />
<None Include="Skins\DiamondPurple.ssk" />
<None Include="Skins\DiamondRed.ssk" />
<None Include="Skins\Eighteen.ssk" />
<None Include="Skins\EighteenColor1.ssk" />
<None Include="Skins\EighteenColor2.ssk" />
<None Include="Skins\Emerald.ssk" />
<None Include="Skins\EmeraldColor1.ssk" />
<None Include="Skins\EmeraldColor2.ssk" />
<None Include="Skins\EmeraldColor3.ssk" />
<None Include="Skins\GlassBrown.ssk" />
<None Include="Skins\GlassGreen.ssk" />
<None Include="Skins\GlassOrange.ssk" />
<None Include="Skins\Longhorn.ssk" />
<None Include="Skins\MacOS.ssk" />
<None Include="Skins\Midsummer.ssk" />
<None Include="Skins\MidsummerColor1.ssk" />
<None Include="Skins\MidsummerColor2.ssk" />
<None Include="Skins\MidsummerColor3.ssk" />
<None Include="Skins\mp10.ssk" />
<None Include="Skins\mp10green.ssk" />
<None Include="Skins\mp10maroon.ssk" />
<None Include="Skins\mp10mulberry.ssk" />
<None Include="Skins\mp10pink.ssk" />
<None Include="Skins\mp10purple.ssk" />
<None Include="Skins\MSN.ssk" />
<None Include="Skins\office2007.ssk" />
<None Include="Skins\OneBlue.ssk" />
<None Include="Skins\OneCyan.ssk" />
<None Include="Skins\OneGreen.ssk" />
<None Include="Skins\OneOrange.ssk" />
<None Include="Skins\Page.ssk" />
<None Include="Skins\PageColor1.ssk" />
<None Include="Skins\PageColor2.ssk" />
<None Include="Skins\RealOne.ssk" />
<None Include="Skins\Silver.ssk" />
<None Include="Skins\SilverColor1.ssk" />
<None Include="Skins\SilverColor2.ssk" />
<None Include="Skins\SportsBlack.ssk" />
<None Include="Skins\SportsBlue.ssk" />
<None Include="Skins\SportsCyan.ssk" />
<None Include="Skins\SportsGreen.ssk" />
<None Include="Skins\SportsOrange.ssk" />
<None Include="Skins\SteelBlack.ssk" />
<None Include="Skins\SteelBlue.ssk" />
<None Include="Skins\vista1.ssk" />
<None Include="Skins\vista1_green.ssk" />
<None Include="Skins\Vista2_color1.ssk" />
<None Include="Skins\Vista2_color2.ssk" />
<None Include="Skins\Vista2_color3.ssk" />
<None Include="Skins\Vista2_color4.ssk" />
<None Include="Skins\Vista2_color5.ssk" />
<None Include="Skins\Vista2_color6.ssk" />
<None Include="Skins\Vista2_color7.ssk" />
<None Include="Skins\Warm.ssk" />
<None Include="Skins\WarmColor1.ssk" />
<None Include="Skins\WarmColor2.ssk" />
<None Include="Skins\WarmColor3.ssk" />
<None Include="Skins\Wave.ssk" />
<None Include="Skins\WaveColor1.ssk" />
<None Include="Skins\WaveColor2.ssk" />
<None Include="Skins\XPBlue.ssk" />
<None Include="Skins\XPGreen.ssk" />
<None Include="Skins\XPOrange.ssk" />
<None Include="Skins\XPSilver.ssk" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
......
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<appSettings>
<!--是否开机自动启动料仓-->
<add key="App_AutoRun" value="1" />
<add key="App_Title" value="AC_SA_料仓_1" />
<add key="scanner_start_command" value="S" />
<add key="App_AutoRun" value="1"/>
<add key="App_Title" value="AC_SA_料仓_1"/>
<add key="scanner_start_command" value="S"/>
<!-- 开始吹气的判断值(配置值=服务器发送的湿度值-开始吹气值)-->
<add key="StartBlowValue" value="4" />
<add key="StartBlowValue" value="4"/>
<!-- 停止吹气的判断值(配置值=服务器发送的湿度值-停止吹气值)-->
<add key="StopBlowValue" value="4" />
<add key="StopBlowValue" value="4"/>
<!--Server address-->
<!--<add key="http.server" value="http://localhost:80/"/>-->
<!--storeType-->
<add key="store_count" value="1" />
<add key="store_count" value="1"/>
<!--start one store config-->
<add key="Store_Position_Config" value="\StoreConfig\AC\linePositions.csv" />
<add key="Store_ConfigPath" value="\StoreConfig\AC\StoreConfig.csv" />
<add key="Store_Type" value="RC_AC_SA" />
<add key="Store_CID" value="zhac1" />
<add key="Store_Position_Config" value="\StoreConfig\AC\linePositions.csv"/>
<add key="Store_ConfigPath" value="\StoreConfig\AC\StoreConfig.csv"/>
<add key="Store_Type" value="RC_AC_SA"/>
<add key="Store_CID" value="zhac1"/>
<!--end one store config-->
<!--摄像机名称列表配置,用#分割-->
<add key="CameraName" value="GigE:MV-CE100-30GC (00C69898484)" />
<add key="CameraName" value="GigE:MV-CE100-30GC (00C69898484)"/>
<!--二维码类型列表配置,用#分割,一维码=Barcode。-->
<add key="CodeType" value="Barcode" />
<add key="CodeType" value="Barcode"/>
<!--<add key="CodeType" value="Data Matrix ECC 200"/>-->
<!--二维码参数文件所在路径,文件名与二维码类型名一样-->
<add key="CodeParamPath" value="\CodeParam\" />
<add key ="AI_ConvertPosition" value ="55"/>
<add key ="InOutDefaultPosition" value ="8000"/>
<add key ="Config_Pwd" value ="123456"/>
<add key="CodeParamPath" value="\CodeParam\"/>
<add key="AI_ConvertPosition" value="55"/>
<add key="InOutDefaultPosition" value="8000"/>
<add key="Config_Pwd" value="123456"/>
<!--出库等待料盘拿走的时间,秒-->
<add key ="OutStoreWaitSeconds" value ="600"/>
<add key="OutStoreWaitSeconds" value="600"/>
<!--压紧轴对应4mm的脉冲-->
<add key="ComAxisChangeValue" value="2400" />
<add key="ComAxisChangeValue" value="2400"/>
<!--伺服波特率-->
<add key="ACBaudRate" value="115200"/>
</appSettings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs/ZHACStore1.log" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
<file value="logs/ZHACStore1.log"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" />
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<root>
<level value="Info" />
<appender-ref ref="RollingLogFileAppender" />
<level value="Info"/>
<appender-ref ref="RollingLogFileAppender"/>
</root>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<!-- 部署服务库项目时,必须将配置文件的内容添加到
主机的 app.config 文件中。System.Configuration 不支持库的配置文件。 -->
......@@ -63,14 +65,14 @@
<service name="AcStoreWCF.CWSMDBox">
<endpoint address="" binding="basicHttpBinding" contract="AcStoreWCF.ICWSMDBox">
<identity>
<dns value="localhost" />
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/AcStoreWCF/CWSMDBox/" />
<add baseAddress="http://localhost:8733/Design_Time_Addresses/AcStoreWCF/CWSMDBox/"/>
</baseAddresses>
</host>
</service>
......@@ -80,11 +82,11 @@
<behavior>
<!-- 为避免泄漏元数据信息,
请在部署前将以下值设置为 false -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<!-- 要接收故障异常详细信息以进行调试,
请将以下值设置为 true。在部署前设置为 false
以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="False" />
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
......
......@@ -54,12 +54,19 @@
this.btnComMove = new System.Windows.Forms.Button();
this.txtComSpeed = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.lblSpeed = new System.Windows.Forms.Label();
this.trackBar1 = new System.Windows.Forms.TrackBar();
this.btnMCopy = new System.Windows.Forms.Button();
this.btnUCopy = new System.Windows.Forms.Button();
this.btnICopy = new System.Windows.Forms.Button();
this.btnCCopy = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(39, 77);
this.label1.Location = new System.Drawing.Point(39, 79);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(92, 17);
this.label1.TabIndex = 0;
......@@ -68,7 +75,7 @@
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(39, 131);
this.label2.Location = new System.Drawing.Point(39, 136);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(92, 17);
this.label2.TabIndex = 1;
......@@ -77,7 +84,7 @@
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(39, 184);
this.label3.Location = new System.Drawing.Point(39, 194);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(92, 17);
this.label3.TabIndex = 2;
......@@ -86,9 +93,11 @@
// btnMiddleMove
//
this.btnMiddleMove.BackColor = System.Drawing.SystemColors.Control;
this.btnMiddleMove.Location = new System.Drawing.Point(266, 70);
this.btnMiddleMove.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnMiddleMove.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnMiddleMove.Location = new System.Drawing.Point(246, 65);
this.btnMiddleMove.Name = "btnMiddleMove";
this.btnMiddleMove.Size = new System.Drawing.Size(131, 36);
this.btnMiddleMove.Size = new System.Drawing.Size(140, 45);
this.btnMiddleMove.TabIndex = 4;
this.btnMiddleMove.Text = "旋转轴+(顺时针)";
this.btnMiddleMove.UseVisualStyleBackColor = false;
......@@ -97,31 +106,42 @@
//
// txtMiddleSpeed
//
this.txtMiddleSpeed.Location = new System.Drawing.Point(150, 75);
this.txtMiddleSpeed.Enabled = false;
this.txtMiddleSpeed.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtMiddleSpeed.Location = new System.Drawing.Point(140, 74);
this.txtMiddleSpeed.MaxLength = 10;
this.txtMiddleSpeed.Name = "txtMiddleSpeed";
this.txtMiddleSpeed.Size = new System.Drawing.Size(108, 23);
this.txtMiddleSpeed.Size = new System.Drawing.Size(97, 26);
this.txtMiddleSpeed.TabIndex = 5;
//
// txtUpDownSpeed
//
this.txtUpDownSpeed.Location = new System.Drawing.Point(150, 129);
this.txtUpDownSpeed.Enabled = false;
this.txtUpDownSpeed.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtUpDownSpeed.Location = new System.Drawing.Point(140, 131);
this.txtUpDownSpeed.MaxLength = 10;
this.txtUpDownSpeed.Name = "txtUpDownSpeed";
this.txtUpDownSpeed.Size = new System.Drawing.Size(108, 23);
this.txtUpDownSpeed.Size = new System.Drawing.Size(97, 26);
this.txtUpDownSpeed.TabIndex = 6;
//
// txtInOutSpeed
//
this.txtInOutSpeed.Location = new System.Drawing.Point(150, 182);
this.txtInOutSpeed.Enabled = false;
this.txtInOutSpeed.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtInOutSpeed.Location = new System.Drawing.Point(140, 189);
this.txtInOutSpeed.MaxLength = 10;
this.txtInOutSpeed.Name = "txtInOutSpeed";
this.txtInOutSpeed.Size = new System.Drawing.Size(108, 23);
this.txtInOutSpeed.Size = new System.Drawing.Size(97, 26);
this.txtInOutSpeed.TabIndex = 7;
//
// btnUpDownMove
//
this.btnUpDownMove.BackColor = System.Drawing.SystemColors.Control;
this.btnUpDownMove.Location = new System.Drawing.Point(266, 124);
this.btnUpDownMove.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnUpDownMove.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnUpDownMove.Location = new System.Drawing.Point(246, 122);
this.btnUpDownMove.Name = "btnUpDownMove";
this.btnUpDownMove.Size = new System.Drawing.Size(131, 36);
this.btnUpDownMove.Size = new System.Drawing.Size(140, 45);
this.btnUpDownMove.TabIndex = 9;
this.btnUpDownMove.Text = "升降轴+(上升)";
this.btnUpDownMove.UseVisualStyleBackColor = false;
......@@ -131,9 +151,11 @@
// btnInOutMove
//
this.btnInOutMove.BackColor = System.Drawing.SystemColors.Control;
this.btnInOutMove.Location = new System.Drawing.Point(266, 177);
this.btnInOutMove.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnInOutMove.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnInOutMove.Location = new System.Drawing.Point(246, 180);
this.btnInOutMove.Name = "btnInOutMove";
this.btnInOutMove.Size = new System.Drawing.Size(131, 36);
this.btnInOutMove.Size = new System.Drawing.Size(140, 45);
this.btnInOutMove.TabIndex = 10;
this.btnInOutMove.Text = "进出轴+(前进)";
this.btnInOutMove.UseVisualStyleBackColor = false;
......@@ -143,9 +165,11 @@
// btnInOutMovej
//
this.btnInOutMovej.BackColor = System.Drawing.SystemColors.Control;
this.btnInOutMovej.Location = new System.Drawing.Point(401, 177);
this.btnInOutMovej.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnInOutMovej.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnInOutMovej.Location = new System.Drawing.Point(395, 180);
this.btnInOutMovej.Name = "btnInOutMovej";
this.btnInOutMovej.Size = new System.Drawing.Size(131, 36);
this.btnInOutMovej.Size = new System.Drawing.Size(140, 45);
this.btnInOutMovej.TabIndex = 14;
this.btnInOutMovej.Text = "进出轴-(后退)";
this.btnInOutMovej.UseVisualStyleBackColor = false;
......@@ -155,9 +179,11 @@
// btnUpDownMovej
//
this.btnUpDownMovej.BackColor = System.Drawing.SystemColors.Control;
this.btnUpDownMovej.Location = new System.Drawing.Point(401, 124);
this.btnUpDownMovej.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnUpDownMovej.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnUpDownMovej.Location = new System.Drawing.Point(395, 122);
this.btnUpDownMovej.Name = "btnUpDownMovej";
this.btnUpDownMovej.Size = new System.Drawing.Size(131, 36);
this.btnUpDownMovej.Size = new System.Drawing.Size(140, 45);
this.btnUpDownMovej.TabIndex = 13;
this.btnUpDownMovej.Text = "升降轴-(下降)";
this.btnUpDownMovej.UseVisualStyleBackColor = false;
......@@ -167,9 +193,11 @@
// btnMiddleMovej
//
this.btnMiddleMovej.BackColor = System.Drawing.SystemColors.Control;
this.btnMiddleMovej.Location = new System.Drawing.Point(401, 70);
this.btnMiddleMovej.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnMiddleMovej.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnMiddleMovej.Location = new System.Drawing.Point(395, 65);
this.btnMiddleMovej.Name = "btnMiddleMovej";
this.btnMiddleMovej.Size = new System.Drawing.Size(131, 36);
this.btnMiddleMovej.Size = new System.Drawing.Size(140, 45);
this.btnMiddleMovej.TabIndex = 12;
this.btnMiddleMovej.Text = "旋转轴-(逆时针)";
this.btnMiddleMovej.UseVisualStyleBackColor = false;
......@@ -178,7 +206,8 @@
//
// button1
//
this.button1.Location = new System.Drawing.Point(401, 336);
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.Location = new System.Drawing.Point(569, 347);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(126, 37);
this.button1.TabIndex = 16;
......@@ -188,23 +217,32 @@
//
// txtInOutPosition
//
this.txtInOutPosition.Location = new System.Drawing.Point(551, 182);
this.txtInOutPosition.Enabled = false;
this.txtInOutPosition.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtInOutPosition.Location = new System.Drawing.Point(544, 189);
this.txtInOutPosition.MaxLength = 20;
this.txtInOutPosition.Name = "txtInOutPosition";
this.txtInOutPosition.Size = new System.Drawing.Size(108, 23);
this.txtInOutPosition.Size = new System.Drawing.Size(108, 26);
this.txtInOutPosition.TabIndex = 19;
//
// txtUpdownPosition
//
this.txtUpdownPosition.Location = new System.Drawing.Point(551, 129);
this.txtUpdownPosition.Enabled = false;
this.txtUpdownPosition.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtUpdownPosition.Location = new System.Drawing.Point(544, 131);
this.txtUpdownPosition.MaxLength = 20;
this.txtUpdownPosition.Name = "txtUpdownPosition";
this.txtUpdownPosition.Size = new System.Drawing.Size(108, 23);
this.txtUpdownPosition.Size = new System.Drawing.Size(108, 26);
this.txtUpdownPosition.TabIndex = 18;
//
// txtMiddlePosition
//
this.txtMiddlePosition.Location = new System.Drawing.Point(551, 75);
this.txtMiddlePosition.Enabled = false;
this.txtMiddlePosition.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtMiddlePosition.Location = new System.Drawing.Point(544, 74);
this.txtMiddlePosition.MaxLength = 20;
this.txtMiddlePosition.Name = "txtMiddlePosition";
this.txtMiddlePosition.Size = new System.Drawing.Size(108, 23);
this.txtMiddlePosition.Size = new System.Drawing.Size(108, 26);
this.txtMiddlePosition.TabIndex = 17;
//
// label5
......@@ -232,19 +270,24 @@
//
// txtComPosition
//
this.txtComPosition.Location = new System.Drawing.Point(551, 240);
this.txtComPosition.Enabled = false;
this.txtComPosition.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtComPosition.Location = new System.Drawing.Point(544, 249);
this.txtComPosition.MaxLength = 20;
this.txtComPosition.Name = "txtComPosition";
this.txtComPosition.Size = new System.Drawing.Size(108, 23);
this.txtComPosition.Size = new System.Drawing.Size(108, 26);
this.txtComPosition.TabIndex = 26;
//
// btnComMovej
//
this.btnComMovej.BackColor = System.Drawing.SystemColors.Control;
this.btnComMovej.Location = new System.Drawing.Point(401, 235);
this.btnComMovej.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnComMovej.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnComMovej.Location = new System.Drawing.Point(395, 240);
this.btnComMovej.Name = "btnComMovej";
this.btnComMovej.Size = new System.Drawing.Size(131, 36);
this.btnComMovej.Size = new System.Drawing.Size(140, 45);
this.btnComMovej.TabIndex = 25;
this.btnComMovej.Text = "压紧轴-(向)";
this.btnComMovej.Text = "压紧轴-(向)";
this.btnComMovej.UseVisualStyleBackColor = false;
this.btnComMovej.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnComMovej_MouseDown);
this.btnComMovej.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnComMovej_MouseUp);
......@@ -252,36 +295,111 @@
// btnComMove
//
this.btnComMove.BackColor = System.Drawing.SystemColors.Control;
this.btnComMove.Location = new System.Drawing.Point(266, 235);
this.btnComMove.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnComMove.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnComMove.Location = new System.Drawing.Point(246, 240);
this.btnComMove.Name = "btnComMove";
this.btnComMove.Size = new System.Drawing.Size(131, 36);
this.btnComMove.Size = new System.Drawing.Size(140, 45);
this.btnComMove.TabIndex = 24;
this.btnComMove.Text = "压紧轴+(向)";
this.btnComMove.Text = "压紧轴+(向)";
this.btnComMove.UseVisualStyleBackColor = false;
this.btnComMove.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnComMove_MouseDown);
this.btnComMove.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnComMove_MouseUp);
//
// txtComSpeed
//
this.txtComSpeed.Location = new System.Drawing.Point(150, 240);
this.txtComSpeed.Enabled = false;
this.txtComSpeed.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtComSpeed.Location = new System.Drawing.Point(140, 249);
this.txtComSpeed.MaxLength = 10;
this.txtComSpeed.Name = "txtComSpeed";
this.txtComSpeed.Size = new System.Drawing.Size(108, 23);
this.txtComSpeed.Size = new System.Drawing.Size(97, 26);
this.txtComSpeed.TabIndex = 23;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(39, 242);
this.label4.Location = new System.Drawing.Point(39, 254);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(92, 17);
this.label4.TabIndex = 22;
this.label4.Text = "(轴四)压紧轴";
//
// lblSpeed
//
this.lblSpeed.AutoSize = true;
this.lblSpeed.Location = new System.Drawing.Point(313, 377);
this.lblSpeed.Name = "lblSpeed";
this.lblSpeed.Size = new System.Drawing.Size(142, 17);
this.lblSpeed.TabIndex = 30;
this.lblSpeed.Text = "点动速度=0.2倍目标速度";
//
// trackBar1
//
this.trackBar1.LargeChange = 2;
this.trackBar1.Location = new System.Drawing.Point(42, 328);
this.trackBar1.Minimum = 1;
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(366, 45);
this.trackBar1.TabIndex = 29;
this.trackBar1.Value = 2;
this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged);
//
// btnMCopy
//
this.btnMCopy.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnMCopy.Location = new System.Drawing.Point(661, 73);
this.btnMCopy.Name = "btnMCopy";
this.btnMCopy.Size = new System.Drawing.Size(69, 28);
this.btnMCopy.TabIndex = 31;
this.btnMCopy.Text = "复制";
this.btnMCopy.UseVisualStyleBackColor = true;
this.btnMCopy.Click += new System.EventHandler(this.btnMCopy_Click);
//
// btnUCopy
//
this.btnUCopy.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnUCopy.Location = new System.Drawing.Point(661, 130);
this.btnUCopy.Name = "btnUCopy";
this.btnUCopy.Size = new System.Drawing.Size(69, 28);
this.btnUCopy.TabIndex = 32;
this.btnUCopy.Text = "复制";
this.btnUCopy.UseVisualStyleBackColor = true;
this.btnUCopy.Click += new System.EventHandler(this.btnUCopy_Click);
//
// btnICopy
//
this.btnICopy.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnICopy.Location = new System.Drawing.Point(661, 188);
this.btnICopy.Name = "btnICopy";
this.btnICopy.Size = new System.Drawing.Size(69, 28);
this.btnICopy.TabIndex = 33;
this.btnICopy.Text = "复制";
this.btnICopy.UseVisualStyleBackColor = true;
this.btnICopy.Click += new System.EventHandler(this.btnICopy_Click);
//
// btnCCopy
//
this.btnCCopy.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCCopy.Location = new System.Drawing.Point(661, 248);
this.btnCCopy.Name = "btnCCopy";
this.btnCCopy.Size = new System.Drawing.Size(69, 28);
this.btnCCopy.TabIndex = 34;
this.btnCCopy.Text = "复制";
this.btnCCopy.UseVisualStyleBackColor = true;
this.btnCCopy.Click += new System.EventHandler(this.btnCCopy_Click);
//
// FrmAxisDebug
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(707, 413);
this.ClientSize = new System.Drawing.Size(805, 442);
this.Controls.Add(this.btnCCopy);
this.Controls.Add(this.btnICopy);
this.Controls.Add(this.btnUCopy);
this.Controls.Add(this.btnMCopy);
this.Controls.Add(this.lblSpeed);
this.Controls.Add(this.trackBar1);
this.Controls.Add(this.txtComPosition);
this.Controls.Add(this.btnComMovej);
this.Controls.Add(this.btnComMove);
......@@ -312,6 +430,7 @@
this.Text = "轴点动调试";
this.Load += new System.EventHandler(this.FrmAxisDebug_Load);
this.Shown += new System.EventHandler(this.FrmAxisDebug_Shown);
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
......@@ -343,5 +462,11 @@
private System.Windows.Forms.Button btnComMove;
private System.Windows.Forms.TextBox txtComSpeed;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label lblSpeed;
private System.Windows.Forms.TrackBar trackBar1;
private System.Windows.Forms.Button btnMCopy;
private System.Windows.Forms.Button btnUCopy;
private System.Windows.Forms.Button btnICopy;
private System.Windows.Forms.Button btnCCopy;
}
}
\ No newline at end of file
......@@ -23,17 +23,19 @@ namespace OnlineStore.ACSingleStore
private ConfigMoveAxis updown = null;
//private ConfigMoveAxis compress = null;
private ConfigMoveAxis inout = null;
private int compress_Slv = 0;
private ConfigMoveAxis comp = null;
//private int compress_Slv = 0;
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public FrmAxisDebug(AC_SA_BoxBean boxBean)
{
middle = boxBean.Config.Middle_Axis;
updown = boxBean.Config.UpDown_Axis;
compress_Slv = boxBean.Config.CompressAxis_Slv;
//compress_Slv = boxBean.Config.CompressAxis_Slv;
comp = boxBean.Config.Comp_Axis;
inout = boxBean.Config.InOut_Axis;
InitializeComponent();
txtComSpeed.Text = boxBean.Config.CompressAxis_EndSpeed.ToString();
this.Text = boxBean.StoreName + "_轴点动调试";
}
......@@ -48,7 +50,7 @@ namespace OnlineStore.ACSingleStore
txtMiddleSpeed.Text = (middle.TargetSpeed / 5).ToString();
txtInOutSpeed.Text = (inout.TargetSpeed / 5).ToString();
txtUpDownSpeed.Text = (updown.TargetSpeed / 5).ToString();
txtComSpeed.Text = (StoreManager.Config.CompressAxis_EndSpeed/5).ToString();
txtComSpeed.Text = (comp.TargetSpeed/5).ToString();
timer1.Start();
}
/// <summary>
......@@ -246,6 +248,8 @@ namespace OnlineStore.ACSingleStore
}
private void btnComMove_MouseDown(object sender, MouseEventArgs e)
{
if (btnComMove.BackColor.Equals(System.Drawing.SystemColors.Control))
{
int speed = FormUtil.GetIntValue(txtComSpeed);
if (speed <= 0)
{
......@@ -253,10 +257,8 @@ namespace OnlineStore.ACSingleStore
return;
}
this.btnComMove.BackColor = Color.Green;
ShuoKeControls.SetSpeed(compress_Slv, ShuoKeCMD.SetEndSpeed, speed);
ShuoKeControls.SetSpeed(compress_Slv, ShuoKeCMD.SetMaxSpeed, speed);
ShuoKeControls.VolMove(compress_Slv, speed);
AxisMove(comp, speed);
}
}
private void btnComMove_MouseUp(object sender, MouseEventArgs e)
......@@ -264,10 +266,8 @@ namespace OnlineStore.ACSingleStore
if (this.btnComMove.BackColor == Color.Green)
{
btnComMove.BackColor = System.Drawing.SystemColors.Control;
ShuoKeControls.SuddownStop(compress_Slv);
// ShuoKeControls.GetABSPosition(compress_Slv);
txtComPosition.Text = ShuoKeControls.GetABSPosition(compress_Slv).ToString();
ACServerManager.SuddenStop(comp.DeviceName, comp.GetAxisValue());
UpdateCompPosition();
}
}
private void btnComMovej_MouseDown(object sender, MouseEventArgs e)
......@@ -279,9 +279,7 @@ namespace OnlineStore.ACSingleStore
return;
}
this.btnComMovej.BackColor = Color.Green;
ShuoKeControls.SetSpeed(compress_Slv, ShuoKeCMD.SetEndSpeed, speed);
ShuoKeControls.SetSpeed(compress_Slv, ShuoKeCMD.SetMaxSpeed, speed);
ShuoKeControls.VolMove(compress_Slv,-speed);
AxisMove(comp, -speed);
}
private void btnComMovej_MouseUp(object sender, MouseEventArgs e)
......@@ -289,9 +287,8 @@ namespace OnlineStore.ACSingleStore
if (btnComMovej.BackColor.Equals(Color.Green))
{
btnComMovej.BackColor = System.Drawing.SystemColors.Control;
ShuoKeControls.SuddownStop(compress_Slv);
// ShuoKeControls.GetABSPosition(compress_Slv);
txtComPosition.Text = ShuoKeControls.GetABSPosition(compress_Slv).ToString();
ACServerManager.SuddenStop(comp.DeviceName,comp.GetAxisValue());
UpdateCompPosition();
}
}
......@@ -303,7 +300,6 @@ namespace OnlineStore.ACSingleStore
private void FrmAxisDebug_Shown(object sender, EventArgs e)
{
SetSkin(this);
}
private void timer1_Tick(object sender, EventArgs e)
......@@ -313,22 +309,18 @@ namespace OnlineStore.ACSingleStore
UpdateMiddlePosition();
UpdateInOutPosition();
UpdateUpdownPosition();
txtComPosition.Text = ShuoKeControls.GetABSPosition(compress_Slv).ToString();
//ShuoKeInfo info = ShuoKeControls.GetLastPosition(compress_Slv);
//if (info != null)
//{
// txtComPosition.Text = info.LastPosition.ToString();
// TimeSpan span = DateTime.Now - info.UpdateTime;
// if (span.TotalSeconds > 1.5)
// {
// ShuoKeControls.GetABSPosition(compress_Slv);
// }
//}
UpdateCompPosition();
// txtComPosition.Text = ShuoKeControls.GetLastPosition(compress_Slv).ToString();
}
}
private void UpdateCompPosition()
{
int compPosition = ACServerManager.GetTargetPosition(comp.DeviceName, comp.GetAxisValue());
if (!txtComPosition.Text.Equals(compPosition.ToString()))
{
txtComPosition.Text = compPosition.ToString();
}
}
private void UpdateUpdownPosition()
{
int updownPosition = ACServerManager.GetTargetPosition(updown.DeviceName, updown.GetAxisValue());
......@@ -355,5 +347,35 @@ namespace OnlineStore.ACSingleStore
txtInOutPosition.Text = inoutPosition.ToString();
}
}
private void trackBar1_ValueChanged(object sender, EventArgs e)
{
int value = trackBar1.Value;
lblSpeed.Text = "点动速度=" + (value / 10f) + "倍目标速度";
txtMiddleSpeed.Text = (middle.TargetSpeed * value / 10).ToString();
txtInOutSpeed.Text = (inout.TargetSpeed * value / 10).ToString();
txtUpDownSpeed.Text = (updown.TargetSpeed * value / 10).ToString();
txtComSpeed.Text = (comp.TargetSpeed * value / 10).ToString();
}
private void btnMCopy_Click(object sender, EventArgs e)
{
Clipboard.SetDataObject(txtMiddlePosition.Text, true);
}
private void btnUCopy_Click(object sender, EventArgs e)
{
Clipboard.SetDataObject(txtUpdownPosition.Text, true);
}
private void btnICopy_Click(object sender, EventArgs e)
{
Clipboard.SetDataObject(txtInOutPosition.Text, true);
}
private void btnCCopy_Click(object sender, EventArgs e)
{
Clipboard.SetDataObject(txtComPosition.Text, true);
}
}
}
......@@ -17,6 +17,7 @@ using OnlineStore.DeviceLibrary;
using System.IO.Ports;
using OnlineStore.LoadCSVLibrary;
using CodeLibrary;
using UserFromControl;
namespace OnlineStore.ACSingleStore
{
......@@ -46,7 +47,7 @@ namespace OnlineStore.ACSingleStore
LogUtil.error(LOGGER, "找不到对应的料仓");
return;
}
txtSpeed.Text = store.Config.CompressAxis_EndSpeed.ToString();
// txtSpeed.Text = store.Config.CompressAxis_EndSpeed.ToString();
cmbAxisList.DataSource = new List<ConfigMoveAxis>(store.moveAxisList);
cmbAxisList.DisplayMember = "Explain";
cmbAxisList.ValueMember = "Explain";
......@@ -89,13 +90,13 @@ namespace OnlineStore.ACSingleStore
//txtUpDownP1.Text = ktkPosition.UpDownAxis_DoorOPosition_P1.ToString();
}
List<string> port = new List<string>(SerialPort.GetPortNames());
comboBoxPortName.DataSource = port;
if (port.IndexOf(store.Config.CompressAxis_PortName) >= 0)
{
comboBoxPortName.SelectedIndex = port.IndexOf(store.Config.CompressAxis_PortName);
}
cmbHomeType.SelectedIndex = 0;
//List<string> port = new List<string>(SerialPort.GetPortNames());
//comboBoxPortName.DataSource = port;
//if (port.IndexOf(store.Config.CompressAxis_PortName) >= 0)
//{
// comboBoxPortName.SelectedIndex = port.IndexOf(store.Config.CompressAxis_PortName);
//}
//cmbHomeType.SelectedIndex = 0;
timer1.Enabled = true;
}
#endregion
......@@ -149,7 +150,7 @@ namespace OnlineStore.ACSingleStore
this.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
notifyIcon1.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
LoadOk = true;
cmbHomeType.SelectedIndex = 1;
// cmbHomeType.SelectedIndex = 1;
HideForm();
}
private DateTime preReadModblsTime = DateTime.Now;
......@@ -166,25 +167,7 @@ namespace OnlineStore.ACSingleStore
//忙碌状态不读取状态
if (!store.storeRunStatus.Equals(StoreRunStatus.Busy))
{
if (chbAutoRead.Checked)
{
string portName = GetPortName();
int SlvAddr = GetSlaveAddr();
//判断私服是否打开、
if (ACServerManager.ServerOnStatus(portName, SlvAddr))
{
lblServerOn.Text = "伺服ON";
int lOutPulse = ACServerManager.GetTargetPosition(portName, SlvAddr);
lblOutPulse.Text = string.Format("{0:d}", lOutPulse);
int lCountPulse = ACServerManager.GetActualtPosition(portName, SlvAddr);
lblCountPulse.Text = string.Format("{0:d}", lCountPulse);
}
else
{
lblServerOn.Text = "伺服OFF";
}
}
}
//ReadPosistion();
......@@ -294,92 +277,6 @@ namespace OnlineStore.ACSingleStore
//}
}
private void ReadPosistion()
{
string portName = GetPortName();
int SlvAddr = GetSlaveAddr();
//判断私服是否打开、
if (ACServerManager.ServerOnStatus(portName, SlvAddr))
{
lblServerOn.Text = "伺服ON";
}
else
{
lblServerOn.Text = "伺服OFF";
}
string deviceName = GetPortName();
if (ACServerManager.ServerOnStatus(store.Config.Middle_Axis.DeviceName, store.Config.Middle_Axis.GetAxisValue()))
{
axis_1_Alarm.IOValue = ACServerManager.GetAlarmStatus(store.Config.Middle_Axis.DeviceName, store.Config.Middle_Axis.GetAxisValue());
axis_1_Alarm.ShowData();
int lOutPulse1 = ACServerManager.GetTargetPosition(store.Config.Middle_Axis.DeviceName, store.Config.Middle_Axis.GetAxisValue());
lblOutPulse1.Text = string.Format("{0:d}", lOutPulse1);
int lCountPulse1 = ACServerManager.GetActualtPosition(store.Config.Middle_Axis.DeviceName, store.Config.Middle_Axis.GetAxisValue());
lblCountPulse1.Text = string.Format("{0:d}", lCountPulse1);
txtMiddleTarget.Text = store.Config.Middle_Axis.TargetPosition.ToString();
if ( store.Config.Middle_Axis.IsSameAxis(portName,SlvAddr))
{
lblOutPulse.Text = lblOutPulse1.Text;
lblCountPulse.Text = lblCountPulse1.Text;
}
}
if (ACServerManager.ServerOnStatus(store.Config.UpDown_Axis.DeviceName, store.Config.UpDown_Axis.GetAxisValue()))
{
axis_2_Alarm.IOValue = ACServerManager.GetAlarmStatus(store.Config.UpDown_Axis.DeviceName, store.Config.UpDown_Axis.GetAxisValue());
axis_2_Alarm.ShowData();
int lOutPulse2 = ACServerManager.GetTargetPosition(store.Config.UpDown_Axis.DeviceName, store.Config.UpDown_Axis.GetAxisValue());
lblOutPulse2.Text = string.Format("{0:d}", lOutPulse2);
int lCountPulse2 = ACServerManager.GetActualtPosition(store.Config.UpDown_Axis.DeviceName, store.Config.UpDown_Axis.GetAxisValue());
lblCountPulse2.Text = string.Format("{0:d}", lCountPulse2);
txtInoutTarget.Text = store.Config.InOut_Axis.TargetPosition.ToString();
if ( store.Config.UpDown_Axis.IsSameAxis(portName, SlvAddr))
{
lblOutPulse.Text = lblOutPulse2.Text;
lblCountPulse.Text = lblCountPulse2.Text;
}
}
if (ACServerManager.ServerOnStatus(store.Config.InOut_Axis.DeviceName, store.Config.InOut_Axis.GetAxisValue()))
{
axis_3_Alarm.IOValue = ACServerManager.GetAlarmStatus(store.Config.InOut_Axis.DeviceName, store.Config.InOut_Axis.GetAxisValue());
int lOutPulse3 = ACServerManager.GetTargetPosition(store.Config.InOut_Axis.DeviceName, store.Config.InOut_Axis.GetAxisValue());
lblOutPulse3.Text = string.Format("{0:d}", lOutPulse3);
int lCountPulse3 = ACServerManager.GetActualtPosition(store.Config.InOut_Axis.DeviceName, store.Config.InOut_Axis.GetAxisValue());
lblCountPulse3.Text = string.Format("{0:d}", lCountPulse3);
txtUpdownTarget.Text = store.Config.UpDown_Axis.TargetPosition.ToString();
if ( store.Config.InOut_Axis.IsSameAxis(portName, SlvAddr))
{
lblOutPulse.Text = lblOutPulse3.Text;
lblCountPulse.Text = lblCountPulse3.Text;
}
}
}
private void Bt_ClearCounter_Click(object sender, EventArgs e)
{
string portName = txtAxisDeviceName.Text;
short SlvAddr = FormUtil.GetShortValue(txtAxisValue);
//KTKSMCManager.WSetCountPulse(portName, SlvAddr, 0);
//KTKSMCManager.WSetOutPulse(portName, SlvAddr, 0);
}
private void FunctionFail(System.Int32 ReturnCode)
{
if (ReturnCode != 0)
{
MessageBox.Show("错误码:" + ReturnCode.ToString(), "", MessageBoxButtons.OK);
LogUtil.error(LOGGER, "错误码:" + ReturnCode.ToString());
}
}
private void FunctionFail(string funName, System.Int32 ReturnCode)
{
if (ReturnCode != 0)
{
MessageBox.Show("方法:" + funName + ",错误码:" + ReturnCode.ToString(), "", MessageBoxButtons.OK);
LogUtil.error(LOGGER, "方法:" + funName + ",错误码:" + ReturnCode.ToString());
}
}
private void FrmTest_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)//当用户点击窗体右上角X按钮或(Alt + F4)时 发生
......@@ -864,19 +761,19 @@ namespace OnlineStore.ACSingleStore
private void btnComP2_Click(object sender, EventArgs e)
{
int value = FormUtil.GetIntValue(txtComP2);
ShuoKeControls.AbsMove(store.Config.CompressAxis_Slv, value);
AxisABSMove(store.Config.Comp_Axis, value,store.Config.CompAxis_P2_Speed );
}
private void btnComP1_Click(object sender, EventArgs e)
{
int value = FormUtil.GetIntValue(txtComP1);
ShuoKeControls.AbsMove(store.Config.CompressAxis_Slv, value);
AxisABSMove(store.Config.Comp_Axis, value, store.Config.CompAxis_P1_Speed);
}
private void btnComP3_Click(object sender, EventArgs e)
{
int value = FormUtil.GetIntValue(txtComP3);
ShuoKeControls.AbsMove(store.Config.CompressAxis_Slv, value);
AxisABSMove(store.Config.Comp_Axis, value, store.Config.CompAxis_P3_Speed);
}
int xWidth = SystemInformation.PrimaryMonitorSize.Width;//获取显示器屏幕宽度
int yHeight = SystemInformation.PrimaryMonitorSize.Height;//高度
......@@ -1236,11 +1133,12 @@ namespace OnlineStore.ACSingleStore
{
stop_button_Click(null, null);
}
CodeManager.CloseCamera();
CodeManager.CloseAllCamera();
KNDManager.CloseAllDO();
StoreOpenStatus(false);
KNDManager.CloseAllConnection();
KNDAIManager.CloseAllConnection();
ACServerManager.CloseAllPort();
//WCFControl.CloseWCF();
System.Environment.Exit(System.Environment.ExitCode);
}
......@@ -1280,9 +1178,6 @@ namespace OnlineStore.ACSingleStore
ExitApp();
}
}
private void 学习二维码ToolStripMenuItem_Click(object sender, EventArgs e)
{
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
......@@ -1296,70 +1191,6 @@ namespace OnlineStore.ACSingleStore
int value = ACServerManager.GetHomeSingle(GetPortName(), GetSlaveAddr());
this.txtHomeSingle.Text = value.ToString();
}
private void btnOpen_Click(object sender, EventArgs e)
{
if (StoreManager.OpenShuoKe(store))
{
store.SetShuokeSpeed();
FormComStatus(true);
}
}
private void btnClose_Click(object sender, EventArgs e)
{
ShuoKeControls.ClosePort();
FormComStatus(false);
}
private void btnVolMove_Click(object sender, EventArgs e)
{
int speed = FormUtil.GetIntValue(txtSpeed);
ShuoKeControls.VolMove(store.Config.CompressAxis_Slv, speed);
}
private void btnGetPosition_Click(object sender, EventArgs e)
{
int value = ShuoKeControls.GetABSPosition(store.Config.CompressAxis_Slv);
lblShuoKeMsg.Text = DateTime.Now.ToLongTimeString() + "实时位置:" + value;
}
private void btnStop_Click(object sender, EventArgs e)
{
ShuoKeControls.SuddownStop(this.store.Config.CompressAxis_Slv);
}
private void btnClearPosition_Click(object sender, EventArgs e)
{
ShuoKeControls.PositionClear(this.store.Config.CompressAxis_Slv, ShuoKeCMD.AbsPositionClear);
ShuoKeControls.PositionClear(this.store.Config.CompressAxis_Slv, ShuoKeCMD.RelPositionClear);
}
private void btnHomeMove_Click(object sender, EventArgs e)
{
ShuoKeControls.HomeMove(this.store.Config.CompressAxis_Slv, byte.Parse(cmbHomeType.SelectedIndex.ToString()));
}
private void btnLineAbsMove_Click(object sender, EventArgs e)
{
int posi = FormUtil.GetIntValue(txtLinePosition);
ShuoKeControls.AbsMove(this.store.Config.CompressAxis_Slv, posi);
}
private void btnRelMove_Click(object sender, EventArgs e)
{
int posi = FormUtil.GetIntValue(txtLinePosition);
ShuoKeControls.RelativeMove(this.store.Config.CompressAxis_Slv, posi);
}
private void btnStatusSearch_Click(object sender, EventArgs e)
{
ShuoKeInfo info = ShuoKeControls.GetStatus(store.Config.CompressAxis_Slv);
lblShuoKeMsg.Text = info.ToShowStr();
}
private void FormComStatus(bool isOpen)
{
btnOpen.Enabled = !isOpen;
btnClose.Enabled = isOpen;
btnClearPosition.Enabled = isOpen;
btnVolMove.Enabled = isOpen;
btnGetPosition.Enabled = isOpen;
btnHomeMove.Enabled = isOpen;
btnLineAbsMove.Enabled = isOpen;
btnStatusSearch.Enabled = isOpen;
// Bt_ClearCounter.Enabled = isOpen;
}
private void groupBox2_Enter(object sender, EventArgs e)
{
......@@ -1420,25 +1251,106 @@ namespace OnlineStore.ACSingleStore
}
}
private void btnH_Click(object sender, EventArgs e)
//private void btnH_Click(object sender, EventArgs e)
//{
// string portName = txtAxisDeviceName.Text;
// short SlvAddr = FormUtil.GetShortValue(txtAxisValue);
// if (store.Config.InOut_Axis.IsSameAxis(portName, SlvAddr) && (store.InOutAxisCanMove().Equals(false)))
// {
// MessageBox.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
// }
// else if (store.Config.Middle_Axis.IsSameAxis(portName, SlvAddr) || store.Config.UpDown_Axis.IsSameAxis(portName, SlvAddr))
// {
// if (!InOutIsIsP1())
// {
// return;
// }
// }
// LogUtil.info("点击【正方向原点返回】,端口号【" + portName + "】地址【" + SlvAddr + "】 ");
// ACServerManager.ZhHomeMove(portName, SlvAddr);
//}
private void btnGetAlarm_Click_1(object sender, EventArgs e)
{
string portName = txtAxisDeviceName.Text;
string PortName = txtAxisDeviceName.Text;
short SlvAddr = FormUtil.GetShortValue(txtAxisValue);
if (store.Config.InOut_Axis.IsSameAxis(portName, SlvAddr) && (store.InOutAxisCanMove().Equals(false)))
txtServoStatue.Text = ACServerManager.ServerOnStatus(PortName, SlvAddr) ? "✔" : "✘";
this.txtAlarmStatus.Text = ACServerManager.GetAlarmStatus(PortName, SlvAddr).ToString();
this.txtBusyStatus.Text = ACServerManager.GetBusyStatus(PortName, SlvAddr).ToString();
this.txtHomeStatus.Text = ACServerManager.GetHomeEndStatus(PortName, SlvAddr).ToString();
this.txtHomeSingle.Text = ACServerManager.GetHomeSingle(PortName, SlvAddr).ToString();
this.txtLimit1.Text = ACServerManager.GetLimitPositiveSingle(PortName, SlvAddr).ToString();
this.txtLimit2.Text = ACServerManager.GetLimitNegativeSingle(PortName, SlvAddr).ToString();
}
private void button1_Click_2(object sender, EventArgs e)
{
MessageBox.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
string portName = txtAxisDeviceName.Text;
short slvAddr = FormUtil.GetShortValue(txtAxisValue);
LogUtil.info("点击【清理报警】,端口号【" + portName + "】地址【" + slvAddr + "】 ");
ACServerManager.AlarmClear(portName, slvAddr);
Thread.Sleep(100);
ACServerManager.ServoOn(portName, slvAddr);
}
else if (store.Config.Middle_Axis.IsSameAxis(portName, SlvAddr) || store.Config.UpDown_Axis.IsSameAxis(portName, SlvAddr))
private void btnReadPosition_Click_1(object sender, EventArgs e)
{
if (!InOutIsIsP1())
ReadPosistion();
}
private void ReadPosistion()
{
return;
string portName = GetPortName();
int SlvAddr = GetSlaveAddr();
//判断私服是否打开、
if (ACServerManager.ServerOnStatus(portName, SlvAddr))
{
txtServoStatue.Text = "✔";
}
else
{
txtServoStatue.Text = "✘";
}
ReadA(store.Config.Middle_Axis, lblActual1, lblTargetP1, txtMiddleTarget, axis_1_Alarm);
ReadA(store.Config.UpDown_Axis, lblActual2, lblTargetP2, txtUpdownTarget, axis_2_Alarm);
ReadA(store.Config.InOut_Axis, lblActual3, lblTargetP3, txtInoutTarget, axis_3_Alarm);
ReadA(store.Config.Comp_Axis, lblActual4, lblTargetP4, txt4Target, axis_4_Alarm);
}
private void ReadA(ConfigMoveAxis axis, TextBox lblActual, TextBox lblTarget, TextBox lblT, IOStatusControl sta)
{
string portName = GetPortName();
int SlvAddr = GetSlaveAddr();
if (ACServerManager.ServerOnStatus(axis.DeviceName, axis.GetAxisValue()))
{
sta.IOValue = ACServerManager.GetAlarmStatus(axis.DeviceName, axis.GetAxisValue());
int tP = ACServerManager.GetTargetPosition(axis.DeviceName, axis.GetAxisValue());
lblTarget.Text = string.Format("{0:d}", tP);
int aP = ACServerManager.GetActualtPosition(axis.DeviceName, axis.GetAxisValue());
lblActual.Text = string.Format("{0:d}", aP);
lblT.Text = axis.TargetPosition.ToString();
if (axis.IsSameAxis(portName, SlvAddr))
{
txtP.Text = lblActual.Text;
}
}
}
LogUtil.info("点击【正方向原点返回】,端口号【" + portName + "】地址【" + SlvAddr + "】 ");
ACServerManager.ZhHomeMove(portName, SlvAddr);
private void 升降轴位置调试ToolStripMenuItem_Click(object sender, EventArgs e)
{
string PortName = store.Config.UpDown_Axis.DeviceName;
int slvAddr = store.Config.UpDown_Axis.GetAxisValue();
string ioIP = "192.168.200.13";
int ioIndex = 0;
// if (store.Config.StoreDIList.ContainsKey(IO_Type.UpdownPositionSingal))
if (store.Config.StoreDIList.ContainsKey(IO_Type.TrayCheck_Fixture))
{
ioIP = store.Config.StoreDIList[IO_Type.TrayCheck_Fixture].DeviceName;
ioIndex = store.Config.StoreDIList[IO_Type.TrayCheck_Fixture].GetIOAddr();
}
FrmPositionTool frm = new FrmPositionTool(PortName, slvAddr, ioIP, ioIndex );
frm.ShowDialog();
}
}
}
......@@ -47,7 +47,7 @@ namespace OnlineStore.ACSingleStore.Properties {
}
/// <summary>
/// 使用此强类型资源类,为所有资源查找
/// 重写当前线程的 CurrentUICulture 属性
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
......
......@@ -12,7 +12,7 @@ namespace OnlineStore.ACSingleStore.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.6.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
......
namespace OnlineStore.ACSingleStore
{
partial class FrmPositionTool
{
/// <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.components = new System.ComponentModel.Container();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.txtP4Offset = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.txtP3Offset = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.txtP6Offset = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.txtP5Offset = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.btnOpenFolder = new System.Windows.Forms.Button();
this.btnGetActualPosition = new System.Windows.Forms.Button();
this.txtSpeed = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.txtFileName = new System.Windows.Forms.TextBox();
this.ioStatusControl1 = new UserFromControl.IOStatusControl();
this.btnAbsMove = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.txtPosition = new System.Windows.Forms.TextBox();
this.txtActualPosition = new System.Windows.Forms.TextBox();
this.label13 = new System.Windows.Forms.Label();
this.btnSdStop = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.txtTargetPosition = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label12 = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.txtAddr = new System.Windows.Forms.TextBox();
this.btnHomeMove = new System.Windows.Forms.Button();
this.btnServoOn = new System.Windows.Forms.Button();
this.txtPortName = new System.Windows.Forms.TextBox();
this.btnServoOff = new System.Windows.Forms.Button();
this.txtIOIndex = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtIoIp = new System.Windows.Forms.TextBox();
this.btnExit = new System.Windows.Forms.Button();
this.btnClear = new System.Windows.Forms.Button();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.groupBox6.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox6
//
this.groupBox6.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.groupBox6.Controls.Add(this.groupBox2);
this.groupBox6.Controls.Add(this.groupBox1);
this.groupBox6.Controls.Add(this.btnExit);
this.groupBox6.Controls.Add(this.btnClear);
this.groupBox6.Controls.Add(this.richTextBox1);
this.groupBox6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox6.Location = new System.Drawing.Point(6, 5);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(1008, 707);
this.groupBox6.TabIndex = 250;
this.groupBox6.TabStop = false;
//
// groupBox2
//
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox2.Controls.Add(this.txtP4Offset);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.txtP3Offset);
this.groupBox2.Controls.Add(this.label9);
this.groupBox2.Controls.Add(this.txtP6Offset);
this.groupBox2.Controls.Add(this.label5);
this.groupBox2.Controls.Add(this.txtP5Offset);
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.btnOpenFolder);
this.groupBox2.Controls.Add(this.btnGetActualPosition);
this.groupBox2.Controls.Add(this.txtSpeed);
this.groupBox2.Controls.Add(this.label8);
this.groupBox2.Controls.Add(this.txtFileName);
this.groupBox2.Controls.Add(this.ioStatusControl1);
this.groupBox2.Controls.Add(this.btnAbsMove);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.txtPosition);
this.groupBox2.Controls.Add(this.txtActualPosition);
this.groupBox2.Controls.Add(this.label13);
this.groupBox2.Controls.Add(this.btnSdStop);
this.groupBox2.Controls.Add(this.label6);
this.groupBox2.Controls.Add(this.txtTargetPosition);
this.groupBox2.Location = new System.Drawing.Point(9, 192);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(458, 504);
this.groupBox2.TabIndex = 283;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "位置信息";
//
// txtP4Offset
//
this.txtP4Offset.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtP4Offset.Location = new System.Drawing.Point(184, 174);
this.txtP4Offset.MaxLength = 30;
this.txtP4Offset.Name = "txtP4Offset";
this.txtP4Offset.Size = new System.Drawing.Size(121, 26);
this.txtP4Offset.TabIndex = 287;
this.txtP4Offset.Text = "-6000";
//
// label10
//
this.label10.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label10.Location = new System.Drawing.Point(6, 177);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(173, 20);
this.label10.TabIndex = 288;
this.label10.Text = "入料缓冲点P4偏移量:";
this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtP3Offset
//
this.txtP3Offset.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtP3Offset.Location = new System.Drawing.Point(184, 142);
this.txtP3Offset.MaxLength = 30;
this.txtP3Offset.Name = "txtP3Offset";
this.txtP3Offset.Size = new System.Drawing.Size(121, 26);
this.txtP3Offset.TabIndex = 285;
this.txtP3Offset.Text = "6000";
//
// label9
//
this.label9.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label9.Location = new System.Drawing.Point(6, 145);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(173, 20);
this.label9.TabIndex = 286;
this.label9.Text = "入料前点P3偏移量:";
this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtP6Offset
//
this.txtP6Offset.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtP6Offset.Location = new System.Drawing.Point(184, 110);
this.txtP6Offset.MaxLength = 30;
this.txtP6Offset.Name = "txtP6Offset";
this.txtP6Offset.Size = new System.Drawing.Size(121, 26);
this.txtP6Offset.TabIndex = 283;
this.txtP6Offset.Text = "6000";
//
// label5
//
this.label5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label5.Location = new System.Drawing.Point(6, 113);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(173, 20);
this.label5.TabIndex = 284;
this.label5.Text = "出料缓冲点P6偏移量:";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtP5Offset
//
this.txtP5Offset.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtP5Offset.Location = new System.Drawing.Point(184, 78);
this.txtP5Offset.MaxLength = 30;
this.txtP5Offset.Name = "txtP5Offset";
this.txtP5Offset.Size = new System.Drawing.Size(121, 26);
this.txtP5Offset.TabIndex = 281;
this.txtP5Offset.Text = "-6000";
//
// label4
//
this.label4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label4.Location = new System.Drawing.Point(6, 81);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(173, 20);
this.label4.TabIndex = 282;
this.label4.Text = "出料前点P5偏移值:";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btnOpenFolder
//
this.btnOpenFolder.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOpenFolder.Location = new System.Drawing.Point(312, 22);
this.btnOpenFolder.Name = "btnOpenFolder";
this.btnOpenFolder.Size = new System.Drawing.Size(132, 36);
this.btnOpenFolder.TabIndex = 280;
this.btnOpenFolder.Text = "打开文件夹";
this.btnOpenFolder.UseVisualStyleBackColor = true;
this.btnOpenFolder.Click += new System.EventHandler(this.btnOpenFolder_Click);
//
// btnGetActualPosition
//
this.btnGetActualPosition.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnGetActualPosition.Location = new System.Drawing.Point(312, 342);
this.btnGetActualPosition.Name = "btnGetActualPosition";
this.btnGetActualPosition.Size = new System.Drawing.Size(132, 36);
this.btnGetActualPosition.TabIndex = 269;
this.btnGetActualPosition.Text = "读取位置";
this.btnGetActualPosition.UseVisualStyleBackColor = true;
this.btnGetActualPosition.Click += new System.EventHandler(this.btnGetActualPosition_Click);
//
// txtSpeed
//
this.txtSpeed.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtSpeed.Location = new System.Drawing.Point(184, 227);
this.txtSpeed.MaxLength = 30;
this.txtSpeed.Name = "txtSpeed";
this.txtSpeed.Size = new System.Drawing.Size(121, 26);
this.txtSpeed.TabIndex = 83;
this.txtSpeed.Text = "20";
//
// label8
//
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(6, 230);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(173, 20);
this.label8.TabIndex = 84;
this.label8.Text = "移动速度:";
this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtFileName
//
this.txtFileName.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtFileName.Location = new System.Drawing.Point(141, 27);
this.txtFileName.MaxLength = 30;
this.txtFileName.Name = "txtFileName";
this.txtFileName.Size = new System.Drawing.Size(164, 26);
this.txtFileName.TabIndex = 278;
this.txtFileName.Text = "position.csv";
//
// ioStatusControl1
//
this.ioStatusControl1.IOName = "检测信号";
this.ioStatusControl1.IOValue = 0;
this.ioStatusControl1.isCanClick = false;
this.ioStatusControl1.Location = new System.Drawing.Point(38, 401);
this.ioStatusControl1.Name = "ioStatusControl1";
this.ioStatusControl1.Size = new System.Drawing.Size(267, 69);
this.ioStatusControl1.TabIndex = 279;
//
// btnAbsMove
//
this.btnAbsMove.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAbsMove.Location = new System.Drawing.Point(312, 222);
this.btnAbsMove.Name = "btnAbsMove";
this.btnAbsMove.Size = new System.Drawing.Size(132, 36);
this.btnAbsMove.TabIndex = 88;
this.btnAbsMove.Text = "开始运动";
this.btnAbsMove.UseVisualStyleBackColor = true;
this.btnAbsMove.Click += new System.EventHandler(this.btnAbsMove_Click);
//
// label3
//
this.label3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.Location = new System.Drawing.Point(13, 30);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(122, 20);
this.label3.TabIndex = 277;
this.label3.Text = "保存文件名称:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label7
//
this.label7.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label7.Location = new System.Drawing.Point(6, 355);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(173, 20);
this.label7.TabIndex = 271;
this.label7.Text = "实际位置:";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtPosition
//
this.txtPosition.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtPosition.Location = new System.Drawing.Point(184, 265);
this.txtPosition.MaxLength = 30;
this.txtPosition.Name = "txtPosition";
this.txtPosition.Size = new System.Drawing.Size(121, 26);
this.txtPosition.TabIndex = 89;
this.txtPosition.Text = "5000";
//
// txtActualPosition
//
this.txtActualPosition.Enabled = false;
this.txtActualPosition.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtActualPosition.Location = new System.Drawing.Point(184, 352);
this.txtActualPosition.MaxLength = 30;
this.txtActualPosition.Name = "txtActualPosition";
this.txtActualPosition.Size = new System.Drawing.Size(121, 26);
this.txtActualPosition.TabIndex = 270;
//
// label13
//
this.label13.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label13.Location = new System.Drawing.Point(6, 268);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(173, 20);
this.label13.TabIndex = 90;
this.label13.Text = "目标位置:";
this.label13.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btnSdStop
//
this.btnSdStop.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSdStop.Location = new System.Drawing.Point(312, 260);
this.btnSdStop.Name = "btnSdStop";
this.btnSdStop.Size = new System.Drawing.Size(132, 36);
this.btnSdStop.TabIndex = 257;
this.btnSdStop.Text = "停止";
this.btnSdStop.UseVisualStyleBackColor = true;
this.btnSdStop.Click += new System.EventHandler(this.btnSdStop_Click);
//
// label6
//
this.label6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label6.Location = new System.Drawing.Point(6, 321);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(173, 20);
this.label6.TabIndex = 268;
this.label6.Text = "目标位置:";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtTargetPosition
//
this.txtTargetPosition.Enabled = false;
this.txtTargetPosition.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtTargetPosition.Location = new System.Drawing.Point(184, 318);
this.txtTargetPosition.MaxLength = 30;
this.txtTargetPosition.Name = "txtTargetPosition";
this.txtTargetPosition.Size = new System.Drawing.Size(121, 26);
this.txtTargetPosition.TabIndex = 267;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label12);
this.groupBox1.Controls.Add(this.label18);
this.groupBox1.Controls.Add(this.txtAddr);
this.groupBox1.Controls.Add(this.btnHomeMove);
this.groupBox1.Controls.Add(this.btnServoOn);
this.groupBox1.Controls.Add(this.txtPortName);
this.groupBox1.Controls.Add(this.btnServoOff);
this.groupBox1.Controls.Add(this.txtIOIndex);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.txtIoIp);
this.groupBox1.Location = new System.Drawing.Point(9, 13);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(458, 173);
this.groupBox1.TabIndex = 282;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "设备信息";
//
// label12
//
this.label12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label12.Location = new System.Drawing.Point(8, 28);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(122, 20);
this.label12.TabIndex = 1;
this.label12.Text = "端口号:";
this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label18
//
this.label18.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label18.Location = new System.Drawing.Point(8, 64);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(122, 20);
this.label18.TabIndex = 94;
this.label18.Text = "地址:";
this.label18.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtAddr
//
this.txtAddr.Enabled = false;
this.txtAddr.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtAddr.Location = new System.Drawing.Point(136, 61);
this.txtAddr.MaxLength = 30;
this.txtAddr.Name = "txtAddr";
this.txtAddr.Size = new System.Drawing.Size(164, 26);
this.txtAddr.TabIndex = 95;
this.txtAddr.Text = "1";
//
// btnHomeMove
//
this.btnHomeMove.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnHomeMove.Location = new System.Drawing.Point(307, 113);
this.btnHomeMove.Name = "btnHomeMove";
this.btnHomeMove.Size = new System.Drawing.Size(132, 36);
this.btnHomeMove.TabIndex = 110;
this.btnHomeMove.Text = "原点返回";
this.btnHomeMove.UseVisualStyleBackColor = true;
this.btnHomeMove.Click += new System.EventHandler(this.btnHomeMove_Click);
//
// btnServoOn
//
this.btnServoOn.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnServoOn.Location = new System.Drawing.Point(307, 25);
this.btnServoOn.Name = "btnServoOn";
this.btnServoOn.Size = new System.Drawing.Size(132, 36);
this.btnServoOn.TabIndex = 258;
this.btnServoOn.Text = "打开伺服";
this.btnServoOn.UseVisualStyleBackColor = true;
this.btnServoOn.Click += new System.EventHandler(this.btnServoOn_Click);
//
// txtPortName
//
this.txtPortName.Enabled = false;
this.txtPortName.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtPortName.Location = new System.Drawing.Point(136, 25);
this.txtPortName.MaxLength = 30;
this.txtPortName.Name = "txtPortName";
this.txtPortName.Size = new System.Drawing.Size(164, 26);
this.txtPortName.TabIndex = 276;
this.txtPortName.Text = "COM1";
//
// btnServoOff
//
this.btnServoOff.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnServoOff.Location = new System.Drawing.Point(307, 64);
this.btnServoOff.Name = "btnServoOff";
this.btnServoOff.Size = new System.Drawing.Size(132, 36);
this.btnServoOff.TabIndex = 259;
this.btnServoOff.Text = "关闭伺服";
this.btnServoOff.UseVisualStyleBackColor = true;
this.btnServoOff.Click += new System.EventHandler(this.btnServoOff_Click);
//
// txtIOIndex
//
this.txtIOIndex.Enabled = false;
this.txtIOIndex.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtIOIndex.Location = new System.Drawing.Point(136, 133);
this.txtIOIndex.MaxLength = 30;
this.txtIOIndex.Name = "txtIOIndex";
this.txtIOIndex.Size = new System.Drawing.Size(164, 26);
this.txtIOIndex.TabIndex = 275;
this.txtIOIndex.Text = "1";
//
// label1
//
this.label1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(8, 100);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(122, 20);
this.label1.TabIndex = 272;
this.label1.Text = "IO模块IP:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label2
//
this.label2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(8, 136);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(122, 20);
this.label2.TabIndex = 274;
this.label2.Text = "检测信号地址:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtIoIp
//
this.txtIoIp.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtIoIp.Location = new System.Drawing.Point(136, 97);
this.txtIoIp.MaxLength = 30;
this.txtIoIp.Name = "txtIoIp";
this.txtIoIp.Size = new System.Drawing.Size(164, 26);
this.txtIoIp.TabIndex = 273;
this.txtIoIp.Text = "192.168.201.11";
//
// btnExit
//
this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnExit.Location = new System.Drawing.Point(838, 665);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(132, 36);
this.btnExit.TabIndex = 281;
this.btnExit.Text = "退出";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// btnClear
//
this.btnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnClear.Location = new System.Drawing.Point(691, 665);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(132, 36);
this.btnClear.TabIndex = 106;
this.btnClear.Text = "清理";
this.btnClear.UseVisualStyleBackColor = true;
this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
//
// richTextBox1
//
this.richTextBox1.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.richTextBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.richTextBox1.Location = new System.Drawing.Point(473, 20);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(526, 642);
this.richTextBox1.TabIndex = 105;
this.richTextBox1.Text = "";
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// FrmPositionTool
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(1020, 719);
this.Controls.Add(this.groupBox6);
this.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Name = "FrmPositionTool";
this.Text = "升降轴位置测试";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmPositionTool_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox6.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.TextBox txtAddr;
private System.Windows.Forms.Label label18;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.TextBox txtPosition;
private System.Windows.Forms.Button btnAbsMove;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox txtSpeed;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.Button btnClear;
private System.Windows.Forms.Button btnHomeMove;
private System.Windows.Forms.Button btnSdStop;
private System.Windows.Forms.Button btnServoOff;
private System.Windows.Forms.Button btnServoOn;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txtTargetPosition;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox txtActualPosition;
private System.Windows.Forms.Button btnGetActualPosition;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.TextBox txtIOIndex;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtIoIp;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtPortName;
private System.Windows.Forms.TextBox txtFileName;
private System.Windows.Forms.Label label3;
private UserFromControl.IOStatusControl ioStatusControl1;
private System.Windows.Forms.Button btnOpenFolder;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TextBox txtP4Offset;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox txtP3Offset;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txtP6Offset;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtP5Offset;
private System.Windows.Forms.Label label4;
}
}

using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.ACSingleStore
{
public partial class FrmPositionTool : FrmBase
{
private string LogName = ResourceCulture.GetString("升降轴位置调试:");
private string PortName = "";
private int SlvAddr = 0;
private string IoIp = "";
private int IoIndex = 0;
public string Axis_Brake = IO_Type.Axis_Brake;
private System.Timers.Timer toolTimer = new System.Timers.Timer();
public FrmPositionTool(string protName, int slvAddr,string ioIp, int ioIndex)
{
InitializeComponent();
this.PortName = protName;
this.SlvAddr = slvAddr;
this.IoIp = ioIp;
this.IoIndex = ioIndex;
toolTimer.Enabled = false;
toolTimer.Interval = 50;
toolTimer.AutoReset = true;
toolTimer.Elapsed += ToolTimer_Elapsed;
FrmPositionTool.CheckForIllegalCrossThreadCalls = false;
}
private void Form1_Load(object sender, EventArgs e)
{
ACServerManager.IsShowMsg = false;
LogUtil.logBox = this.richTextBox1;
//ACServerManager.richeBox = this.richTextBox1;
CheckForIllegalCrossThreadCalls = false;
txtPortName.Text = PortName;
txtAddr.Text = SlvAddr.ToString();
txtIOIndex.Text = IoIndex.ToString();
txtIoIp.Text = IoIp.ToString();
//if (KNDManager.instance == null)
//{
// IOManager.Init();
// IOManager.instance.ConnectionIOList(new List<string> { /*IoIp*/ });
//}
P3Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P3_Offset);
P4Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P4_Offset);
P5Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P5_Offset);
P6Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P6_Offset);
int tSpeed = ConfigAppSettings.GetIntValue(Setting_Init.Tool_TargetSpeed);
int tPosition = ConfigAppSettings.GetIntValue(Setting_Init.Tool_TargetPosition);
if (P3Offset.Equals(0)) P3Offset = 6000;
if (P4Offset.Equals(0)) P4Offset = -6000;
if (P5Offset.Equals(0)) P5Offset = -6000;
if (P6Offset.Equals(0)) P6Offset = 6000;
if (tSpeed.Equals(0)) tSpeed = 20;
if (tPosition.Equals(0)) tPosition = 6000;
txtP3Offset.Text = P3Offset.ToString();
txtP4Offset.Text = P4Offset.ToString();
txtP5Offset.Text = P5Offset.ToString();
txtP6Offset.Text = P6Offset.ToString();
txtSpeed.Text = tSpeed.ToString();
txtPosition.Text = tPosition.ToString();
SaveConfig(tSpeed, tPosition);
//判断伺服是否已经打开
bool isOn = ACServerManager.ServerOnStatus(PortName, SlvAddr);
formStatus(isOn);
timer1.Start();
ioStatusControl1.IOName = ResourceCulture.GetString("检测信号");
}
private void btnServoOn_Click(object sender, EventArgs e)
{
this.PortName = txtPortName.Text;
this.SlvAddr = FormUtil.GetIntValue(txtAddr);
bool result = ACServerManager.OpenPort(PortName);
if (!result)
{
MessageBox.Show(ResourceCulture.GetString("打开串口失败"));
return;
}
formStatus(true);
ACServerManager.InitSlvAddr(PortName, SlvAddr);
Thread.Sleep(100);
ACServerManager.AlarmClear(PortName, SlvAddr);
ACServerManager.ServoOn(PortName, SlvAddr);
try
{
StoreManager.Store.KNDIOMove(Axis_Brake, IO_VALUE.HIGH);
}catch(Exception ex)
{
}
}
private void btnServoOff_Click(object sender, EventArgs e)
{
StopTimer();
// toolTimer.Stop();
ACServerManager.SuddenStop(PortName, SlvAddr);
Thread.Sleep(100);
try
{
StoreManager.Store.KNDIOMove(Axis_Brake, IO_VALUE.LOW);
}
catch (Exception ex)
{
}
ACServerManager.ServoOff(PortName, SlvAddr);
formStatus(false);
}
private void formStatus(bool p)
{
txtPortName.Enabled = !p;
txtAddr.Enabled = !p;
txtIOIndex.Enabled = !p;
// txtIoIp.Enabled = !p;
btnAbsMove.Enabled = p;
btnSdStop.Enabled = p;
btnHomeMove.Enabled = p;
timer1.Enabled = p;
btnServoOff.Enabled = p;
btnServoOn.Enabled = !p;
btnGetActualPosition.Enabled = p;
}
private void btnClear_Click(object sender, EventArgs e)
{
this.richTextBox1.Text = "";
}
private void btnRelMove_Click(object sender, EventArgs e)
{
int position = Convert.ToInt32(txtPosition.Text);
ACServerManager.RelMove(PortName, SlvAddr, position);
}
private void btnHomeMove_Click(object sender, EventArgs e)
{
int speed = Convert.ToInt32(txtSpeed.Text);
ACServerManager.HomeMove(PortName, SlvAddr, speed);
}
private void btnSpeedMove_Click(object sender, EventArgs e)
{
int speed = Convert.ToInt32(txtSpeed.Text);
ACServerManager.SpeedMove(PortName, SlvAddr, speed);
}
private void btnGetActualPosition_Click(object sender, EventArgs e)
{
int value = ACServerManager.GetTargetPosition(PortName, SlvAddr);
txtTargetPosition.Text = value.ToString();
value = ACServerManager.GetActualtPosition(PortName, SlvAddr);
txtActualPosition.Text = value.ToString();
}
private void SaveConfig(int speed,int position)
{
//保存配置
ConfigAppSettings.SaveValue(Setting_Init.Tool_P3_Offset, P3Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_P4_Offset, P4Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_P5_Offset, P5Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_P6_Offset, P6Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_TargetSpeed, speed);
ConfigAppSettings.SaveValue(Setting_Init.Tool_TargetPosition, position);
}
private void btnAbsMove_Click(object sender, EventArgs e)
{
int speed = Convert.ToInt32(txtSpeed.Text);
int position = Convert.ToInt32(txtPosition.Text.Trim(), 10);
TargetPostion = position;
if (speed <= (0))
{
MessageBox.Show(ResourceCulture.GetString("请输入正确的速度"));
txtSpeed.Focus();
return;
}
P3Offset = FormUtil.GetIntValue(txtP3Offset);
P4Offset = FormUtil.GetIntValue(txtP4Offset);
P5Offset = FormUtil.GetIntValue(txtP5Offset);
P6Offset = FormUtil.GetIntValue(txtP6Offset);
SaveConfig(speed, position);
LastValue = IO_VALUE.LOW;
string fileName = txtFileName.Text;
string filePath = Application.StartupPath + @"\logs\" + fileName;
if (File.Exists(filePath))
{
string msg = "文件【" + fileName + "】已存在,是否确定覆盖?";
DialogResult result = MessageBox.Show(msg, "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (!result.Equals(DialogResult.OK))
{
return;
}
}
PositionList = new List<int>();
LogUtil.info(LogName + "伺服开始运动,速度【" + speed + "】位置【" + position + "】启动定时器 ");
formMoveStatus(false);
ACServerManager.AbsMove(PortName, SlvAddr, position, speed);
toolTimer.Start();
}
private int P3Offset = 0;
private int P4Offset = 0;
private int P5Offset = 0;
private int P6Offset = 0;
private void formMoveStatus(bool status)
{
txtFileName.Enabled = status;
txtP5Offset.Enabled = status;
txtP3Offset.Enabled = status;
txtP4Offset.Enabled = status;
txtP6Offset.Enabled = status;
txtSpeed.Enabled = status;
txtPosition.Enabled = status;
}
private void btnSdStop_Click(object sender, EventArgs e)
{
toolTimer.Stop();
ACServerManager.SuddenStop(PortName, SlvAddr);
}
private IO_VALUE GetSingleValue()
{
return KNDManager.GetDIValue(IoIp, 0, (ushort)IoIndex);
}
private int TargetPostion = 0;
private bool isInProcesss = false;
private DateTime LastTime = DateTime.Now;
private List<int> PositionList = new List<int>();
private IO_VALUE LastValue = IO_VALUE.LOW;
private DateTime LastGetPTime = DateTime.Now;
private void ToolTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
TimeSpan span = DateTime.Now - LastTime;
if (isInProcesss && span.TotalSeconds < 1)
{
return;
}
isInProcesss = true;
try
{
int moveS = ACServerManager.GetBusyStatus(PortName, SlvAddr);
if (moveS.Equals(1))
{
IO_VALUE currValue = GetSingleValue();
TimeSpan checkSpan = DateTime.Now - LastGetPTime;
if (LastValue.Equals(IO_VALUE.LOW) && currValue.Equals(IO_VALUE.HIGH)&&checkSpan.TotalSeconds>2)
{
int currPos = ACServerManager.GetActualtPosition(PortName, SlvAddr);
txtActualPosition.Text = currPos.ToString();
PositionList.Add(currPos);
int num = PositionList.Count;
int preValue = 0;
if (PositionList.Count > 1)
{
preValue = PositionList[num - 2];
}
LogUtil.info(LogName + "【"+ num + "】【" + currPos+"】【"+Math.Abs(currPos-preValue)+"】");
if (LogUtil.logBox == null)
{
this.richTextBox1.AppendText(LogName + "【" + num + "】【" + currPos + "】【" + Math.Abs(currPos - preValue) + "】"+Environment.NewLine);
}
LastValue = IO_VALUE.HIGH;
LastGetPTime = DateTime.Now;
}
LastValue = currValue;
}
else
{
StopTimer();
}
}catch(Exception ex)
{
LogUtil.error(LogName+"ToolTimer_Elapsed" + ex.ToString());
}
isInProcesss = false;
}
private void StopTimer()
{
toolTimer.Stop();
if (PositionList.Count <= 0)
{
return;
}
LogUtil.info(LogName + "伺服已停止运动,停止定时器,记录数据");
List<string> strList = new List<string>();
strList.Add("编号,标准位置,升降轴库位出料前点P5,升降轴库位出料缓冲点P6,升降轴库位入料前点P3,升降轴库位入料缓冲点P4");
int index = 1;
foreach (int p in PositionList)
{
int P3 = p + P3Offset;
int P4 = p + P4Offset;
int P5 = p + P5Offset;
int P6 = p + P6Offset;
string resultstr = index + "," + p + ","+P5+","+P6+","+P3+","+P4+"";
strList.Add(resultstr);
index++;
}
string fileName = txtFileName.Text;
string filePath = Application.StartupPath + @"\logs\" + fileName;
try
{
// Clipboard.SetDataObject(resultstr);
File.WriteAllLines(filePath, strList.ToArray());
LogUtil.error(LogName + "保存位置到文件【" + filePath + "】成功");
}
catch (Exception ex)
{
LogUtil.error(LogName + "保存位置到文件【" + filePath + "】出错:" + ex.ToString());
}
formMoveStatus(true );
}
private void timer1_Tick(object sender, EventArgs e)
{
try
{
ioStatusControl1.IOValue = (int)GetSingleValue();
ioStatusControl1.ShowData();
}
catch (Exception ex)
{
}
}
private void FrmPositionTool_FormClosing(object sender, FormClosingEventArgs e)
{
timer1.Stop();
if (btnServoOff.Enabled)
{
StopTimer();
// toolTimer.Stop();
ACServerManager.SuddenStop(PortName, SlvAddr);
Thread.Sleep(100);
}
LogUtil.logBox = null;
//ACServerManager.CloseAllPort();
//IOManager.instance.CloseAllConnection();
}
private void btnOpenFolder_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("Explorer.exe", Application.StartupPath + @"\logs\");
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
public class ResourceCulture
{
internal static string GetString(string str)
{
return str;
}
}
}
<?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
......@@ -87,3 +87,53 @@ bug修改:压紧轴点动时实时坐标更新。
增加压紧轴复位的配置。
StoreConfig.csv增加:
PRO,出入库多少次自动复位压紧轴,Box_ResetCCount,3,,,,,,,
20191210修改:
压紧轴改为伺服控制:
1.以前的三个轴波特率为9600,压紧轴的波特率需要一致.
2.所有压紧轴相关的位置都要重新配置,压紧轴回原点是向上的,位置都是正整数。
配置修改:
StoreConfig.csv删除原来的步进电机配置:
PRO,硕科步进电机(压紧轴)控制端口号,CompressAxis_PortName,COM3,,,,,,,
PRO,硕科步进电机(压紧轴)控制波特率,CompressAxis_PortBaudrate,9600,,,,,,,
PRO,硕科步进电机(压紧轴)控制奇偶校验,CompressAxis_PortParity,0,,,,,,,
PRO,硕科步进电机(压紧轴)控制停止位,CompressAxis_StopBits,1,,,,,,,
PRO,硕科步进电机(压紧轴)控制初速度,CompressAxis_StartSpeed,5000,,,,,,,
PRO,硕科步进电机(压紧轴)控制最大速度,CompressAxis_MaxSpeed,8000,,,,,,,
PRO,硕科步进电机(压紧轴)控制末速度,CompressAxis_EndSpeed,6000,,,,,,,
PRO,硕科步进电机(压紧轴)控制加速度,CompressAxis_AddSpeed,3000,,,,,,,
PRO,硕科步进电机(压紧轴)控制减速度,CompressAxis_DelSpeed,3000,,,,,,,
PRO,硕科步进电机(压紧轴)控制归零速度(原点返回速度),CompressAxis_HomeSpeed,5000,,,,,,,
PRO,硕科步进电机轴地址(压紧轴),CompressAxis_Slv,1,,,,,,,
增加压紧轴配置:
,,,,,,,,, ,
AXIS,(轴四)压紧轴,Comp_Axis,4,COM1,0,,,,,
PRO,(轴四)压紧轴目标速度,CompAxis_TargetSpeed,100,,,,,,,
PRO,(轴四)压紧轴加速度,CompAxis_AddSpeed,300,,,,,,,
PRO,(轴四)压紧轴减速度,CompAxis_DelSpeed,300,,,,,,,
PRO,(轴四)压紧轴原点低速,CompAxis_HomeLowSpeed,20,,,,,,,
PRO,(轴四)压紧轴原点高速,CompAxis_HomeHighSpeed,60,,,,,,,
PRO,(轴四)压紧轴原点加速度,CompAxis_HomeAddSpeed,200,,,,,,,
PRO,压紧轴(轴4)P1速度,CompAxis_P1_Speed,100,,,,,,,
PRO,压紧轴(轴4)P2速度,CompAxis_P2_Speed,100,,,,,,,
PRO,压紧轴(轴4)P3速度,CompAxis_P3_Speed,100,,,,,,,
,,,,,,,
20200301
增加升降轴调试功能
20200305
进出轴回待机点时,原点信号必须亮。
20200311
扫码更新为最新版本。
......@@ -79,5 +79,15 @@ namespace OnlineStore.Common
/// 压紧轴1mm对应的脉冲
/// </summary>
public static string ComAxisChangeValue = "ComAxisChangeValue";
public static string ACBaudRate = "ACBaudRate";
public static string Tool_P3_Offset = "Tool_P3_Offset";
public static string Tool_P4_Offset = "Tool_P4_Offset";
public static string Tool_P5_Offset = "Tool_P5_Offset";
public static string Tool_P6_Offset = "Tool_P6_Offset";
public static string Tool_TargetSpeed = "Tool_TargetSpeed";
public static string Tool_TargetPosition = "Tool_TargetPosition";
}
}
......@@ -282,13 +282,13 @@ namespace OnlineStore.Common
/// <param name="ReceiveData">接收数据</param>
/// <param name="Overtime">超时时间</param>
/// <returns></returns>
public int SendCommand(byte[] SendData, ref byte[] ReceiveData, int Overtime,out bool isOk)
public int SendCommand(byte[] SendData, ref byte[] ReceiveData, int Overtime, out bool isOk)
{
isOk = false;
if (_serialPort.IsOpen)
{
//lock (lockObj)
if(Monitor.TryEnter(lockObj,10))
if (Monitor.TryEnter(lockObj, Overtime + 50))
{
//Monitor.Enter(lockObj);
try
......@@ -339,7 +339,7 @@ namespace OnlineStore.Common
return -1;
}
private byte PreSlvAddr = 0;
/// <summary>
/// 发送命令
/// </summary>
......@@ -352,17 +352,28 @@ namespace OnlineStore.Common
{
if (_serialPort == null)
{
LogUtil.error(PortName+" 发送数据"+ByteToString(SendData)+ "失败,_serialPort=null");
LogUtil.error(PortName + " 发送数据" + ByteToString(SendData) + "失败,_serialPort=null");
return -1;
}
if (_serialPort.IsOpen)
{
if (Monitor.TryEnter(lockObj, 1))
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;
......@@ -395,7 +406,7 @@ namespace OnlineStore.Common
}
catch (Exception ex)
{
LogUtil.error(PortName + " 发送数据" + ByteToString(SendData) + " 出错:"+ex.ToString());
LogUtil.error(PortName + " 发送数据" + ByteToString(SendData) + " 出错:" + ex.ToString());
}
finally
{
......
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.DeviceLibrary</RootNamespace>
<AssemblyName>DeviceLibrary</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
......@@ -67,8 +67,6 @@
<Compile Include="PanasonicServo\ACCMDManager.cs" />
<Compile Include="PanasonicServo\ACServerManager.cs" />
<Compile Include="PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="ShuoKe\MeteringSignalBean.cs" />
<Compile Include="ShuoKe\ShuoKeController.cs" />
<Compile Include="store\LineMoveP.cs" />
<Compile Include="store\LineAlarm.cs">
<SubType>Code</SubType>
......
......@@ -128,6 +128,11 @@ namespace OnlineStore.DeviceLibrary
try
{
isProcess = true;
if (StoreManager.Store == null)
{
isProcess = false;
return;
}
bool IsNeedReadAI = StoreManager.Store.KNDIOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.HIGH);
IsNeedReadAI = (IsNeedReadAI || NeedReadAI);
TimeSpan span = DateTime.Now - PreCheckTime;
......
......@@ -21,24 +21,17 @@ namespace OnlineStore.DeviceLibrary
public static ushort DoStartAddress = 100;
public static ushort DefualtLength = 16;
private static byte DefualtSlaveID = 255;
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static Dictionary<string, MasterTcpClient> mastMap = new Dictionary<string, MasterTcpClient>();
public static Dictionary<string, List<KNDIO>> DIValueMap = new Dictionary<string, List<KNDIO>>();
public static Dictionary<string, List<KNDIO>> DOValueMap = new Dictionary<string, List<KNDIO>>();
private static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static Dictionary<string, MasterTcpClient> mastMap = new Dictionary<string, MasterTcpClient>();
private static Dictionary<string, List<KNDIO>> DIValueMap = new Dictionary<string, List<KNDIO>>();
private static Dictionary<string, List<KNDIO>> DOValueMap = new Dictionary<string, List<KNDIO>>();
private static object DIMapLock = "";
private static object DOMapLock = "";
public static System.Timers.Timer timer = null;
private static System.Timers.Timer timer = null;
private static bool isWrite=false;
public static void ConnectionIP(string ioIp, ushort port)
private static void ConnectionIP(string ioIp, ushort port)
{
if (timer == null)
{
timer = new System.Timers.Timer();
timer.Interval = 300;
timer.AutoReset = true;
timer.Elapsed += timer_Elapsed;
timer.Enabled = true;
}
MasterTcpClient MBmaster = null;
if (mastMap.ContainsKey(ioIp))
{
......@@ -77,13 +70,19 @@ namespace OnlineStore.DeviceLibrary
mastMap.Add(ioIp, MBmaster);
Thread.Sleep(10);
if (MBmaster.connected)
{
LogUtil.info("连接IO模块[" + ioIp + "]成功");
//读取所有的DO
ReadMultipleDO(ioIp, DefualtSlaveID, DoStartAddress, DefualtLength);
MBmaster.ReadCoils(1, DoStartAddress, DefualtLength, DefualtSlaveID);
}
else
{
LogUtil.info("连接IO模块[" + ioIp + "]失败,等待重连");
}
}
catch (Exception error)
{
LogUtil.error(LOGGER,"连接IO模块[" + ioIp + "]出错:"+error.ToString());
LogUtil.error(LOGGER, "连接IO模块[" + ioIp + "]出错:" + error.ToString());
}
}
/// <summary>
......@@ -130,7 +129,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "出错啦:"+ex.ToString());
LogUtil.error(LOGGER, "出错啦:"+ex.StackTrace);
}
Thread.Sleep(1);
}
......@@ -143,13 +142,21 @@ namespace OnlineStore.DeviceLibrary
{
ConnectionIP(ip, port);
}
}
public static void ConnectionKND(string ip)
if (timer == null)
{
//端口号暂时使用固定的502;
ushort port = 502;
ConnectionIP(ip, port);
timer = new System.Timers.Timer();
timer.Interval = 1000;
timer.AutoReset = true;
timer.Elapsed += timer_Elapsed;
timer.Enabled = true;
}
}
//public static void ConnectionKND(string ip)
//{
// //端口号暂时使用固定的502;
// ushort port = 502;
// ConnectionIP(ip, port);
//}
public static void ReadMultipleDI(string ioIp, byte slaveId, ushort StartAddress, ushort length)
{
isWrite = true;
......@@ -188,8 +195,14 @@ namespace OnlineStore.DeviceLibrary
isWrite = true;
foreach (string key in mastMap.Keys)
{
byte[] data = new byte[] { 0,0};
try
{
byte[] data = new byte[] { 0, 0 };
WriteMultipleDO(key, DefualtSlaveID, DoStartAddress, DefualtLength, data);
}catch (Exception ex)
{
LogUtil.error("CloseAllDO出错:" + ex.ToString());
}
}
isWrite = false;
}
......
......@@ -11,8 +11,16 @@ namespace OnlineStore.DeviceLibrary
/// 0132h 原点接近传感器输入 (HOME) 状态 ReadOnly 0: 输入 OFF 1: 输入 ON
/// </summary>
public static string Home_Single = "0132";
// 0022h 负方向驱动禁止输入(NOT) ReadOnly 0: 输入 OFF、 1: 输入 ON
// 0023h 正方向驱动禁止输入(POT) ReadOnly 0: 输入 OFF、 1: 输入 ON
/// <summary>
/// 0022h 负方向驱动禁止输入(NOT) ReadOnly 0: 输入 OFF、 1: 输入 ON
/// </summary>
public static string Limit_Negative_Single = "0022";
/// <summary>
/// 0023h 正方向驱动禁止输入(POT) ReadOnly 0: 输入 OFF、 1: 输入 ON
/// </summary>
public static string Limit_Positive_Single = "0023";
/// <summary>
///速度 4601
/// </summary>
......@@ -320,6 +328,7 @@ namespace OnlineStore.DeviceLibrary
//sendData[4] = dataByte[1];
//sendData[5] = dataByte[0];
}
sendData = buildCheckData(sendData, sendData.Length - 2);
......
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.IO.Ports;
......@@ -14,8 +15,8 @@ namespace OnlineStore.DeviceLibrary
public partial class ACServerManager
{
public static bool IsShowMsg = false ;
private static int SleepMSendons = 100;
private static int SleepMSendons = 60;
private static int ReviceOutTimeMS = 100;
private static Dictionary<string, Dictionary<string, int>> ComAddrValue = new Dictionary<string, Dictionary<string, int>>();
private static string mapObj = "";
......@@ -73,20 +74,31 @@ namespace OnlineStore.DeviceLibrary
}
}
public static void ClearSpeed()
{
LogUtil.info("清理之前设置保存的速度列表");
ComAddrValue = new Dictionary<string, Dictionary<string, int>>();
}
public static bool OpenPort(string portName)
{
if (serialBeanMap.ContainsKey(portName))
{
return true ;
return true;
}
int ACBaudRate = ConfigAppSettings.GetIntValue(Setting_Init.ACBaudRate);
if (ACBaudRate <= 0)
{
ACBaudRate = 9600;
}
AcSerialBean bean = new AcSerialBean(portName, 9600, Parity.Even, 8, StopBits.One);
AcSerialBean bean = new AcSerialBean(portName, ACBaudRate, Parity.Even, 8, StopBits.One);
bool result = bean.openPort();
if (!result)
{
LogUtil.info("打开串口【" + portName + "】失败");
LogUtil.info("打开串口【" + portName + "】【" + ACBaudRate + "】失败");
return false;
}
LogUtil.info("打开串口【" + portName + "】成功");
LogUtil.info("打开串口【" + portName + "】【" + ACBaudRate + "】成功");
//bean.DataReceived += DataReceived;
if (serialBeanMap.ContainsKey(portName))
......@@ -114,8 +126,19 @@ namespace OnlineStore.DeviceLibrary
{
serialBeanMap.Remove(portName);
}
LogUtil.info("ACServerManager 关闭串口【" + portName + "】 ");
}
public static void CloseAllPort()
{
List<string> kes = new List<string>(serialBeanMap.Keys);
foreach (string key in kes)
{
ColsePort(key);
}
}
/// <summary>
/// 是否成功打开伺服
/// </summary>
......@@ -128,7 +151,7 @@ namespace OnlineStore.DeviceLibrary
PreReadCoilAddr = ACCMDManager.ServerOn_Addr;
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, PreReadCoilAddr, "0000", 1);
//SendData(portName,dataArray);
byte[] reviceData = SendCommand(portName, dataArray, 100, 6);
byte[] reviceData = SendCommand(portName, dataArray, ReviceOutTimeMS, 6);
int result= GetCoilData(portName, reviceData, PreReadCoilAddr);
//TODO
return result>=1;
......@@ -152,7 +175,6 @@ namespace OnlineStore.DeviceLibrary
//把数字转换为四位的字符串
public static string SpeedToStr(int speed,int length)
{
speed = Math.Abs(speed);
string str = String.Format("{0:X}", speed);
return str.PadLeft(length, '0');
}
......@@ -206,7 +228,7 @@ namespace OnlineStore.DeviceLibrary
//SendStrAndSleep(portName, slvAddrStr + "06 4638 " + SpeedToStr(homeLowSpeed, 4) + " ffff", sleep);
////原点返回加速度=30
//SendStrAndSleep(portName, slvAddrStr + "06 4639 " + SpeedToStr(homeAddSpeed, 4) + " ffff", sleep);
UpdateEEPROM(portName, slvAddr);
//UpdateEEPROM(portName, slvAddr);
}
public static void UpdateEEPROM(string portName, int slvAddr)
{
......@@ -287,7 +309,6 @@ namespace OnlineStore.DeviceLibrary
SendData(portName, data);
System.Threading.Thread.Sleep(SleepMSendons);
UpdateBlock(portName, slvAddr, ACCMDManager.Block_RelMove);
OpenAndCloseSTB(portName, slvAddr);
}
......@@ -303,7 +324,7 @@ namespace OnlineStore.DeviceLibrary
if (isHomeEnd.Equals(1))
{
int value = 2000;
LogUtil.info("轴【" + portName + "_" + slvAddr + "】原点返回时发现原点已亮且回过原点,需要先相对走" + value);
LogUtil.info("轴【" + portName +"_"+slvAddr +"】原点返回时发现原点已亮且回过原点,需要先相对走" + value);
RelMove(portName, slvAddr, value);
bool isStop = false;
for (int i = 0; i <= 10; i++)
......@@ -312,21 +333,21 @@ namespace OnlineStore.DeviceLibrary
if (GetBusyStatus(portName, slvAddr).Equals(0))
{
isStop = true;
LogUtil.info("轴【" + portName + "_" + slvAddr + "】相对走" + value + "已结束");
LogUtil.info("轴【" + portName + "_" + slvAddr + "】 相对走" + value + "已结束");
break;
}
}
if (!isStop)
{
LogUtil.info("轴【" + portName + "_" + slvAddr + "】相对走" + value + "已等待2分钟,直接停止");
LogUtil.info("轴【" + portName + "_" + slvAddr + "】 相对走" + value + "已等待2分钟,直接停止");
SuddenStop(portName, slvAddr);
}
}
else
{
int volSpeed = Math.Abs(speed / 5);
int volSpeed =Math.Abs( speed / 5);
int time = 1500;
LogUtil.info("轴【" + portName + "_" + slvAddr + "】原点返回时发现原点已亮但未回过原点,先匀速向上走" + time + ",速度[" + volSpeed + "]");
LogUtil.info("轴【" + portName + "_" + slvAddr + "】原点返回时发现原点已亮但未回过原点,先匀速向上走"+time+",速度["+ volSpeed + "]" );
//需要匀速向上走
ACServerManager.SpeedMove(portName, slvAddr, volSpeed);
......@@ -336,35 +357,43 @@ namespace OnlineStore.DeviceLibrary
Thread.Sleep(100);
}
}
}
catch (Exception ex)
}catch(Exception ex)
{
LogUtil.error("轴【" + portName + "】原点返回前验证是否在原点出错:" + ex.StackTrace);
LogUtil.error("轴【" + portName + "_" + slvAddr + "】原点返回前验证是否在原点出错:" + ex.StackTrace);
}
//默认负方向原点返回
UpdateBlock(portName, slvAddr, ACCMDManager.Block_HomeMove1);
LogUtil.debug("回原点:反方向");
//}
Thread.Sleep(SleepMSendons);
OpenAndCloseSTB(portName, slvAddr);
}
public static void ZhHomeMove(string portName, int slvAddr )
{
UpdateBlock(portName, slvAddr, ACCMDManager.Block_HomeMove0);
LogUtil.info(portName+ "回原点:正方向");
Thread.Sleep(SleepMSendons);
OpenAndCloseSTB(portName, slvAddr);
}
public static void SpeedMove(string portName, int slvAddr, int speed)
public static void SetSpeed(string portName, int slvAddr, int speed)
{
int preSpeed = GetAddrValue(portName,slvAddr, ACCMDManager.Speed_Addr);
int preSpeed = GetAddrValue(portName, slvAddr, ACCMDManager.Speed_Addr);
if ((preSpeed.Equals(-1)) || (!preSpeed.Equals(Math.Abs(speed))))
{
string v1 = slvAddr + "064601 " + ACServerManager.SpeedToStr(speed, 4) + " ffff";
LogUtil.debug("轴【" + portName + "】更新速度为【" + speed + "】,发送数据【" + v1 + "】");
SendStrAndSleep(portName, v1, SleepMSendons);
UpdateAddrValue(portName,slvAddr, ACCMDManager.Speed_Addr, Math.Abs(speed));
LogUtil.debug("轴【" + portName + "_" + slvAddr + "】更新速度为【" + speed + "】,发送数据【" + v1 + "】");
Thread.Sleep(SleepMSendons);
for (int i = 1; i <= 3; i++)
{
bool result = SendStrAndSleep(portName, v1, SleepMSendons);
if (result)
{
break;
}
else
{
LogUtil.error("轴【" + portName + "_" + slvAddr + "】更新速度为【" + speed + "】,发送数据【" + v1 + "】,第【" + i + "】次失败");
Thread.Sleep(SleepMSendons);
}
}
UpdateAddrValue(portName, slvAddr, ACCMDManager.Speed_Addr, Math.Abs(speed));
Thread.Sleep(SleepMSendons);
}
}
public static void SpeedMove(string portName, int slvAddr, int speed)
{
SetSpeed(portName, slvAddr, speed);
if (speed > 0)
{
UpdateBlock(portName, slvAddr, ACCMDManager.Block_VolMove0);
......@@ -376,6 +405,21 @@ namespace OnlineStore.DeviceLibrary
//Thread.Sleep(SleepMSendons);
OpenAndCloseSTB(portName, slvAddr);
}
public static bool isInPosition(ConfigMoveAxis Axis, int PPosition)
{
int outCount = ACServerManager.GetActualtPosition(Axis.DeviceName, Axis.GetAxisValue());
int errorCount = Math.Abs(outCount - PPosition);
if (errorCount <= Axis.CanErrorCountMin)
{
return true;
}
else
{
return false;
}
}
public static void AbsMove(string portName, int slvAddr, int targetPosition, int targetSpeed)
{
//先更新速度
......@@ -387,7 +431,7 @@ namespace OnlineStore.DeviceLibrary
//速度 V1 =100
string v1 = slvAddrStr + "064601 " + SpeedToStr(targetSpeed, 4) + " ffff";
SendStrAndSleep(portName, v1, SleepMSendons);
UpdateAddrValue(portName, slvAddr, ACCMDManager.Speed_Addr, targetSpeed);
UpdateAddrValue(portName,slvAddr, ACCMDManager.Speed_Addr, targetSpeed);
}
//绝对运动
AbsMove(portName, slvAddr, targetPosition);
......@@ -433,6 +477,9 @@ namespace OnlineStore.DeviceLibrary
SendData(portName, data);
Thread.Sleep(SleepMSendons);
UpdateBlock(portName, slvAddr, ACCMDManager.Block_AbsMove);
//data = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteRegisters, ACCMDManager.BlockNo, ACCMDManager.Block_AbsMove, 2);
//SendData(portName, data);
//Thread.Sleep(SleepMSendons);
OpenAndCloseSTB(portName, slvAddr);
}
}
......
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.IO.Ports;
......@@ -27,14 +28,15 @@ namespace OnlineStore.DeviceLibrary
return null;
}
public static void SendStrAndSleep(string portName, string str, int sleepS)
public static bool SendStrAndSleep(string portName, string str, int sleepS)
{
byte[] data = AcSerialBean.StringToByte(str);
data[data.Length - 1] = 0x00;
data[data.Length - 2] = 0x00;
data = ACCMDManager.buildCheckData(data, data.Length - 2);
SendData(portName, data);
bool result = SendData(portName, data);
System.Threading.Thread.Sleep(sleepS);
return result;
}
public static void SaveData(string portName, byte slvAddr, string regAddr, int value)
......@@ -76,7 +78,7 @@ namespace OnlineStore.DeviceLibrary
return;
}
byte[] returnData = SendCommand(portName, data, 50, reviceLength);
byte[] returnData = SendCommand(portName, data, ReviceOutTimeMS, reviceLength);
string strSend = "";
for (int i = 0; i < returnData.Length; i++)
{
......@@ -87,13 +89,14 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info( "串口" + portName + " 收到数据:" + strSend + "");
}
}
public static void SendData(string portName, byte[] data)
public static bool SendData(string portName, byte[] data)
{
if (data == null)
{
return;
return false;
}
byte[] returnData = SendCommand(portName, data, 50, 8);
bool result = false;
byte[] returnData = SendCommand(portName, data, ReviceOutTimeMS, 8, out result);
if (returnData != null)
{
string strSend = "";
......@@ -106,6 +109,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info("串口" + portName + " 收到数据:" + strSend + "");
}
}
return result;
}
/// <summary>
/// 发送数据并获取返回值
......@@ -115,9 +119,9 @@ namespace OnlineStore.DeviceLibrary
/// <returns>返回值的长度</returns>
public static byte[] SendCommand(string portName, byte[] data, int outTime, int reviceLength)
{
if (outTime > 80)
if (outTime <100)
{
outTime = 80;
outTime = 100;
}
byte[] returnData = null;
......@@ -147,7 +151,69 @@ namespace OnlineStore.DeviceLibrary
}
else
{
bean.SendCommand(data, ref returnData, outTime, reviceLength);
int ret= bean.SendCommand(data, ref returnData, outTime, reviceLength);
if (!ret.Equals(reviceLength))
{
LogUtil.error("串口" + portName + " 写入数据:" + strSend + ",预计返回字节数【"+reviceLength+"】实际返回【"+ret+"】");
}
System.Threading.Thread.Sleep(2);
}
}
catch (Exception ex)
{
LogUtil.info(ex.ToString());
}
return returnData;
}
/// <summary>
/// 发送数据并获取返回值
/// </summary>
/// <param name="data">发送的数据</param>
/// <param name="outTime">超时时间</param>
/// <param name="result">返回结果,是否发送成功</param>
/// <returns>返回值的长度</returns>
public static byte[] SendCommand(string portName, byte[] data, int outTime, int reviceLength,out bool result)
{
if (outTime < 100)
{
outTime = 100;
}
byte[] returnData = null;
result = false;
try
{
if (data == null)
{
return returnData;
}
string strSend = "";
for (int i = 0; i < data.Length; i++)
{
strSend += string.Format("{0:X2} ", data[i]);
}
if (strSend.Equals(""))
{
return returnData;
}
if (IsShowMsg)
{
LogUtil.info("串口" + portName + " 写入数据:" + strSend + "");
}
AcSerialBean bean = GetSerialBean(portName);
if (bean == null)
{
LogUtil.debug("ACServerManager SendCommand 试图向未打开串口【" + portName + "】写入数据:" + strSend + "。");
}
else
{
int ret = bean.SendCommand(data, ref returnData, outTime, reviceLength);
if (!ret.Equals(reviceLength))
{
LogUtil.error("串口" + portName + " 写入数据:" + strSend + ",预计返回字节数【" + reviceLength + "】实际返回【" + ret + "】");
}else
{
result = true ;
}
System.Threading.Thread.Sleep(2);
}
}
......@@ -157,7 +223,6 @@ namespace OnlineStore.DeviceLibrary
}
return returnData;
}
public static void WriteData(string portName, int slvAddr, string addr, string data, byte cmd, int length)
{
......@@ -189,7 +254,13 @@ namespace OnlineStore.DeviceLibrary
dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteCoil, addr, data, length);
SendData(portName, dataArray);
}
public static void SuddenStop(ConfigMoveAxis axis)
{
if (GetBusyStatus(axis.DeviceName, axis.GetAxisValue()).Equals(1))
{
SuddenStop(axis.DeviceName, axis.GetAxisValue());
}
}
public static void SuddenStop(string portName, int slvAddr)
{
// RunBlock(7);
......@@ -200,19 +271,18 @@ namespace OnlineStore.DeviceLibrary
int length = 2;
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteCoil, addr, data, length);
SendData(portName, dataArray);
System.Threading.Thread.Sleep(1000);
System.Threading.Thread.Sleep(500);
data = "0000";
dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteCoil, addr, data, length);
SendData(portName, dataArray);
}
public static void OpenAndCloseSTB(string portName, int slvAddr)
{
OnlyOpenSTB(portName, slvAddr);
System.Threading.Thread.Sleep(100);
System.Threading.Thread.Sleep(200);
CloseSTB(portName, slvAddr);
System.Threading.Thread.Sleep(100);
System.Threading.Thread.Sleep(SleepMSendons);
}
public static void OnlyOpenSTB(string portName, int slvAddr)
......@@ -234,13 +304,13 @@ namespace OnlineStore.DeviceLibrary
public static void UpdateBlock(string portName, int slvAddr, string blockNum)
{
int preNum = GetAddrValue(portName, slvAddr, ACCMDManager.BlockNo);
int preNum = GetAddrValue(portName,slvAddr, ACCMDManager.BlockNo);
if (preNum.Equals(-1) || (!preNum.ToString().Equals(blockNum)))
{
byte[] data = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteRegisters, ACCMDManager.BlockNo, blockNum , 2);
SendData(portName, data);
int value = Convert.ToInt16(blockNum);
UpdateAddrValue(portName, slvAddr, ACCMDManager.BlockNo, value);
UpdateAddrValue(portName,slvAddr, ACCMDManager.BlockNo, value);
Thread.Sleep(SleepMSendons);
}
}
......@@ -253,7 +323,7 @@ namespace OnlineStore.DeviceLibrary
int length = 2;
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteCoil, addr, data, length);
SendData(portName, dataArray);
System.Threading.Thread.Sleep(100);
System.Threading.Thread.Sleep(200);
data = "0000";
dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteCoil, addr, data, length);
SendData(portName, dataArray);
......@@ -304,20 +374,39 @@ namespace OnlineStore.DeviceLibrary
PreReadAddr = ACCMDManager.TargetPostion;
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadRegisters, ACCMDManager.TargetPostion, "0000", 2);
// SendData(portName,dataArray);
byte[] reviceData = SendCommand(portName, dataArray, 100, 9);
byte[] reviceData = SendCommand(portName, dataArray, ReviceOutTimeMS, 9);
return GetRegisterData(portName, reviceData, ACCMDManager.TargetPostion);
}
public static int GetActualtPosition(string portName, int slvAddr)
public static int GetActualtPosition(ConfigMoveAxis axis)
{
return GetActualtPosition(axis.DeviceName, axis.GetAxisValue());
}
public static int GetActualtPosition(string portName, int slvAddr, int rGetCount = 3)
{
PreReadAddr = ACCMDManager.ActualPosition;
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadRegisters, ACCMDManager.ActualPosition, "0000", 2);
// SendData(portName,dataArray);
byte[] reviceData = SendCommand(portName, dataArray, 100, 9);
byte[] reviceData = SendCommand(portName, dataArray, ReviceOutTimeMS, 9);
return GetRegisterData(portName, reviceData, ACCMDManager.ActualPosition);
int result = -1;
for (int i = 1; i <= rGetCount; i++)
{
result = GetRegisterData(portName, reviceData, ACCMDManager.ActualPosition);
if (!result.Equals(-1))
{
break;
}
else
{
LogUtil.error("第" + i + "次获取" + portName + "_" + slvAddr + "的实时位置" + result);
}
Thread.Sleep(180);
}
return result;
}
public static int GetCoilData(string portName, byte[] reviceData, string Address)
{
if (reviceData != null && reviceData.Length > 0)
......@@ -352,7 +441,7 @@ namespace OnlineStore.DeviceLibrary
PreReadCoilAddr = ACCMDManager.Alarm_Status;
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, PreReadCoilAddr, "0000", 1);
//SendData(portName,dataArray);
byte[] reviceData = SendCommand(portName, dataArray, 100, 6);
byte[] reviceData = SendCommand(portName, dataArray, ReviceOutTimeMS, 6);
return GetCoilData(portName, reviceData, PreReadCoilAddr);
}
......@@ -361,7 +450,7 @@ namespace OnlineStore.DeviceLibrary
PreReadCoilAddr = ACCMDManager.BUSYStatus;
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, ACCMDManager.BUSYStatus, "0000", 1);
//SendData(portName,dataArray);
byte[] reviceData = SendCommand(portName, dataArray, 100, 6);
byte[] reviceData = SendCommand(portName, dataArray, ReviceOutTimeMS, 6);
return GetCoilData(portName, reviceData, ACCMDManager.BUSYStatus);
}
......@@ -370,7 +459,7 @@ namespace OnlineStore.DeviceLibrary
PreReadCoilAddr = ACCMDManager.HOME_CMP_Status;
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, ACCMDManager.HOME_CMP_Status, "0000", 1);
//SendData(portName,dataArray);
byte[] reviceData = SendCommand(portName, dataArray, 100, 6);
byte[] reviceData = SendCommand(portName, dataArray, ReviceOutTimeMS, 6);
return GetCoilData(portName, reviceData, ACCMDManager.HOME_CMP_Status);
}
......@@ -378,10 +467,43 @@ namespace OnlineStore.DeviceLibrary
{
PreReadCoilAddr = ACCMDManager.Home_Single;
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, ACCMDManager.Home_Single, "0000", 1);
byte[] reviceData = SendCommand(portName, dataArray, 100, 6);
byte[] reviceData = SendCommand(portName, dataArray, ReviceOutTimeMS, 6);
return GetCoilData(portName, reviceData, ACCMDManager.Home_Single);
}
/// <summary>
/// 负极限
/// </summary>
public static int GetLimitNegativeSingle(string portName, int slvAddr)
{
PreReadCoilAddr = ACCMDManager.Home_Single;
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, ACCMDManager.Limit_Negative_Single, "0000", 1);
byte[] reviceData = SendCommand(portName, dataArray, ReviceOutTimeMS, 6);
return GetCoilData(portName, reviceData, ACCMDManager.Home_Single);
}
/// <summary>
/// 负极限
/// </summary>
public static int GetLimitNegativeSingle(ConfigMoveAxis axis)
{
return GetLimitNegativeSingle(axis.DeviceName, axis.GetAxisValue());
}
/// <summary>
/// 正极限
/// </summary>
public static int GetLimitPositiveSingle(ConfigMoveAxis axis)
{
return GetLimitPositiveSingle(axis.DeviceName, axis.GetAxisValue());
}
/// <summary>
/// 正极限
/// </summary>
public static int GetLimitPositiveSingle(string portName, int slvAddr)
{
PreReadCoilAddr = ACCMDManager.Home_Single;
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, ACCMDManager.Limit_Positive_Single, "0000", 1);
byte[] reviceData = SendCommand(portName, dataArray, ReviceOutTimeMS, 6);
return GetCoilData(portName, reviceData, ACCMDManager.Home_Single);
}
}
/// <summary>
/// 记录最后一次获得的寄存器的值
......
......@@ -32,8 +32,8 @@ DO,相机照明开,CameraLight_Power,110,192.168.200.11,0,相机照明开,Y11,DO-11,0,
DO,允许放料信号,CanPutTray,114,192.168.200.11,0,允许放料信号,Y15,DO-15,0,
DO,可取料信号,CanGetTray,115,192.168.200.11,0,可取料信号,Y16,DO-16,0,
AXIS,(轴一)旋转轴,Middle_Axis,1,COM6,0,,,,,
AXIS,(轴二)升降轴轴,UpDown_Axis,1,COM5,0,,,,,
AXIS,(轴三)进出轴,InOut_Axis,1,COM4,0,,,,,
AXIS,(轴二)升降轴轴,UpDown_Axis,2,COM6,0,,,,,
AXIS,(轴三)进出轴,InOut_Axis,3,COM6,0,,,,,
,温湿度传感器地址,Temperate_ServerAddress,192.168.200.34,,,,,,,
,扫码枪IP,Scanner_Ip,192.168.200.33,,,,,,,
,扫码枪端口号,Scanner_Port,51236,,,,,,,
......@@ -43,7 +43,7 @@ PRO,升降轴 进料口取料缓冲点 P7,UpDownAxis_DoorOBPosition_P7,415000,,,,,,,
PRO,升降轴 进料口出料缓冲点 P8,UpDownAxis_DoorIBPosition_P8,403000,,,,,,,
PRO,旋转轴(轴1)P1 待机原位点,MiddleAxis_P1_Position,268093,,,,,,,
PRO,进出轴(轴3)P1待机原位点,InOutAxis_P1_Position,1000,,,,,,,
PRO,压紧轴(轴4)P1待机原位点,CompressAxis_P1_Position,-7500,,,,,,,
PRO,压紧轴(轴4)P1待机原位点,CompressAxis_P1_Position,10000,,,,,,,
PRO,是否使用定位气缸,IsHasLocationCylinder,0,,,,,,,
PRO,是否有左右侧门,IsHasDoorLimit,1,,,,,,,
PRO,是否使用压紧轴(1=使用),IsHasCompress_Axis,1,,,,, ,,
......@@ -70,6 +70,7 @@ PRO,(轴三)进出轴减速度,InoutAxis_DelSpeed,300,,,,,,,
PRO,(轴三)进出轴原点低速,InoutAxis_HomeLowSpeed,20,,,,,,,
PRO,(轴三)进出轴原点高速,InoutAxis_HomeHighSpeed,60,,,,,,,
PRO,(轴三)进出轴原点加速度,InoutAxis_HomeAddSpeed,200,,,,,,,
PRO,升降轴(轴2)P1速度,UpDownAxis_P1_Speed,250,,,,,,,
PRO,升降轴(轴2)P2速度,UpDownAxis_P2_Speed,250,,,,,,,
PRO,升降轴(轴2)P3速度,UpDownAxis_P3_Speed,250,,,,,,,
......@@ -106,18 +107,6 @@ PRO,每次吹气的时间(分钟),BlowAir_Time,10,,,,,,,
PRO,两次吹气间隔(分钟),BlowAir_Interval,10,,,,,,,
PRO,温湿度端口号,Humiture_Port,COM1,,,,,,,
,,,,,,,,, ,
PRO,硕科步进电机(压紧轴)控制端口号,CompressAxis_PortName,COM3,,,,,,,
PRO,硕科步进电机(压紧轴)控制波特率,CompressAxis_PortBaudrate,9600,,,,,,,
PRO,硕科步进电机(压紧轴)控制奇偶校验,CompressAxis_PortParity,0,,,,,,,
PRO,硕科步进电机(压紧轴)控制停止位,CompressAxis_StopBits,1,,,,,,,
PRO,硕科步进电机(压紧轴)控制初速度,CompressAxis_StartSpeed,5000,,,,,,,
PRO,硕科步进电机(压紧轴)控制最大速度,CompressAxis_MaxSpeed,8000,,,,,,,
PRO,硕科步进电机(压紧轴)控制末速度,CompressAxis_EndSpeed,6000,,,,,,,
PRO,硕科步进电机(压紧轴)控制加速度,CompressAxis_AddSpeed,3000,,,,,,,
PRO,硕科步进电机(压紧轴)控制减速度,CompressAxis_DelSpeed,3000,,,,,,,
PRO,硕科步进电机(压紧轴)控制归零速度(原点返回速度),CompressAxis_HomeSpeed,5000,,,,,,,
PRO,硕科步进电机轴地址(压紧轴),CompressAxis_Slv,1,,,,,,,
,,,,,,,,, ,
PRO,模拟量IO模块的IP地址,AIDevice_IP,192.168.200.12,,,,,,,
PRO,模拟信号1默认高度,AIDI1_DefaultPosition,2920,,,,,,,
PRO,模拟信号2默认高度,AIDI2_DefaultPosition,2960,,,,,,,
......@@ -125,3 +114,15 @@ PRO,模拟信号3默认高度,AIDI3_DefaultPosition,2500,,,,,,,
,,,,,,,,, ,
PRO,模拟信号1的地址,AIDI1_Addr,7,,,,,,,
PRO,模拟信号2的地址,AIDI2_Addr,8,,,,,,,
,,,,,,,,, ,
AXIS,(轴四)压紧轴,Comp_Axis,4,COM6,0,,,,,
PRO,(轴四)压紧轴目标速度,CompAxis_TargetSpeed,100,,,,,,,
PRO,(轴四)压紧轴加速度,CompAxis_AddSpeed,300,,,,,,,
PRO,(轴四)压紧轴减速度,CompAxis_DelSpeed,300,,,,,,,
PRO,(轴四)压紧轴原点低速,CompAxis_HomeLowSpeed,20,,,,,,,
PRO,(轴四)压紧轴原点高速,CompAxis_HomeHighSpeed,60,,,,,,,
PRO,(轴四)压紧轴原点加速度,CompAxis_HomeAddSpeed,200,,,,,,,
PRO,压紧轴(轴4)P1速度,CompAxis_P1_Speed,100,,,,,,,
PRO,压紧轴(轴4)P2速度,CompAxis_P2_Speed,100,,,,,,,
PRO,压紧轴(轴4)P3速度,CompAxis_P3_Speed,100,,,,,,,
,,,,,,,
......@@ -145,10 +145,12 @@ namespace OnlineStore.DeviceLibrary
moveAxisList.Add(Config.Middle_Axis);
moveAxisList.Add(Config.UpDown_Axis);
moveAxisList.Add(Config.InOut_Axis);
moveAxisList.Add(Config.Comp_Axis);
this.AxisAlarmCodeMap = new Dictionary<string , AxisAlarmInfo>();
this.AxisAlarmCodeMap.Add(Config.UpDown_Axis.GetNameStr(), new AxisAlarmInfo());
this.AxisAlarmCodeMap.Add(Config.InOut_Axis.GetNameStr(), new AxisAlarmInfo());
this.AxisAlarmCodeMap.Add(this.Config.Middle_Axis.GetNameStr(), new AxisAlarmInfo());
this.AxisAlarmCodeMap.Add(this.Config.Comp_Axis.GetNameStr(), new AxisAlarmInfo());
}
......@@ -159,14 +161,14 @@ namespace OnlineStore.DeviceLibrary
{
LogUtil.info(LOGGER, StoreName + "开始启动,启动时间:" + StartTime.ToString());
if (IsHasCompress_Axis)
{
if (ShuoKeControls.isRun == false && (!StoreManager.OpenShuoKe(this)))
{
LogUtil.info(StoreName + "打开驱动器串口失败,启动失败!");
return false;
}
}
//if (IsHasCompress_Axis)
//{
// if (ShuoKeControls.isRun == false && (!StoreManager.OpenShuoKe(this)))
// {
// LogUtil.info(StoreName + "打开驱动器串口失败,启动失败!");
// return false;
// }
//}
autoNext = false;
mainTimer.Enabled = false;
alarmType = StoreAlarmType.None;
......@@ -236,23 +238,9 @@ namespace OnlineStore.DeviceLibrary
ACAxisHomeMove(Config.InOut_Axis);
LogUtil.info(LOGGER, StoreName + "开始原点返回,先把进出轴回原点");
//设置速度
SetShuokeSpeed();
// SetShuokeSpeed();
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(2000));
}
public void SetShuokeSpeed()
{
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetAddSpeed, Config.CompressAxis_AddSpeed);
Thread.Sleep(60);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetDelSpeed, Config.CompressAxis_DelSpeed);
Thread.Sleep(60);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetEndSpeed, Config.CompressAxis_EndSpeed);
Thread.Sleep(60);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetHomeSpeed, Config.CompressAxis_HomeSpeed);
Thread.Sleep(60);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetMaxSpeed, Config.CompressAxis_MaxSpeed);
Thread.Sleep(60);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetStartSpeed, Config.CompressAxis_StartSpeed);
}
public void MoveToP1()
{
KNDIOMove(IO_Type.CanPutTray, IO_VALUE.LOW);
......@@ -262,7 +250,7 @@ namespace OnlineStore.DeviceLibrary
StoreMove.NextMoveStep(StoreMoveStep.BOX_M_H_TOP1_InOutToP1);
LogUtil.info(LOGGER, StoreName + "到待机状态,进出轴到P1,判断叉子没有料盘");
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed );
ComBeforeHomeMove();
// ComBeforeHomeMove();
//判断叉子没有料盘
//StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.LOW));
}
......@@ -314,7 +302,7 @@ namespace OnlineStore.DeviceLibrary
{
InoutStartReset();
//硕科压紧轴回原点
SetShuokeSpeed();
// SetShuokeSpeed();
}
else
{
......@@ -369,7 +357,7 @@ namespace OnlineStore.DeviceLibrary
//进出轴原点返回完成,将进出轴的位置设置=0
AxisCountClear(Config.InOut_Axis);
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
ComBeforeHomeMove();
// ComBeforeHomeMove();
//判断叉子没有料盘
//StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.LOW));
CloseDoorAndWait();
......@@ -385,10 +373,7 @@ namespace OnlineStore.DeviceLibrary
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack);
if (IsHasCompress_Axis)
{
StoreMove.TimeOutSeconds = 120;
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, 0, true));
ShuoKeControls.HomeMove(Config.CompressAxis_Slv, 1);
Thread.Sleep(60);
ACAxisHomeMove(Config.Comp_Axis);
}
ACAxisHomeMove(Config.Middle_Axis);
ACAxisHomeMove(Config.UpDown_Axis);
......@@ -399,7 +384,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "复位中:旋转轴运动到P1,上下轴走到P1,压紧轴到P1!");
ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorOPosition_P1, Config.UpDownAxis_P1_Speed);
ComMoveToPosition(Config.CompressAxis_P1_Position);
ComMoveToPosition(Config.CompressAxis_P1_Position,Config.CompAxis_P1_Speed);
break;
case StoreMoveStep.BOX_H_MiddleAxisToP1:
if (StartResetOut())
......@@ -423,9 +408,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "到待机状态,压紧轴回原点,关闭舱门");
if (IsHasCompress_Axis)
{
StoreMove.TimeOutSeconds = 120;
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, 1, true));
ShuoKeControls.HomeMove(Config.CompressAxis_Slv, 1);
ACAxisHomeMove(Config.Comp_Axis);
}
//关闭舱门
CloseDoorAndWait();
......@@ -435,7 +418,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "复位中:旋转轴运动到P1,上下轴走到P1,压紧轴到P1!");
ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorOPosition_P1, Config.UpDownAxis_P1_Speed);
ComMoveToPosition(Config.CompressAxis_P1_Position);
ComMoveToPosition(Config.CompressAxis_P1_Position,Config.CompAxis_P1_Speed);
break;
case StoreMoveStep.BOX_M_H_TOP1_OtherAxisToP1:
......@@ -534,33 +517,11 @@ namespace OnlineStore.DeviceLibrary
}
return false;
}
private void ComBeforeHomeMove()
private void ComMoveToPosition(int targetPosition, int targetSpeed)
{
if (IsHasCompress_Axis)
{
int relValue = -2000;
LogUtil.debug("压紧轴相对位置:" + relValue);
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, relValue, false));
ShuoKeControls.RelativeMove(Config.CompressAxis_Slv, relValue);
Thread.Sleep(100);
}
}
private void ComMoveToPosition(int targetPosition)
{
ComMoveToPosition(targetPosition, false);
}
private void ComMoveToPosition(int targetPosition, bool isNeedCheckSingle)
{
if (IsHasCompress_Axis)
{
LogUtil.debug("压紧轴绝对运动目标位置:" + targetPosition);
if (isNeedCheckSingle)
{
MeteringSignal.StartCheck(targetPosition, ShuoKeControls.GetABSPosition(Config.CompressAxis_Slv));
}
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, targetPosition, false));
ShuoKeControls.AbsMove(Config.CompressAxis_Slv, targetPosition);
Thread.Sleep(100);
ACAxisMove(Config.Comp_Axis, targetPosition, targetSpeed);
}
}
......@@ -609,7 +570,7 @@ namespace OnlineStore.DeviceLibrary
//进出轴原点返回完成,将进出轴的位置设置=0
AxisCountClear(Config.InOut_Axis);
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
ComBeforeHomeMove();
// ComBeforeHomeMove();
//判断叉子没有料盘
//StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.LOW));
CloseDoorAndWait();
......@@ -627,10 +588,7 @@ namespace OnlineStore.DeviceLibrary
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack);
if (IsHasCompress_Axis)
{
StoreMove.TimeOutSeconds = 120;
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, 0, true));
ShuoKeControls.HomeMove(Config.CompressAxis_Slv, 1);
Thread.Sleep(60);
ACAxisHomeMove(Config.Comp_Axis);
}
ACAxisHomeMove(Config.Middle_Axis);
ACAxisHomeMove(Config.UpDown_Axis);
......@@ -641,7 +599,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "回原点:旋转轴运动到P1,上下轴到P1,压紧轴到P1!");
ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorOPosition_P1, Config.UpDownAxis_P1_Speed);
ComMoveToPosition(Config.CompressAxis_P1_Position);
ComMoveToPosition(Config.CompressAxis_P1_Position,Config.CompAxis_P1_Speed);
break;
case StoreMoveStep.BOX_H_MiddleAxisToP1:
LogUtil.info(LOGGER, StoreName + "回原点完成");
......@@ -737,7 +695,7 @@ namespace OnlineStore.DeviceLibrary
{
ACServerManager.ServoOff(axis.DeviceName, axis.GetAxisValue());
//关闭串口,等下次重新打开
ACServerManager.ColsePort(axis.DeviceName);
// ACServerManager.ColsePort(axis.DeviceName);
}
Thread.Sleep(100);
KNDIOMove(IO_Type.Run_Signal, IO_VALUE.LOW);
......@@ -783,10 +741,10 @@ namespace OnlineStore.DeviceLibrary
IsRun = false;
KNDManager.CloseAllDO();
if (IsHasCompress_Axis)
{
ShuoKeControls.ClosePort();
}
//if (IsHasCompress_Axis)
//{
// ShuoKeControls.ClosePort();
//}
LogUtil.info(LOGGER, StoreName + ",停止运行,总运行时间:" + span.ToString());
}
......@@ -1072,7 +1030,7 @@ namespace OnlineStore.DeviceLibrary
{
if (NeedCheckSafetyLight.Equals(1))
{
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor))
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SO_13_DeviceToDoor))
{
NeedCheckSafetyLight = 2;
LOGGER.Info("出库SO_10_DeviceToDoor运动中,光栅被遮挡,停止进出轴运动");
......@@ -1090,10 +1048,10 @@ namespace OnlineStore.DeviceLibrary
{
if (NeedCheckSafetyLight.Equals(2))
{
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor))
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SO_13_DeviceToDoor))
{
LOGGER.Info("出库SO_10_DeviceToDoor运动中,光栅已恢复,继续进出轴运动");
SO_10_DeviceToDoorPro();
SO_13_DeviceToDoor();
}
else if (StoreMove.MoveType.Equals(StoreMoveType.InStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SI_05_DeviceToDoor))
{
......@@ -1366,7 +1324,7 @@ namespace OnlineStore.DeviceLibrary
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
if (IsHasCompress_Axis)
{
ShuoKeControls.SuddownStop(Config.CompressAxis_Slv);
ACServerManager.SuddenStop(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue());
}
else
{
......@@ -1386,7 +1344,7 @@ namespace OnlineStore.DeviceLibrary
KNDIOMove(IO_Type.Door_Up, IO_VALUE.LOW);
KNDIOMove(IO_Type.CanGetTray, IO_VALUE.LOW);
CodeManager.CloseCamera();
CodeManager.CloseAllCamera();
isInPro = false;
}
......
......@@ -95,13 +95,16 @@ namespace OnlineStore.DeviceLibrary
//判断是否在P1,如果是,不需要运行
int outCount = ACServerManager.GetActualtPosition(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
int errorCount = Math.Abs(outCount - InOut_P1);
if (errorCount <= Config.InOut_Axis.CanErrorCountMin)
//需要判断原点信号
int org = ACServerManager.GetHomeSingle(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
if (errorCount <= Config.InOut_Axis.CanErrorCountMin && org.Equals(1))
{
LogUtil.info("进出轴当前位置:" + outCount + ",已经在P1,不需要再回P1");
}
else
{
ACAxisMove(Config.InOut_Axis, InOut_P1, Config.InOutAxis_P1_Speed);
StoreMove.WaitList.Add(WaitResultInfo.WaitAxisOrg(Config.InOut_Axis, IO_VALUE.HIGH));
}
//StoreMove.WaitList.Add(WaitResultInfo.WaitAxisOrg(Config.InOut_Axis,IO_VALUE.HIGH));
}
......@@ -152,7 +155,7 @@ namespace OnlineStore.DeviceLibrary
{
wait.IsEnd = KNDIOValue(wait.IoType).Equals(wait.IoValue);
int timeOutMs = Config.IOSingle_TimerOut;
if (StoreMove.MoveStep == StoreMoveStep.SO_14_WaitTake)
if (StoreMove.MoveStep == StoreMoveStep.SO_18_WaitTake)
{
timeOutMs = 650000;
}
......@@ -170,6 +173,11 @@ namespace OnlineStore.DeviceLibrary
{
wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds);
}
else if (wait.WaitType == 6)
{
IO_VALUE value = (IO_VALUE)ACServerManager.GetHomeSingle(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue());
wait.IsEnd = wait.IoValue.Equals(value);
}
else if (wait.WaitType == 7)
{
if (wait.HeightValue > 0)
......@@ -185,12 +193,12 @@ namespace OnlineStore.DeviceLibrary
LogUtil.debug("等待height=" + wait.HeightValue + "完成");
}
}
else if (wait.WaitType == 5)
{
string msg = "";
wait.IsEnd = ShuoKeIsEnd(wait, out msg);
NotOkMsg = NotOkMsg +" "+ msg;
}
//else if (wait.WaitType == 5)
//{
// string msg = "";
// wait.IsEnd = ShuoKeIsEnd(wait, out msg);
// NotOkMsg = NotOkMsg +" "+ msg;
//}
if (wait.IsEnd)
{
if (StoreMove.OneWaitCanEndStep)
......@@ -221,37 +229,6 @@ namespace OnlineStore.DeviceLibrary
}
}
private bool ShuoKeIsEnd(WaitResultInfo wait, out string msg)
{
//bool result = false;
msg = "";
if (wait.IsHomeMove)
{
return ShuoKeControls.IsHomeMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime, out msg);
}
else
{
bool isend = ShuoKeControls.IsMoveEnd(wait.SlvAddr, wait.TargetPosition, StoreMove.LastSetpTime, out msg);
if (isend)
{
bool isCheckOk = (MeteringSignal.TragetChangeCount <= MeteringSignal.SignalChangeCount);
if (isCheckOk || MeteringSignal.TragetChangeCount <= 0)
{
MeteringSignal.StopCheck();
return true;
}
else
{
msg = "压紧轴计量检测目标【" + MeteringSignal.TragetChangeCount + "】实际【" + MeteringSignal.SignalChangeCount + "】";
LogUtil.error("压紧轴已经停止运动,但是 " + msg);
return false ;
}
}
}
return false;
}
#endregion
#region 入库
......@@ -321,10 +298,10 @@ namespace OnlineStore.DeviceLibrary
StoreMove.NextMoveStep(StoreMoveStep.SI_02_InOutAxisHome);
OpenDoorAndWait();
InOutBackToP1(moveP.InOut_P1);
if (Config.Box_ResetCCount < CurrInOutCCount && IsHasCompress_Axis)
{
ComBeforeHomeMove();
}
//if (Config.Box_ResetCCount < CurrInOutCCount && IsHasCompress_Axis)
//{
// ComBeforeHomeMove();
//}
}
private void SI_05_DeviceToDoor()
{
......@@ -363,28 +340,28 @@ namespace OnlineStore.DeviceLibrary
}
else if (StoreMove.MoveStep == StoreMoveStep.SI_02_InOutAxisHome)
{
if (Config.Box_ResetCCount < CurrInOutCCount && IsHasCompress_Axis)
{
StoreMove.NextMoveStep(StoreMoveStep.SI_021_CompAxisHome);
OutStoreLog("入库:SI_021 已出入库" + CurrInOutCCount + "次,压紧轴需要原点返回");
CurrInOutCCount = 0;
StoreMove.TimeOutSeconds = 120;
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, 0, true));
ShuoKeControls.HomeMove(Config.CompressAxis_Slv, 1);
}
else
{
//if (Config.Box_ResetCCount < CurrInOutCCount && IsHasCompress_Axis)
//{
// StoreMove.NextMoveStep(StoreMoveStep.SI_021_CompAxisHome);
// OutStoreLog("入库:SI_021 已出入库" + CurrInOutCCount + "次,压紧轴需要原点返回");
// CurrInOutCCount = 0;
// StoreMove.TimeOutSeconds = 120;
// StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, 0, true));
// ShuoKeControls.HomeMove(Config.CompressAxis_Slv, 1);
//}
//else
//{
InStoreLog("入库:SI_03 所有轴回到待机点,轴2、轴1 动作到P1,,轴4动作至P3");
StoreMove.NextMoveStep(StoreMoveStep.SI_03_ReturnHome);
ComMoveToPosition(moveP.ComPress_P3);
ComMoveToPosition(moveP.ComPress_P3,Config.CompAxis_P3_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
}
//}
}else if (StoreMove.MoveStep == StoreMoveStep.SI_021_CompAxisHome)
{
InStoreLog("入库:SI_03 所有轴回到待机点,轴2、轴1 动作到P1,,轴4动作至P3");
StoreMove.NextMoveStep(StoreMoveStep.SI_03_ReturnHome);
ComMoveToPosition(moveP.ComPress_P3);
ComMoveToPosition(moveP.ComPress_P3,Config.CompAxis_P3_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
}
......@@ -394,7 +371,7 @@ namespace OnlineStore.DeviceLibrary
{
InStoreLog("入库:SI_04_CompressWare 压紧物品(有压紧轴的才需要此步骤),压紧轴至P3(压紧前点) 开始");
StoreMove.NextMoveStep(StoreMoveStep.SI_04_CompressWare);
ComMoveToPosition(moveP.ComPress_P3);
ComMoveToPosition(moveP.ComPress_P3,Config.CompAxis_P3_Speed);
//ShuoKeControls.AbsMove(Config.CompressAxis_Slv, moveP.ComPress_P3);
//StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, moveP.ComPress_P3, false));
}
......@@ -415,7 +392,7 @@ namespace OnlineStore.DeviceLibrary
NeedCheckSafetyLight = 0;
InStoreLog("入库:SI_06 拿物品,压紧轴至P2(压紧点)) 升降轴至P7(进料口取料缓冲点) ");
StoreMove.NextMoveStep(StoreMoveStep.SI_06_DoorWarToDevice);
ComMoveToPosition(moveP.ComPress_P2, true);
ComMoveToPosition(moveP.ComPress_P2, Config.CompAxis_P2_Speed);
//if (IsHasCompress_Axis)
//{
// ShuoKeControls.AbsMove(Config.CompressAxis_Slv, moveP.ComPress_P2);
......@@ -502,7 +479,7 @@ namespace OnlineStore.DeviceLibrary
//SendLineStatus(StoreID, posId, StoreStatus.InStoreEnd);
StoreMove.NextMoveStep(StoreMoveStep.SI_12_PutWareToBag);
ComMoveToPosition(moveP.ComPress_P3, true);
ComMoveToPosition(moveP.ComPress_P3, Config.CompAxis_P3_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P4, Config.UpDownAxis_P4_Speed);
}
......@@ -517,7 +494,7 @@ namespace OnlineStore.DeviceLibrary
{
InStoreLog("入库:SI_14 返回待机点,轴2/轴1/轴4动作至P1(待机点)),检测门关闭");
StoreMove.NextMoveStep(StoreMoveStep.SI_14_GoBack);
ComMoveToPosition(moveP.ComPress_P1);
ComMoveToPosition(moveP.ComPress_P1,Config.CompAxis_P1_Speed);
//if (IsHasCompress_Axis)
//{
// ShuoKeControls.AbsMove(Config.CompressAxis_Slv, moveP.ComPress_P1);
......@@ -582,10 +559,10 @@ namespace OnlineStore.DeviceLibrary
//ACAxisMove(Config.InOut_Axis, StoreMove.MoveParam.MoveP.InOut_P1, Config.InOutAxis_P1_Speed);
InOutBackToP1(StoreMove.MoveParam.MoveP.InOut_P1);
if (Config.Box_ResetCCount < CurrInOutCCount && IsHasCompress_Axis)
{
ComBeforeHomeMove();
}
//if (Config.Box_ResetCCount < CurrInOutCCount && IsHasCompress_Axis)
//{
// ComBeforeHomeMove();
//}
//OpenDoorAndWait();
}
else
......@@ -619,35 +596,35 @@ namespace OnlineStore.DeviceLibrary
OutStoreLog("出库:SO_02 叉子先运动到P1,已出入库次数:"+CurrInOutCCount);
InOutBackToP1(StoreMove.MoveParam.MoveP.InOut_P1);
if (Config.Box_ResetCCount < CurrInOutCCount && IsHasCompress_Axis)
{
ComBeforeHomeMove();
}
//if (Config.Box_ResetCCount < CurrInOutCCount && IsHasCompress_Axis)
//{
// ComBeforeHomeMove();
//}
}
else if (StoreMove.MoveStep == StoreMoveStep.SO_02_DeviceBack)
{
if (Config.Box_ResetCCount < CurrInOutCCount && IsHasCompress_Axis)
{
StoreMove.NextMoveStep(StoreMoveStep.SO_021_CompAxisHome);
OutStoreLog("出库:SO_021 已出入库" + CurrInOutCCount + "次,压紧轴需要原点返回");
CurrInOutCCount = 0;
StoreMove.TimeOutSeconds = 120;
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, 0, true));
ShuoKeControls.HomeMove(Config.CompressAxis_Slv, 1);
}
else
{
//if (Config.Box_ResetCCount < CurrInOutCCount && IsHasCompress_Axis)
//{
// StoreMove.NextMoveStep(StoreMoveStep.SO_021_CompAxisHome);
// OutStoreLog("出库:SO_021 已出入库" + CurrInOutCCount + "次,压紧轴需要原点返回");
// CurrInOutCCount = 0;
// StoreMove.TimeOutSeconds = 120;
// StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, 0, true));
// ShuoKeControls.HomeMove(Config.CompressAxis_Slv, 1);
//}
//else
//{
StoreMove.NextMoveStep(StoreMoveStep.SO_03_ToBagPosition);
OutStoreLog("出库:SO_03 走到库位,压紧轴至P3(压紧前点) ,旋转轴至P2(库位点),升降轴至P5(库位出库前点)");
ComMoveToPosition(moveP.ComPress_P3);
ComMoveToPosition(moveP.ComPress_P3,Config.CompAxis_P3_Speed);
ACAxisMove(Config.Middle_Axis, StoreMove.MoveParam.MoveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, StoreMove.MoveParam.MoveP.UpDown_P5, Config.UpDownAxis_P5_Speed);
}
//}
}else if (StoreMove.MoveStep == StoreMoveStep.SO_021_CompAxisHome)
{
StoreMove.NextMoveStep(StoreMoveStep.SO_03_ToBagPosition);
OutStoreLog("出库:SO_03 走到库位,压紧轴至P3(压紧前点) ,旋转轴至P2(库位点),升降轴至P5(库位出库前点)");
ComMoveToPosition(moveP.ComPress_P3);
ComMoveToPosition(moveP.ComPress_P3,Config.CompAxis_P3_Speed);
ACAxisMove(Config.Middle_Axis, StoreMove.MoveParam.MoveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, StoreMove.MoveParam.MoveP.UpDown_P5, Config.UpDownAxis_P5_Speed);
}
......@@ -661,7 +638,7 @@ namespace OnlineStore.DeviceLibrary
{
OutStoreLog("出库:SO_05 拿起物品,升降轴至P6(库位出料缓冲点),压紧轴至P2(压紧点) ");
StoreMove.NextMoveStep(StoreMoveStep.SO_05_BagWareToDevice);
ComMoveToPosition(moveP.ComPress_P2, true);
ComMoveToPosition(moveP.ComPress_P2, Config.CompAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P6, Config.UpDownAxis_P6_Speed);
}
else if (StoreMove.MoveStep == StoreMoveStep.SO_05_BagWareToDevice)
......@@ -726,7 +703,7 @@ namespace OnlineStore.DeviceLibrary
if (IsHasCompress_Axis || Config.IsHasLocationCylinder.Equals(0))
{
//SO_10_DeviceToDoorPro();
StoreMove.NextMoveStep(StoreMoveStep.SO_091_WaitNoTray);
StoreMove.NextMoveStep(StoreMoveStep.SO_11_WaitNoTray);
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Door, IO_VALUE.LOW));
StoreMove.WaitList.Add(WaitResultInfo.WaitHeight(0));
OpenDoorAndWait();
......@@ -734,45 +711,50 @@ namespace OnlineStore.DeviceLibrary
}
else
{
StoreMove.NextMoveStep(StoreMoveStep.SO_09_LocationCylinder_Down);
StoreMove.NextMoveStep(StoreMoveStep.SO_09_LocationDown);
OutStoreLog("出库:SO_09 定位气缸退回,定位气缸退回 ");
LocationDownAndWait();
}
}
//此处需要等待移栽没有工作,才能把盘放入出料口
else if (StoreMove.MoveStep == StoreMoveStep.SO_09_LocationCylinder_Down)
else if (StoreMove.MoveStep == StoreMoveStep.SO_09_LocationDown)
{
StoreMove.NextMoveStep(StoreMoveStep.SO_091_WaitNoTray);
OutStoreLog("出库:SO_091 打开仓门,等待门口无料盘 ");
StoreMove.NextMoveStep(StoreMoveStep.SO_11_WaitNoTray);
OutStoreLog("出库:SO_11 等待门口无料盘 ");
StoreMove.TimeOutSeconds = 120;
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Door, IO_VALUE.LOW));
StoreMove.WaitList.Add(WaitResultInfo.WaitHeight(0));
}
else if (StoreMove.MoveStep == StoreMoveStep.SO_11_WaitNoTray)
{
StoreMove.NextMoveStep(StoreMoveStep.SO_12_OpenDoor);
OutStoreLog("出库:SO_12 打开仓门 ");
OpenDoorAndWait();
}
else if (StoreMove.MoveStep == StoreMoveStep.SO_091_WaitNoTray)
else if (StoreMove.MoveStep == StoreMoveStep.SO_12_OpenDoor)
{
SO_10_DeviceToDoorPro();
SO_13_DeviceToDoor();
}
else if (StoreMove.MoveStep == StoreMoveStep.SO_10_DeviceToDoor)
else if (StoreMove.MoveStep == StoreMoveStep.SO_13_DeviceToDoor)
{
OutStoreLog("出库:SO_11 放下物品,升降轴至P8(进料口出料缓冲点) ");
StoreMove.NextMoveStep(StoreMoveStep.SO_11_DevicePutWare);
StoreMove.NextMoveStep(StoreMoveStep.SO_14_DevicePutWare);
OutStoreLog("出库:SO_14 放下物品,升降轴至P8(进料口出料缓冲点) ");
NeedCheckSafetyLight = 0;
ComMoveToPosition(moveP.ComPress_P1, true);
ComMoveToPosition(moveP.ComPress_P1, Config.CompAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P8, Config.UpDownAxis_P8_Speed);
}
else if (StoreMove.MoveStep == StoreMoveStep.SO_11_DevicePutWare)
else if (StoreMove.MoveStep == StoreMoveStep.SO_14_DevicePutWare)
{
StoreMove.NextMoveStep(StoreMoveStep.SO_12_DeviceOutFromDoor);
OutStoreLog("出库:SO_12 叉子从出料口返回,,进出轴动作至P1(待机点) ");
StoreMove.NextMoveStep(StoreMoveStep.SO_15_InoutBack);
OutStoreLog("出库:SO_15 叉子从出料口返回,,进出轴动作至P1(待机点) ");
InOutBackToP1(moveP.InOut_P1);
KNDAIManager.NeedReadAI = true;
}
else if (StoreMove.MoveStep == StoreMoveStep.SO_12_DeviceOutFromDoor)
else if (StoreMove.MoveStep == StoreMoveStep.SO_15_InoutBack)
{
StoreMove.NextMoveStep(StoreMoveStep.SO_121_CheckHasTray);
OutStoreLog("出库:SO_121等待门口有料盘高度,更新状态为出库完成");
StoreMove.NextMoveStep(StoreMoveStep.SO_16_CheckHasTray);
OutStoreLog("出库:SO_16 等待门口有料盘高度,更新状态为出库完成");
StoreMove.TimeOutSeconds = 20;
StoreMove.WaitList.Add(WaitResultInfo.WaitHeight(8));
//把料盘放到门口时出库完成
string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PositionNum : "";
......@@ -782,14 +764,14 @@ namespace OnlineStore.DeviceLibrary
//手动给服务器发消息
SendLineStatus();
}
else if (StoreMove.MoveStep == StoreMoveStep.SO_121_CheckHasTray)
else if (StoreMove.MoveStep == StoreMoveStep.SO_16_CheckHasTray)
{
StoreMove.NextMoveStep(StoreMoveStep.SO_13_GoBack);
OutStoreLog("出库:SO_13 升降轴返回,轴2至P1(待机点) ,关闭舱门");
StoreMove.NextMoveStep(StoreMoveStep.SO_17_GoBack);
OutStoreLog("出库:SO_17 升降轴返回,轴2至P1(待机点) ,关闭舱门");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
CloseDoorAndWait();
}
else if (StoreMove.MoveStep == StoreMoveStep.SO_13_GoBack)
else if (StoreMove.MoveStep == StoreMoveStep.SO_17_GoBack)
{
int OutStoreWaitSeconds = ConfigAppSettings.GetIntValue(Setting_Init.OutStoreWaitSeconds);
if (OutStoreWaitSeconds <= 0)
......@@ -797,16 +779,16 @@ namespace OnlineStore.DeviceLibrary
OutStoreWaitSeconds = 600;
}
int ms = OutStoreWaitSeconds * 1000;
StoreMove.NextMoveStep(StoreMoveStep.SO_14_WaitTake);
OutStoreLog("出库:SO_14_WaitTake 等待拿走物品,最多等待" + OutStoreWaitSeconds + "秒");
StoreMove.TimeOutSeconds = OutStoreWaitSeconds;
StoreMove.NextMoveStep(StoreMoveStep.SO_18_WaitTake);
OutStoreLog("出库:SO_18_WaitTake 等待拿走物品,最多等待" + OutStoreWaitSeconds + "秒");
KNDIOMove(IO_Type.CanGetTray, IO_VALUE.HIGH);
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(ms));
//StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Door, IO_VALUE.LOW));
StoreMove.WaitList.Add(WaitResultInfo.WaitHeight(0));
StoreMove.OneWaitCanEndStep = true;
}
else if (StoreMove.MoveStep == StoreMoveStep.SO_14_WaitTake)
else if (StoreMove.MoveStep == StoreMoveStep.SO_18_WaitTake)
{
KNDIOMove(IO_Type.CanGetTray, IO_VALUE.LOW);
TimeSpan span = DateTime.Now - startOutStoreTime;
......@@ -825,10 +807,10 @@ namespace OnlineStore.DeviceLibrary
}
}
private void SO_10_DeviceToDoorPro()
private void SO_13_DeviceToDoor()
{
LineMoveP moveP = StoreMove.MoveParam.MoveP;
StoreMove.NextMoveStep(StoreMoveStep.SO_10_DeviceToDoor);
StoreMove.NextMoveStep(StoreMoveStep.SO_13_DeviceToDoor);
OutStoreLog("出库:SO_10 叉子进出料口,进出轴至P2(进料口取料点) ");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
NeedCheckSafetyLight = 1;
......@@ -899,7 +881,7 @@ namespace OnlineStore.DeviceLibrary
}
if (storeMoveType.Equals(StoreMoveType.InStore))
{
int newIndex = autoPositionIndex;
int newIndex = autoPositionIndex - 1;
if (newIndex < 0)
{
if (AutoStartIndex >= 0 && AutoStartIndex < PositionNumList.Count)
......
......@@ -29,24 +29,6 @@ namespace OnlineStore.DeviceLibrary
public StoreManager()
{
}
public static bool OpenShuoKe(AC_SA_BoxBean box)
{
//打开硕科步进驱动器端口
Parity parity = (Parity)box.Config.CompressAxis_PortParity;
StopBits bit = (StopBits)box.Config.CompressAxis_StopBits;
bool result = ShuoKeControls.InitPort(box.Config.CompressAxis_PortName, box.Config.CompressAxis_PortBaudrate,
box.Config.CompressAxis_PortParity, 8, bit);
if (result)
{
LogUtil.info(box.StoreName + "打开硕科步进控制器【" + box.Config.CompressAxis_PortName + "】成功");
return true;
}
else
{
LogUtil.error(box.StoreName + "打开硕科步进控制器【" + box.Config.CompressAxis_PortName + "】失败,启动失败!");
return false;
}
}
public static void CheckEnum(Type type)
{
if (type.IsEnum)
......
......@@ -4,6 +4,7 @@ using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
......@@ -18,7 +19,7 @@ namespace OnlineStore.DeviceLibrary
public static List<string> cameraNameList = new List<string>();
public static List<string> codeTypeList = new List<string>();
public static List<string> balserNameList = new List<string>();
//public static List<string> balserNameList = new List<string>();
public static List<string> hikNameList = new List<string>();
private static char spiltChar = '#';
......@@ -43,22 +44,15 @@ namespace OnlineStore.DeviceLibrary
string[] codeArray = codeStr.Split(spiltChar);
foreach (string str in codeArray)
{
if (str.Trim().Equals(""))
{
continue;
}
LogUtil.info("加载到配置二维码类型:" + str.Trim());
codeTypeList.Add(str.Trim());
}
string[] names = CodeLibrary.HIKCamera.Instance.CameraName;
hikNameList.AddRange(names);
foreach(string str in names)
{
LogUtil.info("加载到HIK相机:" + str.Trim());
}
names = CodeLibrary.BaslerCamera.Instance.CameraName;
balserNameList.AddRange(names);
foreach (string str in names)
{
LogUtil.info("加载到Balser相机:" + str.Trim());
}
LoadCamera(false);
CodeLibrary.HDCodeLearnHelper.LoadConfig(nameStr, codeStr);
}
......@@ -67,70 +61,70 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error("解析摄像机配置出错:" + ex.ToString());
}
}
public static void CloseCamera()
private static void LoadCamera(bool isReLoad)
{
BaslerCamera.Instance.Close();
HIKCamera.Instance.Close();
}
public static Bitmap GetCamerImage(string cameraName)
if (isReLoad || Camera._cam == null)
{
Bitmap bitm = null;
try
{
if (balserNameList.Contains(cameraName))
{
bool result = BaslerCamera.Instance.IsOpen;
if (!result)
if (Camera._cam != null)
{
result = BaslerCamera.Instance.Open(cameraName);
LogUtil.info("打开相机:" + cameraName + "(" + result + ")");
Camera._cam.CloseAll();
}
if (result)
{
BaslerCamera.Instance.GrabOne();
bitm = BaslerCamera.Instance.Image;
//BaslerCamera.Instance.Close();
Camera.Type = CameraType.HIK;
Camera._cam.Load();
}
else
catch (Exception ex)
{
LogUtil.error("相机【" + cameraName + "】打开失败:" + BaslerCamera.Instance.ErrInfo);
LogUtil.error("加载HIK相机出错:" + ex.ToString());
}
}
else if (hikNameList.Contains(cameraName))
{
bool result = HIKCamera.Instance.IsOpen;
if (!result)
string[] names = Camera._cam.Name;
if (names != null)
{
result= HIKCamera.Instance.Open(cameraName);
LogUtil.info("打开相机:" + cameraName + "(" + result + ")");
}
if (result)
foreach (string n in names)
{
HIKCamera.Instance.GrabOne();
bitm = HIKCamera.Instance.Image;
//HIKCamera.Instance.Close();
}
else
if (!hikNameList.Contains(n))
{
LogUtil.error("相机【" + cameraName + "】打开失败:" + HIKCamera.Instance.ErrInfo);
hikNameList.Add(n);
}
}
else
// hikNameList.AddRange(names);
foreach (string name in hikNameList)
{
LogUtil.info("未找到相机【" + cameraName + "】无法获取图片");
LogUtil.info("加载到HIK相机:" + name);
}
}
catch (Exception ex)
}
public static void CloseCamera(string cameraName)
{
LogUtil.error("从相机【" + cameraName + "】获取图片出错:" + ex.ToString());
Camera._cam.Close(cameraName);
}
return bitm;
public static void CloseAllCamera()
{
//BaslerCamera.Instance.Close();
//HIKCamera.Instance.Close();
Camera._cam.CloseAll();
}
//public static Bitmap GetCamerImage(string cameraName)
//{
// Bitmap bitm = null;
// try
// {
// bitm = Camera._cam.GrabOneImage(cameraName);
// }
// catch (Exception ex)
// {
// LogUtil.error(" 【" + cameraName + "】获取图片出错:" + ex.ToString());
// }
// return bitm;
//}
[HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan( )
public static List<string> CameraScan()
{
List<string> codeList = new List<string>();
List<CodeInfo> allCodeList = new List<CodeInfo>();
......@@ -139,19 +133,21 @@ namespace OnlineStore.DeviceLibrary
{
foreach (string cameraName in cameraNameList)
{
using (Bitmap bitmap = GetCamerImage(cameraName))
HalconDotNet.HObject ho_Image = null;
try
{
if (bitmap == null)
ho_Image = Camera._cam.CaptureOnImage(cameraName);
if (ho_Image == null)
{
LogUtil.error(" 摄像机【" + cameraName + "】获取图片失败,关闭相机");
CloseCamera();
LogUtil.error(" 【" + cameraName + "】取图片失败[" + Camera._cam.ErrInfo + "],关闭相机");
CloseCamera(cameraName);
continue;
}
LogUtil.debug(" 摄像机【" + cameraName + "】获取图片完成");
System.Threading.Thread.Sleep(1);
HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
LogUtil.debug(" 摄像机【" + cameraName + "】转换图片完成,开始扫码");
//Bitmap bit = new Bitmap(bitmap);
//LogUtil.debug(" 摄像机【" + cameraName + "】获取图片完成");
//System.Threading.Thread.Sleep(1);
//HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bit);
LogUtil.info(" 【" + cameraName + "】转换图片完成,开始扫码");
List<CodeInfo> cc = new List<CodeInfo>();
foreach (string codeType in codeTypeList)
{
......@@ -164,22 +160,39 @@ namespace OnlineStore.DeviceLibrary
{
cc = HDCodeHelper.DecodeCode(ho_Image, 1, GetCodeParamFilePath(codeType), codeType);
}
//LogUtil.info(" 摄像机【" + cameraName + "】【"+ codeType + "】扫码完成");
LogUtil.info(" 【" + cameraName + "】【"+ codeType + "】扫码完成");
}
allCodeList.AddRange(cc);
}
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();
}
}
}
}
catch (AccessViolationException e)
{
LogUtil.error("扫码出现AccessViolationException异常:" + e.ToString());
GC.Collect();
// GC.Collect();
}
catch (Exception ex)
{
LogUtil.error("扫码出错:" + ex.ToString());
}
foreach(CodeInfo info in allCodeList)
foreach (CodeInfo info in allCodeList)
{
codeList.Add(info.CodeStr);
}
......@@ -204,3 +217,4 @@ namespace OnlineStore.DeviceLibrary
}
}
......@@ -254,7 +254,7 @@ namespace OnlineStore.DeviceLibrary
//如果是进出轴,并且光栅被遮挡,直接返回false
if (NeedCheckSafetyLight.Equals(2))
{
if (StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor) ||
if (StoreMove.MoveStep.Equals(StoreMoveStep.SO_13_DeviceToDoor) ||
StoreMove.MoveStep.Equals(StoreMoveStep.SI_05_DeviceToDoor))
{
return false;
......
......@@ -259,36 +259,39 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 料仓出库,定位气缸退回(有压紧轴的不需要此步骤),,定位气缸退回(Y104-1/PCI5O1-84) (Y104-2/PCI5O1-91) (Y104-2/PCI5O1-96) 退回到位
/// </summary>
SO_09_LocationCylinder_Down = 109,
SO_09_LocationDown = 109,
/// <summary>
/// 等待门口无料盘
/// </summary>
SO_091_WaitNoTray=115,
SO_11_WaitNoTray,
/// <summary>
/// 等待门口无料盘
/// </summary>
SO_12_OpenDoor,
/// <summary>
/// 料仓出库,,叉子进出料口,,轴3( 叉子) 至P2( 进料口取料点)
/// /// </summary>
SO_10_DeviceToDoor = 110,
SO_13_DeviceToDoor,
/// <summary>
/// 料仓出库,,把物品放下,,轴2( 上下) 至P8( 进料口出料缓冲点)轴4( 压紧) 至P1( 待机点)
/// </summary>
SO_11_DevicePutWare = 111,
SO_14_DevicePutWare,
/// <summary>
/// 料仓出库,,叉子从出料口返回,,轴3( 叉子) 动作至P1( 待机点)
/// </summary>
SO_12_DeviceOutFromDoor = 112,
SO_15_InoutBack,
/// <summary>
/// 需要检测到门口有料盘高度
/// </summary>
SO_121_CheckHasTray=116,
SO_16_CheckHasTray,
/// <summary>
/// 料仓出库,,升降轴返回,, 轴2至P1( 待机点)
/// </summary>
SO_13_GoBack = 113,
SO_17_GoBack,
/// <summary>
/// 等待拿走物品
/// </summary>
SO_14_WaitTake=114,
SO_18_WaitTake,
#endregion
......@@ -296,7 +299,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 入库检测
/// </summary>
SI_00_TrayCheck=200,
SI_00_TrayCheck =200,
/// <summary>
/// 入库,。定位气缸下降
/// </summary>
......
......@@ -374,61 +374,61 @@ namespace OnlineStore.LoadCSVLibrary
[ConfigProAttribute("InOut_Axis")]
public ConfigMoveAxis InOut_Axis { get; set; }
/// <summary>
/// PRO 硕科步进电机(压紧轴)控制端口号 CompressAxis_PortName COM4
/// </summary>
[ConfigProAttribute("CompressAxis_PortName")]
public string CompressAxis_PortName { get; set; }
/// <summary>
/// PRO 硕科步进电机(压紧轴)控制波特率 CompressAxis_PortBaudrate 9600
/// </summary>
[ConfigProAttribute("CompressAxis_PortBaudrate")]
public int CompressAxis_PortBaudrate { get; set; }
/// <summary>
/// PRO 硕科步进电机(压紧轴)控制奇偶校验 CompressAxis_PortParity 2
/// </summary>
[ConfigProAttribute("CompressAxis_PortParity")]
public int CompressAxis_PortParity { get; set; }
/// <summary>
/// PRO 硕科步进电机(压紧轴)控制停止位 CompressAxis_StopBits 1
/// </summary>
[ConfigProAttribute("CompressAxis_StopBits")]
public int CompressAxis_StopBits { get; set; }
/// <summary>
/// PRO 硕科步进电机(压紧轴)控制初速度 CompressAxis_StartSpeed 100
/// </summary>
[ConfigProAttribute("CompressAxis_StartSpeed")]
public int CompressAxis_StartSpeed { get; set; }
/// <summary>
/// PRO 硕科步进电机(压紧轴)控制最大速度 CompressAxis_MaxSpeed 10000
/// </summary>
[ConfigProAttribute("CompressAxis_MaxSpeed")]
public int CompressAxis_MaxSpeed { get; set; }
/// <summary>
/// PRO 硕科步进电机(压紧轴)控制末速度 CompressAxis_EndSpeed 10000
/// </summary>
[ConfigProAttribute("CompressAxis_EndSpeed")]
public int CompressAxis_EndSpeed { get; set; }
/// <summary>
/// PRO 硕科步进电机(压紧轴)控制加速度 CompressAxis_AddSpeed 5000
/// </summary>
[ConfigProAttribute("CompressAxis_AddSpeed")]
public int CompressAxis_AddSpeed { get; set; }
/// <summary>
/// PRO 硕科步进电机(压紧轴)控制减速度 CompressAxis_DelSpeed 1000
/// </summary>
[ConfigProAttribute("CompressAxis_DelSpeed")]
public int CompressAxis_DelSpeed { get; set; }
/// <summary>
/// PRO 硕科步进电机(压紧轴)控制归零速度(原点返回速度) CompressAxis_HomeSpeed 10000
/// </summary>
[ConfigProAttribute("CompressAxis_HomeSpeed")]
public int CompressAxis_HomeSpeed { get; set; }
/// <summary>
/// PRO,硕科步进电机轴地址(压紧轴),CompressAxis_Slv,1,,,,,,
/// </summary>
[ConfigProAttribute("CompressAxis_Slv")]
public int CompressAxis_Slv { get; set; }
///// <summary>
///// PRO 硕科步进电机(压紧轴)控制端口号 CompressAxis_PortName COM4
///// </summary>
//[ConfigProAttribute("CompressAxis_PortName")]
//public string CompressAxis_PortName { get; set; }
///// <summary>
///// PRO 硕科步进电机(压紧轴)控制波特率 CompressAxis_PortBaudrate 9600
///// </summary>
//[ConfigProAttribute("CompressAxis_PortBaudrate")]
//public int CompressAxis_PortBaudrate { get; set; }
///// <summary>
///// PRO 硕科步进电机(压紧轴)控制奇偶校验 CompressAxis_PortParity 2
///// </summary>
//[ConfigProAttribute("CompressAxis_PortParity")]
//public int CompressAxis_PortParity { get; set; }
///// <summary>
///// PRO 硕科步进电机(压紧轴)控制停止位 CompressAxis_StopBits 1
///// </summary>
//[ConfigProAttribute("CompressAxis_StopBits")]
//public int CompressAxis_StopBits { get; set; }
///// <summary>
///// PRO 硕科步进电机(压紧轴)控制初速度 CompressAxis_StartSpeed 100
///// </summary>
//[ConfigProAttribute("CompressAxis_StartSpeed")]
//public int CompressAxis_StartSpeed { get; set; }
///// <summary>
///// PRO 硕科步进电机(压紧轴)控制最大速度 CompressAxis_MaxSpeed 10000
///// </summary>
//[ConfigProAttribute("CompressAxis_MaxSpeed")]
//public int CompressAxis_MaxSpeed { get; set; }
///// <summary>
///// PRO 硕科步进电机(压紧轴)控制末速度 CompressAxis_EndSpeed 10000
///// </summary>
//[ConfigProAttribute("CompressAxis_EndSpeed")]
//public int CompressAxis_EndSpeed { get; set; }
///// <summary>
///// PRO 硕科步进电机(压紧轴)控制加速度 CompressAxis_AddSpeed 5000
///// </summary>
//[ConfigProAttribute("CompressAxis_AddSpeed")]
//public int CompressAxis_AddSpeed { get; set; }
///// <summary>
///// PRO 硕科步进电机(压紧轴)控制减速度 CompressAxis_DelSpeed 1000
///// </summary>
//[ConfigProAttribute("CompressAxis_DelSpeed")]
//public int CompressAxis_DelSpeed { get; set; }
///// <summary>
///// PRO 硕科步进电机(压紧轴)控制归零速度(原点返回速度) CompressAxis_HomeSpeed 10000
///// </summary>
//[ConfigProAttribute("CompressAxis_HomeSpeed")]
//public int CompressAxis_HomeSpeed { get; set; }
///// <summary>
///// PRO,硕科步进电机轴地址(压紧轴),CompressAxis_Slv,1,,,,,,
///// </summary>
//[ConfigProAttribute("CompressAxis_Slv")]
//public int CompressAxis_Slv { get; set; }
/// <summary>
/// PRO (轴一)旋转轴最小限位 MiddleAxis_PositionMin
......@@ -524,30 +524,56 @@ namespace OnlineStore.LoadCSVLibrary
[ConfigProAttribute("AIDI2_Addr", true)]
public int AIDI2_Addr { get; set; }
//private List<string> TempAddrList = null;
//public static char TempAddrSpilt = '#';
///// <summary>
///// 温湿度地址列表
///// </summary>
//public List<string> GetTempAddrList()
//{
// if (TempAddrList == null)
// {
// TempAddrList = new List<string>();
// string[] array = Temperate_Serveraddress.Split(TempAddrSpilt);
// if (array.Length > 0)
// {
// foreach (string str in array)
// {
// if (!str.Equals(""))
// {
// TempAddrList.Add(str);
// }
// }
// }
// }
// return TempAddrList;
//}
/// <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 压紧轴(轴4)P1速度 CompAxis_P1_Speed 100
/// </summary>
[ConfigProAttribute("CompAxis_P1_Speed")]
public int CompAxis_P1_Speed { get; set; }
/// <summary>
/// PRO 压紧轴(轴4)P2速度 CompAxis_P2_Speed 100
/// </summary>
[ConfigProAttribute("CompAxis_P2_Speed")]
public int CompAxis_P2_Speed { get; set; }
/// <summary>
///PRO 压紧轴(轴4)P3速度 CompAxis_P3_Speed 100
/// </summary>
[ConfigProAttribute("CompAxis_P3_Speed")]
public int CompAxis_P3_Speed { get; set; }
protected override void initMustHavePro()
{
......@@ -626,14 +652,21 @@ namespace OnlineStore.LoadCSVLibrary
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.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.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;
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!