Commit 45f62419 LN

增加伺服bean

1 个父辈 aff17178
......@@ -49,7 +49,7 @@ namespace OnlineStore.AssemblyLine
if (i >= maxCount)
{
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
{
......@@ -73,7 +73,7 @@ namespace OnlineStore.AssemblyLine
if (i >= maxCount)
{
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
{
......@@ -106,8 +106,8 @@ namespace OnlineStore.AssemblyLine
lblTrayNum.Text = "托盘编码:" + TrayManager.GetTrayNum(equipBean.DeviceID);
}
string canOut = LineManager.Line.CanOutStore(equipBean.DeviceID) ? "可出库":"不可出库" ;
lblStoreStatus.Text = KTK_Store.GetRunStr(equipBean.lineStatus, equipBean.runStatus)+"("+canOut+")";
string canOut = LineManager.Line.CanOutStore(equipBean.DeviceID) ? "可出库" : "不可出库";
lblStoreStatus.Text = KTK_Store.GetRunStr(equipBean.lineStatus, equipBean.runStatus) + "(" + canOut + ")";
lblThisSta.Text = equipBean.WarnMsg;
string text = "";
List<InOutParam> ps = new List<InOutParam>(equipBean.waitInStoreList);
......@@ -123,9 +123,10 @@ namespace OnlineStore.AssemblyLine
{
lblInstoreList.Text = text;
}
}catch(Exception ex)
}
catch (Exception ex)
{
LogUtil.error(equipBean.Name+ "界面定时器出错:"+ex.ToString());
LogUtil.error(equipBean.Name + "界面定时器出错:" + ex.ToString());
}
}
......@@ -207,7 +208,7 @@ namespace OnlineStore.AssemblyLine
{
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.Add("0=默认位置");
......@@ -228,9 +229,9 @@ namespace OnlineStore.AssemblyLine
}
else
{
btnSwLocationCylinder.Visible = false ;
btnSWTop.Visible = false ;
btnFL_TopCylinder.Visible = true ;
btnSwLocationCylinder.Visible = false;
btnSWTop.Visible = false;
btnFL_TopCylinder.Visible = true;
}
txtBp1.Text = equipBean.Config.BatchAxisP1.ToString();
txtBP2.Text = equipBean.Config.BatchAxisP2.ToString();
......@@ -304,7 +305,7 @@ namespace OnlineStore.AssemblyLine
equipBean.Config.IsDebug = 1;
LineManager.SaveFeedingEquipConfig(equipBean.Config);
equipBean.ChangeDebug(true);
LogUtil.info(equipBean.Name+ "用户切换到调试状态 ");
LogUtil.info(equipBean.Name + "用户切换到调试状态 ");
}
}
}
......@@ -327,9 +328,9 @@ namespace OnlineStore.AssemblyLine
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
{
......@@ -357,13 +358,13 @@ namespace OnlineStore.AssemblyLine
}
catch (Exception ex)
{
LogUtil.error( "出错:" + ex.StackTrace);
LogUtil.error("出错:" + ex.StackTrace);
}
}
private void btnReset_Click(object sender, EventArgs e)
{
if (equipBean.runStatus>(LineRunStatus.Wait))
if (equipBean.runStatus > (LineRunStatus.Wait))
{
equipBean.Reset();
}
......@@ -418,7 +419,7 @@ namespace OnlineStore.AssemblyLine
}
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();
btnMoveto.Text = size + "寸移栽位置 :";
}
......@@ -426,20 +427,17 @@ namespace OnlineStore.AssemblyLine
private void btnMoveto_Click(object sender, EventArgs e)
{
int position = FormUtil.GetIntValue(txtSizePosition);
if (position != -1)
{
int speed = equipBean.Config.UpdownAxis_P2Speed;
string portName = equipBean.Config.UpDown_Axis.DeviceName;
int SlvAddr = equipBean.Config.UpDown_Axis.GetAxisValue();
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)
{
this.Enabled = false;
equipBean.RunAxis(false,equipBean.Config.Batch_Axis);
equipBean.RunAxis(false, equipBean.BatchAxis);
this.Enabled = true;
LogUtil.info("伺服运转ON完成");
}
......@@ -460,14 +458,12 @@ namespace OnlineStore.AssemblyLine
private void button3_Click(object sender, EventArgs e)
{
int position = FormUtil.GetIntValue(txtP1);
if (position != -1)
{
int speed =equipBean.Config.UpdownAxis_P2Speed;
string portName = equipBean.Config.UpDown_Axis.DeviceName;
int SlvAddr = equipBean.Config.UpDown_Axis.GetAxisValue();
int speed = equipBean.Config.UpdownAxis_P2Speed;
LogUtil.info("点击【P1点测试】, 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed);
}
equipBean.UpdownAxis.AbsMove(position, speed);
}
private void btnSave_Click(object sender, EventArgs e)
......@@ -512,19 +508,19 @@ namespace OnlineStore.AssemblyLine
private void btnBP1_Click(object sender, EventArgs e)
{
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)
{
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)
{
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)
......
......@@ -41,7 +41,7 @@ namespace OnlineStore.AssemblyLine
{
portName = equipBean.Config.UpDown_Axis.DeviceName;
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;
}
else
......@@ -393,25 +393,23 @@ namespace OnlineStore.AssemblyLine
private void btnMoveto_Click(object sender, EventArgs e)
{
int position = FormUtil.GetIntValue(txtP2);
if (position != -1)
{
int speed = equipBean.Config.UpdownAxis_DownSpeed;
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)
{
this.Enabled = false;
equipBean.RunAxis(false,equipBean.Config.UpDown_Axis);
equipBean.RunAxis(false,equipBase.UpdownAxis);
this.Enabled = true;
LogUtil.info("伺服运转ON完成");
}
private void btnAxisOff_Click(object sender, EventArgs e)
{
equipBean.CloseAxis(equipBean.Config.UpDown_Axis);
equipBean.CloseAxis(equipBase.UpdownAxis);
LogUtil.info("伺服运转OFF完成");
}
......@@ -430,12 +428,11 @@ namespace OnlineStore.AssemblyLine
private void button3_Click(object sender, EventArgs e)
{
int position = FormUtil.GetIntValue(txtP1);
if (position != -1)
{
int speed =equipBean.Config.UpdownAxis_P1Speed;
LogUtil.info("点击【P1点测试】, 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed);
}
equipBean.UpdownAxis.AbsMove(position, speed);
}
private void btnSave_Click(object sender, EventArgs e)
......@@ -456,12 +453,11 @@ namespace OnlineStore.AssemblyLine
private void btnBoxP_Click(object sender, EventArgs e)
{
int position = FormUtil.GetIntValue(txtP3);
if (position != -1)
{
int speed = equipBean.Config.UpdownAxis_DownSpeed;
LogUtil.info("点击【料仓门口下降位置】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed);
}
equipBean.UpdownAxis.AbsMove(position, speed);
}
}
......
......@@ -180,7 +180,7 @@ namespace OnlineStore.AssemblyLine
{
if (equipBean.UseAxis)
{
axisMoveControl1.LoadData(equipBean, new ConfigMoveAxis[] { equipBean.Config.UpDown_Axis });
axisMoveControl1.LoadData(equipBean, new AxisBean[] { equipBean.UpdownAxis });
cmbSizeList.Items.Clear();
cmbSizeList.Items.Add("0=默认位置");
for (int i = 8; i <= 48; i = i + 4)
......@@ -373,11 +373,9 @@ namespace OnlineStore.AssemblyLine
int position = FormUtil.GetIntValue(txtP3);
if (position != -1)
{
string portName = equipBean.Config.UpDown_Axis.DeviceName;
int SlvAddr = equipBean.Config.UpDown_Axis.GetAxisValue();
int speed = equipBean.Config.UpdownAxis_DownSpeed;
LogUtil.info("点击【出料皮带线位置P3】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed);
equipBase.UpdownAxis.AbsMove(position, speed);
}
}
......@@ -386,11 +384,9 @@ namespace OnlineStore.AssemblyLine
int position = FormUtil.GetIntValue(txtP2);
if (position != -1)
{
string portName = equipBean.Config.UpDown_Axis.DeviceName;
int SlvAddr = equipBean.Config.UpDown_Axis.GetAxisValue();
int speed = equipBean.Config.UpdownAxis_DownSpeed;
LogUtil.info("点击【移栽位置】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed);
equipBase.UpdownAxis.AbsMove(position, speed);
}
}
......@@ -399,11 +395,9 @@ namespace OnlineStore.AssemblyLine
int position = FormUtil.GetIntValue(txtP1);
if (position != -1)
{
string portName = equipBean.Config.UpDown_Axis.DeviceName;
int SlvAddr = equipBean.Config.UpDown_Axis.GetAxisValue();
int speed = equipBean.Config.UpdownAxis_P1Speed;
LogUtil.info("点击【P1点测试】, 位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(portName, SlvAddr, position, speed);
equipBase.UpdownAxis.AbsMove(position, speed);
}
}
......
......@@ -16,7 +16,7 @@ namespace OnlineStore.AssemblyLine
{
public partial class AxisMoveControl : UserControl
{
private List<ConfigMoveAxis> axisList = new List<ConfigMoveAxis>();
private List<AxisBean> axisList = new List<AxisBean>();
private EquipBase equipBase = null;
private string PortName = "";
private int SlvAddr = 0;
......@@ -25,37 +25,30 @@ namespace OnlineStore.AssemblyLine
{
InitializeComponent();
}
public void LoadData(EquipBase equipBase, params ConfigMoveAxis[] moveAxis)
public void LoadData(EquipBase equipBase, params AxisBean[] moveAxis)
{
this.equipBase = equipBase;
axisList = new List<ConfigMoveAxis>(moveAxis);
axisList = new List<AxisBean>(moveAxis);
if (axisList.Count > 0)
{
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;
PortName = moveAxis[0].DeviceName;
SlvAddr = moveAxis[0].GetAxisValue();
PortName = moveAxis[0].Config.DeviceName;
SlvAddr = moveAxis[0].Config.GetAxisValue();
txtAxisDeviceName.Text = PortName;
txtAxisValue.Text = SlvAddr.ToString();
}
}
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 + "】 ");
equipBase.OpenAxis(axisList[comboBox1.SelectedIndex]);
equipBase.RunAxis(false, axisList[comboBox1.SelectedIndex]);
}
private void btnCloseAxis_Click(object sender, EventArgs e)
......@@ -132,7 +125,7 @@ namespace OnlineStore.AssemblyLine
{
if (comboBox1.SelectedIndex > 0)
{
ConfigMoveAxis axis = axisList[comboBox1.SelectedIndex];
ConfigMoveAxis axis = axisList[comboBox1.SelectedIndex].Config;
PortName = axis.DeviceName;
SlvAddr = axis.GetAxisValue();
txtAxisDeviceName.Text = PortName;
......
......@@ -71,6 +71,7 @@
<Compile Include="assemblyLine\FeedingEquip.cs" />
<Compile Include="assemblymanager\StoreServerManager.cs" />
<Compile Include="assemblymanager\TrayManager.cs" />
<Compile Include="baan\AxisBean.cs" />
<Compile Include="deviceLibrary\halcon\CodeManager.cs" />
<Compile Include="deviceLibrary\IO\AIOBOX\AIOBOXManager.cs" />
<Compile Include="deviceLibrary\IO\IOManager.cs" />
......
......@@ -31,7 +31,10 @@ namespace OnlineStore.DeviceLibrary
/// 当前正在通过的托盘号
/// </summary>
protected int currTrayNum = 0;
/// <summary>
/// 升降轴
/// </summary>
public AxisBean UpdownAxis = null;
protected abstract void ReturnHomeProcess();
protected virtual void StopMoveProcess()
{
......@@ -44,7 +47,7 @@ namespace OnlineStore.DeviceLibrary
BaseTimerProcess();
}
public override void Alarm(LineAlarmType alarmType )
public override void Alarm(LineAlarmType alarmType)
{
if (this.alarmType.Equals(alarmType))
{
......@@ -232,183 +235,35 @@ namespace OnlineStore.DeviceLibrary
#region 伺服运动
public bool RunAxis(bool isCheck, ConfigMoveAxis axis)
public bool RunAxis(bool isCheck, AxisBean axis)
{
if (!UseAxis)
{
return true;
}
string portName = axis.DeviceName;
int slvAddr = axis.GetAxisValue();
IOMove(axis.ServerOnDO, IO_VALUE.HIGH);
Thread.Sleep(1000);
//打开所有轴
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))
IOMove(axis.Config.ServerOnDO, IO_VALUE.HIGH);
string msg = "";
bool result = axis.Open(isCheck, out msg);
if (result && String.IsNullOrEmpty(msg))
{
return false;
}
}
IsIntSlvBlock = true;
IOMove(axis.BreakOnDO, IO_VALUE.HIGH);
IOMove(axis.Config.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
{
//清理报警,再重新打开一次
LogUtil.info(Name + "第一次打开轴" + axis.Explain + "失败,先清理一下报警,再重新打开一次");
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 );
WarnMsg = Name + msg;
Alarm(LineAlarmType.AxisAlarm);
return false;
}
}
return true;
}
public void CloseAxis(ConfigMoveAxis axis)
public void CloseAxis(AxisBean axis)
{
string portName = axis.DeviceName;
int slvAddr = axis.GetAxisValue();
LogUtil.info(Name + "关闭刹车,关闭伺服");
IOMove(axis.BreakOnDO, IO_VALUE.LOW);
ACServerManager.ServoOff(portName, slvAddr);
//关闭串口,等下次重新打开
ACServerManager.ColsePort(portName);
IOMove(axis.Config.BreakOnDO, IO_VALUE.LOW);
axis.Close();
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
#region CheckWait处理
......@@ -444,11 +299,11 @@ namespace OnlineStore.DeviceLibrary
string msg = "";
if (wait.IsHomeMove)
{
wait.IsEnd = ACHomeMoveIsEnd(wait.AxisInfo, out msg);
wait.IsEnd = AxisBean.HomeMoveIsEnd(moveInfo, wait.AxisInfo, out msg);
}
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(""))
{
......@@ -485,7 +340,7 @@ namespace OnlineStore.DeviceLibrary
ConfigIO io = baseConfig.getWaitIO(wait.IoType);
WarnMsg = Name + "等待" + NotOkMsg + " 超时";
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)
{
......@@ -528,7 +383,7 @@ namespace OnlineStore.DeviceLibrary
}
else
{
wait.IsEnd = CheckWaitResult(wait);
wait.IsEnd = CheckWaitResult(moveInfo, wait);
}
//else if (wait.WaitType.Equals(10))
//{
......@@ -553,13 +408,13 @@ namespace OnlineStore.DeviceLibrary
{
WarnMsg = moveInfo.Name + "[" + moveInfo.MoveType + "][" + moveInfo.MoveStep + "]等待[" + NotOkMsg
+ "]超时[" + Math.Round(span.TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg,DeviceID+ 18);
Alarm(LineAlarmType.IoSingleTimeOut );
LogUtil.error(WarnMsg, DeviceID + 18);
Alarm(LineAlarmType.IoSingleTimeOut);
}
}
protected virtual bool CheckWaitResult(WaitResultInfo wait)
protected virtual bool CheckWaitResult(LineMoveInfo moveInfo, WaitResultInfo wait)
{
return false;
}
......
......@@ -17,6 +17,7 @@ namespace OnlineStore.DeviceLibrary
{
public FeedingEquip_Config Config;
public AxisBean BatchAxis = null;
public FeedingEquip(string cid, FeedingEquip_Config config)
{
this.DeviceID = config.Id;
......@@ -25,13 +26,15 @@ namespace OnlineStore.DeviceLibrary
IsDebug = config.IsDebug.Equals(1);
Name = (" " + "_入料_" + DeviceID % 100 + " ").ToUpper();
Init();
MoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-Move");
SecondMoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-SecondMove");
UseAxis = true;
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,14 +123,9 @@ namespace OnlineStore.DeviceLibrary
{
mainTimer.Stop();
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;
......@@ -136,6 +134,7 @@ namespace OnlineStore.DeviceLibrary
StartReset();
return true;
}return false;
}
/// <summary>
/// 入料装置重置
......@@ -144,20 +143,15 @@ namespace OnlineStore.DeviceLibrary
{
WarnMsg = "";
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("开始重置: ");
runStatus = LineRunStatus.Reset;
MoveInfo.NewMove(LineMoveType.Reset);
StartReset();
return true;
}return false;
}
private void StartReset()
{
......@@ -210,14 +204,14 @@ namespace OnlineStore.DeviceLibrary
case LineMoveStep.FR_04_LocationCylinder_Down:
LogInfo(MoveInfo.MoveType + ":FR_05_AxisHomeMove:2伺服原点返回");
MoveInfo.NextMoveStep(LineMoveStep.FR_05_AxisHomeMove);
ACAxisHomeMove(Config.Batch_Axis);
ACAxisHomeMove(Config.UpDown_Axis);
BatchAxis.HomeMove(MoveInfo);
UpdownAxis.HomeMove(MoveInfo);
break;
case LineMoveStep.FR_05_AxisHomeMove:
LogInfo(MoveInfo.MoveType + ":FR_06_AxisToP1:2伺服到P1点");
MoveInfo.NextMoveStep(LineMoveStep.FR_06_AxisToP1);
ACAxisMove(Config.Batch_Axis, Config.BatchAxisP1, Config.BatchAxis_P1Speed);
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
BatchAxis.AbsMove (MoveInfo, Config.BatchAxisP1, Config.BatchAxis_P1Speed);
UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
break;
case LineMoveStep.FR_06_AxisToP1:
LogInfo(MoveInfo.MoveType + ":FR_07_MoveCylinder_Up:上料横移机构上升SOL");
......@@ -254,8 +248,8 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.EndMove();
SecondMoveInfo.EndMove();
BatchAxisStopCheck();
ACServerManager.SuddenStop(Config.Batch_Axis);
ACServerManager.SuddenStop(Config.UpDown_Axis);
BatchAxis.SuddenStop();
UpdownAxis.SuddenStop();
if (Config.SidesWayNum <= 0)
{
IOMove(IO_Type.FL_StopCylinder_Down1, IO_VALUE.LOW);
......@@ -373,7 +367,7 @@ namespace OnlineStore.DeviceLibrary
if (IOValue(TargetIoType).Equals(TargetIoValue))
{
LogUtil.info(Name+ "上料轴,检测到 " + TargetIoType + "=" + TargetIoValue + ",可以停止运动");
ACServerManager.SuddenStop(Config.Batch_Axis.DeviceName, Config.Batch_Axis.GetAxisValue());
BatchAxis.SuddenStop();
BatchAxisStopCheck();
}
IsInProcess = false;
......
......@@ -10,7 +10,7 @@ namespace OnlineStore.DeviceLibrary
{
partial class FeedingEquip
{
protected override bool CheckWaitResult(WaitResultInfo wait)
protected override bool CheckWaitResult(LineMoveInfo moveInfo,WaitResultInfo wait)
{
if (wait.WaitType.Equals(WaitEnum.W101_BatchAxisMove))
{
......@@ -21,7 +21,7 @@ namespace OnlineStore.DeviceLibrary
}
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)
{
LogUtil.error(msg);
......@@ -193,7 +193,7 @@ namespace OnlineStore.DeviceLibrary
LogInfo(SecondMoveInfo.MoveNum + "*************** 托盘号【" + currTrayNum + "】 ,需要出库,开始出库处理,升降伺服到P1点");
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_201_UpDownToP1);
InStoreLog(" MO_201_UpDownToP1 紧急出料移栽:升降伺服到P1点" );
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
}
else
......@@ -305,7 +305,7 @@ namespace OnlineStore.DeviceLibrary
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_204_UpdownAxisToP2);
int targetP = Config.GetUpdownPositionP2(SecondMoveInfo.MoveParam.PlateH);
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))
{
......@@ -317,7 +317,7 @@ namespace OnlineStore.DeviceLibrary
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_206_UpdownAxisToP1);
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))
{
......@@ -471,7 +471,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(LineMoveStep.FI_08_BatchAxisToP2);
InStoreLog(" FI_08_BatchAxisToP2 开始:提升轴下降到位P2");
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))
{
......@@ -499,7 +499,7 @@ namespace OnlineStore.DeviceLibrary
//无料盘
MoveInfo.NextMoveStep(LineMoveStep.FI_31_BatchAxisToP2);
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))
......@@ -559,7 +559,7 @@ namespace OnlineStore.DeviceLibrary
int targetPositon = Config.GetUpdownPositionP2(LastHeight);
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))
{
......@@ -571,7 +571,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.NextMoveStep(LineMoveStep.FI_21_UpDownAxisToP1);
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))
{
......@@ -605,7 +605,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.NextMoveStep(LineMoveStep.FI_31_BatchAxisToP2);
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))
{
......@@ -617,7 +617,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.NextMoveStep(LineMoveStep.FI_33_BatchAxisToP1);
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))
{
......@@ -685,14 +685,10 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.CanWhileCount = 0;
// 需要增加定时器,获取验证信号并停止伺服
StartMovePosition = ACServerManager.GetActualtPosition(Config.Batch_Axis);
if (StartMovePosition.Equals(-1))
{
StartMovePosition = ACServerManager.GetActualtPosition(Config.Batch_Axis);
}
StartMovePosition = BatchAxis.GetAclPosition();
MoveInfo.WaitList.Add(WaitResultInfo.WaitBatchAxis(Config.Batch_Axis, Config.BatchAxisP3, Config.BatchAxis_P3Speed));
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();
}
......@@ -706,11 +702,7 @@ namespace OnlineStore.DeviceLibrary
{
int AxisChangeValue = Config.Height_ChangeValue;
//计算高度
EndMovePosition = ACServerManager.GetActualtPosition(Config.Batch_Axis);
if (EndMovePosition.Equals(-1))
{
EndMovePosition = ACServerManager.GetActualtPosition(Config.Batch_Axis);
}
EndMovePosition = BatchAxis.GetAclPosition();
LastHeight = (int)Math.Ceiling(1F * (EndMovePosition - StartMovePosition) / AxisChangeValue);
int addHeight = 0;
//如果检测信号未亮,极限亮了,需要补充高
......@@ -870,7 +862,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(LineMoveStep.FO_08_BatchAxisToP2);
InStoreLog(" FO_08_BatchAxisToP2 开始:提升轴下降到位P2");
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))
{
......@@ -882,14 +874,14 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.NextMoveStep(LineMoveStep.FO_10_AxisUpMove);
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))
{
MoveInfo.NextMoveStep(LineMoveStep.FO_11_AxisDownMove);
InStoreLog(" FO_31_BatchAxisToP2 料盘移栽:提升伺服下降指定的高度");
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))
......@@ -914,7 +906,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.NextMoveStep(LineMoveStep.FO_31_BatchAxisToP2);
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))
{
......@@ -926,7 +918,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.NextMoveStep(LineMoveStep.FO_33_BatchAxisToP1);
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))
{
......
......@@ -43,6 +43,7 @@ namespace OnlineStore.DeviceLibrary
Config.UpDown_Axis.ServerOnDO = IO_Type.UpDownAxis_ServoOn;
Config.UpDown_Axis.BreakOnDO = IO_Type.UpDownAxis_BreakOn;
}
UpdownAxis=new AxisBean (config.UpDown_Axis);
}
public override bool StartRun(bool isDebug=false)
......@@ -153,7 +154,7 @@ namespace OnlineStore.DeviceLibrary
public bool ReturnHome()
{
mainTimer.Stop();
if (!RunAxis(true,Config.UpDown_Axis))
if (!RunAxis(true, UpdownAxis))
{
return false;
}
......@@ -178,7 +179,7 @@ namespace OnlineStore.DeviceLibrary
TrayManager.DelNeedEmptyTrayNum();
MoveInfo.EndMove();
}
if (!RunAxis(true, Config.UpDown_Axis))
if (!RunAxis(true, UpdownAxis))
{
return false;
}
......@@ -302,7 +303,7 @@ namespace OnlineStore.DeviceLibrary
{
if (UseAxis)
{
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
}
else
{
......@@ -315,7 +316,7 @@ namespace OnlineStore.DeviceLibrary
if (UseAxis)
{
int position = Config.GetUpdownP2(trayHeight);
ACAxisMove(Config.UpDown_Axis, position, Config.UpdownAxis_DownSpeed);
UpdownAxis.AbsMove(MoveInfo, position, Config.UpdownAxis_DownSpeed);
}
else
{
......@@ -327,7 +328,7 @@ namespace OnlineStore.DeviceLibrary
if (UseAxis)
{
int position = Config.GetUpdownP3(trayHeight);
ACAxisMove(Config.UpDown_Axis, position, Config.UpdownAxis_DownSpeed);
UpdownAxis.AbsMove(MoveInfo, position, Config.UpdownAxis_DownSpeed);
}
else
{
......@@ -339,7 +340,7 @@ namespace OnlineStore.DeviceLibrary
if (UseAxis)
{
MoveInfo.NextMoveStep(LineMoveStep.MH_UpDownHomeMove);
ACAxisHomeMove(Config.UpDown_Axis);
UpdownAxis.HomeMove(MoveInfo);
}
else
{
......
......@@ -42,6 +42,7 @@ namespace OnlineStore.DeviceLibrary
Config.UpDown_Axis.ServerOnDO = IO_Type.UpDownAxis_ServoOn;
Config.UpDown_Axis.BreakOnDO = IO_Type.UpDownAxis_BreakOn;
}
UpdownAxis = new AxisBean(config.UpDown_Axis);
}
public override bool StartRun(bool isDebug=false)
......@@ -70,7 +71,7 @@ namespace OnlineStore.DeviceLibrary
mainTimer.Enabled = false;
}
StopMove();
CloseAxis(Config.UpDown_Axis);
CloseAxis(UpdownAxis);
//停止运行时,把所有IO 置零
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
......@@ -103,7 +104,7 @@ namespace OnlineStore.DeviceLibrary
public bool ReturnHome()
{
if (!RunAxis(true, Config.UpDown_Axis))
if (!RunAxis(true, UpdownAxis))
{
return false;
}
......@@ -121,7 +122,7 @@ namespace OnlineStore.DeviceLibrary
public override bool Reset()
{
if (!RunAxis(true, Config.UpDown_Axis))
if (!RunAxis(true, UpdownAxis))
{
return false;
}
......@@ -223,7 +224,7 @@ namespace OnlineStore.DeviceLibrary
// CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
if (UseAxis)
{
ACServerManager.SuddenStop(Config.UpDown_Axis);
UpdownAxis.SuddenStop();
}
CylinderMove(MoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
......@@ -243,7 +244,7 @@ namespace OnlineStore.DeviceLibrary
{
if (UseAxis)
{
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
}
else
{
......@@ -256,7 +257,7 @@ namespace OnlineStore.DeviceLibrary
if (UseAxis)
{
int position = Config.GetUpdownP2(trayHeight);
ACAxisMove(Config.UpDown_Axis, position, Config.UpdownAxis_DownSpeed);
UpdownAxis.AbsMove(MoveInfo, position, Config.UpdownAxis_DownSpeed);
}
else
{
......@@ -268,7 +269,7 @@ namespace OnlineStore.DeviceLibrary
if (UseAxis)
{
int position = Config.GetUpdownP3(trayHeight);
ACAxisMove(Config.UpDown_Axis, position, Config.UpdownAxis_DownSpeed);
UpdownAxis.AbsMove(MoveInfo, position, Config.UpdownAxis_DownSpeed);
}
else
{
......@@ -280,7 +281,7 @@ namespace OnlineStore.DeviceLibrary
if (UseAxis)
{
MoveInfo.NextMoveStep(LineMoveStep.MH_UpDownHomeMove);
ACAxisHomeMove(Config.UpDown_Axis);
UpdownAxis.HomeMove(MoveInfo);
}
else
{
......
......@@ -12,7 +12,7 @@ namespace OnlineStore.DeviceLibrary
{
#region 托盘检测
protected override bool CheckWaitResult(WaitResultInfo wait)
protected override bool CheckWaitResult(LineMoveInfo moveInfo, WaitResultInfo wait)
{
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
{
// 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)
{
LogUtil.error("AIO WriteSingleDO ["+ioIp+"] [" + StartAddress + "] 第" + i + "次失败:" + aioBox.ErrInfo);
}
else
{
break;
}
LogUtil.error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 失败:" + aioBox.ErrInfo);
}
// else
// {
// break;
// }
//}
}
else
{
......@@ -364,16 +364,14 @@ namespace OnlineStore.DeviceLibrary
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
{
AIOBOX aioBox = getAIO(ioIp);
Box_Sta currBox_Sta = GetBox_Sta(onOff);
if (aioBox != null)
{
// Box_Addr add = GetAddr(StartAddress);
Box_Sta currBox_Sta = GetBox_Sta(onOff);
aioBox.WriteDO(StartAddress, currBox_Sta);
//写入之后,等待指定间隔后回写
......@@ -392,6 +390,7 @@ namespace OnlineStore.DeviceLibrary
};
mytimer.AutoReset = false;//设置是否自动重启,即自动执行多次;
mytimer.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件mytask;
}
else
{
......@@ -445,9 +444,6 @@ namespace OnlineStore.DeviceLibrary
if (aioBox != null)
{
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)
{
sta = DOValueMap[ioIP][StartAddress];
......
......@@ -40,31 +40,8 @@ namespace OnlineStore.LoadCSVLibrary
public int SubType { 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()
{
// return "ConfigBase。" + "类型:" + ProType + ",说明:" + Explain + ",名称:" + ProName + ",属性值:" + ProVale;
......@@ -135,10 +112,7 @@ namespace OnlineStore.LoadCSVLibrary
/// 出入库目标值(只有出入库过程中才会有效)
/// </summary>
public int TargetPosition { get; set; }
///// <summary>
///// 速度倍率
///// </summary>
//public int ResolveSpeed { get; set; }
/// <summary>
/// 最小位置
/// </summary>
......@@ -159,28 +133,21 @@ namespace OnlineStore.LoadCSVLibrary
}
return false;
}
public bool PositionIsHasLimit(){
if (PositionMin.Equals(PositionMax))
{
return false;
} return true;
}
/// <summary>
/// 下拉列表显示
/// </summary>
public string DisplayStr
{
get {
get
{
return Explain + "(" + ProName + ")";
}
set
{
}
}
public override int GetValue()
{
return GetAxisValue();
}
/// <summary>
/// 使用康泰克板卡表示轴编号,使用Ac伺服电机表示伺服地址
/// </summary>
......@@ -193,11 +160,6 @@ namespace OnlineStore.LoadCSVLibrary
}
return (short)Convert.ToInt32(ProValue);
}
//public override string ToString()
//{
// return "ConfigMoveAxis。" + "类型:" + ProType + ",说明:" + Explain + ",名称:" + ProName + ",属性值:" + ProVale + ",设备名称:" + DeviceName;
//}
public override void CheckField()
{
if (String.IsNullOrEmpty( ProType) || String.IsNullOrEmpty( ProName ) || String.IsNullOrEmpty( DeviceName ) || String.IsNullOrEmpty( ProValue ))
......@@ -205,16 +167,6 @@ namespace OnlineStore.LoadCSVLibrary
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;
}
}
......@@ -289,7 +241,23 @@ namespace OnlineStore.LoadCSVLibrary
{
}
}
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()
//{
// return "[" + ProType + "]" + Explain + "," + ProName + ",属性值:" + ProVale + ",设备名称:" + DeviceName + ",描述:" + Describe + ",电器定义:" + ElectricalDefinition + ",代码定义:" + CodeDefinition + "";
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!