Commit 1f248698 LN

1

1 个父辈 b1cebe83
......@@ -170,16 +170,13 @@ namespace OnlineStore.DeviceLibrary
Task.Factory.StartNew(delegate
{
IOManager.instance.ConnectionIOList(cioList);
Thread.Sleep(5);
// if (!IsDebug)
//{
Thread.Sleep(5);
Task.Factory.StartNew(delegate
{
string[] rfidArray = rfidList.ToArray();
//连接rfip
RFIDManager.RfidReader.Open(rfidArray);
});
//}
});
addLastDI(IO_Type.Airpressure_Check, IOValue(IO_Type.Airpressure_Check));
addLastDI(IO_Type.SuddenStop_BTN, IOValue(IO_Type.SuddenStop_BTN));
addLastDI(IO_Type.Reset_BTN, IOValue(IO_Type.Reset_BTN));
......
......@@ -9,18 +9,15 @@ using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class AxisBean
{
public ConfigMoveAxis Config =null;
public class AxisBean
{
public ConfigMoveAxis Config = null;
public static int TimeoutInterval = 500;
/// <summary>
/// 正常工作过程中判断位置是否到达时使用
/// </summary>
public int LastPosition = 0;
public string AxisName;
public AxisBean(ConfigMoveAxis axisConfig)
{
......@@ -28,9 +25,9 @@ namespace OnlineStore.DeviceLibrary
AxisName = Config.Explain + "[" + Config.DeviceName + "-" + Config.GetAxisValue() + "]";
}
private bool IsIntSlvBlock = false;
public bool Open(bool isCheck,out string Msg)
public bool Open(bool isCheck, out string Msg)
{
Msg = "";
string portName = Config.DeviceName;
......@@ -64,7 +61,7 @@ namespace OnlineStore.DeviceLibrary
/// 打开所有轴
/// </summary>
/// <returns></returns>
private bool OpenAxis( out string msg)
private bool OpenAxis(out string msg)
{
msg = "";
//判断轴是否正常
......@@ -72,25 +69,25 @@ namespace OnlineStore.DeviceLibrary
int slvAddr = Config.GetAxisValue();
if (ACServerManager.ServerOnStatus(portName, slvAddr))
{
LogUtil.info( AxisName+ "成功打开" );
LogUtil.info(AxisName + "成功打开");
}
else
{
//清理报警,再重新打开一次
LogUtil.info(AxisName+ "第一次打开失败,先清理一下报警,再重新打开一次");
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);
LogUtil.info(AxisName + "清理报警后重新打卡轴成功:" + Config.Explain);
}
else
{
ACServerManager.ServoOff(portName, slvAddr);
msg= "打开轴" + Config.Explain + "失败 ";
LogUtil.info(AxisName + msg);
msg = "打开轴" + Config.Explain + "失败 ";
LogUtil.info(AxisName + msg);
return false;
}
}
......@@ -98,9 +95,9 @@ namespace OnlineStore.DeviceLibrary
return true;
}
public void ServoOff()
{
{
LogUtil.info("ServoOff【" + AxisName + "】");
ACServerManager.ServoOff(Config.DeviceName, Config.GetAxisValue());
ACServerManager.ServoOff(Config.DeviceName, Config.GetAxisValue());
}
public void HomeMove(LineMoveInfo MoveInfo)
{
......@@ -123,14 +120,14 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(Config, targetPosition, targetSpeed));
Config.TargetPosition = targetPosition;
ACServerManager.AbsMove(Config.DeviceName, Config.GetAxisValue(), targetPosition, targetSpeed);
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)
public static bool ACAxisMoveIsEnd(LineMoveInfo MoveInfo, ConfigMoveAxis axis, int targetPosition, int targetSpeed, out string msg)
{
msg = "";
string deviceName = axis.DeviceName;
......@@ -156,14 +153,14 @@ namespace OnlineStore.DeviceLibrary
}
else
{
msg = " " + MoveInfo.SLog + axis.DisplayStr + ",目标位置[" + targetPosition + "]当前位置[" + outCount
msg = " " + MoveInfo.SLog + axis.DisplayStr + ",目标位置[" + targetPosition + "]当前位置[" + outCount
+ "],误差过大,需要报警";
LogUtil.error(msg,1034);
LogUtil.error(msg, 1034);
}
}
return false;
}
public static bool HomeMoveIsEnd(LineMoveInfo MoveInfo, ConfigMoveAxis axis, out string msg)
public static bool HomeMoveIsEnd(LineMoveInfo MoveInfo, ConfigMoveAxis axis, out string msg)
{
msg = "";
if (ACServerManager.IsHomeMoveEnd(axis.DeviceName, axis.GetAxisValue()))
......@@ -185,14 +182,14 @@ namespace OnlineStore.DeviceLibrary
}
else
{
msg = " " + MoveInfo.SLog + axis.DisplayStr + ",收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警";
msg = " " + MoveInfo.SLog + axis.DisplayStr + ",收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警";
LogUtil.error(msg);
}
}
return false;
}
public int GetAclPosition()
public int GetAclPosition()
{
int p = ACServerManager.GetActualtPosition(Config);
return p;
......@@ -200,12 +197,12 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 绝对运动至点,不等待结果
/// </summary>
private void AbsMove(int targetPos, double targetSpeed)
private void AbsMove(int targetPos, double targetSpeed)
{
if (targetPos.Equals(-1))
{
return ;
}
return;
}
LastPosition = -1;
if (targetSpeed > Config.TargetSpeed || targetSpeed <= 0)
{
......@@ -217,209 +214,13 @@ namespace OnlineStore.DeviceLibrary
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;
//}
}
}
......@@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
......@@ -40,8 +40,8 @@ namespace OnlineStore.LoadCSVLibrary
public int SubType { get; set; }
public string ConfigStr { get; set; }
public override string ToString()
{
// return "ConfigBase。" + "类型:" + ProType + ",说明:" + Explain + ",名称:" + ProName + ",属性值:" + ProVale;
......@@ -50,9 +50,9 @@ namespace OnlineStore.LoadCSVLibrary
public virtual void CheckField()
{
if (String.IsNullOrEmpty(ProType) || String.IsNullOrEmpty(ProName) || String.IsNullOrEmpty(ProValue))
if (String.IsNullOrEmpty(ProType) || String.IsNullOrEmpty(ProName) || String.IsNullOrEmpty(ProValue))
{
throw new CVSFieldNotMatchingExection(ToString() + ",【类型:"+ProType+"】【名称:"+ProName+"】【属性值:"+ProValue+"】必须配置值!");
throw new CVSFieldNotMatchingExection(ToString() + ",【类型:" + ProType + "】【名称:" + ProName + "】【属性值:" + ProValue + "】必须配置值!");
}
}
}
......@@ -64,7 +64,7 @@ namespace OnlineStore.LoadCSVLibrary
/// <summary>
/// 伺服ON的Do信号
/// </summary>
public string ServerOnDO ="" ;
public string ServerOnDO = "";
/// <summary>
/// 伺服刹车信号
/// </summary>
......@@ -84,7 +84,7 @@ namespace OnlineStore.LoadCSVLibrary
/// </summary>
//[CSVAttribute("目标速度")]
public int TargetSpeed { get; set; }
/// <summary>
/// 加速度
/// </summary>
......@@ -106,20 +106,20 @@ namespace OnlineStore.LoadCSVLibrary
/// <summary>
/// 可以误差的脉冲范围的最大值
/// </summary>
public int CanErrorCountMax = 100;
public int CanErrorCountMax = 500;
/// <summary>
/// 出入库目标值(只有出入库过程中才会有效)
/// </summary>
public int TargetPosition { get; set; }
/// <summary>
/// 最小位置
/// </summary>
public int PositionMin { get; set; }
/// <summary>
/// 最大位置
/// </summary>
/// <summary>
/// 最大位置
/// </summary>
public int PositionMax { get; set; }
public string GetNameStr()
{
......@@ -133,7 +133,7 @@ namespace OnlineStore.LoadCSVLibrary
}
return false;
}
/// <summary>
/// 下拉列表显示
/// </summary>
......@@ -147,29 +147,29 @@ namespace OnlineStore.LoadCSVLibrary
{
}
}
/// <summary>
/// 使用康泰克板卡表示轴编号,使用Ac伺服电机表示伺服地址
/// </summary>
/// <returns></returns>
public short GetAxisValue()
{
{
if (ProValue.Equals("") || ProValue.Equals("-1"))
{
{
return -1;
}
return (short)Convert.ToInt32(ProValue);
}
}
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】必须配置值!");
}
}
}
}
/// <summary>
/// io配置
/// </summary>
......@@ -195,7 +195,7 @@ namespace OnlineStore.LoadCSVLibrary
}
else
{
return DeviceName;
return DeviceName;
}
}
return IP;
......@@ -229,13 +229,13 @@ namespace OnlineStore.LoadCSVLibrary
/// <summary>
/// SlaveID
/// </summary>
[CSVAttribute("SlaveID") ]
public byte SlaveID { get; set; }
[CSVAttribute("SlaveID")]
public byte SlaveID { get; set; }
public string DisplayStr
{
get
{
return ElectricalDefinition + "-" + Explain + "-" + ProName+"";
return ElectricalDefinition + "-" + Explain + "-" + ProName + "";
}
set
{
......@@ -278,5 +278,5 @@ namespace OnlineStore.LoadCSVLibrary
public static string AXIS = "AXIS";
public static string PRO = "PRO";
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!