Commit 5bda3d61 LN

增加hc板卡代码

1 个父辈 4385548a
正在显示 40 个修改的文件 包含 1127 行增加148 行删除
...@@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadCSVLibrary", "source\Lo ...@@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadCSVLibrary", "source\Lo
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProCopyClient", "ProCopyClient\ProCopyClient.csproj", "{63ED00F8-B7E2-4674-859C-22B11625CAE8}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProCopyClient", "ProCopyClient\ProCopyClient.csproj", "{63ED00F8-B7E2-4674-859C-22B11625CAE8}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HuichuanLibrary", "source\HuichuanLibrary\HuichuanLibrary.csproj", "{C9575C5E-9D4B-4B4F-BE41-926652B8985F}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
...@@ -45,6 +47,10 @@ Global ...@@ -45,6 +47,10 @@ Global
{63ED00F8-B7E2-4674-859C-22B11625CAE8}.Debug|Any CPU.Build.0 = Debug|Any CPU {63ED00F8-B7E2-4674-859C-22B11625CAE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63ED00F8-B7E2-4674-859C-22B11625CAE8}.Release|Any CPU.ActiveCfg = Release|Any CPU {63ED00F8-B7E2-4674-859C-22B11625CAE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63ED00F8-B7E2-4674-859C-22B11625CAE8}.Release|Any CPU.Build.0 = Release|Any CPU {63ED00F8-B7E2-4674-859C-22B11625CAE8}.Release|Any CPU.Build.0 = Release|Any CPU
{C9575C5E-9D4B-4B4F-BE41-926652B8985F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9575C5E-9D4B-4B4F-BE41-926652B8985F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9575C5E-9D4B-4B4F-BE41-926652B8985F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9575C5E-9D4B-4B4F-BE41-926652B8985F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
......
...@@ -129,6 +129,12 @@ ...@@ -129,6 +129,12 @@
</Compile> </Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="userControl\AxisMoveControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="userControl\AxisMoveControl.Designer.cs">
<DependentUpon>AxisMoveControl.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="FrmAxisDebug.resx"> <EmbeddedResource Include="FrmAxisDebug.resx">
<DependentUpon>FrmAxisDebug.cs</DependentUpon> <DependentUpon>FrmAxisDebug.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
...@@ -166,6 +172,9 @@ ...@@ -166,6 +172,9 @@
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
</Compile> </Compile>
<EmbeddedResource Include="userControl\AxisMoveControl.resx">
<DependentUpon>AxisMoveControl.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
...@@ -190,6 +199,10 @@ ...@@ -190,6 +199,10 @@
<Project>{513bc1c9-800d-43a6-9499-3700baec3554}</Project> <Project>{513bc1c9-800d-43a6-9499-3700baec3554}</Project>
<Name>DeviceLibrary</Name> <Name>DeviceLibrary</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\HuichuanLibrary\HuichuanLibrary.csproj">
<Project>{C9575C5E-9D4B-4B4F-BE41-926652B8985F}</Project>
<Name>HuichuanLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\LoadCVSLibrary\LoadCSVLibrary.csproj"> <ProjectReference Include="..\LoadCVSLibrary\LoadCSVLibrary.csproj">
<Project>{064bebf5-8faa-4ea2-a5f3-a06e6e7d9251}</Project> <Project>{064bebf5-8faa-4ea2-a5f3-a06e6e7d9251}</Project>
<Name>LoadCSVLibrary</Name> <Name>LoadCSVLibrary</Name>
...@@ -221,9 +234,7 @@ ...@@ -221,9 +234,7 @@
<Install>false</Install> <Install>false</Install>
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<Folder Include="userControl\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
<!--出库等待料盘拿走的时间,秒--> <!--出库等待料盘拿走的时间,秒-->
<add key="OutStoreWaitSeconds" value="10" /> <add key="OutStoreWaitSeconds" value="10" />
<!--温控器类型,0=壁挂王字壳温湿度变送器,1=妙昕温湿度记录仪--> <!--温控器类型,0=壁挂王字壳温湿度变送器,1=妙昕温湿度记录仪-->
<add key="HumitureControllerType" value="0" /> <add key="HumitureControllerType" value="0" />
<add key="UseAIOBOX" value="1" /> <add key ="UseHCBoard" value ="1"/>
<!--流水线地址和端口配置--> <!--流水线地址和端口配置-->
<add key="LineServerIp" value="192.168.8.108" /> <add key="LineServerIp" value="192.168.8.108" />
<add key="LineServerPort" value="5246" /> <add key="LineServerPort" value="5246" />
......
...@@ -43,12 +43,12 @@ namespace OnlineStore.ACSingleStore ...@@ -43,12 +43,12 @@ namespace OnlineStore.ACSingleStore
private void AxisMove(ConfigMoveAxis axis, int speed) private void AxisMove(ConfigMoveAxis axis, int speed)
{ {
LogUtil.debug(LOGGER, "点动:deviceName=" + axis.DeviceName + ",axis=" + axis.GetAxisValue() + ",speed=" + speed); LogUtil.debug(LOGGER, "点动:deviceName=" + axis.DeviceName + ",axis=" + axis.GetAxisValue() + ",speed=" + speed);
ACServerManager.SpeedMove(axis.DeviceName, axis.GetAxisValue(), speed); AxisManager.instance.SpeedMove(axis.DeviceName, axis.GetAxisValue(), speed);
} }
private void FrmAxisDebug_Load(object sender, EventArgs e) private void FrmAxisDebug_Load(object sender, EventArgs e)
{ {
ACServerManager.ClearSpeed(); AxisManager.instance.ClearSpeed();
txtMiddleSpeed.Text = (middle.TargetSpeed / 5).ToString(); txtMiddleSpeed.Text = (middle.TargetSpeed / 5).ToString();
txtInOutSpeed.Text = (inout.TargetSpeed / 5).ToString(); txtInOutSpeed.Text = (inout.TargetSpeed / 5).ToString();
txtUpDownSpeed.Text = (updown.TargetSpeed / 5).ToString(); txtUpDownSpeed.Text = (updown.TargetSpeed / 5).ToString();
...@@ -65,7 +65,7 @@ namespace OnlineStore.ACSingleStore ...@@ -65,7 +65,7 @@ namespace OnlineStore.ACSingleStore
//{ //{
// InOutDefaultPosition = 3000; // InOutDefaultPosition = 3000;
//} //}
int currValue = ACServerManager.GetActualtPosition(inout.DeviceName, inout.GetAxisValue()); int currValue = AxisManager.instance.GetActualtPosition(inout.DeviceName, inout.GetAxisValue());
if (currValue <= InOutDefaultPosition) if (currValue <= InOutDefaultPosition)
{ {
return true; return true;
...@@ -98,7 +98,7 @@ namespace OnlineStore.ACSingleStore ...@@ -98,7 +98,7 @@ namespace OnlineStore.ACSingleStore
if (btnMiddleMove.BackColor == Color.Green) if (btnMiddleMove.BackColor == Color.Green)
{ {
btnMiddleMove.BackColor = System.Drawing.SystemColors.Control; btnMiddleMove.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(middle.DeviceName, middle.GetAxisValue()); AxisManager.instance.SuddenStop(middle.DeviceName, middle.GetAxisValue());
UpdateMiddlePosition(); UpdateMiddlePosition();
} }
} }
...@@ -127,7 +127,7 @@ namespace OnlineStore.ACSingleStore ...@@ -127,7 +127,7 @@ namespace OnlineStore.ACSingleStore
if (btnUpDownMove.BackColor == Color.Green) if (btnUpDownMove.BackColor == Color.Green)
{ {
btnUpDownMove.BackColor = System.Drawing.SystemColors.Control; btnUpDownMove.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(updown.DeviceName, updown.GetAxisValue()); AxisManager.instance.SuddenStop(updown.DeviceName, updown.GetAxisValue());
UpdateUpdownPosition(); UpdateUpdownPosition();
} }
} }
...@@ -157,7 +157,7 @@ namespace OnlineStore.ACSingleStore ...@@ -157,7 +157,7 @@ namespace OnlineStore.ACSingleStore
if (this.btnInOutMove.BackColor == Color.Green) if (this.btnInOutMove.BackColor == Color.Green)
{ {
btnInOutMove.BackColor = System.Drawing.SystemColors.Control; btnInOutMove.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(inout.DeviceName, inout.GetAxisValue()); AxisManager.instance.SuddenStop(inout.DeviceName, inout.GetAxisValue());
UpdateInOutPosition(); UpdateInOutPosition();
} }
} }
...@@ -185,7 +185,7 @@ namespace OnlineStore.ACSingleStore ...@@ -185,7 +185,7 @@ namespace OnlineStore.ACSingleStore
if (btnMiddleMovej.BackColor == Color.Green) if (btnMiddleMovej.BackColor == Color.Green)
{ {
btnMiddleMovej.BackColor = System.Drawing.SystemColors.Control; btnMiddleMovej.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(middle.DeviceName, middle.GetAxisValue()); AxisManager.instance.SuddenStop(middle.DeviceName, middle.GetAxisValue());
UpdateMiddlePosition(); UpdateMiddlePosition();
} }
} }
...@@ -214,7 +214,7 @@ namespace OnlineStore.ACSingleStore ...@@ -214,7 +214,7 @@ namespace OnlineStore.ACSingleStore
if (btnUpDownMovej.BackColor == Color.Green) if (btnUpDownMovej.BackColor == Color.Green)
{ {
btnUpDownMovej.BackColor = System.Drawing.SystemColors.Control; btnUpDownMovej.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(updown.DeviceName, updown.GetAxisValue()); AxisManager.instance.SuddenStop(updown.DeviceName, updown.GetAxisValue());
UpdateUpdownPosition(); UpdateUpdownPosition();
} }
} }
...@@ -244,7 +244,7 @@ namespace OnlineStore.ACSingleStore ...@@ -244,7 +244,7 @@ namespace OnlineStore.ACSingleStore
if (btnInOutMovej.BackColor.Equals(Color.Green)) if (btnInOutMovej.BackColor.Equals(Color.Green))
{ {
btnInOutMovej.BackColor = System.Drawing.SystemColors.Control; btnInOutMovej.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(inout.DeviceName, inout.GetAxisValue()); AxisManager.instance.SuddenStop(inout.DeviceName, inout.GetAxisValue());
UpdateInOutPosition(); UpdateInOutPosition();
} }
} }
...@@ -268,7 +268,7 @@ namespace OnlineStore.ACSingleStore ...@@ -268,7 +268,7 @@ namespace OnlineStore.ACSingleStore
if (this.btnComMove.BackColor == Color.Green) if (this.btnComMove.BackColor == Color.Green)
{ {
btnComMove.BackColor = System.Drawing.SystemColors.Control; btnComMove.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(comp.DeviceName, comp.GetAxisValue()); AxisManager.instance.SuddenStop(comp.DeviceName, comp.GetAxisValue());
UpdateCompPosition(); UpdateCompPosition();
} }
} }
...@@ -289,7 +289,7 @@ namespace OnlineStore.ACSingleStore ...@@ -289,7 +289,7 @@ namespace OnlineStore.ACSingleStore
if (btnComMovej.BackColor.Equals(Color.Green)) if (btnComMovej.BackColor.Equals(Color.Green))
{ {
btnComMovej.BackColor = System.Drawing.SystemColors.Control; btnComMovej.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(comp.DeviceName,comp.GetAxisValue()); AxisManager.instance.SuddenStop(comp.DeviceName,comp.GetAxisValue());
UpdateCompPosition(); UpdateCompPosition();
} }
} }
...@@ -317,7 +317,7 @@ namespace OnlineStore.ACSingleStore ...@@ -317,7 +317,7 @@ namespace OnlineStore.ACSingleStore
} }
private void UpdateCompPosition() private void UpdateCompPosition()
{ {
int compPosition = ACServerManager.GetTargetPosition(comp.DeviceName, comp.GetAxisValue()); int compPosition = AxisManager.instance.GetTargetPosition(comp.DeviceName, comp.GetAxisValue());
if (!txtComPosition.Text.Equals(compPosition.ToString())) if (!txtComPosition.Text.Equals(compPosition.ToString()))
{ {
txtComPosition.Text = compPosition.ToString(); txtComPosition.Text = compPosition.ToString();
...@@ -325,7 +325,7 @@ namespace OnlineStore.ACSingleStore ...@@ -325,7 +325,7 @@ namespace OnlineStore.ACSingleStore
} }
private void UpdateUpdownPosition() private void UpdateUpdownPosition()
{ {
int updownPosition = ACServerManager.GetTargetPosition(updown.DeviceName, updown.GetAxisValue()); int updownPosition = AxisManager.instance.GetTargetPosition(updown.DeviceName, updown.GetAxisValue());
if (!txtUpdownPosition.Text.Equals(updownPosition.ToString())) if (!txtUpdownPosition.Text.Equals(updownPosition.ToString()))
{ {
txtUpdownPosition.Text = updownPosition.ToString(); txtUpdownPosition.Text = updownPosition.ToString();
...@@ -334,7 +334,7 @@ namespace OnlineStore.ACSingleStore ...@@ -334,7 +334,7 @@ namespace OnlineStore.ACSingleStore
private void UpdateMiddlePosition() private void UpdateMiddlePosition()
{ {
int middlePosition = ACServerManager.GetTargetPosition(middle.DeviceName, middle.GetAxisValue()); int middlePosition = AxisManager.instance.GetTargetPosition(middle.DeviceName, middle.GetAxisValue());
if (!txtMiddlePosition.Text.Equals(middlePosition.ToString())) if (!txtMiddlePosition.Text.Equals(middlePosition.ToString()))
{ {
txtMiddlePosition.Text = middlePosition.ToString(); txtMiddlePosition.Text = middlePosition.ToString();
...@@ -343,7 +343,7 @@ namespace OnlineStore.ACSingleStore ...@@ -343,7 +343,7 @@ namespace OnlineStore.ACSingleStore
private void UpdateInOutPosition() private void UpdateInOutPosition()
{ {
int inoutPosition = ACServerManager.GetTargetPosition(inout.DeviceName, inout.GetAxisValue()); int inoutPosition = AxisManager.instance.GetTargetPosition(inout.DeviceName, inout.GetAxisValue());
if (!txtInOutPosition.Text.Equals(inoutPosition.ToString())) if (!txtInOutPosition.Text.Equals(inoutPosition.ToString()))
{ {
txtInOutPosition.Text = inoutPosition.ToString(); txtInOutPosition.Text = inoutPosition.ToString();
...@@ -354,7 +354,7 @@ namespace OnlineStore.ACSingleStore ...@@ -354,7 +354,7 @@ namespace OnlineStore.ACSingleStore
{ {
int value = trackBar1.Value; int value = trackBar1.Value;
lblSpeed.Text = "点动速度=" + (value / 10f) + "倍目标速度"; lblSpeed.Text = "点动速度=" + (value / 10f) + "倍目标速度";
ACServerManager.ClearSpeed(); AxisManager.instance.ClearSpeed();
txtMiddleSpeed.Text = (middle.TargetSpeed * value / 10).ToString(); txtMiddleSpeed.Text = (middle.TargetSpeed * value / 10).ToString();
txtInOutSpeed.Text = (inout.TargetSpeed * value / 10).ToString(); txtInOutSpeed.Text = (inout.TargetSpeed * value / 10).ToString();
txtUpDownSpeed.Text = (updown.TargetSpeed * value / 10).ToString(); txtUpDownSpeed.Text = (updown.TargetSpeed * value / 10).ToString();
......
...@@ -44,7 +44,7 @@ namespace OnlineStore.ACSingleStore ...@@ -44,7 +44,7 @@ namespace OnlineStore.ACSingleStore
} }
return str; return str;
} }
internal static string GetCodeNum(string codeName = "RC1250-ACSingleStore") internal static string GetCodeNum(string codeName = "SO664-HCSingleStore")
{ {
byte[] byteArray = System.Text.Encoding.ASCII.GetBytes(codeName); byte[] byteArray = System.Text.Encoding.ASCII.GetBytes(codeName);
string result = ""; string result = "";
......
 
using HuichuanLibrary;
using log4net; using log4net;
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.DeviceLibrary; using OnlineStore.DeviceLibrary;
...@@ -51,8 +52,24 @@ namespace OnlineStore.ACSingleStore ...@@ -51,8 +52,24 @@ namespace OnlineStore.ACSingleStore
AddForm(box.Name, frm); AddForm(box.Name, frm);
} }
this.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title); this.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
chbAutoRun.Checked =( ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun).Equals(1)); int autoValue = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun);
if (autoValue.Equals(1))
{
开机自动启动ToolStripMenuItem.Text = gouStr + " 开机自动启动";
}
else
{
开机自动启动ToolStripMenuItem.Text = "开机自动启动";
}
if (StoreManager.Store.UseBuzzer)
{
启用蜂鸣器ToolStripMenuItem.Text = gouStr + " 启用蜂鸣器";
}
else
{
启用蜂鸣器ToolStripMenuItem.Text = "启用蜂鸣器";
}
LoadOk = true; LoadOk = true;
LogUtil.logBox = this.logBox; LogUtil.logBox = this.logBox;
this.timer1.Start(); this.timer1.Start();
...@@ -193,7 +210,7 @@ namespace OnlineStore.ACSingleStore ...@@ -193,7 +210,7 @@ namespace OnlineStore.ACSingleStore
IOManager.instance.CloseAllDO(); IOManager.instance.CloseAllDO();
IOManager.instance.CloseAllConnection(); IOManager.instance.CloseAllConnection();
ACServerManager.CloseAllPort(); AxisManager.instance.CloseAllPort();
//this.Close(); //this.Close();
System.Environment.Exit(System.Environment.ExitCode); System.Environment.Exit(System.Environment.ExitCode);
...@@ -324,12 +341,7 @@ namespace OnlineStore.ACSingleStore ...@@ -324,12 +341,7 @@ namespace OnlineStore.ACSingleStore
{ {
LogUtil.ClearLog(); LogUtil.ClearLog();
} }
private void debug_enable_checkBox_CheckedChanged(object sender, EventArgs e)
{
LogUtil.debug_opened = chkDebug.Checked;
}
private void btnCopyLog_Click(object sender, EventArgs e) private void btnCopyLog_Click(object sender, EventArgs e)
{ {
Clipboard.SetDataObject(logBox.Text); Clipboard.SetDataObject(logBox.Text);
...@@ -392,23 +404,7 @@ namespace OnlineStore.ACSingleStore ...@@ -392,23 +404,7 @@ namespace OnlineStore.ACSingleStore
LogM(); LogM();
} }
private void chbAutoRun_CheckedChanged(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
if (chbAutoRun.Checked)
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 1);
ManagerUtil.AutoRun(Application.ExecutablePath, true);
}
else
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 0);
ManagerUtil.AutoRun(Application.ExecutablePath, false);
}
}
private void tabControl1_DrawItem(object sender, DrawItemEventArgs e) private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
{ {
...@@ -498,11 +494,7 @@ namespace OnlineStore.ACSingleStore ...@@ -498,11 +494,7 @@ namespace OnlineStore.ACSingleStore
} }
} }
private void chkDebug_CheckedChanged(object sender, EventArgs e)
{
LogUtil.debug_opened = chkDebug.Checked;
LogUtil.info("debug_opened:" + chkDebug.Checked);
}
private void logBox_VisibleChanged(object sender, EventArgs e) private void logBox_VisibleChanged(object sender, EventArgs e)
{ {
if (logBox.Visible) if (logBox.Visible)
...@@ -534,5 +526,82 @@ namespace OnlineStore.ACSingleStore ...@@ -534,5 +526,82 @@ namespace OnlineStore.ACSingleStore
LogUtil.error("显示界面出错:" + ex.ToString()); LogUtil.error("显示界面出错:" + ex.ToString());
} }
} }
private string gouStr = "✔";
private void 开机自动启动ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
if (开机自动启动ToolStripMenuItem.Text.Contains(gouStr))
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 0);
ManagerUtil.AutoRun(Application.ExecutablePath, false);
开机自动启动ToolStripMenuItem.Text = "开机自动启动";
}
else
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 1);
ManagerUtil.AutoRun(Application.ExecutablePath, true);
开机自动启动ToolStripMenuItem.Text = gouStr + "开机自动启动";
}
LogUtil.info(Name + " 点击:" + 开机自动启动ToolStripMenuItem.Text);
}
private void 启用蜂鸣器ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
bool result = !启用蜂鸣器ToolStripMenuItem.Text.Contains(gouStr);
if (result.Equals(StoreManager.Store.UseBuzzer))
{
return;
}
StoreManager.Store.UseBuzzer = result;
ConfigAppSettings.SaveValue(Setting_Init.UseBuzzer, (StoreManager.Store.UseBuzzer ? 1 : 0));
if (result)
{
启用蜂鸣器ToolStripMenuItem.Text = gouStr + " 启用蜂鸣器";
}
else
{
启用蜂鸣器ToolStripMenuItem.Text = "启用蜂鸣器";
}
LogUtil.info(Name + " 点击:" + 启用蜂鸣器ToolStripMenuItem.Text);
}
private void 开启DEBUG日志ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
bool result = !开启DEBUG日志ToolStripMenuItem.Text.Contains(gouStr);
if (result.Equals(LogUtil.debug_opened))
{
return;
}
LogUtil.debug_opened = result;
if (result)
{
开启DEBUG日志ToolStripMenuItem.Text = gouStr + " 开启DEBUG日志";
}
else
{
开启DEBUG日志ToolStripMenuItem.Text = "开启DEBUG日志";
}
LogUtil.info(Name + " 点击:" + 开启DEBUG日志ToolStripMenuItem.Text);
}
private void 板卡调试ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmHuiChuanTest frm = new FrmHuiChuanTest();
frm.ShowDialog();
}
} }
} }
...@@ -21,16 +21,19 @@ namespace OnlineStore.ACSingleStore ...@@ -21,16 +21,19 @@ namespace OnlineStore.ACSingleStore
{ {
private string LogName = ResourceCulture.GetString("升降轴位置调试:"); private string LogName = ResourceCulture.GetString("升降轴位置调试:");
private string PortName = ""; private string PortName = "";
private int SlvAddr = 0; private short SlvAddr = 0;
private string IoIp = ""; private string IoIp = "";
private int IoIndex = 0; private int IoIndex = 0;
public string Axis_Brake = IO_Type.Axis_Brake; public string Axis_Brake = IO_Type.Axis_Brake;
private System.Timers.Timer toolTimer = new System.Timers.Timer(); private System.Timers.Timer toolTimer = new System.Timers.Timer();
public FrmPositionTool(string protName, int slvAddr,string ioIp, int ioIndex)
private ConfigMoveAxis configAxis;
public FrmPositionTool(ConfigMoveAxis axis,string ioIp, int ioIndex)
{ {
InitializeComponent(); InitializeComponent();
this.PortName = protName; this.PortName = axis.DeviceName;
this.SlvAddr = slvAddr; this.SlvAddr = axis.GetAxisValue();
configAxis = axis;
this.IoIp = ioIp; this.IoIp = ioIp;
this.IoIndex = ioIndex; this.IoIndex = ioIndex;
...@@ -44,11 +47,11 @@ namespace OnlineStore.ACSingleStore ...@@ -44,11 +47,11 @@ namespace OnlineStore.ACSingleStore
private void Form1_Load(object sender, EventArgs e) private void Form1_Load(object sender, EventArgs e)
{ {
ACServerManager.IsShowMsg = false; AxisManager.instance.IsShowMsg = false;
LogUtil.logBox = this.richTextBox1; LogUtil.logBox = this.richTextBox1;
//ACServerManager.richeBox = this.richTextBox1; //AxisManager.instance.richeBox = this.richTextBox1;
CheckForIllegalCrossThreadCalls = false; CheckForIllegalCrossThreadCalls = false;
txtPortName.Text = PortName; txtPortName.Text = PortName;
...@@ -86,7 +89,7 @@ namespace OnlineStore.ACSingleStore ...@@ -86,7 +89,7 @@ namespace OnlineStore.ACSingleStore
SaveConfig(tSpeed, tPosition); SaveConfig(tSpeed, tPosition);
//判断伺服是否已经打开 //判断伺服是否已经打开
bool isOn = ACServerManager.ServerOnStatus(PortName, SlvAddr); bool isOn = AxisManager.instance.ServerOnStatus(PortName, SlvAddr);
formStatus(isOn); formStatus(isOn);
timer1.Start(); timer1.Start();
ioStatusControl1.IOName = ResourceCulture.GetString("检测信号"); ioStatusControl1.IOName = ResourceCulture.GetString("检测信号");
...@@ -94,8 +97,8 @@ namespace OnlineStore.ACSingleStore ...@@ -94,8 +97,8 @@ namespace OnlineStore.ACSingleStore
private void btnServoOn_Click(object sender, EventArgs e) private void btnServoOn_Click(object sender, EventArgs e)
{ {
this.PortName = txtPortName.Text; this.PortName = txtPortName.Text;
this.SlvAddr = FormUtil.GetIntValue(txtAddr); this.SlvAddr = FormUtil.GetShortValue(txtAddr);
bool result = ACServerManager.OpenPort(PortName); bool result = AxisManager.instance.OpenPort(PortName);
if (!result) if (!result)
{ {
MessageBox.Show(ResourceCulture.GetString("打开串口失败")); MessageBox.Show(ResourceCulture.GetString("打开串口失败"));
...@@ -103,10 +106,10 @@ namespace OnlineStore.ACSingleStore ...@@ -103,10 +106,10 @@ namespace OnlineStore.ACSingleStore
} }
formStatus(true); formStatus(true);
ACServerManager.InitSlvAddr(PortName, SlvAddr); AxisManager.instance.InitSlvAddr(PortName, SlvAddr);
Thread.Sleep(100); Thread.Sleep(100);
ACServerManager.AlarmClear(PortName, SlvAddr); AxisManager.instance.AlarmClear(PortName, SlvAddr);
ACServerManager.ServoOn(PortName, SlvAddr); AxisManager.instance.ServoOn(PortName, SlvAddr);
try try
{ {
...@@ -122,7 +125,7 @@ namespace OnlineStore.ACSingleStore ...@@ -122,7 +125,7 @@ namespace OnlineStore.ACSingleStore
{ {
StopTimer(); StopTimer();
// toolTimer.Stop(); // toolTimer.Stop();
ACServerManager.SuddenStop(PortName, SlvAddr); AxisManager.instance.SuddenStop(PortName, SlvAddr);
Thread.Sleep(100); Thread.Sleep(100);
try try
{ {
...@@ -132,7 +135,7 @@ namespace OnlineStore.ACSingleStore ...@@ -132,7 +135,7 @@ namespace OnlineStore.ACSingleStore
{ {
} }
ACServerManager.ServoOff(PortName, SlvAddr); AxisManager.instance.ServoOff(PortName, SlvAddr);
formStatus(false); formStatus(false);
} }
...@@ -160,23 +163,23 @@ namespace OnlineStore.ACSingleStore ...@@ -160,23 +163,23 @@ namespace OnlineStore.ACSingleStore
private void btnRelMove_Click(object sender, EventArgs e) private void btnRelMove_Click(object sender, EventArgs e)
{ {
int position = Convert.ToInt32(txtPosition.Text); int position = Convert.ToInt32(txtPosition.Text);
ACServerManager.RelMove(PortName, SlvAddr, position); AxisManager.instance.RelMove(PortName, SlvAddr, position);
} }
private void btnHomeMove_Click(object sender, EventArgs e) private void btnHomeMove_Click(object sender, EventArgs e)
{ {
int speed = Convert.ToInt32(txtSpeed.Text); int speed = Convert.ToInt32(txtSpeed.Text);
ACServerManager.HomeMove(PortName, SlvAddr, speed); AxisManager.instance.HomeMove(PortName, SlvAddr, configAxis.HomeHighSpeed,configAxis.HomeLowSpeed,configAxis.HomeAddSpeed);
} }
private void btnSpeedMove_Click(object sender, EventArgs e) private void btnSpeedMove_Click(object sender, EventArgs e)
{ {
int speed = Convert.ToInt32(txtSpeed.Text); int speed = Convert.ToInt32(txtSpeed.Text);
ACServerManager.SpeedMove(PortName, SlvAddr, speed); AxisManager.instance.SpeedMove(PortName, SlvAddr, speed);
} }
private void btnGetActualPosition_Click(object sender, EventArgs e) private void btnGetActualPosition_Click(object sender, EventArgs e)
{ {
int value = ACServerManager.GetTargetPosition(PortName, SlvAddr); int value = AxisManager.instance.GetTargetPosition(PortName, SlvAddr);
txtTargetPosition.Text = value.ToString(); txtTargetPosition.Text = value.ToString();
value = ACServerManager.GetActualtPosition(PortName, SlvAddr); value = AxisManager.instance.GetActualtPosition(PortName, SlvAddr);
txtActualPosition.Text = value.ToString(); txtActualPosition.Text = value.ToString();
} }
private void SaveConfig(int speed,int position) private void SaveConfig(int speed,int position)
...@@ -223,7 +226,7 @@ namespace OnlineStore.ACSingleStore ...@@ -223,7 +226,7 @@ namespace OnlineStore.ACSingleStore
PositionList = new List<int>(); PositionList = new List<int>();
LogUtil.info(LogName + "伺服开始运动,速度【" + speed + "】位置【" + position + "】启动定时器 "); LogUtil.info(LogName + "伺服开始运动,速度【" + speed + "】位置【" + position + "】启动定时器 ");
formMoveStatus(false); formMoveStatus(false);
ACServerManager.AbsMove(PortName, SlvAddr, position, speed); AxisManager.instance.AbsMove(PortName, SlvAddr, position, speed);
toolTimer.Start(); toolTimer.Start();
} }
private int P3Offset = 0; private int P3Offset = 0;
...@@ -244,7 +247,7 @@ namespace OnlineStore.ACSingleStore ...@@ -244,7 +247,7 @@ namespace OnlineStore.ACSingleStore
private void btnSdStop_Click(object sender, EventArgs e) private void btnSdStop_Click(object sender, EventArgs e)
{ {
toolTimer.Stop(); toolTimer.Stop();
ACServerManager.SuddenStop(PortName, SlvAddr); AxisManager.instance.SuddenStop(PortName, SlvAddr);
} }
private IO_VALUE GetSingleValue() private IO_VALUE GetSingleValue()
...@@ -267,14 +270,14 @@ namespace OnlineStore.ACSingleStore ...@@ -267,14 +270,14 @@ namespace OnlineStore.ACSingleStore
isInProcesss = true; isInProcesss = true;
try try
{ {
int moveS = ACServerManager.GetBusyStatus(PortName, SlvAddr); int moveS = AxisManager.instance.GetBusyStatus(PortName, SlvAddr);
if (moveS.Equals(1)) if (moveS.Equals(1))
{ {
IO_VALUE currValue = GetSingleValue(); IO_VALUE currValue = GetSingleValue();
TimeSpan checkSpan = DateTime.Now - LastGetPTime; TimeSpan checkSpan = DateTime.Now - LastGetPTime;
if (LastValue.Equals(IO_VALUE.LOW) && currValue.Equals(IO_VALUE.HIGH)&&checkSpan.TotalSeconds>2) if (LastValue.Equals(IO_VALUE.LOW) && currValue.Equals(IO_VALUE.HIGH)&&checkSpan.TotalSeconds>2)
{ {
int currPos = ACServerManager.GetActualtPosition(PortName, SlvAddr); int currPos = AxisManager.instance.GetActualtPosition(PortName, SlvAddr);
txtActualPosition.Text = currPos.ToString(); txtActualPosition.Text = currPos.ToString();
PositionList.Add(currPos); PositionList.Add(currPos);
int num = PositionList.Count; int num = PositionList.Count;
...@@ -363,11 +366,11 @@ namespace OnlineStore.ACSingleStore ...@@ -363,11 +366,11 @@ namespace OnlineStore.ACSingleStore
{ {
StopTimer(); StopTimer();
// toolTimer.Stop(); // toolTimer.Stop();
ACServerManager.SuddenStop(PortName, SlvAddr); AxisManager.instance.SuddenStop(PortName, SlvAddr);
Thread.Sleep(100); Thread.Sleep(100);
} }
LogUtil.logBox = null; LogUtil.logBox = null;
//ACServerManager.CloseAllPort(); //AxisManager.instance.CloseAllPort();
//IOManager.instance.CloseAllConnection(); //IOManager.instance.CloseAllConnection();
} }
......
...@@ -117,4 +117,7 @@ ...@@ -117,4 +117,7 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </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> </root>
\ No newline at end of file \ No newline at end of file
...@@ -82,6 +82,7 @@ namespace OnlineStore.Common ...@@ -82,6 +82,7 @@ namespace OnlineStore.Common
public static string HumitureControllerType = "HumitureControllerType"; public static string HumitureControllerType = "HumitureControllerType";
public static string UseAIOBOX = "UseAIOBOX"; public static string UseAIOBOX = "UseAIOBOX";
public static string UseHCBoard = "UseHCBoard";
public static string LineServerIp = "LineServerIp"; public static string LineServerIp = "LineServerIp";
public static string LineServerPort = "LineServerPort"; public static string LineServerPort = "LineServerPort";
...@@ -105,5 +106,7 @@ namespace OnlineStore.Common ...@@ -105,5 +106,7 @@ namespace OnlineStore.Common
public static string Location_PosID_ = "Location_PosID_"; public static string Location_PosID_ = "Location_PosID_";
public static string UseBuzzer = "UseBuzzer";
} }
} }
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public abstract class AxisManager
{
public bool IsShowMsg = false;
public static AxisManager instance;
public void Init()
{
bool UseHCBoard = ConfigAppSettings.GetIntValue(Setting_Init.UseHCBoard).Equals(1);
if (UseHCBoard)
{
//instance = new HCAxisManager();
}
else
{
instance = new ACServerManager();
}
}
public abstract bool OpenPort(string portName);
public abstract void ColsePort(string portName);
public abstract void CloseAllPort();
public abstract bool ServerOnStatus(string portName, short slvAddr);
public abstract void ClearSpeed();
public abstract bool IsHomeMoveEnd(string portName, short slvAddr);
public abstract void ServoOn(string portName, short slvAddr);
public abstract void ServoOff(string portName, short slvAddr);
public abstract void InitSlvAddr(string portName, short slvAddr);
public abstract void InitSlvAddr(string portName, short slvAddr, int targetSpeed, int addSpeed, int delSpeed);
public abstract void RelMove(string portName, short slvAddr, int position, int targetSpeed = 0, int ptpAcc = 0, int ptpDec = 0);
public abstract void HomeMove(string portName, short slvAddr, int highVel, int lowVel, int acc);
public abstract void SpeedMove(string portName, short slvAddr, int speed);
public abstract void SuddenStop(string portName, short slvAddr);
public abstract bool isInPosition(ConfigMoveAxis Axis, int PPosition, bool isLog = false);
public abstract void AbsMove(string portName, short slvAddr, int targetPosition, int targetSpeed=0 , int ptpAcc=0, int ptpDec=0);
public abstract void AlarmClear(string portName, short slvAddr);
public abstract int GetTargetPosition(string portName, short slvAddr);
public abstract int GetActualtPosition(string portName, short slvAddr);
public abstract int GetAlarmStatus(string portName, short slvAddr);
public abstract int GetBusyStatus(string portName, short slvAddr);
public abstract int GetHomeEndStatus(string portName, short slvAddr);
public abstract int GetHomeSingle(string portName, short slvAddr);
/// <summary>
/// 负极限
/// </summary>
public abstract int GetLimitNegativeSingle(string portName, short slvAddr);
/// <summary>
/// 正极限
/// </summary>
public abstract int GetLimitPositiveSingle(string portName, short slvAddr);
}
}
using HuichuanLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class HCAxisManager : AxisManager
{
public override void AbsMove(string portName, short slvAddr, int targetPosition, int targetSpeed=0,int ptpAcc=0,int ptpDec=0)
{
HCBoardManager.AbsMove((short)slvAddr, targetPosition, targetSpeed, ptpAcc, ptpDec);
}
public override void AlarmClear(string portName, short slvAddr)
{
HCBoardManager.ClearAxisSts((short)slvAddr);
}
public override void ClearSpeed()
{
}
public override void CloseAllPort()
{
}
public override void ColsePort(string portName)
{
}
public override int GetActualtPosition(string portName, short slvAddr)
{
return (int)HCBoardManager.GetAxisCurrPos(slvAddr);
}
public override int GetAlarmStatus(string portName, short slvAddr)
{
AxisSts axisS= HCBoardManager.GetAxisSts(slvAddr);
return axisS.ALM;
}
public override int GetBusyStatus(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.BUSY;
}
public override int GetHomeEndStatus(string portName, short slvAddr)
{
return (int) HCBoardManager.GetHomeStatus(slvAddr);
}
public override int GetHomeSingle(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.ALM;
}
public override int GetLimitNegativeSingle(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.NEL;
}
public override int GetLimitPositiveSingle(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.PEL;
}
public override int GetTargetPosition(string portName, short slvAddr)
{
return (int)HCBoardManager.GetAxisPrfPos(slvAddr);
}
public override void HomeMove(string portName, short slvAddr, int highVel, int lowVel, int acc)
{
HCBoardManager.StartHomeMove(slvAddr,(uint) highVel, (uint)lowVel, (uint)acc);
}
public override void InitSlvAddr(string portName, short slvAddr)
{
}
public override void InitSlvAddr(string portName, short slvAddr, int targetSpeed, int addSpeed, int delSpeed)
{
}
public override bool IsHomeMoveEnd(string portName, short slvAddr)
{
return HCBoardManager.HomeingIsEnd(slvAddr);
}
public override bool isInPosition(ConfigMoveAxis Axis, int PPosition, bool isLog = false)
{
return HCBoardManager.IsInPosition(Axis.GetAxisValue(), PPosition,Axis .CanErrorCountMax);
}
public override bool OpenPort(string portName)
{
return true;
}
public override void RelMove(string portName, short slvAddr, int position, int targetSpeed = 0, int ptpAcc = 0, int ptpDec = 0)
{
HCBoardManager.RelMove(slvAddr, position, targetSpeed, ptpAcc, ptpDec);
}
public override bool ServerOnStatus(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.ServoOn.Equals(1);
}
public override void ServoOff(string portName, short slvAddr)
{
HCBoardManager.ServoOff(slvAddr);
}
public override void ServoOn(string portName, short slvAddr)
{
HCBoardManager.ServoOn(slvAddr);
}
public override void SpeedMove(string portName, short slvAddr, int speed)
{
HCBoardManager.SpeedMove(slvAddr, speed);
}
public override void SuddenStop(string portName, short slvAddr)
{
HCBoardManager.AxisStop(slvAddr);
}
}
}
...@@ -59,14 +59,17 @@ ...@@ -59,14 +59,17 @@
<Compile Include="acSingleStore\BoxBean_Partial.cs" /> <Compile Include="acSingleStore\BoxBean_Partial.cs" />
<Compile Include="acSingleStore\StoreBean.cs" /> <Compile Include="acSingleStore\StoreBean.cs" />
<Compile Include="acSingleStore\StoreManager.cs" /> <Compile Include="acSingleStore\StoreManager.cs" />
<Compile Include="AXIS\AxisManager.cs" />
<Compile Include="AXIS\HC\HCAxisManager.cs" />
<Compile Include="IO\AIOBOX\AIOBOXManager.cs" /> <Compile Include="IO\AIOBOX\AIOBOXManager.cs" />
<Compile Include="IO\HCIOManager.cs" />
<Compile Include="IO\IOManager.cs" /> <Compile Include="IO\IOManager.cs" />
<Compile Include="IO\KangNaiDe\KNDManager.cs" /> <Compile Include="IO\KangNaiDe\KNDManager.cs" />
<Compile Include="IO\KangNaiDe\MasterTcpClient.cs" /> <Compile Include="IO\KangNaiDe\MasterTcpClient.cs" />
<Compile Include="lineConnect\LineConnect.cs" /> <Compile Include="lineConnect\LineConnect.cs" />
<Compile Include="PanasonicServo\ACCMDManager.cs" /> <Compile Include="AXIS\PanasonicServo\ACCMDManager.cs" />
<Compile Include="PanasonicServo\ACServerManager.cs" /> <Compile Include="AXIS\PanasonicServo\ACServerManager.cs" />
<Compile Include="PanasonicServo\ACServerManager_Partial.cs" /> <Compile Include="AXIS\PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="store\LineMoveP.cs" /> <Compile Include="store\LineMoveP.cs" />
<Compile Include="store\LineAlarm.cs"> <Compile Include="store\LineAlarm.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
...@@ -94,6 +97,10 @@ ...@@ -94,6 +97,10 @@
<Project>{43cdd09e-fcf3-4960-a01d-3bbfe9933122}</Project> <Project>{43cdd09e-fcf3-4960-a01d-3bbfe9933122}</Project>
<Name>Common</Name> <Name>Common</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\HuichuanLibrary\HuichuanLibrary.csproj">
<Project>{c9575c5e-9d4b-4b4f-be41-926652b8985f}</Project>
<Name>HuichuanLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\LoadCVSLibrary\LoadCSVLibrary.csproj"> <ProjectReference Include="..\LoadCVSLibrary\LoadCSVLibrary.csproj">
<Project>{064bebf5-8faa-4ea2-a5f3-a06e6e7d9251}</Project> <Project>{064bebf5-8faa-4ea2-a5f3-a06e6e7d9251}</Project>
<Name>LoadCSVLibrary</Name> <Name>LoadCSVLibrary</Name>
......
using HuichuanLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary.IO
{
public class HCIOManager : IOManager
{
public override void CloseAllConnection()
{
}
public override void CloseAllDO()
{
HCBoardManager.CloseAllDO();
}
public override void ConnectionIOList(List<string> dIODeviceNameList)
{
if (dIODeviceNameList.Count > 0 && dIODeviceNameList.Contains("HC"))
{
if (!HCBoardManager.CardInitOk())
{
HCBoardManager.InitCard();
}
}
}
public override IO_VALUE GetDIValue(string deviceName, byte slaveID, ushort index)
{
short v = HCBoardManager.GetBitDI((short)index);
return (IO_VALUE)v;
}
public override IO_VALUE GetDOValue(string deviceName, byte slaveID, ushort index)
{
short v = HCBoardManager.GetBitDO((short)index);
return (IO_VALUE)v;
}
public override IO_VALUE GetIOValue(ConfigIO configIO)
{
short index =(short) configIO.GetIOAddr();
short v = HCBoardManager.GetBitDO(index);
return (IO_VALUE)v;
}
public override void ReadAllDI(string deviceName, byte slaveId)
{
}
public override void ReadAllDO(string deviceName, byte slaveId)
{
}
public override void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value, int time)
{
try
{
short v = (short)value;
HCBoardManager.SetBitDO((short)index, v);
short targetV = 0;
if (v.Equals((short)0))
{
targetV = 1;
}
//写入之后,等待指定间隔后回写
System.Timers.Timer mytimer = new System.Timers.Timer(time);
mytimer.Elapsed += (o1, e1) =>
{
try
{
HCBoardManager.SetBitDO((short)index, targetV);
}
catch (Exception ex)
{
LogUtil.error("**********定时回写入 出错:" + ex.StackTrace);
}
};
mytimer.AutoReset = false;
mytimer.Enabled = true;
}
catch (Exception ex)
{
LogUtil.error("AIO WriteSingleDO [" + index + "] 出错:" + ex.ToString());
}
}
public override void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value)
{
short v = (short)value;
HCBoardManager.SetBitDO((short)index, v);
}
}
}
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.DeviceLibrary.IO;
using OnlineStore.LoadCSVLibrary; using OnlineStore.LoadCSVLibrary;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -21,14 +22,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -21,14 +22,8 @@ namespace OnlineStore.DeviceLibrary
{ {
if (StoreManager.Config.DOList.ContainsKey(ioType)) if (StoreManager.Config.DOList.ContainsKey(ioType))
{ {
ConfigIO configIo = StoreManager.Config.DOList[ioType]; ConfigIO configIo = StoreManager.Config.DOList[ioType];
//DateTime time = DateTime.Now; instance.WriteSingleDO(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr(), ioValue);
instance.WriteSingleDO(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr(), ioValue);
//TimeSpan span = DateTime.Now - time;
//if (span.TotalMilliseconds > 100)
//{
// LogUtil.error("IOMove [" + ioType + "] ["+ioValue+"]耗时" + span.TotalMilliseconds);
//}
Thread.Sleep(60); Thread.Sleep(60);
} }
else else
...@@ -74,14 +69,21 @@ namespace OnlineStore.DeviceLibrary ...@@ -74,14 +69,21 @@ namespace OnlineStore.DeviceLibrary
#endregion #endregion
public static void Init() public static void Init()
{ {
bool isAIOBox = ConfigAppSettings.GetIntValue(Setting_Init.UseAIOBOX).Equals(1); bool UseHCBoard = ConfigAppSettings.GetIntValue(Setting_Init.UseHCBoard).Equals(1);
if (isAIOBox) if (UseHCBoard)
{ {
instance = new AIOBOXManager(); instance = new HCIOManager();
} }
else else
{ {
instance = new KNDManager(); bool isAIOBox = ConfigAppSettings.GetIntValue(Setting_Init.UseAIOBOX).Equals(1); if (isAIOBox)
{
instance = new AIOBOXManager();
}
else
{
instance = new KNDManager();
}
} }
} }
public abstract void ReadAllDI(string deviceName, byte slaveId); public abstract void ReadAllDI(string deviceName, byte slaveId);
...@@ -93,10 +95,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -93,10 +95,10 @@ namespace OnlineStore.DeviceLibrary
public abstract void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value); public abstract void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value);
public abstract IO_VALUE GetDIValue(string deviceName, byte slaveID, ushort v); public abstract IO_VALUE GetDIValue(string deviceName, byte slaveID, ushort index);
public abstract IO_VALUE GetDOValue(string deviceName, byte slaveID, ushort v); public abstract IO_VALUE GetDOValue(string deviceName, byte slaveID, ushort index);
public abstract IO_VALUE GetIOValue(ConfigIO configIO); public abstract IO_VALUE GetIOValue(ConfigIO configIO);
......
...@@ -64,18 +64,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -64,18 +64,13 @@ namespace OnlineStore.DeviceLibrary
PositionNumList = new List<string>(); PositionNumList = new List<string>();
foreach (ACStorePosition position in positionList) foreach (ACStorePosition position in positionList)
{ {
// if (position.StoreId.Equals(StoreID)) bool result = ACStorePosition.CheckPosition(position, Config);
if (result && position.StoreId.Equals(DeviceID))
{ {
bool result = ACStorePosition.CheckPosition(position, Config); PositionNumList.Add(position.PositionNum);
if (result&&position.StoreId.Equals(DeviceID))
{
PositionNumList.Add(position.PositionNum);
}
} }
} }
IOManager.Init();
//IOManager.instance.ConnectionIOList(Config.DIODeviceNameList);
mainTimer.Enabled = false; mainTimer.Enabled = false;
int isAuto = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun); int isAuto = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun);
...@@ -251,9 +246,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -251,9 +246,9 @@ namespace OnlineStore.DeviceLibrary
} }
ACServerManager.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue()); AxisManager.instance.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue()); AxisManager.instance.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()); AxisManager.instance.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
isInSuddenDown = false; isInSuddenDown = false;
isNoAirCheck = false; isNoAirCheck = false;
alarmType = StoreAlarmType.None; alarmType = StoreAlarmType.None;
...@@ -323,7 +318,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -323,7 +318,7 @@ namespace OnlineStore.DeviceLibrary
break; break;
case StoreMoveStep.BOX_H_InOutToP1: case StoreMoveStep.BOX_H_InOutToP1:
//如果此时轴三还在报警,需要提示错误并等待 //如果此时轴三还在报警,需要提示错误并等待
if (ACServerManager.GetAlarmStatus(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()) > 0) if (AxisManager.instance.GetAlarmStatus(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()) > 0)
{ {
LogUtil.error( "进出轴报警!复位失败,请检查!"); LogUtil.error( "进出轴报警!复位失败,请检查!");
} }
...@@ -466,7 +461,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -466,7 +461,7 @@ namespace OnlineStore.DeviceLibrary
case StoreMoveStep.BOX_H_InOutToP1: case StoreMoveStep.BOX_H_InOutToP1:
//如果此时轴三还在报警,需要提示错误并等待 //如果此时轴三还在报警,需要提示错误并等待
if (ACServerManager.GetAlarmStatus(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()) > 0) if (AxisManager.instance.GetAlarmStatus(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()) > 0)
{ {
WarnMsg = "进出轴报警!复位失败,请检查!"; WarnMsg = "进出轴报警!复位失败,请检查!";
LogUtil.error( "进出轴报警!复位失败,请检查!"); LogUtil.error( "进出轴报警!复位失败,请检查!");
...@@ -510,18 +505,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -510,18 +505,18 @@ namespace OnlineStore.DeviceLibrary
{ {
string portName = moveAxis.DeviceName; string portName = moveAxis.DeviceName;
short slvAddr = moveAxis.GetAxisValue(); short slvAddr = moveAxis.GetAxisValue();
ACServerManager.OpenPort(portName); AxisManager.instance.OpenPort(portName);
Thread.Sleep(50); Thread.Sleep(50);
//初始化串口 //初始化串口
//ACServerManager.InitSlvAddr(portName, slvAddr); //AxisManager.instance.InitSlvAddr(portName, slvAddr);
if (!IsIntSlvBlock) if (!IsIntSlvBlock)
{ {
ACServerManager.InitSlvAddr(portName, slvAddr, moveAxis.TargetSpeed, moveAxis.AddSpeed, moveAxis.DelSpeed); AxisManager.instance.InitSlvAddr(portName, slvAddr, moveAxis.TargetSpeed, moveAxis.AddSpeed, moveAxis.DelSpeed);
Thread.Sleep(100); Thread.Sleep(100);
} }
ACServerManager.AlarmClear(portName, slvAddr); AxisManager.instance.AlarmClear(portName, slvAddr);
Thread.Sleep(50); Thread.Sleep(50);
ACServerManager.ServoOn(portName, slvAddr); AxisManager.instance.ServoOn(portName, slvAddr);
} }
Thread.Sleep(500); Thread.Sleep(500);
//打开所有轴 //打开所有轴
...@@ -545,7 +540,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -545,7 +540,7 @@ namespace OnlineStore.DeviceLibrary
//判断轴是否正常 //判断轴是否正常
foreach (ConfigMoveAxis axis in moveAxisList) foreach (ConfigMoveAxis axis in moveAxisList)
{ {
if (ACServerManager.ServerOnStatus(axis.DeviceName, axis.GetAxisValue())) if (AxisManager.instance.ServerOnStatus(axis.DeviceName, axis.GetAxisValue()))
{ {
LogUtil.info( Name + "成功打开轴:" + axis.Explain); LogUtil.info( Name + "成功打开轴:" + axis.Explain);
} }
...@@ -553,17 +548,17 @@ namespace OnlineStore.DeviceLibrary ...@@ -553,17 +548,17 @@ namespace OnlineStore.DeviceLibrary
{ {
//清理报警,再重新打开一次 //清理报警,再重新打开一次
LogUtil.info( Name + "第一次打开轴" + axis.Explain + "失败,先清理一下报警,再重新打开一次"); LogUtil.info( Name + "第一次打开轴" + axis.Explain + "失败,先清理一下报警,再重新打开一次");
ACServerManager.AlarmClear(axis.DeviceName, axis.GetAxisValue()); AxisManager.instance.AlarmClear(axis.DeviceName, axis.GetAxisValue());
System.Threading.Thread.Sleep(1200); System.Threading.Thread.Sleep(1200);
ACServerManager.ServoOn(axis.DeviceName, axis.GetAxisValue()); AxisManager.instance.ServoOn(axis.DeviceName, axis.GetAxisValue());
System.Threading.Thread.Sleep(100); System.Threading.Thread.Sleep(100);
if (ACServerManager.ServerOnStatus(axis.DeviceName, axis.GetAxisValue())) if (AxisManager.instance.ServerOnStatus(axis.DeviceName, axis.GetAxisValue()))
{ {
LogUtil.info( Name + "清理报警后重新打卡轴成功:" + axis.Explain); LogUtil.info( Name + "清理报警后重新打卡轴成功:" + axis.Explain);
} }
else else
{ {
ACServerManager.ServoOff(axis.DeviceName, axis.GetAxisValue()); AxisManager.instance.ServoOff(axis.DeviceName, axis.GetAxisValue());
int alarmCode = GetAlarmCodeByAxis(axis); int alarmCode = GetAlarmCodeByAxis(axis);
WarnMsg = Name + "打开轴" + axis.Explain + "失败 "; WarnMsg = Name + "打开轴" + axis.Explain + "失败 ";
LogUtil.info( Name + WarnMsg); LogUtil.info( Name + WarnMsg);
...@@ -581,9 +576,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -581,9 +576,9 @@ namespace OnlineStore.DeviceLibrary
IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW); IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
foreach (ConfigMoveAxis axis in moveAxisList) foreach (ConfigMoveAxis axis in moveAxisList)
{ {
ACServerManager.ServoOff(axis.DeviceName, axis.GetAxisValue()); AxisManager.instance.ServoOff(axis.DeviceName, axis.GetAxisValue());
//关闭串口,等下次重新打开 //关闭串口,等下次重新打开
// ACServerManager.ColsePort(axis.DeviceName); // AxisManager.instance.ColsePort(axis.DeviceName);
} }
Thread.Sleep(100); Thread.Sleep(100);
IOManager.IOMove(IO_Type.Run_Signal, IO_VALUE.LOW); IOManager.IOMove(IO_Type.Run_Signal, IO_VALUE.LOW);
...@@ -1065,7 +1060,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1065,7 +1060,7 @@ namespace OnlineStore.DeviceLibrary
string deviceName = axisInfo.GetNameStr(); string deviceName = axisInfo.GetNameStr();
AxisAlarmInfo info = AxisAlarmCodeMap[deviceName]; AxisAlarmInfo info = AxisAlarmCodeMap[deviceName];
int alarmIo = ACServerManager.GetAlarmStatus(deviceName, axis); int alarmIo = AxisManager.instance.GetAlarmStatus(deviceName, axis);
if (alarmIo == 1) if (alarmIo == 1)
{ {
...@@ -1096,10 +1091,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -1096,10 +1091,10 @@ namespace OnlineStore.DeviceLibrary
IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW); IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
//运动版停止 //运动版停止
ACServerManager.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue()); AxisManager.instance.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue()); AxisManager.instance.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()); AxisManager.instance.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue()); AxisManager.instance.SuddenStop(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue());
CloseAllAxis(); CloseAllAxis();
......
...@@ -28,7 +28,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -28,7 +28,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(StoreMoveStep.SC_04_Inventory);//直接跑到库位点,不使用盘点信号 MoveInfo.NextMoveStep(StoreMoveStep.SC_04_Inventory);//直接跑到库位点,不使用盘点信号
//StoreMove.NextMoveStep(StoreMoveStep.SC_02_MoveToLBag); //StoreMove.NextMoveStep(StoreMoveStep.SC_02_MoveToLBag);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P2, Config.MiddleAxis_P2_Speed); ACAxisMove(Config.Middle_Axis, moveP.Middle_P2, Config.MiddleAxis_P2_Speed);
int outCount = ACServerManager.GetActualtPosition(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue()); int outCount = AxisManager.instance.GetActualtPosition(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
int disCount = Math.Abs(outCount - moveP.UpDown_P5); int disCount = Math.Abs(outCount - moveP.UpDown_P5);
if (disCount > 150000) if (disCount > 150000)
{ {
...@@ -50,18 +50,19 @@ namespace OnlineStore.DeviceLibrary ...@@ -50,18 +50,19 @@ namespace OnlineStore.DeviceLibrary
else if (MoveInfo.MoveStep == StoreMoveStep.SC_03_MoveToHBag) else if (MoveInfo.MoveStep == StoreMoveStep.SC_03_MoveToHBag)
{ {
MoveInfo.NextMoveStep(StoreMoveStep.SC_04_Inventory); MoveInfo.NextMoveStep(StoreMoveStep.SC_04_Inventory);
CheckPositionLog(" 升降轴到目标位置, 当前位置=" + ACServerManager.GetActualtPosition(Config.UpDown_Axis) + " 目标位置=" + ACServerManager.GetTargetPosition(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue())); CheckPositionLog(" 升降轴到目标位置, 当前位置=" + AxisManager.instance.GetActualtPosition(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue()) +
//ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue()); " 目标位置=" + AxisManager.instance.GetTargetPosition(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue()));
//AxisManager.instance.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
//int outCount = ACServerManager.GetActualtPosition(Config.UpDown_Axis); //int outCount = AxisManager.instance.GetActualtPosition(Config.UpDown_Axis);
//int errorCount = Math.Abs(outCount - moveP.UpDown_P9); //int errorCount = Math.Abs(outCount - moveP.UpDown_P9);
//if (errorCount <= Config.UpDown_Axis.CanErrorCountMax) //if (errorCount <= Config.UpDown_Axis.CanErrorCountMax)
//{ //{
// CheckPositionLog(" 升降轴到目标位置, 当前位置=" + ACServerManager.GetActualtPosition(Config.UpDown_Axis)+" 目标位置="+ moveP.UpDown_P9 + " errorCount="+ errorCount); // CheckPositionLog(" 升降轴到目标位置, 当前位置=" + AxisManager.instance.GetActualtPosition(Config.UpDown_Axis)+" 目标位置="+ moveP.UpDown_P9 + " errorCount="+ errorCount);
//} //}
//else //else
//{ //{
// CheckPositionLog(" 升降轴运动过程中检测到料盘, 当前位置=" + ACServerManager.GetActualtPosition(Config.UpDown_Axis) + " 目标位置=" + moveP.UpDown_P9 + " errorCount=" + errorCount+ " Config.UpDown_Axis.CanErrorCountMax=" + Config.UpDown_Axis.CanErrorCountMax); // CheckPositionLog(" 升降轴运动过程中检测到料盘, 当前位置=" + AxisManager.instance.GetActualtPosition(Config.UpDown_Axis) + " 目标位置=" + moveP.UpDown_P9 + " errorCount=" + errorCount+ " Config.UpDown_Axis.CanErrorCountMax=" + Config.UpDown_Axis.CanErrorCountMax);
//} //}
Dictionary<string, string> paramMap = new Dictionary<string, string>(); Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("cid", CID);//cid = 料仓CID paramMap.Add("cid", CID);//cid = 料仓CID
......
...@@ -113,7 +113,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -113,7 +113,7 @@ namespace OnlineStore.DeviceLibrary
private void InOutBackToP1(int InOut_P1) private void InOutBackToP1(int InOut_P1)
{ {
//判断是否在P1,如果是,不需要运行 //判断是否在P1,如果是,不需要运行
int outCount = ACServerManager.GetActualtPosition(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()); int outCount = AxisManager.instance.GetActualtPosition(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
int errorCount = Math.Abs(outCount - InOut_P1); int errorCount = Math.Abs(outCount - InOut_P1);
if (errorCount <= Config.InOut_Axis.CanErrorCountMin) if (errorCount <= Config.InOut_Axis.CanErrorCountMin)
{ {
...@@ -343,7 +343,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -343,7 +343,7 @@ namespace OnlineStore.DeviceLibrary
} }
private void SI_05_DeviceToDoor() private void SI_05_DeviceToDoor()
{ {
if (!ACServerManager.isInPosition(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P1,true)) if (!AxisManager.instance.isInPosition(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P1,true))
{ {
MoveInfo.NextMoveStep(StoreMoveStep.SI_03_ReturnHome); MoveInfo.NextMoveStep(StoreMoveStep.SI_03_ReturnHome);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
...@@ -351,7 +351,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -351,7 +351,7 @@ namespace OnlineStore.DeviceLibrary
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P1, Config.UpDownAxis_P1_Speed); ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
return; return;
} }
if (!ACServerManager.isInPosition(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P1)) if (!AxisManager.instance.isInPosition(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P1))
{ {
MoveInfo.NextMoveStep(StoreMoveStep.SI_03_ReturnHome); MoveInfo.NextMoveStep(StoreMoveStep.SI_03_ReturnHome);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
...@@ -428,7 +428,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -428,7 +428,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
ComMoveToPosition(moveP.ComPress_P3, Config.CompAxis_P3_Speed); ComMoveToPosition(moveP.ComPress_P3, Config.CompAxis_P3_Speed);
if (!ACServerManager.isInPosition(Config.UpDown_Axis, moveP.UpDown_P1)) if (!AxisManager.instance.isInPosition(Config.UpDown_Axis, moveP.UpDown_P1))
{ {
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed); ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
} }
...@@ -436,7 +436,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -436,7 +436,7 @@ namespace OnlineStore.DeviceLibrary
{ {
InStoreLog("入库:SI_03 升降轴已在P1[" + moveP.UpDown_P1 + "]"); InStoreLog("入库:SI_03 升降轴已在P1[" + moveP.UpDown_P1 + "]");
} }
if (!ACServerManager.isInPosition(Config.Middle_Axis, moveP.Middle_P1)) if (!AxisManager.instance.isInPosition(Config.Middle_Axis, moveP.Middle_P1))
{ {
ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed); ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
} }
......
...@@ -26,7 +26,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -26,7 +26,7 @@ namespace OnlineStore.DeviceLibrary
public Dictionary<int, BoxConfig> BoxConfigMap { get; set; } public Dictionary<int, BoxConfig> BoxConfigMap { get; set; }
public Dictionary<int, BoxBean> BoxMap = new Dictionary<int, BoxBean>(); public Dictionary<int, BoxBean> BoxMap = new Dictionary<int, BoxBean>();
public bool UseBuzzer = true;
public StoreConfig Config { get; set; } public StoreConfig Config { get; set; }
#region 初始化 #region 初始化
...@@ -48,6 +48,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -48,6 +48,7 @@ namespace OnlineStore.DeviceLibrary
Name = (" Store_" + Config.CID + " ").ToUpper(); Name = (" Store_" + Config.CID + " ").ToUpper();
List<string> ioList = new List<string>(); List<string> ioList = new List<string>();
IOManager.Init();
//AddDeviceName(ioList, Config.DIODeviceNameList); //AddDeviceName(ioList, Config.DIODeviceNameList);
...@@ -61,7 +62,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -61,7 +62,6 @@ namespace OnlineStore.DeviceLibrary
BoxConfigMap.Add(config.DeviceID, config); BoxConfigMap.Add(config.DeviceID, config);
} }
IOManager.Init();
//先初始化设备 //先初始化设备
......
...@@ -222,7 +222,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -222,7 +222,7 @@ namespace OnlineStore.DeviceLibrary
moveAxis.TargetPosition = 0; moveAxis.TargetPosition = 0;
LogUtil.info( moveAxis.DisplayStr + "speed[" + moveAxis.TargetSpeed + "]开始原点返回"); LogUtil.info( moveAxis.DisplayStr + "speed[" + moveAxis.TargetSpeed + "]开始原点返回");
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, true)); MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, true));
ACServerManager.HomeMove(moveAxis.DeviceName, (short)moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed); AxisManager.instance.HomeMove(moveAxis.DeviceName, (short)moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed,moveAxis.HomeLowSpeed,moveAxis.HomeAddSpeed);
} }
/// <summary> /// <summary>
...@@ -232,7 +232,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -232,7 +232,7 @@ namespace OnlineStore.DeviceLibrary
{ {
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, targetPosition, targetSpeed)); MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, targetPosition, targetSpeed));
moveAxis.TargetPosition = targetPosition; moveAxis.TargetPosition = targetPosition;
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed); AxisManager.instance.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed);
} }
/// <summary> /// <summary>
...@@ -254,8 +254,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -254,8 +254,8 @@ namespace OnlineStore.DeviceLibrary
// } // }
//} //}
bool isOk = ACServerManager.GetBusyStatus(deviceName, axisNo).Equals(0); bool isOk = AxisManager.instance.GetBusyStatus(deviceName, axisNo).Equals(0);
int outCount = ACServerManager.GetActualtPosition(deviceName, axisNo); int outCount = AxisManager.instance.GetActualtPosition(deviceName, axisNo);
int errorCount = Math.Abs(outCount - targetPosition); int errorCount = Math.Abs(outCount - targetPosition);
if (isOk) if (isOk)
{ {
...@@ -268,7 +268,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -268,7 +268,7 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.error( moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount + LogUtil.error( moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount +
"],误差过大,重新开始运动,剩余[" + MoveInfo.CanWhileCount + "]次"); "],误差过大,重新开始运动,剩余[" + MoveInfo.CanWhileCount + "]次");
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed); AxisManager.instance.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed);
MoveInfo.CanWhileCount--; MoveInfo.CanWhileCount--;
} }
else else
...@@ -283,10 +283,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -283,10 +283,10 @@ namespace OnlineStore.DeviceLibrary
protected bool ACHomeMoveIsEnd(ConfigMoveAxis moveAxis, out string msg) protected bool ACHomeMoveIsEnd(ConfigMoveAxis moveAxis, out string msg)
{ {
msg = ""; msg = "";
if (ACServerManager.IsHomeMoveEnd(moveAxis.DeviceName, moveAxis.GetAxisValue())) if (AxisManager.instance.IsHomeMoveEnd(moveAxis.DeviceName, moveAxis.GetAxisValue()))
{ {
//原点完成并且位置=0 //原点完成并且位置=0
int outCount = ACServerManager.GetActualtPosition(moveAxis.DeviceName, moveAxis.GetAxisValue()); int outCount = AxisManager.instance.GetActualtPosition(moveAxis.DeviceName, moveAxis.GetAxisValue());
int errorCount = Math.Abs(outCount); int errorCount = Math.Abs(outCount);
if (errorCount <= moveAxis.CanErrorCountMax) if (errorCount <= moveAxis.CanErrorCountMax)
{ {
...@@ -297,7 +297,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -297,7 +297,7 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.error( moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],重新回原点,剩余[" + MoveInfo.CanWhileCount + "]次"); LogUtil.error( moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],重新回原点,剩余[" + MoveInfo.CanWhileCount + "]次");
//LogUtil.error( StoreName + moveAxis.DisplayStr + "重新回原点"); //LogUtil.error( StoreName + moveAxis.DisplayStr + "重新回原点");
ACServerManager.HomeMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed); AxisManager.instance.HomeMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed, moveAxis.HomeLowSpeed, moveAxis.HomeAddSpeed);
MoveInfo.CanWhileCount--; MoveInfo.CanWhileCount--;
} }
else else
......
此文件类型无法预览
此文件的差异太大,无法显示。
using log4net;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace HuichuanLibrary
{
public class HCLogUtil
{
public static ILog LOGGER = LogManager.GetLogger("RollingLogFileAppender");
public static ConcurrentDictionary<int, DateTime> lastErrorLogTime = new ConcurrentDictionary<int, DateTime>();
public static System.Windows.Forms.RichTextBox logBox = null;
public static int showCount = 20;
public static bool debug_opened = false;
public static void info(ILog log, string msg)
{
if (log == null)
{
return;
}
log.Info(msg);
AddToBox(msg, Color.Black);
//clear();
}
public static void info(ILog log, string msg, Color color)
{
log.Info(msg);
AddToBox(msg, color);
}
public static void debug(ILog log, string msg, Color color)
{
log.Debug(msg);
if (debug_opened)
{
AddToBox(msg, color);
}
}
public static void debug(ILog log, string msg)
{
log.Debug(msg);
if (debug_opened)
{
AddToBox(msg, Color.Gray);
}
}
public static void error(string errorMsg, int type, int seconds = 10)
{
try
{
if (lastErrorLogTime.ContainsKey(type))
{
TimeSpan span = DateTime.Now - lastErrorLogTime[type];
if (span.TotalSeconds > seconds)
{
lastErrorLogTime[type] = DateTime.Now;
error(LOGGER, errorMsg);
}
}
else
{
lastErrorLogTime.TryAdd(type, DateTime.Now);
error(LOGGER, errorMsg);
}
}
catch (Exception ex)
{
LOGGER.Error(" 打印日志【" + type + "-" + errorMsg + "】出错:" + ex.ToString());
}
}
public static void error(ILog log, string errorMsg, Exception ex = null)
{
if (errorMsg.Trim().Equals("") && (ex == null))
{
return;
}
if (ex == null)
{
log.Error(errorMsg);
}
else
{
log.Error(errorMsg, ex);
}
AddToBox(errorMsg, Color.Red);
}
private static object lockObj = "";
private static void AddToBox(string msg, Color color)
{
if (Monitor.TryEnter(lockObj, 2))
{
try
{
ShowLogPro(msg, color);
}
catch (Exception ex)
{
LOGGER.Error("出错:", ex);
}
finally
{
Monitor.Exit(lockObj);
}
}
else
{
LOGGER.Debug("ShowLogPro【" + msg + "】失败,未得到锁");
}
}
private static List<string> logList = new List<string>();
public static string LastText = "";
[HandleProcessCorruptedStateExceptions]
private static void ShowLogPro(string msg, Color color)
{
try
{
if (logList.Count >= showCount)
{
logList.RemoveAt(0);
}
string text = "";
foreach (string str in logList)
{
text += str;
}
System.DateTime now = System.DateTime.Now;
logList.Add(now.ToLongTimeString() + " " + msg + Environment.NewLine);
if (logBox == null)
{
return;
}
LastText = text;
if (logBox.Visible)
{
logBox.Text = text;
// logBox.Focus(); //使文本框获取焦点
logBox.AppendText(now.ToLongTimeString() + " " + msg + Environment.NewLine); //增加文本
TimeSpan span = DateTime.Now - lastTime;
if (span.TotalSeconds > 3000000)
{
lastTime = DateTime.Now;
logBox.Select(logBox.Text.Length, 0); //设置光标的位置到文本尾
logBox.ScrollToCaret(); //滚动到控件光标处
}
}
}
catch (AccessViolationException e)
{
LOGGER.Error(" ShowLogPro 出错:" + e.ToString());
}
catch (Exception ex)
{
LOGGER.Error("出错:" + ex.ToString());
}
}
private static DateTime lastTime = DateTime.Now;
public static void UpdateLogbox()
{
if (logBox != null && logBox.Visible)
{
logBox.Text = LastText;
TimeSpan span = DateTime.Now - lastTime;
if (span.TotalSeconds > 3000000)
{
lastTime = DateTime.Now;
logBox.Select(logBox.Text.Length, 0); //设置光标的位置到文本尾
logBox.ScrollToCaret(); //滚动到控件光标处
}
}
}
public static void ClearLog()
{
if (logBox != null)
{
LastText = "";
logList.Clear();
logBox.Text = "";
}
}
public static void debug(string msg)
{
debug(LOGGER, msg);
}
public static void error(string errorMsg, Exception ex = null)
{
error(LOGGER, errorMsg, ex);
}
public static void info(string msg)
{
info(LOGGER, msg);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C9575C5E-9D4B-4B4F-BE41-926652B8985F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HuichuanLibrary</RootNamespace>
<AssemblyName>HuichuanLibrary</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\dll\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="FrmHuiChuanTest.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmHuiChuanTest.Designer.cs">
<DependentUpon>FrmHuiChuanTest.cs</DependentUpon>
</Compile>
<Compile Include="HCBoardManager.cs" />
<Compile Include="HCBoardManager_Axis.cs" />
<Compile Include="ImcApi.cs" />
<Compile Include="HCLogUtil.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="huichuan\x64\IMC_API_x64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="huichuan\x64\msvcr100.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="huichuan\x64\msvcr100d.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="huichuan\x86\IMC_API_x86.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="huichuan\x86\msvcr100.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="huichuan\x86\msvcr100d.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="huichuan\x64\IMC_API_x64.lib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="huichuan\x86\IMC_API_x86.lib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="FrmHuiChuanTest.resx">
<DependentUpon>FrmHuiChuanTest.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file
此文件的差异太大,无法显示。
using log4net;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace HuichuanLibrary
{
public class LogUtil
{
public static ILog LOGGER = LogManager.GetLogger("RollingLogFileAppender");
public static ConcurrentDictionary<int, DateTime> lastErrorLogTime = new ConcurrentDictionary<int, DateTime>();
public static System.Windows.Forms.RichTextBox logBox = null;
public static int showCount = 15;
public static bool debug_opened = false;
public static void info(ILog log, string msg)
{
if (log == null)
{
return;
}
log.Info(msg);
AddToBox(msg, Color.Black);
//clear();
}
public static void info(ILog log, string msg, Color color)
{
log.Info(msg);
AddToBox(msg, color);
}
public static void debug(ILog log, string msg, Color color)
{
log.Debug(msg);
if (debug_opened)
{
AddToBox(msg, color);
}
}
public static void debug(ILog log, string msg)
{
log.Debug(msg);
if (debug_opened)
{
AddToBox(msg, Color.Gray);
}
}
public static void error(string errorMsg, int type, int seconds = 10)
{
try
{
if (lastErrorLogTime.ContainsKey(type))
{
TimeSpan span = DateTime.Now - lastErrorLogTime[type];
if (span.TotalSeconds > seconds)
{
lastErrorLogTime[type] = DateTime.Now;
error(LOGGER, errorMsg);
}
}
else
{
lastErrorLogTime.TryAdd(type, DateTime.Now);
error(LOGGER, errorMsg);
}
}
catch (Exception ex)
{
LOGGER.Error(" 打印日志【" + type + "-" + errorMsg + "】出错:" + ex.ToString());
}
}
public static void error(ILog log, string errorMsg, Exception ex = null)
{
if (errorMsg.Trim().Equals("") && (ex == null))
{
return;
}
if (ex == null)
{
log.Error(errorMsg);
}
else
{
log.Error(errorMsg, ex);
}
AddToBox(errorMsg, Color.Red);
}
private static object lockObj = "";
private static void AddToBox(string msg, Color color)
{
if (Monitor.TryEnter(lockObj, 2))
{
try
{
ShowLogPro(msg, color);
}
catch (Exception ex)
{
LOGGER.Error("出错:", ex);
}
finally
{
Monitor.Exit(lockObj);
}
}
else
{
LOGGER.Debug("ShowLogPro【" + msg + "】失败,未得到锁");
}
}
private static List<string> logList = new List<string>();
public static string LastText = "";
[HandleProcessCorruptedStateExceptions]
private static void ShowLogPro(string msg, Color color)
{
try
{
if (logList.Count >= showCount)
{
logList.RemoveAt(0);
}
string text = "";
foreach (string str in logList)
{
text += str;
}
System.DateTime now = System.DateTime.Now;
logList.Add(now.ToLongTimeString() + " " + msg + Environment.NewLine);
if (logBox == null)
{
return;
}
LastText = text;
if (logBox.Visible)
{
logBox.Text = text;
// logBox.Focus(); //使文本框获取焦点
logBox.AppendText(now.ToLongTimeString() + " " + msg + Environment.NewLine); //增加文本
TimeSpan span = DateTime.Now - lastTime;
if (span.TotalSeconds > 3000000)
{
lastTime = DateTime.Now;
logBox.Select(logBox.Text.Length, 0); //设置光标的位置到文本尾
logBox.ScrollToCaret(); //滚动到控件光标处
}
}
}
catch (AccessViolationException e)
{
LOGGER.Error(" ShowLogPro 出错:" + e.ToString());
}
catch (Exception ex)
{
LOGGER.Error("出错:" + ex.ToString());
}
}
private static DateTime lastTime = DateTime.Now;
public static void UpdateLogbox()
{
if (logBox != null && logBox.Visible)
{
logBox.Text = LastText;
TimeSpan span = DateTime.Now - lastTime;
if (span.TotalSeconds > 3000000)
{
lastTime = DateTime.Now;
logBox.Select(logBox.Text.Length, 0); //设置光标的位置到文本尾
logBox.ScrollToCaret(); //滚动到控件光标处
}
}
}
public static void ClearLog()
{
if (logBox != null)
{
LastText = "";
logList.Clear();
logBox.Text = "";
}
}
public static void debug(string msg)
{
debug(LOGGER, msg);
}
public static void error(string errorMsg, Exception ex = null)
{
error(LOGGER, errorMsg, ex);
}
public static void info(string msg)
{
info(LOGGER, msg);
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("HuichuanLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HuichuanLibrary")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("c9575c5e-9d4b-4b4f-be41-926652b8985f")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
此文件类型无法预览
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!