Commit 1c43d39d 刘韬

导入汇川库

1 个父辈 73bbb05b

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2024
# Visual Studio Version 16
VisualStudioVersion = 16.0.30621.155
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "source\Common\Common.csproj", "{43CDD09E-FCF3-4960-A01D-3BBFE9933122}"
EndProject
......
......@@ -73,7 +73,10 @@ namespace OnlineStore.Common
/// 温控器类型,0=壁挂王字壳温湿度变送器,1=妙昕温湿度记录仪
/// </summary>
public static string HumitureControllerType = "HumitureControllerType";
public static string UseHCBoard = "UseHCBoard";
public static string UseAIOBOX = "UseAIOBOX";
public static string LineServerIp = "LineServerIp";
public static string LineServerPort = "LineServerPort";
......
......@@ -41,9 +41,6 @@
<Reference Include="CodeLibrary">
<HintPath>..\..\dll\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="DeviceLib">
<HintPath>..\..\dll\DeviceLib.dll</HintPath>
</Reference>
<Reference Include="halcondotnet">
<HintPath>..\..\dll\halcondotnet.dll</HintPath>
</Reference>
......
using DeviceLib;
using log4net;
using log4net;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
......@@ -40,7 +39,7 @@ namespace OnlineStore.DUOStore
private void AxisMove(ConfigMoveAxis axis, int speed)
{
LogUtil.debug( "点动:deviceName=" + axis.DeviceName + ",axis=" + axis.GetAxisValue() + ",speed=" + speed);
ACServerManager.SpeedMove(axis.DeviceName, axis.GetAxisValue(), speed);
AxisManager.instance.SpeedMove(axis.DeviceName, axis.GetAxisValue(), speed);
}
private void FrmAxisDebug_Load(object sender, EventArgs e)
......@@ -55,7 +54,7 @@ namespace OnlineStore.DUOStore
{
int InOutDefaultPosition = ConfigAppSettings.GetIntValue(Setting_Init.InOutDefaultPosition);
int currValue = ACServerManager.GetActualtPosition(inout.DeviceName, inout.GetAxisValue());
int currValue = AxisManager.instance.GetActualtPosition(inout.DeviceName, inout.GetAxisValue());
if (currValue <= InOutDefaultPosition)
{
return true;
......@@ -88,7 +87,7 @@ namespace OnlineStore.DUOStore
if (btnMiddleMove.BackColor == Color.Green)
{
btnMiddleMove.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(middle.DeviceName, middle.GetAxisValue());
AxisManager.instance.SuddenStop(middle.DeviceName, middle.GetAxisValue());
UpdateMiddlePosition();
}
}
......@@ -116,8 +115,8 @@ namespace OnlineStore.DUOStore
{
if (btnUpDownMove.BackColor == Color.Green)
{
btnUpDownMove.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(updown.DeviceName, updown.GetAxisValue());
btnUpDownMove.BackColor = System.Drawing.SystemColors.Control;
AxisManager.instance.SuddenStop(updown.DeviceName, updown.GetAxisValue());
UpdateUpdownPosition();
}
}
......@@ -142,7 +141,7 @@ namespace OnlineStore.DUOStore
if (this.btnInOutMove.BackColor == Color.Green)
{
btnInOutMove.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(inout.DeviceName, inout.GetAxisValue());
AxisManager.instance.SuddenStop(inout.DeviceName, inout.GetAxisValue());
UpdateInOutPosition();
}
}
......@@ -170,7 +169,7 @@ namespace OnlineStore.DUOStore
if (btnMiddleMovej.BackColor == Color.Green)
{
btnMiddleMovej.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(middle.DeviceName, middle.GetAxisValue());
AxisManager.instance.SuddenStop(middle.DeviceName, middle.GetAxisValue());
UpdateMiddlePosition();
}
}
......@@ -199,7 +198,7 @@ namespace OnlineStore.DUOStore
if (btnUpDownMovej.BackColor == Color.Green)
{
btnUpDownMovej.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(updown.DeviceName, updown.GetAxisValue());
AxisManager.instance.SuddenStop(updown.DeviceName, updown.GetAxisValue());
UpdateUpdownPosition();
}
}
......@@ -224,7 +223,7 @@ namespace OnlineStore.DUOStore
if (btnInOutMovej.BackColor.Equals(Color.Green))
{
btnInOutMovej.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(inout.DeviceName, inout.GetAxisValue());
AxisManager.instance.SuddenStop(inout.DeviceName, inout.GetAxisValue());
UpdateInOutPosition();
}
}
......@@ -247,8 +246,8 @@ namespace OnlineStore.DUOStore
{
if (this.btnComMove.BackColor == Color.Green)
{
btnComMove.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(comp.DeviceName, comp.GetAxisValue());
btnComMove.BackColor = System.Drawing.SystemColors.Control;
AxisManager.instance.SuddenStop(comp.DeviceName, comp.GetAxisValue());
UpdateCompPosition();
}
}
......@@ -268,8 +267,8 @@ namespace OnlineStore.DUOStore
{
if (btnComMovej.BackColor.Equals(Color.Green))
{
btnComMovej.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(comp.DeviceName,comp.GetAxisValue());
btnComMovej.BackColor = System.Drawing.SystemColors.Control;
AxisManager.instance.SuddenStop(comp.DeviceName,comp.GetAxisValue());
UpdateCompPosition();
}
}
......@@ -297,7 +296,7 @@ namespace OnlineStore.DUOStore
}
private void UpdateCompPosition()
{
int compPosition = ACServerManager.GetTargetPosition(comp.DeviceName, comp.GetAxisValue());
int compPosition = AxisManager.instance.GetTargetPosition(comp.DeviceName, comp.GetAxisValue());
if (!txtComPosition.Text.Equals(compPosition.ToString()))
{
txtComPosition.Text = compPosition.ToString();
......@@ -305,7 +304,7 @@ namespace OnlineStore.DUOStore
}
private void UpdateUpdownPosition()
{
int updownPosition = ACServerManager.GetTargetPosition(updown.DeviceName, updown.GetAxisValue());
int updownPosition = AxisManager.instance.GetTargetPosition(updown.DeviceName, updown.GetAxisValue());
if (!txtUpdownPosition.Text.Equals(updownPosition.ToString()))
{
txtUpdownPosition.Text = updownPosition.ToString();
......@@ -314,7 +313,7 @@ namespace OnlineStore.DUOStore
private void UpdateMiddlePosition()
{
int middlePosition = ACServerManager.GetTargetPosition(middle.DeviceName, middle.GetAxisValue());
int middlePosition = AxisManager.instance.GetTargetPosition(middle.DeviceName, middle.GetAxisValue());
if (!txtMiddlePosition.Text.Equals(middlePosition.ToString()))
{
txtMiddlePosition.Text = middlePosition.ToString();
......@@ -323,7 +322,7 @@ namespace OnlineStore.DUOStore
private void UpdateInOutPosition()
{
int inoutPosition = ACServerManager.GetTargetPosition(inout.DeviceName, inout.GetAxisValue());
int inoutPosition = AxisManager.instance.GetTargetPosition(inout.DeviceName, inout.GetAxisValue());
if (!txtInOutPosition.Text.Equals(inoutPosition.ToString()))
{
txtInOutPosition.Text = inoutPosition.ToString();
......
......@@ -17,7 +17,6 @@ using OnlineStore.DeviceLibrary;
using System.IO.Ports;
using OnlineStore.LoadCSVLibrary;
using CodeLibrary;
using DeviceLib;
using UserFromControl;
namespace OnlineStore.DUOStore
......
......@@ -17,7 +17,6 @@ using OnlineStore.DeviceLibrary;
using System.IO.Ports;
using OnlineStore.LoadCSVLibrary;
using CodeLibrary;
using DeviceLib;
using UserFromControl;
namespace OnlineStore.DUOStore
......@@ -411,7 +410,7 @@ namespace OnlineStore.DUOStore
private bool InOutIsIsP1()
{
int InOutDefaultPosition = ConfigAppSettings.GetIntValue(Setting_Init.InOutDefaultPosition);
int currValue = ACServerManager.GetActualtPosition(BoxBean.Config.InOut_Axis.DeviceName, BoxBean.Config.InOut_Axis.GetAxisValue());
int currValue = AxisManager.instance.GetActualtPosition(BoxBean.Config.InOut_Axis.DeviceName, BoxBean.Config.InOut_Axis.GetAxisValue());
if (currValue <= InOutDefaultPosition)
{
return true;
......@@ -431,7 +430,7 @@ namespace OnlineStore.DUOStore
}
int targetPosition = FormUtil.GetIntValue(txtValue);
moveAxis.TargetPosition = targetPosition;
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed);
AxisManager.instance.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed, moveAxis.AddSpeed, moveAxis.DelSpeed);
}
private void btnUpDownP1_Click(object sender, EventArgs e)
{
......@@ -711,7 +710,7 @@ namespace OnlineStore.DUOStore
private void btnUpdown_Click(object sender, EventArgs e)
{
string PortName = BoxBean.Config.UpDown_Axis.DeviceName;
int slvAddr = BoxBean.Config.UpDown_Axis.GetAxisValue();
short slvAddr = BoxBean.Config.UpDown_Axis.GetAxisValue();
string ioIP = "192.168.200.13";
int ioIndex = 0;
// if (store.Config.StoreDIList.ContainsKey(IO_Type.UpdownPositionSingal))
......
using CodeLibrary;
using DeviceLib;
using log4net;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
......@@ -243,7 +242,7 @@ namespace OnlineStore.DUOStore
e.Cancel = true;
HideForm();
}
}
}
private void ExitApp()
{
......@@ -270,8 +269,8 @@ namespace OnlineStore.DUOStore
IOManager.instance.CloseAllDO();
IOManager.instance.CloseAllConnection();
HumitureController.CloseAllPort();
ACServerManager.CloseAllPort();
HumitureController.CloseAllPort();
AxisManager.instance.CloseAllPort();
if (Camera._cam != null)
{
Camera._cam.CloseAll();
......

using DeviceLib;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
......@@ -22,14 +21,16 @@ namespace OnlineStore.DUOStore
{
private string LogName = ResourceCulture.GetString("升降轴位置调试:");
private string PortName = "";
private int SlvAddr = 0;
private short SlvAddr = 0;
private string IoIp = "";
private int IoIndex = 0;
public string Axis_Brake = IO_Type.UpdownAxis_Break;
private int subType = 0;
private System.Timers.Timer toolTimer = new System.Timers.Timer();
public int ptpAcc=0;
public int ptpDec = 0;
private string boxName = "";
public FrmPositionTool(string protName, int slvAddr, string ioIp, int ioIndex, string text,int ioSubType)
public FrmPositionTool(string protName, short slvAddr, string ioIp, int ioIndex, string text,int ioSubType)
{
InitializeComponent();
this.PortName = protName;
......@@ -49,11 +50,11 @@ namespace OnlineStore.DUOStore
private void Form1_Load(object sender, EventArgs e)
{
ACServerManager.IsShowMsg = false;
AxisManager.instance.IsShowMsg = false;
LogUtil.logBox = this.richTextBox1;
//ACServerManager.richeBox = this.richTextBox1;
//AxisManager.instance.richeBox = this.richTextBox1;
CheckForIllegalCrossThreadCalls = false;
txtPortName.Text = PortName;
......@@ -91,7 +92,7 @@ namespace OnlineStore.DUOStore
SaveConfig(tSpeed, tPosition);
//判断伺服是否已经打开
bool isOn = ACServerManager.ServerOnStatus(PortName, SlvAddr);
bool isOn = AxisManager.instance.IsServeoOn(PortName, SlvAddr);
formStatus(isOn);
timer1.Start();
ioStatusControl1.IOName = ResourceCulture.GetString("检测信号");
......@@ -109,8 +110,8 @@ namespace OnlineStore.DUOStore
//P6Offset = FormUtil.GetIntValue(txtP6Offset);
//StopTimer();
this.PortName = txtPortName.Text;
this.SlvAddr = FormUtil.GetIntValue(txtAddr);
bool result = ACServerManager.OpenPort(PortName,ConfigAppSettings.GetIntValue(Setting_Init.ACBaudRate));
this.SlvAddr = FormUtil.GetShortValue(txtAddr);
bool result = AxisManager.instance.OpenPort(PortName);
if (!result)
{
MessageBox.Show(ResourceCulture.GetString("打开串口失败"));
......@@ -118,10 +119,10 @@ namespace OnlineStore.DUOStore
}
formStatus(true);
ACServerManager.InitSlvAddr(PortName, SlvAddr);
//AxisManager.instance.InitSlvAddr(PortName, SlvAddr);
Thread.Sleep(100);
ACServerManager.AlarmClear(PortName, SlvAddr);
ACServerManager.ServoOn(PortName, SlvAddr);
AxisManager.instance.AlarmClear(PortName, SlvAddr);
AxisManager.instance.ServoOn(PortName, SlvAddr);
try
{
......@@ -137,7 +138,7 @@ namespace OnlineStore.DUOStore
{
StopTimer();
// toolTimer.Stop();
ACServerManager.SuddenStop(PortName, SlvAddr);
AxisManager.instance.SuddenStop(PortName, SlvAddr);
Thread.Sleep(100);
try
{
......@@ -147,7 +148,7 @@ namespace OnlineStore.DUOStore
{
}
ACServerManager.ServoOff(PortName, SlvAddr);
AxisManager.instance.ServoOff(PortName, SlvAddr);
formStatus(false);
}
......@@ -174,25 +175,25 @@ namespace OnlineStore.DUOStore
private void btnRelMove_Click(object sender, EventArgs e)
{
int speed = Convert.ToInt32(txtSpeed.Text);
int position = Convert.ToInt32(txtPosition.Text);
ACServerManager.RelMove(PortName, SlvAddr, position,speed);
//int speed = Convert.ToInt32(txtSpeed.Text);
//int position = Convert.ToInt32(txtPosition.Text);
//AxisManager.instance.RelMove(PortName, SlvAddr, position,speed);
}
private void btnHomeMove_Click(object sender, EventArgs e)
{
int speed = Convert.ToInt32(txtSpeed.Text);
ACServerManager.HomeMove(PortName, SlvAddr, speed);
AxisManager.instance.HomeMove(PortName, SlvAddr,50,1 ,speed);
}
private void btnSpeedMove_Click(object sender, EventArgs e)
{
int speed = Convert.ToInt32(txtSpeed.Text);
ACServerManager.SpeedMove(PortName, SlvAddr, speed);
AxisManager.instance.SpeedMove(PortName, SlvAddr, speed);
}
private void btnGetActualPosition_Click(object sender, EventArgs e)
{
int value = ACServerManager.GetTargetPosition(PortName, SlvAddr);
int value = AxisManager.instance.GetTargetPosition(PortName, SlvAddr);
txtTargetPosition.Text = value.ToString();
value = ACServerManager.GetActualtPosition(PortName, SlvAddr);
value = AxisManager.instance.GetActualtPosition(PortName, SlvAddr);
txtActualPosition.Text = value.ToString();
}
......@@ -242,7 +243,7 @@ namespace OnlineStore.DUOStore
PositionList = new List<int>();
LogUtil.info(LogName + "伺服开始运动,速度【"+speed+"】位置【"+position+"】启动定时器 ");
formMoveStatus(false);
ACServerManager.AbsMove(PortName, SlvAddr, position,speed);
AxisManager.instance.AbsMove(PortName, SlvAddr, position,speed,ptpAcc,ptpDec);
toolTimer.Start();
}
private int P3Offset = 0;
......@@ -263,7 +264,7 @@ namespace OnlineStore.DUOStore
private void btnSdStop_Click(object sender, EventArgs e)
{
toolTimer.Stop();
ACServerManager.SuddenStop(PortName, SlvAddr);
AxisManager.instance.SuddenStop(PortName, SlvAddr);
}
private IO_VALUE GetSingleValue()
......@@ -289,14 +290,14 @@ namespace OnlineStore.DUOStore
isInProcesss = true;
try
{
int moveS = ACServerManager.GetBusyStatus(PortName, SlvAddr);
int moveS = AxisManager.instance.GetBusyStatus(PortName, SlvAddr);
if (moveS.Equals(1))
{
IO_VALUE currValue = GetSingleValue();
TimeSpan checkSpan = DateTime.Now - LastGetPTime;
if (LastValue.Equals(IO_VALUE.LOW) && currValue.Equals(IO_VALUE.HIGH) && checkSpan.TotalSeconds > 2)
{
int currPos = ACServerManager.GetActualtPosition(PortName, SlvAddr);
int currPos = AxisManager.instance.GetActualtPosition(PortName, SlvAddr);
txtActualPosition.Text = currPos.ToString();
PositionList.Add(currPos);
int num = PositionList.Count;
......@@ -399,11 +400,11 @@ namespace OnlineStore.DUOStore
{
StopTimer();
// toolTimer.Stop();
ACServerManager.SuddenStop(PortName, SlvAddr);
AxisManager.instance.SuddenStop(PortName, SlvAddr);
Thread.Sleep(100);
}
LogUtil.logBox = null;
//ACServerManager.CloseAllPort();
//AxisManager.instance.CloseAllPort();
//IOManager.instance.CloseAllConnection();
}
......
......@@ -11,7 +11,6 @@ using OnlineStore.DeviceLibrary;
using OnlineStore.Common;
using System.Threading;
using OnlineStore.LoadCSVLibrary;
using DeviceLib;
namespace OnlineStore.DUOStore
{
......@@ -20,8 +19,9 @@ namespace OnlineStore.DUOStore
private List<AxisBean> axisList = new List<AxisBean>();
private BoxBean boxBean = null;
private string PortName = "";
private int SlvAddr = 0;
private short SlvAddr = 0;
public int ptpAcc = 0;
public int ptpDec = 0;
public AxisMoveControl()
{
InitializeComponent();
......@@ -85,7 +85,7 @@ namespace OnlineStore.DUOStore
private void btnCloseAxis_Click(object sender, EventArgs e)
{
LogUtil.info("点击【关闭伺服】,【" + PortName + "_" + SlvAddr + "】 ");
// ACServerManager.ServoOff(PortName, SlvAddr);
// AxisManager.instance.ServoOff(PortName, SlvAddr);
axisList[comboBox1.SelectedIndex].ServoOff();
}
......@@ -98,7 +98,7 @@ namespace OnlineStore.DUOStore
int position = FormUtil.GetIntValue(txtAPosition);
int speed = FormUtil.GetIntValue(txtASpeed);
LogUtil.info("点击【绝对运动】,【" + PortName + "_" + SlvAddr + "】位置【" + position + "】速度【" + speed + "】");
ACServerManager.AbsMove(PortName, SlvAddr, position, speed);
AxisManager.instance.AbsMove(PortName, SlvAddr, position, speed, ptpAcc, ptpDec);
}
private void btnAxisRMove_Click(object sender, EventArgs e)
......@@ -110,7 +110,7 @@ namespace OnlineStore.DUOStore
int position = FormUtil.GetIntValue(txtAPosition);
int speed = FormUtil.GetIntValue(txtASpeed);
LogUtil.info("点击【相对运动】,【" + PortName + "_" + SlvAddr + "】位置【" + position + "】速度【" + speed + "】");
ACServerManager.RelMove(PortName, SlvAddr, position, speed);
AxisManager.instance.RelMove(PortName, SlvAddr, position, speed,ptpAcc,ptpDec);
}
private void btnAxisVMove_Click(object sender, EventArgs e)
......@@ -121,13 +121,13 @@ namespace OnlineStore.DUOStore
}
int speed = FormUtil.GetIntValue(txtASpeed);
LogUtil.info("点击【匀速运动】,【" + PortName + "_" + SlvAddr + "】 速度【" + speed + "】");
ACServerManager.SpeedMove(PortName, SlvAddr, speed);
AxisManager.instance.SpeedMove(PortName, SlvAddr, speed);
}
private void btnAxisStop_Click(object sender, EventArgs e)
{
LogUtil.info("点击【停止运动】,【" + PortName + "_" + SlvAddr + "】 ");
ACServerManager.SuddenStop(PortName, SlvAddr);
AxisManager.instance.SuddenStop(PortName, SlvAddr);
if (btnAddMove.BackColor == Color.Green)
{
btnAddMove.BackColor = System.Drawing.SystemColors.Control;
......@@ -143,9 +143,9 @@ namespace OnlineStore.DUOStore
private void btnComAlarmClear_Click(object sender, EventArgs e)
{
LogUtil.info("点击【清理报警】,【" + PortName + "_" + SlvAddr + "】 ");
ACServerManager.AlarmClear(PortName, SlvAddr);
AxisManager.instance.AlarmClear(PortName, SlvAddr);
Thread.Sleep(100);
ACServerManager.ServoOn(PortName, SlvAddr);
AxisManager.instance.ServoOn(PortName, SlvAddr);
}
private void btnAxisReturnHome_Click(object sender, EventArgs e)
......@@ -156,25 +156,25 @@ namespace OnlineStore.DUOStore
}
int speed = FormUtil.GetIntValue(txtASpeed);
LogUtil.info("点击【原点返回】,【" + PortName + "_" + SlvAddr + "】 速度【" + speed + "】");
ACServerManager.HomeMove(PortName, SlvAddr, speed);
AxisManager.instance.HomeMove(PortName, SlvAddr,50,1,speed);
}
private void btnGetAlarm_Click(object sender, EventArgs e)
{
this.txtAlarmStatus.Text = ACServerManager.GetAlarmStatus(PortName, SlvAddr).ToString();
this.txtBusyStatus.Text = ACServerManager.GetBusyStatus(PortName, SlvAddr).ToString();
this.txtStb.Text = ACServerManager.GetSTBState(PortName, SlvAddr).ToString();
this.txtHomeStatus.Text = ACServerManager.GetHomeEndStatus(PortName, SlvAddr).ToString();
this.txtHomeSingle.Text = ACServerManager.GetHomeSingle(PortName, SlvAddr).ToString();
this.txtLimit1.Text = ACServerManager.GetLimitPositiveSingle(PortName, SlvAddr).ToString();
this.txtLimit2.Text = ACServerManager.GetLimitNegativeSingle(PortName, SlvAddr).ToString();
txtServoStatue.Text = ACServerManager.ServerOnStatus(PortName, SlvAddr) ? "✔" : "✘";
this.txtAlarmStatus.Text = AxisManager.instance.GetAlarmStatus(PortName, SlvAddr).ToString();
this.txtBusyStatus.Text = AxisManager.instance.GetBusyStatus(PortName, SlvAddr).ToString();
//this.txtStb.Text = AxisManager.instance.GetSTBState(PortName, SlvAddr).ToString();
this.txtHomeStatus.Text = AxisManager.instance.GetHomeEndStatus(PortName, SlvAddr).ToString();
this.txtHomeSingle.Text = AxisManager.instance.GetHomeSingle(PortName, SlvAddr).ToString();
this.txtLimit1.Text = AxisManager.instance.GetLimitPositiveSingle(PortName, SlvAddr).ToString();
this.txtLimit2.Text = AxisManager.instance.GetLimitNegativeSingle(PortName, SlvAddr).ToString();
txtServoStatue.Text = AxisManager.instance.IsServeoOn(PortName, SlvAddr) ? "✔" : "✘";
}
private void btnReadPosition_Click(object sender, EventArgs e)
{
lblCountPulse.Text = ACServerManager.GetActualtPosition(PortName, SlvAddr).ToString();
lblCountPulse.Text = AxisManager.instance.GetActualtPosition(PortName, SlvAddr).ToString();
}
......@@ -254,7 +254,7 @@ namespace OnlineStore.DUOStore
private void AxisMove(int speed)
{
LogUtil.info("【" + PortName + "_" + SlvAddr + "】点动: 速度:" + speed);
ACServerManager.SpeedMove(PortName, SlvAddr, speed);
AxisManager.instance.SpeedMove(PortName, SlvAddr, speed);
}
private void btnAddMove_MouseDown(object sender, MouseEventArgs e)
{
......@@ -280,7 +280,7 @@ namespace OnlineStore.DUOStore
if (btnAddMove.BackColor == Color.Green)
{
btnAddMove.BackColor = Color.White;
ACServerManager.SuddenStop(PortName, SlvAddr);
AxisManager.instance.SuddenStop(PortName, SlvAddr);
btnReadPosition_Click(null, null);
}
}
......@@ -309,7 +309,7 @@ namespace OnlineStore.DUOStore
if (btnDelMove.BackColor == Color.Green)
{
btnDelMove.BackColor = Color.White;
ACServerManager.SuddenStop(PortName, SlvAddr);
AxisManager.instance.SuddenStop(PortName, SlvAddr);
btnReadPosition_Click(null, null);
}
}
......
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public abstract class AxisManager
{
public bool IsShowMsg = false;
public static AxisManager instance;
public static bool UseHCBoard = true;
public static void Init()
{
// UseHCBoard = ConfigAppSettings.GetIntValue(Setting_Init.UseHCBoard).Equals(1);
if (UseHCBoard)
{
instance = new HCAxisManager();
}
else
{
//instance = new ACServerManager();
}
}
#region 485通信方法
public abstract bool OpenPort(string portName);
/// <summary>
/// 松下专用
/// </summary>
/// <param name="portName"></param>
public abstract void ColsePort(string portName);
/// <summary>
/// 松下专用
/// </summary>
public abstract void CloseAllPort();
/// <summary>
/// 松下专用
/// </summary>
public abstract void ClearSpeed();
/// <summary>
/// 松下专用
/// </summary>
/// <param name="portName"></param>
/// <param name="slvAddr"></param>
/// <param name="targetSpeed"></param>
/// <param name="addSpeed"></param>
/// <param name="delSpeed"></param>
public abstract void InitSlvAddr(string portName, short slvAddr, int targetSpeed, int addSpeed, int delSpeed);
public abstract bool IsServeoOn(string portName, short slvAddr);
#endregion
public abstract bool OpenCard();
public abstract bool CloseCard();
public abstract bool IsHomeMoveEnd(string portName, short slvAddr);
public abstract bool AbsMoveIsEnd(string portName, short axisNo, int targetPosition, int canErrorCount, out bool countError);
public abstract void ServoOn(string portName, short slvAddr);
public abstract void ServoOff(string portName, short slvAddr);
public abstract void RelMove(string portName, short slvAddr, int position, int targetSpeed , int ptpAcc , int ptpDec );
public abstract void HomeMove(string portName, short slvAddr, int highVel, int lowVel, int acc);
public abstract void SpeedMove(string portName, short slvAddr, int speed);
public abstract void SuddenStop(string portName, short slvAddr);
public abstract bool isInPosition(string portName, short slvAddr, int PPosition, int canErrorCount, bool isLog = false);
public abstract void AbsMove(string portName, short slvAddr, int targetPosition, int targetSpeed , int ptpAcc , int ptpDec );
public abstract void AlarmClear(string portName, short slvAddr);
public abstract int GetTargetPosition(string portName, short slvAddr);
public abstract int GetActualtPosition(string portName, short slvAddr);
public abstract int GetAlarmStatus(string portName, short slvAddr);
public abstract int GetBusyStatus(string portName, short slvAddr);
public abstract int GetHomeEndStatus(string portName, short slvAddr);
public abstract int GetHomeSingle(string portName, short slvAddr);
/// <summary>
/// 负极限
/// </summary>
public abstract int GetLimitNegativeSingle(string portName, short slvAddr);
/// <summary>
/// 正极限
/// </summary>
public abstract int GetLimitPositiveSingle(string portName, short slvAddr);
public abstract short GetErrorCode(string portName, short slvAddr);
}
}
using HuichuanLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class HCAxisManager : AxisManager
{
public override bool OpenCard()
{
return HCBoardManager.OpenCard();
}
public override bool CloseCard()
{
return HCBoardManager.CloseCard();
}
public override void AbsMove(string portName, short slvAddr, int targetPosition, int targetSpeed,int ptpAcc,int ptpDec)
{
HCBoardManager.AbsMove((short)slvAddr, targetPosition, targetSpeed, ptpAcc, ptpDec);
}
public override void AlarmClear(string portName, short slvAddr)
{
HCBoardManager.ClearAxisSts((short)slvAddr);
}
public override bool OpenPort(string portName)
{
return true;
}
public override void ClearSpeed()
{
}
public override void CloseAllPort()
{
}
public override void ColsePort(string portName)
{
}
public override void InitSlvAddr(string portName, short slvAddr, int targetSpeed, int addSpeed, int delSpeed)
{
}
public override int GetActualtPosition(string portName, short slvAddr)
{
return (int)HCBoardManager.GetAxisCurrPos(slvAddr);
}
public override int GetAlarmStatus(string portName, short slvAddr)
{
AxisSts axisS= HCBoardManager.GetAxisSts(slvAddr);
return axisS.ALM;
}
public override int GetBusyStatus(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.BUSY;
}
public override int GetHomeEndStatus(string portName, short slvAddr)
{
return (int) HCBoardManager.GetHomeStatus(slvAddr);
}
public override int GetHomeSingle(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.ALM;
}
public override int GetLimitNegativeSingle(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.NEL;
}
public override int GetLimitPositiveSingle(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.PEL;
}
public override int GetTargetPosition(string portName, short slvAddr)
{
return (int)HCBoardManager.GetAxisPrfPos(slvAddr);
}
public override void HomeMove(string portName, short slvAddr, int highVel, int lowVel, int acc)
{
HCBoardManager.StartHomeMove(slvAddr,(uint) highVel, (uint)lowVel, (uint)acc);
}
public override bool IsHomeMoveEnd(string portName, short slvAddr)
{
return HCBoardManager.HomeingIsEnd(slvAddr);
}
public override bool isInPosition(string portName, short slvAddr, int PPosition, int canErrorCount, bool isLog = false)
{
return HCBoardManager.IsInPosition(slvAddr, PPosition,canErrorCount );
}
public override void RelMove(string portName, short slvAddr, int position, int targetSpeed, int ptpAcc , int ptpDec )
{
HCBoardManager.RelMove(slvAddr, position, targetSpeed, ptpAcc, ptpDec);
}
public override bool IsServeoOn(string portName, short slvAddr)
{
AxisSts axisS = HCBoardManager.GetAxisSts(slvAddr);
return axisS.ServoOn.Equals(1);
}
public override void ServoOff(string portName, short slvAddr)
{
HCBoardManager.ServoOff(slvAddr);
}
public override void ServoOn(string portName, short slvAddr)
{
HCBoardManager.ServoOn(slvAddr);
}
public override void SpeedMove(string portName, short slvAddr, int speed)
{
HCBoardManager.SpeedMove(slvAddr, speed);
}
public override void SuddenStop(string portName, short slvAddr)
{
HCBoardManager.AxisStop(slvAddr);
}
public override bool AbsMoveIsEnd(string portName, short axisNo, int targetPosition, int canErrorCount, out bool countError)
{
countError = false;
bool isOk = HCBoardManager.MoveIsEnd(axisNo);
if (isOk)
{
if (HCBoardManager.IsInPosition(axisNo, targetPosition, canErrorCount))
{
return true;
}
else
{
countError = true;
}
}
return false;
}
public override short GetErrorCode(string portName, short slvAddr)
{
return HCBoardManager.GetAxErrCode(slvAddr);
}
}
}
......@@ -46,13 +46,12 @@
<Reference Include="CodeLibrary">
<HintPath>..\..\dll\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="DeviceLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\DeviceLib.dll</HintPath>
</Reference>
<Reference Include="halcondotnet">
<HintPath>..\..\dll\halcondotnet.dll</HintPath>
</Reference>
<Reference Include="HuichuanLibrary">
<HintPath>..\..\..\HuichuanLibrary\HuichuanLibrary\bin\Debug\HuichuanLibrary.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\log4net.dll</HintPath>
......@@ -68,6 +67,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AXIS\AxisManager.cs" />
<Compile Include="AXIS\HC\HCAxisManager.cs" />
<Compile Include="AXIS\PanasonicServo\ACCMDManager.cs" />
<Compile Include="AXIS\PanasonicServo\ACServerManager.cs" />
<Compile Include="AXIS\PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="device\IO\HCIOManager.cs" />
<Compile Include="duoStore\AxisBean.cs" />
<Compile Include="duoStore\BoxBean.cs" />
<Compile Include="duoStore\BoxBean_Partial.cs" />
......
......@@ -15,6 +15,9 @@ namespace OnlineStore.DeviceLibrary
{
public class AIOBOXManager : IOManager
{
//public static uint DefaultDICount = 16;
//public static uint DefaultDOCount = 16;
public Dictionary<string, AIOBOX> AIOMap = new Dictionary<string, AIOBOX>();
public Dictionary<string, List<Box_Sta>> DIValueMap = new Dictionary<string, List<Box_Sta>>();
......@@ -25,18 +28,19 @@ namespace OnlineStore.DeviceLibrary
private object DILock = "";
private object DOLock = "";
private List<string> IoIPLIst = new List<string>();
private System.Timers.Timer conTimer = null;
public override void ConnectionIOList(List<string> DIONameList)
{
foreach (string ip in DIONameList)
{
ConnectionIP(ip);
}
}
private bool isProcess = false;
private DateTime lastTime = DateTime.Now;
public void ConnectionIP(string ioIp)
{
AIOBOX aioBox = null;
......@@ -65,46 +69,80 @@ namespace OnlineStore.DeviceLibrary
{
DOValueMap.Remove(ioIp);
}
int DIMS = ConfigAppSettings.GetIntValue("DIMS");
if (DIMS <= 0)
{
DIMS = 150;
}
else if (DIMS < 20)
{
DIMS = 100;
}
int DOMS = ConfigAppSettings.GetIntValue("DOMS");
if (DOMS <= 0)
{
DOMS = 300;
}
else if (DOMS < 100)
{
DOMS = 300;
}
int DILength = StoreManager.Config.GetDILength(ioIp);
int DOLength = StoreManager.Config.GetDOLength(ioIp);
string logName = "IO模块[" + ioIp + "] DI[" + DILength + "] DO[" + DOLength + "] ";
string logName = "IO模块[" + ioIp + "] DI[" + DILength + "] DO[" + DOLength + "],[" + DIMS + "] [" + DOMS + "]";
try
{
aioBox = new AIOBOX("AIOBOX");
aioBox.SetType(Asa.IOModule.Box_Type.DI, DILength, Asa.IOModule.Box_Type.DO, DOLength);
// Create new modbus master and add event functions
aioBox = new AIOBOX();
aioBox.SetType(Box_Type.DI, DILength, Box_Type.DO, DOLength);
//aioBox.LogPath(Application.StartupPath + @"\logs\aio\", LogType.OnlyError);
aioBox.IP = ioIp;
aioBox.Upload = false;
// bool rtn = aioBox.AutoIP(ioIp);
// aioBox.SetInput(Asa.IOModule.Box_Type.DI, DILength);
// aioBox.SetOutput(Asa.IOModule.Box_Type.DO, DOLength);
//DI主动上传
// aioBox.AutoReadInput(true, DIMS);
// aioBox.AutoReadOutput(false, DOMS);
aioBox.DI_Changed_Event += AioBox_DI_Changed_Event; ;
aioBox.DO_Changed_Event += AioBox_DO_Changed_Event;
LogUtil.info("开始连接:" + logName + ":");
aioBox.Connect();
bool conRes = aioBox.Connect();
LogUtil.info("开始连接:" + logName + ":" + conRes.ToString());
AIOMap.Add(ioIp, aioBox);
Thread.Sleep(5);
//读取所有的DO
ReadAllDI(ioIp, 0);
Thread.Sleep(5);
GC.Collect();
}
catch (Exception error)
{
LogUtil.error("连接IO模块 " + logName + " 出错:" + error.ToString());
LogUtil.error( "连接IO模块 " + logName + " 出错:" + error.ToString());
}
}
private DateTime lastLogTime = DateTime.Now;
private void AioBox_Log_Out_Event(AIOBOX box, string[] s)
{
foreach (string str in s)
{
LogUtil.AIOLog.Debug("[" + box.IP + "]" + str);
}
}
private void AioBox_DI_Changed_Event(AIOBOX box, Box_Sta[] sta)
{
try
{
UpdateAllDI(box.IP, sta);
//LogUtil.info("ReadAllDI [" + box.IP + "]:" + string.Join(" ", sta));
}
catch (Exception ex)
{
......@@ -123,6 +161,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error("AioBox_DO_Changed_Event出错:" + ex.ToString());
}
}
private void UpdateAllDI(string ip, Box_Sta[] sta)
{
if (sta != null && sta.Length >= StoreManager.Config.GetDILength(ip))
......@@ -171,7 +210,12 @@ namespace OnlineStore.DeviceLibrary
newList.AddRange(sta);
List<Box_Sta> oldList = null;
DOValueMap.TryGetValue(ip, out oldList);
//string result = "UpdateAllDO ip[" + ip + "], sta :";
//for (int i = 0; i < newList.Count; i++)
//{
// result += newList[i] + ",";
//}
//LogUtil.info(result);
if (oldList == null || oldList.Count.Equals(newList.Count).Equals(false))
{
needUpdate = true;
......@@ -247,7 +291,7 @@ namespace OnlineStore.DeviceLibrary
}
else
{
LogUtil.error("WriteSingleDO出错 没有连接IO模块:" + ioIp);
LogUtil.error( "WriteSingleDO出错 没有连接IO模块:" + ioIp);
}
}
catch (Exception ex)
......@@ -272,11 +316,11 @@ namespace OnlineStore.DeviceLibrary
try
{
aioBox.WriteDO(StartAddress, aioBox.ReverseStatus(currBox_Sta));
LogUtil.debug("**********定时回写入 IO [" + ioIp + "] [" + StartAddress + "]值" + aioBox.ReverseStatus(currBox_Sta) + "】:");
LogUtil.debug( "**********定时回写入 IO [" + ioIp + "] [" + StartAddress + "]值" + aioBox.ReverseStatus(currBox_Sta) + "】:");
}
catch (Exception ex)
{
LogUtil.error("**********定时回写入 出错:" + ex.ToString());
LogUtil.error( "**********定时回写入 出错:" + ex.StackTrace);
}
};
mytimer.AutoReset = false;//设置是否自动重启,即自动执行多次;
......@@ -285,7 +329,7 @@ namespace OnlineStore.DeviceLibrary
}
else
{
LogUtil.error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错 没有连接IO模块:" + ioIp);
LogUtil.error( "AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错 没有连接IO模块:" + ioIp);
}
}
catch (Exception ex)
......@@ -328,7 +372,7 @@ namespace OnlineStore.DeviceLibrary
}
public override IO_VALUE GetDOValue(string ioIP, byte slaveId, ushort StartAddress)
{
IO_VALUE value = IO_VALUE.None;
IO_VALUE value = IO_VALUE.LOW;
try
{
AIOBOX aioBox = getAIO(ioIP);
......@@ -345,10 +389,6 @@ namespace OnlineStore.DeviceLibrary
{
value = IO_VALUE.HIGH;
}
else
{
value = IO_VALUE.LOW;
}
}
}
catch (Exception ex)
......@@ -360,7 +400,7 @@ namespace OnlineStore.DeviceLibrary
public override IO_VALUE GetDIValue(string ioIP, byte slaveId, ushort StartAddress)
{
IO_VALUE value = IO_VALUE.None;
IO_VALUE value = IO_VALUE.LOW;
for (int i = 1; i <= 3; i++)
{
try
......@@ -383,44 +423,32 @@ namespace OnlineStore.DeviceLibrary
{
value = IO_VALUE.HIGH;
}
else
{
value = IO_VALUE.LOW;
}
}
break;
}
catch (Exception ex)
{
if (i <= 1)
{
LogUtil.debug (" 第【" + i + "】次 GetDIValue [" + ioIP + "] [" + StartAddress + "] 出错:" + ex.ToString());
}
else
{
LogUtil.error(" 第【" + i + "】次 GetDIValue [" + ioIP + "] [" + StartAddress + "] 出错:" + ex.ToString());
}
LogUtil.error("GetDIValue [" + ioIP + "] [" + StartAddress + "] ["+i+"] 出错:" + ex.ToString());
}
}
return value;
}
public override IO_VALUE GetIOValue(ConfigIO configIO)
{
IO_VALUE value = IO_VALUE.None;
IO_VALUE value = IO_VALUE.LOW;
try
{
if (configIO.ProType.Equals(ConfigItemType.DI))
{
return GetDIValue(configIO.IO_IP, 0, configIO.GetIOAddr());
return GetDIValue(configIO.IO_IP, configIO.SlaveID, configIO.GetIOAddr());
}
else if (configIO.ProType.Equals(ConfigItemType.DO))
{
return GetDOValue(configIO.IO_IP, 0, configIO.GetIOAddr());
return GetDOValue(configIO.IO_IP, configIO.SlaveID, configIO.GetIOAddr());
}
}
catch (Exception ex)
{
LogUtil.error(" GetIOValue [" + configIO.IO_IP + "] [" + configIO.GetIOAddr() + "] 获取数据出错:", ex);
LogUtil.error( " GetIOValue [" + configIO.IO_IP + "] [" + configIO.GetIOAddr() + "] 获取数据出错:" + ex.ToString());
}
return value;
}
......@@ -448,4 +476,5 @@ namespace OnlineStore.DeviceLibrary
}
}
}
}
\ No newline at end of file
using HuichuanLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary.IO
{
public class HCIOManager : IOManager
{
public override void CloseAllConnection()
{
}
public override void CloseAllDO()
{
HCBoardManager.CloseAllDO();
}
public override void ConnectionIOList(List<string> dIODeviceNameList)
{
if (dIODeviceNameList.Count > 0 && dIODeviceNameList.Contains("HC"))
{
if (!HCBoardManager.CardInitOk())
{
HCBoardManager.OpenCard();
}
}
}
public override IO_VALUE GetDIValue(string deviceName, byte slaveID, ushort index)
{
short v = HCBoardManager.GetBitDI((short)index);
return (IO_VALUE)v;
}
public override IO_VALUE GetDOValue(string deviceName, byte slaveID, ushort index)
{
short v = HCBoardManager.GetBitDO((short)index);
return (IO_VALUE)v;
}
public override IO_VALUE GetIOValue(ConfigIO configIO)
{
short index =(short) configIO.GetIOAddr();
short v = HCBoardManager.GetBitDO(index);
return (IO_VALUE)v;
}
public override void ReadAllDI(string deviceName, byte slaveId)
{
}
public override void ReadAllDO(string deviceName, byte slaveId)
{
}
public override void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value, int time)
{
try
{
short v = (short)value;
HCBoardManager.SetBitDO((short)index, v);
short targetV = 0;
if (v.Equals((short)0))
{
targetV = 1;
}
//写入之后,等待指定间隔后回写
System.Timers.Timer mytimer = new System.Timers.Timer(time);
mytimer.Elapsed += (o1, e1) =>
{
try
{
HCBoardManager.SetBitDO((short)index, targetV);
}
catch (Exception ex)
{
LogUtil.error("**********定时回写入 出错:" + ex.StackTrace);
}
};
mytimer.AutoReset = false;
mytimer.Enabled = true;
}
catch (Exception ex)
{
LogUtil.error("AIO WriteSingleDO [" + index + "] 出错:" + ex.ToString());
}
}
public override void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value)
{
short v = (short)value;
HCBoardManager.SetBitDO((short)index, v);
}
}
}
using OnlineStore.Common;
using OnlineStore.DeviceLibrary.IO;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
......@@ -18,11 +19,15 @@ namespace OnlineStore.DeviceLibrary
#region KNDIO
public static void IOMove(string ioType, IO_VALUE ioValue, int subType)
{
if (string.IsNullOrEmpty(ioType))
{
return;
}
ConfigIO configIo = GetDO(ioType, subType);
if (configIo != null)
{
instance.WriteSingleDO(configIo.IO_IP, 0, configIo.GetIOAddr(), ioValue);
Thread.Sleep(1);
instance.WriteSingleDO(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr(), ioValue);
Thread.Sleep(10);
}
else
{
......@@ -32,7 +37,11 @@ namespace OnlineStore.DeviceLibrary
public static IO_VALUE IOValue(string ioType, int subType)
{
IO_VALUE ioValue = IO_VALUE.LOW;
if (string.IsNullOrEmpty(ioType))
{
return IO_VALUE.None;
}
IO_VALUE ioValue = IO_VALUE.None;
ConfigIO configIo = GetDI(ioType, subType);
if (configIo == null)
{
......@@ -43,12 +52,11 @@ namespace OnlineStore.DeviceLibrary
{
if (configIo.ProType.Equals(ConfigItemType.DI))
{
ioValue = instance.GetDIValue(configIo.IO_IP, 0, configIo.GetIOAddr());
ioValue = instance.GetDIValue(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr());
}
else
{
ioValue = instance.GetDOValue(configIo.IO_IP, 0, configIo.GetIOAddr());
ioValue = instance.GetDOValue(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr());
}
}
else
......@@ -57,14 +65,18 @@ namespace OnlineStore.DeviceLibrary
}
return ioValue;
}
public static IO_VALUE DOValue(string ioType, int subType = 0)
public static IO_VALUE DOValue(string ioType, int subType)
{
IO_VALUE ioValue = IO_VALUE.LOW;
if (string.IsNullOrEmpty(ioType))
{
return IO_VALUE.None;
}
IO_VALUE ioValue = IO_VALUE.None;
ConfigIO configIo = GetDO(ioType, subType);
if (configIo != null)
{
ioValue = instance.GetDOValue(configIo.IO_IP, 0, configIo.GetIOAddr());
ioValue = instance.GetDOValue(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr());
}
else
{
......@@ -72,7 +84,34 @@ namespace OnlineStore.DeviceLibrary
}
return ioValue;
}
private static ConfigIO GetDI(string ioType, int subType)
public static IO_VALUE DIValue(string ioType, int subType)
{
if (string.IsNullOrEmpty(ioType))
{
return IO_VALUE.None;
}
IO_VALUE ioValue = IO_VALUE.None;
ConfigIO configIo = GetDI(ioType, subType);
if (configIo != null)
{
ioValue = instance.GetDIValue(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr());
}
else
{
LogUtil.error("未找到 DI [" + ioType + "][" + subType + "]");
}
return ioValue;
}
internal static ConfigIO GetIO(string ioType, int subType)
{
ConfigIO configIo = GetDI(ioType, subType);
if (configIo == null)
{
configIo = GetDO(ioType, subType);
}
return configIo;
}
internal static ConfigIO GetDI(string ioType, int subType)
{
ConfigIO configIo = null;
if (subType <= 0)
......@@ -84,19 +123,25 @@ namespace OnlineStore.DeviceLibrary
}
else
{
if (StoreManager.AllConfigMap.ContainsKey(subType))
if (StoreManager.allConfigMap.ContainsKey(subType))
{
string newType = ioType.Replace("SW1_", "SW_").Replace("SW2_", "SW_").Replace("SW3_", "SW_").Replace("SW4_", "SW_");
if (StoreManager.AllConfigMap[subType].DIList.ContainsKey(newType))
if (StoreManager.allConfigMap[subType].DIList.ContainsKey(ioType))
{
return StoreManager.AllConfigMap[subType].DIList[newType];
return StoreManager.allConfigMap[subType].DIList[ioType];
}
}
}
if (configIo == null && subType > 0)
{
if (StoreManager.Config.DIList.ContainsKey(ioType))
{
return StoreManager.Config.DIList[ioType];
}
}
return configIo;
}
private static ConfigIO GetDO(string ioType, int subType)
internal static ConfigIO GetDO(string ioType, int subType)
{
ConfigIO configIo = null;
if (subType <= 0)
......@@ -108,48 +153,44 @@ namespace OnlineStore.DeviceLibrary
}
else
{
if (StoreManager.AllConfigMap.ContainsKey(subType))
if (StoreManager.allConfigMap.ContainsKey(subType))
{
string newType = ioType.Replace("SW1_", "SW_").Replace("SW2_", "SW_").Replace("SW3_", "SW_").Replace("SW4_", "SW_");
if (StoreManager.AllConfigMap[subType].DOList.ContainsKey(newType))
if (StoreManager.allConfigMap[subType].DOList.ContainsKey(ioType))
{
return StoreManager.AllConfigMap[subType].DOList[newType];
return StoreManager.allConfigMap[subType].DOList[ioType];
}
}
}
return configIo;
}
public static void CloseDeviceDO(List<ConfigIO> DoList)
{
foreach (ConfigIO io in DoList)
if (configIo == null && subType > 0)
{
instance.WriteSingleDO(io.IO_IP, 0, io.GetIOAddr(), IO_VALUE.LOW);
Thread.Sleep(60);
if (StoreManager.Config.DOList.ContainsKey(ioType))
{
return StoreManager.Config.DOList[ioType];
}
}
return configIo;
}
public static void CloseDeviceDO(int subType)
#endregion
public static void Init()
{
List<ConfigIO> DoList = new List<ConfigIO>();
if (subType <= 0)
bool UseHCBoard = true;// ConfigAppSettings.GetIntValue(Setting_Init.UseHCBoard).Equals(1);
if (UseHCBoard)
{
DoList = new List<ConfigIO>(StoreManager.Config.DOList.Values);
instance = new HCIOManager();
}
else
{
if (StoreManager.AllConfigMap.ContainsKey(subType))
bool isAIOBox = ConfigAppSettings.GetIntValue(Setting_Init.UseAIOBOX).Equals(1); if (isAIOBox)
{
DoList = new List<ConfigIO>(StoreManager.AllConfigMap[subType].DOList.Values);
instance = new AIOBOXManager();
}
//else
//{
// instance = new KNDManager();
//}
}
CloseDeviceDO(DoList);
}
#endregion
public static void Init()
{
instance = new AIOBOXManager();
}
public abstract void ReadAllDI(string deviceName, byte slaveId);
public abstract void ReadAllDI(string deviceName, byte slaveId);
public abstract void ReadAllDO(string deviceName, byte slaveId);
......@@ -158,11 +199,11 @@ namespace OnlineStore.DeviceLibrary
public abstract void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value);
public abstract IO_VALUE GetDIValue(string deviceName, byte slaveID, ushort v);
public abstract IO_VALUE GetDIValue(string deviceName, byte slaveID, ushort index);
public abstract IO_VALUE GetDOValue(string deviceName, byte slaveID, ushort v);
public abstract IO_VALUE GetDOValue(string deviceName, byte slaveID, ushort index);
public abstract IO_VALUE GetIOValue(ConfigIO configIO);
......

