Commit 1454cbb8 LN

1

1 个父辈 8ef2449f
......@@ -48,6 +48,8 @@
<!--是否打开托盘编码界面-->
<add key ="OpenRFIDWrite" value ="1"/>
<add key="DefaultPWD" value ="123456"/>
<!--当前调试的设备ID,分号分割-->
<add key ="DebugDeviceId" value ="103"/>
</appSettings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
......
......@@ -788,7 +788,7 @@
this.tabPage2.Location = new System.Drawing.Point(4, 26);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(1365, 645);
this.tabPage2.Size = new System.Drawing.Size(1319, 657);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = " 伺服信息 ";
this.tabPage2.UseVisualStyleBackColor = true;
......@@ -804,7 +804,7 @@
this.groupBox9.Controls.Add(this.txtBP2);
this.groupBox9.Location = new System.Drawing.Point(22, 516);
this.groupBox9.Name = "groupBox9";
this.groupBox9.Size = new System.Drawing.Size(644, 150);
this.groupBox9.Size = new System.Drawing.Size(836, 150);
this.groupBox9.TabIndex = 220;
this.groupBox9.TabStop = false;
this.groupBox9.Text = "上料轴位置配置";
......@@ -916,7 +916,7 @@
//
this.axisMoveControl1.Location = new System.Drawing.Point(10, 5);
this.axisMoveControl1.Name = "axisMoveControl1";
this.axisMoveControl1.Size = new System.Drawing.Size(678, 353);
this.axisMoveControl1.Size = new System.Drawing.Size(858, 349);
this.axisMoveControl1.TabIndex = 219;
//
// groupBox2
......@@ -930,7 +930,7 @@
this.groupBox2.Controls.Add(this.txtSizePosition);
this.groupBox2.Location = new System.Drawing.Point(22, 360);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(644, 147);
this.groupBox2.Size = new System.Drawing.Size(836, 147);
this.groupBox2.TabIndex = 218;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "升降轴位置配置";
......
......@@ -375,7 +375,7 @@ namespace OnlineStore.AssemblyLine
}
private void btnTrayLocationCylinder_Click(object sender, EventArgs e)
{
BtnMove(btnTrayLocationCylinder, "SL升降盘定位气缸前进", "SL升降盘定位气缸后退", IO_Type.SL_TrayLocation_Before, IO_Type.SL_TrayLocation_After);
BtnMove(btnTrayLocationCylinder, "SL升降盘定位气缸前进", "SL升降盘定位气缸后退", IO_Type.SL_TrayLocation_After, IO_Type.SL_TrayLocation_Before);
}
private void btnToroid_TopCylinder_Click(object sender, EventArgs e)
{
......
......@@ -52,6 +52,7 @@
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.lblMoveInfo = new System.Windows.Forms.Label();
this.lblTrayNum = new System.Windows.Forms.Label();
this.lblInstoreList = new System.Windows.Forms.Label();
this.tabPage2 = new System.Windows.Forms.TabPage();
......@@ -68,7 +69,6 @@
this.txtP2 = new System.Windows.Forms.TextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.lblName = new System.Windows.Forms.Label();
this.lblMoveInfo = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox3.SuspendLayout();
......@@ -537,6 +537,17 @@
this.groupBox6.TabStop = false;
this.groupBox6.Text = "消息";
//
// lblMoveInfo
//
this.lblMoveInfo.AutoSize = true;
this.lblMoveInfo.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblMoveInfo.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.lblMoveInfo.Location = new System.Drawing.Point(13, 29);
this.lblMoveInfo.Name = "lblMoveInfo";
this.lblMoveInfo.Size = new System.Drawing.Size(68, 17);
this.lblMoveInfo.TabIndex = 280;
this.lblMoveInfo.Text = "运动信息:";
//
// lblTrayNum
//
this.lblTrayNum.AutoSize = true;
......@@ -574,7 +585,7 @@
//
this.axisMoveControl1.Location = new System.Drawing.Point(10, 7);
this.axisMoveControl1.Name = "axisMoveControl1";
this.axisMoveControl1.Size = new System.Drawing.Size(678, 388);
this.axisMoveControl1.Size = new System.Drawing.Size(835, 344);
this.axisMoveControl1.TabIndex = 219;
//
// groupBox2
......@@ -588,9 +599,9 @@
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.btnP2);
this.groupBox2.Controls.Add(this.txtP2);
this.groupBox2.Location = new System.Drawing.Point(19, 396);
this.groupBox2.Location = new System.Drawing.Point(19, 369);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(646, 204);
this.groupBox2.Size = new System.Drawing.Size(815, 204);
this.groupBox2.TabIndex = 218;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "升降轴位置配置";
......@@ -749,17 +760,6 @@
this.lblName.Text = "出料流水线";
this.lblName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblMoveInfo
//
this.lblMoveInfo.AutoSize = true;
this.lblMoveInfo.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblMoveInfo.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.lblMoveInfo.Location = new System.Drawing.Point(13, 29);
this.lblMoveInfo.Name = "lblMoveInfo";
this.lblMoveInfo.Size = new System.Drawing.Size(68, 17);
this.lblMoveInfo.TabIndex = 280;
this.lblMoveInfo.Text = "运动信息:";
//
// FrmMoveEquip
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
......
......@@ -76,15 +76,25 @@ namespace OnlineStore.AssemblyLine
private void btnAxisVMove_Click(object sender, EventArgs e)
{
int speed = FormUtil.GetIntValue(txtASpeed);
int speed = FormUtil.GetIntValue(txtASpeed);
LogUtil.info("点击【匀速运动】,【" + PortName + "_" + SlvAddr + "】 速度【" + speed + "】");
ACServerManager.SpeedMove(PortName, SlvAddr, speed);
}
private void btnAxisStop_Click(object sender, EventArgs e)
{
LogUtil.info("点击【停止运动】,【" + PortName + "_" + SlvAddr + "】 ");
ACServerManager.SuddenStop(PortName, SlvAddr);
if (btnAddMove.BackColor == Color.Green)
{
btnAddMove.BackColor = System.Drawing.SystemColors.Control;
}
if (btnDelMove.BackColor == Color.Green)
{
btnDelMove.BackColor = System.Drawing.SystemColors.Control;
}
btnReadPosition_Click(null, null);
}
private void btnComAlarmClear_Click(object sender, EventArgs e)
......@@ -131,11 +141,15 @@ namespace OnlineStore.AssemblyLine
txtAxisValue.Text = SlvAddr.ToString();
Color color = Color.Black;
if (comboBox1.SelectedIndex.Equals(0))
{
{
btnAddMove.Text = "点动+(下降)";
btnDelMove.Text = "点动-(上升)";
color = Color.Blue;
}
else if (comboBox1.SelectedIndex.Equals(1))
{
btnAddMove.Text = "点动+(上升)";
btnDelMove.Text = "点动-(下降)";
color = Color.Red;
}
btnOpenAxis.ForeColor = color;
......@@ -148,6 +162,8 @@ namespace OnlineStore.AssemblyLine
btnComAlarmClear.ForeColor = color;
btnReadPosition.ForeColor = color;
btnGetAlarm.ForeColor = color;
btnAddMove.ForeColor = color;
btnDelMove.ForeColor = color;
this.txtAlarmStatus.Text = "";
this.txtBusyStatus.Text = "";
......@@ -158,7 +174,59 @@ namespace OnlineStore.AssemblyLine
txtServoStatue.Text = "";
}
}
private void AxisMove( int speed)
{
LogUtil.info("【" + PortName + "_" + SlvAddr + "】点动: 速度:" + speed);
ACServerManager.SpeedMove(PortName, SlvAddr, speed);
}
private void btnAddMove_MouseDown(object sender, MouseEventArgs e)
{
if (btnAddMove.BackColor.Equals(System.Drawing.SystemColors.Control))
{
int speed = FormUtil.GetIntValue(txtMiddleSpeed);
if (speed <= 0)
{
MessageBox.Show("提示", "请先输入正确的速度");
return;
}
btnAddMove.BackColor = Color.Green;
AxisMove( speed);
}
}
private void btnAddMove_MouseUp(object sender, MouseEventArgs e)
{
if (btnAddMove.BackColor == Color.Green )
{
btnAddMove.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(PortName, SlvAddr);
btnReadPosition_Click(null, null);
}
}
private void btnDelMove_MouseDown(object sender, MouseEventArgs e)
{
if (btnDelMove.BackColor.Equals(System.Drawing.SystemColors.Control))
{
int speed = FormUtil.GetIntValue(txtMiddleSpeed);
if (speed <= 0)
{
MessageBox.Show("提示", "请先输入正确的速度");
return;
}
btnDelMove.BackColor = Color.Green;
AxisMove(-speed);
}
}
private void btnDelMove_MouseUp(object sender, MouseEventArgs e)
{
if ( btnDelMove.BackColor == Color.Green)
{
btnDelMove.BackColor = System.Drawing.SystemColors.Control;
ACServerManager.SuddenStop(PortName, SlvAddr);
btnReadPosition_Click(null, null);
}
}
}
}
......@@ -77,5 +77,7 @@ namespace OnlineStore.Common
public static string OpenRFIDWrite = "OpenRFIDWrite";
public static string DefaultPWD = "DefaultPWD";
public static string AgvServerIp = "AgvServerIp";
public static string DebugDeviceId = "DebugDeviceId";
}
}
......@@ -149,6 +149,11 @@ namespace OnlineStore.Common
}
}
public static string GetValue(object debugDeviceId)
{
throw new NotImplementedException();
}
/// <summary>
/// 更新配置文件信息
/// </summary>
......@@ -170,16 +175,7 @@ namespace OnlineStore.Common
LogUtil.error(LOGGER, "UpdateConfig保存配置出错:name=" + name + ",Xvalue=" + Xvalue + "," + ex.StackTrace);
}
}
public static int GetIntValue(object line_dischargeLine_count)
{
throw new NotImplementedException();
}
public static string GetValue(object configPath_DischargeLine)
{
throw new NotImplementedException();
}
///<summary>
///向.config文件的appKey结写入信息AppValue 保存设置
......
......@@ -117,14 +117,41 @@ namespace OnlineStore.DeviceLibrary
CodeManager.LoadConfig();
string ids = ConfigAppSettings.GetValue(Setting_Init.DebugDeviceId);
if (IsDebug)
{
List<int> testDeviceIdList = new List<int>() { 103, 104 };
ioList = new List<string>();
foreach (int id in testDeviceIdList)
try
{
FeedingEquip feed = FeedingEquipMap[103];
ioList.AddRange(feed.Config.IOIPList);
string[] testDeviceIdList = ids.Split(',');
ioList = new List<string>();
foreach (string str in testDeviceIdList)
{
int id = Convert.ToInt32(str);
if (FeedingEquipMap.ContainsKey(id))
{
FeedingEquip feed = FeedingEquipMap[id];
ioList.AddRange(feed.Config.IOIPList);
}
else if (ProvidingEquipMap.ContainsKey(id))
{
ProvidingEquip feed = ProvidingEquipMap[id];
ioList.AddRange(feed.Config.IOIPList);
}
else if (DisLineMap.ContainsKey(id))
{
DischargeLine feed = DisLineMap[id];
ioList.AddRange(feed.Config.IOIPList);
}
else if (MoveEquipMap.ContainsKey(id))
{
MoveEquip equip = MoveEquipMap[id];
ioList.AddRange(equip.Config.IOIPList);
}
}
}
catch (Exception ex)
{
LogUtil.error(Name + "加载调试设备出错:" + ex.ToString());
}
}
......@@ -136,8 +163,8 @@ namespace OnlineStore.DeviceLibrary
{
Task.Factory.StartNew(delegate
{
//连接rfip
RFIDManager.ConnectRFIOList(new List<string>(DeviceConfig.ProRFIpMap.Values));
//连接rfip
RFIDManager.ConnectRFIOList(new List<string>(DeviceConfig.ProRFIpMap.Values));
});
}
addLastDI(IO_Type.Airpressure_Check, IOValue(IO_Type.Airpressure_Check));
......
......@@ -15,8 +15,8 @@ namespace OnlineStore.DeviceLibrary
public partial class ACServerManager
{
public static bool IsShowMsg = false ;
private static int SleepMSendons = 20;
private static int ReviceOutTimeMS = 100;
private static int SleepMSendons = 50;
private static int ReviceOutTimeMS = 200;
private static Dictionary<string, Dictionary<string, int>> ComAddrValue = new Dictionary<string, Dictionary<string, int>>();
private static string mapObj = "";
......@@ -177,33 +177,33 @@ namespace OnlineStore.DeviceLibrary
{
LogUtil.info("开始初始化伺服【" + portName + "】【" + slvAddr + "】");
//写入block
int sleep = 20;
int sleep = 50;
string slvAddrStr = string.Format(strFromat, slvAddr);
//block0=原点返回,正方向
string str0 = slvAddrStr + "104800 000408 00000420 00000000 ffff";
SendStrAndSleep(portName, str0, sleep);
//block1=原点返回,反方向
string str1 = slvAddrStr + "104804 000408 04000420 00000000 ffff";
SendStrAndSleep(portName, str1, sleep);
//block2=绝对位置运动
string str2 = slvAddrStr + "104808 000408 10000211EC78FFFF ffff";
SendStrAndSleep(portName, str2, sleep);
//block3=相对位置运动
string str3 = slvAddrStr + "10480C 000408 10000111EC78FFFF ffff";
SendStrAndSleep(portName, str3, sleep);
//block4=正方向匀速运动
string str4 = slvAddrStr + "104810 000408 10000311 00000000 ffff";
SendStrAndSleep(portName, str4, sleep);
//block5=反方向匀速运动
string str5 = slvAddrStr + "104814 000408 14000311 00000000 ffff";
SendStrAndSleep(portName, str5, sleep);
//block6=减速停止
string str6 = slvAddrStr + "104818 000408 00000500 00000000 ffff";
SendStrAndSleep(portName, str6, sleep);
////block0=原点返回,正方向
//string str0 = slvAddrStr + "104800 000408 00000420 00000000 ffff";
//SendStrAndSleep(portName, str0, sleep);
////block1=原点返回,反方向
//string str1 = slvAddrStr + "104804 000408 04000420 00000000 ffff";
//SendStrAndSleep(portName, str1, sleep);
////block2=绝对位置运动
//string str2 = slvAddrStr + "104808 000408 10000211EC78FFFF ffff";
//SendStrAndSleep(portName, str2, sleep);
////block3=相对位置运动
//string str3 = slvAddrStr + "10480C 000408 10000111EC78FFFF ffff";
//SendStrAndSleep(portName, str3, sleep);
////block4=正方向匀速运动
//string str4 = slvAddrStr + "104810 000408 10000311 00000000 ffff";
//SendStrAndSleep(portName, str4, sleep);
////block5=反方向匀速运动
//string str5 = slvAddrStr + "104814 000408 14000311 00000000 ffff";
//SendStrAndSleep(portName, str5, sleep);
////block6=减速停止
//string str6 = slvAddrStr + "104818 000408 00000500 00000000 ffff";
//SendStrAndSleep(portName, str6, sleep);
//block7=紧急停止
string str7 = slvAddrStr + "10481c 000408 00000510 00000000 ffff";
SendStrAndSleep(portName, str7, sleep);
////block7=紧急停止
//string str7 = slvAddrStr + "10481c 000408 00000510 00000000 ffff";
//SendStrAndSleep(portName, str7, sleep);
//0106460001009D12
//速度 V1 =100
......@@ -362,16 +362,28 @@ namespace OnlineStore.DeviceLibrary
}
public static void SetSpeed(string portName, int slvAddr, int speed)
{
int preSpeed = GetAddrValue(portName,slvAddr, ACCMDManager.Speed_Addr);
int preSpeed = GetAddrValue(portName, slvAddr, ACCMDManager.Speed_Addr);
if ((preSpeed.Equals(-1)) || (!preSpeed.Equals(Math.Abs(speed))))
{
string v1 = slvAddr + "064601 " + ACServerManager.SpeedToStr(speed, 4) + " ffff";
LogUtil.debug("轴【" + portName + "_" + slvAddr + "】更新速度为【" + speed + "】,发送数据【" + v1 + "】");
SendStrAndSleep(portName, v1, SleepMSendons);
UpdateAddrValue(portName,slvAddr, ACCMDManager.Speed_Addr, Math.Abs(speed));
Thread.Sleep(SleepMSendons);
}
for (int i = 1; i <= 3; i++)
{
bool result = SendStrAndSleep(portName, v1, SleepMSendons);
if (result)
{
break;
}
else
{
LogUtil.error("轴【" + portName + "_" + slvAddr + "】更新速度为【" + speed + "】,发送数据【" + v1 + "】,第【" + i + "】次失败");
Thread.Sleep(SleepMSendons);
}
}
UpdateAddrValue(portName, slvAddr, ACCMDManager.Speed_Addr, Math.Abs(speed));
Thread.Sleep(SleepMSendons);
}
}
public static void SpeedMove(string portName, int slvAddr, int speed)
{
......
......@@ -27,16 +27,18 @@ namespace OnlineStore.DeviceLibrary
}
return null;
}
public static void SendStrAndSleep(string portName, string str, int sleepS)
public static bool SendStrAndSleep(string portName, string str, int sleepS)
{
byte[] data = AcSerialBean.StringToByte(str);
data[data.Length - 1] = 0x00;
data[data.Length - 2] = 0x00;
data = ACCMDManager.buildCheckData(data, data.Length - 2);
SendData(portName, data);
bool result = SendData(portName, data);
System.Threading.Thread.Sleep(sleepS);
}
return result;
}
public static void SaveData(string portName, byte slvAddr, string regAddr, int value)
{
......@@ -88,13 +90,20 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info( "串口" + portName + " 收到数据:" + strSend + "");
}
}
public static void SendData(string portName, byte[] data)
public static bool SendData(string portName, byte[] data)
{
if (data == null)
{
return;
return false;
}
byte[] returnData = SendCommand(portName, data, ReviceOutTimeMS, 8);
int timeOut = ReviceOutTimeMS;
if (data[1].Equals((byte)10))
{
timeOut = 1000;
}
bool result = false;
byte[] returnData = SendCommand(portName, data, timeOut, 8, out result);
if (returnData != null)
{
string strSend = "";
......@@ -107,6 +116,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info("串口" + portName + " 收到数据:" + strSend + "");
}
}
return result;
}
/// <summary>
/// 发送数据并获取返回值
......@@ -163,7 +173,65 @@ namespace OnlineStore.DeviceLibrary
}
return returnData;
}
/// <summary>
/// 发送数据并获取返回值
/// </summary>
/// <param name="data">发送的数据</param>
/// <param name="outTime">超时时间</param>
/// <param name="result">返回结果,是否发送成功</param>
/// <returns>返回值的长度</returns>
public static byte[] SendCommand(string portName, byte[] data, int outTime, int reviceLength, out bool result)
{
if (outTime < 100)
{
outTime = 100;
}
byte[] returnData = null;
result = false;
try
{
if (data == null)
{
return returnData;
}
string strSend = "";
for (int i = 0; i < data.Length; i++)
{
strSend += string.Format("{0:X2} ", data[i]);
}
if (strSend.Equals(""))
{
return returnData;
}
if (IsShowMsg)
{
LogUtil.info("串口" + portName + " 写入数据:" + strSend + "");
}
AcSerialBean bean = GetSerialBean(portName);
if (bean == null)
{
LogUtil.debug("ACServerManager SendCommand 试图向未打开串口【" + portName + "】写入数据:" + strSend + "。");
}
else
{
int ret = bean.SendCommand(data, ref returnData, outTime, reviceLength);
if (!ret.Equals(reviceLength))
{
LogUtil.error("串口" + portName + " 写入数据:" + strSend + ",预计返回字节数【" + reviceLength + "】实际返回【" + ret + "】");
}
else
{
result = true;
}
System.Threading.Thread.Sleep(2);
}
}
catch (Exception ex)
{
LogUtil.info(ex.ToString());
}
return returnData;
}
public static void WriteData(string portName, int slvAddr, string addr, string data, byte cmd, int length)
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!