Commit efb5e928 张东亮

逻辑基本完成,出入料口待对接

1 个父辈 c21bf5fd
......@@ -102,7 +102,7 @@
<conversionPattern value="[%date][%t]%-5p %m%n" />
</layout>
</appender>
<appender name="Jaka" type="log4net.Appender.RollingFileAppender">
<appender name="jaka" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\\Jaka\\jaka.log" />
<param name="Encoding" value="UTF-8" />
<param name="AppendToFile" value="true" />
......@@ -114,9 +114,9 @@
<param name="ConversionPattern" value="[%d][%t][%c:%L]%-5p %m%n" />
</layout>
</appender>
<logger name="Jaka">
<logger name="jaka">
<level value="info" />
<appender-ref ref="Jaka" />
<appender-ref ref="jaka" />
</logger>
<logger name="RollingLogFileAppender">
<level value="Info" />
......
......@@ -337,7 +337,7 @@ namespace OnlineStore.CarriageClient
AxisManager.instance.CloseAllPort();
AxisManager.instance.CloseCard();
RFIDManager.Close();
StoreBean.robotEquip.StopRobotService();
//StoreBean.robotEquip.StopRobotService();
if (Camera._cam != null)
{
Camera._cam.CloseAll();
......
......@@ -667,7 +667,7 @@
//
this.chkManualRobot.AutoSize = true;
this.chkManualRobot.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chkManualRobot.Location = new System.Drawing.Point(512, 191);
this.chkManualRobot.Location = new System.Drawing.Point(758, 160);
this.chkManualRobot.Name = "chkManualRobot";
this.chkManualRobot.Size = new System.Drawing.Size(141, 26);
this.chkManualRobot.TabIndex = 3;
......@@ -678,7 +678,7 @@
// btnColseRobotService
//
this.btnColseRobotService.BackColor = System.Drawing.Color.Red;
this.btnColseRobotService.Location = new System.Drawing.Point(511, 97);
this.btnColseRobotService.Location = new System.Drawing.Point(758, 241);
this.btnColseRobotService.Name = "btnColseRobotService";
this.btnColseRobotService.Size = new System.Drawing.Size(123, 48);
this.btnColseRobotService.TabIndex = 2;
......@@ -689,7 +689,7 @@
// btnOpenRobotService
//
this.btnOpenRobotService.BackColor = System.Drawing.Color.YellowGreen;
this.btnOpenRobotService.Location = new System.Drawing.Point(511, 25);
this.btnOpenRobotService.Location = new System.Drawing.Point(758, 52);
this.btnOpenRobotService.Name = "btnOpenRobotService";
this.btnOpenRobotService.Size = new System.Drawing.Size(123, 48);
this.btnOpenRobotService.TabIndex = 1;
......@@ -702,7 +702,7 @@
this.ucRobot1.Location = new System.Drawing.Point(4, 13);
this.ucRobot1.Margin = new System.Windows.Forms.Padding(4);
this.ucRobot1.Name = "ucRobot1";
this.ucRobot1.Size = new System.Drawing.Size(500, 428);
this.ucRobot1.Size = new System.Drawing.Size(550, 428);
this.ucRobot1.TabIndex = 0;
//
// panBase
......
......@@ -570,6 +570,18 @@ namespace OnlineStore.CarriageClient
private void chkManualRobot_CheckedChanged(object sender, EventArgs e)
{
ManualRobot(chkManualRobot.Checked);
try
{
if (robotEquip.GetRobotInfo(out JAKABean jAKABean))
{
ucRobot1.Update(jAKABean.RobotData);
}
}
catch(Exception ex)
{
LogUtil.error("chkManualRobot_CheckedChanged",ex);
}
}
}
......
......@@ -71,23 +71,39 @@ namespace OnlineStore.Common
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
} return a;
}
return a;
}
public static string GetValue(string key)
{
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
if (Monitor.TryEnter(configloc, 500))
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return "";
}
else
{
return config.AppSettings.Settings[key].Value;
try
{
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return "";
}
else
{
return config.AppSettings.Settings[key].Value;
}
}
catch (Exception ex)
{
LogUtil.error("获取【" + key + "】的值失败!", ex);
}
finally
{
Monitor.Exit(configloc);
}
}
return "";
}
public static decimal GetNumValue(string key)
static decimal GetNumValue(string key)
{
decimal a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
......@@ -107,54 +123,52 @@ namespace OnlineStore.Common
public static int GetIntValue(string key)
{
int a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
} return a;
string val = GetValue(key);
Int32.TryParse(val, out a);
return a;
}
public static void SaveValue(string key, int value)
{
SaveValue(key, value.ToString());
}
static object configloc = new object();
public static void SaveValue(string key, string value)
{
try
if (Monitor.TryEnter(configloc, 500))
{
if (key.Equals(""))
//if (key.Equals("") || value.Equals(""))
try
{
return;
if (key.Equals(""))
//if (key.Equals("") || value.Equals(""))
{
return;
}
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
SetValue(key, value);
}
else
{
UpdateConfig(key, value);
}
}
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
catch (Exception ex)
{
SetValue(key, value);
LogUtil.error("SaveValue保存配置出错:AppKey=" + key + ",AppValue=" + value + ",", ex);
}
else
finally
{
UpdateConfig(key, value);
Monitor.Exit(configloc);
}
}
catch (Exception ex)
else
{
LogUtil.error( "SaveValue保存配置出错:AppKey=" + key + ",AppValue=" + value + ",",ex);
LogUtil.error("SaveValue保存配置失败,未得到锁:AppKey=" + key + ",AppValue=" + value);
}
}
public static string GetValue(object debugDeviceId)
{
throw new NotImplementedException();
}
/// <summary>
/// 更新配置文件信息
/// </summary>
......@@ -173,10 +187,10 @@ namespace OnlineStore.Common
}
catch (Exception ex)
{
LogUtil.error( "UpdateConfig保存配置出错:name=" + name + ",Xvalue=" + Xvalue + ",",ex);
LogUtil.error("UpdateConfig保存配置出错:name=" + name + ",Xvalue=" + Xvalue + ",", ex);
}
}
///<summary>
///向.config文件的appKey结写入信息AppValue 保存设置
......@@ -207,7 +221,7 @@ namespace OnlineStore.Common
}
catch (Exception ex)
{
LogUtil.error( "SetValue保存配置出错:AppKey=" + AppKey + ",AppValue=" + AppValue + ",",ex);
LogUtil.error("SetValue保存配置出错:AppKey=" + AppKey + ",AppValue=" + AppValue + ",", ex);
}
}
}
......
......@@ -147,8 +147,8 @@ namespace OnlineStore.DeviceLibrary
if (TrayIsInPosition())
{
MoveInfo.NextMoveStep(StepEnum.Inlet_Reset_04_Finish);
LogInfo($"复位 {MoveInfo.SLog}:检测到料盘,皮带停止");
InletRun(false);
LogInfo($"复位 {MoveInfo.SLog}:检测到料盘,5秒后皮带停止");
IOMove(IO_Type.Inlet_Run, IO_VALUE.HIGH,5000);
}
else if (MoveInfo.IsTimeOut(15))
{
......@@ -171,6 +171,7 @@ namespace OnlineStore.DeviceLibrary
AllowFeedIn(false);
Inch7JackUp(false);
Inch13JackUp(false);
InletRun(false);
MoveInfo.EndMove();
}
......@@ -354,6 +355,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Inlet_7InchJackDown, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Inlet_7InchJackUp, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Inlet_7InchJackUpSig, IO_VALUE.HIGH));
}
}
else
......@@ -364,6 +366,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Inlet_7InchJackUp, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Inlet_7InchJackDown, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Inlet_7InchJackDownSig, IO_VALUE.HIGH));
}
}
}
......@@ -381,6 +384,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Inlet_13InchJackDown, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Inlet_13InchJackUp, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Inlet_13InchJackUpSig, IO_VALUE.HIGH));
}
}
else
......@@ -391,6 +395,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Inlet_13InchJackUp, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Inlet_13InchJackDown, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Inlet_13InchJackDownSig, IO_VALUE.HIGH));
}
}
}
......
......@@ -333,9 +333,14 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 送料允许
/// </summary>
private void AddWaitAllowFeedOut()
private void AddWaitAllowFeedOut(bool on)
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Outlet_AllowFeedSig, IO_VALUE.HIGH));
if (on)
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Outlet_AllowFeedSig, IO_VALUE.HIGH));
else
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Outlet_AllowFeedSig, IO_VALUE.LOW));
}
}
/// <summary>
......@@ -352,6 +357,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Outlet_JackDown, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Outlet_JackUp, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Outlet_JackUpSig, IO_VALUE.HIGH));
}
}
else
......@@ -362,6 +368,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Outlet_JackUp, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Outlet_JackDown, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Outlet_JackDownSig, IO_VALUE.HIGH));
}
}
}
......
......@@ -55,22 +55,22 @@ namespace OnlineStore.DeviceLibrary
{
NextMoveStep(StepEnum.Outlet_02_CheckTray, "检查是否有料盘");
JackUp(false);
AddWaitTime(2000);
}
else if (MoveInfo.IsStep(StepEnum.Outlet_02_CheckTray))
{
if (TrayCheck())
{
NextMoveStep(StepEnum.Outlet_03_CheckAllowFeedOut, "有料盘,准备送走");
AddWaitAllowFeedOut();
AddWaitTime(5000);
AddWaitAllowFeedOut(true);
AddWaitTime(2000);
MoveInfo.OneWaitCanEndStep = true;
}
else//无料盘
{
NextMoveStep(StepEnum.Outlet_05_JackUp, "无料盘,顶升抬起,准备料盘放入");
JackUp(true);
AddWaitTime(5000);
if (BufferDataManager.TrayInOutletInfo != null)
BufferDataManager.TrayInOutletInfo = null;
}
}
else if (MoveInfo.IsStep(StepEnum.Outlet_03_CheckAllowFeedOut))
......@@ -78,12 +78,12 @@ namespace OnlineStore.DeviceLibrary
NextMoveStep(StepEnum.Outlet_04_WaitTrayLeave, "允许料盘离开,链条运行");
OutletRun(true);
AddWaitTrayCheck1(false);
AddWaitTrayCheck2(true);
AddWaitTrayCheck2(false);
//AddWaitAllowFeedOut(false);
}
else if (MoveInfo.IsStep(StepEnum.Outlet_04_WaitTrayLeave))
{
NextMoveStep(StepEnum.Outlet_05_JackUp, "料盘离开完成,清除出料口缓存,链条停止,顶升抬起");
NextMoveStep(StepEnum.Outlet_05_JackUp, "料盘离开完成,链条停止,顶升抬起");
BufferDataManager.TrayInOutletInfo = null;
OutletRun(false);
JackUp(true);
......
......@@ -61,7 +61,6 @@ namespace OnlineStore.DeviceLibrary
System.Threading.Thread.Sleep(2000);
EnableRobot(true);
System.Threading.Thread.Sleep(2000);
StartProg(true);
});
}
......@@ -71,8 +70,6 @@ namespace OnlineStore.DeviceLibrary
{
Task.Factory.StartNew(delegate
{
StartProg(false);
System.Threading.Thread.Sleep(2000);
EnableRobot(false);
System.Threading.Thread.Sleep(2000);
PowerOn(false);
......@@ -152,6 +149,9 @@ namespace OnlineStore.DeviceLibrary
isNoAirpressure_Check = false;
MoveInfo.NextMoveStep(StepEnum.Robot_Reset_01_Wait);
LogInfo($"复位 {MoveInfo.SLog} :轴开始复位");
StartProg(true);
curcmd = "";
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
isInPro = false;
}
......@@ -161,19 +161,12 @@ namespace OnlineStore.DeviceLibrary
{
MoveResetPro();
}
//else if(MoveInfo.MoveType.Equals(MoveType.RHome))
//{
// MoveHomePro();
//}
}
static int axisDiff = 20000;
private bool CheckTongsPos()
{
return false;
}
//Bitmap resetBitMap = null;
bool resetRtnA = false;
bool resetRtnB = false;
private void MoveResetPro()
{
if (MoveInfo.IsInWait)
......@@ -352,14 +345,12 @@ namespace OnlineStore.DeviceLibrary
internal override void StopMove()
{
MoveInfo.EndMove();
MoveAxis.SuddenStop();
CompressAxis.SuddenStop();
StartProg(false);
CloseAllAxis();
curcmd = "";
}
public override void StopRun()
......
......@@ -73,89 +73,89 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 获取整个料仓的状态
/// </summary>
//public Operation getLineBoxStatus()
//{
// //构建发送给服务器的对象
// Operation lineOperation = new Operation();
// lineOperation.msg = "";
// lineOperation.alarmList = new List<AlarmInfo>();
// lineOperation.cid = CID;
// lineOperation.seq = ConfigAppSettings.nextSeq();
// lineOperation.status = 1;
// if (WarnMsg != "")
// {
// lineOperation.status = (int)DeviceStatus.Warning;
// lineOperation.msg = WarnMsg;
// }
// lineOperation.status = (int)DeviceStatus.StoreOnline;
public Operation getLineBoxStatus()
{
//构建发送给服务器的对象
Operation lineOperation = new Operation();
lineOperation.msg = "";
lineOperation.alarmList = new List<AlarmInfo>();
lineOperation.cid = CID;
lineOperation.seq = ConfigAppSettings.nextSeq();
lineOperation.status = 1;
if (WarnMsg != "")
{
lineOperation.status = (int)DeviceStatus.Warning;
lineOperation.msg = WarnMsg;
}
lineOperation.status = (int)DeviceStatus.StoreOnline;
// BoxStatus boxStatus = new BoxStatus();
// boxStatus.boxId = 1;
BoxStatus boxStatus = new BoxStatus();
boxStatus.boxId = 1;
// boxStatus.msg = WarnMsg;
// lineOperation.msg = WarnMsg;
boxStatus.msg = WarnMsg;
lineOperation.msg = WarnMsg;
// if (WarnMsg.Equals(""))
// {
// boxStatus.msg = CodeMsg;
// lineOperation.msg = CodeMsg;
// }
// CodeMsg = "";
// //WarnMsg = "";
// //状态
// boxStatus.status = (int)deviceStatus;
// if (IsDebug)
// {
// boxStatus.status = (int)DeviceStatus.Debugging;
// }
// else if (runStatus.Equals(DeviceStatus.OutStoreBoxEnd) || runStatus.Equals(DeviceStatus.InStoreEnd))
// {
// boxStatus.data.Add(ParamDefine.posId, lastPosId);
// boxStatus.data.Add(ParamDefine.barcode,lastBarcode);
// boxStatus.data.Add(ParamDefine.executeTime, executeTime);
// }
// else if (!lastPosId.Equals(""))
// {
// boxStatus.data.Add(ParamDefine.posId, lastPosId);
// boxStatus.data.Add(ParamDefine.barcode, lastBarcode);
// boxStatus.data.Add(ParamDefine.executeTime,executeTime);
// boxStatus.status = (int)deviceStatus;
// if (lastPosId != "")
// {
// LogUtil.info("给服务器发送出入库消息:" + Name + ",status【" + deviceStatus + "】posId【" + lastPosId + "】barcode【"+lastBarcode+"】");
// }
// lastPosId = "";
// lastBarcode = "";
// }
if (WarnMsg.Equals(""))
{
boxStatus.msg = CodeMsg;
lineOperation.msg = CodeMsg;
}
CodeMsg = "";
//WarnMsg = "";
//状态
boxStatus.status = (int)deviceStatus;
if (IsDebug)
{
boxStatus.status = (int)DeviceStatus.Debugging;
}
//else if (runStatus.Equals(DeviceStatus.OutStoreBoxEnd) || runStatus.Equals(DeviceStatus.InStoreEnd))
//{
// boxStatus.data.Add(ParamDefine.posId, lastPosId);
// boxStatus.data.Add(ParamDefine.barcode, lastBarcode);
// boxStatus.data.Add(ParamDefine.executeTime, executeTime);
//}
//else if (!lastPosId.Equals(""))
//{
// boxStatus.data.Add(ParamDefine.posId, lastPosId);
// boxStatus.data.Add(ParamDefine.barcode, lastBarcode);
// boxStatus.data.Add(ParamDefine.executeTime, executeTime);
// boxStatus.status = (int)deviceStatus;
// if (lastPosId != "")
// {
// LogUtil.info("给服务器发送出入库消息:" + Name + ",status【" + deviceStatus + "】posId【" + lastPosId + "】barcode【" + lastBarcode + "】");
// }
// lastPosId = "";
// lastBarcode = "";
//}
// if (MoveInfo.MoveType.Equals(MoveType.InStore)||MoveInfo.MoveType.Equals(MoveType.OutStore))
// {
// if ((MoveInfo.MoveParam != null)&&( MoveInfo.MoveParam.PosInfo!=null))
// {
// if (!boxStatus.data.ContainsKey(ParamDefine.posId))
// {
// boxStatus.data.Add(ParamDefine.posId, MoveInfo.MoveParam.PosInfo.PosId);
// }
// boxStatus.data.Add(ParamDefine.code, MoveInfo.MoveParam.PosInfo.barcode);
// }
// }
if (MoveInfo.MoveType.Equals(MoveType.InStore) || MoveInfo.MoveType.Equals(MoveType.OutStore))
{
if ((MoveInfo.MoveParam != null) && (MoveInfo.MoveParam.PosInfo != null))
{
if (!boxStatus.data.ContainsKey(ParamDefine.posId))
{
boxStatus.data.Add(ParamDefine.posId, MoveInfo.MoveParam.PosInfo.PosId);
}
boxStatus.data.Add(ParamDefine.code, MoveInfo.MoveParam.PosInfo.barcode);
}
}
// //温湿度
// //ASTemperateParam param = HumitureServer.GetTemperateParam(Config.Temperate_Serveraddress);
// HumitureParam param = humBean.LastData;
// if (param != null)
// {
// boxStatus.humidity = param.Humidity.ToString();
// boxStatus.temperature = param.Temperate.ToString();
// }
// lineOperation.boxStatus.Add(1, boxStatus);
//温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.Temperate_Serveraddress);
//HumitureParam param = humBean.LastData;
//if (param != null)
//{
// boxStatus.humidity = param.Humidity.ToString();
// boxStatus.temperature = param.Temperate.ToString();
//}
lineOperation.boxStatus.Add(1, boxStatus);
// if (!alarmType.Equals(AlarmType.None))
// {
// lineOperation.alarmList.Add(alarmInfo);
// }
// return lineOperation;
//}
if (!alarmType.Equals(AlarmType.None))
{
lineOperation.alarmList.Add(alarmInfo);
}
return lineOperation;
}
//public void SendLineStatus()
//{
......@@ -230,63 +230,63 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(Name + "执行TimerProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
}
}
//public bool ReviceInStoreCMD(string posId, int plateH, int plateW, string message)
//{
// string logName = "入库库位验证【 " + message + "】【" + posId + "】:";
// try
// {
public bool ReviceInStoreCMD(string posId, int plateH, int plateW, string code)
{
string logName = "入库库位验证【 " + code + "】【" + posId + "】:";
try
{
// if (runStatus.Equals(RunStatus.Wait))
// {
// LogUtil.info(logName + " 设备未启动,验证失败");
// return false;
// }
// //发送扫码内容到服务器进行入库操作
// Operation operation = getLineBoxStatus();
// operation.op = 1;
// operation.data = new Dictionary<string, string>() { { "code", message }, { "boxId", this.DeviceID.ToString() } };
// operation.data.Add("inPos", posId);
// string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
// for (int i = 1; i <= 3; i++)
// {
// bool timeOut = false;
// Operation resultOperation = HttpHelper.PostOperation(SServerManager.GetPostApi(server), operation);
// if (timeOut)
// {
// LogUtil.info(logName + " 第" + i + "次发送超时 ");
// continue;
// }
// if (resultOperation == null)
// {
// // CodeMsg = "二维码【" + message + "】没有收到服务器反馈";
// LogUtil.info(logName + " 没有收到服务器反馈 ");
// }
// else if (!string.IsNullOrEmpty(resultOperation.msg))
// {
// //如果有提示消息,直接显示提示
// LogUtil.info(logName + "服务器反馈 :" + resultOperation.msg);
if (runStatus.Equals(RunStatus.Wait))
{
LogUtil.info(logName + " 设备未启动,验证失败");
return false;
}
//发送扫码内容到服务器进行入库操作
Operation operation = getLineBoxStatus();
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", code }, { "boxId", this.DeviceID.ToString() } };
operation.data.Add("inPos", posId);
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
for (int i = 1; i <= 3; i++)
{
bool timeOut = false;
Operation resultOperation = HttpHelper.PostOperation(SServerManager.GetPostApi(server), operation);
if (timeOut)
{
LogUtil.info(logName + " 第" + i + "次发送超时 ");
continue;
}
if (resultOperation == null)
{
// CodeMsg = "二维码【" + message + "】没有收到服务器反馈";
LogUtil.info(logName + " 没有收到服务器反馈 ");
}
else if (!string.IsNullOrEmpty(resultOperation.msg))
{
//如果有提示消息,直接显示提示
LogUtil.info(logName + "服务器反馈 :" + resultOperation.msg);
// }
// else if (resultOperation.op.Equals(1))
// {
// LogUtil.info(logName + " 成功");
// return true;
// }
// else
// {
// LogUtil.info(logName + "服务器反馈 :" + JsonHelper.SerializeObject(resultOperation));
// }
// break;
// }
// }
// catch (Exception ex)
// {
// LogUtil.info(logName + " 出错:" + ex.ToString());
}
else if (resultOperation.op.Equals(1))
{
LogUtil.info(logName + " 成功");
return true;
}
else
{
LogUtil.info(logName + "服务器反馈 :" + JsonHelper.SerializeObject(resultOperation));
}
break;
}
}
catch (Exception ex)
{
LogUtil.info(logName + " 出错:" + ex.ToString());
// }
// return false;
//}
//public string LastVisualRfid = "";
}
return false;
}
public string LastVisualRfid = "";
string lastdataStr = "";
private void ReviceOutStoreProcess(TaskData resultOperation)
{
......
......@@ -111,14 +111,15 @@ namespace OnlineStore.DeviceLibrary
NextMoveStep(StepEnum.InStore_16_ArmBackToP1, "在NG箱放料完成,清除机器人料叉缓存,机械臂回待机点");
//在料仓口口放料完成
BufferDataManager.TrayInRobotInfo = null;
// UpdateLocInfo(MoveInfo.MoveParam.PosInfo.barcode, TaskStatus.BOXDOOR);
// UpdateLocInfo(MoveInfo.MoveParam.PosInfo.barcode, TaskStatus.BOXDOOR);
InStore_16_ArmBackToP1();
break;
#endregion
case StepEnum.InStore_16_ArmBackToP1:
NextMoveStep(StepEnum.InStore_17_Finish, "入库结束");
UpdateLocInfo(MoveInfo.MoveParam.PosInfo, TaskStatus.BOXDOOR);
if (CheckInstoreTrayTarget())
UpdateLocInfo(MoveInfo.MoveParam.PosInfo, TaskStatus.BOXDOOR);
InStore_17_Finish();
break;
case StepEnum.InStore_17_Finish:
......@@ -145,11 +146,11 @@ namespace OnlineStore.DeviceLibrary
}
private bool InStore_04_CheckInletState()
{
if (MoveInfo.MoveParam.PosInfo!=null)
if (MoveInfo.MoveParam.PosInfo != null)
return true;
return false;
}
private void InStore_05_ArmToTrayLow(int width=7)
private void InStore_05_ArmToTrayLow(int width = 7)
{
if (width == 7 || width == 13)
SendCmd(GetCmd_InletLow(width));
......@@ -220,12 +221,12 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
/// <param name="posinfo"></param>
/// <param name="status"></param>
private void UpdateLocInfo(InOutPosInfo posinfo,string status)
private void UpdateLocInfo(InOutPosInfo posinfo, string status)
{
string result=SServerManager.UpdateTrayLoc(posinfo.barcode, status, posinfo.PosId,posinfo.taskId);
if(!result.Equals(""))
string result = SServerManager.UpdateTrayLoc(posinfo.barcode, status, posinfo.PosId, posinfo.taskId);
if (!result.Equals(""))
{
SServerManager.UpdateTrayLoc(posinfo.barcode, status, posinfo.PosId,posinfo.taskId);
SServerManager.UpdateTrayLoc(posinfo.barcode, status, posinfo.PosId, posinfo.taskId);
}
}
}
......
......@@ -49,7 +49,8 @@ namespace OnlineStore.DeviceLibrary
OutStore_07_ArmBackToP1();
break;
case StepEnum.OutStore_07_ArmBackToP1:
NextMoveStep(StepEnum.OutStore_08_MoveAxisToOutlet, "行走机构到出料口");
NextMoveStep(StepEnum.OutStore_08_MoveAxisToOutlet, "机械臂到待机点,上报状态,行走机构到出料口");
UpdateLocInfo(MoveInfo.MoveParam.PosInfo, TaskStatus.INROBOT);
OutStore_08_MoveAxisToOutlet();
break;
case StepEnum.OutStore_08_MoveAxisToOutlet:
......@@ -104,7 +105,6 @@ namespace OnlineStore.DeviceLibrary
{
//添加机器人缓存,并上报任务状态
BufferDataManager.TrayInRobotInfo = MoveInfo.MoveParam.PosInfo.ToCopy();
UpdateLocInfo(MoveInfo.MoveParam.PosInfo, TaskStatus.INROBOT);
SendCmd(GetCmd_Standby());
}
......
......@@ -68,6 +68,7 @@ namespace OnlineStore.DeviceLibrary
return sb.ToString();
}
string cmdResponse = "";
bool robotOnline = true;
/// <summary>
/// 机器人移动成功
/// </summary>
......@@ -83,6 +84,7 @@ namespace OnlineStore.DeviceLibrary
if (!bean.RobotData.Online)
{
SetWarnMsg("无法读取机器人状态,因机器人离线");
robotOnline = false;
return false;
}
else
......@@ -91,6 +93,17 @@ namespace OnlineStore.DeviceLibrary
}
try
{
if (robotOnline && bean.RobotData.RecvMsg.Equals("") && (DateTime.Now - sendTime).TotalSeconds > 10)
{
SendCmd(curcmd);
LogUtil.info($"机器人命令10秒内未收到反馈,重发命令:【{curcmd}】");
}
if (!robotOnline && bean.RobotData.RecvMsg.Contains("home") && bean.RobotData.RecvMsg.Contains("done"))
{
SendCmd(curcmd);
LogUtil.info($"重发机器人离线前的命令:【{curcmd}】");
robotOnline = true;
}
if (!cmdResponse.Equals(bean.RobotData.RecvMsg) && !bean.RobotData.RecvMsg.Equals(""))
{
cmdResponse = bean.RobotData.RecvMsg;
......@@ -137,6 +150,7 @@ namespace OnlineStore.DeviceLibrary
return insafeAtOutlet;
}
public string curcmd = "";
DateTime sendTime = DateTime.Now;
/// <summary>
/// 发送命令
/// </summary>
......@@ -160,6 +174,7 @@ namespace OnlineStore.DeviceLibrary
ClearSpecifiedAlarm("无法发送命令,因机器人离线");
}
JAKAServer.SendCmd(bean.RemoteEndPoint, cmd);
sendTime = DateTime.Now;
LogUtil.info($"Send RobotMove Cmd:【{cmd}】");
}
/// <summary>
......@@ -263,9 +278,15 @@ namespace OnlineStore.DeviceLibrary
if (GetRobotInfo(out JAKA.JAKABean bean))
{
if (on)
bean.PowerOn();
{
if (bean.RobotData.RobotStatus.powered_on == 0)
bean.PowerOn();
}
else
bean.PowerOff();
{
if (bean.RobotData.RobotStatus.powered_on == 1)
bean.PowerOff();
}
}
}
/// <summary>
......@@ -277,9 +298,16 @@ namespace OnlineStore.DeviceLibrary
if (GetRobotInfo(out JAKA.JAKABean bean))
{
if (enable)
bean.EnableRobot();
{
if (bean.RobotData.RobotStatus.enabled == 0)
bean.EnableRobot();
}
else
bean.DisableRobot();
{
if (bean.RobotData.RobotStatus.enabled == 1)
bean.DisableRobot();
}
}
}
......@@ -292,7 +320,10 @@ namespace OnlineStore.DeviceLibrary
if (GetRobotInfo(out JAKA.JAKABean bean))
{
if (start)
{
bean.Run();
}
else
bean.Abort();
}
......
......@@ -15,7 +15,7 @@ namespace JAKA
int rtn = jakaAPI.create_handler(ip.ToCharArray(),ref _handle);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"CreateHandler OK");
InfoLog($"CreateHandler OK");
//SetErrorHandler();
SetErrorCodeFilePath(Application.StartupPath+ @"\jaka_files\JAKA_ERROR_CODE.csv");
return true;
......@@ -35,7 +35,7 @@ namespace JAKA
int rtn = jakaAPI.set_error_handler(ref _handle, user_error_handle);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"SetErrorHandler OK");
InfoLog($"SetErrorHandler OK");
return true;
}
else
......@@ -53,7 +53,7 @@ namespace JAKA
int rtn = jakaAPI.destory_handler(ref _handle);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"DestroyHandler OK");
InfoLog($"DestroyHandler OK");
return true;
}
else
......@@ -71,7 +71,7 @@ namespace JAKA
int rtn = jakaAPI.power_on(ref _handle);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"PowerOn OK");
InfoLog($"PowerOn OK");
return true;
}
else
......@@ -88,7 +88,7 @@ namespace JAKA
int rtn = jakaAPI.power_off(ref _handle);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"PowerOff OK");
InfoLog($"PowerOff OK");
return true;
}
else
......@@ -105,7 +105,7 @@ namespace JAKA
int rtn = jakaAPI.shut_down(ref _handle);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"ShutDown OK");
InfoLog($"ShutDown OK");
return true;
}
else
......@@ -122,7 +122,7 @@ namespace JAKA
int rtn = jakaAPI.enable_robot(ref _handle);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"EnableRobot OK");
InfoLog($"EnableRobot OK");
return true;
}
else
......@@ -139,7 +139,7 @@ namespace JAKA
int rtn = jakaAPI.disable_robot(ref _handle);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"DisableRobot OK");
InfoLog($"DisableRobot OK");
return true;
}
else
......@@ -388,7 +388,7 @@ namespace JAKA
/// <param name="index">DI 索引(从 0 开始)</param>
/// <param name="value">DI 状态查询结果</param>
/// <returns></returns>
bool GetDigitalInput(JKTYPE.IOType iOType, int index,out bool result)
public bool GetDigitalInput(JKTYPE.IOType iOType, int index,out bool result)
{
result = false;
int rtn = jakaAPI.get_digital_input(ref _handle, iOType, index,ref result);
......@@ -410,7 +410,7 @@ namespace JAKA
/// <param name="index">DO 索引(从 0 开始)</param>
/// <param name="value">DO 状态查询结果</param>
/// <returns></returns>
bool GetDigitalOutput(JKTYPE.IOType iOType, int index, out bool result)
public bool GetDigitalOutput(JKTYPE.IOType iOType, int index, out bool result)
{
result = false;
int rtn = jakaAPI.get_digital_output(ref _handle, iOType, index, ref result);
......@@ -433,7 +433,7 @@ namespace JAKA
int rtn = jakaAPI.program_run(ref _handle);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"Run OK");
InfoLog($"Run OK");
return false;
}
else
......@@ -450,7 +450,7 @@ namespace JAKA
int rtn = jakaAPI.program_pause(ref _handle);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"Pause OK");
InfoLog($"Pause OK");
return false;
}
else
......@@ -467,7 +467,7 @@ namespace JAKA
int rtn = jakaAPI.program_resume(ref _handle);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"Resume OK");
InfoLog($"Resume OK");
return false;
}
else
......@@ -485,7 +485,7 @@ namespace JAKA
int rtn = jakaAPI.program_abort(ref _handle);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"Abort OK");
InfoLog($"Abort OK");
return true;
}
else
......@@ -504,7 +504,7 @@ namespace JAKA
int rtn = jakaAPI.program_load(ref _handle,file.ToCharArray());
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"Load OK");
InfoLog($"Load OK");
return true;
}
else
......@@ -696,7 +696,7 @@ namespace JAKA
int rtn = jakaAPI.is_in_pos(ref _handle, ref inPos);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"IsInPos OK");
InfoLog($"IsInPos OK");
return true;
}
else
......@@ -930,7 +930,7 @@ namespace JAKA
int rtn = jakaAPI.clear_error(ref _handle);
if (rtn == RtnCode.ERR_SUCC)
{
DebugLog($"ClearError OK");
InfoLog($"ClearError OK");
return true;
}
else
......
......@@ -47,6 +47,7 @@ namespace JAKA
/// </summary>
public int ScanRate = 300;
RobotData robotData = new RobotData();
string err = "";
private void UpdateData()
{
try
......@@ -61,7 +62,12 @@ namespace JAKA
{
if (GetLastError(ref error))
{
robotData.Errorinfo = $"运行异常:{string.Join("", error.message)}[{error.code}]";
robotData.Errorinfo = $"运行异常:【{error.code}】【{string.Join("", error.message)}】";
if(!err.Equals(robotData.Errorinfo))
{
err = robotData.Errorinfo;
log.Error(err);
}
}
else
{
......@@ -79,6 +85,7 @@ namespace JAKA
robotData.Online = RobotData.Online;
robotData.CurCmd = RobotData.CurCmd;
robotData.RecvMsg = RobotData.RecvMsg;
log.Info($"Update Robot Data:【{RobotData.CurCmd}】【{RobotData.RecvMsg}】【{RobotData.Errorinfo}】");
UpdateDataEvent?.Invoke(robotData);
}
......
......@@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.lblestop = new System.Windows.Forms.Label();
this.lblpoweredon = new System.Windows.Forms.Label();
this.lblservoenabled = new System.Windows.Forms.Label();
......@@ -38,19 +39,21 @@
this.lblonsoftlimit = new System.Windows.Forms.Label();
this.lbldragstatus = new System.Windows.Forms.Label();
this.lblsdkconnect = new System.Windows.Forms.Label();
this.btnPowerOn = new System.Windows.Forms.Button();
this.btnPowerOff = new System.Windows.Forms.Button();
this.btnDisable = new System.Windows.Forms.Button();
this.btnEnable = new System.Windows.Forms.Button();
this.btnStop = new System.Windows.Forms.Button();
this.btnStart = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.lblSafe = new System.Windows.Forms.Label();
this.btnRun = new System.Windows.Forms.Button();
this.lblresponse = new System.Windows.Forms.Label();
this.btnSend = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.lblCmd = new System.Windows.Forms.Label();
this.lblProgramstate = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
......@@ -87,7 +90,7 @@
// lblerrorcode
//
this.lblerrorcode.AutoSize = true;
this.lblerrorcode.Location = new System.Drawing.Point(242, 92);
this.lblerrorcode.Location = new System.Drawing.Point(14, 119);
this.lblerrorcode.Name = "lblerrorcode";
this.lblerrorcode.Size = new System.Drawing.Size(41, 12);
this.lblerrorcode.TabIndex = 3;
......@@ -106,7 +109,7 @@
// lblrapidrate
//
this.lblrapidrate.AutoSize = true;
this.lblrapidrate.Location = new System.Drawing.Point(291, 59);
this.lblrapidrate.Location = new System.Drawing.Point(313, 59);
this.lblrapidrate.Name = "lblrapidrate";
this.lblrapidrate.Size = new System.Drawing.Size(53, 12);
this.lblrapidrate.TabIndex = 5;
......@@ -152,56 +155,12 @@
this.lblsdkconnect.TabIndex = 9;
this.lblsdkconnect.Text = "SDK与控制器连接";
//
// btnPowerOn
//
this.btnPowerOn.BackColor = System.Drawing.Color.GreenYellow;
this.btnPowerOn.Location = new System.Drawing.Point(16, 123);
this.btnPowerOn.Name = "btnPowerOn";
this.btnPowerOn.Size = new System.Drawing.Size(99, 43);
this.btnPowerOn.TabIndex = 10;
this.btnPowerOn.Text = "打开本体电源";
this.btnPowerOn.UseVisualStyleBackColor = false;
this.btnPowerOn.Click += new System.EventHandler(this.btnPowerOn_Click);
//
// btnPowerOff
//
this.btnPowerOff.BackColor = System.Drawing.Color.DeepPink;
this.btnPowerOff.Location = new System.Drawing.Point(16, 172);
this.btnPowerOff.Name = "btnPowerOff";
this.btnPowerOff.Size = new System.Drawing.Size(99, 43);
this.btnPowerOff.TabIndex = 11;
this.btnPowerOff.Text = "关闭本体电源";
this.btnPowerOff.UseVisualStyleBackColor = false;
this.btnPowerOff.Click += new System.EventHandler(this.btnPowerOff_Click);
//
// btnDisable
//
this.btnDisable.BackColor = System.Drawing.Color.DeepPink;
this.btnDisable.Location = new System.Drawing.Point(125, 172);
this.btnDisable.Name = "btnDisable";
this.btnDisable.Size = new System.Drawing.Size(99, 43);
this.btnDisable.TabIndex = 13;
this.btnDisable.Text = "关闭使能";
this.btnDisable.UseVisualStyleBackColor = false;
this.btnDisable.Click += new System.EventHandler(this.btnDisable_Click);
//
// btnEnable
//
this.btnEnable.BackColor = System.Drawing.Color.GreenYellow;
this.btnEnable.Location = new System.Drawing.Point(125, 123);
this.btnEnable.Name = "btnEnable";
this.btnEnable.Size = new System.Drawing.Size(99, 43);
this.btnEnable.TabIndex = 12;
this.btnEnable.Text = "打开使能";
this.btnEnable.UseVisualStyleBackColor = false;
this.btnEnable.Click += new System.EventHandler(this.btnEnable_Click);
//
// btnStop
//
this.btnStop.BackColor = System.Drawing.Color.DeepPink;
this.btnStop.Location = new System.Drawing.Point(230, 172);
this.btnStop.Location = new System.Drawing.Point(102, 195);
this.btnStop.Name = "btnStop";
this.btnStop.Size = new System.Drawing.Size(99, 43);
this.btnStop.Size = new System.Drawing.Size(73, 43);
this.btnStop.TabIndex = 15;
this.btnStop.Text = "停止程序";
this.btnStop.UseVisualStyleBackColor = false;
......@@ -210,9 +169,9 @@
// btnStart
//
this.btnStart.BackColor = System.Drawing.Color.GreenYellow;
this.btnStart.Location = new System.Drawing.Point(230, 123);
this.btnStart.Location = new System.Drawing.Point(102, 146);
this.btnStart.Name = "btnStart";
this.btnStart.Size = new System.Drawing.Size(99, 43);
this.btnStart.Size = new System.Drawing.Size(73, 43);
this.btnStart.TabIndex = 14;
this.btnStart.Text = "运行程序";
this.btnStart.UseVisualStyleBackColor = false;
......@@ -220,22 +179,23 @@
//
// groupBox1
//
this.groupBox1.Controls.Add(this.button4);
this.groupBox1.Controls.Add(this.button3);
this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.lblSafe);
this.groupBox1.Controls.Add(this.btnRun);
this.groupBox1.Controls.Add(this.lblresponse);
this.groupBox1.Controls.Add(this.btnSend);
this.groupBox1.Controls.Add(this.comboBox1);
this.groupBox1.Controls.Add(this.lblCmd);
this.groupBox1.Controls.Add(this.lblProgramstate);
this.groupBox1.Controls.Add(this.btnPowerOn);
this.groupBox1.Controls.Add(this.btnStop);
this.groupBox1.Controls.Add(this.lblestop);
this.groupBox1.Controls.Add(this.btnStart);
this.groupBox1.Controls.Add(this.lblpoweredon);
this.groupBox1.Controls.Add(this.btnDisable);
this.groupBox1.Controls.Add(this.lblservoenabled);
this.groupBox1.Controls.Add(this.btnEnable);
this.groupBox1.Controls.Add(this.lblerrorcode);
this.groupBox1.Controls.Add(this.btnPowerOff);
this.groupBox1.Controls.Add(this.lblinpos);
this.groupBox1.Controls.Add(this.lblrapidrate);
this.groupBox1.Controls.Add(this.lblsdkconnect);
......@@ -244,25 +204,46 @@
this.groupBox1.Controls.Add(this.lblonsoftlimit);
this.groupBox1.Location = new System.Drawing.Point(3, 3);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(418, 292);
this.groupBox1.Size = new System.Drawing.Size(451, 260);
this.groupBox1.TabIndex = 16;
this.groupBox1.TabStop = false;
//
// button1
//
this.button1.BackColor = System.Drawing.Color.SandyBrown;
this.button1.Location = new System.Drawing.Point(340, 146);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(71, 43);
this.button1.TabIndex = 24;
this.button1.Text = "清除错误";
this.button1.UseVisualStyleBackColor = false;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// lblSafe
//
this.lblSafe.AutoSize = true;
this.lblSafe.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblSafe.Location = new System.Drawing.Point(252, 59);
this.lblSafe.Name = "lblSafe";
this.lblSafe.Size = new System.Drawing.Size(55, 14);
this.lblSafe.TabIndex = 23;
this.lblSafe.Text = "安全位置";
//
// btnRun
//
this.btnRun.BackColor = System.Drawing.Color.GreenYellow;
this.btnRun.Location = new System.Drawing.Point(335, 140);
this.btnRun.Location = new System.Drawing.Point(14, 146);
this.btnRun.Name = "btnRun";
this.btnRun.Size = new System.Drawing.Size(69, 59);
this.btnRun.Size = new System.Drawing.Size(82, 43);
this.btnRun.TabIndex = 21;
this.btnRun.Text = "一键启动";
this.btnRun.Text = "上电使能";
this.btnRun.UseVisualStyleBackColor = false;
this.btnRun.Click += new System.EventHandler(this.btnRun_Click);
//
// lblresponse
//
this.lblresponse.AutoSize = true;
this.lblresponse.Location = new System.Drawing.Point(114, 92);
this.lblresponse.Location = new System.Drawing.Point(213, 92);
this.lblresponse.Name = "lblresponse";
this.lblresponse.Size = new System.Drawing.Size(53, 12);
this.lblresponse.TabIndex = 20;
......@@ -270,9 +251,9 @@
//
// btnSend
//
this.btnSend.Location = new System.Drawing.Point(215, 235);
this.btnSend.Location = new System.Drawing.Point(340, 200);
this.btnSend.Name = "btnSend";
this.btnSend.Size = new System.Drawing.Size(99, 43);
this.btnSend.Size = new System.Drawing.Size(71, 38);
this.btnSend.TabIndex = 19;
this.btnSend.Text = "发送命令";
this.btnSend.UseVisualStyleBackColor = true;
......@@ -280,10 +261,9 @@
//
// comboBox1
//
this.comboBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Items.AddRange(new object[] {
"home",
"standby",
"store1-high",
"store1-low",
"store2-high",
......@@ -305,9 +285,9 @@
"inlet-up",
"outlet-down",
"ngbox-down"});
this.comboBox1.Location = new System.Drawing.Point(16, 247);
this.comboBox1.Location = new System.Drawing.Point(200, 214);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(137, 20);
this.comboBox1.Size = new System.Drawing.Size(116, 24);
this.comboBox1.TabIndex = 18;
//
// lblCmd
......@@ -323,19 +303,58 @@
//
this.lblProgramstate.AutoSize = true;
this.lblProgramstate.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblProgramstate.Location = new System.Drawing.Point(200, 59);
this.lblProgramstate.Location = new System.Drawing.Point(191, 59);
this.lblProgramstate.Name = "lblProgramstate";
this.lblProgramstate.Size = new System.Drawing.Size(55, 14);
this.lblProgramstate.TabIndex = 16;
this.lblProgramstate.Text = "程序运行";
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// button2
//
this.button2.BackColor = System.Drawing.Color.PaleGoldenrod;
this.button2.Location = new System.Drawing.Point(181, 146);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(71, 43);
this.button2.TabIndex = 25;
this.button2.Text = "回零";
this.button2.UseVisualStyleBackColor = false;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.BackColor = System.Drawing.Color.Turquoise;
this.button3.Location = new System.Drawing.Point(262, 146);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(71, 43);
this.button3.TabIndex = 26;
this.button3.Text = "回待机点";
this.button3.UseVisualStyleBackColor = false;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.BackColor = System.Drawing.Color.DeepPink;
this.button4.Location = new System.Drawing.Point(16, 195);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(80, 43);
this.button4.TabIndex = 27;
this.button4.Text = "下电下使能";
this.button4.UseVisualStyleBackColor = false;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// UCRobot
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.groupBox1);
this.Name = "UCRobot";
this.Size = new System.Drawing.Size(425, 298);
this.Size = new System.Drawing.Size(457, 272);
this.Load += new System.EventHandler(this.UCRobot_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
......@@ -353,10 +372,6 @@
private System.Windows.Forms.Label lblonsoftlimit;
private System.Windows.Forms.Label lbldragstatus;
private System.Windows.Forms.Label lblsdkconnect;
private System.Windows.Forms.Button btnPowerOn;
private System.Windows.Forms.Button btnPowerOff;
private System.Windows.Forms.Button btnDisable;
private System.Windows.Forms.Button btnEnable;
private System.Windows.Forms.Button btnStop;
private System.Windows.Forms.Button btnStart;
private System.Windows.Forms.GroupBox groupBox1;
......@@ -366,5 +381,11 @@
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label lblresponse;
private System.Windows.Forms.Button btnRun;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Label lblSafe;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button4;
}
}
......@@ -21,14 +21,14 @@ namespace JAKA
}
private JAKABean jakaBean;
private JAKAServer server;
public void Regidter(JAKABean jakabean,JAKAServer jAKAServer)
public void Regidter(JAKABean jakabean, JAKAServer jAKAServer)
{
this.jakaBean = jakabean;
groupBox1.Text = $"[{jakabean.IP}]";
server = jAKAServer;
jakabean.RegisterUpdataEvent(Update);
}
private void Update(RobotData robotData)
public void Update(RobotData robotData)
{
if (!this.IsHandleCreated)
return;
......@@ -49,7 +49,7 @@ namespace JAKA
{
lblProgramstate.BackColor = Color.Red;
}
else if(robotData.ProgramState.Equals(ProgramState.PROGRAM_PAUSED))
else if (robotData.ProgramState.Equals(ProgramState.PROGRAM_PAUSED))
{
lblProgramstate.BackColor = Color.Yellow;
}
......@@ -58,7 +58,7 @@ namespace JAKA
lblProgramstate.BackColor = Color.YellowGreen;
}
lblCmd.Text = robotData.CurCmd;
if(robotData.Online)
if (robotData.Online)
{
groupBox1.Text = $"[{jakaBean.IP}][在线]";
}
......@@ -108,7 +108,8 @@ namespace JAKA
private void btnSend_Click(object sender, EventArgs e)
{
Task.Factory.StartNew(() => {
Task.Factory.StartNew(() =>
{
if (groupBox1.Text.Contains("在线"))
{
string cmd = comboBox1.SelectedItem.ToString();//textBox1.Text;
......@@ -121,12 +122,67 @@ namespace JAKA
private void btnRun_Click(object sender, EventArgs e)
{
Task.Factory.StartNew(() => {
jakaBean.PowerOn();
System.Threading.Thread.Sleep(2000);
jakaBean.EnableRobot();
System.Threading.Thread.Sleep(2000);
jakaBean.Run();
Task.Factory.StartNew(() =>
{
if (jakaBean.PowerOn())
jakaBean.EnableRobot();
});
}
private void timer1_Tick(object sender, EventArgs e)
{
try
{
if (jakaBean.GetDigitalOutput(IOType.IO_CABINET, 0, out bool insafe))
{
lblSafe.BackColor = insafe ? Color.YellowGreen : Color.Red;
}
}
catch
{
}
}
private void UCRobot_Load(object sender, EventArgs e)
{
timer1.Start();
}
private void button1_Click(object sender, EventArgs e)
{
jakaBean.ClearError();
}
private void button2_Click(object sender, EventArgs e)
{
Task.Factory.StartNew(() =>
{
if (groupBox1.Text.Contains("在线"))
{
server.SendCmd(jakaBean.RemoteEndPoint, "home");
}
});
}
private void button3_Click(object sender, EventArgs e)
{
Task.Factory.StartNew(() =>
{
if (groupBox1.Text.Contains("在线"))
{
server.SendCmd(jakaBean.RemoteEndPoint, "standby");
}
});
}
private void button4_Click(object sender, EventArgs e)
{
Task.Factory.StartNew(() =>
{
if (jakaBean.DisableRobot())
jakaBean.PowerOff();
});
}
}
......
......@@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!