using Asa;
using DeviceLib;
using Asa;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
......@@ -224,7 +222,7 @@ namespace OnlineStore.DeviceLibrary
case StoreMoveStep.BOX_H02_InoutToP1:
//如果此时轴三还在报警,需要提示错误并等待
if (ACServerManager.GetAlarmStatus(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()) > 0)
if (AxisManager.instance.GetAlarmStatus(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()) > 0)
{
LogUtil.error(Name + MoveInfo.MoveType + "复位失败: " + Config.InOut_Axis.Explain + "报警");
WarnMsg = Name + "复位失败: " + Config.InOut_Axis.Explain + "报警";
......@@ -370,10 +368,10 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.EndMove();
IOMove(IO_Type.UpdownAxis_Break, IO_VALUE.LOW);
//运动版停止
MiddleAxis.SuddenStop(true);
UpdownAxis.SuddenStop(true);
InoutAxis.SuddenStop(true);
ComAxis.SuddenStop(true);
MiddleAxis.SuddenStop();
UpdownAxis.SuddenStop();
InoutAxis.SuddenStop();
ComAxis.SuddenStop();
CloseAllAxis();
LogInfo("StopMove");
isInPro = false;
......
using Asa;
using DeviceLib;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
......@@ -20,7 +19,7 @@ namespace OnlineStore.DeviceLibrary
#region 出入库结果验证
private bool AcInPosition(ConfigMoveAxis axis, int p)
{
return ACServerManager.isInPosition(axis.DeviceName, axis.GetAxisValue(), p, axis.CanErrorCountMax);
return AxisManager.instance.isInPosition(axis.DeviceName, axis.GetAxisValue(), p, axis.CanErrorCountMax);
}
private static DateTime lastComRHomeTime = DateTime.Now;
......
......@@ -294,7 +294,6 @@ namespace OnlineStore.DeviceLibrary
}
}
}
public override void StopMove()
{
foreach (BoxBean equip in this.BoxMap.Values)
......@@ -304,16 +303,14 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.EndMove();
hoisterCylinder.Stop();
//轴运动停止
T3_UpdownAxis.SuddenStop(true);
T2_MiddleAxis.SuddenStop(true);
T1_BatchAxis.SuddenStop(true);
T3_UpdownAxis.SuddenStop();
T2_MiddleAxis.SuddenStop();
T1_BatchAxis.SuddenStop();
CloseAllAxis();
LineStop();
}
public override void StopRun()
{
mainTimer.Enabled = false;
......@@ -323,7 +320,7 @@ namespace OnlineStore.DeviceLibrary
foreach (BoxBean equip in BoxMap.Values)
{
equip.StopRun();
}
}
runStatus = StoreRunStatus.Wait;
// RFIDManager.Close();
TimeSpan span = DateTime.Now - StartTime;
......@@ -657,7 +654,6 @@ namespace OnlineStore.DeviceLibrary
public bool OpenAllAxis(bool isCheck = true)
{
if (RunMultiAxis(isCheck, IO_Type.MoveAxis_Run, IO_Type.MoveAxis_Break, new AxisBean []{ T3_UpdownAxis,T2_MiddleAxis}))
{
if (RunAxis(isCheck, T1_BatchAxis) )
......
using DeviceLib;
using OnlineStore.Common;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
......@@ -48,7 +47,7 @@ namespace OnlineStore.DeviceLibrary
{
LogUtil.debug(Name + "CheckWaitResult 检测到" + T1_BatchAxis.TargetIoType + "=" + T1_BatchAxis.TargetIoValue + ",停止运行");
T1_BatchAxis.StopAxisCheckMove();
if (ACServerManager.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(1))
if (AxisManager.instance.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(1))
{
T1_BatchAxis.SuddenStop();
}
......@@ -56,7 +55,7 @@ namespace OnlineStore.DeviceLibrary
}
else
{
bool isOk = ACServerManager.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(0);
bool isOk = AxisManager.instance.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(0);
if (isOk)
{
//TODO 判断是否达到高度,如果未达到,继续上升
......
using DeviceLib;
using OnlineStore.Common;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
......@@ -147,7 +146,7 @@ namespace OnlineStore.DeviceLibrary
{
short axis = axisInfo.Config.GetAxisValue();
string deviceName = axisInfo.Config.GetNameStr();
int value = ACServerManager.GetAlarmStatus(deviceName, axis);
int value = AxisManager.instance.GetAlarmStatus(deviceName, axis);
//if (value.Equals(-1))
//{
// value = ACServerManager.GetAlarmStatus(deviceName, axis);
......
using DeviceLib;
using log4net;
using log4net;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
......@@ -18,7 +17,7 @@ namespace OnlineStore.DeviceLibrary
public static DUOStoreBean Store = null;
public static Store_Config Config = null;
public static Dictionary<int, BaseConfig> AllConfigMap = null;
public static Dictionary<int, BaseConfig> allConfigMap = null;
private static bool isInit = false;
public static bool IsConnectServer = !ConfigAppSettings.GetValue(Setting_Init.http_server).Equals("");
public StoreManager()
......@@ -48,7 +47,7 @@ namespace OnlineStore.DeviceLibrary
{
try
{
AllConfigMap = new Dictionary<int, BaseConfig>();
allConfigMap = new Dictionary<int, BaseConfig>();
BaseConfig.ProIOIpMap = new Dictionary<string, string>();
if (!isInit)
{
......@@ -77,7 +76,7 @@ namespace OnlineStore.DeviceLibrary
string linefilePath = appPath + ConfigAppSettings.GetValue(Setting_Init.Store_ConfigPath);
Config = CSVConfigReader.LoadLineConfig(0, CID, "Line", linefilePath);
AllConfigMap.Add(0, Config);
allConfigMap.Add(0, Config);
string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.BOX_ConfigPath);
for (int i = 1; i <= count; i++)
......@@ -88,7 +87,7 @@ namespace OnlineStore.DeviceLibrary
string boxCid = ConfigAppSettings.GetValue(storeIdConfig);
BOX_Config moveConfig = CSVConfigReader.LoadBoxConfig(i, boxCid, "BOX", config);
moveConfig.SetIO(i);
AllConfigMap.Add(i, moveConfig);
allConfigMap.Add(i, moveConfig);
storeConfig.Add(i, moveConfig);
}
string positionConfigFile = appPath + ConfigAppSettings.GetValue(Setting_Init.Store_Position_Config);
......@@ -108,7 +107,6 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info("加载料仓完成!");
}
ACServerManager.LogEvent += ACServerManager_LogEvent;
Store = new DUOStoreBean(Config, storeConfig);
}
}
......@@ -137,7 +135,7 @@ namespace OnlineStore.DeviceLibrary
{
LogUtil.error("保存配置文件失败:" + configFile);
}
AllConfigMap[storeConfig.Id] = storeConfig;
allConfigMap[storeConfig.Id] = storeConfig;
Store.BoxConfigMap[storeConfig.Id] = storeConfig;
Store.BoxMap[storeConfig.Id].Config = storeConfig;
Store.BoxMap[storeConfig.Id].MoveAxisConfig();
......@@ -176,21 +174,7 @@ namespace OnlineStore.DeviceLibrary
}
return false;
}
private static void ACServerManager_LogEvent(InfoType type, string msg)
{
if (type.Equals(InfoType.Error))
{
LogUtil.error(msg);
}
else if (type.Equals(InfoType.Info))
{
LogUtil.info(msg);
}
else
{
LogUtil.debug(msg);
}
}
#endregion
#region 位置加载
......
using DeviceLib;
using log4net;
using log4net;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
......@@ -458,7 +457,7 @@ namespace OnlineStore.DeviceLibrary
#region 多个伺服运动
public bool RunMultiAxis(bool isCheck, string serverOnDO, string breakOnDO, params AxisBean[] axisArray)
public bool RunMultiAxis(bool isCheck, params AxisBean[] axisArray)
{
IOManager.IOMove(serverOnDO, IO_VALUE.HIGH, baseConfig.Id);
string msg = "";
......@@ -474,18 +473,18 @@ namespace OnlineStore.DeviceLibrary
}
Thread.Sleep(500);
//打开所有轴
if (isCheck)
{
foreach (AxisBean axis in axisArray)
{
if (!axis.AxisIsOpen(out msg))
{
SetWarnMsg(Name + msg);
Alarm(AlarmType.AxisAlarm);
return false;
}
}
}
//if (isCheck)
//{
// foreach (AxisBean axis in axisArray)
// {
// if (!axis.OpenAxis(out msg))
// {
// SetWarnMsg(Name + msg);
// Alarm(AlarmType.AxisAlarm);
// return false;
// }
// }
//}
IOManager.IOMove(breakOnDO, IO_VALUE.HIGH, baseConfig.Id);
return true;
}
......
......@@ -51,6 +51,7 @@ namespace OnlineStore.LoadCSVLibrary
throw new CVSFieldNotMatchingExection(ConfigStr + ",【类型:" + ProType + "】【名称:" + ProName + "】【属性值:" + ProValue + "】必须配置值!");
}
}
public byte SlaveID = 0;
}
/// <summary>
/// 运动轴配置
......
......@@ -36,7 +36,7 @@ namespace OnlineStore.LoadCSVLibrary
/// <summary>
/// DI,0,启动,AutoRun_BTN,2,PRO_AOI_IP_1,X03,
/// </summary>
public static string AutoRun_BTN = "AutoRun_BTN";
//public static string AutoRun_BTN = "AutoRun_BTN";
/// <summary>
/// DI,0,气压检测,Airpressure_Check,3,PRO_AOI_IP_1,X04,
/// </summary>
......@@ -126,22 +126,22 @@ namespace OnlineStore.LoadCSVLibrary
/// <summary>
/// DO,1,左侧料仓升降轴刹车ON,UpdownAxis_Break,11,PRO_AOI_IP_1,Y12,
/// </summary>
public static string UpdownAxis_Break = "UpdownAxis_Break";
//public static string UpdownAxis_Break = "UpdownAxis_Break";
/// <summary>
/// DO,0,提升机构升降轴刹车ON,BatchAxis_Break,13,PRO_AOI_IP_1,Y14,
/// </summary>
public static string BatchAxis_Break = "BatchAxis_Break";
//public static string BatchAxis_Break = "BatchAxis_Break";
/// <summary>
/// DO,0,移栽机构上下轴刹车ON,MoveAxis_Break,14,PRO_AOI_IP_1,Y15,
/// </summary>
public static string MoveAxis_Break = "MoveAxis_Break";
//public static string MoveAxis_Break = "MoveAxis_Break";
/// <summary>
/// DO,1,左侧料仓伺服ON,Axis_Run,15,PRO_AOI_IP_1,Y16,
/// </summary>
public static string Axis_Run = "Axis_Run";
//public static string Axis_Run = "Axis_Run";
/// <summary>
......@@ -213,19 +213,19 @@ namespace OnlineStore.LoadCSVLibrary
/// <summary>
/// DI,0,取料气缸料盘检测,ClampCylinder_Check,0,PRO_AOI_IP_3,X41,
/// </summary>
public static string ClampCylinder_Check = "ClampCylinder_Check";
//public static string ClampCylinder_Check = "ClampCylinder_Check";
/// <summary>
/// DI,0,线体出口放行信号,LineOut_BTN,1,PRO_AOI_IP_3,X42,
/// </summary>
public static string LineOut_BTN = "LineOut_BTN";
// public static string LineOut_BTN = "LineOut_BTN";
/// <summary>
/// DO,0,线体入口指示灯,LineIn_Led,0,PRO_AOI_IP_3,Y41,
/// </summary>
public static string LineIn_Led = "LineIn_Led";
//public static string LineIn_Led = "LineIn_Led";
/// <summary>
/// DO,0,线体出口指示灯,LineOut_Led,1,PRO_AOI_IP_3,Y42,
/// </summary>
public static string LineOut_Led = "LineOut_Led";
//public static string LineOut_Led = "LineOut_Led";
/// <summary>
/// DO,0,设备内部照明ON,Device_Led,2,PRO_AOI_IP_3,Y43,
/// </summary>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!