Commit 40e19609 刘韬

稳定版

1 个父辈 1587d8a9
......@@ -36,6 +36,12 @@ namespace OnlineStore.Common
[MyConfigComment("屏蔽日志窗口")]
public static MyConfig<bool> Device_DisableLogWindow = true;
[MyConfigComment("出库任务数量大于值时治具托盘全部从LS3转移走")]
public static MyConfig<int> Device_LS3_MTP2_OutTaskMaxCount = 5;
[MyConfigComment("出库任务数量大于值时料盘托盘全部从LS3转移走")]
public static MyConfig<int> Device_LS3_MTP1_OutTaskMaxCount = 5;
[MyConfigComment("URRobot_MI1_IP")]
public static MyConfig<string> URRobot_MI1_IP;
[MyConfigComment("URRobot_MI1_速度倍率")]
......
......@@ -139,18 +139,16 @@ namespace OnlineStore.Common
return result;
}
static object lockpost = new object();
public static Operation Post(string url, Operation operation, int timeout = 5000, bool printlog = false)
public static Operation Post(string url, Operation operation, int timeout, out string log)
{
log = "";
try
{
string json = JsonHelper.SerializeObject(operation);
string result = Post(url, json, timeout);
Operation op = JsonHelper.DeserializeJsonToObject<Operation>(result);
if (printlog)
{
LogUtil.info("Send [" + json + "] Revice [" + result + "]");
}
log = "Send [" + json + "] Revice [" + result + "]";
return op;
}
catch (Exception ex)
......
......@@ -156,6 +156,7 @@
<Compile Include="userControl\FixtureSizeConfigControl.Designer.cs">
<DependentUpon>FixtureSizeConfigControl.cs</DependentUpon>
</Compile>
<Compile Include="VirtuallyStore\BufferSlotsManger.cs" />
<Compile Include="VirtuallyStore\CommandList.cs" />
<Compile Include="VirtuallyStore\Reference.cs" />
<Compile Include="VirtuallyStore\VMsg.cs" />
......
......@@ -43,7 +43,7 @@ namespace DeviceLibrary
if (canStopLine(out _) && isIOon)//(DOValue(LineIO).Equals(IO_VALUE.HIGH) || DOValue(LineRevIO).Equals(IO_VALUE.HIGH)))
{
IOSTOP();
LogUtil.info(Name + $" 线体管理器 停止线体.");
LogUtil.info("["+ Name+"]" + $" 线体管理器 停止线体.");
}
}
}
......
using OnlineStore.Common;
using OnlineStore;
using OnlineStore.Common;
using Robot.UR;
using System;
using System.Collections.Generic;
......@@ -48,12 +49,14 @@ namespace DeviceLibrary
{
RobotStatus = false;
//Msg.add(POS_Start + "机器人状态异常:" + Robot.CurDashboardReponse, MsgLevel.alarm);
robot.PlayProgram();
robot.StopProgram();
}
else if (!robot.ClientIsConnected) {
RobotStatus = false;
robot.StopProgram();
Thread.Sleep(300);
robot.StopRobot();
}
else
RobotStatus = true;
......@@ -61,7 +64,7 @@ namespace DeviceLibrary
public void Move(MoveInfo moveInfo, int movecmd) {
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitAction(new Func<WaitResultInfo, bool>(IsMoveOk), "等待" + $"[{robot.Name}]" + "移动到位"));
moveInfo.WaitList.Add(WaitResultInfo.WaitAction(new Func<WaitResultInfo, bool>(IsMoveOk), crc.GetString("Res0157","等待") + $"[{robot.Name}]" + crc.GetString("Res0057","移动到位")));
}
lastMoveCmd = movecmd;
robot.SendMoveCmd(movecmd, Setting_Init.URRobot_MI1_Speed_Rate);
......@@ -91,4 +94,4 @@ namespace DeviceLibrary
RobotCheck.Enabled = false;
}
}
}
}
\ No newline at end of file
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using RemoteSheardObject;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
......@@ -12,7 +13,7 @@ using System.Threading.Tasks;
namespace DeviceLibrary
{
class ServerCommunication
public class ServerCommunication
{
volatile StoreStatus _storeStatus = StoreStatus.Debugging;
public StoreStatus storeStatus {
......@@ -41,10 +42,18 @@ namespace DeviceLibrary
GC.KeepAlive(serverConnectTimer);
LogUtil.info($"server:{server},cid:{CID}");
}
public int OutMaterialTaskCount = 0;
public int OutReelTaskCount = 0;
private void ServerConnectTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
if (!string.IsNullOrEmpty(server) && server.ToLower().StartsWith("http"))
{
var data = TheLine.GetTaskCount();
OutMaterialTaskCount = data["pizzaBox"] + data["pcb"] + data["tray"];
OutReelTaskCount = data["reel"];
}
//if (!RobotManage.isRunning)
// ProcessMsg(MsgService.MSList);
//if (!string.IsNullOrWhiteSpace(server))
......@@ -54,7 +63,8 @@ namespace DeviceLibrary
{
LogUtil.info($"ServerConnectTimer_Elapsed:{ex}");
}
finally {
finally
{
//Monitor.Exit(serverConnectTimer);
}
}
......@@ -75,7 +85,7 @@ namespace DeviceLibrary
}
).Where(x=>!string.IsNullOrEmpty(x)));
}
public void SendInStoreRequest(string[] codelist, ReelParam reel,bool printlog=false) {
public void SendInStoreRequest(string[] codelist, ReelParam reel) {
if (RobotManage.InoutDebugMode)
return;
......@@ -86,11 +96,12 @@ namespace DeviceLibrary
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", code }, { "boxId", StoreID.ToString() }, { "doorReelSignal", "1" } };
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 15000, printlog);
Operation resultOperation = OnlineStore.Common.HttpHelper.Post(GetPostApi(), operation, 15000, out string log);
if (resultOperation==null || operation.seq != resultOperation.seq)
{
LogUtil.error(log);
Thread.Sleep(1000);
SendInStoreRequest(codelist, reel, printlog);
SendInStoreRequest(codelist, reel);
return;
}
ResultProcess(resultOperation);
......@@ -109,7 +120,7 @@ namespace DeviceLibrary
LogUtil.info(JsonHelper.SerializeObject(operation));
if (RobotManage.InoutDebugMode)
return true;
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 15000);
Operation resultOperation = OnlineStore.Common.HttpHelper.Post(GetPostApi(), operation, 15000,out _);
if (resultOperation == null)
{
......@@ -253,7 +264,7 @@ namespace DeviceLibrary
printlog = true;
}
Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation,700, printlog);
Operation resultOperation = OnlineStore.Common.HttpHelper.Post(GetPostApi(), lineOperation,700, out string log);
if (resultOperation != null)
getthtime = 0;
//LogUtil.info(JsonHelper.SerializeObject(resultOperation.data));
......
using Newtonsoft.Json;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
class BufferSlotsManger
{
Dictionary<string, BufferSlotInfo> bufferSlotInfos = new Dictionary<string, BufferSlotInfo>();
string DeviceName;
public BufferSlotsManger(string devicename)
{
DeviceName = devicename;
LoadData();
for (int i = 0; i < 8; i++)
{
string sloatkey = DeviceName + "_B0" + (i + 1);
if (!bufferSlotInfos.ContainsKey(sloatkey))
{
bufferSlotInfos.Add(sloatkey, new BufferSlotInfo(sloatkey));
}
}
}
public string GetFreeSlot()
{
lock (bufferSlotInfos)
{
var slot = bufferSlotInfos.Values.ToList().Find(s => !s.HasReel);
return slot?.Name;
}
}
public string GetInstoreSlot(out JobInfo jobInfo)
{
lock (bufferSlotInfos)
{
var slot = bufferSlotInfos.Values.ToList().Find(s => s.HasReel && s.IsInstore);
jobInfo = slot?.JobInfo.Clone();
return slot?.Name;
}
}
public string GetOutstoreSlot(out JobInfo jobInfo)
{
lock (bufferSlotInfos)
{
var slot = bufferSlotInfos.Values.ToList().Find(s => s.HasReel && !s.IsInstore);
jobInfo = slot?.JobInfo.Clone();
return slot?.Name;
}
}
public void SetSlotInfo(string name, bool isinstore, JobInfo jobInfo)
{
lock (bufferSlotInfos)
{
bufferSlotInfos[name].IsInstore = isinstore;
bufferSlotInfos[name].JobInfo = jobInfo.Clone();
bufferSlotInfos[name].HasReel = true;
}
SaveData();
}
public void ClearSlot(string name)
{
lock (bufferSlotInfos)
{
bufferSlotInfos[name].HasReel = false;
}
SaveData();
}
void LoadData() {
string filename = $"Config\\BufferSlotsList_{DeviceName}.temp";
if (File.Exists(filename))
{
bool isreadok = false;
try
{
var tl = File.ReadAllText(filename);
bufferSlotInfos = JsonConvert.DeserializeObject<Dictionary<string, BufferSlotInfo>>(tl);
isreadok = bufferSlotInfos != null;
if (!isreadok)
LogUtil.error("启动时缓存料盘信息加载失败:"+DeviceName);
}
catch (Exception ex)
{
LogUtil.error("启动时缓存料盘信息加载失败:" + DeviceName + ex);
}
if (isreadok)
return;
try
{
var tl = File.ReadAllText(filename+"~");
bufferSlotInfos = JsonConvert.DeserializeObject<Dictionary<string, BufferSlotInfo>>(tl);
if (bufferSlotInfos == null)
{
LogUtil.error("启动时备份缓存料盘加载失败:"+DeviceName);
bufferSlotInfos = new Dictionary<string, BufferSlotInfo>();
}
}
catch (Exception ex)
{
LogUtil.error("启动时托盘备份信息加载失败:" + ex);
bufferSlotInfos = new Dictionary<string, BufferSlotInfo>();
}
}
}
void SaveData() {
string filename = $"Config\\BufferSlotsList_{DeviceName}.temp";
try
{
var TL = bufferSlotInfos.Where(t => t.Value.HasReel).ToDictionary(a => a.Key, a => a.Value);
ConfigHelper.Config.FileSave(JsonConvert.SerializeObject(TL), filename+"~");
ConfigHelper.Config.FileSave(JsonConvert.SerializeObject(TL), filename);
}
catch (Exception ex)
{
LogUtil.error("托盘信息保存失败:" + ex);
}
}
}
class BufferSlotInfo {
public string Name;
public bool HasReel;
public bool IsInstore;
public JobInfo JobInfo;
public BufferSlotInfo(string name) {
Name = name;
}
}
}
......@@ -15,14 +15,20 @@ namespace DeviceLibrary
Prefix = prefix;
log = LogManager.GetLogger(logname);
}
string lastinfo = "";
public void Info(string txt) {
if (String.Compare(lastinfo, txt, StringComparison.Ordinal) == 0)
return;
if (Prefix != "")
txt =$"[{Prefix}] "+ txt;
log.Info(txt);
}
string lasterr = "";
public void Error(string txt)
{
if (String.Compare(lasterr, txt, StringComparison.Ordinal) == 0)
return;
if (Prefix != "")
txt = $"[{Prefix}] " + txt;
log.Error(txt);
......
......@@ -114,20 +114,20 @@ namespace DeviceLibrary
LogUtil.info(JsonHelper.SerializeObject(operation));
if (RobotManage.InoutDebugMode)
return true;
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 5000);
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 5000,out string log);
if (resultOperation == null)
{
LogUtil.info($"SendStoreState error,posid:{barcode}, storeStatus:{storeStatus}");
VLog.Error($"SendStoreState error,posid:{barcode}, storeStatus:{storeStatus}");
return false;
}
if (operation.seq != resultOperation.seq)
{
LogUtil.info($"SendStoreState seq error,posid:{barcode}, storeStatus:{storeStatus}");
VLog.Error($"SendStoreState seq error,posid:{barcode}, storeStatus:{storeStatus}");
return false;
}
LogUtil.info($"SendStoreState success,posid:{barcode}, storeStatus:{storeStatus}");
VLog.Info(log);
VLog.Info($"SendStoreState success,posid:{barcode}, storeStatus:{storeStatus}");
ResultProcess(resultOperation);
}
return true;
......@@ -238,7 +238,7 @@ namespace DeviceLibrary
printlog = true;
}
Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation,700, printlog);
Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation,700, out string log);
if (resultOperation != null)
getthtime = 0;
//LogUtil.info(JsonHelper.SerializeObject(resultOperation.data));
......@@ -407,7 +407,7 @@ namespace DeviceLibrary
else
{
JobInfo jobInfo = new JobInfo(code, posIdStr, plateW, plateH);
OutStoreEvent?.Invoke("服务器", jobInfo);
OutStoreEvent?.Invoke(crc.GetString("Res0064","服务器"), jobInfo);
}
TimeSpan span = DateTime.Now - time;
......
......@@ -92,7 +92,12 @@ namespace DeviceLibrary
MsgService.MSList["RT-" + vs.CID].clear();
vs.VTowerProcess();
}
finally {
catch (Exception ex)
{
VLog.Error("VTowerProcess error:"+ex);
}
finally
{
MsgService.MSList["RT-" + vs.CID].Show();
}
});
......
......@@ -33,10 +33,18 @@ namespace DeviceLibrary
LogUtil.info($"{DeviceListName}设备线程启动");
while (RobotManage.mainMachine.mstart)
{
Thread.Sleep(200);
Thread.Sleep(150);
ManualResetEvent.WaitAll(new ManualResetEvent[] { RobotManage.mainMachine.ResetEvent });
if (!RobotManage.mainMachine.canRunning || !RobotManage.mainMachine.mstart)
continue;
{
if (RobotManage.mainMachine.mstart) {
DevicesList.ForEach(x =>
{
x.FrontStopProcess();
});
}
continue;
}
DevicesList.ForEach(x =>
{
try
......@@ -47,6 +55,7 @@ namespace DeviceLibrary
{
MsgService.MSList[x.GroupName].add(ex.ToString(), MsgLevel.warning);
MsgService.MSList[x.GroupName].setlogones();
LogUtil.error($"{DeviceListName} 出错:"+ ex);
}
finally
{
......
......@@ -33,7 +33,7 @@ namespace DeviceLibrary
public Dictionary<string, DeviceGroup> DeviceGroup { get=>RobotManage.DeviceGroup; }
public bool UserPause { get; set; } = false;
ServerCommunication ServerCM;
public ServerCommunication ServerCM;
public ManualResetEvent ResetEvent = new ManualResetEvent(true);
......@@ -90,14 +90,15 @@ namespace DeviceLibrary
while (mstart) {
try
{
canRunning = DeviceCheck();
canRunning = DeviceCheck();
if (canRunning)
{
ResetEvent.Set();
BtnProcess();
canRunning = SafeCheck();
}
Thread.Sleep(200);
Thread.Sleep(150);
ResetEvent.Set();
if (!canRunning || !mstart)
continue;
if (runStatus == RunStatus.Running)
......@@ -155,6 +156,11 @@ namespace DeviceLibrary
}
public void Stop() {
mstart = false;
DeviceSnapshot();
SideMove.DeviceList.Values.ToList().ForEach(s => s.Stop());
TransplantMove.DeviceList.Values.ToList().ForEach(s => s.Stop());
TrayStop.DeviceList.Values.ToList().ForEach(s => s.Stop());
MI.DeviceList.Values.ToList().ForEach(s => s.Stop());
IOMove(IO_Type.Line_Run, IO_VALUE.LOW);
ResetEvent.Set();
Alarm(AlarmType.None);
......@@ -290,5 +296,34 @@ namespace DeviceLibrary
}
return ok;
}
public void DeviceSnapshot()
{
LogUtil.info("===开始记录系统当前情况.===");
MoveInfo.List.ForEach(m => {
LogUtil.info($"\t{m.Name}: {m.MoveStep}\t{m.MoveParam.ToStr()}");
});
AxisBean.List.ToList().ForEach(al => {
al.Value.ForEach(ax => {
LogUtil.info($"\t{ax.AxisName}: {ax.GetAclPosition()}");
});
});
VStoreCollection.VStoreList.Values.ToList().ForEach(vs => {
LogUtil.info($"\t{vs.TowerName}\t{vs.CID}: {vs.RTStoreStatus}\tCurrentTerminalReelID:{vs.CurrentTerminalReelID}\tInStoreJobInfo:{vs.InStoreJobInfo?.ToStr()}");
});
ConfigHelper.Config.Configlist.ToList().ForEach(cc => {
LogUtil.info($"\t{cc.Key}: {cc.Value}");
});
MsgService.MSList.ToList().ForEach(msl =>
{
msl.Value.get().ToList().ForEach(cc =>
{
LogUtil.info($"\t{cc.datetime}\t{cc.msgLevel}\t{cc.msgtxt} ");
});
});
LogUtil.info("===记录结束.===");
}
}
}
\ No newline at end of file
......@@ -116,6 +116,7 @@ namespace DeviceLibrary
MI_08,
MI_09,
MI_10,
MI_ReelTacked,
MI_11,
MI_12,
MI_13,
......
......@@ -74,10 +74,13 @@ namespace DeviceLibrary
case "IsFree":
isok = TrayManager.IsFree(remoteLoad);
break;
case "IsNeedProcessNG":
isok = TrayManager.IsNeedProcessNG(remoteLoad);
break;
case "OK":
case "FAIL":
lastresult[Seq] = remoteLoad.Action == "OK" ? RemoteResult.True : RemoteResult.False;
LogUtil.info("Revice Command Callback:" + remoteLoad.GroupName + " - " + remoteLoad.Action);
LogUtil.info($"[{remoteLoad.GroupName}] Revice Command Callback:" + remoteLoad.Action);
return;
default:
break;
......@@ -100,7 +103,7 @@ namespace DeviceLibrary
allClients[deviceGroupName].Send(JsonConvert.SerializeObject(message));
}
catch (Exception ex){
LogUtil.info($"设备:{deviceGroupName} 消息发送出错:"+ex.ToString());
LogUtil.error($"设备:{deviceGroupName} 消息发送出错:"+ex.ToString());
}
}
......@@ -109,7 +112,7 @@ namespace DeviceLibrary
remoteLoad.GroupName = GroupName;
if (remoteLoad.RequestLoadInfo != null && string.IsNullOrEmpty(remoteLoad.RequestLoadInfo.DeviceGroupName))
remoteLoad.RequestLoadInfo.DeviceGroupName = GroupName;
LogUtil.info($"{GroupName},发送:{remoteLoad.Action},Seq:{remoteLoad.Seq}");
LogUtil.info($"[{GroupName}],发送:{remoteLoad.Action},Seq:{remoteLoad.Seq}");
lastresult[remoteLoad.Seq] = RemoteResult.None;
SendMessage(GroupName, remoteLoad);
return WaitResult(GroupName, remoteLoad.Seq,waittime);
......@@ -118,22 +121,30 @@ namespace DeviceLibrary
{
if (!lastresult.ContainsKey(seq))
return RemoteResult.Timeout;
while (lastresult[seq] == RemoteResult.None && waittime > 0)
{
System.Threading.Thread.Sleep(50);
waittime = waittime - 50;
}
if (lastresult[seq] == RemoteResult.None)
{
LogUtil.info($"等待{GroupName}反馈超时 seq:"+seq);
lastresult[seq] = RemoteResult.Timeout;
}
var result = lastresult[seq];
lock (lastresult)
try
{
lastresult.Remove(seq);
while (lastresult[seq] == RemoteResult.None && waittime > 0)
{
System.Threading.Thread.Sleep(50);
waittime = waittime - 50;
}
if (lastresult[seq] == RemoteResult.None)
{
LogUtil.info($"等待{GroupName}反馈超时 seq:" + seq);
lastresult[seq] = RemoteResult.Timeout;
}
var result = lastresult[seq];
lock (lastresult)
{
lastresult.Remove(seq);
}
return result;
}
return result;
catch(Exception ex) {
LogUtil.error($"等待{GroupName}反馈超时 seq:" + seq +" 出错:"+ex);
return RemoteResult.Timeout;
}
}
public static void SendResult(string deviceGroupName, bool result,long Seq)
{
......
......@@ -190,6 +190,7 @@ namespace DeviceLibrary
LogUtil.info("用户暂停");
else
LogUtil.info("系统暂停: "+msg);
mainMachine.DeviceSnapshot();
Thread.Sleep(500);
}
else
......
......@@ -37,10 +37,11 @@ namespace DeviceLibrary
Traylist[rfid].LastAddr = addr;
Traylist[rfid].Destination = TrayManager.AddrDesc[Traylist[rfid].DestinationAddr];
Traylist[rfid].LastPosition = TrayManager.AddrDesc[Traylist[rfid].LastAddr];
if (reelcheck == 0)
Traylist[rfid].HasLoadCheck--;
else if (reelcheck == 1)
Traylist[rfid].HasLoadCheck = 1;
if (Traylist[rfid].TrayType == TrayTypeE.MTP1 && (addr == 16 || addr == 20 || addr == 5 || addr == 3))
Traylist[rfid].HasLoadCheck += reelcheck == 0 ? -1 : 1;
else if (Traylist[rfid].TrayType == TrayTypeE.MTP2)
Traylist[rfid].HasLoadCheck += reelcheck == 0 ? -1 : 1;
trayInfo = Traylist[rfid];
//Statistics();
}
......@@ -56,6 +57,12 @@ namespace DeviceLibrary
lock (Traylist)
{
LogUtil.info($"SetTrayLoadInfo:{rfid},{requestLoadInfo?.LoadParam?.ToStr()},{requestLoadInfo?.DeviceGroupName}");
if (!Traylist.ContainsKey(rfid)) {
Traylist.Add(rfid, new TrayInfo());
Traylist[rfid].RFID = rfid;
Traylist[rfid].LastUpdateTime = DateTime.Now;
}
if (requestLoadInfo == null)
{
Traylist[rfid].SetToEmpty();
......@@ -131,13 +138,21 @@ namespace DeviceLibrary
TrayRequest[remoteLoad.GroupName] = remoteLoad.RequestLoadInfo;
}
}
public static bool CalcNeedTrans(int curaddr1, int destaddr1, bool hasload) {
public static bool CalcNeedTrans(int curaddr1, int destaddr1, bool hasload,TrayTypeE trayType) {
if (!hasload)
{
var addrs = TrayRequest.Values.Select(x => new { TaryType = x.GetTrayType, Addr = GetAddrByGroupName(x.DeviceGroupName) }).ToList();
if (curaddr1 == 19 && RobotManage.mainMachine.ServerCM.OutMaterialTaskCount > Setting_Init.Device_LS3_MTP2_OutTaskMaxCount && trayType== TrayTypeE.MTP2)
{
return true;
}
if (curaddr1 == 19 && RobotManage.mainMachine.ServerCM.OutReelTaskCount > Setting_Init.Device_LS3_MTP1_OutTaskMaxCount && trayType == TrayTypeE.MTP1)
{
return true;
}
var addrs = TrayRequest.Values.Where(x=>x.TrayType==trayType.ToString()).Select(x => new { TaryType = x.GetTrayType, Addr = GetAddrByGroupName(x.DeviceGroupName) }).ToList();
foreach (var a in addrs)
{
var trayaddrs = TrayManager.Traylist.Values.Where(t => (DateTime.Now - t.LastUpdateTime).TotalSeconds < 30 && t.TrayType == a.TaryType && !hasload).Select(t => t.LastAddr).ToList();
var trayaddrs = TrayManager.Traylist.Values.Where(t => (DateTime.Now - t.LastUpdateTime).TotalSeconds < 60 && t.TrayType == a.TaryType && !hasload).Select(t => t.LastAddr).ToList();
if (trayaddrs.Count == 0)
return false;
......@@ -252,6 +267,17 @@ namespace DeviceLibrary
}
return false;
}
/// <summary>
/// 是否需要等待处理NG物料
/// </summary>
/// <param name="remoteLoad"></param>
/// <returns></returns>
public static bool IsNeedProcessNG(RemoteLoad remoteLoad)
{
var requestLoadInfo = remoteLoad.RequestLoadInfo;
var xx = TrayManager.Traylist.Values.ToList().Where(t => t.HasLoad && t.LoadType == requestLoadInfo.GetTrayType && (t.LastAddr >= 20 || t.LastAddr < 2));
return xx.Count() > 0;
}
/// <summary>
/// 空托盘数量
......
......@@ -17,6 +17,7 @@ namespace DeviceLibrary
void TrayRelease();
bool IsFree();
bool FrontCheck(int curaddr);
void FrontStopProcess();
}
public enum DeviceStateE
......
......@@ -69,6 +69,8 @@ namespace DeviceLibrary
{
DeviceState = DeviceStateE.Stop;
MoveInfo.log("停止运行");
Task.Run(() => { Task.Delay(1000).Wait(); IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.LOW); });
}
public void Process()
{
......@@ -147,7 +149,7 @@ namespace DeviceLibrary
if (IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.HIGH))
{
RemoteLoad remoteLoad1 = new RemoteLoad();
remoteLoad1.Seq = DateTime.Now.Ticks;
remoteLoad1.Seq = Snowflake.Instance().GetId();
remoteLoad1.Action = "DoorLock";
remoteLoad1.RequestLoadInfo = new RequestLoadInfo();
remoteLoad1.RequestLoadInfo.IsEmpty = false;
......@@ -188,7 +190,7 @@ namespace DeviceLibrary
if (IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.LOW))
{
RemoteLoad remoteLoad2 = new RemoteLoad();
remoteLoad2.Seq = DateTime.Now.Ticks;
remoteLoad2.Seq = Snowflake.Instance().GetId();
remoteLoad2.Action = "DoorLock";
remoteLoad2.RequestLoadInfo = new RequestLoadInfo();
remoteLoad2.RequestLoadInfo.IsEmpty = true;
......@@ -248,7 +250,7 @@ namespace DeviceLibrary
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.LOW);
MoveInfo.NextMoveStep(MoveStep.Wait);
if (GroupName == "AMH-SBSH2")
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(4000));
MoveInfo.log("托盘已放行");
} else if (MoveInfo.IsTimeOut(10)) {
MoveInfo.log("托盘放行失败,重新放行");
......@@ -293,7 +295,7 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.TransplantMove_14);
MoveInfo.log("检测到物料已离开");
}
else {
else if (MoveInfo.IsTimeOut(1)) {
MetrialGetRetry++;
if (MetrialGetRetry > 3) {
Msg.add($"{MoveInfo.Name}取料失败", MsgLevel.alarm);
......@@ -368,7 +370,7 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.TransplantMove_24);
var remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.Seq = Snowflake.Instance().GetId();
remoteLoad.Action = "DoorRelease";
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.IsEmpty = true;//true出库 false入库
......@@ -427,7 +429,7 @@ namespace DeviceLibrary
IOMove(IO_Type.AMH_Sucker, IO_VALUE.LOW);
IOMove(IO_Type.AMH_Sucker_Release, IO_VALUE.HIGH,2000);
ConfigHelper.Config.Set($"Runtime_{GroupName}_IsSucker", false);
TheLine.UpdateLocInfo("", MoveInfo.MoveParam.WareCode, TheLine.LineStatusE.BOXDOOR, GroupName);
//TheLine.UpdateLocInfo("", MoveInfo.MoveParam.WareCode, TheLine.LineStatusE.BOXDOOR, GroupName);
break;
case MoveStep.TransplantMove_27:
......@@ -502,7 +504,7 @@ namespace DeviceLibrary
case MoveStep.TransplantMove_06:
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Action = "DoorRelease";
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.Seq = Snowflake.Instance().GetId();
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.IsEmpty=false;
remoteLoad.RequestLoadInfo.LoadParam = MoveInfo2.MoveParam.clone();
......@@ -607,10 +609,12 @@ namespace DeviceLibrary
public bool IsFree()
{
if (MoveInfo2.MoveStep != MoveStep.Wait) {
if (MoveInfo2.MoveStep != MoveStep.Wait || MoveInfo.MoveStep > MoveStep.TransplantMove_26) {
return false;
}
if (MoveInfo.MoveStep >= MoveStep.TransplantMove_10 && MoveInfo.MoveStep <= MoveStep.TransplantMove_20)
return false;
return true;
}
......@@ -624,5 +628,13 @@ namespace DeviceLibrary
MoveInfo.NewMove(MoveStep.H01_HomeReset);
MoveInfo.log("开始重置");
}
public void FrontStopProcess()
{
if (IOValue(IO_Type.AMH_Front_Check).Equals(IO_VALUE.LOW))
{
IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.LOW);
}
}
}
}
\ No newline at end of file
......@@ -72,6 +72,8 @@ namespace DeviceLibrary
{
DeviceState = DeviceStateE.Stop;
MoveInfo.log("停止运行");
Task.Run(() => { Task.Delay(1000).Wait(); IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.LOW); });
}
public void Process()
{
......@@ -211,7 +213,7 @@ namespace DeviceLibrary
//空托盘
MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.Seq = Snowflake.Instance().GetId();
remoteLoad.Action = "TrayReady";
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.TrayType = trayInfo.TrayType.ToString();
......@@ -229,7 +231,7 @@ namespace DeviceLibrary
//有物料
MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.Seq = Snowflake.Instance().GetId();
remoteLoad.Action = "TrayReady";
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.TrayType = trayInfo.TrayType.ToString();
......@@ -368,7 +370,7 @@ namespace DeviceLibrary
{
if (IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.LOW))
{
Msg.add("托盘放料后没有检测到物料", MsgLevel.alarm);
Msg.add(crc.GetString("Res0062","托盘放料后没有检测到物料"), MsgLevel.alarm);
return;
}
}
......@@ -383,7 +385,7 @@ namespace DeviceLibrary
if (GroupName == "AMH-ML5-1" || GroupName == "AMH-ML5-2")
{
var remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.Seq = Snowflake.Instance().GetId();
remoteLoad.Action = "IsSafe";
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
var result = RemoteService.SendAndWait(GroupName, remoteLoad,6000);
......@@ -421,7 +423,7 @@ namespace DeviceLibrary
/// 释放托盘
/// </summary>
public void TrayRelease() {
MoveInfo.log("释放托盘");
MoveInfo.log("释放托盘:" + CurrrentRFID);
MoveInfo.NextMoveStep(MoveStep.TrayStop_LoadProcessed);
if (TrayManager.Traylist.ContainsKey(CurrrentRFID) && TrayManager.Traylist[CurrrentRFID].HasLoad)
{
......@@ -453,7 +455,7 @@ namespace DeviceLibrary
if (GroupName == d && MI.DeviceList[d].DeviceState != DeviceStateE.Run
&& MI.DeviceList[d].MoveInfo.MoveStep != MoveStep.Wait)
{
Msg.add("等待" + d + "完成复位", MsgLevel.warning);
Msg.add(crc.GetString("Res0157","等待") + d + crc.GetString("Res0063","完成复位"), MsgLevel.warning);
}
else if (GroupName == d && MI.DeviceList[d].DeviceState == DeviceStateE.Run
&& MI.DeviceList[d].MoveInfo.MoveStep != MoveStep.Wait)
......@@ -497,5 +499,13 @@ namespace DeviceLibrary
{
return IOValue(IO_Type.MI_Front_Check).Equals(IO_VALUE.LOW);
}
public void FrontStopProcess()
{
if (IOValue(IO_Type.MI_Front_Check).Equals(IO_VALUE.LOW))
{
IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.LOW);
}
}
}
}
\ No newline at end of file
......@@ -26,9 +26,6 @@ namespace DeviceLibrary
public AxisMoveControl()
{
InitializeComponent();
if (DesignMode)
return;
this.Tag = "not";
crc.OpenResourceLog = true;
crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
crc.CurrLanguage = Setting_Init.Device_Default_Language;
......@@ -56,7 +53,7 @@ namespace DeviceLibrary
currentAxis = axisList[0];
PortName = axisList[0].Config.DeviceName;
SlvAddr = axisList[0].Config.GetAxisValue();
txtAxisDeviceName.Text = PortName;
//txtAxisDeviceName.Text = PortName;
txtAxisValue.Text = SlvAddr.ToString();
}
btnAddMove.BackColor = Color.White;
......@@ -227,7 +224,7 @@ namespace DeviceLibrary
axis = axisList[cmbAxis.SelectedIndex].Config;
PortName = axis.DeviceName;
SlvAddr = axis.GetAxisValue();
txtAxisDeviceName.Text = PortName;
//txtAxisDeviceName.Text = PortName;
txtAxisValue.Text = SlvAddr.ToString();
Color color = Color.Black;
......@@ -348,15 +345,15 @@ namespace DeviceLibrary
private void timer1_Tick(object sender, EventArgs e)
{
//LogUtil.OutputDebugString($"timer1_Tick:{this.Visible}");
if (this.Visible && !DesignMode)
LogUtil.OutputDebugString($"timer1_Tick:{this.Visible}");
if (this.Visible)
{
ReadAxisStatus();
}
}
private void ReadAxisStatus()
{
groupBox2.Text = cmbAxis.Text + "-"+crc.GetString("Res0189","状态监控");
groupBox2.Text = cmbAxis.Text + "-" + crc.GetString("AxisMoveControl_groupAxis_groupBox2_Text","状态监控");
//【1】更新轴号
short axisNo = SlvAddr;
if (axisNo < 0)
......@@ -396,9 +393,9 @@ namespace DeviceLibrary
{
return;
}
ShowlbSts(lblPEL, sts.PEL); //正限位信号
//ShowlbSts(lblPEL, sts.PEL); //正限位信号
ShowlbSts(lblORG, sts.ORG); //原点信号
ShowlbSts(lblNEL, sts.NEL); //负限位信号
//ShowlbSts(lblNEL, sts.NEL); //负限位信号
//label59.Text = ConvertDecimalToBinary(nTimerAxSts[0]); //轴状态是按bit进行解读,因此这里将AxSts转换为二进制bit进行显示
lblAxPrfPos.Text = HCBoardManager.GetAxisPrfPos(axisNo).ToString();
......@@ -447,12 +444,5 @@ namespace DeviceLibrary
lbl.BackColor = this.BackColor;
}
}
private void lblAlarmcode_Click(object sender, EventArgs e)
{
var s = string.Join(",", HuichuanLibrary.HCBoardManager.GetAxisErrorDetail(SlvAddr));
MessageBox.Show(s);
LogUtil.error(s);
}
}
}
\ No newline at end of file
......@@ -206,7 +206,36 @@ public class ReelParam
return $":[{PosID}][{WareCode}][{RFID}][{PlateW}x{PlateH}]";
}
}
bool islog = false;
public void logresult()
{
if (!islog)
{
islog = true;
var datetime = DateTime.Now;
string countfile = $"\\Logs\\NGLOG_{datetime:yyyyMMdd}.csv";
Directory.CreateDirectory("\\Logs\\");
if (!File.Exists(countfile))
{
StreamWriter sw1 = new StreamWriter(countfile, true, Encoding.GetEncoding("GB2312"));
sw1.WriteLine($"WareCode,SN,PN,Date,NgMsg");
sw1.Close();
sw1.Dispose();
}
try
{
var sw = new StreamWriter(countfile, true, Encoding.GetEncoding("GB2312"));
//var sw = File.Open(countfile, FileMode.Append, FileAccess.Write);
// string s = $"\r\n{ReeID},{PN},{PlateW}x{PlateH},{ReelDest},{NgMsg},{QTY},{WareCode}";
//var b = Encoding.GetEncoding("gb2312").GetBytes(s);
//sw.Write(b, 0, b.Length);
sw.WriteLine($"{WareCode},{RI},{PN},{datetime:yyyy/MM/dd HH:mm:ss},{NgMsg}");
sw.Close();
sw.Dispose();
}
catch { }
}
}
}
public enum DoorStatusE {
Busy,
......
......@@ -46,7 +46,7 @@ public class RemoteClient
{
if (LastState != webSocket.State)
{
LOGGER.Info($"Remote:{GroupName} 掉线了");
LOGGER.Error($"Remote:{GroupName} 掉线了");
}
LastState = webSocket.State;
}
......@@ -68,7 +68,7 @@ public class RemoteClient
else if (webSocket.State == WebSocket4Net.WebSocketState.Connecting) {
errstatuscounr++;
if (errstatuscounr > 5) {
LOGGER.Info($"Remote:{GroupName} Connecting 超时");
LOGGER.Error($"Remote:{GroupName} Connecting 超时");
try { webSocket.Close(); } catch { }
webSocket.Open();
errstatuscounr = 0;
......@@ -87,7 +87,7 @@ public class RemoteClient
}
catch
{
LOGGER.Info("Cant Deserialize remote command:" + e.Message);
LOGGER.Error("Cant Deserialize remote command:" + e.Message);
return;
}
switch (remoteLoad.Action)
......@@ -124,7 +124,7 @@ public class RemoteClient
}
if (lastresult == RemoteResult.None)
{
LOGGER.Info("等待远程反馈超时");
LOGGER.Error("等待远程反馈超时");
timeoutCount++;
lastresult = RemoteResult.Timeout;
if (timeoutCount > 3)
......
......@@ -94,6 +94,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RemoteClient.cs" />
<Compile Include="SLog.cs" />
<Compile Include="Snowflake.cs" />
<Compile Include="StoreCID.cs" />
<Compile Include="TheLine.cs" />
</ItemGroup>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace RemoteSheardObject
{
/// <summary>
/// 动态生产有规律的ID Snowflake算法是Twitter的工程师为实现递增而不重复的ID实现的
/// http://blog.csdn.net/w200221626/article/details/52064976
/// C# 实现 Snowflake算法
/// </summary>
public class Snowflake
{
private static long machineId;//机器ID
private static long datacenterId = 0L;//数据ID
private static long sequence = 0L;//计数从零开始
private static long twepoch = 687888001020L; //唯一时间随机量
private static long machineIdBits = 5L; //机器码字节数
private static long datacenterIdBits = 5L;//数据字节数
public static long maxMachineId = -1L ^ -1L << (int)machineIdBits; //最大机器ID
private static long maxDatacenterId = -1L ^ (-1L << (int)datacenterIdBits);//最大数据ID
private static long sequenceBits = 12L; //计数器字节数,12个字节用来保存计数码
private static long machineIdShift = sequenceBits; //机器码数据左移位数,就是后面计数器占用的位数
private static long datacenterIdShift = sequenceBits + machineIdBits;
private static long timestampLeftShift = sequenceBits + machineIdBits + datacenterIdBits; //时间戳左移动位数就是机器码+计数器总字节数+数据字节数
public static long sequenceMask = -1L ^ -1L << (int)sequenceBits; //一微秒内可以产生计数,如果达到该值则等到下一微妙在进行生成
private static long lastTimestamp = -1L;//最后时间戳
private static object syncRoot = new object();//加锁对象
static Snowflake snowflake;
public static Snowflake Instance()
{
if (snowflake == null)
snowflake = new Snowflake();
return snowflake;
}
public Snowflake()
{
Snowflakes(0L, -1);
}
public Snowflake(long machineId)
{
Snowflakes(machineId, -1);
}
public Snowflake(long machineId, long datacenterId)
{
Snowflakes(machineId, datacenterId);
}
private void Snowflakes(long machineId, long datacenterId)
{
if (machineId >= 0)
{
if (machineId > maxMachineId)
{
throw new Exception("机器码ID非法");
}
Snowflake.machineId = machineId;
}
if (datacenterId >= 0)
{
if (datacenterId > maxDatacenterId)
{
throw new Exception("数据中心ID非法");
}
Snowflake.datacenterId = datacenterId;
}
}
/// <summary>
/// 生成当前时间戳
/// </summary>
/// <returns>毫秒</returns>
private static long GetTimestamp()
{
//让他2000年开始
return (long)(DateTime.UtcNow - new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
}
/// <summary>
/// 获取下一微秒时间戳
/// </summary>
/// <param name="lastTimestamp"></param>
/// <returns></returns>
private static long GetNextTimestamp(long lastTimestamp)
{
long timestamp = GetTimestamp();
int count = 0;
while (timestamp <= lastTimestamp)//这里获取新的时间,可能会有错,这算法与comb一样对机器时间的要求很严格
{
count++;
if (count > 10)
throw new Exception("机器的时间可能不对");
Thread.Sleep(1);
timestamp = GetTimestamp();
}
return timestamp;
}
/// <summary>
/// 获取长整形的ID
/// </summary>
/// <returns></returns>
public long GetId()
{
lock (syncRoot)
{
long timestamp = GetTimestamp();
if (Snowflake.lastTimestamp == timestamp)
{ //同一微妙中生成ID
sequence = (sequence + 1) & sequenceMask; //用&运算计算该微秒内产生的计数是否已经到达上限
if (sequence == 0)
{
//一微妙内产生的ID计数已达上限,等待下一微妙
timestamp = GetNextTimestamp(Snowflake.lastTimestamp);
}
}
else
{
//不同微秒生成ID
sequence = 0L;
}
if (timestamp < lastTimestamp)
{
throw new Exception("时间戳比上一次生成ID时时间戳还小,故异常");
}
Snowflake.lastTimestamp = timestamp; //把当前时间戳保存为最后生成ID的时间戳
long Id = ((timestamp - twepoch) << (int)timestampLeftShift)
| (datacenterId << (int)datacenterIdShift)
| (machineId << (int)machineIdShift)
| sequence;
return Id;
}
}
}
}
using ConfigHelper;
using ConfigHelper;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
......@@ -33,6 +33,10 @@ namespace RemoteSheardObject
return !string.IsNullOrEmpty(SubmitPostData("/service/store/robotBox/updateLocInfo", postData));
}
/// <summary>
/// 获取正在进行的任务数量
/// </summary>
/// <returns></returns>
public static Dictionary<string,int> GetTaskCount()
{
//pizzaBox,pcb,tray,reel
......@@ -46,13 +50,13 @@ namespace RemoteSheardObject
taskdata["reel"] = 0;
var result= JsonConvert.DeserializeObject<ResultData>(SubmitPostData("/rest/micron/device/getTaskCount", postData));
if (result.code != 0)
if (result==null || result.code != 0)
return taskdata;
foreach (var k in taskdata.Keys)
foreach (var k in taskdata.Keys.ToArray())
{
if (result.data.ContainsKey(k))
taskdata[k] = int.Parse(result.data[k]);
if (result.data.ContainsKey(k+"_out"))
taskdata[k] = int.Parse(result.data[k + "_out"]);
}
return taskdata;
}
......@@ -129,7 +133,8 @@ namespace RemoteSheardObject
}
//去掉最后一个"&"符号
postDataString.Length--;
if (postDataString.Length>0)
postDataString.Length--;
//将POST请求参数转换为字节数组
byte[] bytes = Encoding.UTF8.GetBytes(postDataString.ToString());
......@@ -144,7 +149,7 @@ namespace RemoteSheardObject
catch (Exception ex)
{
// 捕获任何网络异常,并输出错误信息
Console.WriteLine("提交POST请求时发生错误:" + ex.Message);
//Console.WriteLine(crc.GetString("Res0071","提交POST请求时发生错误:") + ex.Message);
// 请求失败,返回false
return "";
......@@ -152,4 +157,4 @@ namespace RemoteSheardObject
}
}
}
}
}
\ No newline at end of file
......@@ -58,7 +58,14 @@ namespace TheMachine
{
e.Cancel = true;
this.WindowState = FormWindowState.Minimized;
return;
}
LogUtil.info("系统强制退出应用 step1");
btn_stop_Click(sender, EventArgs.Empty);
Thread.Sleep(2000);
LogUtil.info("系统强制退出应用 step2");
Application.Exit();
LogUtil.info("系统强制退出应用 step3");
}
//LogControl lc = new LogControl();
......@@ -355,18 +362,7 @@ namespace TheMachine
{
if (!RobotManage.isRunning)
{
//if (RobotManage.mainMachine.IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
//{
// RobotManage.mainMachine.Msg.add(crc.GetString("Res0017","急停中,无法启动"), MsgLevel.warning);
// RobotManage.mainMachine.Msg.Show();
// //return;
//}
//if (RobotManage.mainMachine.IOValue(IO_Type.AutoRun_Single).Equals(IO_VALUE.LOW))
//{
// RobotManage.mainMachine.Msg.add(crc.GetString("Res0018","运行开关没有打开,无法启动"), MsgLevel.warning);
// RobotManage.mainMachine.Msg.Show();
// //return;
//}
LogUtil.info("用户按下启动:"+ sender.ToString());
RobotManage.Start();
userpause = false;
......
using ConfigHelper;
using log4net.Config;
using Microsoft.Win32.TaskScheduler;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
......@@ -46,8 +47,7 @@ namespace TheMachine
}
}
}
Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true).SetValue(Application.ProductName, Application.ExecutablePath);
AddOrUpdateStartupTask();
Config.LoadMyConfig(new Setting_Init().GetType());
Application.ThreadException += Application_ThreadException;
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
......@@ -103,6 +103,43 @@ namespace TheMachine
public const int SW_RESTORE = 9;
#endregion
public static void AddOrUpdateStartupTask()
{
// 获取当前程序的路径和名称
string appPath = Process.GetCurrentProcess().MainModule.FileName;
string TaskName = "AutoStartup_" + Process.GetCurrentProcess().MainModule.ModuleName;
// 创建或更新计划任务
using (TaskService taskService = new TaskService())
{
// 获取任务定义,如果不存在则创建新的任务定义
TaskDefinition taskDefinition;
if (taskService.GetTask(TaskName) != null)
{
taskDefinition = taskService.GetTask(TaskName).Definition;
}
else
{
taskDefinition = taskService.NewTask();
taskDefinition.RegistrationInfo.Description = TaskName;
}
if (taskDefinition.Triggers.Count == 0 || taskDefinition.Triggers[0].TriggerType != TaskTriggerType.Logon)
{
// 设置触发器为用户登录后启动
LogonTrigger logonTrigger = (LogonTrigger)taskDefinition.Triggers.Add(new LogonTrigger());
logonTrigger.Delay = TimeSpan.FromSeconds(5);
}
// 设置操作为启动应用程序
taskDefinition.Actions.Clear();
taskDefinition.Actions.Add(new ExecAction(appPath, null, System.IO.Path.GetDirectoryName(appPath)));
// 设置任务的运行权限为管理员权限
taskDefinition.Principal.RunLevel = TaskRunLevel.Highest;
// 保存任务
taskService.RootFolder.RegisterTaskDefinition(TaskName, taskDefinition, TaskCreation.CreateOrUpdate, null, null, TaskLogonType.InteractiveToken, null);
}
}
}
}
......@@ -7,7 +7,7 @@
<ProjectGuid>{61FDFF14-8BB7-439A-85A0-592E3011F4C4}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>TheMachine</RootNamespace>
<AssemblyName>CycleLine</AssemblyName>
<AssemblyName>MT</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
......@@ -60,6 +60,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\增广夹爪\Rmaxis\bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Win32.TaskScheduler, Version=2.10.1.0, Culture=neutral, PublicKeyToken=e25603a88b3aa7da, processorArchitecture=MSIL">
<HintPath>..\packages\TaskScheduler.2.10.1\lib\net452\Microsoft.Win32.TaskScheduler.dll</HintPath>
</Reference>
<Reference Include="Neotel.Rmaxis">
<HintPath>..\..\增广夹爪\Rmaxis\bin\Debug\Neotel.Rmaxis.dll</HintPath>
</Reference>
......@@ -68,6 +71,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
......@@ -292,6 +296,7 @@
<DependentUpon>uc_boxdebug.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.manifest" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
......
......@@ -145,9 +145,12 @@ namespace TheMachine
listView1.Items[ti.RFID].ForeColor = Color.DarkGray;
else
listView1.Items[ti.RFID].ForeColor = Color.Black;
if (ti.HasLoad && ti.TrayParam.IsNg) {
listView1.Items[ti.RFID].ForeColor = Color.Orange;
}
if (ti.HasLoad && ti.HasLoadCheck<0)
listView1.Items[ti.RFID].ForeColor = Color.Red;
}
ListView2.Items.Clear();
foreach (var tivk in TrayManager.TrayRequest.ToArray())
......@@ -181,13 +184,15 @@ namespace TheMachine
gb_trayinfo.Visible = false;
return;
}
var ti = TrayManager.Traylist[listView1.SelectedItems[0].Text];
string txt = "RFID" + ": " + listView1.SelectedItems[0].Text;
txt += "\r\n"+crc.GetString("Res0021","托盘类型") + ": " + listView1.SelectedItems[0].SubItems[2].Text;
txt += "\r\n"+crc.GetString("Res0055","物料") + ": " + listView1.SelectedItems[0].SubItems[3].Text;
txt += "\r\n"+crc.GetString("Res0023","目的地") + ": " + listView1.SelectedItems[0].SubItems[4].Text;
txt += "\r\n"+"Code" + ": " + listView1.SelectedItems[0].SubItems[6].Text;
if (ti.HasLoad && ti.TrayParam.IsNg) {
txt += "\r\n" + "NgMsg" + ": " + ti.TrayParam.NgMsg;
}
lbl_info.Text = txt;
gb_trayinfo.Visible = true;
}
......
using DeviceLibrary;
using DeviceLibrary;
using OnlineStore;
using System;
using System.Collections.Generic;
......@@ -75,8 +75,8 @@ namespace TheMachine.device.Other
{
stateView.Items.Clear();
foreach (var store in VStoreCollection.VStoreList.Values.ToList()) {
ListViewItem lvi = new ListViewItem(new string[] { "", store.CID, store.RTStoreStatus.ToString(), store.GetStateStr() });
ListViewItem lvi = new ListViewItem(new string[] { "", TowerList.List[store.CID].TowerName+"-"+store.CID, store.RTStoreStatus.ToString(), store.GetStateStr() });
stateView.Items.Add(lvi);
}
}
......@@ -85,11 +85,11 @@ namespace TheMachine.device.Other
{
if (RobotManage.isRunning)
{
MessageBox.Show("请先停止系统运行");
MessageBox.Show(crc.GetString("Res0072","请先停止系统运行"));
return;
}
MI.DeviceList["AMH-MI1"].
MI.DeviceList["AMH-MI1"].Reset();
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="TaskScheduler" version="2.10.1" targetFramework="net461" />
</packages>
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!