Commit 45f62419 LN

增加伺服bean

1 个父辈 aff17178
...@@ -23,7 +23,7 @@ namespace OnlineStore.AssemblyLine ...@@ -23,7 +23,7 @@ namespace OnlineStore.AssemblyLine
internal partial class FrmFeedingEquip : FrmEquipBase internal partial class FrmFeedingEquip : FrmEquipBase
{ {
private bool IsLoad = false; private bool IsLoad = false;
private FeedingEquip equipBean; private FeedingEquip equipBean;
internal FrmFeedingEquip(FeedingEquip moveEquip) internal FrmFeedingEquip(FeedingEquip moveEquip)
{ {
...@@ -33,7 +33,7 @@ namespace OnlineStore.AssemblyLine ...@@ -33,7 +33,7 @@ namespace OnlineStore.AssemblyLine
InitializeComponent(); InitializeComponent();
LoadIOList(); LoadIOList();
} }
private void LoadIOList() private void LoadIOList()
{ {
int maxCount = 16; int maxCount = 16;
...@@ -49,12 +49,12 @@ namespace OnlineStore.AssemblyLine ...@@ -49,12 +49,12 @@ namespace OnlineStore.AssemblyLine
if (i >= maxCount) if (i >= maxCount)
{ {
this.tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 28)); this.tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
this.tableLayoutPanel3.Controls.Add(control, 0, roleindex- maxCount); this.tableLayoutPanel3.Controls.Add(control, 0, roleindex - maxCount);
} }
else else
{ {
this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 28)); this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
this.tableLayoutPanel1.Controls.Add(control, 0, roleindex); this.tableLayoutPanel1.Controls.Add(control, 0, roleindex);
} }
roleindex++; roleindex++;
i++; i++;
...@@ -73,7 +73,7 @@ namespace OnlineStore.AssemblyLine ...@@ -73,7 +73,7 @@ namespace OnlineStore.AssemblyLine
if (i >= maxCount) if (i >= maxCount)
{ {
this.tableLayoutPanel4.RowStyles.Add(new RowStyle(SizeType.Absolute, 28)); this.tableLayoutPanel4.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
this.tableLayoutPanel4.Controls.Add(control, 0, roleindex-maxCount); this.tableLayoutPanel4.Controls.Add(control, 0, roleindex - maxCount);
} }
else else
{ {
...@@ -104,10 +104,10 @@ namespace OnlineStore.AssemblyLine ...@@ -104,10 +104,10 @@ namespace OnlineStore.AssemblyLine
{ {
ReadIOList(); ReadIOList();
lblTrayNum.Text = "托盘编码:" + TrayManager.GetTrayNum(equipBean.DeviceID); lblTrayNum.Text = "托盘编码:" + TrayManager.GetTrayNum(equipBean.DeviceID);
} }
string canOut = LineManager.Line.CanOutStore(equipBean.DeviceID) ? "可出库":"不可出库" ; string canOut = LineManager.Line.CanOutStore(equipBean.DeviceID) ? "可出库" : "不可出库";
lblStoreStatus.Text = KTK_Store.GetRunStr(equipBean.lineStatus, equipBean.runStatus)+"("+canOut+")"; lblStoreStatus.Text = KTK_Store.GetRunStr(equipBean.lineStatus, equipBean.runStatus) + "(" + canOut + ")";
lblThisSta.Text = equipBean.WarnMsg; lblThisSta.Text = equipBean.WarnMsg;
string text = ""; string text = "";
List<InOutParam> ps = new List<InOutParam>(equipBean.waitInStoreList); List<InOutParam> ps = new List<InOutParam>(equipBean.waitInStoreList);
...@@ -123,9 +123,10 @@ namespace OnlineStore.AssemblyLine ...@@ -123,9 +123,10 @@ namespace OnlineStore.AssemblyLine
{ {
lblInstoreList.Text = text; lblInstoreList.Text = text;
} }
}catch(Exception ex) }
catch (Exception ex)
{ {
LogUtil.error(equipBean.Name+ "界面定时器出错:"+ex.ToString()); LogUtil.error(equipBean.Name + "界面定时器出错:" + ex.ToString());
} }
} }
...@@ -148,7 +149,7 @@ namespace OnlineStore.AssemblyLine ...@@ -148,7 +149,7 @@ namespace OnlineStore.AssemblyLine
} }
private void btnOpenDo_Click(object sender, EventArgs e) private void btnOpenDo_Click(object sender, EventArgs e)
{ {
WriteDO(IO_VALUE.HIGH); WriteDO(IO_VALUE.HIGH);
} }
private void btnWriteSingleDO_Click(object sender, EventArgs e) private void btnWriteSingleDO_Click(object sender, EventArgs e)
{ {
...@@ -158,7 +159,7 @@ namespace OnlineStore.AssemblyLine ...@@ -158,7 +159,7 @@ namespace OnlineStore.AssemblyLine
{ {
string deviceName = txtDoName.Text; string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex); int index = FormUtil.GetIntValue(txtDOIndex);
// IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW; // IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime); int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId); int slaveId = FormUtil.GetIntValue(txtSlaveId);
if (time > 0) if (time > 0)
...@@ -189,7 +190,7 @@ namespace OnlineStore.AssemblyLine ...@@ -189,7 +190,7 @@ namespace OnlineStore.AssemblyLine
ConfigIO io = GetSelectDO(); ConfigIO io = GetSelectDO();
if (io != null) if (io != null)
{ {
// txtIp.Text = io.DeviceName; // txtIp.Text = io.DeviceName;
txtDOIndex.Text = io.GetIOAddr().ToString(); txtDOIndex.Text = io.GetIOAddr().ToString();
txtDoName.Text = io.IO_IP; txtDoName.Text = io.IO_IP;
txtSlaveId.Text = io.SlaveID.ToString(); txtSlaveId.Text = io.SlaveID.ToString();
...@@ -206,8 +207,8 @@ namespace OnlineStore.AssemblyLine ...@@ -206,8 +207,8 @@ namespace OnlineStore.AssemblyLine
private void FrmStoreIOStatus_Load(object sender, EventArgs e) private void FrmStoreIOStatus_Load(object sender, EventArgs e)
{ {
chbDebug.Checked = equipBean.IsDebug; chbDebug.Checked = equipBean.IsDebug;
axisMoveControl1.LoadData(equipBean, new ConfigMoveAxis[] {equipBean.Config.UpDown_Axis,equipBean.Config.Batch_Axis }); axisMoveControl1.LoadData(equipBean, new AxisBean[] { equipBean.UpdownAxis, equipBean.BatchAxis });
cmbSizeList.Items.Clear(); cmbSizeList.Items.Clear();
cmbSizeList.Items.Add("0=默认位置"); cmbSizeList.Items.Add("0=默认位置");
...@@ -227,10 +228,10 @@ namespace OnlineStore.AssemblyLine ...@@ -227,10 +228,10 @@ namespace OnlineStore.AssemblyLine
btnFL_TopCylinder.Visible = false; btnFL_TopCylinder.Visible = false;
} }
else else
{ {
btnSwLocationCylinder.Visible = false ; btnSwLocationCylinder.Visible = false;
btnSWTop.Visible = false ; btnSWTop.Visible = false;
btnFL_TopCylinder.Visible = true ; btnFL_TopCylinder.Visible = true;
} }
txtBp1.Text = equipBean.Config.BatchAxisP1.ToString(); txtBp1.Text = equipBean.Config.BatchAxisP1.ToString();
txtBP2.Text = equipBean.Config.BatchAxisP2.ToString(); txtBP2.Text = equipBean.Config.BatchAxisP2.ToString();
...@@ -259,7 +260,7 @@ namespace OnlineStore.AssemblyLine ...@@ -259,7 +260,7 @@ namespace OnlineStore.AssemblyLine
{ {
ReadIOList(); ReadIOList();
} }
internal void FormStatus(bool isStart) internal void FormStatus(bool isStart)
{ {
...@@ -268,7 +269,7 @@ namespace OnlineStore.AssemblyLine ...@@ -268,7 +269,7 @@ namespace OnlineStore.AssemblyLine
btnReset.Enabled = isStart; btnReset.Enabled = isStart;
btnInStore.Enabled = isStart; btnInStore.Enabled = isStart;
btnOutStore.Enabled = isStart; btnOutStore.Enabled = isStart;
} }
private void FrmIOStatus_Shown(object sender, EventArgs e) private void FrmIOStatus_Shown(object sender, EventArgs e)
{ {
timer1.Start(); timer1.Start();
...@@ -301,10 +302,10 @@ namespace OnlineStore.AssemblyLine ...@@ -301,10 +302,10 @@ namespace OnlineStore.AssemblyLine
if (result.Equals(DialogResult.Yes)) if (result.Equals(DialogResult.Yes))
{ {
equipBean.IsDebug = true; equipBean.IsDebug = true;
equipBean.Config.IsDebug = 1; equipBean.Config.IsDebug = 1;
LineManager.SaveFeedingEquipConfig(equipBean.Config); LineManager.SaveFeedingEquipConfig(equipBean.Config);
equipBean.ChangeDebug(true); equipBean.ChangeDebug(true);
LogUtil.info(equipBean.Name+ "用户切换到调试状态 "); LogUtil.info(equipBean.Name + "用户切换到调试状态 ");
} }
} }
} }
...@@ -327,9 +328,9 @@ namespace OnlineStore.AssemblyLine ...@@ -327,9 +328,9 @@ namespace OnlineStore.AssemblyLine
private void btnOutStore_Click(object sender, EventArgs e) private void btnOutStore_Click(object sender, EventArgs e)
{ {
if (equipBean.runStatus .Equals(LineRunStatus.Runing)) if (equipBean.runStatus.Equals(LineRunStatus.Runing))
{ {
equipBean.StartOutStoreMove(new InOutParam( )); equipBean.StartOutStoreMove(new InOutParam());
} }
else else
{ {
...@@ -357,41 +358,41 @@ namespace OnlineStore.AssemblyLine ...@@ -357,41 +358,41 @@ namespace OnlineStore.AssemblyLine
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error( "出错:" + ex.StackTrace); LogUtil.error("出错:" + ex.StackTrace);
} }
} }
private void btnReset_Click(object sender, EventArgs e) private void btnReset_Click(object sender, EventArgs e)
{ {
if (equipBean.runStatus>(LineRunStatus.Wait)) if (equipBean.runStatus > (LineRunStatus.Wait))
{ {
equipBean.Reset(); equipBean.Reset();
} }
} }
private void btnLocationCylinder_Click(object sender, EventArgs e) private void btnLocationCylinder_Click(object sender, EventArgs e)
{ {
BtnMove(btnLocationCylinder, "SL定位气缸上升", "SL定位气缸下降", IO_Type.SL_LocationCylinder_Down, IO_Type.SL_LocationCylinder_Up); BtnMove(btnLocationCylinder, "SL定位气缸上升", "SL定位气缸下降", IO_Type.SL_LocationCylinder_Down, IO_Type.SL_LocationCylinder_Up);
} }
private void btnOutTopCylinder_Click(object sender, EventArgs e) private void btnOutTopCylinder_Click(object sender, EventArgs e)
{ {
BtnMove(btnOutTopCylinder, "SL出口顶升上升", "SL出口顶升下降", IO_Type.SL_OutTopCylinder_Down, IO_Type.SL_OutTopCylinder_Up); BtnMove(btnOutTopCylinder, "SL出口顶升上升", "SL出口顶升下降", IO_Type.SL_OutTopCylinder_Down, IO_Type.SL_OutTopCylinder_Up);
} }
private void btnFeedSideWay_Click(object sender, EventArgs e) private void btnFeedSideWay_Click(object sender, EventArgs e)
{ {
BtnMove(btnFeedSideWay, "SL上料横移机构上升", "SL上料横移机构下降", IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up); BtnMove(btnFeedSideWay, "SL上料横移机构上升", "SL上料横移机构下降", IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
} }
private void btnFeedCylinder_Click(object sender, EventArgs e) private void btnFeedCylinder_Click(object sender, EventArgs e)
{ {
BtnMove(btnFeedCylinder, "SL上料气缸放松", "SL上料气缸夹紧", IO_Type.SL_MoveCylinder_Tighten, IO_Type.SL_MoveCylinder_Slack); BtnMove(btnFeedCylinder, "SL上料气缸放松", "SL上料气缸夹紧", IO_Type.SL_MoveCylinder_Tighten, IO_Type.SL_MoveCylinder_Slack);
} }
private void btnFeedSideWayCylinder_Click(object sender, EventArgs e) private void btnFeedSideWayCylinder_Click(object sender, EventArgs e)
{ {
BtnMove(btnFeedSideWayCylinder, "SL上料横移气缸取料", "SL上料横移气缸放料", IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give); BtnMove(btnFeedSideWayCylinder, "SL上料横移气缸取料", "SL上料横移气缸放料", IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give);
} }
private void btnTrayLocationCylinder_Click(object sender, EventArgs e) private void btnTrayLocationCylinder_Click(object sender, EventArgs e)
{ {
BtnMove(btnTrayLocationCylinder, "SL升降盘定位气缸前进", "SL升降盘定位气缸后退", IO_Type.SL_TrayLocation_Before, IO_Type.SL_TrayLocation_After); BtnMove(btnTrayLocationCylinder, "SL升降盘定位气缸前进", "SL升降盘定位气缸后退", IO_Type.SL_TrayLocation_Before, IO_Type.SL_TrayLocation_After);
...@@ -409,7 +410,7 @@ namespace OnlineStore.AssemblyLine ...@@ -409,7 +410,7 @@ namespace OnlineStore.AssemblyLine
{ {
BtnMove(btnSwLocationCylinder, "环形线横移定位上升", "环形线横移定位下降", IO_Type.SW_LocationCylinder_Down, IO_Type.SW_LocationCylinder_Up); BtnMove(btnSwLocationCylinder, "环形线横移定位上升", "环形线横移定位下降", IO_Type.SW_LocationCylinder_Down, IO_Type.SW_LocationCylinder_Up);
} }
private void cmbSizeList_SelectedIndexChanged(object sender, EventArgs e) private void cmbSizeList_SelectedIndexChanged(object sender, EventArgs e)
{ {
if (cmbSizeList.SelectedIndex < 0) if (cmbSizeList.SelectedIndex < 0)
...@@ -418,32 +419,29 @@ namespace OnlineStore.AssemblyLine ...@@ -418,32 +419,29 @@ namespace OnlineStore.AssemblyLine
} }
int size = 0; int size = 0;
try {size= Convert.ToInt32(cmbSizeList.Text); } catch (Exception ex) { } try { size = Convert.ToInt32(cmbSizeList.Text); } catch (Exception ex) { }
txtSizePosition.Text = equipBean.Config.GetUpdownPositionP2(size).ToString(); txtSizePosition.Text = equipBean.Config.GetUpdownPositionP2(size).ToString();
btnMoveto.Text = size + "寸移栽位置 :"; btnMoveto.Text = size + "寸移栽位置 :";
} }
private void btnMoveto_Click(object sender, EventArgs e) private void btnMoveto_Click(object sender, EventArgs e)
{ {
int position = FormUtil.GetIntValue(txtSizePosition); int position = FormUtil.GetIntValue(txtSizePosition);
if (position != -1)
{ int speed = equipBean.Config.UpdownAxis_P2Speed;
int speed = equipBean.Config.UpdownAxis_P2Speed; LogUtil.info("点击【移栽位置】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】");
string portName = equipBean.Config.UpDown_Axis.DeviceName; equipBean.UpdownAxis.AbsMove(position, speed);
int SlvAddr = equipBean.Config.UpDown_Axis.GetAxisValue();
LogUtil.info("点击【移栽位置】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed);
}
} }
private void btnAxisOn_Click(object sender, EventArgs e) private void btnAxisOn_Click(object sender, EventArgs e)
{ {
this.Enabled = false; this.Enabled = false;
equipBean.RunAxis(false,equipBean.Config.Batch_Axis); equipBean.RunAxis(false, equipBean.BatchAxis);
this.Enabled = true; this.Enabled = true;
LogUtil.info("伺服运转ON完成"); LogUtil.info("伺服运转ON完成");
} }
private void btnCloseAll_Click(object sender, EventArgs e) private void btnCloseAll_Click(object sender, EventArgs e)
{ {
...@@ -460,14 +458,12 @@ namespace OnlineStore.AssemblyLine ...@@ -460,14 +458,12 @@ namespace OnlineStore.AssemblyLine
private void button3_Click(object sender, EventArgs e) private void button3_Click(object sender, EventArgs e)
{ {
int position = FormUtil.GetIntValue(txtP1); int position = FormUtil.GetIntValue(txtP1);
if (position != -1)
{ int speed = equipBean.Config.UpdownAxis_P2Speed;
int speed =equipBean.Config.UpdownAxis_P2Speed;
string portName = equipBean.Config.UpDown_Axis.DeviceName; LogUtil.info("点击【P1点测试】, 位置【" + position + "】速度【" + speed + "】");
int SlvAddr = equipBean.Config.UpDown_Axis.GetAxisValue(); equipBean.UpdownAxis.AbsMove(position, speed);
LogUtil.info("点击【P1点测试】, 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed);
}
} }
private void btnSave_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e)
...@@ -477,12 +473,12 @@ namespace OnlineStore.AssemblyLine ...@@ -477,12 +473,12 @@ namespace OnlineStore.AssemblyLine
int size = 0; int size = 0;
try { size = Convert.ToInt32(cmbSizeList.Text); } catch (Exception ex) { } try { size = Convert.ToInt32(cmbSizeList.Text); } catch (Exception ex) { }
int sizePosition = FormUtil.GetIntValue(txtSizePosition); int sizePosition = FormUtil.GetIntValue(txtSizePosition);
equipBean.Config.UpdateUpdownPositon(size, sizePosition); equipBean.Config.UpdateUpdownPositon(size, sizePosition);
//equipBean.Config.UpdateUpdownBoxPositon(size, sizeBoxP); //equipBean.Config.UpdateUpdownBoxPositon(size, sizeBoxP);
LineManager.SaveFeedingEquipConfig(equipBean.Config); LineManager.SaveFeedingEquipConfig(equipBean.Config);
MessageBox.Show("保存成功!"); MessageBox.Show("保存成功!");
} }
private void btnLineRun_Click(object sender, EventArgs e) private void btnLineRun_Click(object sender, EventArgs e)
{ {
...@@ -512,19 +508,19 @@ namespace OnlineStore.AssemblyLine ...@@ -512,19 +508,19 @@ namespace OnlineStore.AssemblyLine
private void btnBP1_Click(object sender, EventArgs e) private void btnBP1_Click(object sender, EventArgs e)
{ {
int position = FormUtil.GetIntValue(txtBp1); int position = FormUtil.GetIntValue(txtBp1);
ACServerManager.AbsMove(equipBean.Config.Batch_Axis.DeviceName, equipBean.Config.Batch_Axis.GetAxisValue(), position, equipBean.Config.BatchAxis_P1Speed); equipBean.BatchAxis.AbsMove(position, equipBean.Config.BatchAxis_P1Speed);
} }
private void btnBP2_Click(object sender, EventArgs e) private void btnBP2_Click(object sender, EventArgs e)
{ {
int position = FormUtil.GetIntValue(txtBP2); int position = FormUtil.GetIntValue(txtBP2);
ACServerManager.AbsMove(equipBean.Config.Batch_Axis.DeviceName, equipBean.Config.Batch_Axis.GetAxisValue(), position, equipBean.Config.BatchAxis_P2Speed); equipBean.BatchAxis.AbsMove(position, equipBean.Config.BatchAxis_P2Speed);
} }
private void btnBP3_Click(object sender, EventArgs e) private void btnBP3_Click(object sender, EventArgs e)
{ {
int position = FormUtil.GetIntValue(txtBP3); int position = FormUtil.GetIntValue(txtBP3);
ACServerManager.AbsMove(equipBean.Config.Batch_Axis.DeviceName, equipBean.Config.Batch_Axis.GetAxisValue(), position, equipBean.Config.BatchAxis_P3Speed); equipBean.BatchAxis.AbsMove(position, equipBean.Config.BatchAxis_P3Speed);
} }
private void btnBSave_Click(object sender, EventArgs e) private void btnBSave_Click(object sender, EventArgs e)
...@@ -539,7 +535,7 @@ namespace OnlineStore.AssemblyLine ...@@ -539,7 +535,7 @@ namespace OnlineStore.AssemblyLine
MessageBox.Show("保存成功!"); MessageBox.Show("保存成功!");
} }
} }
} }
...@@ -41,7 +41,7 @@ namespace OnlineStore.AssemblyLine ...@@ -41,7 +41,7 @@ namespace OnlineStore.AssemblyLine
{ {
portName = equipBean.Config.UpDown_Axis.DeviceName; portName = equipBean.Config.UpDown_Axis.DeviceName;
SlvAddr = equipBean.Config.UpDown_Axis.GetAxisValue(); SlvAddr = equipBean.Config.UpDown_Axis.GetAxisValue();
axisMoveControl1.LoadData(equipBean, new ConfigMoveAxis[] { equipBean.Config.UpDown_Axis }); axisMoveControl1.LoadData(equipBean, new AxisBean[] { equipBean.UpdownAxis });
btnUpDownUp.Visible = false; btnUpDownUp.Visible = false;
} }
else else
...@@ -392,26 +392,24 @@ namespace OnlineStore.AssemblyLine ...@@ -392,26 +392,24 @@ namespace OnlineStore.AssemblyLine
private void btnMoveto_Click(object sender, EventArgs e) private void btnMoveto_Click(object sender, EventArgs e)
{ {
int position = FormUtil.GetIntValue(txtP2); int position = FormUtil.GetIntValue(txtP2);
if (position != -1)
{
int speed = equipBean.Config.UpdownAxis_DownSpeed; int speed = equipBean.Config.UpdownAxis_DownSpeed;
LogUtil.info("点击【移栽位置】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】"); LogUtil.info("点击【移栽位置】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed); equipBean.UpdownAxis.AbsMove(position, speed);
}
} }
private void btnAxisOn_Click(object sender, EventArgs e) private void btnAxisOn_Click(object sender, EventArgs e)
{ {
this.Enabled = false; this.Enabled = false;
equipBean.RunAxis(false,equipBean.Config.UpDown_Axis); equipBean.RunAxis(false,equipBase.UpdownAxis);
this.Enabled = true; this.Enabled = true;
LogUtil.info("伺服运转ON完成"); LogUtil.info("伺服运转ON完成");
} }
private void btnAxisOff_Click(object sender, EventArgs e) private void btnAxisOff_Click(object sender, EventArgs e)
{ {
equipBean.CloseAxis(equipBean.Config.UpDown_Axis); equipBean.CloseAxis(equipBase.UpdownAxis);
LogUtil.info("伺服运转OFF完成"); LogUtil.info("伺服运转OFF完成");
} }
...@@ -430,12 +428,11 @@ namespace OnlineStore.AssemblyLine ...@@ -430,12 +428,11 @@ namespace OnlineStore.AssemblyLine
private void button3_Click(object sender, EventArgs e) private void button3_Click(object sender, EventArgs e)
{ {
int position = FormUtil.GetIntValue(txtP1); int position = FormUtil.GetIntValue(txtP1);
if (position != -1)
{
int speed =equipBean.Config.UpdownAxis_P1Speed; int speed =equipBean.Config.UpdownAxis_P1Speed;
LogUtil.info("点击【P1点测试】, 位置【" + position + "】速度【" + speed + "】"); LogUtil.info("点击【P1点测试】, 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed); equipBean.UpdownAxis.AbsMove(position, speed);
}
} }
private void btnSave_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e)
...@@ -456,12 +453,11 @@ namespace OnlineStore.AssemblyLine ...@@ -456,12 +453,11 @@ namespace OnlineStore.AssemblyLine
private void btnBoxP_Click(object sender, EventArgs e) private void btnBoxP_Click(object sender, EventArgs e)
{ {
int position = FormUtil.GetIntValue(txtP3); int position = FormUtil.GetIntValue(txtP3);
if (position != -1)
{
int speed = equipBean.Config.UpdownAxis_DownSpeed; int speed = equipBean.Config.UpdownAxis_DownSpeed;
LogUtil.info("点击【料仓门口下降位置】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】"); LogUtil.info("点击【料仓门口下降位置】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed); equipBean.UpdownAxis.AbsMove(position, speed);
}
} }
} }
......
...@@ -180,7 +180,7 @@ namespace OnlineStore.AssemblyLine ...@@ -180,7 +180,7 @@ namespace OnlineStore.AssemblyLine
{ {
if (equipBean.UseAxis) if (equipBean.UseAxis)
{ {
axisMoveControl1.LoadData(equipBean, new ConfigMoveAxis[] { equipBean.Config.UpDown_Axis }); axisMoveControl1.LoadData(equipBean, new AxisBean[] { equipBean.UpdownAxis });
cmbSizeList.Items.Clear(); cmbSizeList.Items.Clear();
cmbSizeList.Items.Add("0=默认位置"); cmbSizeList.Items.Add("0=默认位置");
for (int i = 8; i <= 48; i = i + 4) for (int i = 8; i <= 48; i = i + 4)
...@@ -372,12 +372,10 @@ namespace OnlineStore.AssemblyLine ...@@ -372,12 +372,10 @@ namespace OnlineStore.AssemblyLine
int position = FormUtil.GetIntValue(txtP3); int position = FormUtil.GetIntValue(txtP3);
if (position != -1) if (position != -1)
{ {
string portName = equipBean.Config.UpDown_Axis.DeviceName;
int SlvAddr = equipBean.Config.UpDown_Axis.GetAxisValue();
int speed = equipBean.Config.UpdownAxis_DownSpeed; int speed = equipBean.Config.UpdownAxis_DownSpeed;
LogUtil.info("点击【出料皮带线位置P3】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】"); LogUtil.info("点击【出料皮带线位置P3】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed); equipBase.UpdownAxis.AbsMove(position, speed);
} }
} }
...@@ -385,12 +383,10 @@ namespace OnlineStore.AssemblyLine ...@@ -385,12 +383,10 @@ namespace OnlineStore.AssemblyLine
{ {
int position = FormUtil.GetIntValue(txtP2); int position = FormUtil.GetIntValue(txtP2);
if (position != -1) if (position != -1)
{ {
string portName = equipBean.Config.UpDown_Axis.DeviceName;
int SlvAddr = equipBean.Config.UpDown_Axis.GetAxisValue();
int speed = equipBean.Config.UpdownAxis_DownSpeed; int speed = equipBean.Config.UpdownAxis_DownSpeed;
LogUtil.info("点击【移栽位置】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】"); LogUtil.info("点击【移栽位置】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed); equipBase.UpdownAxis.AbsMove(position, speed);
} }
} }
...@@ -398,12 +394,10 @@ namespace OnlineStore.AssemblyLine ...@@ -398,12 +394,10 @@ namespace OnlineStore.AssemblyLine
{ {
int position = FormUtil.GetIntValue(txtP1); int position = FormUtil.GetIntValue(txtP1);
if (position != -1) if (position != -1)
{ {
string portName = equipBean.Config.UpDown_Axis.DeviceName;
int SlvAddr = equipBean.Config.UpDown_Axis.GetAxisValue();
int speed = equipBean.Config.UpdownAxis_P1Speed; int speed = equipBean.Config.UpdownAxis_P1Speed;
LogUtil.info("点击【P1点测试】, 位置【" + position + "】速度【" + speed + "】"); LogUtil.info("点击【P1点测试】, 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed); equipBase.UpdownAxis.AbsMove(position, speed);
} }
} }
......
...@@ -16,7 +16,7 @@ namespace OnlineStore.AssemblyLine ...@@ -16,7 +16,7 @@ namespace OnlineStore.AssemblyLine
{ {
public partial class AxisMoveControl : UserControl public partial class AxisMoveControl : UserControl
{ {
private List<ConfigMoveAxis> axisList = new List<ConfigMoveAxis>(); private List<AxisBean> axisList = new List<AxisBean>();
private EquipBase equipBase = null; private EquipBase equipBase = null;
private string PortName = ""; private string PortName = "";
private int SlvAddr = 0; private int SlvAddr = 0;
...@@ -25,37 +25,30 @@ namespace OnlineStore.AssemblyLine ...@@ -25,37 +25,30 @@ namespace OnlineStore.AssemblyLine
{ {
InitializeComponent(); InitializeComponent();
} }
public void LoadData(EquipBase equipBase, params ConfigMoveAxis[] moveAxis) public void LoadData(EquipBase equipBase, params AxisBean[] moveAxis)
{ {
this.equipBase = equipBase; this.equipBase = equipBase;
axisList = new List<ConfigMoveAxis>(moveAxis); axisList = new List<AxisBean>(moveAxis);
if (axisList.Count > 0) if (axisList.Count > 0)
{ {
comboBox1.Items.Clear(); comboBox1.Items.Clear();
foreach (ConfigMoveAxis a in axisList) foreach (AxisBean a in axisList)
{ {
comboBox1.Items.Add(a.Explain); comboBox1.Items.Add(a.Config.Explain);
} }
comboBox1.SelectedIndex = 0; comboBox1.SelectedIndex = 0;
PortName = moveAxis[0].DeviceName; PortName = moveAxis[0].Config.DeviceName;
SlvAddr = moveAxis[0].GetAxisValue(); SlvAddr = moveAxis[0].Config.GetAxisValue();
txtAxisDeviceName.Text = PortName; txtAxisDeviceName.Text = PortName;
txtAxisValue.Text = SlvAddr.ToString(); txtAxisValue.Text = SlvAddr.ToString();
} }
} }
private void btnOpenAxis_Click(object sender, EventArgs e) private void btnOpenAxis_Click(object sender, EventArgs e)
{ {
//string portName = txtAxisDeviceName.Text;
//short SlvAddr = FormUtil.GetShortValue(txtAxisValue);
//ACServerManager.OpenPort(portName);
//ACServerManager.AlarmClear(portName, SlvAddr);
//Thread.Sleep(100);
//ACServerManager.ServoOn(portName, SlvAddr);
LogUtil.info("点击【打开伺服】,端口号【" + PortName + "】地址【" + SlvAddr + "】 "); LogUtil.info("点击【打开伺服】,端口号【" + PortName + "】地址【" + SlvAddr + "】 ");
equipBase.OpenAxis(axisList[comboBox1.SelectedIndex]); equipBase.RunAxis(false, axisList[comboBox1.SelectedIndex]);
} }
private void btnCloseAxis_Click(object sender, EventArgs e) private void btnCloseAxis_Click(object sender, EventArgs e)
...@@ -132,7 +125,7 @@ namespace OnlineStore.AssemblyLine ...@@ -132,7 +125,7 @@ namespace OnlineStore.AssemblyLine
{ {
if (comboBox1.SelectedIndex > 0) if (comboBox1.SelectedIndex > 0)
{ {
ConfigMoveAxis axis = axisList[comboBox1.SelectedIndex]; ConfigMoveAxis axis = axisList[comboBox1.SelectedIndex].Config;
PortName = axis.DeviceName; PortName = axis.DeviceName;
SlvAddr = axis.GetAxisValue(); SlvAddr = axis.GetAxisValue();
txtAxisDeviceName.Text = PortName; txtAxisDeviceName.Text = PortName;
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
<Compile Include="assemblyLine\FeedingEquip.cs" /> <Compile Include="assemblyLine\FeedingEquip.cs" />
<Compile Include="assemblymanager\StoreServerManager.cs" /> <Compile Include="assemblymanager\StoreServerManager.cs" />
<Compile Include="assemblymanager\TrayManager.cs" /> <Compile Include="assemblymanager\TrayManager.cs" />
<Compile Include="baan\AxisBean.cs" />
<Compile Include="deviceLibrary\halcon\CodeManager.cs" /> <Compile Include="deviceLibrary\halcon\CodeManager.cs" />
<Compile Include="deviceLibrary\IO\AIOBOX\AIOBOXManager.cs" /> <Compile Include="deviceLibrary\IO\AIOBOX\AIOBOXManager.cs" />
<Compile Include="deviceLibrary\IO\IOManager.cs" /> <Compile Include="deviceLibrary\IO\IOManager.cs" />
......
...@@ -31,7 +31,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -31,7 +31,10 @@ namespace OnlineStore.DeviceLibrary
/// 当前正在通过的托盘号 /// 当前正在通过的托盘号
/// </summary> /// </summary>
protected int currTrayNum = 0; protected int currTrayNum = 0;
/// <summary>
/// 升降轴
/// </summary>
public AxisBean UpdownAxis = null;
protected abstract void ReturnHomeProcess(); protected abstract void ReturnHomeProcess();
protected virtual void StopMoveProcess() protected virtual void StopMoveProcess()
{ {
...@@ -44,7 +47,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -44,7 +47,7 @@ namespace OnlineStore.DeviceLibrary
BaseTimerProcess(); BaseTimerProcess();
} }
public override void Alarm(LineAlarmType alarmType ) public override void Alarm(LineAlarmType alarmType)
{ {
if (this.alarmType.Equals(alarmType)) if (this.alarmType.Equals(alarmType))
{ {
...@@ -108,7 +111,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -108,7 +111,7 @@ namespace OnlineStore.DeviceLibrary
CheckFixtureProcess(); CheckFixtureProcess();
} }
} }
private DateTime lastProTimer = DateTime.Now; private DateTime lastProTimer = DateTime.Now;
private void BaseTimerProcess() private void BaseTimerProcess()
{ {
...@@ -136,7 +139,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -136,7 +139,7 @@ namespace OnlineStore.DeviceLibrary
isInPro = false; isInPro = false;
} }
protected DateTime preIoTimerOutTime = DateTime.Now; protected DateTime preIoTimerOutTime = DateTime.Now;
...@@ -232,188 +235,40 @@ namespace OnlineStore.DeviceLibrary ...@@ -232,188 +235,40 @@ namespace OnlineStore.DeviceLibrary
#region 伺服运动 #region 伺服运动
public bool RunAxis(bool isCheck, ConfigMoveAxis axis) public bool RunAxis(bool isCheck, AxisBean axis)
{ {
if (!UseAxis) if (!UseAxis)
{ {
return true; return true;
} }
string portName = axis.DeviceName; IOMove(axis.Config.ServerOnDO, IO_VALUE.HIGH);
int slvAddr = axis.GetAxisValue(); string msg = "";
IOMove(axis.ServerOnDO, IO_VALUE.HIGH); bool result = axis.Open(isCheck, out msg);
Thread.Sleep(1000); if (result && String.IsNullOrEmpty(msg))
//打开所有轴
ACServerManager.OpenPort(portName);
Thread.Sleep(50);
//初始化
if (!IsIntSlvBlock)
{
ACServerManager.InitSlvAddr(portName, slvAddr, axis.TargetSpeed, axis.AddSpeed, axis.DelSpeed);
Thread.Sleep(100);
}
ACServerManager.AlarmClear(portName, slvAddr);
Thread.Sleep(50);
ACServerManager.ServoOn(portName, slvAddr);
Thread.Sleep(1000);
//打开所有轴
if (isCheck)
{
if (!OpenAxis(axis))
{
return false;
}
}
IsIntSlvBlock = true;
IOMove(axis.BreakOnDO, IO_VALUE.HIGH);
return true;
}
/// <summary>
/// 打开所有轴
/// </summary>
/// <returns></returns>
public bool OpenAxis(ConfigMoveAxis axis)
{
//判断轴是否正常
string portName = axis.DeviceName;
int slvAddr = axis.GetAxisValue();
if (ACServerManager.ServerOnStatus(portName, slvAddr))
{
LogUtil.info(Name + "成功打开轴:" + axis.Explain);
}
else
{ {
//清理报警,再重新打开一次 IOMove(axis.Config.BreakOnDO, IO_VALUE.HIGH);
LogUtil.info(Name + "第一次打开轴" + axis.Explain + "失败,先清理一下报警,再重新打开一次"); return true;
ACServerManager.AlarmClear(portName, slvAddr);
System.Threading.Thread.Sleep(1200);
ACServerManager.ServoOn(portName, slvAddr);
System.Threading.Thread.Sleep(100);
if (ACServerManager.ServerOnStatus(portName, slvAddr))
{
LogUtil.info(Name + "清理报警后重新打卡轴成功:" + axis.Explain);
}
else
{
ACServerManager.ServoOff(portName, slvAddr);
WarnMsg = Name + "打开轴" + axis.Explain + "失败 ";
LogUtil.info(Name + WarnMsg);
Alarm(LineAlarmType.AxisAlarm );
return false;
}
} }
WarnMsg = Name + msg;
return true; Alarm(LineAlarmType.AxisAlarm);
return false;
} }
public void CloseAxis(AxisBean axis)
public void CloseAxis(ConfigMoveAxis axis)
{ {
string portName = axis.DeviceName;
int slvAddr = axis.GetAxisValue();
LogUtil.info(Name + "关闭刹车,关闭伺服"); LogUtil.info(Name + "关闭刹车,关闭伺服");
IOMove(axis.BreakOnDO, IO_VALUE.LOW); IOMove(axis.Config.BreakOnDO, IO_VALUE.LOW);
axis.Close();
ACServerManager.ServoOff(portName, slvAddr);
//关闭串口,等下次重新打开
ACServerManager.ColsePort(portName);
Thread.Sleep(100); Thread.Sleep(100);
IOMove(axis.ServerOnDO, IO_VALUE.LOW); IOMove(axis.Config.ServerOnDO, IO_VALUE.LOW);
} }
protected void ACAxisHomeMove(ConfigMoveAxis moveAxis)
{
moveAxis.TargetPosition = 0;
LogUtil.info(moveAxis.DisplayStr + "speed[" + moveAxis.TargetSpeed + "]开始原点返回");
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, true));
ACServerManager.HomeMove(moveAxis.DeviceName, (short)moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed);
}
/// <summary>
/// 松下伺服电机运动
/// </summary>
protected void ACAxisMove(ConfigMoveAxis moveAxis, int targetPosition, int targetSpeed)
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, targetPosition, targetSpeed));
moveAxis.TargetPosition = targetPosition;
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed);
}
/// <summary>
/// 判断AC伺服电机轴是否运动完成
/// </summary>
protected bool ACAxisMoveIsEnd(ConfigMoveAxis moveAxis, int targetPosition, int targetSpeed, out string msg)
{
msg = "";
string deviceName = moveAxis.DeviceName;
short axisNo = moveAxis.GetAxisValue();
bool isOk = ACServerManager.GetBusyStatus(deviceName, axisNo).Equals(0);
int outCount = ACServerManager.GetActualtPosition(deviceName, axisNo);
int errorCount = Math.Abs(outCount - targetPosition);
if (isOk)
{
if (errorCount <= moveAxis.CanErrorCountMax)
{
return true;
}
//判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0)
{
LogUtil.error(moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount +
"],误差过大,重新开始运动,剩余[" + MoveInfo.CanWhileCount + "]次");
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed);
MoveInfo.CanWhileCount--;
}
else
{
msg = Name + " storeMoveStep=" + MoveInfo.MoveStep + moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount
+ "],误差过大,需要报警";
LogUtil.error(msg);
}
}
return false;
}
protected bool ACHomeMoveIsEnd(ConfigMoveAxis moveAxis, out string msg)
{
msg = "";
if (ACServerManager.IsHomeMoveEnd(moveAxis.DeviceName, moveAxis.GetAxisValue()))
{
//原点完成并且位置=0
int outCount = ACServerManager.GetActualtPosition(moveAxis.DeviceName, moveAxis.GetAxisValue());
int errorCount = Math.Abs(outCount);
if (errorCount <= moveAxis.CanErrorCountMax)
{
return true;
}
//判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0)
{
LogUtil.error(moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],重新回原点,剩余[" + MoveInfo.CanWhileCount + "]次");
//LogUtil.error( StoreName + moveAxis.DisplayStr + "重新回原点");
ACServerManager.HomeMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed);
MoveInfo.CanWhileCount--;
}
else
{
msg = Name + " storeMoveStep=" + MoveInfo.MoveStep + moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警";
LogUtil.error(msg);
}
}
return false;
}
#endregion #endregion
#region CheckWait处理 #region CheckWait处理
protected DateTime preRWTime = DateTime.Now; protected DateTime preRWTime = DateTime.Now;
protected void CheckWait(LineMoveInfo moveInfo) protected void CheckWait(LineMoveInfo moveInfo)
{ {
...@@ -444,11 +299,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -444,11 +299,11 @@ namespace OnlineStore.DeviceLibrary
string msg = ""; string msg = "";
if (wait.IsHomeMove) if (wait.IsHomeMove)
{ {
wait.IsEnd = ACHomeMoveIsEnd(wait.AxisInfo, out msg); wait.IsEnd = AxisBean.HomeMoveIsEnd(moveInfo, wait.AxisInfo, out msg);
} }
else else
{ {
wait.IsEnd = ACAxisMoveIsEnd(wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg); wait.IsEnd = AxisBean.ACAxisMoveIsEnd(moveInfo, wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
} }
if (!msg.Equals("")) if (!msg.Equals(""))
{ {
...@@ -485,7 +340,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -485,7 +340,7 @@ namespace OnlineStore.DeviceLibrary
ConfigIO io = baseConfig.getWaitIO(wait.IoType); ConfigIO io = baseConfig.getWaitIO(wait.IoType);
WarnMsg = Name + "等待" + NotOkMsg + " 超时"; WarnMsg = Name + "等待" + NotOkMsg + " 超时";
Alarm(LineAlarmType.IoSingleTimeOut); Alarm(LineAlarmType.IoSingleTimeOut);
LogUtil.error(MoveInfo.Name + WarnMsg, DeviceID+ 13); LogUtil.error(MoveInfo.Name + WarnMsg, DeviceID + 13);
} }
else if (rwSpan.TotalSeconds > 3 && span.TotalSeconds > 3) else if (rwSpan.TotalSeconds > 3 && span.TotalSeconds > 3)
{ {
...@@ -528,7 +383,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -528,7 +383,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
wait.IsEnd = CheckWaitResult(wait); wait.IsEnd = CheckWaitResult(moveInfo, wait);
} }
//else if (wait.WaitType.Equals(10)) //else if (wait.WaitType.Equals(10))
//{ //{
...@@ -553,13 +408,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -553,13 +408,13 @@ namespace OnlineStore.DeviceLibrary
{ {
WarnMsg = moveInfo.Name + "[" + moveInfo.MoveType + "][" + moveInfo.MoveStep + "]等待[" + NotOkMsg WarnMsg = moveInfo.Name + "[" + moveInfo.MoveType + "][" + moveInfo.MoveStep + "]等待[" + NotOkMsg
+ "]超时[" + Math.Round(span.TotalSeconds, 1) + "]秒"; + "]超时[" + Math.Round(span.TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg,DeviceID+ 18); LogUtil.error(WarnMsg, DeviceID + 18);
Alarm(LineAlarmType.IoSingleTimeOut ); Alarm(LineAlarmType.IoSingleTimeOut);
} }
} }
protected virtual bool CheckWaitResult(WaitResultInfo wait) protected virtual bool CheckWaitResult(LineMoveInfo moveInfo, WaitResultInfo wait)
{ {
return false; return false;
} }
......
...@@ -16,7 +16,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -16,7 +16,8 @@ namespace OnlineStore.DeviceLibrary
public partial class FeedingEquip : EquipBase public partial class FeedingEquip : EquipBase
{ {
public FeedingEquip_Config Config; public FeedingEquip_Config Config;
public AxisBean BatchAxis = null;
public FeedingEquip(string cid, FeedingEquip_Config config) public FeedingEquip(string cid, FeedingEquip_Config config)
{ {
this.DeviceID = config.Id; this.DeviceID = config.Id;
...@@ -24,13 +25,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -24,13 +25,15 @@ namespace OnlineStore.DeviceLibrary
this.Config = config; this.Config = config;
IsDebug = config.IsDebug.Equals(1); IsDebug = config.IsDebug.Equals(1);
Name = (" " + "_入料_" + DeviceID % 100 + " ").ToUpper(); Name = (" " + "_入料_" + DeviceID % 100 + " ").ToUpper();
Init(); Init();
MoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-Move");
SecondMoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-SecondMove");
UseAxis = true; UseAxis = true;
Config.SetAxisParam(); Config.SetAxisParam();
UpdownAxis = new AxisBean(config.UpDown_Axis);
BatchAxis = new AxisBean(config.Batch_Axis);
MoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-Move");
SecondMoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-SecondMove");
} }
/// <summary> /// <summary>
/// 开始运行 /// 开始运行
...@@ -120,22 +123,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -120,22 +123,18 @@ namespace OnlineStore.DeviceLibrary
{ {
mainTimer.Stop(); mainTimer.Stop();
StopMove(); StopMove();
if (!RunAxis(true,Config.Batch_Axis)) if (RunAxis(true, BatchAxis) && RunAxis(true, UpdownAxis))
{ {
return false;
}
if (!RunAxis(true, Config.UpDown_Axis))
{
return false;
}
alarmType = LineAlarmType.None;
runStatus = LineRunStatus.HomeMoving;
LogInfo("开始原点返回: ");
MoveInfo.NewMove(LineMoveType.ReturnHome);
StartReset(); alarmType = LineAlarmType.None;
return true; runStatus = LineRunStatus.HomeMoving;
LogInfo("开始原点返回: ");
MoveInfo.NewMove(LineMoveType.ReturnHome);
StartReset();
return true;
}return false;
} }
/// <summary> /// <summary>
/// 入料装置重置 /// 入料装置重置
...@@ -143,21 +142,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -143,21 +142,16 @@ namespace OnlineStore.DeviceLibrary
public override bool Reset() public override bool Reset()
{ {
WarnMsg = ""; WarnMsg = "";
StopMove(); StopMove();
if (!RunAxis(true, Config.Batch_Axis)) if (RunAxis(true, BatchAxis) && RunAxis(true, UpdownAxis))
{
return false;
}
if (!RunAxis(true, Config.UpDown_Axis))
{ {
return false; alarmType = LineAlarmType.None;
} LogInfo("开始重置: ");
alarmType = LineAlarmType.None; runStatus = LineRunStatus.Reset;
LogInfo("开始重置: "); MoveInfo.NewMove(LineMoveType.Reset);
runStatus = LineRunStatus.Reset; StartReset();
MoveInfo.NewMove(LineMoveType.Reset); return true;
StartReset(); }return false;
return true;
} }
private void StartReset() private void StartReset()
{ {
...@@ -210,14 +204,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -210,14 +204,14 @@ namespace OnlineStore.DeviceLibrary
case LineMoveStep.FR_04_LocationCylinder_Down: case LineMoveStep.FR_04_LocationCylinder_Down:
LogInfo(MoveInfo.MoveType + ":FR_05_AxisHomeMove:2伺服原点返回"); LogInfo(MoveInfo.MoveType + ":FR_05_AxisHomeMove:2伺服原点返回");
MoveInfo.NextMoveStep(LineMoveStep.FR_05_AxisHomeMove); MoveInfo.NextMoveStep(LineMoveStep.FR_05_AxisHomeMove);
ACAxisHomeMove(Config.Batch_Axis); BatchAxis.HomeMove(MoveInfo);
ACAxisHomeMove(Config.UpDown_Axis); UpdownAxis.HomeMove(MoveInfo);
break; break;
case LineMoveStep.FR_05_AxisHomeMove: case LineMoveStep.FR_05_AxisHomeMove:
LogInfo(MoveInfo.MoveType + ":FR_06_AxisToP1:2伺服到P1点"); LogInfo(MoveInfo.MoveType + ":FR_06_AxisToP1:2伺服到P1点");
MoveInfo.NextMoveStep(LineMoveStep.FR_06_AxisToP1); MoveInfo.NextMoveStep(LineMoveStep.FR_06_AxisToP1);
ACAxisMove(Config.Batch_Axis, Config.BatchAxisP1, Config.BatchAxis_P1Speed); BatchAxis.AbsMove (MoveInfo, Config.BatchAxisP1, Config.BatchAxis_P1Speed);
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed); UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
break; break;
case LineMoveStep.FR_06_AxisToP1: case LineMoveStep.FR_06_AxisToP1:
LogInfo(MoveInfo.MoveType + ":FR_07_MoveCylinder_Up:上料横移机构上升SOL"); LogInfo(MoveInfo.MoveType + ":FR_07_MoveCylinder_Up:上料横移机构上升SOL");
...@@ -254,8 +248,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -254,8 +248,8 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.EndMove(); MoveInfo.EndMove();
SecondMoveInfo.EndMove(); SecondMoveInfo.EndMove();
BatchAxisStopCheck(); BatchAxisStopCheck();
ACServerManager.SuddenStop(Config.Batch_Axis); BatchAxis.SuddenStop();
ACServerManager.SuddenStop(Config.UpDown_Axis); UpdownAxis.SuddenStop();
if (Config.SidesWayNum <= 0) if (Config.SidesWayNum <= 0)
{ {
IOMove(IO_Type.FL_StopCylinder_Down1, IO_VALUE.LOW); IOMove(IO_Type.FL_StopCylinder_Down1, IO_VALUE.LOW);
...@@ -373,7 +367,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -373,7 +367,7 @@ namespace OnlineStore.DeviceLibrary
if (IOValue(TargetIoType).Equals(TargetIoValue)) if (IOValue(TargetIoType).Equals(TargetIoValue))
{ {
LogUtil.info(Name+ "上料轴,检测到 " + TargetIoType + "=" + TargetIoValue + ",可以停止运动"); LogUtil.info(Name+ "上料轴,检测到 " + TargetIoType + "=" + TargetIoValue + ",可以停止运动");
ACServerManager.SuddenStop(Config.Batch_Axis.DeviceName, Config.Batch_Axis.GetAxisValue()); BatchAxis.SuddenStop();
BatchAxisStopCheck(); BatchAxisStopCheck();
} }
IsInProcess = false; IsInProcess = false;
......
...@@ -10,7 +10,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -10,7 +10,7 @@ namespace OnlineStore.DeviceLibrary
{ {
partial class FeedingEquip partial class FeedingEquip
{ {
protected override bool CheckWaitResult(WaitResultInfo wait) protected override bool CheckWaitResult(LineMoveInfo moveInfo,WaitResultInfo wait)
{ {
if (wait.WaitType.Equals(WaitEnum.W101_BatchAxisMove)) if (wait.WaitType.Equals(WaitEnum.W101_BatchAxisMove))
{ {
...@@ -21,7 +21,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -21,7 +21,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
bool result = ACAxisMoveIsEnd(wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg); bool result = AxisBean.ACAxisMoveIsEnd(moveInfo, wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
if (!result) if (!result)
{ {
LogUtil.error(msg); LogUtil.error(msg);
...@@ -193,7 +193,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -193,7 +193,7 @@ namespace OnlineStore.DeviceLibrary
LogInfo(SecondMoveInfo.MoveNum + "*************** 托盘号【" + currTrayNum + "】 ,需要出库,开始出库处理,升降伺服到P1点"); LogInfo(SecondMoveInfo.MoveNum + "*************** 托盘号【" + currTrayNum + "】 ,需要出库,开始出库处理,升降伺服到P1点");
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_201_UpDownToP1); SecondMoveInfo.NextMoveStep(LineMoveStep.MO_201_UpDownToP1);
InStoreLog(" MO_201_UpDownToP1 紧急出料移栽:升降伺服到P1点" ); InStoreLog(" MO_201_UpDownToP1 紧急出料移栽:升降伺服到P1点" );
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed); UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
} }
else else
...@@ -305,7 +305,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -305,7 +305,7 @@ namespace OnlineStore.DeviceLibrary
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_204_UpdownAxisToP2); SecondMoveInfo.NextMoveStep(LineMoveStep.MO_204_UpdownAxisToP2);
int targetP = Config.GetUpdownPositionP2(SecondMoveInfo.MoveParam.PlateH); int targetP = Config.GetUpdownPositionP2(SecondMoveInfo.MoveParam.PlateH);
InStoreLog(" MO_204_UpdownAxisToP2 紧急出料移栽:升降伺服下降到指定位置"+targetP); InStoreLog(" MO_204_UpdownAxisToP2 紧急出料移栽:升降伺服下降到指定位置"+targetP);
ACAxisMove(Config.UpDown_Axis, targetP, Config.UpdownAxis_P2Speed); UpdownAxis.AbsMove(MoveInfo, targetP, Config.UpdownAxis_P2Speed);
} }
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_204_UpdownAxisToP2)) else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_204_UpdownAxisToP2))
{ {
...@@ -317,7 +317,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -317,7 +317,7 @@ namespace OnlineStore.DeviceLibrary
{ {
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_206_UpdownAxisToP1); SecondMoveInfo.NextMoveStep(LineMoveStep.MO_206_UpdownAxisToP1);
InStoreLog(" MO_206_UpdownAxisToP1 紧急出料移栽:升降伺服到P1"); InStoreLog(" MO_206_UpdownAxisToP1 紧急出料移栽:升降伺服到P1");
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed); UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
} }
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_206_UpdownAxisToP1)) else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_206_UpdownAxisToP1))
{ {
...@@ -471,7 +471,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -471,7 +471,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(LineMoveStep.FI_08_BatchAxisToP2); MoveInfo.NextMoveStep(LineMoveStep.FI_08_BatchAxisToP2);
InStoreLog(" FI_08_BatchAxisToP2 开始:提升轴下降到位P2"); InStoreLog(" FI_08_BatchAxisToP2 开始:提升轴下降到位P2");
IOMove(IO_Type.Line_Run, IO_VALUE.LOW); IOMove(IO_Type.Line_Run, IO_VALUE.LOW);
ACAxisMove(Config.Batch_Axis, Config.BatchAxisP2, Config.BatchAxis_P2Speed); BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
} }
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_08_BatchAxisToP2)) else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_08_BatchAxisToP2))
{ {
...@@ -499,7 +499,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -499,7 +499,7 @@ namespace OnlineStore.DeviceLibrary
//无料盘 //无料盘
MoveInfo.NextMoveStep(LineMoveStep.FI_31_BatchAxisToP2); MoveInfo.NextMoveStep(LineMoveStep.FI_31_BatchAxisToP2);
InStoreLog(" FI_31_BatchAxisToP2 料盘移栽:未检测到料盘,提升伺服到P2点"); InStoreLog(" FI_31_BatchAxisToP2 料盘移栽:未检测到料盘,提升伺服到P2点");
ACAxisMove(Config.Batch_Axis, Config.BatchAxisP2, Config.BatchAxis_P2Speed); BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
} }
} }
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_11_MoveCylinder_Take)) else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_11_MoveCylinder_Take))
...@@ -559,7 +559,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -559,7 +559,7 @@ namespace OnlineStore.DeviceLibrary
int targetPositon = Config.GetUpdownPositionP2(LastHeight); int targetPositon = Config.GetUpdownPositionP2(LastHeight);
InStoreLog(" FI_19_UpdownAxisToP2 料盘移栽:移栽伺服下降到指定位置:" + targetPositon); InStoreLog(" FI_19_UpdownAxisToP2 料盘移栽:移栽伺服下降到指定位置:" + targetPositon);
ACAxisMove(Config.UpDown_Axis, targetPositon, Config.UpdownAxis_P2Speed); UpdownAxis.AbsMove(MoveInfo, targetPositon, Config.UpdownAxis_P2Speed);
} }
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_19_UpdownAxisToP2)) else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_19_UpdownAxisToP2))
{ {
...@@ -571,7 +571,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -571,7 +571,7 @@ namespace OnlineStore.DeviceLibrary
{ {
MoveInfo.NextMoveStep(LineMoveStep.FI_21_UpDownAxisToP1); MoveInfo.NextMoveStep(LineMoveStep.FI_21_UpDownAxisToP1);
InStoreLog(" FI_21_UpDownAxisToP1 料盘移栽:升降伺服到P1点"); InStoreLog(" FI_21_UpDownAxisToP1 料盘移栽:升降伺服到P1点");
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed); UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
} }
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_21_UpDownAxisToP1)) else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_21_UpDownAxisToP1))
{ {
...@@ -605,7 +605,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -605,7 +605,7 @@ namespace OnlineStore.DeviceLibrary
{ {
MoveInfo.NextMoveStep(LineMoveStep.FI_31_BatchAxisToP2); MoveInfo.NextMoveStep(LineMoveStep.FI_31_BatchAxisToP2);
InStoreLog(" FI_31_BatchAxisToP2 上料完成:未检测到料盘,提升伺服到P2点"); InStoreLog(" FI_31_BatchAxisToP2 上料完成:未检测到料盘,提升伺服到P2点");
ACAxisMove(Config.Batch_Axis, Config.BatchAxisP2, Config.BatchAxis_P2Speed); BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
} }
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_31_BatchAxisToP2)) else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_31_BatchAxisToP2))
{ {
...@@ -617,7 +617,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -617,7 +617,7 @@ namespace OnlineStore.DeviceLibrary
{ {
MoveInfo.NextMoveStep(LineMoveStep.FI_33_BatchAxisToP1); MoveInfo.NextMoveStep(LineMoveStep.FI_33_BatchAxisToP1);
InStoreLog(" FI_33_BatchAxisToP1 上料完成:提升伺服到P1点"); InStoreLog(" FI_33_BatchAxisToP1 上料完成:提升伺服到P1点");
ACAxisMove(Config.Batch_Axis, Config.BatchAxisP1, Config.BatchAxis_P1Speed); BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP1, Config.BatchAxis_P1Speed);
} }
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_33_BatchAxisToP1)) else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_33_BatchAxisToP1))
{ {
...@@ -685,14 +685,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -685,14 +685,10 @@ namespace OnlineStore.DeviceLibrary
{ {
MoveInfo.CanWhileCount = 0; MoveInfo.CanWhileCount = 0;
// 需要增加定时器,获取验证信号并停止伺服 // 需要增加定时器,获取验证信号并停止伺服
StartMovePosition = ACServerManager.GetActualtPosition(Config.Batch_Axis); StartMovePosition = BatchAxis.GetAclPosition();
if (StartMovePosition.Equals(-1))
{
StartMovePosition = ACServerManager.GetActualtPosition(Config.Batch_Axis);
}
MoveInfo.WaitList.Add(WaitResultInfo.WaitBatchAxis(Config.Batch_Axis, Config.BatchAxisP3, Config.BatchAxis_P3Speed)); MoveInfo.WaitList.Add(WaitResultInfo.WaitBatchAxis(Config.Batch_Axis, Config.BatchAxisP3, Config.BatchAxis_P3Speed));
Config.Batch_Axis.TargetPosition = Config.BatchAxisP3; Config.Batch_Axis.TargetPosition = Config.BatchAxisP3;
ACServerManager.AbsMove(Config.Batch_Axis.DeviceName, Config.Batch_Axis.GetAxisValue(), Config.BatchAxisP3, Config.BatchAxis_P3Speed); BatchAxis.AbsMove(Config.BatchAxisP3, Config.BatchAxis_P3Speed);
//开始检测信号 //开始检测信号
BatchAxisStartCheck(); BatchAxisStartCheck();
} }
...@@ -706,11 +702,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -706,11 +702,7 @@ namespace OnlineStore.DeviceLibrary
{ {
int AxisChangeValue = Config.Height_ChangeValue; int AxisChangeValue = Config.Height_ChangeValue;
//计算高度 //计算高度
EndMovePosition = ACServerManager.GetActualtPosition(Config.Batch_Axis); EndMovePosition = BatchAxis.GetAclPosition();
if (EndMovePosition.Equals(-1))
{
EndMovePosition = ACServerManager.GetActualtPosition(Config.Batch_Axis);
}
LastHeight = (int)Math.Ceiling(1F * (EndMovePosition - StartMovePosition) / AxisChangeValue); LastHeight = (int)Math.Ceiling(1F * (EndMovePosition - StartMovePosition) / AxisChangeValue);
int addHeight = 0; int addHeight = 0;
//如果检测信号未亮,极限亮了,需要补充高 //如果检测信号未亮,极限亮了,需要补充高
...@@ -870,7 +862,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -870,7 +862,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(LineMoveStep.FO_08_BatchAxisToP2); MoveInfo.NextMoveStep(LineMoveStep.FO_08_BatchAxisToP2);
InStoreLog(" FO_08_BatchAxisToP2 开始:提升轴下降到位P2"); InStoreLog(" FO_08_BatchAxisToP2 开始:提升轴下降到位P2");
IOMove(IO_Type.Line_Run, IO_VALUE.LOW); IOMove(IO_Type.Line_Run, IO_VALUE.LOW);
ACAxisMove(Config.Batch_Axis, Config.BatchAxisP2, Config.BatchAxis_P2Speed); BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
} }
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_08_BatchAxisToP2)) else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_08_BatchAxisToP2))
{ {
...@@ -882,14 +874,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -882,14 +874,14 @@ namespace OnlineStore.DeviceLibrary
{ {
MoveInfo.NextMoveStep(LineMoveStep.FO_10_AxisUpMove); MoveInfo.NextMoveStep(LineMoveStep.FO_10_AxisUpMove);
InStoreLog(" FO_10_AxisUpMove 开始:上料轴开始慢速上升到P3点"); InStoreLog(" FO_10_AxisUpMove 开始:上料轴开始慢速上升到P3点");
ACAxisMove(Config.Batch_Axis, Config.BatchAxisP3, Config.BatchAxis_TargetSpeed); BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP3, Config.BatchAxis_TargetSpeed);
} }
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_10_AxisUpMove)) else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_10_AxisUpMove))
{ {
MoveInfo.NextMoveStep(LineMoveStep.FO_11_AxisDownMove); MoveInfo.NextMoveStep(LineMoveStep.FO_11_AxisDownMove);
InStoreLog(" FO_31_BatchAxisToP2 料盘移栽:提升伺服下降指定的高度"); InStoreLog(" FO_31_BatchAxisToP2 料盘移栽:提升伺服下降指定的高度");
int targetPosition = Config.BatchAxisP3 + lastOutParam.PlateH * Config.Height_ChangeValue; int targetPosition = Config.BatchAxisP3 + lastOutParam.PlateH * Config.Height_ChangeValue;
ACAxisMove(Config.Batch_Axis, targetPosition, Config.BatchAxis_TargetSpeed); BatchAxis.AbsMove(MoveInfo, targetPosition, Config.BatchAxis_TargetSpeed);
} }
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_11_AxisDownMove)) else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_11_AxisDownMove))
...@@ -914,7 +906,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -914,7 +906,7 @@ namespace OnlineStore.DeviceLibrary
{ {
MoveInfo.NextMoveStep(LineMoveStep.FO_31_BatchAxisToP2); MoveInfo.NextMoveStep(LineMoveStep.FO_31_BatchAxisToP2);
InStoreLog(" FO_31_BatchAxisToP2 出料完成:未检测到料盘,提升伺服到P2点"); InStoreLog(" FO_31_BatchAxisToP2 出料完成:未检测到料盘,提升伺服到P2点");
ACAxisMove(Config.Batch_Axis, Config.BatchAxisP2, Config.BatchAxis_P2Speed); BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
} }
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_31_BatchAxisToP2)) else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_31_BatchAxisToP2))
{ {
...@@ -926,7 +918,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -926,7 +918,7 @@ namespace OnlineStore.DeviceLibrary
{ {
MoveInfo.NextMoveStep(LineMoveStep.FO_33_BatchAxisToP1); MoveInfo.NextMoveStep(LineMoveStep.FO_33_BatchAxisToP1);
InStoreLog(" FO_33_BatchAxisToP1 出料完成:提升伺服到P1点"); InStoreLog(" FO_33_BatchAxisToP1 出料完成:提升伺服到P1点");
ACAxisMove(Config.Batch_Axis, Config.BatchAxisP1, Config.BatchAxis_P1Speed); BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP1, Config.BatchAxis_P1Speed);
} }
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_33_BatchAxisToP1)) else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_33_BatchAxisToP1))
{ {
......
...@@ -43,6 +43,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -43,6 +43,7 @@ namespace OnlineStore.DeviceLibrary
Config.UpDown_Axis.ServerOnDO = IO_Type.UpDownAxis_ServoOn; Config.UpDown_Axis.ServerOnDO = IO_Type.UpDownAxis_ServoOn;
Config.UpDown_Axis.BreakOnDO = IO_Type.UpDownAxis_BreakOn; Config.UpDown_Axis.BreakOnDO = IO_Type.UpDownAxis_BreakOn;
} }
UpdownAxis=new AxisBean (config.UpDown_Axis);
} }
public override bool StartRun(bool isDebug=false) public override bool StartRun(bool isDebug=false)
...@@ -153,7 +154,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -153,7 +154,7 @@ namespace OnlineStore.DeviceLibrary
public bool ReturnHome() public bool ReturnHome()
{ {
mainTimer.Stop(); mainTimer.Stop();
if (!RunAxis(true,Config.UpDown_Axis)) if (!RunAxis(true, UpdownAxis))
{ {
return false; return false;
} }
...@@ -178,7 +179,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -178,7 +179,7 @@ namespace OnlineStore.DeviceLibrary
TrayManager.DelNeedEmptyTrayNum(); TrayManager.DelNeedEmptyTrayNum();
MoveInfo.EndMove(); MoveInfo.EndMove();
} }
if (!RunAxis(true, Config.UpDown_Axis)) if (!RunAxis(true, UpdownAxis))
{ {
return false; return false;
} }
...@@ -302,7 +303,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -302,7 +303,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (UseAxis) if (UseAxis)
{ {
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed); UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
} }
else else
{ {
...@@ -315,7 +316,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -315,7 +316,7 @@ namespace OnlineStore.DeviceLibrary
if (UseAxis) if (UseAxis)
{ {
int position = Config.GetUpdownP2(trayHeight); int position = Config.GetUpdownP2(trayHeight);
ACAxisMove(Config.UpDown_Axis, position, Config.UpdownAxis_DownSpeed); UpdownAxis.AbsMove(MoveInfo, position, Config.UpdownAxis_DownSpeed);
} }
else else
{ {
...@@ -327,7 +328,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -327,7 +328,7 @@ namespace OnlineStore.DeviceLibrary
if (UseAxis) if (UseAxis)
{ {
int position = Config.GetUpdownP3(trayHeight); int position = Config.GetUpdownP3(trayHeight);
ACAxisMove(Config.UpDown_Axis, position, Config.UpdownAxis_DownSpeed); UpdownAxis.AbsMove(MoveInfo, position, Config.UpdownAxis_DownSpeed);
} }
else else
{ {
...@@ -339,7 +340,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -339,7 +340,7 @@ namespace OnlineStore.DeviceLibrary
if (UseAxis) if (UseAxis)
{ {
MoveInfo.NextMoveStep(LineMoveStep.MH_UpDownHomeMove); MoveInfo.NextMoveStep(LineMoveStep.MH_UpDownHomeMove);
ACAxisHomeMove(Config.UpDown_Axis); UpdownAxis.HomeMove(MoveInfo);
} }
else else
{ {
......
...@@ -17,16 +17,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -17,16 +17,16 @@ namespace OnlineStore.DeviceLibrary
{ {
public ProvidingEquip_Config Config; public ProvidingEquip_Config Config;
public ProvidingEquip(string cid, ProvidingEquip_Config config) public ProvidingEquip(string cid, ProvidingEquip_Config config)
{ {
baseConfig = config; baseConfig = config;
this.DeviceID = config.Id; this.DeviceID = config.Id;
this.Config = config; this.Config = config;
IsDebug = config.IsDebug.Equals(1); IsDebug = config.IsDebug.Equals(1);
baseConfig = config; baseConfig = config;
Name = (" " + "_出料_" + DeviceID % 100 + " ").ToUpper(); Name = (" " + "_出料_" + DeviceID % 100 + " ").ToUpper();
Init(); Init();
MoveInfo = new LineMoveInfo(DeviceID, "出料-" + DeviceID + "-MoveInfo"); MoveInfo = new LineMoveInfo(DeviceID, "出料-" + DeviceID + "-MoveInfo");
SecondMoveInfo = new LineMoveInfo(DeviceID, "出料-" + DeviceID + "-SecondMoveInfo"); SecondMoveInfo = new LineMoveInfo(DeviceID, "出料-" + DeviceID + "-SecondMoveInfo");
UseAxis = config.UpDownUseAxis.Equals(1); UseAxis = config.UpDownUseAxis.Equals(1);
...@@ -42,6 +42,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -42,6 +42,7 @@ namespace OnlineStore.DeviceLibrary
Config.UpDown_Axis.ServerOnDO = IO_Type.UpDownAxis_ServoOn; Config.UpDown_Axis.ServerOnDO = IO_Type.UpDownAxis_ServoOn;
Config.UpDown_Axis.BreakOnDO = IO_Type.UpDownAxis_BreakOn; Config.UpDown_Axis.BreakOnDO = IO_Type.UpDownAxis_BreakOn;
} }
UpdownAxis = new AxisBean(config.UpDown_Axis);
} }
public override bool StartRun(bool isDebug=false) public override bool StartRun(bool isDebug=false)
...@@ -70,7 +71,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -70,7 +71,7 @@ namespace OnlineStore.DeviceLibrary
mainTimer.Enabled = false; mainTimer.Enabled = false;
} }
StopMove(); StopMove();
CloseAxis(Config.UpDown_Axis); CloseAxis(UpdownAxis);
//停止运行时,把所有IO 置零 //停止运行时,把所有IO 置零
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW); IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW); IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
...@@ -103,7 +104,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -103,7 +104,7 @@ namespace OnlineStore.DeviceLibrary
public bool ReturnHome() public bool ReturnHome()
{ {
if (!RunAxis(true, Config.UpDown_Axis)) if (!RunAxis(true, UpdownAxis))
{ {
return false; return false;
} }
...@@ -121,7 +122,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -121,7 +122,7 @@ namespace OnlineStore.DeviceLibrary
public override bool Reset() public override bool Reset()
{ {
if (!RunAxis(true, Config.UpDown_Axis)) if (!RunAxis(true, UpdownAxis))
{ {
return false; return false;
} }
...@@ -223,7 +224,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -223,7 +224,7 @@ namespace OnlineStore.DeviceLibrary
// CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up); // CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
if (UseAxis) if (UseAxis)
{ {
ACServerManager.SuddenStop(Config.UpDown_Axis); UpdownAxis.SuddenStop();
} }
CylinderMove(MoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down); CylinderMove(MoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW); IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
...@@ -243,7 +244,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -243,7 +244,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (UseAxis) if (UseAxis)
{ {
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed); UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
} }
else else
{ {
...@@ -256,7 +257,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -256,7 +257,7 @@ namespace OnlineStore.DeviceLibrary
if (UseAxis) if (UseAxis)
{ {
int position = Config.GetUpdownP2(trayHeight); int position = Config.GetUpdownP2(trayHeight);
ACAxisMove(Config.UpDown_Axis, position, Config.UpdownAxis_DownSpeed); UpdownAxis.AbsMove(MoveInfo, position, Config.UpdownAxis_DownSpeed);
} }
else else
{ {
...@@ -268,7 +269,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -268,7 +269,7 @@ namespace OnlineStore.DeviceLibrary
if (UseAxis) if (UseAxis)
{ {
int position = Config.GetUpdownP3(trayHeight); int position = Config.GetUpdownP3(trayHeight);
ACAxisMove(Config.UpDown_Axis, position, Config.UpdownAxis_DownSpeed); UpdownAxis.AbsMove(MoveInfo, position, Config.UpdownAxis_DownSpeed);
} }
else else
{ {
...@@ -280,7 +281,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -280,7 +281,7 @@ namespace OnlineStore.DeviceLibrary
if (UseAxis) if (UseAxis)
{ {
MoveInfo.NextMoveStep(LineMoveStep.MH_UpDownHomeMove); MoveInfo.NextMoveStep(LineMoveStep.MH_UpDownHomeMove);
ACAxisHomeMove(Config.UpDown_Axis); UpdownAxis.HomeMove(MoveInfo);
} }
else else
{ {
......
...@@ -12,7 +12,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -12,7 +12,7 @@ namespace OnlineStore.DeviceLibrary
{ {
#region 托盘检测 #region 托盘检测
protected override bool CheckWaitResult(WaitResultInfo wait) protected override bool CheckWaitResult(LineMoveInfo moveInfo, WaitResultInfo wait)
{ {
if (wait.WaitType.Equals(WaitEnum.W201_ProvidingCanOut)) if (wait.WaitType.Equals(WaitEnum.W201_ProvidingCanOut))
{ {
......
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class AxisBean
{
public ConfigMoveAxis Config =null;
////是否在原点返回
//private bool homeRunning = false;
////是否在移动
//private bool moveRunning = false;
////是否已连接
//public bool isConnect = false;
public static int TimeoutInterval = 500;
/// <summary>
/// 正常工作过程中判断位置是否到达时使用
/// </summary>
public int LastPosition = 0;
public string AxisName;
public AxisBean(ConfigMoveAxis axisConfig)
{
this.Config = axisConfig;
AxisName = Config.Explain + "[" + Config.DeviceName + "-" + Config.GetAxisValue() + "]";
}
private bool IsIntSlvBlock = false;
public bool Open(bool isCheck,out string Msg)
{
Msg = "";
string portName = Config.DeviceName;
int slvAddr = Config.GetAxisValue();
//打开所有轴
ACServerManager.OpenPort(Config.DeviceName);
Thread.Sleep(50);
//初始化
if (!IsIntSlvBlock)
{
ACServerManager.InitSlvAddr(portName, slvAddr, Config.TargetSpeed, Config.AddSpeed, Config.DelSpeed);
Thread.Sleep(100);
}
ACServerManager.AlarmClear(portName, slvAddr);
Thread.Sleep(50);
ACServerManager.ServoOn(portName, slvAddr);
Thread.Sleep(1000);
//打开所有轴
if (isCheck)
{
if (!OpenAxis(out Msg))
{
return false;
}
}
IsIntSlvBlock = true;
return true;
}
/// <summary>
/// 打开所有轴
/// </summary>
/// <returns></returns>
private bool OpenAxis( out string msg)
{
msg = "";
//判断轴是否正常
string portName = Config.DeviceName;
int slvAddr = Config.GetAxisValue();
if (ACServerManager.ServerOnStatus(portName, slvAddr))
{
LogUtil.info( AxisName+ "成功打开" );
}
else
{
//清理报警,再重新打开一次
LogUtil.info(AxisName+ "第一次打开失败,先清理一下报警,再重新打开一次");
ACServerManager.AlarmClear(portName, slvAddr);
System.Threading.Thread.Sleep(1200);
ACServerManager.ServoOn(portName, slvAddr);
System.Threading.Thread.Sleep(100);
if (ACServerManager.ServerOnStatus(portName, slvAddr))
{
LogUtil.info(AxisName + "清理报警后重新打卡轴成功:" + Config.Explain);
}
else
{
ACServerManager.ServoOff(portName, slvAddr);
msg= "打开轴" + Config.Explain + "失败 ";
LogUtil.info(AxisName + msg);
return false;
}
}
return true;
}
public void Close()
{
LogUtil.info("ServoOff【" + AxisName + "】");
ACServerManager.ServoOff(Config.DeviceName, Config.GetAxisValue());
}
public void HomeMove(LineMoveInfo MoveInfo)
{
Config.TargetPosition = 0;
LogUtil.info(Config.DisplayStr + "speed[" + Config.TargetSpeed + "]开始原点返回");
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(Config, true));
ACServerManager.HomeMove(Config.DeviceName, (short)Config.GetAxisValue(), Config.HomeHighSpeed);
}
/// <summary>
/// 松下伺服电机运动
/// </summary>
public void AbsMove(LineMoveInfo MoveInfo, int targetPosition, int targetSpeed)
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(Config, targetPosition, targetSpeed));
Config.TargetPosition = targetPosition;
ACServerManager.AbsMove(Config.DeviceName, Config.GetAxisValue(), targetPosition, targetSpeed);
}
/// <summary>
/// 判断AC伺服电机轴是否运动完成
/// </summary>
public static bool ACAxisMoveIsEnd(LineMoveInfo MoveInfo, ConfigMoveAxis axis,int targetPosition, int targetSpeed, out string msg)
{
msg = "";
string deviceName = axis.DeviceName;
short axisNo = axis.GetAxisValue();
bool isOk = ACServerManager.GetBusyStatus(deviceName, axisNo).Equals(0);
int outCount = ACServerManager.GetActualtPosition(deviceName, axisNo);
int errorCount = Math.Abs(outCount - targetPosition);
if (isOk)
{
if (errorCount <= axis.CanErrorCountMax)
{
return true;
}
//判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0)
{
LogUtil.error(axis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount +
"],误差过大,重新开始运动,剩余[" + MoveInfo.CanWhileCount + "]次");
ACServerManager.AbsMove(axis.DeviceName, axis.GetAxisValue(), targetPosition, targetSpeed);
MoveInfo.CanWhileCount--;
}
else
{
msg = " storeMoveStep=" + MoveInfo.MoveStep + axis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount
+ "],误差过大,需要报警";
LogUtil.error(msg);
}
}
return false;
}
public static bool HomeMoveIsEnd(LineMoveInfo MoveInfo, ConfigMoveAxis axis, out string msg)
{
msg = "";
if (ACServerManager.IsHomeMoveEnd(axis.DeviceName, axis.GetAxisValue()))
{
//原点完成并且位置=0
int outCount = ACServerManager.GetActualtPosition(axis.DeviceName, axis.GetAxisValue());
int errorCount = Math.Abs(outCount);
if (errorCount <= axis.CanErrorCountMax)
{
return true;
}
//判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0)
{
LogUtil.error(axis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],重新回原点,剩余[" + MoveInfo.CanWhileCount + "]次");
//LogUtil.error( StoreName + moveAxis.DisplayStr + "重新回原点");
ACServerManager.HomeMove(axis.DeviceName, axis.GetAxisValue(), axis.HomeHighSpeed);
MoveInfo.CanWhileCount--;
}
else
{
msg = " storeMoveStep=" + MoveInfo.MoveStep + axis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警";
LogUtil.error(msg);
}
}
return false;
}
public int GetAclPosition()
{
int p = ACServerManager.GetActualtPosition(Config);
return p;
}
/// <summary>
/// 绝对运动至点,不等待结果
/// </summary>
public void AbsMove(int targetPos, double targetSpeed)
{
if (targetPos.Equals(-1))
{
return ;
}
LastPosition = -1;
if (targetSpeed > Config.TargetSpeed || targetSpeed <= 0)
{
targetSpeed = Config.TargetSpeed;
}
//小于1,表示是目标速度的百分比
else if (targetSpeed <= 1)
{
targetSpeed = Config.TargetSpeed * targetSpeed;
}
ACServerManager.AbsMove(Config.DeviceName, Config.GetAxisValue(), targetPos, (int)targetSpeed);
}
public void SuddenStop()
{
ACServerManager.SuddenStop(Config.DeviceName, Config.GetAxisValue());
}
///// <summary>
///// 移动到某点,会等到到达位置后结束
///// </summary>
///// <param name="pos"></param>
///// <returns></returns>
//public string AbsMoveAndWait(int pos, double targetSpeed = 0)
//{
// string result = AbsMove(pos, targetSpeed);
// if (!result.Equals(""))
// {
// return result;
// }
// moveRunning = true;
// while (true)
// {
// if (!moveRunning)
// {
// moveRunning = false;
// return AxisName + "用户中止";
// }
// Thread.Sleep(100);
// if (HasAlarm())
// {
// moveRunning = false;
// return AxisName + "伺服报警";
// }
// //判断Buzy及位置是否结束
// if (IsMoveEnd(pos))
// {
// //移动完成
// moveRunning = false;
// return "";
// }
// }
//}
//public bool HasAlarm()
//{
// return ACServerManager.GetAlarmStatus(Config.DeviceName, Config.GetAxisValue()).Equals(1);
//}
///// <summary>
///// 获取位置
///// </summary>
///// <param name="tryTimes">尝试次数</param>
///// <returns></returns>
//public int GetPos(int tryTimes)
//{
// for (int i = 0; i < tryTimes; i++)
// {
// int pos = ACServerManager.GetActualtPosition(Config.DeviceName, Config.GetAxisValue());
// if (pos != -1)
// {
// LastPosition = pos;
// return pos;
// }
// LogUtil.info("获取" + AxisName + "当前位置[" + pos + "]");
// Thread.Sleep(120);
// }
// return -1;
//}
//public bool IsMoveEnd(int targetPos)
//{
// bool isEnd = ACServerManager.GetBusyStatus(Config.DeviceName, Config.GetAxisValue()) == 0;
// return isEnd;
//}
//public void SuddenStop()
//{
// if (homeRunning)
// {
// homeRunning = false;
// }
// if (moveRunning)
// {
// moveRunning = false;
// }
// if (isConnect)
// {
// ACServerManager.SuddenStop(Config.DeviceName, Config.GetAxisValue());
// }
//}
//private void Stop()
//{
// if (homeRunning)
// {
// homeRunning = false;
// }
// if (moveRunning)
// {
// moveRunning = false;
// }
// if (isConnect)
// {
// //ACServerManager.Stop(Config.DeviceName, axisNo);
// }
//}
//public bool IsInPosition(int positionX, int chaValue)
//{
// if (moveRunning)
// {
// return false;
// }
// if (positionX.Equals(-1))
// {
// return true;
// }
// if (!LastPosition.Equals(-1))
// {
// int cha1 = positionX - LastPosition;
// if (Math.Abs(cha1) <= chaValue)
// {
// return true;
// }
// }
// LastPosition = GetPos(2);
// int XCha = positionX - LastPosition;
// if (Math.Abs(XCha) <= chaValue)
// {
// return true;
// }
// return false;
//}
///// <summary>
///// 异步原点返回
///// </summary>
///// <param name="timeout">超时时间</param>
///// <returns></returns>
//public string Home(TimeSpan timeout)
//{
// if (!isConnect)
// {
// return AxisName + "未连接";
// }
// if (moveRunning)
// {
// return AxisName + "正在运动";
// }
// homeRunning = true;
// string result = "";
// ACServerManager.HomeMove(Config.DeviceName, Config.GetAxisValue(), Config.HomeHighSpeed);
// double outTime = timeout.TotalMilliseconds;
// int time = 0;
// while (true)
// {
// if (!homeRunning)
// {
// result = AxisName + "用户中止";
// break;
// }
// else
// {
// Thread.Sleep(TimeoutInterval);
// if (isHomeEnd())
// {
// //LogUtil.info(Config.DeviceName + "原点返回停止,对比实际位置");
// int currentPos = GetPos(2);
// if (currentPos != -1 && Math.Abs(currentPos) <= Config.CanErrorCountMax)
// {
// LogUtil.info(AxisName + "原点返回完成,当前位置【" + currentPos + "】");
// //原点返回完成
// result = "";
// break;
// };
// }
// if (HasAlarm())
// {
// result = AxisName + "报警";
// break;
// }
// time = time + TimeoutInterval;
// if (time >= outTime)
// {
// result = AxisName + "超时";
// break;
// }
// }
// }
// homeRunning = false;
// return result;
//}
//public bool isHomeEnd()
//{
// bool isEnd = ACServerManager.IsHomeMoveEnd(Config.DeviceName, Config.GetAxisValue());
// return isEnd;
//}
}
}
...@@ -341,18 +341,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -341,18 +341,18 @@ namespace OnlineStore.DeviceLibrary
{ {
// Box_Addr add = GetAddr(StartAddress); // Box_Addr add = GetAddr(StartAddress);
for (int i = 1; i <= 3; i++) // for (int i = 1; i <= 3; i++)
//{
bool result = aioBox.WriteDO(StartAddress, GetBox_Sta(onOff));
if (!result)
{ {
bool result = aioBox.WriteDO(StartAddress, GetBox_Sta(onOff)); LogUtil.error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 失败:" + aioBox.ErrInfo);
if (!result)
{
LogUtil.error("AIO WriteSingleDO ["+ioIp+"] [" + StartAddress + "] 第" + i + "次失败:" + aioBox.ErrInfo);
}
else
{
break;
}
} }
// else
// {
// break;
// }
//}
} }
else else
{ {
...@@ -364,34 +364,33 @@ namespace OnlineStore.DeviceLibrary ...@@ -364,34 +364,33 @@ namespace OnlineStore.DeviceLibrary
LOGGER.Error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错啦:" + ex.ToString()); LOGGER.Error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错啦:" + ex.ToString());
} }
} }
public override void WriteSingleDO(string ioIp, byte slaveId, ushort StartAddress, IO_VALUE onOff, int mSeconds) public override void WriteSingleDO(string ioIp, byte slaveId, ushort StartAddress, IO_VALUE onOff, int mSeconds )
{ {
try try
{ {
AIOBOX aioBox = getAIO(ioIp); AIOBOX aioBox = getAIO(ioIp);
Box_Sta currBox_Sta = GetBox_Sta(onOff);
if (aioBox != null) if (aioBox != null)
{ {
// Box_Addr add = GetAddr(StartAddress); Box_Sta currBox_Sta = GetBox_Sta(onOff);
aioBox.WriteDO(StartAddress, currBox_Sta); aioBox.WriteDO(StartAddress, currBox_Sta);
//写入之后,等待指定间隔后回写 //写入之后,等待指定间隔后回写
System.Timers.Timer mytimer = new System.Timers.Timer(mSeconds); System.Timers.Timer mytimer = new System.Timers.Timer(mSeconds);
mytimer.Elapsed += (o1, e1) => mytimer.Elapsed += (o1, e1) =>
{
try
{
aioBox.WriteDO(StartAddress, aioBox.ReverseStatus(currBox_Sta));
LogUtil.debug(LOGGER, "**********定时回写入 IO [" + ioIp + "] [" + StartAddress + "]值" + aioBox.ReverseStatus(currBox_Sta) + "】:");
}
catch (Exception ex)
{ {
LogUtil.error(LOGGER, "**********定时回写入 出错:" + ex.StackTrace); try
} {
}; aioBox.WriteDO(StartAddress, aioBox.ReverseStatus(currBox_Sta));
mytimer.AutoReset = false;//设置是否自动重启,即自动执行多次; LogUtil.debug(LOGGER, "**********定时回写入 IO [" + ioIp + "] [" + StartAddress + "]值" + aioBox.ReverseStatus(currBox_Sta) + "】:");
mytimer.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件mytask; }
catch (Exception ex)
{
LogUtil.error(LOGGER, "**********定时回写入 出错:" + ex.StackTrace);
}
};
mytimer.AutoReset = false;//设置是否自动重启,即自动执行多次;
mytimer.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件mytask;
} }
else else
{ {
...@@ -444,10 +443,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -444,10 +443,7 @@ namespace OnlineStore.DeviceLibrary
AIOBOX aioBox = getAIO(ioIP); AIOBOX aioBox = getAIO(ioIP);
if (aioBox != null) if (aioBox != null)
{ {
Box_Sta sta = Box_Sta.Off; Box_Sta sta = Box_Sta.Off;
// Box_Addr addr = GetAddr(StartAddress);
// int index = (int)StartAddress - (int)StoreManager.Config.GetDILength(ioIP);
if (DOValueMap.ContainsKey(ioIP) && DOValueMap[ioIP].Count > StartAddress) if (DOValueMap.ContainsKey(ioIP) && DOValueMap[ioIP].Count > StartAddress)
{ {
sta = DOValueMap[ioIP][StartAddress]; sta = DOValueMap[ioIP][StartAddress];
......
...@@ -40,31 +40,8 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -40,31 +40,8 @@ namespace OnlineStore.LoadCSVLibrary
public int SubType { get; set; } public int SubType { get; set; }
public string ConfigStr { get; set; } public string ConfigStr { get; set; }
ushort value = 0;
public ushort GetIOAddr()
{
if (value > 0)
{
return value;
}
try
{
value = (ushort)Convert.ToInt32(ProValue);
}
catch (Exception ex)
{
LOGGER.Error("出错:", ex);
}
return value;
}
public virtual int GetValue()
{
if (ProValue.Equals(""))
{
return -1;
}
return Convert.ToInt32(ProValue);
}
public override string ToString() public override string ToString()
{ {
// return "ConfigBase。" + "类型:" + ProType + ",说明:" + Explain + ",名称:" + ProName + ",属性值:" + ProVale; // return "ConfigBase。" + "类型:" + ProType + ",说明:" + Explain + ",名称:" + ProName + ",属性值:" + ProVale;
...@@ -135,10 +112,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -135,10 +112,7 @@ namespace OnlineStore.LoadCSVLibrary
/// 出入库目标值(只有出入库过程中才会有效) /// 出入库目标值(只有出入库过程中才会有效)
/// </summary> /// </summary>
public int TargetPosition { get; set; } public int TargetPosition { get; set; }
///// <summary>
///// 速度倍率
///// </summary>
//public int ResolveSpeed { get; set; }
/// <summary> /// <summary>
/// 最小位置 /// 最小位置
/// </summary> /// </summary>
...@@ -159,28 +133,21 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -159,28 +133,21 @@ namespace OnlineStore.LoadCSVLibrary
} }
return false; return false;
} }
public bool PositionIsHasLimit(){
if (PositionMin.Equals(PositionMax))
{
return false;
} return true;
}
/// <summary> /// <summary>
/// 下拉列表显示 /// 下拉列表显示
/// </summary> /// </summary>
public string DisplayStr public string DisplayStr
{ {
get { get
return Explain + "(" + ProName + ")"; {
return Explain + "(" + ProName + ")";
} }
set set
{ {
} }
} }
public override int GetValue()
{
return GetAxisValue();
}
/// <summary> /// <summary>
/// 使用康泰克板卡表示轴编号,使用Ac伺服电机表示伺服地址 /// 使用康泰克板卡表示轴编号,使用Ac伺服电机表示伺服地址
/// </summary> /// </summary>
...@@ -192,29 +159,14 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -192,29 +159,14 @@ namespace OnlineStore.LoadCSVLibrary
return -1; return -1;
} }
return (short)Convert.ToInt32(ProValue); return (short)Convert.ToInt32(ProValue);
} }
//public override string ToString()
//{
// return "ConfigMoveAxis。" + "类型:" + ProType + ",说明:" + Explain + ",名称:" + ProName + ",属性值:" + ProVale + ",设备名称:" + DeviceName;
//}
public override void CheckField() public override void CheckField()
{ {
if (String.IsNullOrEmpty( ProType) || String.IsNullOrEmpty( ProName ) || String.IsNullOrEmpty( DeviceName ) || String.IsNullOrEmpty( ProValue )) if (String.IsNullOrEmpty( ProType) || String.IsNullOrEmpty( ProName ) || String.IsNullOrEmpty( DeviceName ) || String.IsNullOrEmpty( ProValue ))
{ {
throw new CVSFieldNotMatchingExection(ToString() + ",【类型:ProType】【名称:ProName】【属性值:ProVale】【设备名称:DeviceName】必须配置值!"); throw new CVSFieldNotMatchingExection(ToString() + ",【类型:ProType】【名称:ProName】【属性值:ProVale】【设备名称:DeviceName】必须配置值!");
} }
} }
public bool IsMyAxis(string DeviceName, int AxisNo)
{
int AxisValue = GetAxisValue();
if (DeviceName.Equals(DeviceName) && AxisValue.Equals(AxisNo))
{
return true;
}
return false;
}
} }
...@@ -288,8 +240,24 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -288,8 +240,24 @@ namespace OnlineStore.LoadCSVLibrary
set set
{ {
} }
} }
ushort value = 0;
public ushort GetIOAddr()
{
if (value > 0)
{
return value;
}
try
{
value = (ushort)Convert.ToInt32(ProValue);
}
catch (Exception ex)
{
LOGGER.Error("出错:", ex);
}
return value;
}
//public override string ToString() //public override string ToString()
//{ //{
// return "[" + ProType + "]" + Explain + "," + ProName + ",属性值:" + ProVale + ",设备名称:" + DeviceName + ",描述:" + Describe + ",电器定义:" + ElectricalDefinition + ",代码定义:" + CodeDefinition + ""; // return "[" + ProType + "]" + Explain + "," + ProName + ",属性值:" + ProVale + ",设备名称:" + DeviceName + ",描述:" + Describe + ",电器定义:" + ElectricalDefinition + ",代码定义:" + CodeDefinition + "";
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!