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()
......
......@@ -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);
}
......
......@@ -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!