Commit 501ae682 张东亮

agv按钮状态上报

1 个父辈 8f19e344
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<configSections> <configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections> </configSections>
<appSettings> <appSettings>
<!--是否开机自动启动料仓--> <!--是否开机自动启动料仓-->
<add key="App_AutoRun" value="1" /> <add key="App_AutoRun" value="1"/>
<add key="CameraName" value="GigE:acA3800-10gc (23124327)#" /> <add key="CameraName" value="GigE:acA3800-10gc (23124327)#"/>
<add key="Config_Pwd" value="123456" /> <add key="Config_Pwd" value="123456"/>
<add key="CodeType" value="QR Code#Data Matrix ECC 200#barcode" /> <add key="CodeType" value="QR Code#Data Matrix ECC 200#barcode"/>
<!--二维码参数文件所在路径,文件名与二维码类型名一样--> <!--二维码参数文件所在路径,文件名与二维码类型名一样-->
<add key="CodeParamPath" value="Conifg\" /> <add key="CodeParamPath" value="Conifg\"/>
<add key="CodeCount" value="3" /> <add key="CodeCount" value="3"/>
</appSettings> </appSettings>
<log4net> <log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs/AutoScanAndLabel.log" /> <file value="logs/AutoScanAndLabel.log"/>
<param name="Encoding" value="UTF-8" /> <param name="Encoding" value="UTF-8"/>
<appendToFile value="true" /> <appendToFile value="true"/>
<rollingStyle value="Date" /> <rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd" /> <datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" /> <conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout> </layout>
</appender> </appender>
<appender name="LngResource" type="log4net.Appender.RollingFileAppender"> <appender name="LngResource" type="log4net.Appender.RollingFileAppender">
<file value="logs/LngResource.log" /> <file value="logs/LngResource.log"/>
<param name="Encoding" value="UTF-8" /> <param name="Encoding" value="UTF-8"/>
<appendToFile value="true" /> <appendToFile value="true"/>
<rollingStyle value="Date" /> <rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd" /> <datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%m%n" /> <conversionPattern value="%m%n"/>
</layout> </layout>
</appender> </appender>
<appender name="standrobot" type="log4net.Appender.RollingFileAppender"> <appender name="standrobot" type="log4net.Appender.RollingFileAppender">
<file value="logs/standrobot/standrobot.log" /> <file value="logs/standrobot/standrobot.log"/>
<param name="Encoding" value="UTF-8" /> <param name="Encoding" value="UTF-8"/>
<appendToFile value="true" /> <appendToFile value="true"/>
<rollingStyle value="Date" /> <rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd" /> <datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%m%n" /> <conversionPattern value="%m%n"/>
</layout> </layout>
</appender> </appender>
<logger name="RollingLogFileAppender"> <logger name="RollingLogFileAppender">
<level value="ALL" /> <level value="ALL"/>
<appender-ref ref="RollingLogFileAppender" /> <appender-ref ref="RollingLogFileAppender"/>
</logger> </logger>
<logger name="LngResource"> <logger name="LngResource">
<level value="ALL" /> <level value="ALL"/>
<appender-ref ref="LngResource" /> <appender-ref ref="LngResource"/>
</logger> </logger>
<logger name="HCBOARD"> <logger name="HCBOARD">
<level value="ALL" /> <level value="ALL"/>
<appender-ref ref="RollingLogFileAppender" /> <appender-ref ref="RollingLogFileAppender"/>
</logger> </logger>
<logger name="standrobot"> <logger name="standrobot">
<level value="info" /> <level value="info"/>
<appender-ref ref="standrobot" /> <appender-ref ref="standrobot"/>
</logger> </logger>
<!--<root> <!--<root>
<level value="Info" /> <level value="Info" />
...@@ -66,13 +66,13 @@ ...@@ -66,13 +66,13 @@
</root>--> </root>-->
</log4net> </log4net>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup> </startup>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" /> <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0"/>
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>AutoScanAndLabel</RootNamespace> <RootNamespace>AutoScanAndLabel</RootNamespace>
<AssemblyName>AutoScanAndLabel</AssemblyName> <AssemblyName>AutoScanAndLabel</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>false</Deterministic> <Deterministic>false</Deterministic>
......
...@@ -15,6 +15,7 @@ namespace AutoScanAndLabel ...@@ -15,6 +15,7 @@ namespace AutoScanAndLabel
{ {
public LogControl() public LogControl()
{ {
CheckForIllegalCrossThreadCalls = false;
InitializeComponent(); InitializeComponent();
showLogProDelegate = new ShowLogProDelegate(ShowLogPro); showLogProDelegate = new ShowLogProDelegate(ShowLogPro);
LogUtil.ShowLog += LogUtil_ShowLog; LogUtil.ShowLog += LogUtil_ShowLog;
......
...@@ -19,7 +19,7 @@ namespace AutoScanAndLabel.Properties { ...@@ -19,7 +19,7 @@ namespace AutoScanAndLabel.Properties {
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。 // (以 /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.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources { internal class Resources {
......
...@@ -12,7 +12,7 @@ namespace AutoScanAndLabel.Properties { ...@@ -12,7 +12,7 @@ namespace AutoScanAndLabel.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
......
...@@ -98,7 +98,7 @@ namespace AutoScanAndLabel ...@@ -98,7 +98,7 @@ namespace AutoScanAndLabel
this.cb_labelselect.FormattingEnabled = true; this.cb_labelselect.FormattingEnabled = true;
this.cb_labelselect.Location = new System.Drawing.Point(134, 75); this.cb_labelselect.Location = new System.Drawing.Point(134, 75);
this.cb_labelselect.Name = "cb_labelselect"; this.cb_labelselect.Name = "cb_labelselect";
this.cb_labelselect.Size = new System.Drawing.Size(198, 20); this.cb_labelselect.Size = new System.Drawing.Size(198, 23);
this.cb_labelselect.TabIndex = 0; this.cb_labelselect.TabIndex = 0;
this.cb_labelselect.SelectedIndexChanged += new System.EventHandler(this.cb_labelselect_SelectedIndexChanged); this.cb_labelselect.SelectedIndexChanged += new System.EventHandler(this.cb_labelselect_SelectedIndexChanged);
// //
...@@ -107,7 +107,7 @@ namespace AutoScanAndLabel ...@@ -107,7 +107,7 @@ namespace AutoScanAndLabel
this.cb_printerselect.FormattingEnabled = true; this.cb_printerselect.FormattingEnabled = true;
this.cb_printerselect.Location = new System.Drawing.Point(134, 37); this.cb_printerselect.Location = new System.Drawing.Point(134, 37);
this.cb_printerselect.Name = "cb_printerselect"; this.cb_printerselect.Name = "cb_printerselect";
this.cb_printerselect.Size = new System.Drawing.Size(198, 20); this.cb_printerselect.Size = new System.Drawing.Size(198, 23);
this.cb_printerselect.TabIndex = 0; this.cb_printerselect.TabIndex = 0;
this.cb_printerselect.SelectedIndexChanged += new System.EventHandler(this.cb_printerselect_SelectedIndexChanged); this.cb_printerselect.SelectedIndexChanged += new System.EventHandler(this.cb_printerselect_SelectedIndexChanged);
// //
...@@ -116,7 +116,7 @@ namespace AutoScanAndLabel ...@@ -116,7 +116,7 @@ namespace AutoScanAndLabel
this.chbAutoRun.AutoSize = true; this.chbAutoRun.AutoSize = true;
this.chbAutoRun.Location = new System.Drawing.Point(3, 185); this.chbAutoRun.Location = new System.Drawing.Point(3, 185);
this.chbAutoRun.Name = "chbAutoRun"; this.chbAutoRun.Name = "chbAutoRun";
this.chbAutoRun.Size = new System.Drawing.Size(84, 16); this.chbAutoRun.Size = new System.Drawing.Size(104, 19);
this.chbAutoRun.TabIndex = 1; this.chbAutoRun.TabIndex = 1;
this.chbAutoRun.Text = "开机自启动"; this.chbAutoRun.Text = "开机自启动";
this.chbAutoRun.UseVisualStyleBackColor = true; this.chbAutoRun.UseVisualStyleBackColor = true;
...@@ -141,16 +141,17 @@ namespace AutoScanAndLabel ...@@ -141,16 +141,17 @@ namespace AutoScanAndLabel
this.groupBox2.TabIndex = 4; this.groupBox2.TabIndex = 4;
this.groupBox2.TabStop = false; this.groupBox2.TabStop = false;
this.groupBox2.Text = "PN匹配规则"; this.groupBox2.Text = "PN匹配规则";
this.groupBox2.Visible = false;
// //
// listEdit_pn // listEdit_pn
// //
this.listEdit_pn.Dock = System.Windows.Forms.DockStyle.Fill; this.listEdit_pn.Dock = System.Windows.Forms.DockStyle.Fill;
this.listEdit_pn.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.listEdit_pn.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.listEdit_pn.ListFile = "config/pn.list"; this.listEdit_pn.ListFile = "config/pn.list";
this.listEdit_pn.Location = new System.Drawing.Point(3, 17); this.listEdit_pn.Location = new System.Drawing.Point(3, 21);
this.listEdit_pn.Margin = new System.Windows.Forms.Padding(5); this.listEdit_pn.Margin = new System.Windows.Forms.Padding(5);
this.listEdit_pn.Name = "listEdit_pn"; this.listEdit_pn.Name = "listEdit_pn";
this.listEdit_pn.Size = new System.Drawing.Size(354, 158); this.listEdit_pn.Size = new System.Drawing.Size(354, 154);
this.listEdit_pn.TabIndex = 3; this.listEdit_pn.TabIndex = 3;
this.listEdit_pn.DataRefresh += new System.EventHandler(this.listEdit_pn_DataRefresh); this.listEdit_pn.DataRefresh += new System.EventHandler(this.listEdit_pn_DataRefresh);
// //
...@@ -163,16 +164,17 @@ namespace AutoScanAndLabel ...@@ -163,16 +164,17 @@ namespace AutoScanAndLabel
this.groupBox3.TabIndex = 4; this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false; this.groupBox3.TabStop = false;
this.groupBox3.Text = "QTY匹配规则"; this.groupBox3.Text = "QTY匹配规则";
this.groupBox3.Visible = false;
// //
// listEditControl1 // listEditControl1
// //
this.listEditControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.listEditControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listEditControl1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.listEditControl1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.listEditControl1.ListFile = "config/qty.list"; this.listEditControl1.ListFile = "config/qty.list";
this.listEditControl1.Location = new System.Drawing.Point(3, 17); this.listEditControl1.Location = new System.Drawing.Point(3, 21);
this.listEditControl1.Margin = new System.Windows.Forms.Padding(5); this.listEditControl1.Margin = new System.Windows.Forms.Padding(5);
this.listEditControl1.Name = "listEditControl1"; this.listEditControl1.Name = "listEditControl1";
this.listEditControl1.Size = new System.Drawing.Size(354, 208); this.listEditControl1.Size = new System.Drawing.Size(354, 204);
this.listEditControl1.TabIndex = 3; this.listEditControl1.TabIndex = 3;
this.listEditControl1.DataRefresh += new System.EventHandler(this.listEdit_pn_DataRefresh); this.listEditControl1.DataRefresh += new System.EventHandler(this.listEdit_pn_DataRefresh);
// //
...@@ -180,7 +182,7 @@ namespace AutoScanAndLabel ...@@ -180,7 +182,7 @@ namespace AutoScanAndLabel
// //
this.txt_code.Location = new System.Drawing.Point(6, 24); this.txt_code.Location = new System.Drawing.Point(6, 24);
this.txt_code.Name = "txt_code"; this.txt_code.Name = "txt_code";
this.txt_code.Size = new System.Drawing.Size(264, 21); this.txt_code.Size = new System.Drawing.Size(264, 25);
this.txt_code.TabIndex = 5; this.txt_code.TabIndex = 5;
// //
// btn_codetest // btn_codetest
...@@ -211,6 +213,7 @@ namespace AutoScanAndLabel ...@@ -211,6 +213,7 @@ namespace AutoScanAndLabel
this.groupBox4.TabIndex = 8; this.groupBox4.TabIndex = 8;
this.groupBox4.TabStop = false; this.groupBox4.TabStop = false;
this.groupBox4.Text = "条码匹配测试"; this.groupBox4.Text = "条码匹配测试";
this.groupBox4.Visible = false;
// //
// SettingControl // SettingControl
// //
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.Common</RootNamespace> <RootNamespace>OnlineStore.Common</RootNamespace>
<AssemblyName>MyCommon</AssemblyName> <AssemblyName>MyCommon</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
namespace OnlineStore.Common namespace OnlineStore.Common
{ {
public class LineGetPosOp public class LineGetPosOp
{ {
public LineGetPosOp(string cids,string code) public LineGetPosOp(string cids, string code)
{ {
this.cids = cids; this.cids = cids;
this.code = code; this.code = code;
...@@ -72,6 +72,11 @@ namespace OnlineStore.Common ...@@ -72,6 +72,11 @@ namespace OnlineStore.Common
get { return _data; } get { return _data; }
set { _data = value; } set { _data = value; }
} }
public Dictionary<String, Dictionary<String, String>> mimoOpMap = new Dictionary<string, Dictionary<string, string>>();
/// <summary>
/// agv的日志信息
/// </summary>
public List<AgvLogInfo> logList = new List<AgvLogInfo>();
/// <summary> /// <summary>
/// 整体料仓状态 /// 整体料仓状态
/// 1=正常运行中 /// 1=正常运行中
...@@ -89,6 +94,12 @@ namespace OnlineStore.Common ...@@ -89,6 +94,12 @@ namespace OnlineStore.Common
/// 警告:出库盘到达工位但是没有工人操作 /// 警告:出库盘到达工位但是没有工人操作
/// </summary> /// </summary>
public string msg { get; set; } public string msg { get; set; }
// public Dictionary<string, string> msgData { get; set; } = new Dictionary<string, string>() { {"zh","" },{ "en", "" }, { "jp", "" } };
public Dictionary<string, string> msgData { get; set; } = new Dictionary<string, string>();
public string msgParam { get; set; }
public string msgCode { get; set; }
public string msgEn { get; set; }
public string msgJp { get; set; }
/// <summary> /// <summary>
/// 包含的多个 BOX 的状态信息 /// 包含的多个 BOX 的状态信息
/// </summary> /// </summary>
...@@ -98,7 +109,35 @@ namespace OnlineStore.Common ...@@ -98,7 +109,35 @@ namespace OnlineStore.Common
/// </summary> /// </summary>
public List<AlarmInfo> alarmList = new List<AlarmInfo>(); public List<AlarmInfo> alarmList = new List<AlarmInfo>();
} }
/**
* agv日志信息
*/
public class AgvLogInfo
{
/**
* 消息字符串Code
*/
public String msgCode { get; set; }
/**
* 消息内容
*/
public String msg { get; set; }
/**
* 参数
*/
public String[] msgParams { get; set; }
/**
* 出现时间
*/
public long time { get; set; }
public AgvLogInfo(string msg)
{
this.msgCode = msgCode;
this.msg = msg;
this.msgParams = msgParams;
this.time = DateTime.Now.Ticks;
}
}
/// <summary> /// <summary>
/// 单台料仓状态(包含流水线) /// 单台料仓状态(包含流水线)
/// </summary> /// </summary>
...@@ -162,7 +201,7 @@ namespace OnlineStore.Common ...@@ -162,7 +201,7 @@ namespace OnlineStore.Common
/// <summary> /// <summary>
/// 料仓ID,0表示流水线 /// 料仓ID,0表示流水线
/// </summary> /// </summary>
public int boxId { get; set; } public int boxId { get; set; }
/// <summary> /// <summary>
/// 报警类型, /// 报警类型,
/// </summary> /// </summary>
...@@ -181,11 +220,11 @@ namespace OnlineStore.Common ...@@ -181,11 +220,11 @@ namespace OnlineStore.Common
//AlarmType=2 电钢报警 5=上下电钢 //AlarmType=2 电钢报警 5=上下电钢
//AlarmType=3 IO报警,信号超时 io电器定义(电器定义) //AlarmType=3 IO报警,信号超时 io电器定义(电器定义)
/// </summary> /// </summary>
public string alarmDetail { get; set; } public string alarmDetail { get; set; }
/// <summary> /// <summary>
/// 报警消息 /// 报警消息
/// </summary> /// </summary>
public string alarmMsg { get; set; } public string alarmMsg { get; set; }
/// <summary> /// <summary>
/// 0,1=入库,2=出库 /// 0,1=入库,2=出库
/// </summary> /// </summary>
...@@ -250,6 +289,25 @@ namespace OnlineStore.Common ...@@ -250,6 +289,25 @@ namespace OnlineStore.Common
public static string rfidLoc = "rfidLoc"; public static string rfidLoc = "rfidLoc";
public static string barcode = "barcode"; public static string barcode = "barcode";
/// <summary>
/// 贴标机交互按钮,出口 满料串取出
/// </summary>
public static string SendFullShelf = "SendFullShelf";
/// <summary>
/// 贴标机交互按钮,出口 空料串送入
/// </summary>
public static string NeedEmptySHelf = "NeedEmptySHelf";
/// <summary>
/// 贴标机交互按钮,入口 满料串送入
/// </summary>
public static string NeedFullShelf = "NeedFullShelf";
/// <summary>
/// 贴标机交互按钮,入口 空料串取出
/// </summary>
public static string SendEmptyShelf = "SendEmptyShelf";
public static string doit = "doit";
public static string disable = "disable";
public static string enable = "enable";
} }
} }
using System; using Newtonsoft.Json;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
...@@ -75,7 +76,26 @@ namespace OnlineStore.Common ...@@ -75,7 +76,26 @@ namespace OnlineStore.Common
{ {
return Post(url, paramData, Encoding.UTF8, timeOut); return Post(url, paramData, Encoding.UTF8, timeOut);
} }
public static T Post<T>(string url, T operation, int timeout = 5000, bool printlog = false) where T : new()
{
try
{
string json = JsonConvert.SerializeObject(operation);
string result = Post(url, json, timeout);
T op = JsonConvert.DeserializeObject<T>(result);
if (printlog)
{
LogUtil.info("Send [" + json + "] Revice [" + result + "]");
}
return op;
}
catch (Exception ex)
{
LogUtil.error("Post 出错:" + ex);
}
return default;
}
public static string Post(string url, string paramData, Encoding encoding, int timeOut = 10000) public static string Post(string url, string paramData, Encoding encoding, int timeOut = 10000)
{ {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DL.StandardRobot</RootNamespace> <RootNamespace>DL.StandardRobot</RootNamespace>
<AssemblyName>DL.StandardRobot</AssemblyName> <AssemblyName>DL.StandardRobot</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
......
using System; using DeviceLib.WebApi.Schemas;
using DeviceLibrary.AGVService.Schemas;
using DL.StandardRobot;
using OnlineStore;
using OnlineStore.Common;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using DL.StandardRobot;
using static DL.StandardRobot.StandardRobot; using static DL.StandardRobot.StandardRobot;
namespace DeviceLibrary namespace DeviceLibrary
{ {
public class AGVManager public class AGVManager
{ {
#region 斯坦得AGV PLC方式
static StandardRobot robot = new StandardRobot(); static StandardRobot robot = new StandardRobot();
public static void Connect(string ip) public static void Connect(string ip)
{ {
...@@ -32,7 +38,7 @@ namespace DeviceLibrary ...@@ -32,7 +38,7 @@ namespace DeviceLibrary
{ {
robot.MissionSateChanged -= changedEventHandler; robot.MissionSateChanged -= changedEventHandler;
} }
public static int CurMissionId=0; public static int CurMissionId = 0;
public static void AddMission(int id) public static void AddMission(int id)
{ {
CurMissionId = id; CurMissionId = id;
...@@ -42,5 +48,402 @@ namespace DeviceLibrary ...@@ -42,5 +48,402 @@ namespace DeviceLibrary
{ {
return false; return false;
} }
#endregion
static string std_httpserver = ConfigHelper.Config.Get("std_httpserver");
static string api_createTask = "/nepconSmf/createTask";
static List<TaskState> taskStates = new List<TaskState>();
/// <summary>
/// MIMO折叠门是否开启
/// </summary>
public static bool StringDoorIsOpen = false;
/// <summary>
/// 更新AGV任务状态
/// </summary>
/// <param name="task_code"></param>
/// <param name="task_status"></param>
public static void UpdateTaskStatus(string task_code, string task_status)
{
if (Monitor.TryEnter(taskStates, 300))
{
try
{
//var find = taskStates.Find(s => s.task_code.Equals(task_code));
//if (find != null)
//{
// find.task_status = task_status;
//}
//else
//{
// taskStates.Add(new TaskState() { task_code = task_code, task_status = task_status });
//}
if (taskStates.Count > 0)
{
var find = taskStates.Find(s => s.task_code.Equals(task_code));
if (find != null)
{
find.task_status = task_status;
}
else
{
taskStates.Clear();
taskStates.Add(new TaskState() { task_code = task_code, task_status = task_status });
}
}
else
{
taskStates.Add(new TaskState() { task_code = task_code, task_status = task_status });
}
sendAgvLog("AGV任务" + task_code + "状态更新" + task_status);
}
catch (Exception ex)
{
LogUtil.error("UpdateTaskStatus error:" + task_code + "," + task_status, ex);
}
finally
{
Monitor.Exit(taskStates);
}
}
}
/// <summary>
/// 处理AGV请求的操作
/// </summary>
/// <param name="deviceCheckDto"></param>
/// <param name="rtnData"></param>
public static void HandleDeviceOperate(DeviceCheckDto deviceCheckDto, out RtnData rtnData)
{
rtnData = new RtnData();
switch (deviceCheckDto.task_type)
{
case STDTaskType.NS200_LOAD_B1://NS200入料口上料任务
if (DeviceCheckDto.LOAD_REQ.Equals(deviceCheckDto.operate))//上料请求
{
if (!RobotManage.isRunning)
{
rtnData.code = -1;
rtnData.msg = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv");
}
else
{
RobotManage.mainMachine.RightMoveInfo.NewMove(MoveStep.R40_InShelf);//等待agv到位后执行,启动进入
}
}
else if (DeviceCheckDto.LOAD_DONE.Equals(deviceCheckDto.operate))//上料完成
{
if (RobotManage.mainMachine.RightMoveInfo.MoveStep >= MoveStep.R40_InShelf)
{
rtnData.code = -1;
rtnData.msg = "入料口正在进料";
}
}
else
{
rtnData.code = -1;
rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate;
}
break;
case STDTaskType.NS200_UNLOAD_B1://NS200入料口下料任务
if (DeviceCheckDto.UNLOAD_REQ.Equals(deviceCheckDto.operate))//下料请求
{
if (!RobotManage.isRunning)
{
rtnData.code = -1;
rtnData.msg = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv");
}
else
{
RobotManage.mainMachine.RightMoveInfo.NewMove(MoveStep.R30_OutShelf);//等待agv到位后执行,启动料串离开
}
}
else if (DeviceCheckDto.UNLOAD_DONE.Equals(deviceCheckDto.operate))//下料完成
{
if (RobotManage.mainMachine.RightMoveInfo.MoveStep >= MoveStep.R30_OutShelf)
{
rtnData.code = -1;
rtnData.msg = "入料口正在出料";
}
}
else
{
rtnData.code = -1;
rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate;
}
break;
case STDTaskType.NS200_LOAD_B2://NS200出料口上料任务
if (DeviceCheckDto.LOAD_REQ.Equals(deviceCheckDto.operate))//上料请求
{
if (!RobotManage.isRunning)
{
rtnData.code = -1;
rtnData.msg = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv");
}
else
{
RobotManage.mainMachine.LeftMoveInfo.NewMove(MoveStep.L60_InShelf);//等待agv到位后执行,启动进入
}
}
else if (DeviceCheckDto.LOAD_DONE.Equals(deviceCheckDto.operate))//上料完成
{
if (RobotManage.mainMachine.LeftMoveInfo.MoveStep >= MoveStep.L60_InShelf)
{
rtnData.code = -1;
rtnData.msg = "出料口正在入料";
}
}
else
{
rtnData.code = -1;
rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate;
}
break;
case STDTaskType.NS200_UNLOAD_B2://NS200出料口下料任务
if (DeviceCheckDto.UNLOAD_REQ.Equals(deviceCheckDto.operate))//下料请求
{
if (!RobotManage.isRunning)
{
rtnData.code = -1;
rtnData.msg = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv");
}
else
{
RobotManage.mainMachine.LeftMoveInfo.NewMove(MoveStep.L50_OutShelf);//等待agv到位后执行,启动料串离开
}
}
else if (DeviceCheckDto.UNLOAD_DONE.Equals(deviceCheckDto.operate))//下料完成
{
if (RobotManage.mainMachine.LeftMoveInfo.MoveStep >= MoveStep.L50_OutShelf)
{
rtnData.code = -1;
rtnData.msg = "出料口正在出料";
}
}
else
{
rtnData.code = -1;
rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate;
}
break;
case STDTaskType.MIMO_LOAD://MIMO上料任务
if (DeviceCheckDto.LOAD_REQ.Equals(deviceCheckDto.operate))//上料请求
{
if (!StringDoorIsOpen)
{
rtnData.code = -1;
rtnData.msg = "折叠门开门信号未亮,不允许上料";
}
else
{
//链条正转
sendOpMimoCmd(deviceCheckDto.operate, StringLine(true));
}
}
else if (DeviceCheckDto.OPEN_DOOR.Equals(deviceCheckDto.operate))//开门请求
{
if (!StringDoorIsOpen)//开门
{
sendOpMimoCmd(deviceCheckDto.operate, StringDoor(true));
}
}
else if (DeviceCheckDto.CLOSE_DOOR.Equals(deviceCheckDto.operate))//关门请求
{
sendOpMimoCmd(deviceCheckDto.operate, StringDoor(false));
}
else if (DeviceCheckDto.LOAD_DONE.Equals(deviceCheckDto.operate))//上料完成
{
}
else
{
rtnData.code = -1;
rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate;
}
break;
case STDTaskType.MIMO_UNLOAD:////MIMO下料任务
if (DeviceCheckDto.UNLOAD_REQ.Equals(deviceCheckDto.operate))//下料请求
{
if (!StringDoorIsOpen)
{
rtnData.code = -1;
rtnData.msg = "折叠门开门信号未亮,不允许下料";
}
else
{
//链条反转
sendOpMimoCmd(deviceCheckDto.operate, StringBackLine(true));
}
}
else if (DeviceCheckDto.OPEN_DOOR.Equals(deviceCheckDto.operate))//开门请求
{
if (!StringDoorIsOpen)//开门
{
sendOpMimoCmd(deviceCheckDto.operate, StringDoor(true));
}
}
else if (DeviceCheckDto.CLOSE_DOOR.Equals(deviceCheckDto.operate))//关门请求
{
sendOpMimoCmd(deviceCheckDto.operate, StringDoor(false));
}
else if (DeviceCheckDto.UNLOAD_DONE.Equals(deviceCheckDto.operate))//下料完成
{
}
else
{
rtnData.code = -1;
rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate;
}
break;
}
sendAgvLog($"AGV在设备{deviceCheckDto.device_code}的操作{deviceCheckDto.operate}");
}
static Dictionary<string, string> StringDoor(bool open)
{
//Y14,Y15 折叠门 open/close
if (open)
{
return new Dictionary<string, string> { { "openLock", "doit" } };
}
else
{
return new Dictionary<string, string> { { "closeLock", "doit" } };
}
}
static Dictionary<string, string> StringLine(bool run)
{
if (run)
{
return new Dictionary<string, string> { { "Y08", "open" } };
}
else
{
return new Dictionary<string, string> { { "Y08", "close" } };
}
}
static Dictionary<string, string> StringBackLine(bool run)
{
if (run)
{
return new Dictionary<string, string> { { "Y09", "open" } };
}
else
{
return new Dictionary<string, string> { { "Y09", "close" } };
}
}
/// <summary>
/// 处理AGV任务状态更新
/// </summary>
/// <param name="notificationDto"></param>
/// <param name="rtnData"></param>
public static void HandleTaskNotification(NotificationDto notificationDto, out RtnData rtnData)
{
rtnData = new RtnData();
UpdateTaskStatus(notificationDto.task_code, notificationDto.status);
}
static void sendAgvLog(string msg)
{
Task.Factory.StartNew(() =>
{
while (!RobotManage.mainMachine.ServerCM.SendAgvLog(msg))
{
Thread.Sleep(500);
}
});
}
static void sendOpMimoCmd(string opMsg, Dictionary<string, string> op)
{
Task.Factory.StartNew(() =>
{
while (!RobotManage.mainMachine.ServerCM.OpMIMO(opMsg, op))
{
Thread.Sleep(500);
}
});
}
/// <summary>
/// 创建AGV运输任务
/// </summary>
/// <param name="task_type"></param>
/// <returns></returns>
public static bool CreateAGVTask(string task_type)
{
TaskDto taskDto = new TaskDto() { task_type = task_type, task_code = $"{task_type}_{DateTime.Now.ToString("MMddHHmmss")}" };
try
{
string data = JsonHelper.SerializeObject(taskDto);
string result = HttpHelper.Post(std_httpserver + api_createTask, data, 700);
LogUtil.info($"CreateAGVTask :[{data}][{result}]");
sendAgvLog("Create task:" + task_type + ";FMS response:" + result);
if (string.IsNullOrEmpty(result))
{
return false;
}
RtnData rtnData = JsonHelper.DeserializeJsonToObject<RtnData>(result);
if (rtnData != null)
{
if (rtnData.code == 0)
{
UpdateTaskStatus(taskDto.task_code, taskDto.task_type);
return true;
}
}
}
catch (Exception ex)
{
LogUtil.error($"CreateAGVTask Error:{taskDto.task_code}", ex);
}
return false;
}
}
public class TaskDto
{
/// <summary>
/// 任务编码
/// </summary>
public string task_code { get; set; }
/// <summary>
/// 任务类型
/// </summary>
public string task_type { get; set; }
}
/// <summary>
/// 斯坦得AGV可执行的任务类型
/// </summary>
public class STDTaskType
{
/// <summary>
/// NS200 入料口上料任务
/// </summary>
public const string NS200_LOAD_B1 = "NS200_LOAD_B1";
/// <summary>
/// NS200 入料口下料任务
/// </summary>
public const string NS200_UNLOAD_B1 = "NS200_UNLOAD_B1";
/// <summary>
/// NS200 出料口上料任务
/// </summary>
public const string NS200_LOAD_B2 = "NS200_LOAD_B2";
/// <summary>
/// NS200 出料口下料任务
/// </summary>
public const string NS200_UNLOAD_B2 = "NS200_UNLOAD_B2";
/// <summary>
/// MIMO上料任务
/// </summary>
public const string MIMO_LOAD = "MIMO_LOAD";
/// <summary>
/// MIMO下料任务
/// </summary>
public const string MIMO_UNLOAD = "MIMO_UNLOAD";
}
public class TaskState
{
public string task_code { get; set; }
public bool updated { get; set; } = false;
public string task_status { get; set; } = "CREATED";
} }
} }
using DeviceLib.WebApi.Schemas;
using DeviceLibrary;
using DeviceLibrary.AGVService.Schemas;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
namespace DeviceLib.WebApi.Controllers
{
/// <summary>
/// 设备操作
/// </summary>
[RoutePrefix("nepconSmf/deviceOperate")]
public class deviceOperateController : ApiController
{
[HttpPost]
public RtnData agvOp([FromBody] DeviceCheckDto dto)
{
AGVManager.HandleDeviceOperate(dto, out RtnData rtnData);
return rtnData;
}
}
}
using DeviceLib.WebApi.Schemas;
using DeviceLibrary.AGVService.Schemas;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
namespace DeviceLibrary.AGVService.Controllers
{
/// <summary>
/// 任务执行通知
/// </summary>
[RoutePrefix("nepconSmf/notification")]
public class taskNotificationController : ApiController
{
[HttpPost]
public RtnData taskStatus([FromBody] NotificationDto dto)
{
AGVManager.HandleTaskNotification(dto, out RtnData rtnData);
return rtnData;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.SelfHost;
namespace DeviceLib.WebApi
{
public class HttpService : IDisposable
{
public int Port { get; set; }
private readonly HttpSelfHostServer _server;
public HttpService(int port)
{
this.Port = port;
var config = new HttpSelfHostConfiguration($"http://0.0.0.0:{this.Port}");
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute("DefaultApi", "nepconSmf/{controller}");
_server = new HttpSelfHostServer(config);
}
public Task StartHttpServer()
{
return _server.OpenAsync();
}
public Task CloseHttpServer()
{
return _server.CloseAsync();
}
public void Dispose()
{
_server?.Dispose();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLib.WebApi.Schemas
{
public class DeviceCheckDto
{
/// <summary>
/// 设备标识
/// </summary>
public string device_code { get; set; }
/// <summary>
/// 操作
/// </summary>
public string operate { get; set; }
/// <summary>
/// 任务类型
/// </summary>
public string task_type { get; set; }
/// <summary>
/// 上料请求
/// </summary>
public const string LOAD_REQ = "LOAD_REQ";
/// <summary>
/// 上料完成
/// </summary>
public const string LOAD_DONE = "LOAD_DONE";
/// <summary>
/// 下料请求
/// </summary>
public const string UNLOAD_REQ = "UNLOAD_REQ";
/// <summary>
/// 下料完成
/// </summary>
public const string UNLOAD_DONE = "UNLOAD_DONE";
/// <summary>
/// 开门请求
/// </summary>
public const string OPEN_DOOR = "OPEN_DOOR";
/// <summary>
/// 关门请求
/// </summary>
public const string CLOSE_DOOR = "CLOSE_DOOR";
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary.AGVService.Schemas
{
public class NotificationDto
{
/// <summary>
/// 订单执行状态
/// </summary>
public string status { get; set; }
/// <summary>
/// task_code
/// </summary>
public string task_code { get; set; }
/// <summary>
/// 队列中
/// </summary>
public const string QUEUEING = "QUEUEING";
/// <summary>
/// 正在执行
/// </summary>
public const string EXECUTING = "EXECUTING";
/// <summary>
/// 失败
/// </summary>
public const string FAILED = "FAILED";
/// <summary>
/// 已取消
/// </summary>
public const string CANCELLED = "CANCELLED";
/// <summary>
/// 成功
/// </summary>
public const string SUCCESS = "SUCCESS";
/// <summary>
/// 已挂起
/// </summary>
public const string HANG = "HANG";
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary.AGVService.Schemas
{
public class RtnData
{
public int code { get; set; } = 0;
public object data { get; set; }
public string msg { get; set; } = "ok";
}
}
...@@ -68,8 +68,9 @@ namespace DeviceLibrary ...@@ -68,8 +68,9 @@ namespace DeviceLibrary
/// </summary> /// </summary>
public bool isInSuddenDown = false; public bool isInSuddenDown = false;
public ServerCommunication ServerCM;
DeviceLib.WebApi.HttpService agvService = new DeviceLib.WebApi.HttpService(ConfigHelper.Config.Get("AGVService_Port",8088));
public MainMachine(Robot_Config _config) public MainMachine(Robot_Config _config)
{ {
Config = _config; Config = _config;
...@@ -112,6 +113,8 @@ namespace DeviceLibrary ...@@ -112,6 +113,8 @@ namespace DeviceLibrary
InitPrint(); InitPrint();
LedProcessInit(); LedProcessInit();
agvService.StartHttpServer();
ServerCM = new ServerCommunication();
crc.LanguageChangeEvent += Crc_LanguageChangeEvent; crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
} }
......
...@@ -70,6 +70,7 @@ namespace DeviceLibrary ...@@ -70,6 +70,7 @@ namespace DeviceLibrary
if (!IsDebug) if (!IsDebug)
return; return;
} }
mainMachine.ServerCM.StartConnectServer();
var ElectricGripperPort = ConfigHelper.Config.Get("ElectricGripperPort"); var ElectricGripperPort = ConfigHelper.Config.Get("ElectricGripperPort");
electricGripper.OpenPort(ElectricGripperPort); electricGripper.OpenPort(ElectricGripperPort);
mainThread = new Thread(new ThreadStart(mainMachine.Run)); mainThread = new Thread(new ThreadStart(mainMachine.Run));
...@@ -88,8 +89,8 @@ namespace DeviceLibrary ...@@ -88,8 +89,8 @@ namespace DeviceLibrary
public static void Stop() public static void Stop()
{ {
LogUtil.info("开始停止系统."); LogUtil.info("开始停止系统.");
mainMachine.ServerCM.StopConnectServer();
mainMachine.Stop(); mainMachine?.Stop();
mainMachine.UserPause = false; mainMachine.UserPause = false;
//IOManager.CloseAllConnection(); //IOManager.CloseAllConnection();
//electricGripper.ClosePort(); //electricGripper.ClosePort();
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DeviceLibrary</RootNamespace> <RootNamespace>DeviceLibrary</RootNamespace>
<AssemblyName>DeviceLibrary</AssemblyName> <AssemblyName>DeviceLibrary</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
...@@ -50,6 +50,9 @@ ...@@ -50,6 +50,9 @@
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RmaxisV2, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64"> <Reference Include="RmaxisV2, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\AutoScanAndLabel\bin\Debug\RmaxisV2.dll</HintPath> <HintPath>..\AutoScanAndLabel\bin\Debug\RmaxisV2.dll</HintPath>
...@@ -64,7 +67,16 @@ ...@@ -64,7 +67,16 @@
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.9\lib\net45\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Web.Http, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.9\lib\net45\System.Web.Http.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http.SelfHost, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.SelfHost.5.2.9\lib\net45\System.Web.Http.SelfHost.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
...@@ -74,6 +86,12 @@ ...@@ -74,6 +86,12 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AGVService\Controllers\deviceOperateController.cs" />
<Compile Include="AGVService\Controllers\taskNotificationController.cs" />
<Compile Include="AGVService\HttpService.cs" />
<Compile Include="AGVService\Schemas\DeviceCheckDto.cs" />
<Compile Include="AGVService\Schemas\NotificationDto.cs" />
<Compile Include="AGVService\Schemas\RtnData.cs" />
<Compile Include="AutoScanAndLabel\AxisBean.cs" /> <Compile Include="AutoScanAndLabel\AxisBean.cs" />
<Compile Include="AutoScanAndLabel\Common.cs" /> <Compile Include="AutoScanAndLabel\Common.cs" />
<Compile Include="AutoScanAndLabel\LabelParam.cs" /> <Compile Include="AutoScanAndLabel\LabelParam.cs" />
...@@ -101,6 +119,7 @@ ...@@ -101,6 +119,7 @@
<Compile Include="DeviceLibrary\HC\HCIOManager.cs" /> <Compile Include="DeviceLibrary\HC\HCIOManager.cs" />
<Compile Include="DeviceLibrary\I_IOManager.cs" /> <Compile Include="DeviceLibrary\I_IOManager.cs" />
<Compile Include="DeviceLibrary\IOManager.cs" /> <Compile Include="DeviceLibrary\IOManager.cs" />
<Compile Include="DeviceLibrary\ServerCommunication.cs" />
<Compile Include="DeviceLibrary\ZebraPrinter.cs" /> <Compile Include="DeviceLibrary\ZebraPrinter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="userControl\AxisMoveControl.cs"> <Compile Include="userControl\AxisMoveControl.cs">
...@@ -130,7 +149,7 @@ ...@@ -130,7 +149,7 @@
<Name>Common</Name> <Name>Common</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\DL.StandardRobots\DL.StandardRobots.csproj"> <ProjectReference Include="..\DL.StandardRobots\DL.StandardRobots.csproj">
<Project>{f85a7412-b5b3-4291-a448-a10564602e1a}</Project> <Project>{F85A7412-B5B3-4291-A448-A10564602E1A}</Project>
<Name>DL.StandardRobots</Name> <Name>DL.StandardRobots</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\LoadCVSLibrary\LoadCSVLibrary.csproj"> <ProjectReference Include="..\LoadCVSLibrary\LoadCSVLibrary.csproj">
...@@ -150,5 +169,6 @@ ...@@ -150,5 +169,6 @@
</None> </None>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file \ No newline at end of file
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;
using System.Windows.Forms;
namespace DeviceLibrary
{
public class ServerCommunication
{
volatile StoreStatus _storeStatus = StoreStatus.Debugging;
public StoreStatus storeStatus
{
get => _storeStatus;
set
{
if (_storeStatus != value)
LogUtil.info($"set storeStatus to {value}");
_storeStatus = value;
}
}
static string server = ConfigHelper.Config.Get("http_server", "http://192.168.1.123:8800/");
static string CID = ConfigHelper.Config.Get("CID");
int StoreID = 1;
string StoreName = "";
string WarnMsg = "";
private System.Timers.Timer serverConnectTimer = new System.Timers.Timer();
object serverclock = new object();
public ServerCommunication()
{
serverConnectTimer.Interval = 1000;
serverConnectTimer.AutoReset = true;
serverConnectTimer.Enabled = true;
serverConnectTimer.Elapsed += ServerConnectTimer_Elapsed;
GC.KeepAlive(serverConnectTimer);
LogUtil.info($"server:{server},cid:{CID}");
}
private void ServerConnectTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (Monitor.TryEnter(serverConnectTimer))
{
try
{
if (!server.StartsWith("http"))
return;
SendLineStatus();
}
catch (Exception ex)
{
LogUtil.error($"ServerConnectTimer_Elapsed:{ex}");
}
finally
{
Monitor.Exit(serverConnectTimer);
}
}
}
public void StartConnectServer()
{
serverConnectTimer.Enabled = true;
}
public void StopConnectServer()
{
serverConnectTimer.Enabled = false;
}
/// <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 = new Dictionary<string, string>();
lineOperation.data = lineOperation.data.Concat(GetAgvBtnStatus()).ToDictionary(x => x.Key, v => v.Value);
lineOperation.status = (int)storeStatus;
BoxStatus boxStatus = new BoxStatus();
boxStatus.boxId = StoreID;
//状态
boxStatus.status = (int)storeStatus;
string sendmsg = "";
if (commandResultMsg.Count() > 0)
{
if (commandResultMsg.TryDequeue(out string msg))
{
lineOperation.msg = msg;
lineOperation.msg = lineOperation.msg.Trim().Trim(',');
boxStatus.msg = lineOperation.msg;
}
}
else if (!string.IsNullOrEmpty(WarnMsg))
{
sendmsg = string.Join(",", new string[] { WarnMsg });
//lineOperation.msgData["zh"] = lineOperation.msg;
//lineOperation.msgData["en"] = lineOperation.msg;
//lineOperation.msgData["jp"] = lineOperation.msg;
//lineOperation.status = (int)StoreStatus.Warning;
}
else if (!RobotManage.isRunning)
{
sendmsg = crc.GetString("Res0001", "设备未启动");
}
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 = "rest/djk/labeling/communication"; //流水线状态通信接口
public static string GetPostApi()
{
var host = server;
if (!host.StartsWith("http://"))
{
host = "http://" + host;
}
if (!host.EndsWith("/"))
{
host = host + "/";
}
return host + api_communication;
}
public static string GetPostApi(string api)
{
var host = server;
if (!host.StartsWith("http://"))
{
host = "http://" + host;
}
if (!host.EndsWith("/"))
{
host = host + "/";
}
if (api.StartsWith("/"))
api = api.Substring(1);
return host + api;
}
int laststatus = 0;
public void SendLineStatus()
{
if (RobotManage.IsDebug)
return;
lock (serverclock)
{
bool printlog = false;
DateTime time = DateTime.Now;
//构建发送给服务器的对象
Operation lineOperation = getLineBoxStatus();
if (lineOperation.status != laststatus)
{
laststatus = lineOperation.status;
printlog = true;
}
Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation, 700, printlog);
//LogUtil.info(JsonHelper.SerializeObject(resultOperation.data));
ResultProcess(resultOperation);
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 700)
{
LogUtil.info(StoreName + "TimerProcess[" + span.TotalMilliseconds + "]");
}
}
}
public bool SendAgvLog(string msg)
{
lock (serverclock)
{
Operation operation = getLineBoxStatus();
operation.logList = new List<AgvLogInfo>
{
new AgvLogInfo(msg)
};
LogUtil.info(JsonHelper.SerializeObject(operation));
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 5000);
if (resultOperation == null)
{
LogUtil.info($"SendAgvLog error:{msg}");
return false;
}
LogUtil.info($"SendAgvLog success:{msg}");
}
return true;
}
string mimoCid = ConfigHelper.Config.Get("MIMO_CID", "01");
public bool OpMIMO(string msg, Dictionary<string, string> operate)
{
lock (serverclock)
{
Operation operation = getLineBoxStatus();
operation.mimoOpMap = new Dictionary<string, Dictionary<string, string>>();
//Dictionary<string, string> op = new Dictionary<string, string>
//{
// { "Y10", "open" }
//};
//operation.mimoOpMap.Add("1", op);
operation.mimoOpMap.Add(mimoCid, operate);
LogUtil.info(JsonHelper.SerializeObject(operation));
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 1000);
if (resultOperation == null)
{
LogUtil.info($"OpMIMO error:{msg}");
return false;
}
LogUtil.info($"OpMIMO success:{msg}");
}
return true;
}
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)
{
Dictionary<string, string> dataMap = resultOperation.data;
//折叠门开启状态
if (dataMap.ContainsKey("X16") && dataMap["X16"].Equals("1"))
{
AGVManager.StringDoorIsOpen = true;
}
else
{
AGVManager.StringDoorIsOpen = false;
}
if (dataMap.ContainsKey(ParamDefine.SendEmptyShelf) && dataMap[ParamDefine.SendEmptyShelf].Equals(ParamDefine.doit))
{
AGVManager.CreateAGVTask(STDTaskType.NS200_UNLOAD_B1);
LogUtil.info(StoreName + "收到服务器命令:贴标机 SendEmptyShelf=doit");
}
else if (dataMap.ContainsKey(ParamDefine.SendFullShelf) && dataMap[ParamDefine.SendFullShelf].Equals(ParamDefine.doit))
{
AGVManager.CreateAGVTask(STDTaskType.NS200_UNLOAD_B2);
LogUtil.info(StoreName + "收到服务器命令:贴标机 SendFullShelf=doit");
}
else if (dataMap.ContainsKey(ParamDefine.NeedEmptySHelf) && dataMap[ParamDefine.NeedEmptySHelf].Equals(ParamDefine.doit))
{
AGVManager.CreateAGVTask(STDTaskType.NS200_LOAD_B2);
LogUtil.info(StoreName + "收到服务器命令:贴标机 NeedEmptySHelf=doit");
}
else if (dataMap.ContainsKey(ParamDefine.NeedFullShelf) && dataMap[ParamDefine.NeedFullShelf].Equals(ParamDefine.doit))
{
AGVManager.CreateAGVTask(STDTaskType.NS200_LOAD_B1);
LogUtil.info(StoreName + "收到服务器命令:贴标机 NeedFullShelf=doit");
}
}
if (resultOperation.mimoOpMap != null)
{
foreach (var item in resultOperation.mimoOpMap)
{
Dictionary<string, string> dataMap = item.Value;
if (dataMap.ContainsKey(ParamDefine.SendEmptyShelf) && dataMap[ParamDefine.SendEmptyShelf].Equals(ParamDefine.doit))
{
LogUtil.info(StoreName + $"收到服务器命令:MIMO({item.Key}) SendEmptyShelf=doit 不执行");
}
else if (dataMap.ContainsKey(ParamDefine.NeedEmptySHelf) && dataMap[ParamDefine.NeedEmptySHelf].Equals(ParamDefine.doit))
{
LogUtil.info(StoreName + $"收到服务器命令:MIMO({item.Key}) NeedEmptySHelf=doit 不执行");
}
else if (dataMap.ContainsKey(ParamDefine.SendFullShelf) && dataMap[ParamDefine.SendFullShelf].Equals(ParamDefine.doit))
{
AGVManager.CreateAGVTask(STDTaskType.MIMO_UNLOAD);
LogUtil.info(StoreName + $"收到服务器命令:MIMO({item.Key}) SendFullShelf=doit");
}
else if (dataMap.ContainsKey(ParamDefine.NeedFullShelf) && dataMap[ParamDefine.NeedFullShelf].Equals(ParamDefine.doit))
{
AGVManager.CreateAGVTask(STDTaskType.MIMO_LOAD);
LogUtil.info(StoreName + $"收到服务器命令:MIMO({item.Key}) NeedFullShelf=doit");
}
}
}
}
public Dictionary<string, string> GetAgvBtnStatus()
{
//mimo呼叫agv按钮
Dictionary<string, string> map = new Dictionary<string, string>();
map.Add(ParamDefine.SendEmptyShelf, ParamDefine.disable);
map.Add(ParamDefine.SendFullShelf, ParamDefine.disable);
map.Add(ParamDefine.NeedEmptySHelf, ParamDefine.disable);
map.Add(ParamDefine.NeedFullShelf, ParamDefine.disable);
if (!RobotManage.isRunning)
{
return map;
}
if (RobotManage.mainMachine.IOValue(IO_Type.RightEnd_Check).Equals(IO_VALUE.LOW))
{
map[ParamDefine.NeedFullShelf] = ParamDefine.enable;
}
else
//if (RobotManage.mainMachine.IOValue(IO_Type.RightEnd_Check).Equals(IO_VALUE.HIGH)
// && RobotManage.mainMachine.RightMoveInfo.MoveStep == MoveStep.Wait)
map[ParamDefine.SendEmptyShelf] = ParamDefine.enable;
//if (RobotManage.mainMachine.IOValue(IO_Type.LeftEnd_Check).Equals(IO_VALUE.HIGH)
// && RobotManage.mainMachine.LeftMoveInfo.MoveStep == MoveStep.Wait)
if (RobotManage.mainMachine.IOValue(IO_Type.LeftEnd_Check).Equals(IO_VALUE.HIGH))
map[ParamDefine.SendFullShelf] = ParamDefine.enable;
else
map[ParamDefine.NeedEmptySHelf] = ParamDefine.enable;
return map;
}
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;
}
}
public class ResultData
{
//{"code":0,"msg":"ok","data":"7"}
public int code { get; set; }
public string msg { get; set; }
public Dictionary<string, string> data { get; set; }
}
/// <summary>
///1=设备联机(正常就绪)(入库后,BOX恢复原始状态)(出库后,移载装置恢复原始状态),
///2=急停,3=故障,4=警告,5=调试
/// 6=入库执行中,7=入仓完成,8=入仓失败
/// 9=出库执行,10=出仓完成,11=出库失败
/// </summary>
public enum StoreStatus
{
None = 0,
/// <summary>
/// 1=设备联机(正常就绪)(入库后,BOX恢复原始状态)(出库后,移载装置恢复原始状态),
/// </summary>
StoreOnline = 1,
/// <summary>
///2=急停中
/// </summary>
SuddenStop = 2,
/// <summary>
/// 3=故障中
/// </summary>
InTrouble = 3,
/// <summary>
/// 4=警告
/// </summary>
Warning = 4,
/// <summary>
/// 5=设备调试中
/// </summary>
Debugging = 5,
/// <summary>
/// 6=入库执行中
/// </summary>
InStoreExecute = 6,
/// <summary>
/// 7= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态)
/// </summary>
InStoreEnd = 7,
/// <summary>
/// 8=入库失败
/// </summary>
InStoreFaild = 8,
/// <summary>
/// 9=出库执行中",
/// </summary>
OutStoreExecute = 9,
/// <summary>
///10= 出仓位完成( 料盘已经放到Box门口)
/// </summary>
OutStoreBoxEnd = 10,
/// <summary>
///11=出库完成
/// </summary>
OutStoreEnd = 11,
/// <summary>
/// 12=移栽出库移栽过程中(移栽完成后变成OnLine)
/// </summary>
OutMoveExecute = 12,
/// <summary>
/// 重置中(原点返回和重置都发此状态)
/// </summary>
ResetMove = 13,
/// <summary>
/// 扫码入库失败
/// </summary>
InStoreError = 14,
}
}
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" /> <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
</configuration>
\ No newline at end of file \ No newline at end of file
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.12" targetFramework="net472" /> <package id="log4net" version="2.0.12" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.9" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.9" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.SelfHost" version="5.2.9" targetFramework="net472" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net461" requireReinstallation="true" /> <package id="System.ValueTuple" version="4.5.0" targetFramework="net461" requireReinstallation="true" />
</packages> </packages>
\ No newline at end of file \ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.LoadCSVLibrary</RootNamespace> <RootNamespace>OnlineStore.LoadCSVLibrary</RootNamespace>
<AssemblyName>LoadCSVLibrary</AssemblyName> <AssemblyName>LoadCSVLibrary</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!