Commit c4766ffe 几米阳光

伺服通信模式修改。扫码模式修改。

1 个父辈 b1f19f32
此文件类型无法预览
此文件类型无法预览
...@@ -38,15 +38,25 @@ ...@@ -38,15 +38,25 @@
<ApplicationIcon>box.ico</ApplicationIcon> <ApplicationIcon>box.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Basler.Pylon, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e389355f398382ab, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\Basler.Pylon.dll</HintPath>
</Reference>
<Reference Include="CodeLibrary"> <Reference Include="CodeLibrary">
<HintPath>..\..\dll\CodeLibrary.dll</HintPath> <HintPath>..\..\dll\CodeLibrary.dll</HintPath>
</Reference> </Reference>
<Reference Include="DataMatrix.net">
<HintPath>..\..\dll\DataMatrix.net.dll</HintPath>
</Reference>
<Reference Include="halcondotnet"> <Reference Include="halcondotnet">
<HintPath>..\..\dll\halcondotnet.dll</HintPath> <HintPath>..\..\dll\halcondotnet.dll</HintPath>
</Reference> </Reference>
<Reference Include="log4net"> <Reference Include="log4net">
<HintPath>..\..\dll\log4net.dll</HintPath> <HintPath>..\..\dll\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="MvCameraControl.Net">
<HintPath>..\..\dll\MvCameraControl.Net.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.ServiceModel" /> <Reference Include="System.ServiceModel" />
...@@ -73,12 +83,6 @@ ...@@ -73,12 +83,6 @@
<Compile Include="FrmBase.Designer.cs"> <Compile Include="FrmBase.Designer.cs">
<DependentUpon>FrmBase.cs</DependentUpon> <DependentUpon>FrmBase.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="FrmCamera.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmCamera.Designer.cs">
<DependentUpon>FrmCamera.cs</DependentUpon>
</Compile>
<Compile Include="FrmIOStatus.cs"> <Compile Include="FrmIOStatus.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
...@@ -100,9 +104,6 @@ ...@@ -100,9 +104,6 @@
<EmbeddedResource Include="FrmBase.resx"> <EmbeddedResource Include="FrmBase.resx">
<DependentUpon>FrmBase.cs</DependentUpon> <DependentUpon>FrmBase.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="FrmCamera.resx">
<DependentUpon>FrmCamera.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmIOStatus.resx"> <EmbeddedResource Include="FrmIOStatus.resx">
<DependentUpon>FrmIOStatus.cs</DependentUpon> <DependentUpon>FrmIOStatus.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
......
...@@ -300,6 +300,7 @@ namespace OnlineStore.ACSingleStore ...@@ -300,6 +300,7 @@ namespace OnlineStore.ACSingleStore
lblServerOn.Text = "伺服OFF"; lblServerOn.Text = "伺服OFF";
} }
string deviceName = GetPortName(); string deviceName = GetPortName();
short slvValue=(short) GetSlaveAddr();
if (ACServerManager.ServerOnStatus(store.Config.Middle_Axis.DeviceName, store.Config.Middle_Axis.GetAxisValue())) 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.IOValue = ACServerManager.GetAlarmStatus(store.Config.Middle_Axis.DeviceName, store.Config.Middle_Axis.GetAxisValue());
...@@ -309,7 +310,8 @@ namespace OnlineStore.ACSingleStore ...@@ -309,7 +310,8 @@ namespace OnlineStore.ACSingleStore
int lCountPulse1 = ACServerManager.GetActualtPosition(store.Config.Middle_Axis.DeviceName, store.Config.Middle_Axis.GetAxisValue()); int lCountPulse1 = ACServerManager.GetActualtPosition(store.Config.Middle_Axis.DeviceName, store.Config.Middle_Axis.GetAxisValue());
lblCountPulse1.Text = string.Format("{0:d}", lCountPulse1); lblCountPulse1.Text = string.Format("{0:d}", lCountPulse1);
txtMiddleTarget.Text = store.Config.Middle_Axis.TargetPosition.ToString(); txtMiddleTarget.Text = store.Config.Middle_Axis.TargetPosition.ToString();
if (deviceName.Equals(store.Config.Middle_Axis.DeviceName)) //if (deviceName.Equals(store.Config.Middle_Axis.DeviceName))
if (store.Config.Middle_Axis.IsSameAxis(deviceName, slvValue))
{ {
lblOutPulse.Text = lblOutPulse1.Text; lblOutPulse.Text = lblOutPulse1.Text;
lblCountPulse.Text = lblCountPulse1.Text; lblCountPulse.Text = lblCountPulse1.Text;
...@@ -324,8 +326,9 @@ namespace OnlineStore.ACSingleStore ...@@ -324,8 +326,9 @@ namespace OnlineStore.ACSingleStore
int lCountPulse2 = ACServerManager.GetActualtPosition(store.Config.UpDown_Axis.DeviceName, store.Config.UpDown_Axis.GetAxisValue()); int lCountPulse2 = ACServerManager.GetActualtPosition(store.Config.UpDown_Axis.DeviceName, store.Config.UpDown_Axis.GetAxisValue());
lblCountPulse2.Text = string.Format("{0:d}", lCountPulse2); lblCountPulse2.Text = string.Format("{0:d}", lCountPulse2);
txtInoutTarget.Text = store.Config.InOut_Axis.TargetPosition.ToString(); txtInoutTarget.Text = store.Config.InOut_Axis.TargetPosition.ToString();
if (deviceName.Equals(store.Config.UpDown_Axis.DeviceName)) //if (deviceName.Equals(store.Config.UpDown_Axis.DeviceName))
{ if (store.Config.UpDown_Axis.IsSameAxis(deviceName, slvValue))
{
lblOutPulse.Text = lblOutPulse2.Text; lblOutPulse.Text = lblOutPulse2.Text;
lblCountPulse.Text = lblCountPulse2.Text; lblCountPulse.Text = lblCountPulse2.Text;
} }
...@@ -338,7 +341,8 @@ namespace OnlineStore.ACSingleStore ...@@ -338,7 +341,8 @@ namespace OnlineStore.ACSingleStore
int lCountPulse3 = ACServerManager.GetActualtPosition(store.Config.InOut_Axis.DeviceName, store.Config.InOut_Axis.GetAxisValue()); int lCountPulse3 = ACServerManager.GetActualtPosition(store.Config.InOut_Axis.DeviceName, store.Config.InOut_Axis.GetAxisValue());
lblCountPulse3.Text = string.Format("{0:d}", lCountPulse3); lblCountPulse3.Text = string.Format("{0:d}", lCountPulse3);
txtUpdownTarget.Text = store.Config.UpDown_Axis.TargetPosition.ToString(); txtUpdownTarget.Text = store.Config.UpDown_Axis.TargetPosition.ToString();
if (deviceName.Equals(store.Config.InOut_Axis.DeviceName)) //if (deviceName.Equals(store.Config.InOut_Axis.DeviceName))
if (store.Config.InOut_Axis.IsSameAxis(deviceName, slvValue))
{ {
lblOutPulse.Text = lblOutPulse3.Text; lblOutPulse.Text = lblOutPulse3.Text;
lblCountPulse.Text = lblCountPulse3.Text; lblCountPulse.Text = lblCountPulse3.Text;
...@@ -502,7 +506,8 @@ namespace OnlineStore.ACSingleStore ...@@ -502,7 +506,8 @@ namespace OnlineStore.ACSingleStore
// MessageBox.Show("位置超出" + axisC.Explain + "上下限(" + axisC.PositionMin + "-" + axisC.PositionMax + ")"); // MessageBox.Show("位置超出" + axisC.Explain + "上下限(" + axisC.PositionMin + "-" + axisC.PositionMax + ")");
// return; // return;
//} //}
if (portName.Equals(store.Config.InOut_Axis.DeviceName) && (store.LoacationIsDown().Equals(false))) //if (portName.Equals(store.Config.InOut_Axis.DeviceName) && (store.LoacationIsDown().Equals(false)))
if (store.Config.InOut_Axis.IsSameAxis(portName, SlvAddr) && (store.LoacationIsDown().Equals(false)))
{ {
MessageBox.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return; return;
...@@ -516,7 +521,8 @@ namespace OnlineStore.ACSingleStore ...@@ -516,7 +521,8 @@ namespace OnlineStore.ACSingleStore
string portName = txtAxisDeviceName.Text; string portName = txtAxisDeviceName.Text;
short SlvAddr = FormUtil.GetShortValue(txtAxisValue); short SlvAddr = FormUtil.GetShortValue(txtAxisValue);
int speed = FormUtil.GetIntValue(txtASpeed); int speed = FormUtil.GetIntValue(txtASpeed);
if (portName.Equals(store.Config.InOut_Axis.DeviceName) && (store.LoacationIsDown().Equals(false))) //if (portName.Equals(store.Config.InOut_Axis.DeviceName) && (store.LoacationIsDown().Equals(false)))
if (store.Config.InOut_Axis.IsSameAxis(portName, SlvAddr) && (store.LoacationIsDown().Equals(false)))
{ {
MessageBox.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return; return;
...@@ -540,7 +546,8 @@ namespace OnlineStore.ACSingleStore ...@@ -540,7 +546,8 @@ namespace OnlineStore.ACSingleStore
// return; // return;
//} //}
if (portName.Equals(store.Config.InOut_Axis.DeviceName) && (store.LoacationIsDown().Equals(false))) //if (portName.Equals(store.Config.InOut_Axis.DeviceName) && (store.LoacationIsDown().Equals(false)))
if (store.Config.InOut_Axis.IsSameAxis(portName, SlvAddr) && (store.LoacationIsDown().Equals(false)))
{ {
MessageBox.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("定位气缸不在下降端,不能移动进出轴", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return; return;
...@@ -833,6 +840,7 @@ namespace OnlineStore.ACSingleStore ...@@ -833,6 +840,7 @@ namespace OnlineStore.ACSingleStore
{ {
int currIndex = cmbPosition.SelectedIndex; int currIndex = cmbPosition.SelectedIndex;
store.autoPositionIndex = currIndex; store.autoPositionIndex = currIndex;
store.AutoStartIndex = currIndex;
string poText = cmbPosition.Text; string poText = cmbPosition.Text;
store.autoMsg = "自动出库:" + poText; store.autoMsg = "自动出库:" + poText;
LogUtil.info(LOGGER, store.StoreName + "开启自动出入库模式,开始位置【" + poText + "】(索引=" + currIndex + "),间隔=" + jiange + ",入库开始!"); LogUtil.info(LOGGER, store.StoreName + "开启自动出入库模式,开始位置【" + poText + "】(索引=" + currIndex + "),间隔=" + jiange + ",入库开始!");
...@@ -929,11 +937,16 @@ namespace OnlineStore.ACSingleStore ...@@ -929,11 +937,16 @@ namespace OnlineStore.ACSingleStore
{ {
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH); store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string message = ""; string message = "";
List<string> codeList = HDevelopExport.CameraScan(); //List<string> codeList = HDevelopExport.CameraScan();
//foreach (string str in codeList)
//{
// string code = HDevelopExport.SubStrCode(str);
// message = message + code + "##";
//}
List<string> codeList = CodeManager.CameraScan();
foreach (string str in codeList) foreach (string str in codeList)
{ {
string code = HDevelopExport.SubStrCode(str); message = message + str + "##";
message = message + code + "##";
} }
LogUtil.info("扫码测试收到二维码:" + message); LogUtil.info("扫码测试收到二维码:" + message);
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW); store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
...@@ -1015,7 +1028,7 @@ namespace OnlineStore.ACSingleStore ...@@ -1015,7 +1028,7 @@ namespace OnlineStore.ACSingleStore
{ {
msg = ""; msg = "";
string deviceName = moveAxis.DeviceName; string deviceName = moveAxis.DeviceName;
short axisNo = moveAxis.GetAxisValue(); int axisNo = moveAxis.GetAxisValue();
bool isend = ACServerManager.GetBusyStatus(deviceName, axisNo).Equals(0); bool isend = ACServerManager.GetBusyStatus(deviceName, axisNo).Equals(0);
int outCount = ACServerManager.GetActualtPosition(deviceName, axisNo); int outCount = ACServerManager.GetActualtPosition(deviceName, axisNo);
...@@ -1024,7 +1037,7 @@ namespace OnlineStore.ACSingleStore ...@@ -1024,7 +1037,7 @@ namespace OnlineStore.ACSingleStore
{ {
if (errorCount > moveAxis.CanErrorCountMax) if (errorCount > moveAxis.CanErrorCountMax)
{ {
msg = " DeviceName=" + deviceName + ",AxisNo=" + axisNo + ",targetPosition=" + targetPosition + ",targetSpeed=" + targetSpeed + ",当前outCount=" + outCount + ",误差值大于最大误差【" + moveAxis.CanErrorCountMax + "】,但是轴已经停止运动,需要报警"; msg =moveAxis.Explain + ",targetPosition=" + targetPosition + ",targetSpeed=" + targetSpeed + ",当前outCount=" + outCount + ",误差值大于最大误差【" + moveAxis.CanErrorCountMax + "】,但是轴已经停止运动,需要报警";
LogUtil.error(LOGGER, msg); LogUtil.error(LOGGER, msg);
return false; return false;
} }
...@@ -1216,19 +1229,27 @@ namespace OnlineStore.ACSingleStore ...@@ -1216,19 +1229,27 @@ namespace OnlineStore.ACSingleStore
} }
} }
private void 摄像机调试ToolStripMenuItem_Click(object sender, EventArgs e) //private void 摄像机调试ToolStripMenuItem_Click(object sender, EventArgs e)
{ //{
FrmCamera frm = new FrmCamera(store); // FrmCamera frm = new FrmCamera(store);
frm.ShowDialog(); // frm.ShowDialog();
} //}
private void 学习二维码ToolStripMenuItem_Click(object sender, EventArgs e) private void 学习二维码ToolStripMenuItem_Click(object sender, EventArgs e)
{ {
//string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName);
//string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType);
//HDCodeLearnHelper.LoadConfig(nameStr, codeStr);
//FrmCodeLearn learn = new FrmCodeLearn();
//learn.ShowDialog();
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName); string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName);
string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType); string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType);
HDCodeLearnHelper.LoadConfig(nameStr, codeStr); HDCodeLearnHelper.LoadConfig(nameStr, codeStr);
FrmCodeLearn learn = new FrmCodeLearn(); FrmCodeLearn learn = new FrmCodeLearn();
learn.ShowDialog(); learn.ShowDialog();
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
} }
private void btnReadHomeSingle_Click(object sender, EventArgs e) private void btnReadHomeSingle_Click(object sender, EventArgs e)
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<Compile Include="acSingleStore\AC_SA_BoxBean.cs" /> <Compile Include="acSingleStore\AC_SA_BoxBean.cs" />
<Compile Include="acSingleStore\AC_SA_BoxBean_Partial.cs" /> <Compile Include="acSingleStore\AC_SA_BoxBean_Partial.cs" />
<Compile Include="acSingleStore\ACStoreManager.cs" /> <Compile Include="acSingleStore\ACStoreManager.cs" />
<Compile Include="halcon\HDevelopExport.cs" /> <Compile Include="halcon\CodeManager.cs" />
<Compile Include="KangNaiDe\KNDManager.cs" /> <Compile Include="KangNaiDe\KNDManager.cs" />
<Compile Include="KangNaiDe\MasterTcpClient.cs" /> <Compile Include="KangNaiDe\MasterTcpClient.cs" />
<Compile Include="PanasonicServo\ACCMDManager.cs" /> <Compile Include="PanasonicServo\ACCMDManager.cs" />
......
...@@ -314,8 +314,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -314,8 +314,10 @@ namespace OnlineStore.DeviceLibrary
} }
else if (dataByte.Length == 2) else if (dataByte.Length == 2)
{ {
sendData[4] = dataByte[1]; sendData[4] = dataByte[0];
sendData[5] = dataByte[0]; sendData[5] = dataByte[1];
//sendData[4] = dataByte[1];
//sendData[5] = dataByte[0];
} }
sendData = buildCheckData(sendData, sendData.Length - 2); sendData = buildCheckData(sendData, sendData.Length - 2);
......
...@@ -19,13 +19,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -19,13 +19,14 @@ namespace OnlineStore.DeviceLibrary
private static Dictionary<string, Dictionary<string, int>> ComAddrValue = new Dictionary<string, Dictionary<string, int>>(); private static Dictionary<string, Dictionary<string, int>> ComAddrValue = new Dictionary<string, Dictionary<string, int>>();
private static string mapObj = ""; private static string mapObj = "";
private static int GetAddrValue(string portName, string addr) private static int GetAddrValue(string portName,int slvAddr, string addr)
{ {
int value = -1; int value = -1;
try try
{ {
string name = portName + "_" + slvAddr;
Dictionary<string, int> map = null; Dictionary<string, int> map = null;
ComAddrValue.TryGetValue(portName, out map); ComAddrValue.TryGetValue(name, out map);
if (map == null) if (map == null)
{ {
return -1; return -1;
...@@ -41,27 +42,28 @@ namespace OnlineStore.DeviceLibrary ...@@ -41,27 +42,28 @@ namespace OnlineStore.DeviceLibrary
} }
return value; return value;
} }
private static void UpdateAddrValue(string portName, string addr, int value) private static void UpdateAddrValue(string portName,int slvAddr, string addr, int value)
{ {
try try
{ {
lock (mapObj) lock (mapObj)
{ {
string name = portName + "_" + slvAddr;
Dictionary<string, int> map = null; Dictionary<string, int> map = null;
ComAddrValue.TryGetValue(portName, out map); ComAddrValue.TryGetValue(name, out map);
if (map == null) if (map == null)
{ {
map = new Dictionary<string, int>(); map = new Dictionary<string, int>();
ComAddrValue.Add(portName, map); ComAddrValue.Add(name, map);
} }
if (map.ContainsKey(addr)) if (map.ContainsKey(addr))
{ {
ComAddrValue[portName][addr] = value; ComAddrValue[name][addr] = value;
} }
else else
{ {
ComAddrValue[portName].Add(addr, value); ComAddrValue[name].Add(addr, value);
} }
} }
} }
...@@ -309,12 +311,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -309,12 +311,14 @@ namespace OnlineStore.DeviceLibrary
if (isHomeEnd.Equals(1)) if (isHomeEnd.Equals(1))
{ {
int value = 2000; int value = 2000;
if (portName.Equals(ACStoreManager.store.Config.Middle_Axis.DeviceName) || //if (portName.Equals(ACStoreManager.store.Config.Middle_Axis.DeviceName) ||
portName.Equals(ACStoreManager.store.Config.InOut_Axis.DeviceName)) // portName.Equals(ACStoreManager.store.Config.InOut_Axis.DeviceName))
if(ACStoreManager.store.Config.Middle_Axis.IsSameAxis(portName, slvAddr) ||
ACStoreManager.store.Config.InOut_Axis.IsSameAxis(portName,slvAddr))
{ {
value = -2000; value = -2000;
} }
LogUtil.info("轴【" + portName + "】原点返回时发现原点已亮且回过原点,需要先相对走" + value); LogUtil.info("轴【" + portName +"_"+ slvAddr + "】原点返回时发现原点已亮且回过原点,需要先相对走" + value);
RelMove(portName, slvAddr, value); RelMove(portName, slvAddr, value);
bool isStop = false; bool isStop = false;
for (int i = 0; i <= 10; i++) for (int i = 0; i <= 10; i++)
...@@ -323,13 +327,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -323,13 +327,13 @@ namespace OnlineStore.DeviceLibrary
if (GetBusyStatus(portName, slvAddr).Equals(0)) if (GetBusyStatus(portName, slvAddr).Equals(0))
{ {
isStop = true; isStop = true;
LogUtil.info("轴【" + portName + "相对走" + value + "已结束"); LogUtil.info("轴【" + portName + "_" + slvAddr + "】相对走" + value + "已结束");
break; break;
} }
} }
if (!isStop) if (!isStop)
{ {
LogUtil.info("轴【" + portName + "相对走" + value + "已等待2分钟,直接停止"); LogUtil.info("轴【" + portName + "_" + slvAddr + "】相对走" + value + "已等待2分钟,直接停止");
SuddenStop(portName, slvAddr); SuddenStop(portName, slvAddr);
} }
} }
...@@ -337,15 +341,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -337,15 +341,15 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("轴【" + portName + "】原点返回前验证是否在原点出错:" + ex.StackTrace); LogUtil.error("轴【" + portName + "_" + slvAddr + "】原点返回前验证是否在原点出错:" + ex.StackTrace);
} }
//旋转轴回正方向,其他轴回负方向 //旋转轴回正方向,其他轴回负方向
if (portName.Equals(ACStoreManager.store.Config.Middle_Axis.DeviceName)) if (ACStoreManager.store.Config.Middle_Axis.IsSameAxis(portName, slvAddr))
{ {
UpdateBlock(portName, slvAddr, ACCMDManager.Block_HomeMove0); UpdateBlock(portName, slvAddr, ACCMDManager.Block_HomeMove0);
LogUtil.info("旋转轴原点返回方向:正方向"); LogUtil.info("旋转轴原点返回方向:正方向");
} }
else if (portName.Equals(ACStoreManager.store.Config.InOut_Axis.DeviceName)) else if (ACStoreManager.store.Config.InOut_Axis.IsSameAxis(portName, slvAddr))
{ {
UpdateBlock(portName, slvAddr, ACCMDManager.Block_HomeMove0); UpdateBlock(portName, slvAddr, ACCMDManager.Block_HomeMove0);
LogUtil.info("进出轴原点返回方向:正方向"); LogUtil.info("进出轴原点返回方向:正方向");
...@@ -361,28 +365,22 @@ namespace OnlineStore.DeviceLibrary ...@@ -361,28 +365,22 @@ namespace OnlineStore.DeviceLibrary
public static void SpeedMove(string portName, int slvAddr, int speed) public static void SpeedMove(string portName, int slvAddr, int speed)
{ {
int preSpeed = GetAddrValue(portName, ACCMDManager.Speed_Addr); int preSpeed = GetAddrValue(portName,slvAddr, ACCMDManager.Speed_Addr);
if ((preSpeed.Equals(-1)) || (!preSpeed.Equals(Math.Abs(speed)))) if ((preSpeed.Equals(-1)) || (!preSpeed.Equals(Math.Abs(speed))))
{ {
byte[] data = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteRegisters, "4601", string.Format("{0:X2}", Math.Abs(speed)), 2); byte[] data = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteRegisters, "4601", string.Format("{0:X2}", Math.Abs(speed)), 2);
SendData(portName, data); SendData(portName, data);
UpdateAddrValue(portName, ACCMDManager.Speed_Addr, Math.Abs(speed)); UpdateAddrValue(portName,slvAddr, ACCMDManager.Speed_Addr, Math.Abs(speed));
Thread.Sleep(SleepMSendons); Thread.Sleep(SleepMSendons);
} }
if (speed > 0) if (speed > 0)
{ {
//byte[] data = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteRegisters, ACCMDManager.BlockNo, ACCMDManager.Block_VolMove0, 2);
//SendData(portName, data);
UpdateBlock(portName, slvAddr, ACCMDManager.Block_VolMove0); UpdateBlock(portName, slvAddr, ACCMDManager.Block_VolMove0);
} }
else else
{ {
//byte[] data = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteRegisters, ACCMDManager.BlockNo, ACCMDManager.Block_VolMove1, 2);
//SendData(portName, data);
UpdateBlock(portName, slvAddr, ACCMDManager.Block_VolMove1); UpdateBlock(portName, slvAddr, ACCMDManager.Block_VolMove1);
} }
//Thread.Sleep(SleepMSendons);
OpenAndCloseSTB(portName, slvAddr); OpenAndCloseSTB(portName, slvAddr);
} }
public static void AbsMove(string portName, int slvAddr, int targetPosition, int targetSpeed) public static void AbsMove(string portName, int slvAddr, int targetPosition, int targetSpeed)
...@@ -390,13 +388,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -390,13 +388,13 @@ namespace OnlineStore.DeviceLibrary
//先更新速度 //先更新速度
string slvAddrStr = string.Format(strFromat, slvAddr); string slvAddrStr = string.Format(strFromat, slvAddr);
int preSpeed = GetAddrValue(portName, ACCMDManager.Speed_Addr); int preSpeed = GetAddrValue(portName,slvAddr, ACCMDManager.Speed_Addr);
if ((preSpeed.Equals(-1)) || (!preSpeed.Equals(targetSpeed))) if ((preSpeed.Equals(-1)) || (!preSpeed.Equals(targetSpeed)))
{ {
//速度 V1 =100 //速度 V1 =100
string v1 = slvAddrStr + "064601 " + SpeedToStr(targetSpeed, 4) + " ffff"; string v1 = slvAddrStr + "064601 " + SpeedToStr(targetSpeed, 4) + " ffff";
SendStrAndSleep(portName, v1, SleepMSendons); SendStrAndSleep(portName, v1, SleepMSendons);
UpdateAddrValue(portName, ACCMDManager.Speed_Addr, targetSpeed); UpdateAddrValue(portName,slvAddr, ACCMDManager.Speed_Addr, targetSpeed);
} }
//绝对运动 //绝对运动
AbsMove(portName, slvAddr, targetPosition); AbsMove(portName, slvAddr, targetPosition);
...@@ -442,9 +440,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -442,9 +440,7 @@ namespace OnlineStore.DeviceLibrary
SendData(portName, data); SendData(portName, data);
Thread.Sleep(SleepMSendons); Thread.Sleep(SleepMSendons);
UpdateBlock(portName, slvAddr, ACCMDManager.Block_AbsMove); 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); OpenAndCloseSTB(portName, slvAddr);
} }
} }
......
...@@ -260,6 +260,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -260,6 +260,7 @@ namespace OnlineStore.DeviceLibrary
else else
{ {
bean.SendCommand(data, ref returnData, outTime, reviceLength); bean.SendCommand(data, ref returnData, outTime, reviceLength);
System.Threading.Thread.Sleep(2);
} }
} }
catch (Exception ex) catch (Exception ex)
...@@ -323,6 +324,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -323,6 +324,7 @@ namespace OnlineStore.DeviceLibrary
OnlyOpenSTB(portName, slvAddr); OnlyOpenSTB(portName, slvAddr);
System.Threading.Thread.Sleep(100); System.Threading.Thread.Sleep(100);
CloseSTB(portName, slvAddr); CloseSTB(portName, slvAddr);
System.Threading.Thread.Sleep(100);
} }
public static void OnlyOpenSTB(string portName, int slvAddr) public static void OnlyOpenSTB(string portName, int slvAddr)
...@@ -344,13 +346,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -344,13 +346,13 @@ namespace OnlineStore.DeviceLibrary
public static void UpdateBlock(string portName, int slvAddr, string blockNum) public static void UpdateBlock(string portName, int slvAddr, string blockNum)
{ {
int preNum = GetAddrValue(portName, ACCMDManager.BlockNo); int preNum = GetAddrValue(portName,slvAddr, ACCMDManager.BlockNo);
if (preNum.Equals(-1) || (!preNum.ToString().Equals(blockNum))) if (preNum.Equals(-1) || (!preNum.ToString().Equals(blockNum)))
{ {
byte[] data = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteRegisters, ACCMDManager.BlockNo, blockNum , 2); byte[] data = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_WriteRegisters, ACCMDManager.BlockNo, blockNum , 2);
SendData(portName, data); SendData(portName, data);
int value = Convert.ToInt16(blockNum); int value = Convert.ToInt16(blockNum);
UpdateAddrValue(portName, ACCMDManager.BlockNo, value); UpdateAddrValue(portName,slvAddr, ACCMDManager.BlockNo, value);
Thread.Sleep(SleepMSendons); Thread.Sleep(SleepMSendons);
} }
} }
...@@ -415,7 +417,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -415,7 +417,7 @@ namespace OnlineStore.DeviceLibrary
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadRegisters, ACCMDManager.TargetPostion, "0000", 2); byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadRegisters, ACCMDManager.TargetPostion, "0000", 2);
// SendData(portName,dataArray); // SendData(portName,dataArray);
byte[] reviceData = SendCommand(portName, dataArray, 100, 9); byte[] reviceData = SendCommand(portName, dataArray, 100, 9);
return GetRegisterData(portName, reviceData, ACCMDManager.TargetPostion); return GetRegisterData(portName, reviceData, ACCMDManager.TargetPostion);
} }
public static int GetActualtPosition(string portName, int slvAddr) public static int GetActualtPosition(string portName, int slvAddr)
...@@ -424,7 +426,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -424,7 +426,7 @@ namespace OnlineStore.DeviceLibrary
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadRegisters, ACCMDManager.ActualPosition, "0000", 2); byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadRegisters, ACCMDManager.ActualPosition, "0000", 2);
// SendData(portName,dataArray); // SendData(portName,dataArray);
byte[] reviceData = SendCommand(portName, dataArray, 100, 9); byte[] reviceData = SendCommand(portName, dataArray, 100, 9);
return GetRegisterData(portName, reviceData, ACCMDManager.ActualPosition); return GetRegisterData(portName, reviceData, ACCMDManager.ActualPosition);
} }
...@@ -463,7 +465,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -463,7 +465,7 @@ namespace OnlineStore.DeviceLibrary
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, PreReadCoilAddr, "0000", 1); byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, PreReadCoilAddr, "0000", 1);
//SendData(portName,dataArray); //SendData(portName,dataArray);
byte[] reviceData = SendCommand(portName, dataArray, 100, 6); byte[] reviceData = SendCommand(portName, dataArray, 100, 6);
return GetCoilData(portName, reviceData, PreReadCoilAddr); return GetCoilData(portName, reviceData, PreReadCoilAddr);
} }
public static int GetBusyStatus(string portName, int slvAddr) public static int GetBusyStatus(string portName, int slvAddr)
...@@ -472,7 +474,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -472,7 +474,7 @@ namespace OnlineStore.DeviceLibrary
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, ACCMDManager.BUSYStatus, "0000", 1); byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, ACCMDManager.BUSYStatus, "0000", 1);
//SendData(portName,dataArray); //SendData(portName,dataArray);
byte[] reviceData = SendCommand(portName, dataArray, 100, 6); byte[] reviceData = SendCommand(portName, dataArray, 100, 6);
return GetCoilData(portName, reviceData, ACCMDManager.BUSYStatus); return GetCoilData(portName, reviceData, ACCMDManager.BUSYStatus);
} }
public static int GetHomeEndStatus(string portName, int slvAddr) public static int GetHomeEndStatus(string portName, int slvAddr)
...@@ -481,7 +483,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -481,7 +483,7 @@ namespace OnlineStore.DeviceLibrary
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, ACCMDManager.HOME_CMP_Status, "0000", 1); byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadCoil, ACCMDManager.HOME_CMP_Status, "0000", 1);
//SendData(portName,dataArray); //SendData(portName,dataArray);
byte[] reviceData = SendCommand(portName, dataArray, 100, 6); byte[] reviceData = SendCommand(portName, dataArray, 100, 6);
return GetCoilData(portName, reviceData, ACCMDManager.HOME_CMP_Status); return GetCoilData(portName, reviceData, ACCMDManager.HOME_CMP_Status);
} }
public static int GetHomeSingle(string portName, int slvAddr) public static int GetHomeSingle(string portName, int slvAddr)
......
...@@ -31,75 +31,75 @@ DO,相机照明开,CameraLight_Power,110,192.168.200.10,0,相机照明开,Y11,DO-11,0 ...@@ -31,75 +31,75 @@ DO,相机照明开,CameraLight_Power,110,192.168.200.10,0,相机照明开,Y11,DO-11,0
,,,113,192.168.200.10,0,,Y14,DO-14,0 ,,,113,192.168.200.10,0,,Y14,DO-14,0
DO,门禁功能屏蔽,DisableDoorControl,114,192.168.200.10,0,门禁功能屏蔽,Y15,DO-15,0 DO,门禁功能屏蔽,DisableDoorControl,114,192.168.200.10,0,门禁功能屏蔽,Y15,DO-15,0
,,,115,192.168.200.10,0,,Y16,DO-16,0 ,,,115,192.168.200.10,0,,Y16,DO-16,0
AXIS,(轴一)旋转轴,Middle_Axis,1,COM3,0,,,, AXIS,(轴一)旋转轴,Middle_Axis,1,COM1,0,,,,
AXIS,(轴二)升降轴轴,UpDown_Axis,1,COM4,0,,,, AXIS,(轴二)升降轴轴,UpDown_Axis,2,COM1,0,,,,
AXIS,(轴三)进出轴,InOut_Axis,1,COM5,0,,,, AXIS,(轴三)进出轴,InOut_Axis,3,COM1,0,,,,
PRO,温湿度传感器地址,Temperate_ServerAddress,192.168.200.14,,,,,, PRO,温湿度传感器地址,Temperate_ServerAddress,192.168.200.14,,,,,,,,
PRO,扫码枪IP,Scanner_Ip,192.168.200.13,,,,,, PRO,扫码枪IP,Scanner_Ip,192.168.200.13,,,,,,,,
PRO,扫码枪端口号,Scanner_Port,51236,,,,,, PRO,扫码枪端口号,Scanner_Port,51236,,,,,,,,
PRO,升降轴 进料口取料点 P1,UpDownAxis_DoorOPosition_P1,423300,,,,,, PRO,升降轴 进料口取料点 P1,UpDownAxis_DoorOPosition_P1,423300,,,,,,,,
PRO,升降轴 进料口出料前点 P2,UpDownAxis_DoorIPosition_P2,450000,,,,,, PRO,升降轴 进料口出料前点 P2,UpDownAxis_DoorIPosition_P2,450000,,,,,,,,
PRO,升降轴 进料口取料缓冲点 P7,UpDownAxis_DoorOBPosition_P7,450000,,,,,, PRO,升降轴 进料口取料缓冲点 P7,UpDownAxis_DoorOBPosition_P7,450000,,,,,,,,
PRO,升降轴 进料口出料缓冲点 P8,UpDownAxis_DoorIBPosition_P8,423300,,,,,, PRO,升降轴 进料口出料缓冲点 P8,UpDownAxis_DoorIBPosition_P8,423300,,,,,,,,
PRO,旋转轴(轴1)P1 待机原位点,MiddleAxis_P1_Position,-200400,,,,,, PRO,旋转轴(轴1)P1 待机原位点,MiddleAxis_P1_Position,-199999,,,,,,,,
PRO,进出轴(轴3)P1待机原位点,InOutAxis_P1_Position,500,,,,,, PRO,进出轴(轴3)P1待机原位点,InOutAxis_P1_Position,500,,,,,,,,
PRO,押金轴(轴4)P1待机原位点,CompressAxis_P1_Position,0,,,,,, PRO,押金轴(轴4)P1待机原位点,CompressAxis_P1_Position,0,,,,,,,,
PRO,是否使用定位气缸,IsHasLocationCylinder,1,,,,,, PRO,是否使用定位气缸,IsHasLocationCylinder,1,,,,,,,,
PRO,是否有左右侧门,IsHasDoorLimit,0,,,,,, PRO,是否有左右侧门,IsHasDoorLimit,0,,,,,,,,
PRO,是否使用压紧轴(1=使用),IsHasCompress_Axis,0,,,,, , PRO,是否使用压紧轴(1=使用),IsHasCompress_Axis,0,,,,, ,,,
PRO,设备是否处于调试状态(1=调试,0=正常),IsInDebug,0,,,,,, PRO,设备是否处于调试状态(1=调试,0=正常),IsInDebug,0,,,,,,,,
PRO,气压检测IO关闭需要持续的时间,AirCheckSeconds,3,,,,,, PRO,气压检测IO关闭需要持续的时间,AirCheckSeconds,3,,,,,,,,
PRO,温湿度传感器地址,TemperateServer_Port,9001,,,,,, PRO,温湿度传感器地址,TemperateServer_Port,9001,,,,,,,,
PRO,预警温度,WarnTemperate,80,,,,,, PRO,预警温度,WarnTemperate,80,,,,,,,,
PRO,预警湿度,WarnHumidity,80,,,,,, PRO,预警湿度,WarnHumidity,80,,,,,,,,
PRO,(轴一)旋转轴目标速度,MiddleAxis_TargetSpeed,40,,,,,, PRO,(轴一)旋转轴目标速度,MiddleAxis_TargetSpeed,40,,,,,,,,
PRO,(轴一)旋转轴加速度,MiddleAxis_AddSpeed,2500,,,,,, PRO,(轴一)旋转轴加速度,MiddleAxis_AddSpeed,2500,,,,,,,,
PRO,(轴一)旋转轴减速度,MiddleAxis_DelSpeed,2500,,,,,, PRO,(轴一)旋转轴减速度,MiddleAxis_DelSpeed,2500,,,,,,,,
PRO,(轴一)旋转轴原点低速度,MiddleAxis_HomeLowSpeed,800,,,,,, PRO,(轴一)旋转轴原点低速度,MiddleAxis_HomeLowSpeed,800,,,,,,,,
PRO,(轴一)旋转轴原点高速,MiddleAxis_HomeHighSpeed,60,,,,,, PRO,(轴一)旋转轴原点高速,MiddleAxis_HomeHighSpeed,60,,,,,,,,
PRO,(轴一)旋转轴原点加速度,MiddleAxis_HomeAddSpeed,500,,,,,, PRO,(轴一)旋转轴原点加速度,MiddleAxis_HomeAddSpeed,500,,,,,,,,
PRO,(轴二)升降轴轴目标速度,UpdownAxis_TargetSpeed,40,,,,,, PRO,(轴二)升降轴轴目标速度,UpdownAxis_TargetSpeed,40,,,,,,,,
PRO,(轴二)升降轴轴加速度,UpdownAxis_AddSpeed,1500,,,,,, PRO,(轴二)升降轴轴加速度,UpdownAxis_AddSpeed,1500,,,,,,,,
PRO,(轴二)升降轴轴减速度,UpdownAxis_DelSpeed,1500,,,,,, PRO,(轴二)升降轴轴减速度,UpdownAxis_DelSpeed,1500,,,,,,,,
PRO,(轴二)升降轴轴原点低速度,UpdownAxis_HomeLowSpeed,100,,,,,, PRO,(轴二)升降轴轴原点低速度,UpdownAxis_HomeLowSpeed,100,,,,,,,,
PRO,(轴二)升降轴轴原点高速,UpdownAxis_HomeHighSpeed,200,,,,,, PRO,(轴二)升降轴轴原点高速,UpdownAxis_HomeHighSpeed,200,,,,,,,,
PRO,(轴二)升降轴轴原点加速度,UpdownAxis_HomeAddSpeed,200,,,,,, PRO,(轴二)升降轴轴原点加速度,UpdownAxis_HomeAddSpeed,200,,,,,,,,
PRO,(轴三)进出轴目标速度,InoutAxis_TargetSpeed,40,,,,,, PRO,(轴三)进出轴目标速度,InoutAxis_TargetSpeed,40,,,,,,,,
PRO,(轴三)进出轴加速度,InoutAxis_AddSpeed,2500,,,,,, PRO,(轴三)进出轴加速度,InoutAxis_AddSpeed,2500,,,,,,,,
PRO,(轴三)进出轴减速度,InoutAxis_DelSpeed,2500,,,,,, PRO,(轴三)进出轴减速度,InoutAxis_DelSpeed,2500,,,,,,,,
PRO,(轴三)进出轴原点低速,InoutAxis_HomeLowSpeed,20,,,,,, PRO,(轴三)进出轴原点低速,InoutAxis_HomeLowSpeed,20,,,,,,,,
PRO,(轴三)进出轴原点高速,InoutAxis_HomeHighSpeed,60,,,,,, PRO,(轴三)进出轴原点高速,InoutAxis_HomeHighSpeed,60,,,,,,,,
PRO,(轴三)进出轴原点加速度,InoutAxis_HomeAddSpeed,200,,,,,, PRO,(轴三)进出轴原点加速度,InoutAxis_HomeAddSpeed,200,,,,,,,,
PRO,升降轴(轴2)P1速度,UpDownAxis_P1_Speed,800,,,,,, PRO,升降轴(轴2)P1速度,UpDownAxis_P1_Speed,800,,,,,,,,
PRO,升降轴(轴2)P2速度,UpDownAxis_P2_Speed,800,,,,,, PRO,升降轴(轴2)P2速度,UpDownAxis_P2_Speed,800,,,,,,,,
PRO,升降轴(轴2)P3速度,UpDownAxis_P3_Speed,800,,,,,, PRO,升降轴(轴2)P3速度,UpDownAxis_P3_Speed,800,,,,,,,,
PRO,升降轴(轴2)P4速度,UpDownAxis_P4_Speed,200,,,,,, PRO,升降轴(轴2)P4速度,UpDownAxis_P4_Speed,200,,,,,,,,
PRO,升降轴(轴2)P5速度,UpDownAxis_P5_Speed,800,,,,,, PRO,升降轴(轴2)P5速度,UpDownAxis_P5_Speed,800,,,,,,,,
PRO,升降轴(轴2)P6速度,UpDownAxis_P6_Speed,200,,,,,, PRO,升降轴(轴2)P6速度,UpDownAxis_P6_Speed,200,,,,,,,,
PRO,升降轴(轴2)P7速度,UpDownAxis_P7_Speed,200,,,,,, PRO,升降轴(轴2)P7速度,UpDownAxis_P7_Speed,200,,,,,, ,,
PRO,升降轴(轴2)P8速度,UpDownAxis_P8_Speed,200,,,,,, PRO,升降轴(轴2)P8速度,UpDownAxis_P8_Speed,200,,,,,,,,
PRO,旋转轴(轴1)P1速度,MiddleAxis_P1_Speed,400,,,,,, PRO,旋转轴(轴1)P1速度,MiddleAxis_P1_Speed,400,,,,,,,,
PRO,旋转轴(轴1)P2速度,MiddleAxis_P2_Speed,400,,,,,, PRO,旋转轴(轴1)P2速度,MiddleAxis_P2_Speed,400,,,,,,,,
PRO,进出轴(轴3)P1速度,InOutAxis_P1_Speed,150,,,,,, PRO,进出轴(轴3)P1速度,InOutAxis_P1_Speed,150,,,,,,,,
PRO,进出轴(轴3)P2速度,InOutAxis_P2_Speed,150,,,,,, PRO,进出轴(轴3)P2速度,InOutAxis_P2_Speed,150,,,,,,,,
PRO,进出轴(轴3)P3速度,InOutAxis_P3_Speed,150,,,,,, PRO,进出轴(轴3)P3速度,InOutAxis_P3_Speed,150,,,,,,,,
PRO,(轴一)旋转轴停止时可误差的脉冲数的最小值,MiddleAxis_ErrorCountMin,10,,,,,, PRO,(轴一)旋转轴停止时可误差的脉冲数的最小值,MiddleAxis_ErrorCountMin,10,,,,,,,,
PRO,(轴二)升降轴轴停止时可误差的脉冲数的最小值,UpdownAxis_ErrorCountMin,10,,,,,, PRO,(轴二)升降轴轴停止时可误差的脉冲数的最小值,UpdownAxis_ErrorCountMin,10,,,,,, ,,
PRO,(轴三)进出轴停止时可误差的脉冲数的最小值,InoutAxis_ErrorCountMin,10,,,,,, PRO,(轴三)进出轴停止时可误差的脉冲数的最小值,InoutAxis_ErrorCountMin,10,,,,,,,,
PRO,(轴一)旋转轴停止时可误差的脉冲数的最大值,MiddleAxis_ErrorCountMax,1000,,,,,, PRO,(轴一)旋转轴停止时可误差的脉冲数的最大值,MiddleAxis_ErrorCountMax,1000,,,,,,,,
PRO,(轴二)升降轴轴停止时可误差的脉冲数的最大值,UpdownAxis_ErrorCountMax,1000,,,,,, PRO,(轴二)升降轴轴停止时可误差的脉冲数的最大值,UpdownAxis_ErrorCountMax,1000,,,,,,,,
PRO,(轴三)进出轴停止时可误差的脉冲数的最大值,InoutAxis_ErrorCountMax,1000,,,,,, PRO,(轴三)进出轴停止时可误差的脉冲数的最大值,InoutAxis_ErrorCountMax,1000,,,,,,,,
PRO,出入库多少次,会自动重置旋转轴,Box_ResetMCount,1000,,,,,, PRO,出入库多少次,会自动重置旋转轴,Box_ResetMCount,1000,,,,,,,,
PRO,出入库多少次,会自动重置所有轴操作,Box_ResetACount,100,,,,,, PRO,出入库多少次,会自动重置所有轴操作,Box_ResetACount,10000,,,,,,,,
PRO,IO信号超时时间(毫秒),IOSingle_TimerOut,10000,,,,,, PRO,IO信号超时时间(毫秒),IOSingle_TimerOut,10000,,,,,,,,
PRO,是否使用料盘检测信号,IsUse_Tray_Check,0,,,,,, PRO,是否使用料盘检测信号,IsUse_Tray_Check,0,,,,,, ,,
PRO,(轴一)旋转轴最小限位,MiddleAxis_PositionMin,0,,,,,, PRO,(轴一)旋转轴最小限位,MiddleAxis_PositionMin,0,,,,,,,,
PRO,(轴二)升降轴最小限位,UpdownAxis_PositionMin,0,,,,,, PRO,(轴二)升降轴最小限位,UpdownAxis_PositionMin,0,,,,,,,,
PRO,(轴三)进出轴最小限位,InoutAxis_PositionMin,0,,,,,, PRO,(轴三)进出轴最小限位,InoutAxis_PositionMin,0,,,,,,,,
PRO,(轴一)旋转轴最大限位,MiddleAxis_PositionMax,0,,,,,, PRO,(轴一)旋转轴最大限位,MiddleAxis_PositionMax,0,,,,,,,,
PRO,(轴二)升降轴最大限位,UpdownAxis_PositionMax,0,,,,,, PRO,(轴二)升降轴最大限位,UpdownAxis_PositionMax,0,,,,,,,,
PRO,(轴三)进出轴最大限位,InoutAxis_PositionMax,0,,,,,, PRO,(轴三)进出轴最大限位,InoutAxis_PositionMax,0,,,,,,,,
PRO,需要吹气的温度(温度标准),Max_Temperature,0,,,,,, PRO,需要吹气的温度(温度标准),Max_Temperature,0,,,,,,,,
PRO,需要吹气的湿度(湿度标准),Max_Humidity,10,,,,,, PRO,需要吹气的湿度(湿度标准),Max_Humidity,10,,,,,,,,
PRO,每次吹气的时间(分钟),BlowAir_Time,10,,,,,, PRO,每次吹气的时间(分钟),BlowAir_Time,10,,,,,,,,
PRO,两次吹气间隔(分钟),BlowAir_Interval,10,,,,,, PRO,两次吹气间隔(分钟),BlowAir_Interval,10,,,,,,,,
...@@ -85,8 +85,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -85,8 +85,10 @@ namespace OnlineStore.DeviceLibrary
//初始化摄像机配置 //初始化摄像机配置
string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName); string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName);
string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType); string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType);
HDevelopExport.LoadConfig(nameStr,codeStr); //HDevelopExport.LoadConfig(nameStr,codeStr);
CodeManager.LoadConfig(nameStr, codeStr);
//初始化 //连接设备 //初始化 //连接设备
KNDManager.ConnectionKND(Config.DIODeviceNameList); KNDManager.ConnectionKND(Config.DIODeviceNameList);
...@@ -300,9 +302,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -300,9 +302,9 @@ namespace OnlineStore.DeviceLibrary
moveAxisList.Add(Config.UpDown_Axis); moveAxisList.Add(Config.UpDown_Axis);
moveAxisList.Add(Config.InOut_Axis); moveAxisList.Add(Config.InOut_Axis);
this.AxisAlarmCodeMap = new Dictionary<string , AxisAlarmInfo>(); this.AxisAlarmCodeMap = new Dictionary<string , AxisAlarmInfo>();
this.AxisAlarmCodeMap.Add(Config.UpDown_Axis.DeviceName, new AxisAlarmInfo()); this.AxisAlarmCodeMap.Add(Config.UpDown_Axis.GetNameStr(), new AxisAlarmInfo());
this.AxisAlarmCodeMap.Add(Config.InOut_Axis.DeviceName, new AxisAlarmInfo()); this.AxisAlarmCodeMap.Add(Config.InOut_Axis.GetNameStr(), new AxisAlarmInfo());
this.AxisAlarmCodeMap.Add(this.Config.Middle_Axis.DeviceName, new AxisAlarmInfo()); this.AxisAlarmCodeMap.Add(this.Config.Middle_Axis.GetNameStr(), new AxisAlarmInfo());
} }
...@@ -343,10 +345,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -343,10 +345,10 @@ namespace OnlineStore.DeviceLibrary
storeRunStatus = StoreRunStatus.HomeMoving; storeRunStatus = StoreRunStatus.HomeMoving;
//启动温湿度服务器 //启动温湿度服务器
HumitureServer.StartTemperateServer(Config.TemperateServer_Port); HumitureServer.StartTemperateServer(Config.TemperateServer_Port);
Task.Factory.StartNew(delegate () //Task.Factory.StartNew(delegate ()
{ //{
HDevelopExport.OpenAllCamera(); // HDevelopExport.OpenAllCamera();
}); //});
ReturnHome(); ReturnHome();
StartTime = DateTime.Now; StartTime = DateTime.Now;
timersTimer.Enabled = true; timersTimer.Enabled = true;
...@@ -421,10 +423,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -421,10 +423,10 @@ namespace OnlineStore.DeviceLibrary
autoNext = false; autoNext = false;
} }
Task.Factory.StartNew(delegate () //Task.Factory.StartNew(delegate ()
{ //{
HDevelopExport.OpenAllCamera(); // //HDevelopExport.OpenAllCamera();
}); //});
ACServerManager.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue()); ACServerManager.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue()); ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()); ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
...@@ -655,7 +657,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -655,7 +657,7 @@ namespace OnlineStore.DeviceLibrary
break; break;
case StoreMoveStep.BOX_H_OtherAxisBack: case StoreMoveStep.BOX_H_OtherAxisBack:
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_MiddleAxisToP1); StoreMove.NextMoveStep(StoreMoveStep.BOX_H_MiddleAxisToP1);
LogUtil.info(LOGGER, StoreName + "回原点:旋转轴运动到P1,上下轴到P1!"); LogUtil.info(LOGGER, StoreName + "回原点:旋转轴运动到P1,上下轴到P1!");
ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed); ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed);
...@@ -681,7 +683,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -681,7 +683,7 @@ namespace OnlineStore.DeviceLibrary
foreach (ConfigMoveAxis moveAxis in moveAxisList) foreach (ConfigMoveAxis moveAxis in moveAxisList)
{ {
string portName = moveAxis.DeviceName; string portName = moveAxis.DeviceName;
short slvAddr = moveAxis.GetAxisValue(); int slvAddr = moveAxis.GetAxisValue();
ACServerManager.OpenPort(portName); ACServerManager.OpenPort(portName);
Thread.Sleep(50); Thread.Sleep(50);
//初始化串口 //初始化串口
...@@ -807,7 +809,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -807,7 +809,7 @@ namespace OnlineStore.DeviceLibrary
ShuoKeControls.ClosePort(); ShuoKeControls.ClosePort();
} }
//scanSocket.StopScanner(); //scanSocket.StopScanner();
HDevelopExport.CloseAllCamera(); //HDevelopExport.CloseAllCamera();
HumitureServer.StopTemperateServer(); HumitureServer.StopTemperateServer();
LogUtil.info(LOGGER, StoreName + ",停止运行,总运行时间:" + span.ToString()); LogUtil.info(LOGGER, StoreName + ",停止运行,总运行时间:" + span.ToString());
...@@ -1233,9 +1235,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -1233,9 +1235,9 @@ namespace OnlineStore.DeviceLibrary
foreach (ConfigMoveAxis axisInfo in moveAxisList) foreach (ConfigMoveAxis axisInfo in moveAxisList)
{ {
short axis = axisInfo.GetAxisValue(); int axis = axisInfo.GetAxisValue();
string deviceName = axisInfo.DeviceName; string deviceName = axisInfo.DeviceName;
AxisAlarmInfo info = AxisAlarmCodeMap[deviceName]; AxisAlarmInfo info = AxisAlarmCodeMap[axisInfo.GetNameStr()];
int alarmIo = ACServerManager.GetAlarmStatus(deviceName, axis); int alarmIo = ACServerManager.GetAlarmStatus(deviceName, axis);
...@@ -1254,7 +1256,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1254,7 +1256,7 @@ namespace OnlineStore.DeviceLibrary
info.AlarmIoValue = alarmIo; info.AlarmIoValue = alarmIo;
} }
} }
AxisAlarmCodeMap[deviceName] = info; AxisAlarmCodeMap[axisInfo.GetNameStr()] = info;
} }
//判断报警状态 //判断报警状态
return isInAlarm; return isInAlarm;
...@@ -1264,7 +1266,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1264,7 +1266,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary> /// </summary>
public override void StopMove() public override void StopMove()
{ {
HDevelopExport.CloseAllCamera(); //HDevelopExport.CloseAllCamera();
//运动版停止 //运动版停止
ACServerManager.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue()); ACServerManager.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue()); ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
...@@ -1439,11 +1441,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -1439,11 +1441,16 @@ namespace OnlineStore.DeviceLibrary
KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH); KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string message = ""; string message = "";
List<string> codeList = HDevelopExport.CameraScan(); //List<string> codeList = HDevelopExport.CameraScan();
//foreach (string str in codeList)
//{
// string code = HDevelopExport.SubStrCode(str);
// message = message + code + spiltStr;
//}
List<string> codeList = CodeManager.CameraScan();
foreach (string str in codeList) foreach (string str in codeList)
{ {
string code = HDevelopExport.SubStrCode(str); message = message + str + spiltStr;
message = message + code + spiltStr;
} }
KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW); KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
onCodeReceived(message); onCodeReceived(message);
......
...@@ -25,6 +25,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -25,6 +25,7 @@ namespace OnlineStore.DeviceLibrary
public int autoJiange = 3; public int autoJiange = 3;
public int autoPositionIndex = 0; public int autoPositionIndex = 0;
public string autoMsg = ""; public string autoMsg = "";
public int AutoStartIndex = -1;
#endregion #endregion
#region 出入库参数 #region 出入库参数
...@@ -919,9 +920,17 @@ namespace OnlineStore.DeviceLibrary ...@@ -919,9 +920,17 @@ namespace OnlineStore.DeviceLibrary
//} //}
if (newIndex < 0) if (newIndex < 0)
{ {
autoNext = false; if (AutoStartIndex >= 0 && AutoStartIndex < PositionNumList.Count)
autoMsg = "自动出入库结束!"; {
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,自动 出入库结束!"); newIndex = AutoStartIndex;
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,重新开始自动出入库,索引【" + AutoStartIndex+"】");
}
else
{
autoNext = false;
autoMsg = "自动出入库结束!";
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,自动 出入库结束!");
}
} }
else else
{ {
...@@ -956,9 +965,17 @@ namespace OnlineStore.DeviceLibrary ...@@ -956,9 +965,17 @@ namespace OnlineStore.DeviceLibrary
int newIndex = autoPositionIndex - autoJiange; int newIndex = autoPositionIndex - autoJiange;
if (newIndex < 0) if (newIndex < 0)
{ {
autoNext = false; if (AutoStartIndex >= 0 && AutoStartIndex < PositionNumList.Count)
autoMsg = "自动出入库结束!"; {
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,自动 出入库结束!"); newIndex = AutoStartIndex;
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,重新开始自动出入库,索引【" + AutoStartIndex + "】");
}
else
{
autoNext = false;
autoMsg = "自动出入库结束!";
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,自动 出入库结束!");
}
} }
else else
{ {
......
using CodeLibrary;
using HalconDotNet;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace OnlineStore.DeviceLibrary
{
public class CodeManager
{
public static List<string> cameraNameList = new List<string>();
public static List<string> codeTypeList = new List<string>();
public static List<string> balserNameList = new List<string>();
public static List<string> hikNameList = new List<string>();
private static char spiltChar = '#';
/// <summary>
/// 初始化摄像机名称和二维码类型
/// </summary>
/// <param name="nameStr">摄像机名称,多个用#分割</param>
/// <param name="codeStr">二维码类型,多个用#分割</param>
public static void LoadConfig(string nameStr, string codeStr)
{
cameraNameList = new List<string>();
codeTypeList = new List<string>();
try
{
string[] nameArray = nameStr.Split(spiltChar);
foreach (string str in nameArray)
{
LogUtil.info("加载到配置摄像机名称:" + str.Trim());
cameraNameList.Add(str.Trim());
}
string[] codeArray = codeStr.Split(spiltChar);
foreach (string str in codeArray)
{
LogUtil.info("加载到二维码类型:" + str.Trim());
codeTypeList.Add(str.Trim());
}
string[] names = CodeLibrary.HIKCamera.Instance.CameraName;
hikNameList.AddRange(names);
names = CodeLibrary.BaslerCamera.Instance.CameraName;
balserNameList.AddRange(names);
CodeLibrary.HDCodeLearnHelper.LoadConfig(nameStr, codeStr);
}
catch (Exception ex)
{
LogUtil.error("解析摄像机配置出错:" + ex.ToString());
}
}
public static Bitmap GetCamerImage(string cameraName)
{
Bitmap bitm = null;
if (balserNameList.Contains(cameraName))
{
BaslerCamera.Instance.Open(cameraName);
BaslerCamera.Instance.GrabOne();
bitm = BaslerCamera.Instance.Image;
BaslerCamera.Instance.Close();
}
else if(hikNameList.Contains(cameraName))
{
HIKCamera.Instance.Open(cameraName);
HIKCamera.Instance.GrabOne();
bitm = HIKCamera.Instance.Image;
HIKCamera.Instance.Close();
}
else
{
LogUtil.info("未找到摄像机【"+cameraName+"】无法获取图片");
}
return bitm;
}
public static List<string> CameraScan( )
{
List<string> codeList = new List<string>();
List<CodeInfo> allCodeList = new List<CodeInfo>();
try
{
foreach (string cameraName in cameraNameList)
{
Bitmap bitmap = GetCamerImage(cameraName);
if (bitmap == null)
{
LogUtil.info(" 摄像机【" + cameraName + "】获取图片失败");
}
else
{
HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
List<CodeInfo> cc = new List<CodeInfo>();
foreach (string codeType in codeTypeList)
{
cc = HDCodeHelper.DecodeCode(ho_Image, 1, GetCodeParamFilePath(codeType), codeType);
}
allCodeList.AddRange(cc);
}
}
}
catch (Exception ex)
{
LogUtil.error("扫码出错:" + ex.ToString());
}
foreach(CodeInfo info in allCodeList)
{
codeList.Add(info.CodeStr);
}
return codeList;
}
public static string GetCodeParamFilePath(string codePath)
{
string appPath = Application.StartupPath;
string path = appPath + ConfigAppSettings.GetValue(Setting_Init.CodeParamPath);
string filePath = path + codePath + ".dcm";
if (File.Exists(filePath))
{
return filePath;
}
else
{
return "";
}
}
}
}
using HalconDotNet;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace OnlineStore.DeviceLibrary
{
public class HDevelopCodeLearn
{
public static HWindow hv_ExpDefaultWinHandle;
public static HTuple hv_AcqHandle = null;
public static void HDevelopStop()
{
//MessageBox.Show("Press button to continue", "Program stop");
}
public static void InitHalcon()
{
// Default settings used in HDevelop
HOperatorSet.SetSystem("width", 512);
HOperatorSet.SetSystem("height", 512);
}
public static void RunHalcon(HWindow Window, string camerName, string codeType, string paramPath, int codeCount)
{
InitHalcon();
hv_ExpDefaultWinHandle = Window;
action(camerName, codeType, paramPath, codeCount);
}
private static bool OpenCamera(string cameraName)
{
try
{ //[1] HD USB Camera
HOperatorSet.OpenFramegrabber("GigEVision", 0, 0, 0, 0, 0, 0, "default", -1,
"default", -1, "false", "default", cameraName, 0, -1, out hv_AcqHandle);
//HOperatorSet.OpenFramegrabber("DirectShow", 1, 1, 0, 0, 0, 0, "default", 8, "rgb",
// -1, "false", "default", "[1] HD USB Camera", 0, -1, out hv_AcqHandle);
return true;
}
catch (Exception ex)
{
LogUtil.error("打开摄像机失败:" + ex.ToString() + ",调用关闭摄像头");
CloseCamera(cameraName);
return false;
}
}
private static void CloseCamera(string cameraName)
{
try
{
HOperatorSet.CloseFramegrabber(hv_AcqHandle);
hv_AcqHandle = null;
}
catch (Exception ex)
{
LogUtil.error("关闭摄像机失败:" + ex.ToString());
}
}
public static bool IsRun = false;
// Main procedure
private static bool action(string cameraName, string codeType, string paramPath, int codeCount)
{
IsRun = true;
IsLearnEnd = false;
IsTestEnd = false;
try
{
HTuple hv_code_type = codeType;
HTuple hv_model_path = paramPath;
HObject ho_Image = null, ho_SymbolXLDs = null;
HTuple hv_train_first = null, /*hv_AcqHandle = null,*/ hv_DataCodeHandle = null;
HTuple hv_ResultHandles = new HTuple(), hv_DecodedDataStrings = new HTuple();
HTuple hv_GenParamNames = new HTuple(), hv_ModelBeforeTraining = new HTuple();
// Initialize local and output iconic variables
HOperatorSet.GenEmptyObj(out ho_Image);
HOperatorSet.GenEmptyObj(out ho_SymbolXLDs);
//Image Acquisition 04: Code generated by Image Acquisition 04
//Image Acquisition 01: Code generated by Image Acquisition 01
//hv_code_type = "Data Matrix ECC 200";
//hv_model_path = ("E:/BaiduNetdiskDownload/" + hv_code_type) + ".dcm";
hv_train_first = 1;
if (!OpenCamera(cameraName))
{
return false ;
}
//HOperatorSet.GrabImageStart(hv_AcqHandle, -1);
HOperatorSet.CreateDataCode2dModel(hv_code_type, new HTuple(), new HTuple(),
out hv_DataCodeHandle);
//set_data_code_2d_param (DataCodeHandle, 'strict_model', 'yes')
//set_data_code_2d_param (DataCodeHandle, 'persistence', 0)
//set_data_code_2d_param (DataCodeHandle, 'polarity', 'light_on_dark')
List<string> findCode = new List<string>();
if ((int)(hv_train_first) != 0)
{
while (findCode.Count < codeCount&&IsLearnEnd.Equals(false ))
{
ho_Image.Dispose();
HOperatorSet.GrabImageAsync(out ho_Image, hv_AcqHandle, -1);
//Image Acquisition 04: Do something
//write_image (Image, 'jpeg', 0, 'E:/BaiduNetdiskDownload/fuba2.jpg')
if (ho_Image != null)
{
ho_SymbolXLDs.Dispose();
HOperatorSet.FindDataCode2d(ho_Image, out ho_SymbolXLDs, hv_DataCodeHandle,
"train", "all", out hv_ResultHandles, out hv_DecodedDataStrings);
if ((int)(new HTuple((new HTuple(hv_DecodedDataStrings.TupleLength())).TupleNotEqual(
0))) != 0)
{
HOperatorSet.QueryDataCode2dParams(hv_DataCodeHandle, "get_model_params",
out hv_GenParamNames);
HOperatorSet.GetDataCode2dParam(hv_DataCodeHandle, hv_GenParamNames, out hv_ModelBeforeTraining);
HDevelopStop();
string[] resultList = hv_DecodedDataStrings.SArr;
foreach (string str in resultList)
{
if (!findCode.Contains(str))
{
LogUtil.info("["+cameraName + "][" + codeType + "]学习【" + str+"】");
findCode.Add(str);
}
}
}
ShowImage(ho_Image,ho_SymbolXLDs);
}
Thread.Sleep(500);
}
//*参数写入文件
LogUtil.info("["+cameraName + "][" + codeType + "]保存参数到文件【" + paramPath+"】");
HOperatorSet.WriteDataCode2dModel(hv_DataCodeHandle, hv_model_path);
HOperatorSet.ClearDataCode2dModel(hv_DataCodeHandle);
}
//Read the previously saved data code model
findCode = new List<string>();
HOperatorSet.ReadDataCode2dModel(hv_model_path, out hv_DataCodeHandle);
while (findCode.Count < codeCount&&IsTestEnd.Equals(false ))
{
ho_Image.Dispose();
HOperatorSet.GrabImageAsync(out ho_Image, hv_AcqHandle, -1);
//Image Acquisition 04: Do something
//write_image (Image, 'jpeg', 0, 'E:/BaiduNetdiskDownload/fuba2.jpg')
if (ho_Image != null)
{
ho_SymbolXLDs.Dispose();
HOperatorSet.FindDataCode2d(ho_Image, out ho_SymbolXLDs, hv_DataCodeHandle,
"stop_after_result_num", 5, out hv_ResultHandles, out hv_DecodedDataStrings);
ShowImage(ho_Image,ho_SymbolXLDs);
if ((int)(new HTuple((new HTuple(hv_DecodedDataStrings.TupleLength())).TupleNotEqual(
0))) != 0)
{
string[] resultList = hv_DecodedDataStrings.SArr;
foreach (string str in resultList)
{
if (!findCode.Contains(str))
{
findCode.Add(str);
LogUtil.info("[" + cameraName + "][" + codeType + "]检测到【" + str + "】");
}
}
}
}
Thread.Sleep(500);
}
HOperatorSet.ClearDataCode2dModel(hv_DataCodeHandle);
CloseCamera(cameraName);
ho_Image.Dispose();
ho_SymbolXLDs.Dispose();
IsRun = false;
return true;
}catch(Exception ex)
{
LogUtil.error("出错了:" + ex.ToString());
CloseCamera(cameraName);
IsRun = false;
return false;
}
}
public static bool IsTestEnd = false;
public static bool IsLearnEnd = false;
public static void StopLearn()
{
IsTestEnd = true;
IsLearnEnd = true;
}
private static int dWidth = 0;
private static int dHeight = 0;
private static void ShowImage(HObject ho_Image,HObject ho_SymbolXLDs)
{
if (dWidth <= 0)
{
HTuple width, height;
//int dWidth = 0; int dHeight = 0;
HOperatorSet.GetImageSize(ho_Image, out width, out height);
dWidth = (int)width.D;
dHeight = (int)height.D;
hv_ExpDefaultWinHandle.SetPart(0, 0, dHeight, dWidth);
}
HOperatorSet.DispObj(ho_Image, hv_ExpDefaultWinHandle);
HOperatorSet.DispObj(ho_SymbolXLDs, hv_ExpDefaultWinHandle);
}
}
}
...@@ -275,7 +275,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -275,7 +275,7 @@ namespace OnlineStore.DeviceLibrary
{ {
msg = ""; msg = "";
string deviceName = moveAxis.DeviceName; string deviceName = moveAxis.DeviceName;
short axisNo = moveAxis.GetAxisValue(); int axisNo = moveAxis.GetAxisValue();
//如果是进出轴,并且光栅被遮挡,直接返回false //如果是进出轴,并且光栅被遮挡,直接返回false
...@@ -306,7 +306,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -306,7 +306,7 @@ namespace OnlineStore.DeviceLibrary
//判断是否需要重新运动 //判断是否需要重新运动
if (StoreMove.CanWhileCount > 0) if (StoreMove.CanWhileCount > 0)
{ {
LogUtil.error(LOGGER, moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount + LogUtil.error(LOGGER, moveAxis.Explain + "目标位置[" + targetPosition + "]当前位置[" + outCount +
"],误差过大,重新开始运动,剩余[" + StoreMove.CanWhileCount + "]次"); "],误差过大,重新开始运动,剩余[" + StoreMove.CanWhileCount + "]次");
//LogUtil.error(LOGGER, StoreName + " storeMoveStep=" + StoreMove.MoveStep + moveAxis.DisplayStr + "目标位置[" + targetPosition + "]重新开始运动"); //LogUtil.error(LOGGER, StoreName + " storeMoveStep=" + StoreMove.MoveStep + moveAxis.DisplayStr + "目标位置[" + targetPosition + "]重新开始运动");
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed); ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed);
...@@ -315,7 +315,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -315,7 +315,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
msg = StoreName + " storeMoveStep=" + StoreMove.MoveStep + moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount msg = StoreName + " storeMoveStep=" + StoreMove.MoveStep + moveAxis.Explain + "目标位置[" + targetPosition + "]当前位置[" + outCount
+ "],误差过大,需要报警"; + "],误差过大,需要报警";
LogUtil.error(LOGGER, msg); LogUtil.error(LOGGER, msg);
return false; return false;
...@@ -327,12 +327,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -327,12 +327,12 @@ namespace OnlineStore.DeviceLibrary
return true; return true;
} }
} }
else if (errorCount <= moveAxis.CanErrorCountMin) //else if (errorCount <= moveAxis.CanErrorCountMin)
{ //{
LogUtil.info(LOGGER, " storeMoveStep=" + StoreMove.MoveStep + moveAxis.DisplayStr + ",targetPosition=" + targetPosition + ",当前outCount=" + outCount + // LogUtil.info(LOGGER, " storeMoveStep=" + StoreMove.MoveStep + moveAxis.Explain + ",目标位置[" + targetPosition + "],当前位置[" + outCount +
",误差值小于最小误差【" + moveAxis.CanErrorCountMin + "】,默认轴已经停止运动"); // "],误差值小于最小误差【" + moveAxis.CanErrorCountMin + "】,默认轴已经停止运动");
return true; // return true;
} //}
return false; return false;
} }
protected bool ACHomeMoveIsEnd(ConfigMoveAxis moveAxis,out string msg) protected bool ACHomeMoveIsEnd(ConfigMoveAxis moveAxis,out string msg)
...@@ -348,14 +348,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -348,14 +348,14 @@ namespace OnlineStore.DeviceLibrary
//判断是否需要重新运动 //判断是否需要重新运动
if (StoreMove.CanWhileCount > 0) if (StoreMove.CanWhileCount > 0)
{ {
LogUtil.error(LOGGER, moveAxis.DisplayStr + "收到原点完成信号,当前位置["+outCount+ "],重新回原点,剩余[" + StoreMove.CanWhileCount + "]次"); LogUtil.error(LOGGER, moveAxis.Explain + "收到原点完成信号,当前位置["+outCount+ "],重新回原点,剩余[" + StoreMove.CanWhileCount + "]次");
//LogUtil.error(LOGGER, StoreName + moveAxis.DisplayStr + "重新回原点"); //LogUtil.error(LOGGER, StoreName + moveAxis.DisplayStr + "重新回原点");
ACServerManager.HomeMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed); ACServerManager.HomeMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed);
StoreMove.CanWhileCount--; StoreMove.CanWhileCount--;
} }
else else
{ {
msg = StoreName + " storeMoveStep=" + StoreMove.MoveStep + moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警"; msg = StoreName + " storeMoveStep=" + StoreMove.MoveStep + moveAxis.Explain + "收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警";
LogUtil.error(LOGGER, msg); LogUtil.error(LOGGER, msg);
return false; return false;
} }
......
...@@ -236,12 +236,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -236,12 +236,12 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 旋转轴返回P1 /// 旋转轴返回P1
/// </summary> /// </summary>
BOX_H_MiddleAxisToP1=016, BOX_H_MiddleAxisToP1 = 016,
/// <summary> /// <summary>
/// 叉子先退回P1 /// 叉子先退回P1
/// </summary> /// </summary>
BOX_M_H_InOutToP1=018, BOX_M_H_InOutToP1 =018,
/// <summary> /// <summary>
/// 旋转轴回原点 /// 旋转轴回原点
/// </summary> /// </summary>
......
...@@ -129,6 +129,18 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -129,6 +129,18 @@ namespace OnlineStore.LoadCSVLibrary
/// </summary> /// </summary>
public int PositionMax { get; set; } public int PositionMax { get; set; }
public string GetNameStr()
{
return DeviceName + "_" + GetAxisValue();
}
public bool IsSameAxis(string portName, int slv)
{
if (DeviceName.Equals(portName) && slv.Equals(GetAxisValue()))
{
return true;
}
return false;
}
public bool PositionIsHasLimit(){ public bool PositionIsHasLimit(){
if (PositionMin.Equals(PositionMax)) if (PositionMin.Equals(PositionMax))
{ {
...@@ -155,7 +167,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -155,7 +167,7 @@ namespace OnlineStore.LoadCSVLibrary
/// 使用康泰克板卡表示轴编号,使用Ac伺服电机表示伺服地址 /// 使用康泰克板卡表示轴编号,使用Ac伺服电机表示伺服地址
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public short GetAxisValue() public int GetAxisValue()
{ {
if (ProVale.Equals("") || ProVale.Equals("-1")) if (ProVale.Equals("") || ProVale.Equals("-1"))
{ {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!