Commit 291289f0 刘韬

完成mi对接

1 个父辈 fe9ba0cd
正在显示 41 个修改的文件 包含 2566 行增加333 行删除
......@@ -21,6 +21,8 @@ namespace OnlineStore.Common
[MyConfigComment("服务器地址")]
public static MyConfig<string> Device_Server_Address = "http://192.168.1.243/smf-core";
[MyConfigComment("Mycronic料仓服务器IP")]
public static MyConfig<string> Device_StoreServerURL = "http://192.168.160.29:8585/RtTower.WebService/";
[MyConfigComment("设备界面语言")]
public static MyConfig<string> Device_Default_Language = "zh-CN";
......@@ -65,5 +67,8 @@ namespace OnlineStore.Common
public static MyConfig<int> CameraScan_QRCodeCount = 3;
[MyConfigComment("二维码扫码超时毫秒")]
public static MyConfig<int> CameraScan_CodeTimeOut = 3000;
public static MyConfig<string> Runtime_OutStoreReelInfo;
}
}
......@@ -204,6 +204,7 @@ namespace OnlineStore.Common
/// 库位 ID
/// </summary>
public static string posId = "posId";
public static string cid = "cid";
/// <summary>
/// 料盘宽
/// </summary>
......
......@@ -30,7 +30,7 @@ namespace OnlineStore.Common
return;
}
log.Info(msg);
AddToBox(msg, Color.Black);
//AddToBox(msg, Color.Black);
}
public static void info(ILog log, string msg, Color color)
{
......
......@@ -68,9 +68,23 @@
<Reference Include="Robot.UR">
<HintPath>..\..\..\DllLibrary\第三方\URRobot\Robot.UR\Robot.UR\bin\Debug\Robot.UR.dll</HintPath>
</Reference>
<Reference Include="RtTower.WebService.ComTowerApp.Contract, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\MydataWcfServiceTest\RtTowerClientService\bin\Debug\RtTower.WebService.ComTowerApp.Contract.dll</HintPath>
</Reference>
<Reference Include="RtTower.WebService.SharedModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<Reference Include="RtTower.WebService.SharedService, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\MydataWcfServiceTest\RtTowerClientService\bin\Debug\RtTower.WebService.SharedService.dll</HintPath>
</Reference>
<Reference Include="RtTowerClientService">
<HintPath>..\..\MydataWcfServiceTest\RtTowerClientService\bin\Debug\RtTowerClientService.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
......@@ -141,6 +155,14 @@
<Compile Include="userControl\FixtureSizeConfigControl.Designer.cs">
<DependentUpon>FixtureSizeConfigControl.cs</DependentUpon>
</Compile>
<Compile Include="VirtuallyStore\CommandList.cs" />
<Compile Include="VirtuallyStore\Reference.cs" />
<Compile Include="VirtuallyStore\VMsg.cs" />
<Compile Include="VirtuallyStore\VServerComm.cs" />
<Compile Include="VirtuallyStore\TowerList.cs" />
<Compile Include="VirtuallyStore\VLog.cs" />
<Compile Include="VirtuallyStore\VStoreCollection.cs" />
<Compile Include="VirtuallyStore\VStore.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="userControl\AxisMoveControl.resx">
......
......@@ -34,26 +34,49 @@ namespace DeviceLibrary
List.Add(deviceGroupName, new List<AxisBean>());
List[deviceGroupName].Add(this);
}
int openretry=0;
public bool Open(bool isCheck, out string Msg)
{
Msg = "";
string portName = Config.DeviceName;
short slvAddr = Config.GetAxisValue();
AxisManager.AlarmClear(portName, slvAddr);
Thread.Sleep(50);
AxisManager.ServoOn(portName, slvAddr);
Thread.Sleep(50);
//打开所有轴
if (isCheck)
if (AxisManager.IsServeoOn(portName, slvAddr))
{ openretry = 0; return true; }
openretry++;
{
if (!OpenAxis(out Msg))
Msg += string.Format("第{0}次尝试打开轴:{1}", openretry, Config.Explain);
if (AxisManager.GetBusyStatus(portName, slvAddr) == 1)
{
return false;
}
AxisManager.SuddenStop(portName, slvAddr);
Msg += string.Format("...伺服忙碌,急停{0}次", openretry);
Thread.Sleep(100);
}
//if (AxisManager.GetAlarmStatus(portName, slvAddr) != 0)
//{
// AxisManager.AlarmClear(portName, slvAddr);
// Msg += string.Format("...尝试清除报警第(0)次", openretry);
// Thread.Sleep(100);
//}
AxisManager.ServoOn(portName, slvAddr);
Thread.Sleep(200);
if (AxisManager.IsServeoOn(portName, slvAddr))
{
Msg += "...使能成功";
openretry = 0;
return true;
}
else
Msg += "...尝试使能失败";
Thread.Sleep(1000);
if (openretry < 5)
Msg = "伺服连接中...";
}
return false;
}
/// <summary>
/// 打开所有轴
/// </summary>
......@@ -392,10 +415,9 @@ namespace DeviceLibrary
foreach (AxisBean axis in axisArray)
{
bool result = axis.Open(false, out msg);
if (!result || (!String.IsNullOrEmpty(msg)))
if (!result)
{
//SetWarnMsg(Name + msg);
//Alarm(AlarmType.AxisAlarm);
LogUtil.error(msg);
return false;
}
}
......@@ -418,7 +440,30 @@ namespace DeviceLibrary
Thread.Sleep(10);
}
}
public static bool ClearMultiAlarm(out string msg, List<AxisBean> axisArray)
{
msg = "";
bool isok = true;
foreach (AxisBean axis in axisArray)
{
string portName = axis.Config.DeviceName;
short slvAddr = axis.Config.GetAxisValue();
if (AxisManager.GetAlarmStatus(portName, slvAddr) != 0)
{
AxisManager.AlarmClear(portName, slvAddr);
Thread.Sleep(200);
if (AxisManager.GetAlarmStatus(portName, slvAddr) != 0)
{
msg += string.Format("轴(0)存在报警,清除失败", axis.Config.Explain);
isok = false;
}
else
msg += string.Format("轴(0)存在报警,清除成功", axis.Config.Explain);
}
}
Thread.Sleep(50);
return isok;
}
}
}
......@@ -24,7 +24,7 @@ namespace DeviceLibrary
}
}
static string server = Setting_Init.Device_Server_Address;
static string CID = Setting_Init.Device_CID;
static string CID;
int StoreID = 1;
string StoreName="";
......@@ -32,7 +32,8 @@ namespace DeviceLibrary
private System.Timers.Timer serverConnectTimer = new System.Timers.Timer();
object serverclock = new object();
public ServerCommunication() {
public ServerCommunication(string cid) {
CID = cid;
serverConnectTimer.Interval = 1000;
serverConnectTimer.AutoReset = true;
serverConnectTimer.Enabled = true;
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
class VCmd
{
public static Dictionary<string, string> wslist = new Dictionary<string, string>();
public static Dictionary<string, string> fslist = new Dictionary<string, string>();
public const string GetTowerInformation =@"<XmlCommand>
<Command>GetTowerInformation</Command>
<Parameter>{0}</Parameter>
</XmlCommand>";
public const string SimulateStartButton = @"<XmlCommand>
<Command>SimulateStartButton</Command>
<Parameter>
<LoadMaterialInformation>
<TowerId>{0}</TowerId>
<Barcode>{1}</Barcode>
</LoadMaterialInformation>
</Parameter>
</XmlCommand>";
public const string ProvideItem = @"<XmlCommand>
<Command>ProvideItem</Command>
<Parameter>
<ProvideItem>
<Object>Carrier</Object>
<Name>{0}</Name>
</ProvideItem>
</Parameter>
</XmlCommand>";
public const string UnloadCarrier = @"<XmlCommand>
<Command>UnloadCarrier</Command>
<Parameter>
<CarrierProvideInformation>
<Name>{0}</Name>
</CarrierProvideInformation>
</Parameter>
</XmlCommand>";
public const string GetCarrierInformation = @"<XmlCommand>
<Command>GetCarrierInformation</Command>
<Parameter>{0}</Parameter>
</XmlCommand>";
static VCmd()
{
wslist.Add("GetTowers", @"<XmlCommand>
<Command>GetTowers</Command>
<Parameter/>
</XmlCommand>");
wslist.Add("GetTowerInformation", @"<XmlCommand>
<Command>GetTowerInformation</Command>
<Parameter>000800</Parameter>
</XmlCommand>");
wslist.Add("GetCarrierList", @"<XmlCommand>
<Command>GetProdSites</Command>
<Parameter/>
</XmlCommand>");
wslist.Add("GetProdSites", @"<XmlCommand>
<Command>GetProdSites</Command>
<Parameter></Parameter>
</XmlCommand>");
wslist.Add("GetArticleList", @"<XmlCommand>
<Command>GetArticleList</Command>
<Parameter/>
</XmlCommand>");
wslist.Add("GetArticleInformation", @"<XmlCommand>
<Command>GetArticleInformation</Command>
<Parameter>0402c</Parameter>
</XmlCommand>");
wslist.Add("NewArticle", @"<XmlCommand>
<Command>NewArticle</Command>
<Parameter>
<ArticleInformation>
<ID>0</ID>
<CreateDate>0001-01-01T00:00:00</CreateDate>
<Article>0502c</Article>
<ANote/>
<Cycles>0</Cycles>
<Stock>0</Stock>
<StockMin>0</StockMin>
<StockMax>0</StockMax>
<StockUsed>0</StockUsed>
<Guessed>false</Guessed>
<StockValue>0</StockValue>
<StockVMax>0</StockVMax>
<ReelCount>0</ReelCount>
<ReelMin>0</ReelMin>
<ReelMax>0</ReelMax>
<ReelsUsed>0</ReelsUsed>
<MSL/>
<MSLWatch>false</MSLWatch>
<ACase/>
<AGroup/>
<Poled>false</Poled>
</ArticleInformation>
</Parameter>
</XmlCommand>");
wslist.Add("GetCarrierInformation", @"<XmlCommand>
<Command>GetCarrierInformation</Command>
<Parameter>0014379599</Parameter>
</XmlCommand>");
wslist.Add("NewCarrier", @"<XmlCommand>
<Command>NewCarrier</Command>
<Parameter>
<CarrierInformation>
<ID>0</ID>
<Carrier>672529346529</Carrier>
<CreateDate>0001-01-01T00:00:00</CreateDate>
<Article>0</Article>
<ArticleName>0402c</ArticleName>
<Depot/>
<DepotDate>0001-01-01T00:00:00</DepotDate>
<Stock>0</Stock>
<StockMin>0</StockMin>
<StockNew>0</StockNew>
<StockUsed>0</StockUsed>
<StockTPSys>0</StockTPSys>
<Guessed>false</Guessed>
<Cycles>0</Cycles>
<Outtime>0</Outtime>
</CarrierInformation>
</Parameter>
</XmlCommand>");
wslist.Add("UnloadCarrier", @"<XmlCommand>
<Command>UnloadCarrier</Command>
<Parameter>
<CarrierProvideInformation>
<Name>A003R0004</Name>
<Demand>1</Demand>
<TaskId></TaskId>
</CarrierProvideInformation>
</Parameter>
</XmlCommand>");
wslist.Add("ProvideItem", @"<XmlCommand>
<Command>ProvideItem</Command>
<Parameter>
<ProvideItem>
<Object>Smartbox</Object>
<Name />
<Parts>0</Parts>
<Units>0</Units>
<Size>9</Size>
</ProvideItem>
</Parameter>
</XmlCommand>");
wslist.Add("SimulateStartButton", @"<XmlCommand>
<Command>SimulateStartButton</Command>
<Parameter>
<LoadMaterialInformation>
<TowerId>000800</TowerId>
<Article></Article>
<Barcode></Barcode>
<TaskId></TaskId>
</LoadMaterialInformation>
</Parameter>
</XmlCommand>");
///=====================================================
fslist.Add("Create a New Component", @"[Order]
Action=NEW
Object=ARTICLE
Name=componentname
[Data]
ARTICLE=Component name
");
fslist.Add("Unload a Carrier", @"[Order]
Action=PROVIDE
Object=CARRIER
Name=carriername
Demand=
Target=");
fslist.Add("Create a New Carrier", @"[Order]
Action=NEW
Object=CARRIER
Name=carriername
[Data]
CARRIER=carriername
ARTICLE=Component
");
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace MydataWcfServiceTest.ServiceReference2 {
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="RtTower", ConfigurationName="ServiceReference2.ITowerAppWS")]
public interface ITowerAppWS {
[System.ServiceModel.OperationContractAttribute(Action="RtTower/ITowerAppWS/WebServiceIsConnected", ReplyAction="RtTower/ITowerAppWS/WebServiceIsConnectedResponse")]
bool WebServiceIsConnected();
[System.ServiceModel.OperationContractAttribute(Action="RtTower/ITowerAppWS/WebServiceIsConnected", ReplyAction="RtTower/ITowerAppWS/WebServiceIsConnectedResponse")]
System.Threading.Tasks.Task<bool> WebServiceIsConnectedAsync();
[System.ServiceModel.OperationContractAttribute(Action="RtTower/ITowerAppWS/XmlAction", ReplyAction="RtTower/ITowerAppWS/XmlActionResponse")]
System.Xml.Linq.XElement XmlAction(string xmlData);
[System.ServiceModel.OperationContractAttribute(Action="RtTower/ITowerAppWS/XmlAction", ReplyAction="RtTower/ITowerAppWS/XmlActionResponse")]
System.Threading.Tasks.Task<System.Xml.Linq.XElement> XmlActionAsync(string xmlData);
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface ITowerAppWSChannel : MydataWcfServiceTest.ServiceReference2.ITowerAppWS, System.ServiceModel.IClientChannel {
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class TowerAppWSClient : System.ServiceModel.ClientBase<MydataWcfServiceTest.ServiceReference2.ITowerAppWS>, MydataWcfServiceTest.ServiceReference2.ITowerAppWS {
public TowerAppWSClient() {
}
public TowerAppWSClient(string endpointConfigurationName) :
base(endpointConfigurationName) {
}
public TowerAppWSClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public TowerAppWSClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public TowerAppWSClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress) {
}
public bool WebServiceIsConnected() {
return base.Channel.WebServiceIsConnected();
}
public System.Threading.Tasks.Task<bool> WebServiceIsConnectedAsync() {
return base.Channel.WebServiceIsConnectedAsync();
}
public System.Xml.Linq.XElement XmlAction(string xmlData) {
return base.Channel.XmlAction(xmlData);
}
public System.Threading.Tasks.Task<System.Xml.Linq.XElement> XmlActionAsync(string xmlData) {
return base.Channel.XmlActionAsync(xmlData);
}
}
}
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
{
public class TowerList
{
public static Dictionary<string, TowerInfo> List = new Dictionary<string, TowerInfo>();
static TowerList() {
if (File.Exists("Config\\TowerList.json"))
{
try
{
var tl = File.ReadAllText("Config\\TowerList.json");
List = JsonConvert.DeserializeObject<Dictionary<string, TowerInfo>>(tl);
}
catch (Exception ex)
{
LogUtil.error("启动时美光料仓信息加载失败:" + ex);
}
}
}
public static void SaveTowerInfo()
{
try
{
File.WriteAllText("Config\\TowerList.json", JsonConvert.SerializeObject(List));
}
catch (Exception ex)
{
LogUtil.error("美光料仓信息保存失败:" + ex);
}
}
}
[Serializable]
public class TowerInfo
{
/// <summary>
/// 麦康宁料仓ID
/// </summary>
public string TowerID;
public string TowerName;
public string PosID;
public bool Enable=false;
public string DeviceGroupName;
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class VLog
{
ILog log;
string Prefix="";
public VLog(string prefix="",string logname= "VStore") {
Prefix = prefix;
log = LogManager.GetLogger(logname);
}
public void Info(string txt) {
if (Prefix != "")
txt =$"[{Prefix}] "+ txt;
log.Info(txt);
}
public void Error(string txt)
{
if (Prefix != "")
txt = $"[{Prefix}] " + txt;
log.Error(txt);
}
}
}
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class VMsg
{
public static List<Msg> msg = new List<Msg>();
public string msgtxt;
public MsgLevel msgLevel;
public ErrInfo errInfo;
public DateTime datetime;
public static List<Msg> get()
{
if (_setlogones)
{
_setlogones = false;
foreach (var m in msg)
LogUtil.info(m.msgtxt);
}
List<Msg> mm = new List<Msg>(msg);
return mm;
}
public static void add(string m, MsgLevel ml, ErrInfo errInfo = ErrInfo.Empty)
{
lock (msg)
{
var fm = msg.Find((x) => x.msgtxt == m);
if (fm == null)
msg.Add(new Msg { msgtxt = m, msgLevel = ml, datetime = DateTime.Now, errInfo = errInfo });
}
}
static bool _setlogones = false;
internal static void setlogones()
{
_setlogones = true;
}
public static void clear()
{
msg.Clear();
}
}
}
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class VServerComm
{
volatile StoreStatus _storeStatus = StoreStatus.Debugging;
/// <summary>
/// 出库,reelid
/// </summary>
public event EventHandler<JobInfo> OutStoreEvent;
public StoreStatus storeStatus {
get => _storeStatus;
set {
if (_storeStatus!= value)
VLog.Info($"set storeStatus to {value}");
_storeStatus = value;
}
}
static string server = Setting_Init.Device_Server_Address;
static string CID;//= Setting_Init.Device_CID;
int StoreID = 1;
string StoreName="";
string WarnMsg = "";
System.Timers.Timer serverConnectTimer = new System.Timers.Timer();
VLog VLog;
object serverclock = new object();
public VServerComm(string cid , VLog vLog) {
VLog = vLog;
CID = cid;
serverConnectTimer.Interval = 1000;
serverConnectTimer.AutoReset = true;
serverConnectTimer.Enabled = true;
serverConnectTimer.Elapsed += ServerConnectTimer_Elapsed;
GC.KeepAlive(serverConnectTimer);
VLog.Info($"server:{server},cid:{CID}");
}
private void ServerConnectTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
if (!RobotManage.isRunning)
ProcessMsg(VMsg.msg);
SendLineStatus();
}
catch (Exception ex)
{
VLog.Error($"ServerConnectTimer_Elapsed:{ex}");
}
finally {
//Monitor.Exit(serverConnectTimer);
}
}
public void ProcessMsg(List<Msg> msg) {
WarnMsg = string.Join(",", msg.Select(x =>
{
if (x.msgLevel == MsgLevel.warning || x.msgLevel == MsgLevel.alarm)
{
return x.msgtxt;
}
return null;
}
).Where(x=>!string.IsNullOrEmpty(x)));
}
public void SendInStoreRequest(string[] codelist, ReelParam reel,bool printlog=false) {
if (RobotManage.InoutDebugMode)
return;
lock (serverclock)
{
var code = ProcessCode(codelist, reel.PlateW, reel.PlateH);
Operation operation = getLineBoxStatus();
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", code }, { "boxId", StoreID.ToString() }, { "doorReelSignal", "1" } };
int retrytimes = 0;
retry:
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 15000, printlog);
if (RobotManage.isRunning &&( resultOperation==null || operation.seq != resultOperation.seq))
{
Thread.Sleep(1000);
//SendInStoreRequest(codelist, reel, printlog);
retrytimes++;
if (retrytimes <= 3)
goto retry;
}
ResultProcess(resultOperation);
}
}
public bool SendStoreState(string posid, StoreStatus storeStatus)
{
lock (serverclock)
{
Operation operation = getLineBoxStatus();
if (!string.IsNullOrEmpty(posid))
operation.boxStatus[StoreID].data.Add(ParamDefine.posId, posid);
if (storeStatus == StoreStatus.OutStoreEnd ||
storeStatus == StoreStatus.OutStoreBoxEnd ||
storeStatus == StoreStatus.InStoreEnd)
{
}
else
operation.boxStatus[StoreID].status = (int)storeStatus;
LogUtil.info(JsonHelper.SerializeObject(operation));
if (RobotManage.InoutDebugMode)
return true;
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 15000);
if (resultOperation == null)
{
VLog.Error($"SendStoreState error,posid:{posid}, storeStatus:{storeStatus}");
return false;
}
if (operation.seq != resultOperation.seq)
{
VLog.Error($"SendStoreState seq error,posid:{posid}, storeStatus:{storeStatus}");
return false;
}
VLog.Info($"SendStoreState success,posid:{posid}, storeStatus:{storeStatus}");
ResultProcess(resultOperation);
this.storeStatus = StoreStatus.StoreOnline;
}
return true;
}
public string spiltStr = "##";
private string ProcessCode(string[] codeList,int reelw,int reelh)
{
string message = "";
//= 7x12 = CODE
foreach (string str in codeList)
{
string code = str.Replace("\r", "");
code = code.Replace("\n", "");
//根据二维码开头获取固定尺寸
string codeSize = $"{reelw}x{reelh}";
message = message + "=" + "1+0x0-" + codeSize + "=" + code + spiltStr;
}
return message;
}
/// <summary>
/// 获取整个料仓的状态
/// </summary>
Operation getLineBoxStatus()
{
//构建发送给服务器的对象
Operation lineOperation = new Operation();
lineOperation.msg = "";
lineOperation.alarmList = new List<AlarmInfo>();
lineOperation.cid = CID;
lineOperation.seq = ConfigAppSettings.nextSeq();
lineOperation.status = 1;
//lineOperation.data = GetBtnStatus();
lineOperation.status = (int)storeStatus;
//判断如果是等待料盘拿走超时,状态改为4Warning
//if (alarmType.Equals(StoreAlarmType.IoSingleTimeOut) && StoreMove.MoveType.Equals(StoreMoveType.OutStore))
//{
// if (StoreMove.MoveStep.Equals(StoreMoveStep.SO_15_WaitTake) || StoreMove.MoveStep.Equals(StoreMoveStep.SO_16_CheckIsTake))
// {
// lineOperation.status = (int)StoreStatus.Warning;
// }
//}
BoxStatus boxStatus = new BoxStatus();
boxStatus.boxId = StoreID;
boxStatus.humidity = Humidity.ToString();
boxStatus.temperature = Temperature.ToString();
//状态
boxStatus.status = (int)storeStatus;
string sendmsg = "";
if (commandResultMsg.Count() > 0)
{
if (commandResultMsg.TryDequeue(out string msg))
{
sendmsg = msg.Trim().Trim(',');
}
}
else if (!string.IsNullOrEmpty(WarnMsg))
{
sendmsg = string.Join(",", new string[] { WarnMsg });
}
else if (!RobotManage.isRunning){
sendmsg = crc.GetString("Res0155","设备未启动");
}
lineOperation.msg = sendmsg;
lineOperation.msg = lineOperation.msg.Trim().Trim(',');
boxStatus.msg = lineOperation.msg;
lineOperation.msgEn = lineOperation.msg;
lineOperation.msgJp = lineOperation.msg;
lineOperation.boxStatus.Add(StoreID, boxStatus);
return lineOperation;
}
private static string api_communication = "service/store/communication"; //流水线状态通信接口
public static string GetPostApi()
{
var host = server;
if (!host.StartsWith("http://"))
{
host = "http://" + host;
}
if (!host.EndsWith("/"))
{
host = host + "/";
}
return host + api_communication;
}
int getthtime = 0;
int laststatus = 0;
public void SendLineStatus()
{
if (RobotManage.InoutDebugMode)
return;
lock (serverclock)
{
bool printlog = false;
DateTime time = DateTime.Now;
//构建发送给服务器的对象
Operation lineOperation = getLineBoxStatus();
//如果还没湿度范围,先获取
if (getthtime < 3)
{
if (Max_Humidity <= 0 || (Max_Temperature <= 0))
{
lineOperation.op = 5;
VLog.Info(StoreName + "没有湿度预警范围,需要从服务器获取,发送OP=" + lineOperation.op);
getthtime++;
}
}
if (lineOperation.status != laststatus) {
laststatus = lineOperation.status;
printlog = true;
}
Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation,700, printlog);
if (resultOperation != null)
getthtime = 0;
//LogUtil.info(JsonHelper.SerializeObject(resultOperation.data));
ResultProcess(resultOperation);
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 700)
{
VLog.Info(StoreName + "TimerProcess[" + span.TotalMilliseconds + "]");
}
}
}
public int queueTaskCount=-1;
ConcurrentQueue<string> commandResultMsg = new ConcurrentQueue<string>();
void ResultProcess(Operation resultOperation)
{
//发送状态信息到服务器
if (resultOperation == null)
{
//判断服务端是否返回出库操作
return;
}
if (resultOperation.op.Equals(1))
{
var barcode = "";
if (resultOperation.data.ContainsKey("code"))
barcode = resultOperation.data["code"];
ReviceInStoreProcess(barcode, resultOperation);
}
else if (resultOperation.op.Equals(2))
{
ReviceOutStoreProcess(resultOperation);
}
else if (resultOperation.op.Equals(5))
{
//ProcessHumidityCMD(resultOperation);
}
ProcessHumidityCMD(resultOperation);
if (resultOperation.data != null)
{
string result = "";
Dictionary<string, string> dataMap = resultOperation.data;
if (dataMap.ContainsKey(ParamDefine.queueTaskCount))
{
var s = dataMap[ParamDefine.queueTaskCount];
if (int.TryParse(s, out int c))
{
queueTaskCount = c;
}
else
{
queueTaskCount = -1;
}
}
}
}
/// <summary>
/// 处理服务器入库库位消息
/// </summary>
/// <param name="message"></param>
/// <param name="resultOperation"></param>
private void ReviceInStoreProcess(string message, Operation resultOperation)
{
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId) && data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
//服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度,
//postId格式BoxId#位置
string posId = data[ParamDefine.posId];
int.TryParse(data[ParamDefine.plateW], out int plateW);
int.TryParse(data[ParamDefine.plateH], out int plateH);
//根据发送的posId获取位置列表
ACStorePosition position = CSVPositionReader<ACStorePosition>.GetPositon(posId);
if (position == null)
{
//出入库没有找到服务器发送的库位,需要打印日志方便查询原因
//SetWarnMsg(ResourceControl.InStoreNoPosition, message, posId);
WarnMsg = crc.GetString("Res0049","入库未找到库位:") + posId;//0505
VLog.Info("收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
return;
}
//TODO:判断BOX是否处于可以入库状态,如果调试或急停中,需要返回给服务器;
//if (RobotManage.mainMachine.IsInStoreReady)
//{
// WarnMsg = "";
// if (plateH > 56)
// plateH = 56;
// JobInfo inStoreJob = new JobInfo(message, posId, plateW, plateH);
// RobotManage.mainMachine.StartInStore(inStoreJob);
// //如果当前正在出入库中,需要记录下来,等待空闲时执行
// VLog.Info(StoreName + " 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】 开始入库!");
//}
//else
{
SendStoreState("", StoreStatus.InStoreError);
}
}
}
public double Max_Humidity;
public double Max_Temperature;
public double Humidity;
public double Temperature;
/// <summary>
/// 处理服务器温湿度消息
/// </summary>
/// <param name="resultOperation"></param>
private void ProcessHumidityCMD(Operation resultOperation)
{
if (resultOperation.data == null)
return;
Dictionary<string, string> data = resultOperation.data;
if (data.ContainsKey(ParamDefine.maxHumidity) && data.ContainsKey(ParamDefine.maxTemperature))
{
string maxHumidity = data[ParamDefine.maxHumidity];
string maxTemp = data[ParamDefine.maxTemperature];
VLog.Info( "收到服务器温湿度预警值:maxHumidity=" + maxHumidity + ",maxTemperature=" + maxTemp);
try
{
this.Max_Humidity = (float)Convert.ToDouble(maxHumidity);
this.Max_Temperature = (float)Convert.ToDouble(maxTemp);
VLog.Info( "保存温湿度预警值:Max_Humidity=" + Max_Humidity + ",Max_Temperature=" + Max_Temperature);
}
catch (Exception ex)
{
VLog.Error("转换温湿度失败:" + ex.ToString());
}
}
}
/// <summary>
/// 处理服务器出库任务消息
/// </summary>
/// <param name="resultOperation"></param>
private void ReviceOutStoreProcess(Operation resultOperation)
{
DateTime time = DateTime.Now;
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId)
&& data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
string posIdStr = data[ParamDefine.posId];
//string cid = data[ParamDefine.cid];
string plateWStr = data[ParamDefine.plateW];
string plateHStr = data[ParamDefine.plateH];
string singleOut = data[ParamDefine.singleOut];
string code = "";
if (!data.TryGetValue("code", out code))
data.TryGetValue(ParamDefine.barcode, out code);
VLog.Info("收到服务器出库消息:poaIs=" + posIdStr + ",platew=" + plateWStr + ",plateh=" + plateHStr + ",code=" + code);
int.TryParse(plateWStr, out int plateW);
int.TryParse(plateHStr, out int plateH);
//根据发送的posId获取位置列表
if (string.IsNullOrEmpty(code))
{
//WarnMsg = StoreName + "没有:【" + cid + "】";
VLog.Error("收到服务器出库命令:没有code");
}
else
{
JobInfo jobInfo = new JobInfo(code, posIdStr, plateW, plateH);
OutStoreEvent?.Invoke("服务器", jobInfo);
}
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 100)
{
VLog.Info(StoreName + "执行 ReviceOutStoreProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
}
}
}
private static string Addr_cancelPutInTask = "/service/store/cancelPutInTask";
public string cancelPutInTask(string deviceName, string barcode)
{
string msg = "";
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("barcode", barcode);
string server = GetAddr(Addr_cancelPutInTask, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
VLog.Info(deviceName + "cancelPutInTask " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
ResultData data = JsonHelper.DeserializeJsonToObject<ResultData>(resultStr);
if (data == null)
{
return msg = deviceName + " cancelPutInTask【 " + barcode + "】 没有收到服务器反馈";
}
else if (data.code.Equals(0).Equals(false))
{
return msg = deviceName + " cancelPutInTask【 " + barcode + "】 :" + data.msg;
}
return "";
}
catch (Exception ex)
{
VLog.Error(deviceName + " " + ex.ToString());
}
return msg;
}
public string DisabledPos(string posId, string barcode)
{
string msg = "";
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("posId", posId);
paramMap.Add("barcode", barcode);
string server = GetAddr("/service/store/disabledPos", paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
VLog.Info("DisabledPos " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
ResultData data = JsonHelper.DeserializeJsonToObject<ResultData>(resultStr);
if (data == null)
{
return msg = " DisabledPos【 " + posId + "】 没有收到服务器反馈";
}
else if (data.code.Equals(0).Equals(false))
{
return msg = " DisabledPos【 " + posId + "】 :" + data.msg;
}
return "";
}
catch (Exception ex)
{
VLog.Error("DisabledPos: " + ex.ToString());
}
return msg;
}
private static string GetAddr(string addr, Dictionary<string, string> paramsMap)
{
if (server.EndsWith("/"))
{
server = server.Substring(0, server.Length - 1);
}
string path = server + addr.Trim() + "?";
foreach (string paramName in paramsMap.Keys)
{
string par = System.Web.HttpUtility.UrlEncode(paramsMap[paramName], System.Text.Encoding.UTF8);
path += paramName + "=" + par + "&";
}
path = path.Substring(0, path.Length - 1);
return path;
}
}
}
\ No newline at end of file
using OnlineStore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
namespace DeviceLibrary
{
public class VStore
{
VServerComm ServerCM;
public VLog VLog;
VStoreCollection vc;
MsgService Msg;
/// <summary>
/// 当前料仓终端口的物料reelid
/// </summary>
public string CurrentTerminalReelID
{
get => ConfigHelper.Config.Get("Runtime_Tower_" + CID + "_CurrentTerminalReelID");
set => ConfigHelper.Config.Set("Runtime_Tower_" + CID + "_CurrentTerminalReelID", value);
}
public string CID;
public string TowerName;
public VStore(TowerInfo towerInfo, VStoreCollection storeCollection) {
vc = storeCollection;
CID = towerInfo.TowerID;
TowerName = towerInfo.TowerName;
VLog = new VLog(CID, CID);
ServerCM = new VServerComm(CID,VLog);
ServerCM.OutStoreEvent += ServerCM_OutStoreEvent;
ServerCM.storeStatus = StoreStatus.None;
Msg = new MsgService("RT-"+CID);
OutStoreJobList = new StoreJobList(crc.GetString("Res0050","出库任务"));
}
public void ServerCM_OutStoreEvent(object sender, JobInfo e)
{
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;
internal void VTowerProcess() {
var ti = vc.GetTowerDetailInformation(CID);
if (ti != null)
{
ServerCM.Temperature = ti.Temperature;
ServerCM.Humidity = ti.Humidity * 100;
if (ti.StatusCode == 26)
{
ServerCM.storeStatus = StoreStatus.StoreOnline;
if (RTStoreStatus != RTStoreStatus.LockToInStore)
{
if (RTStoreStatus != RTStoreStatus.Ready)
VLog.Info("料仓已空闲");
RTStoreStatus = RTStoreStatus.Ready;
if (InStoreJobInfo != null)
{
VLog.Info("入库成功:" + InStoreJobInfo.ToStr());
InStoreJobInfo = null;
}
}
else {
Msg.add("料仓为入库锁定状态,请检查舱门口料盘状态", MsgLevel.alarm);
}
}
else if (ti.StatusCode == 1031)
{
ServerCM.storeStatus = StoreStatus.InStoreExecute;
if (RTStoreStatus != RTStoreStatus.InStoreExecute)
VLog.Info("入库执行中");
RTStoreStatus = RTStoreStatus.InStoreExecute;
InStoreJobInfo = null;
}
else if (ti.StatusCode == 1032)
{
if (RTStoreStatus != RTStoreStatus.InStoreReady)
VLog.Info("物料已在舱口");
RTStoreStatus = RTStoreStatus.InStoreReady;
if (InStoreJobInfo != null)
{
if (!vc.BeginInStore(CID, InStoreJobInfo,VLog)) {
Msg.add(crc.GetString("Res0051","无法入库"), MsgLevel.alarm);
}
}
}
else if (ti.StatusCode == 1040)
{
ServerCM.storeStatus = StoreStatus.OutMoveExecute;
if (RTStoreStatus != RTStoreStatus.OutMoveExecute)
VLog.Info("出库执行中");
RTStoreStatus = RTStoreStatus.OutMoveExecute;
}
else if (ti.StatusCode == 1041)
{
if (RTStoreStatus != RTStoreStatus.OutStoreReady)
VLog.Info("出库已完成");
RTStoreStatus = RTStoreStatus.OutStoreReady;
OutStoreJobList.ClearLastPosid();
}
else if (ti.StatusCode == 0)
{
RTStoreStatus = RTStoreStatus.Offline;
//ServerCM.storeStatus = StoreStatus.InStoreExecute;
}
else if (ti.StatusCode< 10000)
{
RTStoreStatus = RTStoreStatus.Busy;
VLog.Info($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}");
}
else
{
VLog.Error($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}");
ServerCM.storeStatus = StoreStatus.InTrouble;
RTStoreStatus = RTStoreStatus.Error;
}
}
else {
ServerCM.storeStatus = StoreStatus.None;
RTStoreStatus = RTStoreStatus.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 物料已取走
3068 初始化中
*/
}
volatile JobInfo InStoreJobInfo;
StoreJobList OutStoreJobList;
public void RequestInStore(JobInfo jobInfo) {
InStoreJobInfo = jobInfo.Clone();
//return vc.BeginInStore(CID, jobInfo);
}
public bool OutStoreEnd(string reelid) {
CurrentTerminalReelID = reelid;
return ServerCM.SendStoreState(reelid, StoreStatus.OutStoreBoxEnd);
}
public bool InStoreEnd(string posid)
{
return ServerCM.SendStoreState(posid, StoreStatus.InStoreEnd);
}
}
public enum RTStoreStatus {
Offline,
Ready,
InStoreReady,
InStoreExecute,
OutStoreReady,
OutMoveExecute,
NGOutReady,
LockToInStore,
Busy,
Error,
}
}
\ No newline at end of file
using log4net;
using Newtonsoft.Json;
using OnlineStore.Common;
using RtTower.WebService.ComTowerApp.Contract;
using RtTower.WebService.SharedService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
namespace DeviceLibrary
{
public class VStoreCollection
{
MydataWcfServiceTest.ServiceReference2.TowerAppWSClient towerAppWSClient;
ServiceHost Host = null;
public VLog VLog = new VLog();
public string StoreServerURL;
public static Dictionary<string, VStore> VStoreList = new Dictionary<string, VStore>();
public VStoreCollection() {
StoreServerURL = Setting_Init.Device_StoreServerURL;
service.OnCommand += Service_OnCommand;
StartService();
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 =>
{
VLog.Info("加载RT料仓:" + s.TowerID);
VStore vStore = new VStore(s,this);
VStoreList[s.TowerID] = vStore;
});
}
private void Service_OnCommand(object sender, string xmlString)
{
var cmd= XmlCommandSerializer.DeserializeCommand(xmlString);
switch (cmd.Command) {
case "NotifyCarrierLoad":
// put in your code here
var r = XElement.Parse(cmd.Parameter);
var reelid = r.Descendants("Barcode").FirstOrDefault().Value;
var towerid = r.Descendants("TowerId").FirstOrDefault().Value;
VLog.Info("收到入库完成通知:" + $"ReelID:{reelid},TowerID:{towerid}");
if (!VStoreList.ContainsKey(towerid))
{
VLog.Error("收到入库信息,但没有找到该料仓id");
}else
VStoreList[towerid].InStoreEnd(reelid);
break;
case "NotifyCarrierUnload":
// put in your code here
r = XElement.Parse(cmd.Parameter);
reelid = r.Descendants("Barcode").FirstOrDefault().Value;
towerid = r.Descendants("TowerId").FirstOrDefault().Value;
VLog.Info("收到出库完成通知:" + $"ReelID:{reelid},TowerID:{towerid}");
if (!VStoreList.ContainsKey(towerid)) {
VLog.Error("收到出库信息,但没有找到该料仓id");
}
else
VStoreList[towerid].OutStoreEnd(reelid);
//VStoreList[towerid].ReelPutOnOutSide(reelid);
break;
}
}
Thread td;
public void Start() {
td = new Thread(new ThreadStart(Run));
td.Start();
}
bool mstate = false;
void Run() {
mstate = true;
while (mstate) {
Thread.Sleep(1000);
VStoreList.Values.ToList().ForEach(vs=>
{
try
{
MsgService.MSList["RT-" + vs.CID].clear();
vs.VTowerProcess();
}
finally {
MsgService.MSList["RT-" + vs.CID].Show();
}
});
}
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()
{
try
{
VLog.Info("start service");
var uri = new Uri("http://localhost:" + 8686 + "/RtTowerClientService");
VLog.Info(uri.ToString());
Host = new ServiceHost(service, uri);
Host.UnknownMessageReceived += Host_UnknownMessageReceived;
//绑定
System.ServiceModel.Channels.Binding httpBinding = new BasicHttpBinding();
//终结点
Host.AddServiceEndpoint(typeof(RtTowerClientService.IRtTowerClientService), httpBinding, uri);
//Host.Open();
if (Host.Description.Behaviors.Find<System.ServiceModel.Description.ServiceMetadataBehavior>() == null)
{
//行为
ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
behavior.HttpGetEnabled = true;
////元数据地址
//behavior.HttpGetUrl = new Uri("http://localhost:18002/Service");
Host.Description.Behaviors.Add(behavior);
}
var serviceDebugBehavior = Host.Description.Behaviors.Find<ServiceDebugBehavior>();
serviceDebugBehavior.HttpHelpPageEnabled = true;
serviceDebugBehavior.IncludeExceptionDetailInFaults = true;
//启动
Host.Open();
//linkLabel1.Text = uri.ToString();
VLog.Info("start service success");
//btn_start.Enabled = false;
//btn_end.Enabled = true;
//label_service_state.Text = Host.State.ToString();
}
catch (Exception ex)
{
VLog.Error(ex.ToString());
//MessageBox.Show(ex.ToString());
}
}
internal void Stop()
{
mstate = false;
}
internal void ShutDown()
{
StopService();
}
private void Host_UnknownMessageReceived(object sender, UnknownMessageReceivedEventArgs e)
{
try
{
VLog.Info("Host_UnknownMessageReceived:");
VLog.Info(e.Message.ToString());
VLog.Info(e.Message.GetReaderAtBodyContents().ToString());
}
catch (Exception ex)
{
VLog.Error(ex.ToString());
//MessageBox.Show(ex.ToString());
}
}
void StopService()
{
if (Host != null && Host.State == CommunicationState.Opened)
{
Host.Close();
//label_service_state.Text = Host.State.ToString();
Host = null;
}
VLog.Info("stop service success");
}
}
}
......@@ -12,12 +12,23 @@ namespace DeviceLibrary
{
public class DeviceBase
{
public static Dictionary<int, IDevice> DeviceListByAddr = new Dictionary<int, IDevice>();
public string CurrrentRFID = "";
public TrayInfo CurrrentTrayInfo { get => TrayManager.Traylist[CurrrentRFID]; }
public MsgService Msg { get; set; }
public string Name { get; set; }
public string GroupName { get; set; }
public static bool FwdFree(int curaddr) {
int nextaddr = curaddr + 1;
if (nextaddr > 20)
nextaddr = 0;
if (!DeviceListByAddr.ContainsKey(nextaddr))
return true;
return DeviceListByAddr[nextaddr].FrontCheck(nextaddr);
}
public void StopMove(bool ServoOff = false)
{
//runStatus = RunStatus.Stop;
......
using OnlineStore.Common;
using Newtonsoft.Json;
using OnlineStore.Common;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
......@@ -20,19 +21,19 @@ namespace DeviceLibrary
{
lock (jobInfos)
{
if (lastoutpos == jobInfo.PosId)
{
LogUtil.info($"[{jobname}] 出库任务正在执行:" + jobInfo.ToStr());
return;
}
var l = jobInfos.ToList().Find((x) => { return x.PosId == jobInfo.PosId; });
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)
......@@ -50,7 +51,7 @@ namespace DeviceLibrary
lastoutpos = "";
}
}
[Serializable]
public class JobInfo
{
public JobInfo(string wareNum, string posId, int platew, int plateh)
......@@ -81,10 +82,26 @@ namespace DeviceLibrary
/// 料盘高
/// </summary>
public int plateH { get; set; }
public string CID { get; set; }
public string ToStr()
{
return "TrayCode【" + TrayCode + "】,WareNum=【" + WareNum + "】,PosId=【" + PosId + "】,plateW=【" + plateW + "】,plateH=【" + plateH + "】";
return "TrayCode【" + TrayCode + "】,WareNum=【" + WareNum + "】,PosId=【" + PosId + "】,plateW=【" + plateW + "】,plateH=【" + plateH + "】,CID=【" + CID + "】";
}
public string Serialize() {
return JsonConvert.SerializeObject(this);
}
public static JobInfo Deserialize(string s) {
try
{
return JsonConvert.DeserializeObject<JobInfo>(s);
}
catch {
return null;
}
}
public JobInfo Clone() {
return (JobInfo)MemberwiseClone();
}
}
......
......@@ -21,11 +21,16 @@ namespace DeviceLibrary
void Reset_BTN() {
if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.HIGH))
{
foreach (var al in AxisBean.List.Values.ToList())
{
if (!AxisBean.ClearMultiAlarm(out string msg, al))
Msg.add(msg, MsgLevel.warning);
}
Msg.add(crc.GetString("Res0161","按下复位按钮."), MsgLevel.info, ErrInfo.ResetBtn);
}
else
{
Msg.add(crc.GetString("Res0162","急停未解除,按下复位按钮尝试复位安全继电器."), MsgLevel.info, ErrInfo.SuddenStop);
Msg.add(crc.GetString("Res0162","急停未解除,按下复位按钮尝试复位安全继电器."), MsgLevel.info);
}
LogUtil.info("按下复位按钮");
......@@ -41,7 +46,7 @@ namespace DeviceLibrary
if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.HIGH))
{
if (!RobotManage.isRunning)
Msg.add(crc.GetString("Res0163","按下启动按钮,开始启动."), MsgLevel.info, ErrInfo.RunBtn);
Msg.add(crc.GetString("Res0163","检测到自动运行状态,开始启动."), MsgLevel.info, ErrInfo.RunBtn);
else
Msg.add( crc.GetString("Res0164","系统正在运行."), MsgLevel.info);
}
......
......@@ -33,7 +33,7 @@ namespace DeviceLibrary
public Dictionary<string, DeviceGroup> DeviceGroup { get=>RobotManage.DeviceGroup; }
public bool UserPause { get; set; } = false;
ServerCommunication ServerCM = new ServerCommunication();
ServerCommunication ServerCM;
public ManualResetEvent ResetEvent = new ManualResetEvent(true);
......@@ -45,6 +45,7 @@ namespace DeviceLibrary
public MainMachine(out string msg) {
GroupName = "root";
msg = "";
ServerCM = new ServerCommunication(Setting_Init.Device_CID);
Config = RobotManage.Config;
Msg = new MsgService("root");
crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
......@@ -158,6 +159,7 @@ namespace DeviceLibrary
Alarm(AlarmType.None);
StopMove(true);
LedProcess(null);
SafetyDevice.PauseAll();
}
public void BeginHomeReset(bool firstRun=false) {
if (!firstRun)
......@@ -236,13 +238,13 @@ namespace DeviceLibrary
}
else if (isInSuddenDown)
{
Alarm(AlarmType.SuddenStop);
//Alarm(AlarmType.SuddenStop);
Msg.add(crc.GetString("Res0176", "急停中"), MsgLevel.alarm);
ok = false;
}
else if (alarmType != AlarmType.None)
{
Msg.add(crc.GetString("Res0177", "系统需要重置"), MsgLevel.alarm, ErrInfo.SuddenStop);
Msg.add(crc.GetString("Res0177", "系统需要重置"), MsgLevel.alarm);
ok = false;
}
if (IOValue(IO_Type.Airpressure_Check).Equals(IO_VALUE.LOW))
......@@ -260,6 +262,15 @@ namespace DeviceLibrary
else {
lastAirCloseTime = DateTime.MinValue;
}
foreach (var al in AxisBean.List.Values.ToList())
{
if (ok && !AxisBean.RunMultiAxis(true, out string msg, al))
{
ok = false;
Msg.add(msg, MsgLevel.warning);
//LogUtil.error(msg);
}
}
if (alarmType!=AlarmType.SuddenStop)
{
TimeSpan span = DateTime.Now - checkAlarmTime;
......
using OnlineStore.Common;
using log4net;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
......@@ -12,6 +13,7 @@ namespace DeviceLibrary
{
public static List<MoveInfo> List = new List<MoveInfo>();
public int TimeOutSeconds = 60;
ILog LOGGER = null;
public MoveInfo(string name, bool addtolist=true)
{
MoveParam = new ReelParam();
......@@ -20,6 +22,14 @@ namespace DeviceLibrary
this.Name = name;
if(addtolist)
List.Add(this);
if(name.StartsWith("AMH-MI1"))
LOGGER = LogManager.GetLogger("AMH-MI1");
else
if (name.StartsWith("AMH-MI2"))
LOGGER = LogManager.GetLogger("AMH-MI2");
else
LOGGER = LogManager.GetLogger("RollingLogFileAppender");
}
public MoveInfo(object p, string v)
......@@ -118,7 +128,7 @@ namespace DeviceLibrary
if (String.Compare(lastmsg,msg, StringComparison.Ordinal)!=0)
{
lastmsg = msg;
LogUtil.info(msg);
LogUtil.info(LOGGER,msg);
}
}
public void error(string msg) {
......@@ -127,7 +137,7 @@ namespace DeviceLibrary
if (String.Compare(lastmsg,msg, StringComparison.Ordinal)!=0)
{
lastmsg = msg;
LogUtil.error(msg);
LogUtil.error(LOGGER, msg);
}
}
......
......@@ -139,6 +139,13 @@ namespace DeviceLibrary
MI_43,
MI_44,
MI_45,
MI_50,
MI_WaitMT,
MI_51,
MI_52,
MI_53,
MI_54,
MI_55,
}
......
......@@ -29,7 +29,7 @@ namespace DeviceLibrary
lock (allClients)
{
if (allClients.ContainsKey(deviceGroupName))
allClients.Add(deviceGroupName, client);
allClients[deviceGroupName]=client;
else
allClients.Add(deviceGroupName,client);
}
......@@ -51,18 +51,23 @@ namespace DeviceLibrary
};
});
}
static volatile RemoteResult lastresult = RemoteResult.None;
static volatile Dictionary<long, RemoteResult> lastresult = new Dictionary<long, RemoteResult>();
static void ProcessMessage(string deviceGroupName, string message) {
bool isok = true;
long Seq = 1;
try
{
lastresult = RemoteResult.None;
var remoteLoad = JsonConvert.DeserializeObject<RemoteLoad>(message);
Seq = remoteLoad.Seq;
lastresult[Seq] = RemoteResult.None;
switch (remoteLoad.Action)
{
case "SetTrayRequest":
TrayManager.SetTrayRequest(remoteLoad);
break;
case "TrayInfo":
TrayManager.TrayInfo(remoteLoad);
break;
case "TrayRelease":
TrayManager.TrayRelease(remoteLoad);
break;
......@@ -71,7 +76,7 @@ namespace DeviceLibrary
break;
case "OK":
case "FAIL":
lastresult = remoteLoad.Action == "OK" ? RemoteResult.True : RemoteResult.False;
lastresult[Seq] = remoteLoad.Action == "OK" ? RemoteResult.True : RemoteResult.False;
LogUtil.info("Revice Command Callback:" + remoteLoad.GroupName + " - " + remoteLoad.Action);
return;
default:
......@@ -82,7 +87,7 @@ namespace DeviceLibrary
isok = false;
LogUtil.info("Remote process error:"+e.ToString());
}
SendResult(deviceGroupName, isok);
SendResult(deviceGroupName, isok, Seq);
}
public static void SendMessage(string deviceGroupName,RemoteLoad message) {
if (!allClients.ContainsKey(deviceGroupName))
......@@ -105,27 +110,35 @@ namespace DeviceLibrary
if (remoteLoad.RequestLoadInfo != null && string.IsNullOrEmpty(remoteLoad.RequestLoadInfo.DeviceGroupName))
remoteLoad.RequestLoadInfo.DeviceGroupName = GroupName;
LogUtil.info($"{GroupName},发送:{remoteLoad.Action},Seq:{remoteLoad.Seq}");
lastresult = RemoteResult.None;
lastresult[remoteLoad.Seq] = RemoteResult.None;
SendMessage(GroupName, remoteLoad);
return WaitResult(waittime);
return WaitResult(GroupName, remoteLoad.Seq,waittime);
}
static RemoteResult WaitResult(int waittime = 3000)
static RemoteResult WaitResult(string GroupName,long seq,int waittime = 3000)
{
while (lastresult == RemoteResult.None && waittime > 0)
if (!lastresult.ContainsKey(seq))
return RemoteResult.Timeout;
while (lastresult[seq] == RemoteResult.None && waittime > 0)
{
System.Threading.Thread.Sleep(50);
waittime = waittime - 50;
}
if (lastresult == RemoteResult.None)
if (lastresult[seq] == RemoteResult.None)
{
LogUtil.info($"等待{GroupName}反馈超时 seq:"+seq);
lastresult[seq] = RemoteResult.Timeout;
}
var result = lastresult[seq];
lock (lastresult)
{
LogUtil.info("等待远程反馈超时");
lastresult = RemoteResult.Timeout;
lastresult.Remove(seq);
}
return lastresult;
return result;
}
public static void SendResult(string deviceGroupName, bool result)
public static void SendResult(string deviceGroupName, bool result,long Seq)
{
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Seq = Seq;
remoteLoad.Action = result?"OK":"FAIL";
remoteLoad.GroupName = deviceGroupName;
SendMessage(deviceGroupName, remoteLoad);
......
......@@ -38,6 +38,7 @@ namespace DeviceLibrary
public static URRobotControl Robot_MI1;
public static URRobotControl Robot_MI2;
public static URRobotControl Robot_CI;
public static VStoreCollection VStoreCollection;
public static void Init() {
string msg = "";
......@@ -72,30 +73,31 @@ namespace DeviceLibrary
Robot_CI = new URRobotControl(Setting_Init.URRobot_CI_IP);
Robot_CI.SetSpeedRate(Setting_Init.URRobot_CI_Speed_Rate);
if (Robot_MI1.StartRobot()) {
LogUtil.info("MI1 UR机器人启动成功,"+ Robot_MI1.GetStatus());
} else {
IsLoadOk = false;
msg += "MI1 UR机器人启动失败" + "\n";
}
if (Robot_MI2.StartRobot())
{
LogUtil.info("MI2 UR机器人启动成功," + Robot_MI2.GetStatus());
}
else
{
IsLoadOk = false;
msg += "MI2 UR机器人启动失败" + "\n";
}
if (Robot_CI.StartRobot())
{
LogUtil.info("CI UR机器人启动成功," + Robot_CI.GetStatus());
}
else
{
IsLoadOk = false;
msg += "CI UR机器人启动失败" + "\n";
}
VStoreCollection = new VStoreCollection();
//if (Robot_MI1.StartRobot()) {
// LogUtil.info("MI1 UR机器人启动成功,"+ Robot_MI1.GetStatus());
//} else {
// IsLoadOk = false;
// msg += "MI1 UR机器人启动失败" + "\n";
//}
//if (Robot_MI2.StartRobot())
//{
// LogUtil.info("MI2 UR机器人启动成功," + Robot_MI2.GetStatus());
//}
//else
//{
// IsLoadOk = false;
// msg += "MI2 UR机器人启动失败" + "\n";
//}
//if (Robot_CI.StartRobot())
//{
// LogUtil.info("CI UR机器人启动成功," + Robot_CI.GetStatus());
//}
//else
//{
// IsLoadOk = false;
// msg += "CI UR机器人启动失败" + "\n";
//}
CodeManager.LoadConfig();
RemoteService.Init();
mainMachine = new MainMachine(out string m);
......@@ -135,6 +137,7 @@ namespace DeviceLibrary
}
mainThread = new Thread(new ThreadStart(mainMachine.Start));
mainThread.Start();
VStoreCollection.Start();
Thread.Sleep(50);
var d1 = new DeviceRunControl("SideMove", SideMove.DeviceList.Values.ToList<IDevice>());
var d2 = new DeviceRunControl("TransplantMove", TransplantMove.DeviceList.Values.ToList<IDevice>());
......@@ -143,20 +146,8 @@ namespace DeviceLibrary
isRunning = true;
GC.KeepAlive(mainThread);
//Task.Run(()=> {
AxisBean.List.ToList().ForEach((x) => { x.Value.ForEach(y => { AxisManager.AlarmClear(y.Config.DeviceName, y.Config.GetAxisValue()); }); });
Task.Delay(100).Wait();
if (mainMachine.DeviceCheck())
{
mainMachine.BeginHomeReset(true);
}
//}).Wait();
d1.Start();
d2.Start();
d3.Start();
......@@ -172,12 +163,14 @@ namespace DeviceLibrary
mainMachine.Stop();
mainMachine.UserPause = false;
}
VStoreCollection.Stop();
isRunning = false;
}
public static void ShutDown()
{
LogUtil.info("开始关闭系统.");
IOManager.CloseAllConnection();
VStoreCollection.ShutDown();
Robot_MI1.StopRobot();
Robot_MI2.StopRobot();
Robot_CI.StopRobot();
......@@ -195,6 +188,7 @@ namespace DeviceLibrary
LogUtil.info("用户暂停");
else
LogUtil.info("系统暂停: "+msg);
Thread.Sleep(500);
}
else
LogUtil.info("用户取消暂停:"+ msg);
......
......@@ -69,9 +69,8 @@ namespace DeviceLibrary
try
{
var TL = Traylist.Where(t => t.Value.DestinationAddr >= 0).ToDictionary(a => a.Key, a => a.Value);
File.Delete("Config\\TrayList.temp");
File.WriteAllText("Config\\TrayList.temp~", JsonConvert.SerializeObject(TL));
File.Move("Config\\TrayList.temp~", "Config\\TrayList.temp");
ConfigHelper.Config.FileSave(JsonConvert.SerializeObject(TL), "Config\\TrayList.temp~");
ConfigHelper.Config.FileSave(JsonConvert.SerializeObject(TL), "Config\\TrayList.temp");
}
catch (Exception ex)
{
......@@ -117,7 +116,6 @@ namespace DeviceLibrary
/// <param name="requestLoadInfo"></param>
public static void SetTrayRequest(RemoteLoad remoteLoad)
{
LogUtil.info($"SetTrayRequest:{remoteLoad.GroupName}=>{remoteLoad.RequestLoadInfo.DeviceGroupName},{remoteLoad.RequestLoadInfo.TrayType}");
lock (TrayRequest)
{
......@@ -137,7 +135,6 @@ namespace DeviceLibrary
if (trayaddrs.Count == 0)
return false;
var ttt = 0;
if (curaddr1 == 9)
ttt = 15;
......@@ -148,8 +145,6 @@ namespace DeviceLibrary
//当前托盘到需求距离
var ts = dis(a.Addr, ttt);
return !(trayaddrs.Where(t1 => dis(a.Addr, t1) < ts).Count() > 0);
};
return false;
......@@ -178,8 +173,6 @@ namespace DeviceLibrary
else
return d + 20;
}
}
public static void SetToEmpty(string rfid)
{
......@@ -214,6 +207,23 @@ namespace DeviceLibrary
device.TrayRelease();
}
}
public static void TrayInfo(RemoteLoad remoteLoad)
{
var requestLoadInfo = remoteLoad.RequestLoadInfo;
LogUtil.info($"TrayInfo:{remoteLoad.GroupName},{requestLoadInfo.DeviceGroupName},{requestLoadInfo.IsEmpty},{requestLoadInfo?.LoadParam.ToStr()}");
lock (requestLoadInfo)
{
var device = TrayStop.DeviceList[remoteLoad.GroupName];
if (requestLoadInfo.IsEmpty)
{
SetTrayLoadInfo(device.CurrrentRFID, null);
ServerCommunication.UpdateRobotStatus(requestLoadInfo.LoadParam.WareCode, RobotStatusE.FINISHED, remoteLoad.GroupName);
}
else {
SetTrayLoadInfo(device.CurrrentRFID, requestLoadInfo);
}
}
}
/// <summary>
/// 移栽机构是否已空闲
/// </summary>
......@@ -265,7 +275,7 @@ namespace DeviceLibrary
OfflineCount = 0;
lastrefresh = DateTime.Now;
Traylist.Values.ToList().ForEach(ti=> {
if ((lastrefresh - ti.LastUpdateTime).TotalSeconds > 30)
if ((lastrefresh - ti.LastUpdateTime).TotalSeconds > 60)
{
ti.isOnline = false;
OfflineCount++;
......@@ -282,6 +292,7 @@ namespace DeviceLibrary
}
}
public class TrayInfo {
string _rfid;
public string RFID { get => _rfid; set {
......@@ -346,14 +357,38 @@ namespace DeviceLibrary
//TrayTypeDesc.Add(TrayTypeE.C04, crc.GetString("Res0013","ShoeBOX治具"));
if (File.Exists("Config\\TrayList.temp"))
{
bool isreadok = false;
try
{
var tl = File.ReadAllText("Config\\TrayList.temp");
Traylist = JsonConvert.DeserializeObject<Dictionary<string, TrayInfo>>(tl);
isreadok = Traylist != null;
if (!isreadok)
LogUtil.error("启动时托盘信息加载失败");
}
catch (Exception ex)
{
LogUtil.error("启动时托盘信息加载失败:" + ex);
}
if (isreadok)
return;
try
{
var tl = File.ReadAllText("Config\\TrayList.temp~");
Traylist = JsonConvert.DeserializeObject<Dictionary<string, TrayInfo>>(tl);
if (Traylist == null)
{
LogUtil.error("启动时托盘信息加载失败");
Traylist = new Dictionary<string, TrayInfo>();
}
catch (Exception ex) {
LogUtil.error("启动时托盘信息加载失败:"+ex);
}
catch (Exception ex)
{
LogUtil.error("启动时托盘备份信息加载失败:" + ex);
Traylist = new Dictionary<string, TrayInfo>();
}
}
}
public static void Init(Dictionary<string, DeviceGroup> deviceGroup) {
......
......@@ -16,6 +16,7 @@ namespace DeviceLibrary
void Stop();
void TrayRelease();
bool IsFree();
bool FrontCheck(int curaddr);
}
public enum DeviceStateE
......
......@@ -8,6 +8,7 @@ using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DeviceLibrary
......@@ -54,8 +55,8 @@ namespace DeviceLibrary
public void Start()
{
OpenAllServo();
Robot.StartRobot();
Robot.PlayProgram();
//Robot.StartRobot();
//Robot.PlayProgram();
DeviceState = DeviceStateE.HomeReset;
MoveInfo.NewMove(MoveStep.H01_HomeReset);
MoveInfo.log("开始回原");
......@@ -68,21 +69,53 @@ namespace DeviceLibrary
}
public void Process()
{
try
{
MsgService.MSList[GroupName + "-T"].clear();
LogUtil.OutputDebugString("DeviceState:" + DeviceState.ToString());
if (DeviceState == DeviceStateE.HomeReset)
ResetProcess();
else if (DeviceState == DeviceStateE.Run)
{
if (!DeviceCheck())
{
return;
}
OneWayProcess();
RobotMoveProcess();
}
}
finally {
MsgService.MSList[GroupName + "-T"].Show();
}
}
private bool DeviceCheck()
{
if (!Robot.IsRun)
{
Msg.add(POS_Start + crc.GetString("Res0010","机器人未启动,正在尝试启动."), MsgLevel.warning);
Robot.StartRobot();
//Thread.Sleep(1000);
return false;
}
if (!Robot.ClientIsConnected) {
Msg.add(POS_Start + crc.GetString("Res0011","机器人未连接MT,无法操作."), MsgLevel.warning);
return false;
}
return true;
}
int isalivetrytimes = 0;
int StopBufDelayMS = 500;
int StopDelayMS = 1500;
RobotPosition FromPos;
RobotPosition ToPos;
VStore CurrentVStore;
JobInfo CurrentJobInfo;
VStore CurrntOutReadyStore;
public void OneWayProcess()
{
if (CheckWait(MoveInfo))
......@@ -92,33 +125,68 @@ namespace DeviceLibrary
{
case MoveStep.Wait:
LogUtil.OutputDebugString("InStoreJobList:" + InStoreJobList.Count.ToString());
if (InStoreJobList.Dequeue(out JobInfo job)) {
MoveInfo.log("收到物料入库任务:" + job.ToStr());
MoveInfo.MoveParam.WareCode = job.WareNum;
MoveInfo.MoveParam.PosID = job.PosId;
MoveInfo.MoveParam.PlateW = job.plateW;
MoveInfo.MoveParam.PlateH = job.plateH;
if (InStoreJob!=null) {
CurrentJobInfo = InStoreJob.Clone();
InStoreJob = null;
MoveInfo.log("收到物料入库任务:" + CurrentJobInfo.ToStr());
MoveInfo.MoveParam.WareCode = CurrentJobInfo.WareNum;
MoveInfo.MoveParam.PosID = CurrentJobInfo.PosId;
MoveInfo.MoveParam.PlateW = CurrentJobInfo.plateW;
MoveInfo.MoveParam.PlateH = CurrentJobInfo.plateH;
MoveInfo.MoveParam.cid = CurrentJobInfo.CID;
MoveInfo.NextMoveStep(MoveStep.MI_01);
FromPos = RobotManage.MI1Postion[POS_Start + "_MT"];
ToPos = RobotManage.MI1Postion[POS_Start + "_SCAN"];
var cid = MoveInfo.MoveParam.PosID;//.Split('_')[0];
CurrentVStore= VStoreCollection.VStoreList[cid];
ToPos = RobotManage.MI1Postion[TowerList.List[cid].PosID];
MoveInfo.log($"开始转移物料:{FromPos.PositionNum}=>{ToPos.PositionNum}");
}
break;
case MoveStep.MI_01:
MoveInfo.NextMoveStep(MoveStep.MI_02);
Location.ToLow(MoveInfo);
Location.ToHigh(MoveInfo);
RoboMoveInfo.MoveParam = MoveInfo.MoveParam.clone();
RoboMoveInfo.NextMoveStep(MoveStep.MI_01);
MoveInfo.log("机器人开始取料");
break;
case MoveStep.MI_02:
if (RoboMoveInfo.MoveStep==MoveStep.Wait)
if (RoboMoveInfo.MoveStep >= MoveStep.MI_40)
{
MoveInfo.NextMoveStep(MoveStep.MI_10);
Location.ToHigh(MoveInfo);
MoveInfo.NextMoveStep(MoveStep.MI_03);
if (FromPos.PositionNum.EndsWith("MT"))
{
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Action = "";
remoteLoad.GroupName = GroupName;
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.DeviceGroupName = GroupName;
remoteLoad.RequestLoadInfo.IsEmpty = true;
remoteLoad.RequestLoadInfo.LoadParam = RoboMoveInfo.MoveParam.clone();
TrayManager.TrayRelease(remoteLoad);
TrayStop.DeviceList[GroupName].TrayRelease();
RoboMoveInfo.log("取料完成托盘放行");
}
else
RoboMoveInfo.log("取料完成");
}
break;
case MoveStep.MI_03:
if (RoboMoveInfo.MoveStep >= MoveStep.MI_44)
{
MoveInfo.NextMoveStep(MoveStep.MI_04);
CurrentVStore.RequestInStore(new JobInfo(RoboMoveInfo.MoveParam.WareCode, "", RoboMoveInfo.MoveParam.PlateW, RoboMoveInfo.MoveParam.PlateH));
}
break;
case MoveStep.MI_04:
if (RoboMoveInfo.MoveStep == MoveStep.Wait)
{
MoveInfo.log("放入料仓口完成:"+ RoboMoveInfo.MoveParam.ToStr());
MoveInfo.NewMove(MoveStep.Wait);
}
break;
case MoveStep.MI_10:
MoveInfo.NextMoveStep(MoveStep.MI_11);
Rotate.RelMove(RobotManage.Config.AMH_Route_PoToMM * 90, RobotManage.Config.AMH_Route_PoToMM_speed);
......@@ -143,12 +211,89 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.Wait);
}
break;
case MoveStep.MI_50:
CurrntOutReadyStore = VStoreCollection.VStoreList.Values.ToList().Find(vs => vs.RTStoreStatus == RTStoreStatus.OutStoreReady);
if (CurrntOutReadyStore != null)
{
if (string.IsNullOrEmpty(CurrntOutReadyStore.CurrentTerminalReelID))
{
MoveInfo.log("当前出库料仓:" + CurrntOutReadyStore.CID + "已是出库完成状态,但是还没有读到物料完成通知");
return;
}
if (!VStoreCollection.OutStoreReelInfo.ContainsKey(CurrntOutReadyStore.CurrentTerminalReelID))
{
MoveInfo.log("当前出库料仓:" + CurrntOutReadyStore.CID + ",没有找到料盘信息:" + CurrntOutReadyStore.CurrentTerminalReelID);
return;
}
var job = VStoreCollection.OutStoreReelInfo[CurrntOutReadyStore.CurrentTerminalReelID];
CurrentJobInfo = job.Clone();
MoveInfo.log("收到物料出库任务:" + CurrentJobInfo.ToStr());
MoveInfo.MoveParam.WareCode = CurrentJobInfo.WareNum;
MoveInfo.MoveParam.PosID = CurrentJobInfo.PosId;
MoveInfo.MoveParam.PlateW = CurrentJobInfo.plateW;
MoveInfo.MoveParam.PlateH = CurrentJobInfo.plateH;
MoveInfo.MoveParam.cid = CurrntOutReadyStore.CID;
FromPos = RobotManage.MI1Postion[TowerList.List[MoveInfo.MoveParam.cid].PosID];
ToPos = RobotManage.MI1Postion[POS_Start + "_MT"];
MoveInfo.NextMoveStep(MoveStep.MI_51);
MoveInfo.log($"开始转移物料:{FromPos.PositionNum}=>{ToPos.PositionNum}");
}
else {
MoveInfo.log("没有找到,在等待出库的料仓");
MoveInfo.NextMoveStep(MoveStep.Wait);
TrayStop.DeviceList[GroupName].TrayRelease();
}
break;
case MoveStep.MI_51:
MoveInfo.NextMoveStep(MoveStep.MI_52);
RoboMoveInfo.MoveParam = MoveInfo.MoveParam.clone();
RoboMoveInfo.NextMoveStep(MoveStep.MI_01);
MoveInfo.log("机器人开始取放料");
break;
case MoveStep.MI_52:
if (RoboMoveInfo.MoveStep >= MoveStep.MI_40)
{
MoveInfo.NextMoveStep(MoveStep.MI_53);
lock (VStoreCollection.OutStoreReelInfo)
{
VStoreCollection.OutStoreReelInfo.Remove(CurrntOutReadyStore.CurrentTerminalReelID);
CurrntOutReadyStore.CurrentTerminalReelID = "";
}
MoveInfo.log("机器人已取到料");
}
break;
case MoveStep.MI_53:
MoveInfo.NextMoveStep(MoveStep.MI_54);
break;
case MoveStep.MI_54:
if (RoboMoveInfo.MoveStep == MoveStep.Wait)
{
MoveInfo.log("机器人完成取放料");
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.GroupName = "AMH-"+ POS_Start;
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.DeviceGroupName = "AMH-ML5-2";
remoteLoad.RequestLoadInfo.IsEmpty = false;
remoteLoad.RequestLoadInfo.TrayType = TrayTypeE.MTP1.ToString();
remoteLoad.RequestLoadInfo.LoadParam = MoveInfo.MoveParam.clone();// 填充料盘信息
TrayManager.TrayRelease(remoteLoad); //这条会自动放行托盘并且写入托盘目的地
MoveInfo.NewMove(MoveStep.Wait);
}
break;
}
}
public void RobotMoveProcess()
{
if (!Robot.ClientIsConnected)
{
Msg.add("机器人已停止运行", MsgLevel.alarm);
return;
}
if (CheckWait(RoboMoveInfo))
return;
......@@ -160,59 +305,62 @@ namespace DeviceLibrary
case MoveStep.MI_01:
RoboMoveInfo.NextMoveStep(MoveStep.MI_02);
Comp.AbsMove(RoboMoveInfo, RobotManage.Config.AMH_RoboMI1_Comp_P1, RobotManage.Config.AMH_RoboMI1_Comp_P1_speed);
RoboMoveInfo.log("压紧轴到待机点");
break;
case MoveStep.MI_02:
if (!Robot.IsMoving())
{
RoboMoveInfo.NextMoveStep(MoveStep.MI_03);
Robot.SendMoveCmd(FromPos.Take_P5, Setting_Init.URRobot_MI1_Speed_Rate);
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
RoboMoveInfo.log("机器人到Take_P5");
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
break;
case MoveStep.MI_03:
if (!Robot.IsMoving())
{
RoboMoveInfo.NextMoveStep(MoveStep.MI_04);
TrayStop.DeviceList[GroupName].Location.ToLow(MoveInfo);
Comp.AbsMove(null, DeviceGroup.p3, RobotManage.Config.AMH_RoboMI1_Comp_P2_speed);
Comp.BatchAxisStartCheck(IO_Type.MI_Robot_Clamp_Check, IO_VALUE.HIGH);
Robot.SendMoveCmd(FromPos.Take_P6, Setting_Init.URRobot_MI1_Speed_Rate);
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
RoboMoveInfo.log("压紧轴都下压");
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
break;
case MoveStep.MI_04:
if (!Robot.IsMoving() && !Comp.IsBusy)
{
RoboMoveInfo.NextMoveStep(MoveStep.MI_05);
Robot.SendMoveCmd(FromPos.Take_P7, Setting_Init.URRobot_MI1_Speed_Rate);
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
Robot.SendMoveCmd(FromPos.Take_P6, Setting_Init.URRobot_MI1_Speed_Rate);
RoboMoveInfo.log("压紧轴到位");
RoboMoveInfo.log("机器人到Take_P6");
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
break;
case MoveStep.MI_05:
if (!Robot.IsMoving())
if (!Robot.IsMoving() && !Comp.IsBusy)
{
RoboMoveInfo.NextMoveStep(MoveStep.MI_06);
Robot.SendMoveCmd(FromPos.P1, Setting_Init.URRobot_MI1_Speed_Rate);
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
Robot.SendMoveCmd(FromPos.Take_P7, Setting_Init.URRobot_MI1_Speed_Rate);
RoboMoveInfo.log("机器人到Take_P7");
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
break;
case MoveStep.MI_06:
if (!Robot.IsMoving())
{
RoboMoveInfo.NextMoveStep(MoveStep.MI_40);
if (FromPos.PositionNum.EndsWith("MT"))
RoboMoveInfo.NextMoveStep(MoveStep.MI_07);
Robot.SendMoveCmd(FromPos.P1, Setting_Init.URRobot_MI1_Speed_Rate);
RoboMoveInfo.log("机器人到P1");
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
break;
case MoveStep.MI_07:
if (!Robot.IsMoving())
{
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Action = "";
remoteLoad.GroupName = GroupName;
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.DeviceGroupName = GroupName;
remoteLoad.RequestLoadInfo.IsEmpty = true;
remoteLoad.RequestLoadInfo.LoadParam = RoboMoveInfo.MoveParam.clone();
TrayManager.TrayRelease(remoteLoad);
TrayStop.DeviceList[GroupName].TrayRelease();
RoboMoveInfo.log("取料完成托盘放行");
}else
RoboMoveInfo.log("取料完成");
RoboMoveInfo.NextMoveStep(MoveStep.MI_40);
RoboMoveInfo.log("机器人取料完成");
}
break;
//放料到缓存位置
......@@ -221,7 +369,8 @@ namespace DeviceLibrary
{
RoboMoveInfo.NextMoveStep(MoveStep.MI_41);
Robot.SendMoveCmd(ToPos.Put_P2, Setting_Init.URRobot_MI1_Speed_Rate);
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
RoboMoveInfo.log("机器人到Put_P2");
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
break;
case MoveStep.MI_41:
......@@ -231,7 +380,9 @@ namespace DeviceLibrary
Comp.AbsMove(RoboMoveInfo, RobotManage.Config.AMH_RoboMI1_Comp_P1, RobotManage.Config.AMH_RoboMI1_Comp_P1_speed);
Robot.SendMoveCmd(ToPos.Put_P3, Setting_Init.URRobot_MI1_Speed_Rate);
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
RoboMoveInfo.log("压紧轴释放");
RoboMoveInfo.log("机器人到Put_P3");
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
break;
case MoveStep.MI_42:
......@@ -239,7 +390,8 @@ namespace DeviceLibrary
{
RoboMoveInfo.NextMoveStep(MoveStep.MI_43);
Robot.SendMoveCmd(ToPos.Put_P4, Setting_Init.URRobot_MI1_Speed_Rate);
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
RoboMoveInfo.log("机器人到Put_P4");
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
break;
case MoveStep.MI_43:
......@@ -247,7 +399,8 @@ namespace DeviceLibrary
{
RoboMoveInfo.NextMoveStep(MoveStep.MI_44);
Robot.SendMoveCmd(ToPos.P1, Setting_Init.URRobot_MI1_Speed_Rate);
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
RoboMoveInfo.log("机器人到P1");
RoboMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
break;
......@@ -261,13 +414,29 @@ namespace DeviceLibrary
}
}
StoreJobList InStoreJobList = new StoreJobList("入库");
StoreJobList InStoreJobList = new StoreJobList(crc.GetString("Res0013","入库"));
volatile JobInfo InStoreJob;
StoreJobList OutStoreJobList = new StoreJobList(crc.GetString("Res0015","出库"));
internal void StartInStore(ReelParam trayParam)
{
//PosID== 料仓CID
InStoreJob = new JobInfo(trayParam.WareCode, trayParam.PosID, trayParam.PlateW, trayParam.PlateH);
InStoreJob.CID = trayParam.PosID;
InStoreJobList.Enqueue(new JobInfo(trayParam.WareCode, trayParam.PosID, trayParam.PlateW, trayParam.PlateH));
MoveInfo.log("写入入库队列:" + trayParam.ToStr());
}
internal void EnqueueOutStore(JobInfo trayParam)
{
OutStoreJobList.Enqueue(trayParam.Clone());
MoveInfo.log("写入出库队列:" + trayParam.ToStr());
}
internal void StartOutStore()
{
MoveInfo.NewMove(MoveStep.MI_50);
MoveInfo.log("开始出库");
}
/// <summary>
/// 释放托盘
/// </summary>
......@@ -291,11 +460,44 @@ namespace DeviceLibrary
Location.ToLow(MoveInfo);
break;
case MoveStep.H02_HomeReset:
if (!Robot.StartRobot()) {
MoveInfo.CanWhileCount--;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitMsg(POS_Start + crc.GetString("Res0016","机器人连接失败"), MoveInfo.CanWhileCount<=0 ? MsgLevel.alarm: MsgLevel.warning));
}else
MoveInfo.NextMoveStep(MoveStep.H03_HomeReset);
break;
case MoveStep.H03_HomeReset:
if (Robot.IsRun)
{
MoveInfo.NextMoveStep(MoveStep.H04_HomeReset);
Robot.PlayProgram();
MoveInfo.log("Robot.ProgramState:" + Robot.ProgramState);
MoveInfo.log("Robot.ClientIsConnected:" + Robot.ClientIsConnected);
MoveInfo.log("Robot.IsRun:" + Robot.IsRun);
MoveInfo.log("Robot.IsStartConnect:" + Robot.IsStartConnect);
MoveInfo.log("Robot.CurCmdReponse:" + Robot.CurCmdReponse);
} else if (MoveInfo.IsTimeOut(30)) {
MoveInfo.WaitList.Add(WaitResultInfo.WaitMsg(POS_Start + crc.GetString("Res0017","机器人启动失败"), MoveInfo.CanWhileCount <= 0 ? MsgLevel.alarm : MsgLevel.warning));
}
break;
case MoveStep.H04_HomeReset:
MoveInfo.NextMoveStep(MoveStep.H05_HomeReset);
if (Robot.ClientIsConnected)
{
Robot.SendMoveCmd(1, Setting_Init.URRobot_MI1_Speed_Rate);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
else if (MoveInfo.IsTimeOut(10))
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitMsg(POS_Start + crc.GetString("Res0018","机器人未连接MT"), MoveInfo.CanWhileCount <= 0 ? MsgLevel.alarm : MsgLevel.warning));
}
break;
case MoveStep.H03_HomeReset:
case MoveStep.H05_HomeReset:
if (!Robot.IsMoving())
{
MoveInfo.EndMove();
......@@ -305,9 +507,38 @@ namespace DeviceLibrary
}
}
public bool IsFree()
/// <summary>
/// 设备是否有任务
/// </summary>
/// <param name="reelParam"></param>
/// <returns></returns>
public bool HasJob(ReelParam reelParam)
{
if (DeviceState != DeviceStateE.Run)
return false;
if (MoveInfo.MoveStep != MoveStep.Wait)
return false;
if (reelParam == null)
{
//空托盘,判断有没有出库任务
var sc = VStoreCollection.VStoreList.Values.ToList().Find(vs=>vs.RTStoreStatus==RTStoreStatus.OutStoreReady);
return (sc != null);
}
if (!VStoreCollection.VStoreList.ContainsKey(reelParam.SubCID)) {
MoveInfo.log("RT料仓CID不存在:"+ reelParam.SubCID);
return false;
}
//有料托盘,判断目的地料仓是否空闲
if (VStoreCollection.VStoreList[reelParam.SubCID].RTStoreStatus == RTStoreStatus.Ready)
{
return MoveInfo.MoveStep == MoveStep.Wait;
VStoreCollection.VStoreList[reelParam.SubCID].RTStoreStatus = RTStoreStatus.LockToInStore;
return true;
}
MoveInfo.log("RT料仓当前状态:" + VStoreCollection.VStoreList[reelParam.SubCID].RTStoreStatus);
return false;
}
int bufferstoresindex = 0;
string[] bufferstores = new string[] { "B01", "B02", "B03", "B04", "B05", "B06", "B07", "B08" };
......@@ -322,5 +553,14 @@ namespace DeviceLibrary
return c;
}
public bool FrontCheck(int curaddr)
{
throw new NotImplementedException();
}
public bool IsFree()
{
throw new NotImplementedException();
}
}
}
\ No newline at end of file
......@@ -21,6 +21,8 @@ namespace DeviceLibrary
DeviceList.Add(devices[key].GroupName, sideMove);
msg += m;
DeviceListByAddr[devices[key].addr_1] = sideMove;
DeviceListByAddr[devices[key].addr_2] = sideMove;
}
}
DeviceGroup DeviceGroup;
......@@ -120,11 +122,20 @@ namespace DeviceLibrary
case MoveStep.SideMove_01:
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_01);
bool Forcetry = false;
if (LastGoInFail && (LastGoInFailTime - DateTime.Now).TotalSeconds > 5)
if (LastGoInFail && (LastGoInFailTime - DateTime.Now).TotalSeconds > 10)
{
Forcetry = true;
LSAMoveInfo.log("上次托盘进入失败本次重试");
}
if (IOValue(IO_Type.Ls_B_Tray_Check).Equals(IO_VALUE.HIGH))
{
break;
}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)
{
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_02);
......@@ -142,10 +153,15 @@ namespace DeviceLibrary
break;
case MoveStep.SideMove_02:
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_03);
IOMove(IO_Type.Ls_A_Front_Stop, IO_VALUE.HIGH, IO_Type.Ls_A_Front_Check, IO_VALUE.LOW, StopDelayMS);
//IOMove(IO_Type.Ls_A_Front_Stop, IO_VALUE.HIGH, IO_Type.Ls_A_Front_Check, IO_VALUE.LOW, StopDelayMS);
IOMove(IO_Type.Ls_A_Front_Stop, IO_VALUE.HIGH);
//IOMove(IO_Type.Ls_A_BufStop_Fwd, IO_VALUE.HIGH, StopBufDelayMS);
break;
case MoveStep.SideMove_03:
if (IOValue(IO_Type.Ls_A_Front_Check).Equals(IO_VALUE.LOW))
{
IOMove(IO_Type.Ls_A_Front_Stop, IO_VALUE.LOW);
}
if (IOValue(IO_Type.Ls_A_Tray_Check).Equals(IO_VALUE.HIGH)) {
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_04);
LastGoInFail = false;
......@@ -162,11 +178,13 @@ namespace DeviceLibrary
}
break;
case MoveStep.SideMove_04:
if (!FwdFree(DeviceGroup.addr_1))
return;
if (LSBMoveInfo.MoveStep==MoveStep.Wait)
{
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_06);
IOMove(IO_Type.Ls_B_BufStop_Fwd, IO_VALUE.HIGH, 500);
LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
Location_A.ToHigh(LSAMoveInfo);
Location_B.ToHigh(LSAMoveInfo);
}
......@@ -186,7 +204,7 @@ namespace DeviceLibrary
break;
case MoveStep.SideMove_08:
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_09);
LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(800));
LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1200));
break;
case MoveStep.SideMove_09:
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_10);
......@@ -290,16 +308,20 @@ namespace DeviceLibrary
case MoveStep.SideMove_02:
Minfo.NextMoveStep(MoveStep.SideMove_03);
Minfo.log($"{Ls_A_Front_Stop}下降,{Ls_A_BufStop_Rwd}回退");
IOMove(Ls_A_Front_Stop, IO_VALUE.HIGH, Ls_A_Front_Check, IO_VALUE.LOW, StopDelayMS);
//IOMove(Ls_A_Front_Stop, IO_VALUE.HIGH, Ls_A_Front_Check, IO_VALUE.LOW, StopDelayMS);
IOMove(Ls_A_Front_Stop, IO_VALUE.HIGH);
IOMove(Ls_A_BufStop_Rwd, IO_VALUE.HIGH, StopBufDelayMS);
break;
case MoveStep.SideMove_03:
if (IOValue(Ls_A_Front_Check).Equals(IO_VALUE.LOW))
IOMove(Ls_A_Front_Stop, IO_VALUE.LOW);
if (IOValue(Ls_A_Tray_Check).Equals(IO_VALUE.HIGH))
{
Minfo.NextMoveStep(MoveStep.SideMove_04);
Minfo.log($"检测到进入的托盘");
Minfo.CanWhileCount = 3;
Minfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
//Minfo.WaitList.Add(WaitResultInfo.WaitTime(500));
}
else if (Minfo.IsTimeOut(10))
{
......@@ -334,7 +356,7 @@ namespace DeviceLibrary
else
Minfo.NextMoveStep(MoveStep.SideMove_06);
Minfo.WaitList.Add(WaitResultInfo.WaitTime(500));
//Minfo.WaitList.Add(WaitResultInfo.WaitTime(500));
}
else if (Minfo.CanWhileCount > 0)
{
......@@ -352,14 +374,18 @@ namespace DeviceLibrary
break;
///直接穿过流程
case MoveStep.SideMove_06:
if (!FwdFree(addr))
return;
Minfo.NextMoveStep(MoveStep.SideMove_07);
IOMove(Ls_A_Stop, IO_VALUE.HIGH, Ls_A_Tray_Check, IO_VALUE.LOW, StopDelayMS);
//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);
Minfo.log($"{Ls_A_Stop}阻挡放行");
break;
case MoveStep.SideMove_07:
if (IOValue(Ls_A_Tray_Check).Equals(IO_VALUE.LOW))
{
IOMove(Ls_A_Stop, IO_VALUE.LOW);
Minfo.NextMoveStep(MoveStep.SideMove_08);
}
else if (Minfo.IsTimeOut(5)) {
......@@ -392,6 +418,7 @@ namespace DeviceLibrary
}
break;
case MoveStep.SideMove_11:
Minfo.NextMoveStep(MoveStep.SideMove_12);
Location_a.ToHigh(Minfo);
Location_b.ToHigh(Minfo);
......@@ -420,20 +447,28 @@ namespace DeviceLibrary
case MoveStep.SideMove_51:
Minfo.NextMoveStep(MoveStep.SideMove_52);
Line.LineStop("n");
Location_a.ToLow(Minfo);
Minfo.log($"顶升下降横移线体停止");
Minfo.log($"横移线体停止");
break;
case MoveStep.SideMove_52:
if (!FwdFree(addr))
return;
Minfo.NextMoveStep(MoveStep.SideMove_53);
if (LS_Type!= LS_TypeE.NoRfid)
IOMove(Ls_A_Stop, IO_VALUE.HIGH, Ls_A_Tray_Check, IO_VALUE.LOW, StopDelayMS);
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);
Minfo.WaitList.Add(WaitResultInfo.WaitIO(Ls_A_Tray_Check, IO_VALUE.LOW));
break;
case MoveStep.SideMove_17:
Minfo.NextMoveStep(MoveStep.SideMove_18);
IOMove(Ls_A_Stop, IO_VALUE.LOW);
Minfo.WaitList.Add(WaitResultInfo.WaitTime(500));
break;
case MoveStep.SideMove_18:
......@@ -474,6 +509,12 @@ namespace DeviceLibrary
DeviceState = DeviceStateE.Run;
LSAMoveInfo.EndMove();
}
if (trayAstate && trayBstate)
{
LSAMoveInfo.log("托盘上2边都有托盘回原结束");
DeviceState = DeviceStateE.Run;
LSAMoveInfo.EndMove();
}
else if (LS_Type == LS_TypeE.NoRfid)
{
LSAMoveInfo.log($"无Rfid横移");
......@@ -513,6 +554,7 @@ namespace DeviceLibrary
LSAMoveInfo.NextMoveStep(MoveStep.H06_HomeReset);
Location_A.ToLow(LSAMoveInfo);
Location_B.ToLow(LSAMoveInfo);
LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Ls_A_Tray_Check, IO_VALUE.LOW));
LSAMoveInfo.log($"顶升下降");
break;
case MoveStep.H06_HomeReset:
......@@ -544,7 +586,13 @@ namespace DeviceLibrary
{
throw new NotImplementedException();
}
public bool FrontCheck(int curaddr)
{
if (DeviceGroup.addr_1 == curaddr)
return IOValue(IO_Type.Ls_A_Front_Check).Equals(IO_VALUE.LOW);
else
return IOValue(IO_Type.Ls_B_Front_Check).Equals(IO_VALUE.LOW);
}
enum LS_TypeE {
NoRfid,
OneWay,
......
using Newtonsoft.Json;
using OnlineStore;
using OnlineStore.LoadCSVLibrary;
using System;
......@@ -20,6 +21,7 @@ namespace DeviceLibrary
TransplantMove sideMove = new TransplantMove(devices[key],config,out string m);
DeviceList.Add(devices[key].GroupName, sideMove);
msg += m;
DeviceListByAddr[devices[key].addr_1] = sideMove;
}
}
Robot_Config Config;
......@@ -109,10 +111,13 @@ namespace DeviceLibrary
break;
case MoveStep.TransplantMove_01:
MoveInfo.NextMoveStep(MoveStep.TransplantMove_02);
IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.HIGH, IO_Type.AMH_Front_Check,IO_VALUE.LOW, StopDelayMS);
//IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.HIGH, IO_Type.AMH_Front_Check,IO_VALUE.LOW, StopDelayMS);
IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.HIGH);
MoveInfo.log($"前阻挡放行");
break;
case MoveStep.TransplantMove_02:
if (IOValue(IO_Type.AMH_Front_Check).Equals(IO_VALUE.LOW))
IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.LOW);
if (IOValue(IO_Type.AMH_In_Check).Equals(IO_VALUE.HIGH))
{
MoveInfo.NextMoveStep(MoveStep.TransplantMove_03);
......@@ -132,22 +137,26 @@ namespace DeviceLibrary
MoveInfo.MoveParam.RFID = CurrrentRFID;
var through = TrayManager.Process(MoveInfo,CurrrentRFID, DeviceGroup.addr_1, out TrayInfo trayInfo);
MoveInfo.log($"rfid:{CurrrentRFID},TrayManager.Process:{trayInfo.DestinationAddr},{DeviceGroup.addr_1},AMH_Reel_Check:{IOValue(IO_Type.AMH_Reel_Check)},HasLoad:{trayInfo.HasLoad}");
//入库判断
if (trayInfo.DestinationAddr == DeviceGroup.addr_1 && trayInfo.HasLoad)
{
if (IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.HIGH))
{
RemoteLoad remoteLoad1 = new RemoteLoad();
remoteLoad1.Seq = DateTime.Now.Ticks;
remoteLoad1.Action = "DoorLock";
remoteLoad1.RequestLoadInfo = new RequestLoadInfo();
remoteLoad1.RequestLoadInfo.IsEmpty = false;
MoveInfo.MoveParam = trayInfo.TrayParam.clone();
MoveInfo.MoveParam.RFID = CurrrentRFID;
ConfigHelper.Config.Set($"Runtime_{GroupName}_CurrrentRFID", CurrrentRFID);
var remoteresult = RemoteService.SendAndWait(GroupName, remoteLoad1);
if (remoteresult == RemoteResult.True)
{
MoveInfo.log($"{GroupName} 开始转移物料置料仓");
MoveInfo.log($"{GroupName} 开始转移物料置料仓,{CurrrentRFID},{MoveInfo.MoveParam.ToStr()}");
MoveInfo.NextMoveStep(MoveStep.TransplantMove_10); // 送达料仓
SRec.info("物料横移", GroupName, "载物托盘", "开始将物料转移至料仓", CurrrentRFID, MoveInfo.MoveParam.ToStr());
SRec.info(crc.GetString("Res0024","物料横移"), GroupName, crc.GetString("Res0025","载物托盘"), crc.GetString("Res0026","开始将物料转移至料仓"), CurrrentRFID, MoveInfo.MoveParam.ToStr());
ConfigHelper.Config.Set($"Runtime_{GroupName}_MoveParamJson", JsonConvert.SerializeObject(MoveInfo.MoveParam));
return;
}
else if (remoteresult == RemoteResult.False) {
......@@ -158,23 +167,24 @@ namespace DeviceLibrary
{
MoveInfo.log($"入库托盘与 {GroupName} 通讯失败,放行托盘,{MoveInfo.MoveParam.ToStr()}");
MoveInfo.NextMoveStep(MoveStep.TransplantMove_04);
SRec.error("物料横移", GroupName, "载物托盘", "料仓当前不可用,放行托盘", CurrrentRFID, MoveInfo.MoveParam.ToStr());
SRec.error(crc.GetString("Res0024","物料横移"), GroupName, crc.GetString("Res0025","载物托盘"), crc.GetString("Res0033","料仓当前不可用,放行托盘"), CurrrentRFID, MoveInfo.MoveParam.ToStr());
}
}
else
{
Msg.add("托盘没有检测到治具", MsgLevel.warning);
Msg.add(crc.GetString("Res0034","托盘没有检测到物料"), MsgLevel.warning);
return;
}
}
//出库判断
else if (!trayInfo.HasLoad && TrayManager.TryGetTrayRequest(GroupName, CurrrentRFID,out ReelParam reelParam))
{
if (IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.LOW))
{
RemoteLoad remoteLoad2 = new RemoteLoad();
remoteLoad2.Seq = DateTime.Now.Ticks;
remoteLoad2.Action = "DoorLock";
remoteLoad2.RequestLoadInfo = new RequestLoadInfo();
remoteLoad2.RequestLoadInfo.IsEmpty = true;
......@@ -184,20 +194,20 @@ namespace DeviceLibrary
trayInfo.TrayParam= reelParam.clone();
MoveInfo.MoveParam.RFID = CurrrentRFID;
MoveInfo.NextMoveStep(MoveStep.TransplantMove_20); //从料仓取出
SRec.info("物料横移", GroupName, "空托盘", "开始从料仓转移物料至托盘", CurrrentRFID, MoveInfo.MoveParam.ToStr());
SRec.info(crc.GetString("Res0024","物料横移"), GroupName, crc.GetString("Res0030","空托盘"), crc.GetString("Res0035","开始从料仓转移物料至托盘"), CurrrentRFID, MoveInfo.MoveParam.ToStr());
ConfigHelper.Config.Set($"Runtime_{GroupName}_MoveParamJson", JsonConvert.SerializeObject(MoveInfo.MoveParam));
return;
}
else
{
MoveInfo.log($"出库托盘与 {GroupName} 通讯失败,放行托盘");
MoveInfo.NextMoveStep(MoveStep.TransplantMove_04);
SRec.error("物料横移", GroupName, "空托盘", "料仓当前不可用,放行托盘", CurrrentRFID, MoveInfo.MoveParam.ToStr());
SRec.error(crc.GetString("Res0024","物料横移"), GroupName, crc.GetString("Res0030","空托盘"), crc.GetString("Res0033","料仓当前不可用,放行托盘"), CurrrentRFID, MoveInfo.MoveParam.ToStr());
}
}
else {
Msg.add("托盘标记为空托盘,但检测到治具", MsgLevel.warning);
Msg.add(crc.GetString("Res0036","托盘标记为空托盘,但检测到物料"), MsgLevel.warning);
return;
}
......@@ -223,13 +233,15 @@ namespace DeviceLibrary
if (!canpass())
return;
MoveInfo.NextMoveStep(MoveStep.TransplantMove_05);
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.HIGH, IO_Type.AMH_In_Check, IO_VALUE.LOW, StopDelayMS);
//IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.HIGH, IO_Type.AMH_In_Check, IO_VALUE.LOW, StopDelayMS);
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.HIGH);
Location.ToLow(MoveInfo);
MoveInfo.log($"后阻挡放行");
break;
case MoveStep.TransplantMove_05:
if (IOValue(IO_Type.AMH_In_Check).Equals(IO_VALUE.LOW))
{
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.LOW);
MoveInfo.NextMoveStep(MoveStep.Wait);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
MoveInfo.log("托盘已放行");
......@@ -256,6 +268,9 @@ namespace DeviceLibrary
var AMH_TS_P2 = DeviceGroup.p2 - (ReelHeight - 70) * Config.AMH_TS_PoToMM + MetrialGetRetry * 2 * Config.AMH_TS_PoToMM;
axis.AbsMove(MoveInfo, AMH_TS_P2, Config.AMH_TS_P1_speed);
IOMove(IO_Type.AMH_Sucker, IO_VALUE.HIGH);
ConfigHelper.Config.Set($"Runtime_{GroupName}_IsInStore", true);
ConfigHelper.Config.Set($"Runtime_{GroupName}_IsSucker", true);
ConfigHelper.Config.Set($"Runtime_{GroupName}_CurrrentRFID", CurrrentRFID);
MoveInfo.log($"PlateH:{MoveInfo.MoveParam.PlateH},AMH_TS_P2:{AMH_TS_P2},ReelHeight:{ReelHeight},MetrialGetRetry:{MetrialGetRetry}");
break;
......@@ -303,12 +318,15 @@ namespace DeviceLibrary
if (!canpass())
return;
MoveInfo.NextMoveStep(MoveStep.TransplantMove_17);
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.HIGH, IO_Type.AMH_In_Check, IO_VALUE.LOW, StopDelayMS);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
//IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.HIGH, IO_Type.AMH_In_Check, IO_VALUE.LOW, StopDelayMS);
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.HIGH);
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.AMH_In_Check, IO_VALUE.LOW));
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
break;
case MoveStep.TransplantMove_17:
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.LOW);
MoveInfo.log("托盘放行结束");
SRec.info("物料横移", GroupName, "空托盘", "载荷已取走");
SRec.info(crc.GetString("Res0024","物料横移"), GroupName, crc.GetString("Res0030","空托盘"), crc.GetString("Res0037","物料已取走"));
MoveInfo.NewMove(MoveStep.Wait);
break;
//从料仓=>线体
......@@ -329,17 +347,21 @@ namespace DeviceLibrary
AMH_TS_P2 = DeviceGroup.p3 - (ReelHeight - 70) * Config.AMH_TS_PoToMM+ (MetrialGetRetry*2* Config.AMH_TS_PoToMM);
axis.AbsMove(MoveInfo, AMH_TS_P2, Config.AMH_TS_P1_speed);
IOMove(IO_Type.AMH_Sucker, IO_VALUE.HIGH);
ConfigHelper.Config.Set($"Runtime_{GroupName}_IsInStore", false);
ConfigHelper.Config.Set($"Runtime_{GroupName}_IsSucker", true);
ConfigHelper.Config.Set($"Runtime_{GroupName}_IsSuckerSuccess", false);
MoveInfo.log($"PlateH:{MoveInfo.MoveParam.PlateH},AMH_TS_P2:{AMH_TS_P2},ReelHeight:{ReelHeight},MetrialGetRetry:{MetrialGetRetry}");
break;
case MoveStep.TransplantMove_22:
MoveInfo.NextMoveStep(MoveStep.TransplantMove_23);
axis.AbsMove(MoveInfo, Config.AMH_TS_P1, Config.AMH_TS_P1_speed);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.AMH_Reel_Check, IO_VALUE.LOW));
MoveInfo.log($"PlateH:{MoveInfo.MoveParam.PlateH},AMH_TS_P1:{Config.AMH_TS_P1},MetrialGetRetry:{MetrialGetRetry}");
break;
case MoveStep.TransplantMove_23:
MoveInfo.NextMoveStep(MoveStep.TransplantMove_24);
var remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.Action = "DoorRelease";
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.IsEmpty = true;//true出库 false入库
......@@ -358,6 +380,8 @@ namespace DeviceLibrary
if (MetrialGetRetry > 3) {
Msg.add($"{MoveInfo.Name}取料失败", MsgLevel.alarm);
RobotManage.UserPause($"{MoveInfo.Name}取料失败");
MetrialGetRetry = 0;
//return;
}
MoveInfo.NextMoveStep(MoveStep.TransplantMove_21);
return;
......@@ -368,6 +392,7 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.TransplantMove_23);
return;
}
ConfigHelper.Config.Set($"Runtime_{GroupName}_IsSuckerSuccess", true);
TrayManager.ClearTrayRequest(GroupName);
MoveInfo.log("释放料仓门, 设置托盘信息");
remoteLoad.RequestLoadInfo.IsEmpty = false;
......@@ -391,6 +416,8 @@ namespace DeviceLibrary
case MoveStep.TransplantMove_26:
MoveInfo.NextMoveStep(MoveStep.TransplantMove_27);
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);
break;
case MoveStep.TransplantMove_27:
MoveInfo.NextMoveStep(MoveStep.TransplantMove_28);
......@@ -405,13 +432,15 @@ namespace DeviceLibrary
return;
MoveInfo.NextMoveStep(MoveStep.TransplantMove_30);
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.HIGH, IO_Type.AMH_In_Check, IO_VALUE.LOW, StopDelayMS);
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.AMH_In_Check, IO_VALUE.LOW));
break;
case MoveStep.TransplantMove_30:
MoveInfo.NextMoveStep(MoveStep.TransplantMove_31);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.LOW);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
break;
case MoveStep.TransplantMove_31:
SRec.error("物料横移", GroupName, "载物托盘", "物料已到托盘", CurrrentRFID, MoveInfo.MoveParam.ToStr());
SRec.error(crc.GetString("Res0024","物料横移"), GroupName, crc.GetString("Res0025","载物托盘"), crc.GetString("Res0038","物料已到托盘"), CurrrentRFID, MoveInfo.MoveParam.ToStr());
MoveInfo.log("从线体到料仓移栽结束");
MoveInfo.NewMove(MoveStep.Wait);
break;
......@@ -435,8 +464,8 @@ namespace DeviceLibrary
break;
case MoveStep.TransplantMove_02:
MoveInfo2.NextMoveStep(MoveStep.TransplantMove_03);
int ReelHeight = MoveInfo.MoveParam.PlateH;
if (FixtureConfig.GetFixtureHeight(MoveInfo.MoveParam.PlateW, MoveInfo.MoveParam.PlateH, out int actualheight1))
int ReelHeight = MoveInfo2.MoveParam.PlateH;
if (FixtureConfig.GetFixtureHeight(MoveInfo2.MoveParam.PlateW, MoveInfo2.MoveParam.PlateH, out int actualheight1))
ReelHeight = actualheight1;
var AMH_TS_P2 = DeviceGroup.p3 - (ReelHeight - 70) * Config.AMH_TS_PoToMM;
axis.AbsMove(MoveInfo2, AMH_TS_P2, Config.AMH_TS_P2_speed);
......@@ -445,6 +474,8 @@ namespace DeviceLibrary
case MoveStep.TransplantMove_03:
MoveInfo2.NextMoveStep(MoveStep.TransplantMove_04);
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);
break;
case MoveStep.TransplantMove_04:
MoveInfo2.NextMoveStep(MoveStep.TransplantMove_05);
......@@ -457,11 +488,12 @@ namespace DeviceLibrary
case MoveStep.TransplantMove_06:
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Action = "DoorRelease";
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.IsEmpty=false;
remoteLoad.RequestLoadInfo.LoadParam = MoveInfo2.MoveParam.clone();
RemoteService.SendAndWait(GroupName, remoteLoad);
MoveInfo2.log("从线体到料仓移栽结束");
MoveInfo2.log("从线体到料仓移栽结束:"+ MoveInfo2.MoveParam.ToStr());
MoveInfo2.NewMove(MoveStep.Wait);
break;
}
......@@ -487,19 +519,58 @@ namespace DeviceLibrary
Transplant.ToLow(MoveInfo);
break;
case MoveStep.H03_HomeReset:
MoveInfo.NextMoveStep(MoveStep.H04_HomeReset);
if (ConfigHelper.Config.Get($"Runtime_{GroupName}_IsSucker",false))
{
if (string.IsNullOrEmpty(CurrrentRFID))
CurrrentRFID = ConfigHelper.Config.Get($"Runtime_{GroupName}_CurrrentRFID");
TrayManager.Process(MoveInfo, CurrrentRFID, DeviceGroup.addr_1, out _);
MoveInfo.log("检测到上次已打开吸盘,CurrrentRFID:"+ CurrrentRFID);
//入库过程
if (ConfigHelper.Config.Get($"Runtime_{GroupName}_IsInStore", false) && IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.LOW))
{
MoveInfo.log("正在入库,并且托盘无料");
MoveInfo2.NewMove(MoveStep.TransplantMove_01);
MoveInfo2.MoveParam = JsonConvert.DeserializeObject<ReelParam>(ConfigHelper.Config.Get($"Runtime_{GroupName}_MoveParamJson"));
MoveInfo.EndMove();
DeviceState = DeviceStateE.Run;
TrayManager.SetToEmpty(ConfigHelper.Config.Get($"Runtime_{GroupName}_CurrrentRFID"));
}
//出库过程d
if (!ConfigHelper.Config.Get($"Runtime_{GroupName}_IsInStore", false) && IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.LOW))
{
MoveInfo.log("正在出库,并且托盘无料,_IsSuckerSuccess:" + ConfigHelper.Config.Get<bool>($"Runtime_{GroupName}_IsSuckerSuccess"));
if(ConfigHelper.Config.Get<bool>($"Runtime_{GroupName}_IsSuckerSuccess"))
MoveInfo.NewMove(MoveStep.TransplantMove_24);
else
MoveInfo.NewMove(MoveStep.TransplantMove_22);
Transplant.ToHigh(MoveInfo);
MoveInfo.MoveParam = JsonConvert.DeserializeObject<ReelParam>(ConfigHelper.Config.Get($"Runtime_{GroupName}_MoveParamJson"));
DeviceState = DeviceStateE.Run;
}
}
break;
case MoveStep.H04_HomeReset:
MoveInfo.EndMove();
DeviceState = DeviceStateE.Run;
break;
}
}
/// <summary>
/// 判断干涉节点是否阻塞
/// </summary>
/// <returns></returns>
bool canpass() {
if (GroupName == "AMH-SBDH2-2")
{
if (IOManager.IOValue(IO_Type.Ls_B_Front_Check, "LS2").Equals(IO_VALUE.HIGH))
{
Msg.add("LS2-2 堵塞中,暂缓放行", MsgLevel.warning);
Msg.add(crc.GetString("Res0039","LS2-2 堵塞中,暂缓放行"), MsgLevel.warning);
return false;
}
}
......@@ -507,11 +578,12 @@ namespace DeviceLibrary
{
if (IOManager.IOValue(IO_Type.Ls_A_Front_Check, "LS2").Equals(IO_VALUE.HIGH))
{
Msg.add("LS2-1 堵塞中,暂缓放行", MsgLevel.warning);
Msg.add(crc.GetString("Res0040","LS2-1 堵塞中,暂缓放行"), MsgLevel.warning);
return false;
}
}
return true;
return FwdFree(DeviceGroup.addr_1);
}
public void TrayRelease()
......@@ -527,5 +599,10 @@ namespace DeviceLibrary
return true;
}
public bool FrontCheck(int curaddr)
{
return IOValue(IO_Type.AMH_Front_Check).Equals(IO_VALUE.LOW);
}
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
......@@ -22,12 +23,13 @@ namespace DeviceLibrary
TrayStop sideMove = new TrayStop(devices[key],out string m);
DeviceList.Add(devices[key].GroupName, sideMove);
msg += m;
DeviceListByAddr[devices[key].addr_1] = sideMove;
}
}
DeviceGroup DeviceGroup;
MoveInfo MoveInfo;
public PuYueRFID_C2S RFID_1 = null;
CylinderManger Location;
public CylinderManger Location;
public AxisBean axis;
public AxisBean axis2;
......@@ -88,6 +90,11 @@ namespace DeviceLibrary
switch (MoveInfo.MoveStep)
{
case MoveStep.Wait:
if (RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0041","ML5料口门光栅被遮挡"), MsgLevel.warning);
return;
}
if (IOValue(IO_Type.MI_In_Check).Equals(IO_VALUE.HIGH))
{
MoveInfo.log("中间检测到托盘");
......@@ -99,14 +106,24 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.TrayStop_01);
Location.ToLow(MoveInfo);
MoveInfo.log("入口检测到托盘");
IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.HIGH);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
}
else {
//Msg.add(crc.GetString("Res0184","空闲中"), MsgLevel.info);
}
break;
case MoveStep.TrayStop_01:
if (IOValue(IO_Type.MI_Front_Check).Equals(IO_VALUE.LOW))
{
MoveInfo.NextMoveStep(MoveStep.TrayStop_02);
IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.HIGH, IO_Type.AMH_Front_Check, IO_VALUE.LOW, StopDelayMS);
IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.LOW);
}
else if (MoveInfo.IsTimeOut(10)){
MoveInfo.NextMoveStep(MoveStep.Wait);
}
//IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.HIGH, IO_Type.AMH_Front_Check, IO_VALUE.LOW, StopDelayMS);
break;
case MoveStep.TrayStop_02:
if (IOValue(IO_Type.MI_In_Check).Equals(IO_VALUE.HIGH))
......@@ -128,7 +145,7 @@ namespace DeviceLibrary
var stop = TrayManager.TryGetTrayRequest(GroupName, CurrrentRFID, out _);
MoveInfo.log($"CurrrentRFID:{CurrrentRFID},HasLoad:{trayInfo.HasLoad},MI_Reel_Check:{IOValue(IO_Type.MI_Reel_Check)},NeedStop:{stop}");
#region 张东亮处理
if (GroupName == "AMH-MI1" || GroupName == "AMH-MI2")
if (GroupName == "AMH-MI1" && trayInfo.TrayType== TrayTypeE.MTP1)// || GroupName == "AMH-MI2")
{
/*
* 请求一个空托盘
......@@ -156,21 +173,29 @@ namespace DeviceLibrary
//物料信息: trayInfo.TrayParam.clone()
//托盘直接放行: MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
//托盘处理完放行,全局方法: TrayStop.DeviceList["AMH-MI1"].TrayRelease();
if (stop && !trayInfo.HasLoad && IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.LOW))
//if (stop && !trayInfo.HasLoad && IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.LOW))
if (!trayInfo.HasLoad && IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.LOW))
{
MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
//请求的空托盘到达时
var device = MI.DeviceList[GroupName];
if (!device.HasJob(null))
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
else
{
MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
device.StartOutStore();
}
}
else if (trayInfo.DestinationAddr == DeviceGroup.addr_1 && trayInfo.HasLoad && IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.HIGH))
{
MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
//抵达了一个有物料的托盘等待处理
var device = MI.DeviceList[trayInfo.Destination];
if (!device.IsFree())
var device = MI.DeviceList[GroupName];
if (!device.HasJob(trayInfo.TrayParam))
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
else {
MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
device.StartInStore(trayInfo.TrayParam);
}
}
......@@ -181,28 +206,32 @@ namespace DeviceLibrary
#endregion
if (stop && !trayInfo.HasLoad && IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.LOW))
{
//空托盘
MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.Action = "TrayReady";
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.TrayType = trayInfo.TrayType.ToString();
if (trayInfo.TrayParam!=null)
if (trayInfo.TrayParam != null)
remoteLoad.RequestLoadInfo.LoadParam = trayInfo.TrayParam.clone();
remoteLoad.RequestLoadInfo.IsEmpty = true;
MoveInfo.remoteLoad = remoteLoad;
if (RemoteService.SendAndWait(GroupName, remoteLoad)!=RemoteResult.True)
if (RemoteService.SendAndWait(GroupName, remoteLoad) != RemoteResult.True)
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
SRec.info("托盘挡停", GroupName, "空托盘","准备接料", CurrrentRFID);
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))
{
//有物料
MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.Action = "TrayReady";
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.TrayType = trayInfo.TrayType.ToString();
......@@ -217,11 +246,45 @@ namespace DeviceLibrary
}
else
{
SRec.info("托盘挡停", GroupName, "载物托盘", "等待物料被接走", CurrrentRFID, remoteLoad.RequestLoadInfo.LoadParam.WareCode);
SRec.info(crc.GetString("Res0042","托盘挡停"), GroupName, crc.GetString("Res0025","载物托盘"), crc.GetString("Res0044","等待物料被接走"), CurrrentRFID, remoteLoad.RequestLoadInfo.LoadParam.WareCode);
MoveInfo.log($"{GroupName} 请求出库成功");
}
return;
}
/*
else if ((trayInfo.DestinationAddr == DeviceGroup.addr_1 || trayInfo.DestinationAddr == -1) &&
((GroupName == "AMH-ML5-1" && CurrrentRFID.StartsWith("MTP2")) ||
(GroupName == "AMH-ML5-2" && CurrrentRFID.StartsWith("MTP1")))
&& IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.HIGH))
{
MoveInfo.log($"{GroupName} NG出库流程");
//NG物料
MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.Action = "TrayReady";
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.TrayType = trayInfo.TrayType.ToString();
remoteLoad.RequestLoadInfo.LoadParam = new ReelParam();
remoteLoad.RequestLoadInfo.LoadParam.PlateW = 794;
remoteLoad.RequestLoadInfo.LoadParam.PlateH = 120;
remoteLoad.RequestLoadInfo.LoadParam.IsNg = true;
remoteLoad.RequestLoadInfo.LoadParam.NgMsg = "[MT]"+ crc.GetString("Res0045","无信息物料");
remoteLoad.RequestLoadInfo.IsEmpty = false;
MoveInfo.remoteLoad = remoteLoad;
var result = RemoteService.SendAndWait(GroupName, remoteLoad);
if (result != RemoteResult.True)
{
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
MoveInfo.log($"{GroupName} 请求NG出库失败:{result}");
}
else
{
MoveInfo.log($"{GroupName} 请求NG出库成功");
}
return;
}*/
else
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
}
......@@ -240,16 +303,25 @@ namespace DeviceLibrary
Location.ToLow(MoveInfo);
break;
case MoveStep.TrayStop_04:
if (!FwdFree(DeviceGroup.addr_1))
return;
MoveInfo.NextMoveStep(MoveStep.TrayStop_05);
Location.ToLow(MoveInfo);
break;
case MoveStep.TrayStop_05:
if (RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0041","ML5料口门光栅被遮挡"), MsgLevel.warning);
return;
}
MoveInfo.NextMoveStep(MoveStep.TrayStop_06);
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.HIGH, IO_Type.MI_In_Check, IO_VALUE.LOW, StopDelayMS);
//IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.HIGH, IO_Type.MI_In_Check, IO_VALUE.LOW, StopDelayMS);
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.HIGH);
break;
case MoveStep.TrayStop_06:
if (IOValue(IO_Type.MI_In_Check).Equals(IO_VALUE.LOW))
{
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.LOW);
MoveInfo.NextMoveStep(MoveStep.Wait);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
MoveInfo.log("托盘已放行");
......@@ -266,44 +338,79 @@ namespace DeviceLibrary
isalivetrytimes = 0;
break;
case MoveStep.TrayStop_WaitLoadProcess:
Msg.add("等待处理载荷",MsgLevel.info);
Msg.add(crc.GetString("Res0046","等待处理物料"),MsgLevel.info);
if (GroupName != "AMH-MI1" && GroupName != "AMH-MI2" && GroupName != "CI")
{
Msg.add(crc.GetString("Res0047","托盘上有物料,等待同步物料信息."), MsgLevel.info);
//if (result == RemoteResult.True && RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.HIGH))
if (IsDoorSafe())
{
Debug.WriteLine("IsDoorSafe:True");
if (IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.HIGH))
{
Msg.add("托盘上有物料,等待同步物料信息.", MsgLevel.info);
//MoveInfo.log($"{GroupName} 料仓状态不明:{result},有物料");
TrayRelease();
}
else
{
var remoteLoad = new RemoteLoad();
remoteLoad.Action = "IsAlive";
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
var result = RemoteService.SendAndWait(GroupName, remoteLoad);
if (result != RemoteResult.True)
{
isalivetrytimes++;
if (isalivetrytimes > 4)
{
TrayManager.Traylist[CurrrentRFID].SetToEmpty();
//MoveInfo.log($"{GroupName} 料仓状态不明:{result},无物料");
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
MoveInfo.log($"{GroupName} 料仓状态不明:{result}");
}
}
else
{
isalivetrytimes = 0;
}
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitMsg(crc.GetString("Res0046","等待处理物料"), MsgLevel.info));
}
}
break;
case MoveStep.TrayStop_LoadProcessed:
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
Location.ToLow(MoveInfo);
MoveInfo.log("载荷离开, 顶升下降");
SRec.info("托盘挡停", GroupName, "载物托盘", "处理结束", CurrrentRFID);
MoveInfo.log("物料离开, 顶升下降");
SRec.info(crc.GetString("Res0042","托盘挡停"), GroupName, crc.GetString("Res0025","载物托盘"), crc.GetString("Res0048","处理结束"), CurrrentRFID);
break;
}
}
bool IsDoorSafe() {
if (GroupName == "AMH-ML5-1" || GroupName == "AMH-ML5-2")
{
var remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.Action = "IsSafe";
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
var result = RemoteService.SendAndWait(GroupName, remoteLoad,6000);
if (result == RemoteResult.True)
{
Debug.WriteLine("Remote IsSafe:True");
return true;
}
else if (result == RemoteResult.False)
{
Debug.WriteLine("Remote IsSafe:False");
return false;
}
else if (result == RemoteResult.Timeout)
{
Debug.WriteLine("Remote IsSafe:False");
return false;
}
else if (RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0041","ML5料口门光栅被遮挡"), MsgLevel.warning);
return false;
}
else
{
Debug.WriteLine("Remote UnKnow:True");
return true;
}
}
return true;
}
/// <summary>
/// 释放托盘
/// </summary>
......@@ -319,6 +426,11 @@ namespace DeviceLibrary
switch (MoveInfo.MoveStep)
{
case MoveStep.Wait:
if ((GroupName == "AMH-ML5-1" || GroupName == "AMH-ML5-2") && RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0041","ML5料口门光栅被遮挡"), MsgLevel.warning);
break;
}
MoveInfo.NextMoveStep(MoveStep.H01_HomeReset);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
break;
......@@ -328,8 +440,13 @@ namespace DeviceLibrary
break;
case MoveStep.H02_HomeReset:
MoveInfo.NextMoveStep(MoveStep.H03_HomeReset);
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.HIGH, IO_Type.MI_In_Check, IO_VALUE.LOW, StopDelayMS);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
if ((GroupName == "AMH-ML5-1" || GroupName == "AMH-ML5-2") && RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0041","ML5料口门光栅被遮挡"), MsgLevel.warning);
break;
}
//IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.HIGH, IO_Type.MI_In_Check, IO_VALUE.LOW, StopDelayMS);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.MI_In_Check,IO_VALUE.LOW));
break;
case MoveStep.H03_HomeReset:
MoveInfo.EndMove();
......@@ -347,5 +464,10 @@ namespace DeviceLibrary
return true;
}
public bool FrontCheck(int curaddr)
{
return IOValue(IO_Type.MI_Front_Check).Equals(IO_VALUE.LOW);
}
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ DI,0,复位,Reset_BTN,1,,X01,,,,,,,,,,
DI,0,自动模式,AutoRun_Single,2,,X02,,,,,,,,,,
DI,0,气压检测,Airpressure_Check,3,,X03,,,,,,,,,,
DI,0,吸盘进气压力检测,Sucker_suction_detection,4,,X04,,,,,,,,,,
DI,0,ML5出入口安全检测,ML5_DoorSafeCheck,149,,X149,,,,,,,,,,
,,,,,,,,,,,,,,,,
DI,0,LS1-1顶升上升端,Ls_A_Location_Up,5,LS1,X05,,,,,,,,,,
DI,0,LS1-1顶升下降端,Ls_A_Location_Down,6,LS1,X06,,,,,,,,,,
......
......@@ -47,6 +47,10 @@ namespace OnlineStore.LoadCSVLibrary
/// </summary>
public static string Sucker_suction_detection = "Sucker_suction_detection";
/// <summary>
/// DI,0,ML5出入口安全检测,ML5_DoorSafeCheck,149,,X149,,,,,,,,,,
/// </summary>
public static string ML5_DoorSafeCheck = "ML5_DoorSafeCheck";
/// <summary>
/// DI,0,CI点料完成,CI_Count_Finished,97,,X97,,,,,,,,,,
/// </summary>
public static string CI_Count_Finished = "CI_Count_Finished";
......
......@@ -21,7 +21,7 @@ public class RemoteLoad
/// </summary>
public string GroupName;
/// <summary>
/// 载荷信息
/// 物料信息
/// </summary>
public RequestLoadInfo RequestLoadInfo;
}
......@@ -164,12 +164,18 @@ public class ReelParam
/// 唯一序列号
/// </summary>
public string RI { get; set; }
public string DC { get; set; }
/// <summary>
/// 批次号
/// </summary>
public string Batch { get; set; }
public string cid { get; set; }
public string SubCID{ get; set; }
public bool ReelOnFixture { get; set; } = false;
public bool IsInStore { get; set; }
public int HeightPos = 0;
public string RFID = "";
......
......@@ -52,6 +52,7 @@ public class RemoteClient
}
WebSocket4Net.WebSocketState LastState = WebSocket4Net.WebSocketState.None;
public bool IsOnline { get => webSocket.State == WebSocket4Net.WebSocketState.Open; }
int errstatuscounr = 0;
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
if (webSocket.State == WebSocket4Net.WebSocketState.Closed)
......@@ -60,9 +61,19 @@ public class RemoteClient
{
LOGGER.Info($"Remote:{GroupName} 重新连接");
webSocket.Open();
errstatuscounr = 0;
}
catch { }
}
else if (webSocket.State == WebSocket4Net.WebSocketState.Connecting) {
errstatuscounr++;
if (errstatuscounr > 5) {
LOGGER.Info($"Remote:{GroupName} Connecting 超时");
try { webSocket.Close(); } catch { }
webSocket.Open();
errstatuscounr = 0;
}
}
}
volatile RemoteResult lastresult = RemoteResult.None;
private void WebSocket_MessageReceived(object sender, WebSocket4Net.MessageReceivedEventArgs e)
......@@ -84,7 +95,7 @@ public class RemoteClient
case "OK":
case "FAIL":
lastresult = remoteLoad.Action == "OK" ? RemoteResult.True : RemoteResult.False;
LOGGER.Info("Revice Command Callback:" + remoteLoad.GroupName + "-" + remoteLoad.Action);
LOGGER.Info("Revice Command Callback:" + remoteLoad.GroupName + " -" + remoteLoad.Action + " ,Seq:" + remoteLoad.Seq);
return;
default:
if (actionlist.ContainsKey(remoteLoad.Action)) {
......@@ -95,7 +106,7 @@ public class RemoteClient
LOGGER.Info("unknow remote command:" + remoteLoad.Action);
break;
}
SendResult(isok);
SendResult(isok, remoteLoad.Seq);
}
Dictionary<string, Func<RequestLoadInfo, bool>> actionlist = new Dictionary<string, Func<RequestLoadInfo, bool>>();
......@@ -103,6 +114,7 @@ public class RemoteClient
{
actionlist[actionName] = action;
}
int timeoutCount = 0;
RemoteResult WaitResult(int waittime=3000)
{
while (lastresult == RemoteResult.None && waittime > 0)
......@@ -113,7 +125,13 @@ public class RemoteClient
if (lastresult == RemoteResult.None)
{
LOGGER.Info("等待远程反馈超时");
timeoutCount++;
lastresult = RemoteResult.Timeout;
if (timeoutCount > 3)
webSocket.Close();
}
else {
timeoutCount = 0;
}
return lastresult;
}
......@@ -125,12 +143,14 @@ public class RemoteClient
if (string.IsNullOrEmpty(remoteLoad.RequestLoadInfo.DeviceGroupName))
remoteLoad.RequestLoadInfo.DeviceGroupName = GroupName;
}
lastresult = RemoteResult.None;
webSocket.Send(JsonConvert.SerializeObject(remoteLoad));
return WaitResult(waittime);
}
void SendResult(bool result)
void SendResult(bool result,long Seq)
{
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Seq = Seq;
remoteLoad.Action = result ? "OK" : "FAIL";
remoteLoad.GroupName = GroupName;
webSocket.Send(JsonConvert.SerializeObject(remoteLoad));
......
......@@ -49,6 +49,16 @@
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<appender name="VStore" type="log4net.Appender.RollingFileAppender">
<file value="logs/VStore.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<appender name="LngResource" type="log4net.Appender.RollingFileAppender">
<file value="logs/LngResource.log"/>
<param name="Encoding" value="UTF-8"/>
......@@ -79,6 +89,110 @@
<level value="ALL"/>
<appender-ref ref="URROBOTLog"/>
</logger>
<logger name="VStore" additivity="false">
<level value="ALL"/>
<appender-ref ref="VStore"/>
</logger>
<appender name="RtTowerClientService" type="log4net.Appender.RollingFileAppender">
<file value="logs/RtTowerClientService.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<logger name="RtTowerClientService" additivity="false">
<level value="ALL"/>
<appender-ref ref="RtTowerClientService"/>
</logger>
<appender name="AMH-MI1" type="log4net.Appender.RollingFileAppender">
<file value="logs/AMH-MI1.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<logger name="AMH-MI1" additivity="false">
<level value="ALL"/>
<appender-ref ref="AMH-MI1"/>
</logger>
<appender name="AMH-MI2" type="log4net.Appender.RollingFileAppender">
<file value="logs/AMH-MI2.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<logger name="AMH-MI2" additivity="false">
<level value="ALL"/>
<appender-ref ref="AMH-MI2"/>
</logger>
<appender name="003039" type="log4net.Appender.RollingFileAppender">
<file value="logs/RT-003039.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<logger name="003039" additivity="false">
<level value="ALL"/>
<appender-ref ref="003039"/>
</logger>
<appender name="003040" type="log4net.Appender.RollingFileAppender">
<file value="logs/RT-003040.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<logger name="003040" additivity="false">
<level value="ALL"/>
<appender-ref ref="003040"/>
</logger>
<appender name="003043" type="log4net.Appender.RollingFileAppender">
<file value="logs/RT-003043.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<logger name="003043" additivity="false">
<level value="ALL"/>
<appender-ref ref="003043"/>
</logger>
<appender name="003048" type="log4net.Appender.RollingFileAppender">
<file value="logs/RT-003048.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<logger name="003048" additivity="false">
<level value="ALL"/>
<appender-ref ref="003048"/>
</logger>
<!--<root>
<level value="Info" />
<appender-ref ref="RollingLogFileAppender" />
......
......@@ -46,9 +46,10 @@ namespace TheMachine
this.tabc = new System.Windows.Forms.TabControl();
this.tabP1 = new System.Windows.Forms.TabPage();
this.pnl = new System.Windows.Forms.Panel();
this.listView1 = new TheMachine.DoubleBufferListView();
this.cb_EnableBuzzer = new System.Windows.Forms.CheckBox();
this.btn_PauseBuzzer = new System.Windows.Forms.Button();
this.禁用蜂鸣器ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.listView1 = new TheMachine.DoubleBufferListView();
this.menuStrip1.SuspendLayout();
this.tabc.SuspendLayout();
this.tabP1.SuspendLayout();
......@@ -58,6 +59,7 @@ namespace TheMachine
// menuStrip1
//
this.menuStrip1.BackColor = System.Drawing.Color.Transparent;
this.menuStrip1.Font = new System.Drawing.Font("Microsoft YaHei UI", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.设备操作ToolStripMenuItem,
this.语言toolStripMenuItem,
......@@ -65,7 +67,7 @@ namespace TheMachine
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2);
this.menuStrip1.Size = new System.Drawing.Size(1008, 29);
this.menuStrip1.Size = new System.Drawing.Size(1008, 35);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
......@@ -78,41 +80,42 @@ namespace TheMachine
this.toolStripSeparator2,
this.启用调试模式ToolStripMenuItem,
this.toolStripSeparator4,
this.禁用蜂鸣器ToolStripMenuItem,
this.toolStripSeparator3,
this.退出ToolStripMenuItem});
this.设备操作ToolStripMenuItem.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.设备操作ToolStripMenuItem.Name = "设备操作ToolStripMenuItem";
this.设备操作ToolStripMenuItem.Size = new System.Drawing.Size(86, 25);
this.设备操作ToolStripMenuItem.Size = new System.Drawing.Size(104, 31);
this.设备操作ToolStripMenuItem.Text = "设备操作";
//
// btn_run
//
this.btn_run.Name = "btn_run";
this.btn_run.Size = new System.Drawing.Size(176, 26);
this.btn_run.Size = new System.Drawing.Size(204, 32);
this.btn_run.Text = "启动";
this.btn_run.Click += new System.EventHandler(this.btn_run_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(173, 6);
this.toolStripSeparator1.Size = new System.Drawing.Size(201, 6);
//
// btn_stop
//
this.btn_stop.Name = "btn_stop";
this.btn_stop.Size = new System.Drawing.Size(176, 26);
this.btn_stop.Size = new System.Drawing.Size(204, 32);
this.btn_stop.Text = "停止";
this.btn_stop.Click += new System.EventHandler(this.btn_stop_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(173, 6);
this.toolStripSeparator2.Size = new System.Drawing.Size(201, 6);
//
// 启用调试模式ToolStripMenuItem
//
this.启用调试模式ToolStripMenuItem.Enabled = false;
this.启用调试模式ToolStripMenuItem.Name = "启用调试模式ToolStripMenuItem";
this.启用调试模式ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.启用调试模式ToolStripMenuItem.Size = new System.Drawing.Size(204, 32);
this.启用调试模式ToolStripMenuItem.Tag = "not";
this.启用调试模式ToolStripMenuItem.Text = "启用配置模式";
this.启用调试模式ToolStripMenuItem.Visible = false;
......@@ -121,13 +124,13 @@ namespace TheMachine
// toolStripSeparator4
//
this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(173, 6);
this.toolStripSeparator4.Size = new System.Drawing.Size(201, 6);
this.toolStripSeparator4.Visible = false;
//
// 退出ToolStripMenuItem
//
this.退出ToolStripMenuItem.Name = "退出ToolStripMenuItem";
this.退出ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.退出ToolStripMenuItem.Size = new System.Drawing.Size(204, 32);
this.退出ToolStripMenuItem.Text = "退出";
this.退出ToolStripMenuItem.Click += new System.EventHandler(this.退出ToolStripMenuItem_Click);
//
......@@ -136,15 +139,14 @@ namespace TheMachine
this.语言toolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.简体中文ToolStripMenuItem,
this.englishToolStripMenuItem});
this.语言toolStripMenuItem.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.语言toolStripMenuItem.Name = "语言toolStripMenuItem";
this.语言toolStripMenuItem.Size = new System.Drawing.Size(54, 25);
this.语言toolStripMenuItem.Size = new System.Drawing.Size(64, 31);
this.语言toolStripMenuItem.Text = "语言";
//
// 简体中文ToolStripMenuItem
//
this.简体中文ToolStripMenuItem.Name = "简体中文ToolStripMenuItem";
this.简体中文ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.简体中文ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.简体中文ToolStripMenuItem.Tag = "not";
this.简体中文ToolStripMenuItem.Text = "简体中文";
this.简体中文ToolStripMenuItem.Click += new System.EventHandler(this.简体中文ToolStripMenuItem_Click);
......@@ -152,16 +154,15 @@ namespace TheMachine
// englishToolStripMenuItem
//
this.englishToolStripMenuItem.Name = "englishToolStripMenuItem";
this.englishToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.englishToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.englishToolStripMenuItem.Tag = "not";
this.englishToolStripMenuItem.Text = "English";
this.englishToolStripMenuItem.Click += new System.EventHandler(this.englishToolStripMenuItem_Click);
//
// 关于ToolStripMenuItem
//
this.关于ToolStripMenuItem.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.关于ToolStripMenuItem.Name = "关于ToolStripMenuItem";
this.关于ToolStripMenuItem.Size = new System.Drawing.Size(54, 25);
this.关于ToolStripMenuItem.Size = new System.Drawing.Size(64, 31);
this.关于ToolStripMenuItem.Text = "关于";
this.关于ToolStripMenuItem.Click += new System.EventHandler(this.关于ToolStripMenuItem_Click);
//
......@@ -175,7 +176,7 @@ namespace TheMachine
this.tabc.Location = new System.Drawing.Point(0, 35);
this.tabc.Name = "tabc";
this.tabc.SelectedIndex = 0;
this.tabc.Size = new System.Drawing.Size(1008, 361);
this.tabc.Size = new System.Drawing.Size(1008, 465);
this.tabc.TabIndex = 1;
//
// tabP1
......@@ -183,7 +184,7 @@ namespace TheMachine
this.tabP1.Controls.Add(this.pnl);
this.tabP1.Location = new System.Drawing.Point(4, 30);
this.tabP1.Name = "tabP1";
this.tabP1.Size = new System.Drawing.Size(1000, 327);
this.tabP1.Size = new System.Drawing.Size(1000, 431);
this.tabP1.TabIndex = 0;
this.tabP1.Text = "状态";
this.tabP1.UseVisualStyleBackColor = true;
......@@ -194,34 +195,9 @@ namespace TheMachine
this.pnl.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnl.Location = new System.Drawing.Point(0, 0);
this.pnl.Name = "pnl";
this.pnl.Size = new System.Drawing.Size(1000, 327);
this.pnl.Size = new System.Drawing.Size(1000, 431);
this.pnl.TabIndex = 273;
//
// listView1
//
this.listView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(0, 0);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.ShowGroups = false;
this.listView1.Size = new System.Drawing.Size(1000, 327);
this.listView1.TabIndex = 2;
this.listView1.UseCompatibleStateImageBehavior = false;
//
// cb_EnableBuzzer
//
this.cb_EnableBuzzer.AutoSize = true;
this.cb_EnableBuzzer.Location = new System.Drawing.Point(334, 6);
this.cb_EnableBuzzer.Name = "cb_EnableBuzzer";
this.cb_EnableBuzzer.Size = new System.Drawing.Size(96, 18);
this.cb_EnableBuzzer.TabIndex = 5;
this.cb_EnableBuzzer.Text = "使用蜂鸣器";
this.cb_EnableBuzzer.UseVisualStyleBackColor = true;
this.cb_EnableBuzzer.CheckedChanged += new System.EventHandler(this.cb_EnableBuzzer_CheckedChanged);
//
// btn_PauseBuzzer
//
this.btn_PauseBuzzer.BackColor = System.Drawing.Color.OrangeRed;
......@@ -235,14 +211,39 @@ namespace TheMachine
this.btn_PauseBuzzer.Visible = false;
this.btn_PauseBuzzer.Click += new System.EventHandler(this.btn_PauseBuzzer_Click);
//
// 禁用蜂鸣器ToolStripMenuItem
//
this.禁用蜂鸣器ToolStripMenuItem.Name = "禁用蜂鸣器ToolStripMenuItem";
this.禁用蜂鸣器ToolStripMenuItem.Size = new System.Drawing.Size(204, 32);
this.禁用蜂鸣器ToolStripMenuItem.Text = "禁用蜂鸣器";
this.禁用蜂鸣器ToolStripMenuItem.Click += new System.EventHandler(this.禁用蜂鸣器ToolStripMenuItem_Click);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(201, 6);
//
// listView1
//
this.listView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(0, 0);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.ShowGroups = false;
this.listView1.Size = new System.Drawing.Size(1000, 431);
this.listView1.TabIndex = 2;
this.listView1.UseCompatibleStateImageBehavior = false;
//
// Form1
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1008, 396);
this.ClientSize = new System.Drawing.Size(1008, 500);
this.Controls.Add(this.tabc);
this.Controls.Add(this.btn_PauseBuzzer);
this.Controls.Add(this.cb_EnableBuzzer);
this.Controls.Add(this.menuStrip1);
this.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
......@@ -273,7 +274,6 @@ namespace TheMachine
private DoubleBufferListView listView1;
private System.Windows.Forms.TabPage tabP1;
private System.Windows.Forms.ToolStripMenuItem 关于ToolStripMenuItem;
private System.Windows.Forms.CheckBox cb_EnableBuzzer;
private System.Windows.Forms.Button btn_PauseBuzzer;
private System.Windows.Forms.Panel pnl;
private System.Windows.Forms.ToolStripMenuItem 语言toolStripMenuItem;
......@@ -283,6 +283,8 @@ namespace TheMachine
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem btn_stop;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem 禁用蜂鸣器ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
}
}
......@@ -113,7 +113,6 @@ namespace TheMachine
#endregion
LogUtil.info("开始初始化");
cb_EnableBuzzer.Checked = Setting_Init.Device_EnableBuzzer;
AlarmBuzzer.BuzzerStateChange += AlarmBuzzer_BuzzerStateChange;
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
......@@ -132,6 +131,8 @@ namespace TheMachine
// Application.DoEvents();
//}
pnl.Enabled = false;
禁用蜂鸣器ToolStripMenuItem_Click(this, EventArgs.Empty);
}
private void AlarmBuzzer_BuzzerStateChange(object sender, bool e)
......@@ -156,7 +157,7 @@ namespace TheMachine
AddForm("tab_traystopMI", "MI", mi);
AddForm("tab_traystopCI", "CI", ci);
AddForm("tab_traysetting", crc.GetString("Form1_tabc_tab_setting__SettingControl_tabControl1_tabPage1_Text","治具设置"), sc);
AddForm("tab_other", "周边", mc);
AddForm("tab_other", crc.GetString("Form1_tabc_tab_other_Text","周边"), mc);
crc.LanguageProcess(this);
}
......@@ -354,18 +355,18 @@ 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;
}
//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;
//}
RobotManage.Start();
userpause = false;
if (RobotManage.isRunning)
......@@ -448,13 +449,6 @@ namespace TheMachine
AboutBox1 aboutBox1 = new AboutBox1();
aboutBox1.ShowDialog();
}
private void cb_EnableBuzzer_CheckedChanged(object sender, EventArgs e)
{
Setting_Init.Device_EnableBuzzer= cb_EnableBuzzer.Checked;
AlarmBuzzer.Enable = cb_EnableBuzzer.Checked;
}
private void btn_PauseBuzzer_Click(object sender, EventArgs e)
{
AlarmBuzzer.MuteOnce();
......@@ -554,5 +548,22 @@ namespace TheMachine
requestLoadInfo.LoadParam.PlateH = 70;
TrayManager.SetTrayLoadInfo("MTP1-0012", requestLoadInfo);
}
private void 禁用蜂鸣器ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (e == EventArgs.Empty) {
AlarmBuzzer.Enable = !Setting_Init.Device_EnableBuzzer;
}
AlarmBuzzer.Enable = !AlarmBuzzer.Enable;
if (AlarmBuzzer.Enable)
{
禁用蜂鸣器ToolStripMenuItem.Text = crc.GetString(crc.GetString("Res0056","设备操作ToolStripMenuItem_禁用蜂鸣器ToolStripMenuItem_Text"),"禁用蜂鸣器");
}
else
禁用蜂鸣器ToolStripMenuItem.Text = crc.GetString("Res0052","起用蜂鸣器");
Setting_Init.Device_EnableBuzzer = AlarmBuzzer.Enable;
}
}
}
\ No newline at end of file
......@@ -46,6 +46,7 @@ namespace TheMachine
}
}
}
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true).SetValue(Application.ProductName, Application.ExecutablePath);
Config.LoadMyConfig(new Setting_Init().GetType());
Application.ThreadException += Application_ThreadException;
......
......@@ -48,7 +48,7 @@ namespace TheMachine
// label_Statistics
//
this.label_Statistics.AutoSize = true;
this.label_Statistics.Location = new System.Drawing.Point(754, 18);
this.label_Statistics.Location = new System.Drawing.Point(686, 11);
this.label_Statistics.Name = "label_Statistics";
this.label_Statistics.Size = new System.Drawing.Size(56, 16);
this.label_Statistics.TabIndex = 1;
......@@ -58,9 +58,9 @@ namespace TheMachine
//
this.gb_trayinfo.Controls.Add(this.btn_reset);
this.gb_trayinfo.Controls.Add(this.lbl_info);
this.gb_trayinfo.Location = new System.Drawing.Point(714, 185);
this.gb_trayinfo.Location = new System.Drawing.Point(689, 156);
this.gb_trayinfo.Name = "gb_trayinfo";
this.gb_trayinfo.Size = new System.Drawing.Size(240, 170);
this.gb_trayinfo.Size = new System.Drawing.Size(302, 170);
this.gb_trayinfo.TabIndex = 2;
this.gb_trayinfo.TabStop = false;
this.gb_trayinfo.Text = "托盘操作";
......@@ -71,7 +71,7 @@ namespace TheMachine
this.btn_reset.Dock = System.Windows.Forms.DockStyle.Bottom;
this.btn_reset.Location = new System.Drawing.Point(3, 137);
this.btn_reset.Name = "btn_reset";
this.btn_reset.Size = new System.Drawing.Size(234, 30);
this.btn_reset.Size = new System.Drawing.Size(296, 30);
this.btn_reset.TabIndex = 1;
this.btn_reset.Text = "清空托盘";
this.btn_reset.UseVisualStyleBackColor = true;
......@@ -82,16 +82,16 @@ namespace TheMachine
this.lbl_info.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbl_info.Location = new System.Drawing.Point(3, 22);
this.lbl_info.Name = "lbl_info";
this.lbl_info.Size = new System.Drawing.Size(234, 145);
this.lbl_info.Size = new System.Drawing.Size(296, 145);
this.lbl_info.TabIndex = 0;
this.lbl_info.Text = "label1";
//
// ListView2
//
this.ListView2.HideSelection = false;
this.ListView2.Location = new System.Drawing.Point(0, 379);
this.ListView2.Location = new System.Drawing.Point(689, 348);
this.ListView2.Name = "ListView2";
this.ListView2.Size = new System.Drawing.Size(671, 244);
this.ListView2.Size = new System.Drawing.Size(302, 276);
this.ListView2.TabIndex = 0;
this.ListView2.UseCompatibleStateImageBehavior = false;
//
......@@ -102,7 +102,7 @@ namespace TheMachine
this.listView1.Location = new System.Drawing.Point(0, 0);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(671, 355);
this.listView1.Size = new System.Drawing.Size(671, 624);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
......
......@@ -45,7 +45,7 @@ namespace TheMachine
timer1.Stop();
#region listview初始化
listView1.Columns.Clear();
var ColList = new string[] { "RFID", crc.GetString("Res0019", "上次地址"), crc.GetString("Res0020", "更新时间"), crc.GetString("Res0021", "托盘类型"), crc.GetString("Res0022", "载荷"), crc.GetString("Res0023", "目的地"),"ID" };
var ColList = new string[] { "RFID", crc.GetString("Res0019", "上次地址"), crc.GetString("Res0020", "更新时间"), crc.GetString("Res0021", "托盘类型"), crc.GetString("Res0022", "物料"), crc.GetString("Res0023", "目的地"),"ID" };
listView1.View = View.Details;
foreach (var coltxt in ColList)
{
......@@ -60,7 +60,7 @@ namespace TheMachine
#region listview2初始化
ListView2.Columns.Clear();
var ColList2 = new string[] { "设备", crc.GetString("Res0021", "托盘类型"), "备注" };
var ColList2 = new string[] { crc.GetString("Res0053","设备"), crc.GetString("Res0021", "托盘类型"), crc.GetString("Res0054","备注") };
ListView2.View = View.Details;
foreach (var coltxt in ColList2)
{
......@@ -151,7 +151,7 @@ namespace TheMachine
{
var ti = tivk.Value;
var traydesc = TrayManager.TrayTypeDesc[ti.GetTrayType];
var desc = ti.IsEmpty ? "空托盘" :"";
var desc = ti.IsEmpty ? crc.GetString("Res0030","空托盘") :"";
var items = new string[] { traydesc, desc };
var listviewitem = new ListViewItem();
......@@ -180,9 +180,9 @@ namespace TheMachine
}
string txt = "RFID" + ": " + listView1.SelectedItems[0].Text;
txt += "\r\n"+"托盘类型" + ": " + listView1.SelectedItems[0].SubItems[2].Text;
txt += "\r\n"+"载荷" + ": " + listView1.SelectedItems[0].SubItems[3].Text;
txt += "\r\n"+"目的地" + ": " + listView1.SelectedItems[0].SubItems[4].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;
lbl_info.Text = txt;
......
......@@ -104,7 +104,7 @@ namespace TheMachine
//if (ioValue.SubType.Equals(0))
{
this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 26));
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + crc.GetString(ioValue.ProName, ioValue.Explain), ioValue.ProName);
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + crc.GetString(ioValue.ProType + "_" + ioValue.ProName, ioValue.Explain), ioValue.ProName);
this.tableLayoutPanel1.Controls.Add(control, 0, roleindex);
roleindex++;
......@@ -120,7 +120,7 @@ namespace TheMachine
//if (ioValue.SubType.Equals(0))
{
this.tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + crc.GetString(ioValue.ProName, ioValue.Explain), ioValue.ProName);
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + crc.GetString(ioValue.ProType + "_" + ioValue.ProName, ioValue.Explain), ioValue.ProName);
control.Click += Control_Click;
this.tableLayoutPanel2.Controls.Add(control, 0, roleindex);
roleindex++;
......
......@@ -45,7 +45,8 @@ namespace TheMachine.device.Other
this.uc_boxdebug2 = new TheMachine.uc_boxdebug();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.uc_boxdebug3 = new TheMachine.uc_boxdebug();
this.btn_scancameraadjust = new System.Windows.Forms.Button();
this.txt_reelid = new System.Windows.Forms.TextBox();
this.btn_manualout = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.tabPage4.SuspendLayout();
this.panel1.SuspendLayout();
......@@ -73,7 +74,8 @@ namespace TheMachine.device.Other
//
// tabPage4
//
this.tabPage4.Controls.Add(this.btn_scancameraadjust);
this.tabPage4.Controls.Add(this.btn_manualout);
this.tabPage4.Controls.Add(this.txt_reelid);
this.tabPage4.Controls.Add(this.panel1);
this.tabPage4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tabPage4.Location = new System.Drawing.Point(4, 22);
......@@ -174,7 +176,7 @@ namespace TheMachine.device.Other
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(798, 470);
this.tabPage1.Size = new System.Drawing.Size(992, 548);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "MI1 点位";
this.tabPage1.UseVisualStyleBackColor = true;
......@@ -186,7 +188,7 @@ namespace TheMachine.device.Other
this.uc_boxdebug1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uc_boxdebug1.Location = new System.Drawing.Point(3, 3);
this.uc_boxdebug1.Name = "uc_boxdebug1";
this.uc_boxdebug1.Size = new System.Drawing.Size(792, 464);
this.uc_boxdebug1.Size = new System.Drawing.Size(986, 542);
this.uc_boxdebug1.TabIndex = 0;
//
// tabPage2
......@@ -195,7 +197,7 @@ namespace TheMachine.device.Other
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(798, 470);
this.tabPage2.Size = new System.Drawing.Size(992, 548);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "MI2 点位";
this.tabPage2.UseVisualStyleBackColor = true;
......@@ -207,7 +209,7 @@ namespace TheMachine.device.Other
this.uc_boxdebug2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uc_boxdebug2.Location = new System.Drawing.Point(3, 3);
this.uc_boxdebug2.Name = "uc_boxdebug2";
this.uc_boxdebug2.Size = new System.Drawing.Size(792, 464);
this.uc_boxdebug2.Size = new System.Drawing.Size(986, 542);
this.uc_boxdebug2.TabIndex = 0;
//
// tabPage3
......@@ -216,7 +218,7 @@ namespace TheMachine.device.Other
this.tabPage3.Location = new System.Drawing.Point(4, 22);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
this.tabPage3.Size = new System.Drawing.Size(798, 470);
this.tabPage3.Size = new System.Drawing.Size(992, 548);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "CI 点位";
this.tabPage3.UseVisualStyleBackColor = true;
......@@ -228,18 +230,25 @@ namespace TheMachine.device.Other
this.uc_boxdebug3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uc_boxdebug3.Location = new System.Drawing.Point(3, 3);
this.uc_boxdebug3.Name = "uc_boxdebug3";
this.uc_boxdebug3.Size = new System.Drawing.Size(792, 464);
this.uc_boxdebug3.Size = new System.Drawing.Size(986, 542);
this.uc_boxdebug3.TabIndex = 0;
//
// btn_scancameraadjust
// txt_reelid
//
this.btn_scancameraadjust.Location = new System.Drawing.Point(19, 242);
this.btn_scancameraadjust.Name = "btn_scancameraadjust";
this.btn_scancameraadjust.Size = new System.Drawing.Size(141, 34);
this.btn_scancameraadjust.TabIndex = 22;
this.btn_scancameraadjust.Text = "相机扫码调试";
this.btn_scancameraadjust.UseVisualStyleBackColor = true;
this.btn_scancameraadjust.Click += new System.EventHandler(this.btn_scancameraadjust_Click);
this.txt_reelid.Location = new System.Drawing.Point(56, 310);
this.txt_reelid.Name = "txt_reelid";
this.txt_reelid.Size = new System.Drawing.Size(192, 21);
this.txt_reelid.TabIndex = 22;
//
// btn_manualout
//
this.btn_manualout.Location = new System.Drawing.Point(254, 300);
this.btn_manualout.Name = "btn_manualout";
this.btn_manualout.Size = new System.Drawing.Size(100, 38);
this.btn_manualout.TabIndex = 23;
this.btn_manualout.Text = "reelid出库";
this.btn_manualout.UseVisualStyleBackColor = true;
this.btn_manualout.Click += new System.EventHandler(this.btn_manualout_Click);
//
// MycronicControl
//
......@@ -250,6 +259,7 @@ namespace TheMachine.device.Other
this.Load += new System.EventHandler(this.MycronicControl_Load);
this.tabControl1.ResumeLayout(false);
this.tabPage4.ResumeLayout(false);
this.tabPage4.PerformLayout();
this.panel1.ResumeLayout(false);
this.flowLayoutPanel1.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
......@@ -280,6 +290,7 @@ namespace TheMachine.device.Other
private URRobot.UCURRobot ucurRobot2;
private System.Windows.Forms.GroupBox groupBox4;
private URRobot.UCURRobot ucurRobot3;
private System.Windows.Forms.Button btn_scancameraadjust;
private System.Windows.Forms.Button btn_manualout;
private System.Windows.Forms.TextBox txt_reelid;
}
}
......@@ -35,19 +35,10 @@ namespace TheMachine.device.Other
}
private void btn_scancameraadjust_Click(object sender, EventArgs e)
private void btn_manualout_Click(object sender, EventArgs e)
{
//CodeLibrary.CodeResourceControl.GetLanguageEvent += Crc_GetLanguageEvent;
CodeLibrary.FrmCodeDecode frm = new CodeLibrary.FrmCodeDecode();
//frm.CurrLanguage = Crc_GetLanguageEvent();
frm.chbZxing.Checked = false;
try
{
frm.ShowDialog();
frm.Dispose();
}
catch { }
RobotManage.VStoreCollection.VLog.Info("手动出库:"+ txt_reelid.Text);
RobotManage.VStoreCollection.BeginOutStore(new JobInfo(txt_reelid.Text, "", 0, 0), RobotManage.VStoreCollection.VLog);
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!