Commit bc154b7d 刘韬

1

1 个父辈 40e19609
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.Common</RootNamespace>
<AssemblyName>MyCommon</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
......
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DeviceLibrary</RootNamespace>
<AssemblyName>DeviceLibrary</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
......
......@@ -4,6 +4,7 @@ using OnlineStore.DeviceLibrary.IO;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
......@@ -26,6 +27,18 @@ namespace DeviceLibrary
{
ConfigIO configIo = StoreManager.Config.DOList[device][ioType];
instance.WriteSingleDO(configIo.DeviceName, configIo.SlaveID, configIo.GetIOAddr(), ioValue);
if (configIo.GetIOAddr() == 9 || configIo.GetIOAddr() == 12) {
LogUtil.info($"{configIo.GetIOAddr()}=={ioValue},device={device},ioType={ioType}");
StackTrace stackTrace = new StackTrace();
for (int i = 0; i < stackTrace.FrameCount; i++)
{
StackFrame stackFrame = stackTrace.GetFrame(i);
string fileName = stackFrame.GetFileName();
int lineNumber = stackFrame.GetFileLineNumber();
LogUtil.info($"Function {stackFrame.GetMethod().Name} called from {fileName}, line {lineNumber}");
}
}
//Thread.Sleep(60);
}
else
......
using OnlineStore;
using OnlineStore.Common;
using RemoteSheardObject;
using Robot.UR;
using System;
using System.Collections.Generic;
......@@ -15,8 +16,10 @@ namespace DeviceLibrary
int lastMoveCmd = 0;
URRobotControl robot;
System.Timers.Timer RobotCheck;
public RobotHelper(URRobotControl _robot) {
string Robotname;
public RobotHelper(URRobotControl _robot,string robotname) {
robot = _robot;
Robotname = robotname;
RobotCheck = new System.Timers.Timer(5000);
RobotCheck.Elapsed += RobotCheck_Elapsed;
......@@ -60,6 +63,23 @@ namespace DeviceLibrary
}
else
RobotStatus = true;
uploadStatus();
}
void uploadStatus() {
EquipMsgData equipMsg = new EquipMsgData();
equipMsg.msgList = new List<EquipMessage>();
equipMsg.status = RobotStatus?1:2;
if (!RobotStatus)
{
equipMsg.msgList.Add(new EquipMessage()
{
msg = crc.GetString("Res0058", "机器人当前不可用"),
type = EquipMessage.ConvertType(MsgLevel.alarm.ToString())
});
}
equipMsg.equipName = Robotname;
TheLine.UploadStatus(equipMsg);
}
public void Move(MoveInfo moveInfo, int movecmd) {
if (moveInfo != null)
......
......@@ -19,6 +19,8 @@ namespace DeviceLibrary
public void Info(string txt) {
if (String.Compare(lastinfo, txt, StringComparison.Ordinal) == 0)
return;
lastinfo = txt;
if (Prefix != "")
txt =$"[{Prefix}] "+ txt;
......@@ -29,6 +31,8 @@ namespace DeviceLibrary
{
if (String.Compare(lasterr, txt, StringComparison.Ordinal) == 0)
return;
lasterr = txt;
if (Prefix != "")
txt = $"[{Prefix}] " + txt;
log.Error(txt);
......
......@@ -103,6 +103,8 @@ namespace DeviceLibrary
else if ((DateTime.Now - LastStatusTime).TotalSeconds > 30)
{
TerminalError = true;
if (InStoreJobInfo!=null)
CurrentTerminalReelID = InStoreJobInfo.WareNum;
if (RTStoreStatus == RTStoreStatus.InStoreReady)
{
VLog.Error($"入库超时出错,没有执行入库过程,RTStoreStatus={RTStoreStatus}:" + InStoreJobInfo?.ToStr());
......@@ -256,7 +258,7 @@ namespace DeviceLibrary
}
if (RTStoreStatus == RTStoreStatus.InStoreError)
{
return crc.GetString("Res0069","入库出错,物料NG");
return crc.GetString("Res0069","入库出错,物料NG") + " Barcode:" + InStoreJobInfo?.WareNum;
}
return crc.GetString("Res0070","空闲中");
}
......
......@@ -2,5 +2,5 @@
<packages>
<package id="Fleck" version="1.2.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net461" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net461" requireReinstallation="true" />
</packages>
\ No newline at end of file
......@@ -4,6 +4,7 @@ using OnlineStore.LoadCSVLibrary;
using RemoteSheardObject;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
......@@ -37,10 +38,10 @@ namespace DeviceLibrary
equipMsg.msgList.Add(new EquipMessage()
{
msg = ml.msgtxt,
status = ml.msgLevel == MsgLevel.alarm ? 1 : 0
type = EquipMessage.ConvertType(ml.msgLevel.ToString())
});
if (ml.msgLevel == MsgLevel.alarm)
equipMsg.status = 1;
equipMsg.status = 2;
});
equipMsg.equipName = GroupName;
TheLine.UploadStatus(equipMsg);
......@@ -253,13 +254,6 @@ namespace DeviceLibrary
StopMove(true);
//storeStatus = StoreStatus.SuddenStop;
}
//else if (_alarmType.Equals(AlarmType.NoAirCheck))
//{
// //isNoAirCheck = true;
// LogUtil.error(Name + " 未检测到气压信号 ,停止运动, 打开报警灯 ");
// StopMove(true);
// //storeStatus = StoreStatus.SuddenStop;
//}
}
internal bool NoAlarm()
{
......@@ -290,14 +284,41 @@ namespace DeviceLibrary
public IO_VALUE IOValue(string ioType) => IOManager.IOValue(ioType, GroupName);
public void IOMove(string IoType, IO_VALUE value, int msTime = 0)
{
if (msTime <= 0)
{
IOManager.IOMove(IoType, value, GroupName);
//if (IoType == "Ls_A_BufStop_Fwd" || IoType == "Ls_B_BufStop_Fwd")
//{
// LogUtil.info($"{IoType}=={value},device={GroupName},msTime={msTime}");
// StackTrace stackTrace = new StackTrace();
// for (int i = 0; i < stackTrace.FrameCount; i++)
// {
// StackFrame stackFrame = stackTrace.GetFrame(i);
// string fileName = stackFrame.GetFileName();
// int lineNumber = stackFrame.GetFileLineNumber();
// LogUtil.info($"-Function {stackFrame.GetMethod().Name} called from {fileName}, line {lineNumber}");
// }
//}
}
else
{
Task.Run(() =>
{
//if (IoType == "Ls_A_BufStop_Fwd" || IoType == "Ls_B_BufStop_Fwd")
//{
// LogUtil.info($"Task {IoType}=={value},device={GroupName},msTime={msTime}");
// StackTrace stackTrace = new StackTrace();
// for (int i = 0; i < stackTrace.FrameCount; i++)
// {
// StackFrame stackFrame = stackTrace.GetFrame(i);
// string fileName = stackFrame.GetFileName();
// int lineNumber = stackFrame.GetFileLineNumber();
// LogUtil.info($"Task -Function {stackFrame.GetMethod().Name} called from {fileName}, line {lineNumber}");
// }
//}
IOManager.IOMove(IoType, value, GroupName);
Thread.Sleep(msTime);
IO_VALUE tValue = value.Equals(IO_VALUE.HIGH) ? IO_VALUE.LOW : IO_VALUE.HIGH;
......
......@@ -137,6 +137,7 @@ namespace DeviceLibrary
if (!IsConfigMode)
return;
}
LogUtil.info("开始启动设备线程");
mainThread = new Thread(new ThreadStart(mainMachine.Start));
mainThread.Start();
VStoreCollection.Start();
......
......@@ -46,16 +46,19 @@ namespace DeviceLibrary
Msg = new MsgService(GroupName+"-T");
MoveInfo = new MoveInfo(GroupName + "-T");
RoboMoveInfo = new MoveInfo(GroupName + "-Robo");
string robotname = "";
if (device.GroupName == "AMH-MI1")
{
Robot = RobotManage.Robot_MI1;
robotname = "R1";
}
else
{
Robot = RobotManage.Robot_MI2;
POS_Start = "MI2";
robotname = "R2";
}
robotHelper = new RobotHelper(Robot);
robotHelper = new RobotHelper(Robot, robotname);
Comp = AxisBean.List[DeviceGroup.GroupName][0];
//Rotate = AxisBean.List[DeviceGroup.GroupName][1];
BufferSlotsManger = new BufferSlotsManger(POS_Start);
......@@ -236,7 +239,7 @@ namespace DeviceLibrary
}
else
{
MoveInfo.log("没有找到,在等待出库的料仓");
MoveInfo.log("没有找到,在等待出库的料仓 SN:"+ InStoreError.CurrentTerminalReelID);
MoveInfo.NextMoveStep(MoveStep.Wait);
TrayStop.DeviceList[GroupName].TrayRelease();
return;
......
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.LoadCSVLibrary</RootNamespace>
<AssemblyName>LoadCSVLibrary</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
......
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
using CodeLibrary;
using RemoteSheardObject;
using System;
using System.Collections.Generic;
using System.IO;
......@@ -207,14 +208,18 @@ public class ReelParam
}
}
bool islog = false;
public void logresult()
/// <summary>
/// NG口位置,1=左侧,2=右侧
/// </summary>
/// <param name="NgPos"></param>
public void logresult(int NgPos = 0)
{
if (!islog)
{
islog = true;
var datetime = DateTime.Now;
string countfile = $"\\Logs\\NGLOG_{datetime:yyyyMMdd}.csv";
Directory.CreateDirectory("\\Logs\\");
string countfile = $".\\Logs\\NGLOG_{datetime:yyyyMMdd}.csv";
Directory.CreateDirectory(".\\Logs\\");
if (!File.Exists(countfile))
{
StreamWriter sw1 = new StreamWriter(countfile, true, Encoding.GetEncoding("GB2312"));
......@@ -234,6 +239,15 @@ public class ReelParam
sw.Dispose();
}
catch { }
Task.Run(()=> {
NgMsgData ngMsgData = new NgMsgData();
ngMsgData.ngPos = NgPos;
ngMsgData.ngMsg = NgMsg;
ngMsgData.barcode = WareCode;
ngMsgData.type = "1";
ngMsgData.mType = "";
TheLine.uploadNgReel(ngMsgData);
});
}
}
}
......
......@@ -13,14 +13,34 @@ namespace RemoteSheardObject
public string equipName { get; set; }
public int ngCount { get; set; }
public List<EquipMessage> msgList { get; set; }
/// <summary>
/// 1.正常, 2.报警, 3.入库中, 4.出库中, 5,满料穿
/// </summary>
public int status { get; set; }
public int p1status { get; set; }
public int p2status { get; set; }
}
public class EquipMessage
{
public string msg { get; set; }
public string name { get; set; }
public int status { get; set; }
//public int status { get; set; }
/**
* 消息类型,info,warning,error
*/
public string type;
public static string ConvertType(string msglevel) {
switch (msglevel) {
case "info":
return "info";
case "warning":
return "warning";
case "alarm":
return "error";
}
return "info";
}
}
......
......@@ -52,7 +52,7 @@ namespace RemoteSheardObject
}
public class HttpHelper
{
static ILog Log = LogManager.GetLogger("HTTP");
static ILog Log = LogManager.GetLogger("RollingLogFileAppender");
public static bool PingURLIP(string url, int ms = 100)
{
string[] urlArray = url.Split('/');
......@@ -146,10 +146,11 @@ namespace RemoteSheardObject
public static T2 Post<T1,T2>(string url, T1 jsonobject, int timeout = 5000, bool printlog = false)
{
string json = "";
string result = "";
try
{
json = JsonConvert.SerializeObject(jsonobject);
string result = Post(url, json, timeout);
result = Post(url, json, timeout);
T2 op = JsonConvert.DeserializeObject<T2>(result);
if (printlog)
{
......@@ -159,7 +160,7 @@ namespace RemoteSheardObject
}
catch (Exception ex)
{
Log.Error("Post 出错【"+ json + "】:" + ex);
Log.Error("Post 出错【"+ json + "】:result:"+ result+"\r\n" + ex);
}
return default;
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RemoteSheardObject
{
public class NgMsgData
{
// NG口位置,1=左侧,2=右侧
public int ngPos = 0;
// 物料类型:pizzaBox,pcb,tray,reel
public string mType;
// 条码
public string barcode;
// 库位号
public string posName;
// 出入库类型,1=入库,2=出库
public string type;
// NG原因
public string ngMsg;
}
}
......@@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RemoteSheardObject</RootNamespace>
<AssemblyName>RemoteSheardObject</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -91,6 +92,7 @@
<Compile Include="MyWebClient.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="NgMsgData.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RemoteClient.cs" />
<Compile Include="SLog.cs" />
......
......@@ -56,7 +56,7 @@ namespace RemoteSheardObject
foreach (var k in taskdata.Keys.ToArray())
{
if (result.data.ContainsKey(k+"_out"))
taskdata[k] = int.Parse(result.data[k + "_out"]);
taskdata[k] = int.Parse(result.data[k + "_out"].ToString());
}
return taskdata;
}
......@@ -102,6 +102,25 @@ namespace RemoteSheardObject
string url = CombineUrl(Config.Get("Device_Server_Address"), "/rest/micron/device/updateStatus");
var resultStr = HttpHelper.Post<EquipMsgData, ResultData>(url, equipMsgData);
}
public static void uploadNgReel(NgMsgData ngMsgData)
{
string url = CombineUrl(Config.Get("Device_Server_Address"), "/rest/micron/device/uploadNgReel");
var resultStr = HttpHelper.Post<NgMsgData, ResultData>(url, ngMsgData,5000,true);
}
/// <summary>
/// NG口位置,1=左侧,2=右侧
/// </summary>
/// <param name="ngPos"></param>
public static void ClearNgPos(int ngPos)
{
var postData = new Dictionary<string, string>()
{
{"ngMsgData",ngPos.ToString() }
};
string url = CombineUrl(Config.Get("Device_Server_Address"), "/rest/micron/device/clearNgPos");
var resultStr = SubmitPostData(url, postData);
}
public class ResultData
{
//{"code":0,"msg":"ok","data":"7"}
......@@ -109,7 +128,7 @@ namespace RemoteSheardObject
public string msg { get; set; }
public Dictionary<string, string> data { get; set; }
public Dictionary<string, object> data { get; set; }
}
public static string SubmitPostData(string url, Dictionary<string, string> postData)
{
......
......@@ -3,17 +3,17 @@
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" />
<package id="SuperSocket.ClientEngine.Core" version="0.10.0" targetFramework="net461" />
<package id="System.Collections.Specialized" version="4.3.0" targetFramework="net461" />
<package id="System.Linq" version="4.3.0" targetFramework="net461" />
<package id="System.Linq" version="4.3.0" targetFramework="net461" requireReinstallation="true" />
<package id="System.Net.NameResolution" version="4.3.0" targetFramework="net461" />
<package id="System.Net.Security" version="4.3.0" targetFramework="net461" />
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net461" requireReinstallation="true" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net461" requireReinstallation="true" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net461" requireReinstallation="true" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net461" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net461" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net461" requireReinstallation="true" />
<package id="System.Threading" version="4.3.0" targetFramework="net461" />
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net461" />
<package id="WebSocket4Net" version="0.15.2" targetFramework="net461" />
......
......@@ -199,7 +199,7 @@
</root>-->
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
......
......@@ -360,10 +360,12 @@ namespace TheMachine
private void btn_run_Click(object sender, EventArgs e)
{
lock (this)
{
if (!RobotManage.isRunning)
{
LogUtil.info("用户按下启动:"+ sender.ToString());
LogUtil.info("用户按下启动:" + sender.ToString());
RobotManage.Start();
userpause = false;
if (RobotManage.isRunning)
......@@ -385,6 +387,7 @@ namespace TheMachine
RobotManage.UserPause(userpause);
}
}
}
private void RobotManage_UserPauseSet(object sender, bool e)
{
if (this.InvokeRequired)
......
......@@ -19,7 +19,7 @@ namespace TheMachine.Properties {
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
......
......@@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType>
<RootNamespace>TheMachine</RootNamespace>
<AssemblyName>MT</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>false</Deterministic>
......
......@@ -76,7 +76,7 @@ namespace TheMachine.device.Other
stateView.Items.Clear();
foreach (var store in VStoreCollection.VStoreList.Values.ToList()) {
ListViewItem lvi = new ListViewItem(new string[] { "", TowerList.List[store.CID].TowerName+"-"+store.CID, store.RTStoreStatus.ToString(), store.GetStateStr() });
ListViewItem lvi = new ListViewItem(new string[] { "", TowerList.List[store.CID].PosID+"-"+store.CID, store.RTStoreStatus.ToString(), store.GetStateStr() });
stateView.Items.Add(lvi);
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!