Commit 04115036 刘韬

稳定版

1 个父辈 291289f0
......@@ -70,5 +70,8 @@ namespace OnlineStore.Common
public static MyConfig<string> Runtime_OutStoreReelInfo;
public static MyConfig<string> Runtime_Robot_ReelInfo;
public static MyConfig<string> Runtime_Robot_FromPos;
public static MyConfig<string> Runtime_Robot_ToPos;
}
}
......@@ -47,8 +47,8 @@ namespace DeviceLibrary
{
//if (!RobotManage.isRunning)
// ProcessMsg(MsgService.MSList);
if (!string.IsNullOrWhiteSpace(server))
SendLineStatus();
//if (!string.IsNullOrWhiteSpace(server))
// SendLineStatus();
}
catch (Exception ex)
{
......@@ -313,16 +313,6 @@ namespace DeviceLibrary
path = path.Substring(0, path.Length - 1);
return path;
}
public static void UpdateRobotStatus(string code,RobotStatusE robotStatus,string trayrfid) {
NameValueCollection nameValue = new NameValueCollection();
nameValue.Add("code", code);
nameValue.Add("status", robotStatus.ToString());
nameValue.Add("locInfo", trayrfid);
var data = HttpHelper.Post(GetPostApi("/service/store/robotBox/emptyPosForPutin"), nameValue);
}
}
public class ResultData
......
using OnlineStore;
using RemoteSheardObject;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
......@@ -12,7 +14,7 @@ namespace DeviceLibrary
{
public class VStore
{
VServerComm ServerCM;
public VServerComm ServerCM;
public VLog VLog;
VStoreCollection vc;
MsgService Msg;
......@@ -43,15 +45,16 @@ namespace DeviceLibrary
VLog.Info(sender+"出库指令信息:" + e.ToStr());
OutStoreJobList.Enqueue(e.Clone());
//MI.DeviceList[TowerList.List[CurrentOutJobInfo.CID].DeviceGroupName].EnqueueOutStore(CurrentOutJobInfo);
vc.BeginOutStore(e.Clone(), VLog);
}
public RTStoreStatus RTStoreStatus = RTStoreStatus.Offline;
DateTime LastStatusTime = DateTime.Now;
internal void VTowerProcess() {
var ti = vc.GetTowerDetailInformation(CID);
var ti = ServerCM.GetTowerDetailInformation(CID);
if (ti != null)
{
ServerCM.Temperature = ti.Temperature;
ServerCM.Humidity = ti.Humidity * 100;
ServerCM.Humidity = ti.Humidity;
if (ti.StatusCode == 26)
{
ServerCM.storeStatus = StoreStatus.StoreOnline;
......@@ -60,18 +63,30 @@ namespace DeviceLibrary
if (RTStoreStatus != RTStoreStatus.Ready)
VLog.Info("料仓已空闲");
RTStoreStatus = RTStoreStatus.Ready;
if (OutStoreJobList.Count > 0)
{
if (OutStoreJobList.Dequeue(out JobInfo jobInfo))
{
RTStoreStatus = RTStoreStatus.LockToInStore;
if (!ServerCM.BeginOutStore(jobInfo.Clone(), VLog)) {
RTStoreStatus = RTStoreStatus.Ready;
}
CurrentTerminalReelID = jobInfo.WareNum;
}
}
if (InStoreJobInfo != null)
{
VLog.Info("入库成功:" + InStoreJobInfo.ToStr());
string[] substrings = InStoreJobInfo.WareNum.Split('#');
string secondSubstring = substrings[1].Substring(1);
InStoreEnd(secondSubstring);
InStoreJobInfo = null;
}
}
else {
else
{
Msg.add("料仓为入库锁定状态,请检查舱门口料盘状态", MsgLevel.alarm);
}
}
else if (ti.StatusCode == 1031)
{
......@@ -79,20 +94,27 @@ namespace DeviceLibrary
if (RTStoreStatus != RTStoreStatus.InStoreExecute)
VLog.Info("入库执行中");
RTStoreStatus = RTStoreStatus.InStoreExecute;
InStoreJobInfo = null;
//InStoreJobInfo = null;
}
else if (ti.StatusCode == 1032)
{
if (RTStoreStatus != RTStoreStatus.InStoreReady)
if ((DateTime.Now - LastStatusTime).TotalSeconds > 30) {
RTStoreStatus = RTStoreStatus.InStoreDataTimeOut;
}
if (RTStoreStatus != RTStoreStatus.InStoreReady && InStoreJobInfo != null)
{
LastStatusTime = DateTime.Now;
VLog.Info("物料已在舱口");
RTStoreStatus = RTStoreStatus.InStoreReady;
if (InStoreJobInfo != null)
if (!ServerCM.BeginInStore(CID, InStoreJobInfo, VLog))
{
if (!vc.BeginInStore(CID, InStoreJobInfo,VLog)) {
Msg.add(crc.GetString("Res0051","无法入库"), MsgLevel.alarm);
RTStoreStatus = RTStoreStatus.LockToInStore;
Msg.add(CID + crc.GetString("Res0051", "无法入库"), MsgLevel.alarm);
VLog.Info("入库指令失败:" + InStoreJobInfo.ToStr());
}
CurrentTerminalReelID = InStoreJobInfo.WareNum;
//Thread.Sleep()
}
}
......@@ -106,18 +128,28 @@ namespace DeviceLibrary
else if (ti.StatusCode == 1041)
{
if (RTStoreStatus != RTStoreStatus.OutStoreReady)
{
VLog.Info("出库已完成");
OutStoreEnd(CurrentTerminalReelID, CID);
}
RTStoreStatus = RTStoreStatus.OutStoreReady;
OutStoreJobList.ClearLastPosid();
}
else if (ti.StatusCode == 0)
else if (ti.StatusCode == 0 || ti.StatusCode == 18)
{
RTStoreStatus = RTStoreStatus.Offline;
//ServerCM.storeStatus = StoreStatus.InStoreExecute;
ServerCM.storeStatus = StoreStatus.None;
}else if (ti.StatusCode == 310117)
{
RTStoreStatus = RTStoreStatus.InStoreError;
ServerCM.storeStatus = StoreStatus.InStoreError;
}
else if (ti.StatusCode< 10000)
else if (ti.StatusCode < 10000)
{
RTStoreStatus = RTStoreStatus.Busy;
ServerCM.storeStatus = StoreStatus.None;
VLog.Info($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}");
}
else
......@@ -133,29 +165,52 @@ namespace DeviceLibrary
RTStoreStatus = RTStoreStatus.Offline;
}
/*
18 offline
26 Ready/Idle
1031 loading material
1032 material put into Terminal from outside
1040 出库执行中
1041 unloading material 物料已到舱门口
1042 material unloaded to Terminal from Tower 物料已取走
6015 Reel already loaded.
3068 初始化中
*/
}
volatile JobInfo InStoreJobInfo;
public string GetStateStr()
{
if (RTStoreStatus == RTStoreStatus.OutStoreReady)
return "出库中" + (!string.IsNullOrEmpty(CurrentTerminalReelID)?"SN:" + CurrentTerminalReelID:"");
if (RTStoreStatus == RTStoreStatus.LockToInStore) {
return "等待入库信息";
}
if ( RTStoreStatus == RTStoreStatus.InStoreExecute || RTStoreStatus == RTStoreStatus.InStoreReady)
{
return "入库中" + " Barcode:" + InStoreJobInfo?.WareNum;
}
if (RTStoreStatus == RTStoreStatus.InStoreError)
{
return "入库出错,物料NG";
}
return "空闲中";
}
public volatile JobInfo InStoreJobInfo;
StoreJobList OutStoreJobList;
public void RequestInStore(JobInfo jobInfo) {
InStoreJobInfo = jobInfo.Clone();
//return vc.BeginInStore(CID, jobInfo);
}
public bool OutStoreEnd(string reelid) {
public bool OutStoreEnd(string reelid,string towerid) {
CurrentTerminalReelID = reelid;
return ServerCM.SendStoreState(reelid, StoreStatus.OutStoreBoxEnd);
TheLine.UpdateLocInfo("", CurrentTerminalReelID, TheLine.LineStatusE.BOXDOOR, towerid);
return ServerCM.SendStoreState("", reelid, StoreStatus.OutStoreEnd);
}
public bool InStoreEnd(string posid)
{
return ServerCM.SendStoreState(posid, StoreStatus.InStoreEnd);
return ServerCM.SendStoreState("", posid, StoreStatus.InStoreEnd);
}
}
public enum RTStoreStatus {
......@@ -163,11 +218,13 @@ namespace DeviceLibrary
Ready,
InStoreReady,
InStoreExecute,
InStoreError,
OutStoreReady,
OutMoveExecute,
NGOutReady,
LockToInStore,
Busy,
Error,
InStoreDataTimeOut
}
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ namespace DeviceLibrary
public class VStoreCollection
{
MydataWcfServiceTest.ServiceReference2.TowerAppWSClient towerAppWSClient;
ServiceHost Host = null;
public VLog VLog = new VLog();
public string StoreServerURL;
......@@ -33,14 +33,6 @@ namespace DeviceLibrary
if(!string.IsNullOrEmpty(Setting_Init.Runtime_OutStoreReelInfo))
OutStoreReelInfo = JsonConvert.DeserializeObject<Dictionary<string, JobInfo>>(Setting_Init.Runtime_OutStoreReelInfo);
BasicHttpBinding binding = new BasicHttpBinding();
binding.MaxReceivedMessageSize = 1073741824;
binding.MaxBufferSize = 1073741824;
binding.MaxBufferPoolSize = 5242880;
binding.AllowCookies = false;
Uri baseAddress = new Uri(StoreServerURL);
EndpointAddress endpointAddress = new EndpointAddress(baseAddress.ToString());
towerAppWSClient = new MydataWcfServiceTest.ServiceReference2.TowerAppWSClient(binding, endpointAddress);
//TowerList.List.Add("123132", new TowerInfo() { TowerID = "13123", TowerName = "asdasd" });
//TowerList.SaveTowerInfo();
TowerList.List.Values.ToList().ForEach(s =>
......@@ -77,7 +69,7 @@ namespace DeviceLibrary
VLog.Error("收到出库信息,但没有找到该料仓id");
}
else
VStoreList[towerid].OutStoreEnd(reelid);
VStoreList[towerid].OutStoreEnd(reelid, towerid);
//VStoreList[towerid].ReelPutOnOutSide(reelid);
break;
......@@ -108,125 +100,8 @@ namespace DeviceLibrary
VLog.Info("RT料仓退出主循环");
}
public bool SendCommand(string command,bool needlog, out string msg,params string[] arg) {
string errmsg;
try
{
XmlDocument xd = new XmlDocument();
command = string.Format(command, arg);
xd.LoadXml(command);
}
catch (Exception ex)
{
errmsg = "Command format error:\r\n" + ex.ToString();
msg = errmsg;
return false;
}
try
{
if (needlog)
VLog.Info("send: " + command);
//string command = textBox_sendcommand.Text;
try
{
var re = towerAppWSClient.XmlAction(command);
msg = re.ToString();
return true;
//errmsg = "Request sent successfully.";
}
catch (Exception ex)
{
errmsg = "Failed to send request."+ ex;
msg = errmsg;
return false;
}
}
catch (Exception ex)
{
errmsg = "Error: " + ex.ToString();
msg = errmsg;
}
return false;
}
/*
10001 UnknownTower
10002 no Towers to list
10003 no ProductionSite to list
10010 no Articles to list
10011 Article not found
10012 Article aready exists
10013 Article not deleted
10020 no Carriers to list
10021 Carrier not found
10022 Carrier alredy exists
10023 Carrier already in Tower
10041 JobList not found
10042 JobList creation Error
10043 Joblist creation Warning
*/
public TowerDetailInformation GetTowerDetailInformation(string CID) {
if (!SendCommand(VCmd.GetTowerInformation,false, out string data, CID))
{
VLog.Error(data);
return null;
}
var result = XmlCommandSerializer.DeserializeResult(data);
if (result.Errorcode != 0) {
VLog.Error(data);
return null;
}
return XmlCommandSerializer.DeserializeTowerDetailInformation(result.Data);
}
public static Dictionary<string, JobInfo> OutStoreReelInfo = new Dictionary<string,JobInfo>();
public bool BeginOutStore(JobInfo jobInfo, VLog vLog)
{
if (!SendCommand(VCmd.GetCarrierInformation, true, out string data, jobInfo.WareNum))
{
vLog.Error(data);
return false;
}
var result = XmlCommandSerializer.DeserializeResult(data);
if (result.Errorcode != 0)
{
vLog.Error(data);
return false;
}
var reelinfo = XmlCommandSerializer.DeserializeCarrierInformation(result.Data);
lock (OutStoreReelInfo) {
OutStoreReelInfo[jobInfo.WareNum] = new JobInfo(jobInfo.WareNum,"", reelinfo.Diameter, reelinfo.Height);
Setting_Init.Runtime_OutStoreReelInfo = JsonConvert.SerializeObject(OutStoreReelInfo);
}
vLog.Info("出库时获取到料盘数据:"+ OutStoreReelInfo[jobInfo.WareNum].ToStr());
if (!SendCommand(VCmd.UnloadCarrier,true, out data, jobInfo.WareNum))
{
vLog.Error(data);
return false;
}
result = XmlCommandSerializer.DeserializeResult(data);
if (result.Errorcode != 0)
{
vLog.Error(data);
return false;
}
return true;
}
public bool BeginInStore(string towerid,JobInfo jobInfo,VLog vLog)
{
if (!SendCommand(VCmd.SimulateStartButton, true,out string data, towerid, jobInfo.WareNum))
{
vLog.Error(data);
return false;
}
var result = XmlCommandSerializer.DeserializeResult(data);
if (result.Errorcode != 0)
{
vLog.Error(data);
return false;
}
return true;
}
RtTowerClientService.Service service = new RtTowerClientService.Service();
void StartService()
{
......
......@@ -21,19 +21,19 @@ namespace DeviceLibrary
{
lock (jobInfos)
{
//if (lastoutpos == jobInfo.WareNum)
//{
// LogUtil.info($"[{jobname}] 出库任务正在执行:" + jobInfo.ToStr());
// return;
//}
//var l = jobInfos.ToList().Find((x) => { return x.WareNum == jobInfo.WareNum; });
//if (l == null)
//{
if (lastoutpos == jobInfo.WareNum)
{
LogUtil.info($"[{jobname}] 出库任务正在执行:" + jobInfo.ToStr());
return;
}
var l = jobInfos.ToList().Find((x) => { return x.WareNum == jobInfo.WareNum; });
if (l == null)
{
jobInfos.Enqueue(jobInfo);
LogUtil.info($"[{jobname}] 库任务加入队列:" + jobInfo.ToStr());
//}
//else
// LogUtil.info($"[{jobname}] 出库任务已存在队列中:" + jobInfo.ToStr());
LogUtil.info($"[{jobname}] 库任务加入队列:" + jobInfo.ToStr());
}
else
LogUtil.info($"[{jobname}] 出库任务已存在队列中:" + jobInfo.ToStr());
}
}
public bool Dequeue(out JobInfo jobInfo)
......
......@@ -238,7 +238,6 @@ namespace DeviceLibrary
}
else if (isInSuddenDown)
{
//Alarm(AlarmType.SuddenStop);
Msg.add(crc.GetString("Res0176", "急停中"), MsgLevel.alarm);
ok = false;
}
......@@ -268,7 +267,6 @@ namespace DeviceLibrary
{
ok = false;
Msg.add(msg, MsgLevel.warning);
//LogUtil.error(msg);
}
}
if (alarmType!=AlarmType.SuddenStop)
......@@ -285,7 +283,6 @@ namespace DeviceLibrary
ok = false;
LogUtil.error(string.Join(",",HuichuanLibrary.HCBoardManager.GetAxisErrorDetail(y.Config.GetAxisValue())));
}
}); });
}
......
......@@ -67,8 +67,10 @@ namespace DeviceLibrary
CIPostion = CSVPositionReader<RobotPosition>.LoadCSVFile(CIPostionFile);
Robot_MI1 = new URRobotControl(Setting_Init.URRobot_MI1_IP);
Robot_MI1.Name = "R1";
Robot_MI1.SetSpeedRate(Setting_Init.URRobot_MI1_Speed_Rate);
Robot_MI2 = new URRobotControl(Setting_Init.URRobot_MI2_IP);
Robot_MI1.Name = "R2";
Robot_MI2.SetSpeedRate(Setting_Init.URRobot_MI2_Speed_Rate);
Robot_CI = new URRobotControl(Setting_Init.URRobot_CI_IP);
Robot_CI.SetSpeedRate(Setting_Init.URRobot_CI_Speed_Rate);
......
......@@ -2,6 +2,7 @@ using Newtonsoft.Json;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using RemoteSheardObject;
using System;
using System.Collections.Generic;
using System.Diagnostics;
......@@ -198,7 +199,6 @@ namespace DeviceLibrary
if (requestLoadInfo.IsEmpty)
{
SetTrayLoadInfo(device.CurrrentRFID, null);
ServerCommunication.UpdateRobotStatus(requestLoadInfo.LoadParam.WareCode, RobotStatusE.FINISHED, remoteLoad.GroupName);
}
else {
SetTrayLoadInfo(device.CurrrentRFID, requestLoadInfo);
......@@ -217,7 +217,6 @@ namespace DeviceLibrary
if (requestLoadInfo.IsEmpty)
{
SetTrayLoadInfo(device.CurrrentRFID, null);
ServerCommunication.UpdateRobotStatus(requestLoadInfo.LoadParam.WareCode, RobotStatusE.FINISHED, remoteLoad.GroupName);
}
else {
SetTrayLoadInfo(device.CurrrentRFID, requestLoadInfo);
......
......@@ -130,18 +130,20 @@ namespace DeviceLibrary
if (IOValue(IO_Type.Ls_B_Tray_Check).Equals(IO_VALUE.HIGH))
{
break;
}else
}
else
if (IOValue(IO_Type.Ls_A_Tray_Check).Equals(IO_VALUE.HIGH))
{
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_04);
LastGoInFail = false;
}else
if (IOValue(IO_Type.Ls_A_Front_Check).Equals(IO_VALUE.HIGH)|| Forcetry)
}
else
if (IOValue(IO_Type.Ls_A_Front_Check).Equals(IO_VALUE.HIGH) || Forcetry)
{
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_02);
Location_A.ToLow(LSAMoveInfo);
//Location_B.ToLow(LSAMoveInfo);
if (!Forcetry)
IOMove(IO_Type.Ls_A_BufStop_Fwd, IO_VALUE.HIGH, StopBufDelayMS);
LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
......@@ -211,7 +213,6 @@ namespace DeviceLibrary
Line.LineStop("n");
Location_A.ToLow(LSAMoveInfo);
Location_B.ToLow(LSAMoveInfo);
LSBMoveInfo.NextMoveStep(MoveStep.SideMove_01);
break;
case MoveStep.SideMove_10:
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_01);
......@@ -380,10 +381,11 @@ namespace DeviceLibrary
//IOMove(Ls_A_Stop, IO_VALUE.HIGH, Ls_A_Tray_Check, IO_VALUE.LOW, StopDelayMS);
IOMove(Ls_A_Stop, IO_VALUE.HIGH);
IOMove(Ls_A_BufStop_Rwd, IO_VALUE.HIGH, StopBufDelayMS);
Line.LineStop("n");
Minfo.log($"{Ls_A_Stop}阻挡放行");
break;
case MoveStep.SideMove_07:
if (IOValue(Ls_A_Tray_Check).Equals(IO_VALUE.LOW))
if (IOMonitor.IODebound(Ls_A_Tray_Check,GroupName,IO_VALUE.LOW,1000))// IOValue(Ls_A_Tray_Check).Equals(IO_VALUE.LOW))
{
IOMove(Ls_A_Stop, IO_VALUE.LOW);
Minfo.NextMoveStep(MoveStep.SideMove_08);
......@@ -453,14 +455,13 @@ namespace DeviceLibrary
if (!FwdFree(addr))
return;
Minfo.NextMoveStep(MoveStep.SideMove_53);
if (LS_Type != LS_TypeE.NoRfid)
IOMove(Ls_A_Stop, IO_VALUE.HIGH);
Location_a.ToLow(Minfo);
Minfo.log($"顶升下降");
break;
case MoveStep.SideMove_53:
Minfo.NextMoveStep(MoveStep.SideMove_54);
if (LS_Type!= LS_TypeE.NoRfid)
//IOMove(Ls_A_Stop, IO_VALUE.HIGH, Ls_A_Tray_Check, IO_VALUE.LOW, StopDelayMS);
IOMove(Ls_A_Stop, IO_VALUE.HIGH);
break;
case MoveStep.SideMove_54:
Minfo.NextMoveStep(MoveStep.SideMove_17);
......
using Newtonsoft.Json;
using OnlineStore;
using OnlineStore.LoadCSVLibrary;
using RemoteSheardObject;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -311,7 +312,7 @@ namespace DeviceLibrary
MoveInfo2.MoveParam = MoveInfo.MoveParam.clone();
Location.ToLow(MoveInfo);
MoveInfo.log("料盘已取走,放行托盘, 子流程开始移栽入库");
ServerCommunication.UpdateRobotStatus(MoveInfo.MoveParam.WareCode, RobotStatusE.BOXDOOR, MoveInfo.MoveParam.RFID);
TheLine.UpdateLocInfo("",MoveInfo.MoveParam.WareCode, TheLine.LineStatusE.BOXDOOR, GroupName);
TrayManager.SetToEmpty(CurrrentRFID);
break;
case MoveStep.TransplantMove_16:
......@@ -397,6 +398,8 @@ namespace DeviceLibrary
MoveInfo.log("释放料仓门, 设置托盘信息");
remoteLoad.RequestLoadInfo.IsEmpty = false;
TrayManager.SetTrayLoadInfo(CurrrentRFID, remoteLoad.RequestLoadInfo);
TheLine.UpdateLocInfo("", MoveInfo.MoveParam.WareCode, TheLine.LineStatusE.INLINE, CurrrentRFID);
//ServerCommunication.UpdateRobotStatus(MoveInfo.MoveParam.WareCode, RobotStatusE.INROBOT, CurrrentRFID);
break;
case MoveStep.TransplantMove_24:
......@@ -418,6 +421,8 @@ 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);
break;
case MoveStep.TransplantMove_27:
MoveInfo.NextMoveStep(MoveStep.TransplantMove_28);
......@@ -476,6 +481,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("", MoveInfo2.MoveParam.WareCode, TheLine.LineStatusE.BOXDOOR, GroupName);
break;
case MoveStep.TransplantMove_04:
MoveInfo2.NextMoveStep(MoveStep.TransplantMove_05);
......@@ -604,5 +610,11 @@ namespace DeviceLibrary
{
return IOValue(IO_Type.AMH_Front_Check).Equals(IO_VALUE.LOW);
}
public void ResetStatus() {
ConfigHelper.Config.Set($"Runtime_{GroupName}_IsSucker", false);
DeviceState = DeviceStateE.HomeReset;
MoveInfo.NewMove(MoveStep.H01_HomeReset);
MoveInfo.log("开始重置");
}
}
}
\ No newline at end of file
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using RemoteSheardObject;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
......@@ -213,8 +214,6 @@ namespace DeviceLibrary
remoteLoad.Action = "TrayReady";
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.TrayType = trayInfo.TrayType.ToString();
if (trayInfo.TrayParam != null)
remoteLoad.RequestLoadInfo.LoadParam = trayInfo.TrayParam.clone();
remoteLoad.RequestLoadInfo.IsEmpty = true;
MoveInfo.remoteLoad = remoteLoad;
......@@ -222,8 +221,6 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
SRec.info(crc.GetString("Res0042","托盘挡停"), GroupName, crc.GetString("Res0030","空托盘"), crc.GetString("Res0043","准备接料"), CurrrentRFID);
if (trayInfo.TrayParam != null)
ServerCommunication.UpdateRobotStatus(trayInfo.TrayParam.WareCode, RobotStatusE.INROBOT, MoveInfo.MoveParam.RFID);
return;
}
else if (trayInfo.DestinationAddr == DeviceGroup.addr_1 && trayInfo.HasLoad && IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.HIGH))
......@@ -247,7 +244,7 @@ namespace DeviceLibrary
else
{
SRec.info(crc.GetString("Res0042","托盘挡停"), GroupName, crc.GetString("Res0025","载物托盘"), crc.GetString("Res0044","等待物料被接走"), CurrrentRFID, remoteLoad.RequestLoadInfo.LoadParam.WareCode);
MoveInfo.log($"{GroupName} 请求出库成功");
MoveInfo.log($"{GroupName} 请求出库成功"+ remoteLoad.RequestLoadInfo.LoadParam.ToStr());
}
return;
}
......@@ -393,7 +390,7 @@ namespace DeviceLibrary
}
else if (result == RemoteResult.Timeout)
{
Debug.WriteLine("Remote IsSafe:False");
Debug.WriteLine("Remote Timeout IsSafe:False");
return false;
}
else if (RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.LOW))
......@@ -417,6 +414,11 @@ namespace DeviceLibrary
public void TrayRelease() {
MoveInfo.log("释放托盘");
MoveInfo.NextMoveStep(MoveStep.TrayStop_LoadProcessed);
if (TrayManager.Traylist.ContainsKey(CurrrentRFID) && TrayManager.Traylist[CurrrentRFID].HasLoad)
{
var ri = TrayManager.Traylist[CurrrentRFID].TrayParam;
TheLine.UpdateLocInfo("", ri.WareCode, TheLine.LineStatusE.INLINE, CurrrentRFID);
}
}
public void ResetProcess()
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace RemoteSheardObject
{
public class EquipMsgData
{
public string equipName { get; set; }
public int ngCount { get; set; }
public List<EquipMessage> msgList { get; set; }
public int status { get; set; }
}
public class EquipMessage
{
public string msg { get; set; }
public string name { get; set; }
public int status { get; set; }
}
}
using log4net;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Security;
using System.Reflection;
using System.Text;
namespace RemoteSheardObject
{
public class MyWebClient : WebClient
{
private int _timeout;
/// <summary>
/// 超时时间(毫秒)
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public MyWebClient()
{
this._timeout = 60000;
}
public MyWebClient(int timeout)
{
this._timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
HttpWebRequest result = (HttpWebRequest)base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}
}
public class HttpHelper
{
static ILog Log = LogManager.GetLogger("HTTP");
public static bool PingURLIP(string url, int ms = 100)
{
string[] urlArray = url.Split('/');
if (urlArray.Length > 3)
{
string ip = urlArray[2];
Ping pingSender = new Ping();
PingReply reply = pingSender.Send(ip, ms);//第一个参数为ip地址,第二个参数为ping的时间
if (reply.Status == IPStatus.Success)
{
//通
return true;
}
else
{
//不通
return false;
}
}
return true;
}
public static string Post(string url, string paramData, int timeOut = 10000)
{
return Post(url, paramData, Encoding.UTF8, timeOut);
}
public static string Post(string url, string paramData, Encoding encoding, int timeOut = 10000)
{
string result = "";
if (url.ToLower().IndexOf("https", System.StringComparison.Ordinal) > -1)
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback((sender, certificate, chain, errors) => { return true; });
}
try
{
using (var wc = new MyWebClient(timeOut))
{
if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
{
wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
}
wc.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
wc.Encoding = encoding;
result = wc.UploadString(url, "POST", paramData);
}
//LogUtil.info(result);
}
catch (Exception e)
{
Log.Error("POST ERROR:" + e.ToString()+"\r\n"+ url);
}
return result;
}
public static string Post(string url, NameValueCollection paramData, int timeOut = 10000)
{
string result = "";
if (url.ToLower().IndexOf("https", System.StringComparison.Ordinal) > -1)
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback((sender, certificate, chain, errors) => { return true; });
}
try
{
using (var wc = new MyWebClient(timeOut))
{
byte[] buf = wc.UploadValues(url, "POST", paramData);
result = Encoding.UTF8.GetString(buf);
}
//LogUtil.info(result);
}
catch (Exception e)
{
Log.Error("POST ERROR:" + e.ToString() + "\r\n" + url);
}
return result;
}
static object lockpost = new object();
public static T2 Post<T1,T2>(string url, T1 jsonobject, int timeout = 5000, bool printlog = false)
{
string json = "";
try
{
json = JsonConvert.SerializeObject(jsonobject);
string result = Post(url, json, timeout);
T2 op = JsonConvert.DeserializeObject<T2>(result);
if (printlog)
{
Log.Info("Send [" + json + "] Revice [" + result + "]");
}
return op;
}
catch (Exception ex)
{
Log.Error("Post 出错【"+ json + "】:" + ex);
}
return default;
}
public static string Get(string url,bool needlog=true)
{
return Get(url, Encoding.UTF8);
}
public static string Get(string url, Encoding encoding, bool needlog = true, int timeOut = 10000)
{
try
{
Debug.WriteLine("HTTP GET FROM: " + url);
using (var wc = new MyWebClient { Encoding = encoding })
{
var readStream = wc.OpenRead(url);
using (var sr = new StreamReader(readStream, encoding))
{
var result = sr.ReadToEnd();
Debug.WriteLine("receive << " + result);
return result;
}
}
}
catch (Exception e)
{
Log.Error("HTTP GET ERROR:" + e.Message);
}
return "";
}
}
}
......@@ -35,6 +35,10 @@
<Reference Include="CodeLibrary">
<HintPath>..\..\GeneralClassLibrary\CodeLibraryProject\CodeLibrary\bin\Debug\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="ConfigHelper, Version=1.0.0.2, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\ConfigHelper\ConfigHelper\bin\Debug\ConfigHelper.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\增广夹爪\Rmaxis\bin\Debug\log4net.dll</HintPath>
......@@ -83,10 +87,15 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="EquipMsgData.cs" />
<Compile Include="MyWebClient.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RemoteClient.cs" />
<Compile Include="SLog.cs" />
<Compile Include="StoreCID.cs" />
<Compile Include="TheLine.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
......
using ConfigHelper;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace RemoteSheardObject
{
public class TheLine
{
public enum LineStatusE {
INLINE,
INROBOT,
BOXDOOR,
FINISHED
}
public static bool UpdateLocInfo(string taskId, string barcode, LineStatusE status, string locInfo)
{
if (barcode.Count(c => c == '#') == 3)
{
barcode = barcode.Split('#')[1].Substring(1);
}
var postData = new Dictionary<string, string>()
{
{"taskId", taskId},
{"barcode", barcode},
{"status", status.ToString()},
{"locInfo", locInfo}
};
return !string.IsNullOrEmpty(SubmitPostData("/service/store/robotBox/updateLocInfo", postData));
}
public static string SubmitPostData(string url, Dictionary<string, string> postData)
{
url = CombineUrl(Config.Get("Device_Server_Address"), url);
//创建WebClient对象
using (var client = new WebClient())
{
//设置提交数据的方式为"application/x-www-form-urlencoded"
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
try
{
//将POST请求参数字典转换为参数字符串
var postDataString = new StringBuilder();
foreach (var item in postData)
{
if (!string.IsNullOrEmpty(item.Value))
{
postDataString.AppendFormat("{0}={1}&", item.Key, Uri.EscapeDataString(item.Value));
}
}
//去掉最后一个"&"符号
postDataString.Length--;
//将POST请求参数转换为字节数组
byte[] bytes = Encoding.UTF8.GetBytes(postDataString.ToString());
//提交POST请求并获取响应
byte[] response = client.UploadData(url, "POST", bytes);
//将响应转换为字符串并输出
return Encoding.UTF8.GetString(response);
}
catch (Exception ex)
{
// 捕获任何网络异常,并输出错误信息
Console.WriteLine("提交POST请求时发生错误:" + ex.Message);
// 请求失败,返回false
return "";
}
}
}
public static string CombineUrl(string baseUrl, string relativeUrl)
{
if (string.IsNullOrEmpty(baseUrl))
{
return relativeUrl;
}
if (string.IsNullOrEmpty(relativeUrl))
{
return baseUrl;
}
baseUrl = baseUrl.TrimEnd('/');
relativeUrl = relativeUrl.TrimStart('/');
return string.Format("{0}/{1}", baseUrl, relativeUrl);
}
public static T GetReelSize<T>(string barcode)
{
if (barcode.Count(c => c == '#') == 3)
{
barcode = barcode.Split('#')[1].Substring(1);
}
var postData = new Dictionary<string, string>()
{
{"barcode", barcode},
};
var result = SubmitPostData( "/service/store/robotBox/getSize", postData);
if (result != null)
return JsonConvert.DeserializeObject<T>(result);
else
return default;
}
public class ResultData
{
//{"code":0,"msg":"ok","data":"7"}
public int code { get; set; }
public string msg { get; set; }
public Dictionary<string, string> data { get; set; }
}
}
}
using DeviceLibrary;
using OnlineStore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
......@@ -28,6 +29,35 @@ namespace TheMachine.device.Other
ucurRobot2.Init(RobotManage.Robot_MI2);
ucurRobot3.Init(RobotManage.Robot_CI);
#region 状态信息listview初始化
stateView.View = View.Details;
ColumnHeader c1 = new ColumnHeader();
c1.Text = "";
c1.Width = 0;
ColumnHeader c2 = new ColumnHeader();
c2.Text = "Tower ID";
c2.Width = 120;
ColumnHeader c3 = new ColumnHeader();
c3.Text = "Status";
c3.Width = 120;
ColumnHeader c4 = new ColumnHeader();
c4.Text = crc.GetString("Form1_tabc_tabP1_Text", "信息");
c4.Width = 470;
stateView.Columns.Add(c1);
stateView.Columns.Add(c2);
stateView.Columns.Add(c3);
stateView.Columns.Add(c4);
#endregion
crc.LanguageChangeEvent += Crc_LanguageChangeEvent; ;
}
private void Crc_LanguageChangeEvent(object sender, EventArgs e)
{
stateView.Columns[1].Text = "Tower ID";
stateView.Columns[2].Text = "Status";
stateView.Columns[3].Text = crc.GetString("Form1_tabc_tabP1_Text", "信息");
}
private void tabPage4_Click(object sender, EventArgs e)
......@@ -37,8 +67,18 @@ namespace TheMachine.device.Other
private void btn_manualout_Click(object sender, EventArgs e)
{
RobotManage.VStoreCollection.VLog.Info("手动出库:"+ txt_reelid.Text);
RobotManage.VStoreCollection.BeginOutStore(new JobInfo(txt_reelid.Text, "", 0, 0), RobotManage.VStoreCollection.VLog);
VStoreCollection.VStoreList.Values.First().VLog.Info("手动出库:"+ txt_reelid.Text);
VStoreCollection.VStoreList.Values.First().ServerCM.BeginOutStore(new JobInfo(txt_reelid.Text, "", 0, 0), RobotManage.VStoreCollection.VLog);
}
private void timer1_Tick(object sender, EventArgs e)
{
stateView.Items.Clear();
foreach (var store in VStoreCollection.VStoreList.Values.ToList()) {
ListViewItem lvi = new ListViewItem(new string[] { "", store.CID, store.RTStoreStatus.ToString(), store.GetStateStr() });
stateView.Items.Add(lvi);
}
}
}
}
......@@ -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
......@@ -43,8 +43,9 @@ namespace TheMachine
this.cylinderButton1 = new TheMachine.CylinderButton();
this.ioControl1 = new TheMachine.IOControl();
this.panel1 = new System.Windows.Forms.Panel();
this.rfidControl1 = new TheMachine.UC.RfidControl();
this.btn_sucker_release = new System.Windows.Forms.Button();
this.rfidControl1 = new TheMachine.UC.RfidControl();
this.btn_Reset = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
......@@ -196,6 +197,7 @@ namespace TheMachine
// panel1
//
this.panel1.AutoScroll = true;
this.panel1.Controls.Add(this.btn_Reset);
this.panel1.Controls.Add(this.btn_sucker_release);
this.panel1.Controls.Add(this.rfidControl1);
this.panel1.Controls.Add(this.button_p3);
......@@ -217,15 +219,6 @@ namespace TheMachine
this.panel1.Size = new System.Drawing.Size(1021, 741);
this.panel1.TabIndex = 10;
//
// rfidControl1
//
this.rfidControl1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.rfidControl1.Location = new System.Drawing.Point(547, 129);
this.rfidControl1.Name = "rfidControl1";
this.rfidControl1.Size = new System.Drawing.Size(196, 99);
this.rfidControl1.TabIndex = 10;
this.rfidControl1.Visible = false;
//
// btn_sucker_release
//
this.btn_sucker_release.BackColor = System.Drawing.Color.White;
......@@ -238,6 +231,25 @@ namespace TheMachine
this.btn_sucker_release.UseVisualStyleBackColor = false;
this.btn_sucker_release.Click += new System.EventHandler(this.btn_sucker_release_Click);
//
// rfidControl1
//
this.rfidControl1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.rfidControl1.Location = new System.Drawing.Point(547, 129);
this.rfidControl1.Name = "rfidControl1";
this.rfidControl1.Size = new System.Drawing.Size(196, 99);
this.rfidControl1.TabIndex = 10;
this.rfidControl1.Visible = false;
//
// btn_Reset
//
this.btn_Reset.Location = new System.Drawing.Point(770, 140);
this.btn_Reset.Name = "btn_Reset";
this.btn_Reset.Size = new System.Drawing.Size(100, 69);
this.btn_Reset.TabIndex = 12;
this.btn_Reset.Text = "Reset";
this.btn_Reset.UseVisualStyleBackColor = true;
this.btn_Reset.Click += new System.EventHandler(this.btn_Reset_Click);
//
// TransplantControl
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
......@@ -269,5 +281,6 @@ namespace TheMachine
private System.Windows.Forms.Panel panel1;
private UC.RfidControl rfidControl1;
private System.Windows.Forms.Button btn_sucker_release;
private System.Windows.Forms.Button btn_Reset;
}
}
......@@ -90,5 +90,10 @@ namespace TheMachine
TransplantMove.DeviceList[DeviceGroupName].IOMove(IO_Type.AMH_Sucker, IO_VALUE.LOW);
TransplantMove.DeviceList[DeviceGroupName].IOMove(IO_Type.AMH_Sucker_Release, IO_VALUE.HIGH,2000);
}
private void btn_Reset_Click(object sender, EventArgs e)
{
TransplantMove.DeviceList[DeviceGroupName].ResetStatus();
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!