Commit 8c2b595c 张东亮

init

0 个父辈
正在显示 163 个修改的文件 包含 15107 行增加0 行删除
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C6D2FC09-46F7-4EC5-A877-15EA06342E4F}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>AGV_UI</RootNamespace>
<AssemblyName>AGV_UI</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Status.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Status.Designer.cs">
<DependentUpon>Status.cs</DependentUpon>
</Compile>
<Compile Include="Manager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Status.resx">
<DependentUpon>Status.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="battery\charge.png" />
<None Include="state\Unknown.png" />
<None Include="state\ready.png" />
<None Include="state\pause.png" />
<None Include="state\manual.png" />
<None Include="state\Executing.png" />
<None Include="state\Error.png" />
<None Include="state\emergency.png" />
<None Include="state\Aborted.png" />
<None Include="task.png" />
<None Include="online.png" />
<None Include="battery\full.png" />
<None Include="battery\common.png" />
<None Include="battery\low.png" />
<None Include="offline.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AGV_UI
{
class Manager
{
static ImageList connImageList;
static ImageList batteryImageList;
static ImageList stateImageList;
static string OnLine = "OnLine";
static string OffLine = "OffLine";
static string LowBattery = "LowBattery";
static string CommonBattery = "CommonBattery";
static string FullBattery = "FullBattery";
static string ChargeBattery = "ChargeBattery";
static string Ready = "Ready";
static string Done = "Done";
static string Pause = "Pause";
static string Executing = "Executing";
static string Aborted = "Aborted";
static string Invalid = "Invalid";
static string EmergencyStop = "EmergencyStop";
static string ManualControl = "ManualControl";
static string Error = "Error";
static string UNKNOWN = "UNKNOWN";
static void InitconnImageList()
{
connImageList = new ImageList();
connImageList.ImageSize = new System.Drawing.Size(32, 32);
connImageList.Images.Add(OnLine, Properties.Resources.online);
connImageList.Images.Add(OffLine, Properties.Resources.offline);
}
static void InitbatteryImageList()
{
batteryImageList = new ImageList();
batteryImageList.ImageSize = new System.Drawing.Size(48, 48);
batteryImageList.Images.Add(LowBattery, Properties.Resources.low);
batteryImageList.Images.Add(CommonBattery, Properties.Resources.common);
batteryImageList.Images.Add(FullBattery, Properties.Resources.full);
batteryImageList.Images.Add(ChargeBattery, Properties.Resources.charge);
}
static void InitStateImageList()
{
stateImageList = new ImageList();
stateImageList.ImageSize = new System.Drawing.Size(48, 48);
stateImageList.Images.Add(UNKNOWN, Properties.Resources.Unknown);
stateImageList.Images.Add(Ready, Properties.Resources.ready);
stateImageList.Images.Add(Done, Properties.Resources.ready);
stateImageList.Images.Add(Pause, Properties.Resources.pause);
stateImageList.Images.Add(ManualControl, Properties.Resources.manual);
stateImageList.Images.Add(Executing, Properties.Resources.Executing);
stateImageList.Images.Add(Error, Properties.Resources.Error);
stateImageList.Images.Add(EmergencyStop, Properties.Resources.emergency);
stateImageList.Images.Add(Aborted, Properties.Resources.Aborted);
stateImageList.Images.Add(Invalid, Properties.Resources.Aborted);
}
/// <summary>
/// 设置连接状态
/// </summary>
/// <param name="state"></param>
/// <returns></returns>
public static Image SetConnState(bool state = false)
{
string tmp = state ? OnLine : OffLine;
if (connImageList == null)
InitconnImageList();
return connImageList.Images[tmp];
}
/// <summary>
/// 设置电量
/// </summary>
/// <param name="min"></param>
/// <param name="max"></param>
public static object[] SetBattery(int curBattery, bool isCharge = false, int min = 20, int max = 90)
{
if (curBattery < 0) curBattery = 0;
Image image;
if (batteryImageList == null)
InitbatteryImageList();
if (isCharge)
{
image = batteryImageList.Images[ChargeBattery];
}
else
{
if (curBattery < min)
image = batteryImageList.Images[LowBattery];
else if (curBattery < max)
image = batteryImageList.Images[CommonBattery];
else
image = batteryImageList.Images[FullBattery];
}
return new object[] { string.Format("{0}%",curBattery), image };
}
/// <summary>
/// 设置小车状态
/// </summary>
/// <param name="curState"></param>
public static object[] SetAGVState(string curState)
{
Image image;
if (stateImageList == null)
InitStateImageList();
if(stateImageList.Images.ContainsKey(curState))
image = stateImageList.Images[curState];
else
image = stateImageList.Images[UNKNOWN];
return new object[] { curState, image };
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("AGVStatus")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AGVStatus")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("c6d2fc09-46f7-4ec5-a877-15ea06342e4f")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace AGV_UI.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AGV_UI.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap Aborted {
get {
object obj = ResourceManager.GetObject("Aborted", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap charge {
get {
object obj = ResourceManager.GetObject("charge", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap common {
get {
object obj = ResourceManager.GetObject("common", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap emergency {
get {
object obj = ResourceManager.GetObject("emergency", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap Error {
get {
object obj = ResourceManager.GetObject("Error", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap Executing {
get {
object obj = ResourceManager.GetObject("Executing", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap full {
get {
object obj = ResourceManager.GetObject("full", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap low {
get {
object obj = ResourceManager.GetObject("low", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap manual {
get {
object obj = ResourceManager.GetObject("manual", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap offline {
get {
object obj = ResourceManager.GetObject("offline", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap online {
get {
object obj = ResourceManager.GetObject("online", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap pause {
get {
object obj = ResourceManager.GetObject("pause", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap ready {
get {
object obj = ResourceManager.GetObject("ready", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap task {
get {
object obj = ResourceManager.GetObject("task", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap Unknown {
get {
object obj = ResourceManager.GetObject("Unknown", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="offline" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\offline.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="task" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\task.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="online" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\online.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Aborted" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\state\Aborted.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="emergency" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\state\emergency.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Error" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\state\Error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Executing" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\state\Executing.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="manual" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\state\manual.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pause" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\state\pause.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ready" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\state\ready.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Unknown" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\state\Unknown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="charge" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\battery\charge.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="common" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\battery\common.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="full" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\battery\full.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="low" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\battery\low.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
\ No newline at end of file \ No newline at end of file
namespace AGV_UI
{
partial class Status
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Status));
this.panelTitle = new System.Windows.Forms.Panel();
this.lblBattery = new System.Windows.Forms.Label();
this.picBxConn = new System.Windows.Forms.PictureBox();
this.lblName = new System.Windows.Forms.Label();
this.panelAGVState = new System.Windows.Forms.Panel();
this.lblAGVState = new System.Windows.Forms.Label();
this.lblTask = new System.Windows.Forms.Label();
this.flowPanelMissionState = new System.Windows.Forms.FlowLayoutPanel();
this.panelTitle.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picBxConn)).BeginInit();
this.panelAGVState.SuspendLayout();
this.SuspendLayout();
//
// panelTitle
//
this.panelTitle.BackColor = System.Drawing.Color.LightBlue;
this.panelTitle.Controls.Add(this.lblBattery);
this.panelTitle.Controls.Add(this.picBxConn);
this.panelTitle.Controls.Add(this.lblName);
this.panelTitle.Dock = System.Windows.Forms.DockStyle.Top;
this.panelTitle.Location = new System.Drawing.Point(0, 0);
this.panelTitle.Name = "panelTitle";
this.panelTitle.Size = new System.Drawing.Size(287, 47);
this.panelTitle.TabIndex = 0;
//
// lblBattery
//
this.lblBattery.Dock = System.Windows.Forms.DockStyle.Right;
this.lblBattery.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblBattery.ForeColor = System.Drawing.Color.Black;
this.lblBattery.Image = ((System.Drawing.Image)(resources.GetObject("lblBattery.Image")));
this.lblBattery.Location = new System.Drawing.Point(249, 0);
this.lblBattery.Name = "lblBattery";
this.lblBattery.Size = new System.Drawing.Size(38, 47);
this.lblBattery.TabIndex = 2;
this.lblBattery.Text = "0%";
this.lblBattery.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// picBxConn
//
this.picBxConn.Dock = System.Windows.Forms.DockStyle.Left;
this.picBxConn.Image = global::AGV_UI.Properties.Resources.offline;
this.picBxConn.Location = new System.Drawing.Point(0, 0);
this.picBxConn.Name = "picBxConn";
this.picBxConn.Size = new System.Drawing.Size(51, 47);
this.picBxConn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.picBxConn.TabIndex = 1;
this.picBxConn.TabStop = false;
//
// lblName
//
this.lblName.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblName.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblName.ForeColor = System.Drawing.Color.Black;
this.lblName.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.lblName.Location = new System.Drawing.Point(0, 0);
this.lblName.Name = "lblName";
this.lblName.Size = new System.Drawing.Size(287, 47);
this.lblName.TabIndex = 0;
this.lblName.Text = "#号车";
this.lblName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// panelAGVState
//
this.panelAGVState.Controls.Add(this.lblAGVState);
this.panelAGVState.Controls.Add(this.lblTask);
this.panelAGVState.Dock = System.Windows.Forms.DockStyle.Top;
this.panelAGVState.Location = new System.Drawing.Point(0, 47);
this.panelAGVState.Name = "panelAGVState";
this.panelAGVState.Size = new System.Drawing.Size(287, 50);
this.panelAGVState.TabIndex = 1;
//
// lblAGVState
//
this.lblAGVState.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblAGVState.Dock = System.Windows.Forms.DockStyle.Left;
this.lblAGVState.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblAGVState.Image = global::AGV_UI.Properties.Resources.Unknown;
this.lblAGVState.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.lblAGVState.Location = new System.Drawing.Point(154, 0);
this.lblAGVState.Name = "lblAGVState";
this.lblAGVState.Size = new System.Drawing.Size(133, 50);
this.lblAGVState.TabIndex = 1;
this.lblAGVState.Text = "None";
this.lblAGVState.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// lblTask
//
this.lblTask.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblTask.Dock = System.Windows.Forms.DockStyle.Left;
this.lblTask.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblTask.Image = global::AGV_UI.Properties.Resources.task;
this.lblTask.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.lblTask.Location = new System.Drawing.Point(0, 0);
this.lblTask.Name = "lblTask";
this.lblTask.Size = new System.Drawing.Size(154, 50);
this.lblTask.TabIndex = 0;
this.lblTask.Text = "无任务";
this.lblTask.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// flowPanelMissionState
//
this.flowPanelMissionState.BackColor = System.Drawing.Color.LightBlue;
this.flowPanelMissionState.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowPanelMissionState.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowPanelMissionState.Location = new System.Drawing.Point(0, 97);
this.flowPanelMissionState.Name = "flowPanelMissionState";
this.flowPanelMissionState.Size = new System.Drawing.Size(287, 230);
this.flowPanelMissionState.TabIndex = 2;
//
// Status
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.flowPanelMissionState);
this.Controls.Add(this.panelAGVState);
this.Controls.Add(this.panelTitle);
this.Name = "Status";
this.Size = new System.Drawing.Size(287, 327);
this.panelTitle.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.picBxConn)).EndInit();
this.panelAGVState.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panelTitle;
private System.Windows.Forms.Label lblName;
private System.Windows.Forms.PictureBox picBxConn;
private System.Windows.Forms.Label lblBattery;
private System.Windows.Forms.Panel panelAGVState;
private System.Windows.Forms.Label lblTask;
private System.Windows.Forms.Label lblAGVState;
private System.Windows.Forms.FlowLayoutPanel flowPanelMissionState;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AGV_UI
{
public partial class Status : UserControl
{
public Status(string name, List<string> infos)
{
InitializeComponent();
AGVName = name;
missionShow = new Dictionary<string, Control>();
if (infos != null && infos.Count > 0)
{
foreach (var item in infos)
{
missionShow.Add(item, new Label() { Name = item,
Font = new Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))),
AutoSize = true,
BorderStyle = BorderStyle.Fixed3D
});
}
flowPanelMissionState.Controls.AddRange(missionShow.Values.ToArray());
}
}
public Status()
{
}
public void Init()
{
foreach (string item in missionShow.Keys)
{
ShowInfo(item, "");
}
SetTitle();
}
public int MaxBattery { get; set; } = 90;
public int MinBattery { get; set; } = 20;
public string AGVName { get; private set; }
#region 私有字段
private Dictionary<string, Control> missionShow;
#endregion
void SetTitle()
{
this.Invoke(new Action(() =>
{
lblName.Text = AGVName;
}
));
}
/// <summary>
/// 设置电量
/// </summary>
/// <param name="curBattery"></param>
/// <param name="isInCharge"></param>
public void SetBattery(int curBattery, bool isInCharge = false)
{
object[] objs = Manager.SetBattery(curBattery, isInCharge, MinBattery, MaxBattery);
try
{
this.Invoke(new Action(() =>
{
if (curBattery < MinBattery)
lblBattery.ForeColor = Color.White;
else
lblBattery.ForeColor = Color.Black;
lblBattery.Text = objs[0] as string;
lblBattery.Image = objs[1] as Image;
}
));
}
catch { }
}
/// <summary>
/// 设置连接状态
/// </summary>
/// <param name="state"></param>
public void SetConnectState(bool state = false)
{
Image image = Manager.SetConnState(state);
this.Invoke(new Action(() =>
{
picBxConn.Image = image;
}
));
}
public void ShowInfo(string key, string info)
{
this.Invoke(new Action(() =>
{
if (missionShow.ContainsKey(key))
missionShow[key].Text = string.Format("{0}:{1}",key, info);
}
));
}
/// <summary>
/// 设置当前任务名称
/// </summary>
/// <param name="taskName"></param>
public void SetCurTask(string taskName)
{
this.Invoke(new Action(() =>
{
lblTask.Text = taskName;
}
));
}
/// <summary>
/// 设置agv当前状态
/// </summary>
/// <param name="curState"></param>
public void SetCurState(string curState)
{
object[] objs = Manager.SetAGVState(curState);
this.Invoke(new Action(() =>
{
lblAGVState.Text = objs[0] as string;
lblAGVState.Image = objs[1] as Image;
}
));
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="lblBattery.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAOZJREFUaEPt
ziEOw1AQxNBcrCT3v1NKDA0CxmrBtzRspbfX6XTadd/382ac/1/2rI3z32QPLQfTZehyMF2GLgfTZehy
MF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfT
ZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2G
LgfTZehyMF2GLgfT9XyupxxMl6HLwXQZuhxMl6HLwXQZuhzM6XR61XV9AQQ5qN/xmUs6AAAAAElFTkSu
QmCC
</value>
</data>
</root>
\ No newline at end of file \ No newline at end of file
using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace AsaPL
{
/// <summary>
/// AGV客户端,对接双层线、生产线
/// </summary>
public class AgvClient
{
private bool _loop;
private Socket _client; //客户端
private List<ClientNode> _node;
private int countRecon; //重连次数
private Thread tSend; //发送线程
private Thread tListen; //监听网络线程
private Thread tRecon; //重连线程
private readonly log4net.ILog LOG;
private readonly string IP; //远程IP地址
private const int PORT = 9501; //端口
private const int SEND_INTERVAL = 2000; //客户端发送所有节点后的间隔
/// <summary>
/// 小车动作事件
/// </summary>
public delegate void ActionEvent(string name);
/// <summary>
/// 小车已准备好,料架准备进入流水线
/// </summary>
public event ActionEvent ReadyEnter;
/// <summary>
/// 小车已准备好,料架准备流出流水线
/// </summary>
public event ActionEvent ReadyLeave;
public event ActionEvent AGVFinishEnter;
public event ActionEvent AGVFinishLeave;
/// <summary>
/// AGV客户端,对接双层线、生产线
/// </summary>
/// <param name="serverIP">服务器IP地址</param>
/// <param name="logName"></param>
public AgvClient(string serverIP, string logName = "AgvClient")
{
IP = serverIP;
_node = new List<ClientNode>();
LOG = log4net.LogManager.GetLogger(logName);
}
/// <summary>
/// 是否连接服务器
/// </summary>
public bool IsConn { private set; get; } = false;
/// <summary>
/// 取消状态,true发送none,false发送实际状态
/// </summary>
public bool CancelState { set; get; } = false;
/// <summary>
/// 连接
/// </summary>
public void Connect()
{
countRecon = 0;
_loop = true;
IsConn = false;
tRecon = new Thread(new ThreadStart(Reconnect));
tListen = new Thread(new ThreadStart(ListenNet));
tSend = new Thread(new ThreadStart(SendStatus));
tRecon.Start();
tListen.Start();
tSend.Start();
LOG.Info("Connect");
}
/// <summary>
/// 关闭
/// </summary>
public void Close()
{
_loop = false;
IsConn = false;
if (_client != null)
{
_client.Close();
_client = null;
}
LOG.Info("Close");
}
/// <summary>
/// 设置状态
/// </summary>
/// <param name="name">节点名称</param>
/// <param name="rfid">RFID</param>
/// <param name="action"></param>
/// <param name="level"></param>
public void SetStatus(string name, string rfid = "", ClientAction action = ClientAction.None, ClientLevel level = ClientLevel.Low)
{
int idx = _node.FindIndex(s => s.Name.Equals(name));
if (idx == -1)
{
ClientNode node = new ClientNode(name, rfid, action, level);
_node.Add(node);
idx = _node.Count - 1;
}
else
{
_node[idx].RFID = rfid;
_node[idx].Action = action;
_node[idx].Level = level;
}
LOG.Info("SetStatus " + _node[idx].ToText());
}
/// <summary>
/// 允许进入
/// </summary>
/// <param name="name"></param>
public void MayEnter(string name)
{
LOG.Info(name + " MayEnter");
ClientNode node = new ClientNode(name, "", ClientAction.MayEnter, ClientLevel.High);
byte[] buff = Encode(node);
bool bln = Send(buff);
}
/// <summary>
/// 允许离开
/// </summary>
/// <param name="name"></param>
public void MayLeave(string name)
{
LOG.Info(name + " MayLeave");
ClientNode node = new ClientNode(name, "", ClientAction.MayLeave, ClientLevel.High);
byte[] buff = Encode(node);
bool bln = Send(buff);
}
/// <summary>
/// 完成进入
/// </summary>
/// <param name="name"></param>
public void FinishEnter(string name)
{
LOG.Info(name + " FinishEnter");
ClientNode node = new ClientNode(name, "", ClientAction.FinishEnter, ClientLevel.High);
byte[] buff = Encode(node);
bool bln = Send(buff);
}
/// <summary>
/// 完成离开
/// </summary>
/// <param name="name"></param>
public void FinishLeave(string name)
{
LOG.Info(name + " FinishLeave");
ClientNode node = new ClientNode(name, "", ClientAction.FinishLeave, ClientLevel.High);
byte[] buff = Encode(node);
bool bln = Send(buff);
}
/// <summary>
/// 重连线程
/// </summary>
private void Reconnect()
{
while (_loop)
{
if (!IsConn)
{
Open();
if (IsConn)
{
countRecon = 0;
LOG.Info("Server connection successful");
}
else
{
LOG.Info("Server connection failed " + ++countRecon + " times");
}
}
Thread.Sleep(1000);
}
}
/// <summary>
/// 打开,连接到服务器
/// </summary>
private void Open()
{
try
{
LOG.Info("Connect " + IP + ":" + PORT);
if (CheckIP(IP))
{
_client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 2000);
_client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 2000);
_client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, 1);
_client.Connect(IPAddress.Parse(IP), PORT);
if (!_loop) return;
IsConn = true;
LOG.Info("Connect OK");
}
}
catch (Exception ex)
{
IsConn = false;
LOG.Error("Open()", ex);
}
}
/// <summary>
/// 监听线程
/// </summary>
private void ListenNet()
{
byte[] temp = new byte[200];
while (_loop)
{
Thread.Sleep(100);
if (!IsConn) continue;
if (_client == null) continue;
try
{
if (_client.Available > 0)
{
int count = _client.Receive(temp);
byte[] _buffer = new byte[count];
Array.Copy(temp, 0, _buffer, 0, count);
ClientNode node = Decode(_buffer);
if (node == null)
{
LOG.Info("Command decoding failed: " + HexBuff(_buffer));
}
else
{
LOG.Info("From server: " + node.ToText());
Resolve(node);
}
}
}
catch (Exception ex)
{
IsConn = false;
LOG.Error("ListenNet()", ex);
}
}
}
/// <summary>
/// 分析数据包
/// </summary>
/// <param name="result"></param>
private void Resolve(ClientNode result)
{
try
{
if (result.Action == ClientAction.ReadyEnter)
{
LOG.Info("Trigger ReadyEnter Event");
ReadyEnter?.Invoke(result.Name);
}
else if (result.Action == ClientAction.ReadyLeave)
{
LOG.Info("Trigger ReadyLeave Event");
ReadyLeave?.Invoke(result.Name);
}
else if(result.Action == ClientAction.FinishEnter)
{
LOG.Info("Trigger FinishEnter Event");
AGVFinishEnter?.Invoke(result.Name);
}
else if(result.Action == ClientAction.FinishLeave)
{
LOG.Info("Trigger FinishLeave Event");
AGVFinishLeave.Invoke(result.Name);
}
}
catch (Exception ex)
{
LOG.Error("Resolve()", ex);
}
}
/// <summary>
/// 连续发送状态线程
/// </summary>
private void SendStatus()
{
while (_loop)
{
if (!IsConn) continue;
Thread.Sleep(SEND_INTERVAL);
if (!IsConn) continue;
for (int i = 0; i < _node.Count; i++)
{
if (!_loop) break;
Thread.Sleep(100);
byte[] buff = Encode(_node[i]);
bool bln = Send(buff);
if (!bln)
{
IsConn = false;
break;
}
}
}
}
/// <summary>
/// 发送命令
/// </summary>
/// <param name="buff"></param>
/// <returns></returns>
private bool Send(byte[] buff)
{
if (!IsConn)
{
LOG.Info("服务器没有连接");
return false;
}
try
{
_client.Send(buff);
LOG.Debug("Send: " + HexBuff(buff));
return true;
}
catch (Exception ex)
{
LOG.Error("Send()", ex);
IsConn = false;
return false;
}
}
/// <summary>
/// 编码
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
private byte[] Encode(ClientNode node)
{
int idx = 0;
byte[] buff = new byte[12];
buff[idx++] = 0xAD;
buff[idx++] = (byte)node.Name[0];
buff[idx++] = Convert.ToByte(node.Name.Substring(1));
buff[idx++] = (byte)node.RFID[0];
buff[idx++] = Convert.ToByte(node.RFID.Substring(1));
if (CancelState)
buff[idx++] = (byte)ClientAction.None;
else
buff[idx++] = (byte)node.Action;
buff[idx++] = (byte)node.Level;
idx += 4; //预留
buff[idx] = 0xDA;
return buff;
}
/// <summary>
/// 解码
/// </summary>
/// <param name="buff"></param>
/// <returns></returns>
private ClientNode Decode(byte[] buff)
{
int idx = 0;
if (buff[idx++] != 0xAD) return null;
string name = (char)buff[idx] + buff[idx + 1].ToString();
idx += 2;
string rfid = (char)buff[idx] + buff[idx + 1].ToString();
idx += 2;
ClientAction action = (ClientAction)buff[idx++];
ClientLevel level = (ClientLevel)buff[idx++];
idx += 4; //预留
if (buff[idx] != 0xDA) return null;
ClientNode node = new ClientNode(name, rfid, action, level);
return node;
}
/// <summary>
/// 16进制
/// </summary>
/// <param name="buff"></param>
/// <returns></returns>
private string HexBuff(byte[] buff)
{
string s = "";
if (buff == null) return s;
for (int i = 0; i < buff.Length; i++)
s += buff[i].ToString("X2") + " ";
return s;
}
/// <summary>
/// 检查IP地址
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
private bool CheckIP(string ip)
{
//IP合法
string pattern = @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$";
bool rtn = System.Text.RegularExpressions.Regex.IsMatch(ip, pattern);
if (!rtn)
{
LOG.Info("Illegal IP address " + ip);
return false;
}
//Ping服务端
try
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingReply result = ping.Send(ip, 2000);
ping.Dispose();
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
{
LOG.Info("Ping " + ip + " request timeout");
return false;
}
return true;
}
catch (Exception ex)
{
LOG.Error("CheckIP()", ex);
return false;
}
}
}
/// <summary>
/// 客户端的节点
/// </summary>
public class ClientNode
{
private string rfid = "00";
/// <summary>
/// 节点名称
/// </summary>
public string Name { set; get; }
/// <summary>
/// RFID
/// </summary>
public string RFID
{
set
{
if (value.Length < 2)
rfid = value.PadLeft(2, '0');
else
rfid = value;
}
get
{
return rfid;
}
}
/// <summary>
/// 动作
/// </summary>
public ClientAction Action { set; get; }
/// <summary>
/// 优先级
/// </summary>
public ClientLevel Level { set; get; }
/// <summary>
/// 客户端节点
/// </summary>
/// <param name="name"></param>
/// <param name="rfid"></param>
/// <param name="action"></param>
/// <param name="level"></param>
public ClientNode(string name, string rfid, ClientAction action, ClientLevel level)
{
Name = name;
RFID = rfid;
Action = action;
Level = level;
}
/// <summary>
/// 所有属性的文本形式
/// </summary>
/// <returns></returns>
public string ToText()
{
string s = string.Format("Name={0}, Action={1}, Level={2}", Name, Action, Level);
return s;
}
}
/// <summary>
/// 客户端的动作
/// </summary>
public enum ClientAction : byte
{
/// <summary>
/// 没有动作
/// </summary>
None = 0,
/// <summary>
/// 需要7寸D料架
/// </summary>
NeedD = 1,
/// <summary>
/// 需要大尺寸C料架
/// </summary>
NeedC = 2,
/// <summary>
/// 需要进入料架
/// </summary>
NeedEnter = 3,
/// <summary>
/// 需要出去料架
/// </summary>
NeedLeave = 4,
/// <summary>
/// 需要进入离开料架
/// </summary>
NeedEnterLeave = 5,
/// <summary>
/// 准备进入,服务器发送
/// </summary>
ReadyEnter = 6,
/// <summary>
/// 可以进入料架
/// </summary>
MayEnter = 7,
/// <summary>
/// 完成进入料架
/// </summary>
FinishEnter = 8,
/// <summary>
/// 准备离开,服务器发送
/// </summary>
ReadyLeave = 9,
/// <summary>
/// 可以出去料架
/// </summary>
MayLeave = 10,
/// <summary>
/// 完成出去料架
/// </summary>
FinishLeave = 11,
}
/// <summary>
/// 客户端的优先级
/// </summary>
public enum ClientLevel : byte
{
/// <summary>
/// 低
/// </summary>
Low = 0,
/// <summary>
/// 中等
/// </summary>
Middle = 1,
/// <summary>
/// 高
/// </summary>
High = 2
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D9154766-67B0-4082-AF8B-DCC7C4CFB5A2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AgvClient</RootNamespace>
<AssemblyName>AsaPL.AgvClient</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\..\..\DLL\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AgvClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("AgvClient")]
[assembly: AssemblyDescription("AGV对接双层线生产线客户端")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("挚锦科技")]
[assembly: AssemblyProduct("AgvClient")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("d9154766-67b0-4082-af8b-dcc7c4cfb5a2")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
文件属性发生变化
文件属性发生变化
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E1C0827A-FA12-49A9-AC71-6D3E6518754A}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>AgvClientTest</RootNamespace>
<AssemblyName>AgvClientTest</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="AsaPL.AgvClient, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\AgvClient\bin\Debug\AsaPL.AgvClient.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\..\..\DLL\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<log4net>
<appender name="AgvClient" type="log4net.Appender.RollingFileAppender">
<file value="logs/AgvClient.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>
<root>
<level value="Info"/>
<appender-ref ref="AgvClient"/>
</root>
</log4net>
</configuration>
\ No newline at end of file \ No newline at end of file
namespace AgvClientTest
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.button7 = new System.Windows.Forms.Button();
this.button8 = new System.Windows.Forms.Button();
this.button9 = new System.Windows.Forms.Button();
this.button10 = new System.Windows.Forms.Button();
this.button11 = new System.Windows.Forms.Button();
this.button12 = new System.Windows.Forms.Button();
this.button13 = new System.Windows.Forms.Button();
this.button14 = new System.Windows.Forms.Button();
this.button15 = new System.Windows.Forms.Button();
this.button16 = new System.Windows.Forms.Button();
this.button17 = new System.Windows.Forms.Button();
this.button19 = new System.Windows.Forms.Button();
this.button20 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button18 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.label5 = new System.Windows.Forms.Label();
this.comboBox3 = new System.Windows.Forms.ComboBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button1.Location = new System.Drawing.Point(455, 49);
this.button1.Margin = new System.Windows.Forms.Padding(4);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(115, 37);
this.button1.TabIndex = 0;
this.button1.Text = "设置";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(285, 54);
this.comboBox1.Margin = new System.Windows.Forms.Padding(4);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(153, 32);
this.comboBox1.TabIndex = 2;
//
// comboBox2
//
this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Items.AddRange(new object[] {
"A5",
"A6",
"E1",
"E2",
"E3",
"E4",
"E5",
"E6",
"E8",
"E9",
"E10",
"E11",
"E12",
"E14",
"E15",
"E16",
"E21",
"E22",
"G1",
"G2",
"G3",
"G4",
"G5",
"G6",
"G7",
"G8",
"G9",
"G10",
"G11",
"G12",
"G13",
"G14",
"G15",
"G16"});
this.comboBox2.Location = new System.Drawing.Point(81, 54);
this.comboBox2.Margin = new System.Windows.Forms.Padding(4);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(153, 32);
this.comboBox2.TabIndex = 3;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(105, 22);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 25);
this.textBox1.TabIndex = 4;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(17, 25);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(71, 15);
this.label1.TabIndex = 5;
this.label1.Text = "A6_RFID:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(8, 65);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(37, 15);
this.label2.TabIndex = 6;
this.label2.Text = "节点";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(241, 71);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(37, 15);
this.label3.TabIndex = 7;
this.label3.Text = "状态";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(239, 22);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(55, 15);
this.label4.TabIndex = 8;
this.label4.Text = "label4";
//
// button3
//
this.button3.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button3.Location = new System.Drawing.Point(372, 108);
this.button3.Margin = new System.Windows.Forms.Padding(4);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(63, 47);
this.button3.TabIndex = 10;
this.button3.Text = "E6";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.SetLineState);
//
// button4
//
this.button4.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button4.Location = new System.Drawing.Point(84, 108);
this.button4.Margin = new System.Windows.Forms.Padding(4);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(63, 47);
this.button4.TabIndex = 11;
this.button4.Text = "E2";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.SetLineState);
//
// button6
//
this.button6.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button6.Location = new System.Drawing.Point(443, 47);
this.button6.Margin = new System.Windows.Forms.Padding(4);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(63, 47);
this.button6.TabIndex = 13;
this.button6.Text = "G10";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.SetLineState);
//
// button7
//
this.button7.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button7.Location = new System.Drawing.Point(585, 108);
this.button7.Margin = new System.Windows.Forms.Padding(4);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(63, 47);
this.button7.TabIndex = 14;
this.button7.Text = "E9";
this.button7.UseVisualStyleBackColor = true;
this.button7.Click += new System.EventHandler(this.SetLineState);
//
// button8
//
this.button8.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button8.Location = new System.Drawing.Point(301, 108);
this.button8.Margin = new System.Windows.Forms.Padding(4);
this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(63, 47);
this.button8.TabIndex = 15;
this.button8.Text = "E5";
this.button8.UseVisualStyleBackColor = true;
this.button8.Click += new System.EventHandler(this.SetLineState);
//
// button9
//
this.button9.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button9.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button9.Location = new System.Drawing.Point(13, 108);
this.button9.Margin = new System.Windows.Forms.Padding(4);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(63, 47);
this.button9.TabIndex = 16;
this.button9.Text = "E1";
this.button9.UseVisualStyleBackColor = true;
this.button9.Click += new System.EventHandler(this.SetLineState);
//
// button10
//
this.button10.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button10.Location = new System.Drawing.Point(13, 163);
this.button10.Margin = new System.Windows.Forms.Padding(4);
this.button10.Name = "button10";
this.button10.Size = new System.Drawing.Size(63, 47);
this.button10.TabIndex = 17;
this.button10.Text = "E10";
this.button10.UseVisualStyleBackColor = true;
this.button10.Click += new System.EventHandler(this.SetLineState);
//
// button11
//
this.button11.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button11.Location = new System.Drawing.Point(301, 163);
this.button11.Margin = new System.Windows.Forms.Padding(4);
this.button11.Name = "button11";
this.button11.Size = new System.Drawing.Size(63, 47);
this.button11.TabIndex = 18;
this.button11.Text = "E14";
this.button11.UseVisualStyleBackColor = true;
this.button11.Click += new System.EventHandler(this.SetLineState);
//
// button12
//
this.button12.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button12.Location = new System.Drawing.Point(443, 163);
this.button12.Margin = new System.Windows.Forms.Padding(4);
this.button12.Name = "button12";
this.button12.Size = new System.Drawing.Size(63, 47);
this.button12.TabIndex = 28;
this.button12.Text = "E16";
this.button12.UseVisualStyleBackColor = true;
this.button12.Click += new System.EventHandler(this.SetLineState);
//
// button13
//
this.button13.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button13.Location = new System.Drawing.Point(155, 163);
this.button13.Margin = new System.Windows.Forms.Padding(4);
this.button13.Name = "button13";
this.button13.Size = new System.Drawing.Size(63, 47);
this.button13.TabIndex = 27;
this.button13.Text = "E12";
this.button13.UseVisualStyleBackColor = true;
this.button13.Click += new System.EventHandler(this.SetLineState);
//
// button14
//
this.button14.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button14.Location = new System.Drawing.Point(159, 108);
this.button14.Margin = new System.Windows.Forms.Padding(4);
this.button14.Name = "button14";
this.button14.Size = new System.Drawing.Size(63, 47);
this.button14.TabIndex = 26;
this.button14.Text = "E3";
this.button14.UseVisualStyleBackColor = true;
this.button14.Click += new System.EventHandler(this.SetLineState);
//
// button15
//
this.button15.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button15.Location = new System.Drawing.Point(514, 47);
this.button15.Margin = new System.Windows.Forms.Padding(4);
this.button15.Name = "button15";
this.button15.Size = new System.Drawing.Size(63, 47);
this.button15.TabIndex = 25;
this.button15.Text = "G21";
this.button15.UseVisualStyleBackColor = true;
this.button15.Click += new System.EventHandler(this.SetLineState);
//
// button16
//
this.button16.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button16.Location = new System.Drawing.Point(84, 163);
this.button16.Margin = new System.Windows.Forms.Padding(4);
this.button16.Name = "button16";
this.button16.Size = new System.Drawing.Size(63, 47);
this.button16.TabIndex = 24;
this.button16.Text = "E11";
this.button16.UseVisualStyleBackColor = true;
this.button16.Click += new System.EventHandler(this.SetLineState);
//
// button17
//
this.button17.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button17.Location = new System.Drawing.Point(372, 163);
this.button17.Margin = new System.Windows.Forms.Padding(4);
this.button17.Name = "button17";
this.button17.Size = new System.Drawing.Size(63, 47);
this.button17.TabIndex = 23;
this.button17.Text = "E15";
this.button17.UseVisualStyleBackColor = true;
this.button17.Click += new System.EventHandler(this.SetLineState);
//
// button19
//
this.button19.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button19.Location = new System.Drawing.Point(230, 108);
this.button19.Margin = new System.Windows.Forms.Padding(4);
this.button19.Name = "button19";
this.button19.Size = new System.Drawing.Size(63, 47);
this.button19.TabIndex = 21;
this.button19.Text = "E4";
this.button19.UseVisualStyleBackColor = true;
this.button19.Click += new System.EventHandler(this.SetLineState);
//
// button20
//
this.button20.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button20.Location = new System.Drawing.Point(514, 108);
this.button20.Margin = new System.Windows.Forms.Padding(4);
this.button20.Name = "button20";
this.button20.Size = new System.Drawing.Size(63, 47);
this.button20.TabIndex = 20;
this.button20.Text = "E8";
this.button20.UseVisualStyleBackColor = true;
this.button20.Click += new System.EventHandler(this.SetLineState);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.button18);
this.groupBox1.Controls.Add(this.button5);
this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.checkBox1);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.comboBox3);
this.groupBox1.Controls.Add(this.button8);
this.groupBox1.Controls.Add(this.button12);
this.groupBox1.Controls.Add(this.button3);
this.groupBox1.Controls.Add(this.button13);
this.groupBox1.Controls.Add(this.button4);
this.groupBox1.Controls.Add(this.button14);
this.groupBox1.Controls.Add(this.button6);
this.groupBox1.Controls.Add(this.button15);
this.groupBox1.Controls.Add(this.button7);
this.groupBox1.Controls.Add(this.button16);
this.groupBox1.Controls.Add(this.button9);
this.groupBox1.Controls.Add(this.button17);
this.groupBox1.Controls.Add(this.button10);
this.groupBox1.Controls.Add(this.button19);
this.groupBox1.Controls.Add(this.button11);
this.groupBox1.Controls.Add(this.button20);
this.groupBox1.Location = new System.Drawing.Point(11, 109);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(692, 260);
this.groupBox1.TabIndex = 29;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "产线";
//
// button18
//
this.button18.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button18.Location = new System.Drawing.Point(585, 47);
this.button18.Margin = new System.Windows.Forms.Padding(4);
this.button18.Name = "button18";
this.button18.Size = new System.Drawing.Size(63, 47);
this.button18.TabIndex = 34;
this.button18.Text = "G22";
this.button18.UseVisualStyleBackColor = true;
this.button18.Click += new System.EventHandler(this.SetLineState);
//
// button5
//
this.button5.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button5.Location = new System.Drawing.Point(585, 163);
this.button5.Margin = new System.Windows.Forms.Padding(4);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(63, 47);
this.button5.TabIndex = 33;
this.button5.Text = "E22";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.SetLineState);
//
// button2
//
this.button2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button2.Location = new System.Drawing.Point(514, 163);
this.button2.Margin = new System.Windows.Forms.Padding(4);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(63, 47);
this.button2.TabIndex = 32;
this.button2.Text = "E21";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.SetLineState);
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Checked = true;
this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox1.Location = new System.Drawing.Point(13, 24);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(89, 19);
this.checkBox1.TabIndex = 31;
this.checkBox1.Text = "自动回复";
this.checkBox1.UseVisualStyleBackColor = true;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(206, 24);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(55, 15);
this.label5.TabIndex = 30;
this.label5.Text = "label5";
//
// comboBox3
//
this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox3.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.comboBox3.FormattingEnabled = true;
this.comboBox3.Location = new System.Drawing.Point(8, 62);
this.comboBox3.Margin = new System.Windows.Forms.Padding(4);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(166, 32);
this.comboBox3.TabIndex = 29;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(723, 388);
this.ControlBox = false;
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.button1);
this.Margin = new System.Windows.Forms.Padding(4);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.ShowIcon = false;
this.Text = "agv对接模拟客户端";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.ComboBox comboBox2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button button8;
private System.Windows.Forms.Button button9;
private System.Windows.Forms.Button button10;
private System.Windows.Forms.Button button11;
private System.Windows.Forms.Button button12;
private System.Windows.Forms.Button button13;
private System.Windows.Forms.Button button14;
private System.Windows.Forms.Button button15;
private System.Windows.Forms.Button button16;
private System.Windows.Forms.Button button17;
private System.Windows.Forms.Button button19;
private System.Windows.Forms.Button button20;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.ComboBox comboBox3;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button18;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AgvClientTest
{
public partial class Form1 : Form
{
private AsaPL.AgvClient client;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 12; i++)
comboBox1.Items.Add((AsaPL.ClientAction)i);
comboBox1.SelectedIndex = 0;
comboBox2.SelectedIndex = 0;
comboBox3.Items.Add(AsaPL.ClientAction.MayEnter);
comboBox3.Items.Add(AsaPL.ClientAction.MayLeave);
comboBox3.SelectedIndex = 0;
client = new AsaPL.AgvClient("10.85.199.1");
client.ReadyEnter += AGV_ReadyEnter;
client.ReadyLeave += AGV_ReadyLeave;
//client.SetStatus("E1", "", AsaPL.ClientAction.None);
//client.SetStatus("E2", "", AsaPL.ClientAction.None);
//client.SetStatus("E3", "", AsaPL.ClientAction.None);
//client.SetStatus("E4", "", AsaPL.ClientAction.None);
//client.SetStatus("E5", "", AsaPL.ClientAction.None);
//client.SetStatus("E6", "", AsaPL.ClientAction.None);
//client.SetStatus("E8", "", AsaPL.ClientAction.None);
//client.SetStatus("E9", "", AsaPL.ClientAction.None);
//client.SetStatus("E10", "", AsaPL.ClientAction.None);
//client.SetStatus("E11", "", AsaPL.ClientAction.None);
//client.SetStatus("E12", "", AsaPL.ClientAction.None);
//client.SetStatus("E14", "", AsaPL.ClientAction.None);
//client.SetStatus("E15", "", AsaPL.ClientAction.None);
//client.SetStatus("E16", "", AsaPL.ClientAction.None);
//client.SetStatus("D4FeederIn", "", AsaPL.ClientAction.None);
//client.SetStatus("D4FeederOut", "", AsaPL.ClientAction.None);
//client.SetStatus("C4FeederIn", "", AsaPL.ClientAction.None);
//client.SetStatus("C4FeederOut", "", AsaPL.ClientAction.None);
client.Connect();
}
private void AGV_ReadyEnter(string nodeName)
{
if (checkBox1.Checked)
{
if (nodeName.StartsWith("A") || nodeName.EndsWith("A"))//|| nodeName.Equals("G10") || nodeName.Equals("G7")
return;
label4.Text = "收到" + nodeName + "ReadyEnter,节点状态变为MayEnter";
client.SetStatus(nodeName, "", AsaPL.ClientAction.MayEnter);
System.Threading.Thread.Sleep(10000);
client.SetStatus(nodeName, "", AsaPL.ClientAction.None);
label4.Text = "设置" + nodeName + " None";
}
}
private void AGV_ReadyLeave(string nodeName)
{
if (checkBox1.Checked)
{
if (nodeName.StartsWith("A") || nodeName.EndsWith("A"))//|| nodeName.Equals("G10") || nodeName.Equals("G7")
return;
label4.Text = "收到" + nodeName + "ReadyLeave,节点状态变为MayLeave";
client.SetStatus(nodeName, "", AsaPL.ClientAction.MayLeave);
System.Threading.Thread.Sleep(10000);
client.SetStatus(nodeName, "", AsaPL.ClientAction.None);
label4.Text = "设置" + nodeName + " None";
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
client.Close();
}
private void button1_Click(object sender, EventArgs e)
{
Task task = new Task(new Action(() => {
client.SetStatus(comboBox2.SelectedItem.ToString(), textBox1.Text, (AsaPL.ClientAction)comboBox1.SelectedIndex);
System.Threading.Thread.Sleep(10000);
client.SetStatus(comboBox2.SelectedItem.ToString(), "", AsaPL.ClientAction.None);
label4.Text = "设置" + comboBox2.SelectedItem.ToString() + " None";
}));
task.Start();
}
private void SetLineState(object sender, EventArgs e)
{
Task task = new Task(new Action(()=>{
if (comboBox3.SelectedItem == null)
return;
string name = ((Button)sender).Text;
client.SetStatus(name, "", (AsaPL.ClientAction)Enum.Parse(typeof(AsaPL.ClientAction), comboBox3.SelectedItem.ToString()));
label5.Text = name + " " + comboBox3.SelectedItem.ToString();
System.Threading.Thread.Sleep(10000);
client.SetStatus(name, "", AsaPL.ClientAction.None);
label5.Text = "设置" + name + " None";
}));
task.Start();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
using log4net.Config;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AgvClientTest
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
XmlConfigurator.Configure();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("AgvClientTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AgvClientTest")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("e1c0827a-fa12-49a9-ac71-6d3e6518754a")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace AgvClientTest.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AgvClientTest.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 覆盖当前线程的 CurrentUICulture 属性
/// 使用此强类型的资源类的资源查找。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AgvClientTest.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
文件属性发生变化
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BAFEAFE6-04E2-48EE-8845-BFC7EA3E3C21}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Common</RootNamespace>
<AssemblyName>Common</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>.\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath>.\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="util\AppConfigHelper.cs" />
<Compile Include="util\IniFileHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingString.cs" />
<Compile Include="util\HttpHelper.cs" />
<Compile Include="util\JsonHelper.cs" />
<Compile Include="util\LogUtil.cs" />
<Compile Include="util\MyWebClient.cs">
<SubType>Component</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file
此文件类型无法预览
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Common")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Common")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("bafeafe6-04e2-48ee-8845-bfc7ea3e3c21")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
此文件类型无法预览
此文件的差异太大,无法显示。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Common
{
public static class SettingString
{
public const int AGVCNT = 4;
//任务名称
public const string Standby = "Standby";
public const string CheckShelf = "CheckShelf";
public const string AutoCharge = "AutoCharge";
public const string UseFleet = "UseFleet";
public const string Leave = "Leave";
public const string Enter = "Enter";
public const string Init = "Init";
//任务状态
public const string Wait = "Wait";
public const string Done = "Done";
public const string Aborted = "Aborted";
public const string Executing = "Executing";
public const string Invalid = "Invalid";
public const string FileName_AGV = "AgvName.csv";
public const string FileName_AgvMission = "AgvMission.csv";
public const string FileName_AgvProductionLine = "AgvProductionLine.csv";
public const string FileName_tempData = "tempData.ini";
public const string IsUse = "IsUse";
public const string RFID = "RFID";
//云仓出料口
public const string D1 = "D1";
public const string D2 = "D2";
public const string D3 = "D3";
//存放料架口
public const string A1 = "A1";//出口
public const string A2 = "A2";//入口
#region 配置名
public const string Port_AGV_Server = "Port_AGV_Server";
public const string httpServer ="http.server";
public const string FLEET = "FLEET";
public const string ChargeThreshold = "ChargeThreshold";
#endregion
}
}
此文件类型无法预览
using System;
using System.Windows.Forms;
using System.Xml;
namespace Common
{
public class AppConfigHelper
{
public static System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
public static string GetValue(string key)
{
if (config.AppSettings.Settings[key] == null)
{
LogUtil.info("未找到配置:" + key + ",请检查配置是否完整!");
return "";
}
else
{
return config.AppSettings.Settings[key].Value;
}
}
public static decimal GetNumValue(string key)
{
decimal a = 0;
//System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
Decimal.TryParse(config.AppSettings.Settings[key].Value, out a);
}
}
return a;
}
public static int GetIntValue(string key)
{
int a = 0;
//System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
}
return a;
}
public static bool GetBoolValue(string key)
{
bool a = false;
//System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
bool.TryParse(config.AppSettings.Settings[key].Value, out a);
}
}
return a;
}
public static void SaveValue(string key, int value)
{
SaveValue(key, value.ToString());
}
public static void SaveValue(string key, bool value)
{
SaveValue(key, value.ToString());
}
public static void SaveValue(string key, string value)
{
try
{
if (key.Equals("") || value.Equals(""))
{
return;
}
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
//System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
SetValue(key, value);
}
else
{
UpdateConfig(key, value);
}
}
catch (Exception ex)
{
LogUtil.error("SaveValue保存配置出错:AppKey=" + key + ",AppValue=" + value + "," + ex.StackTrace);
}
}
/// <summary>
/// 更新配置文件信息
/// </summary>
/// <param name="name">配置文件字段名称</param>
/// <param name="Xvalue">值</param>
private static void UpdateConfig(string name, string Xvalue)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(Application.ExecutablePath + ".config");
XmlNode node = doc.SelectSingleNode(@"//add[@key='" + name + "']");
XmlElement ele = (XmlElement)node;
ele.SetAttribute("value", Xvalue);
doc.Save(Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
LogUtil.error("UpdateConfig保存配置出错:name=" + name + ",Xvalue=" + Xvalue + "," + ex.StackTrace);
}
}
///<summary>
///向.config文件的appKey结写入信息AppValue 保存设置
///</summary>
///<param name="AppKey">节点名</param>
///<param name="AppValue">值</param>
private static void SetValue(String AppKey, String AppValue)
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
if (xElem1 != null)
xElem1.SetAttribute("value", AppValue);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key", AppKey);
xElem2.SetAttribute("value", AppValue);
xNode.AppendChild(xElem2);
}
xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
LogUtil.error("SetValue保存配置出错:AppKey=" + AppKey + ",AppValue=" + AppValue + "," + ex.StackTrace);
}
}
}
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Collections;
using System.Net;
using System.Net.Security;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Reflection;
using System.Net.NetworkInformation;
namespace Common
{
public class HttpHelper
{
// public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static string Post(string url, string paramData)
{
return Post(url, paramData, Encoding.UTF8);
}
//public static bool PingURLIP(string url, int ms=100)
//{
// string[] urlArray = url.Split('/');
// if (urlArray.Length > 3)
// {
// string ip = urlArray[2];
// Ping pingSender = new Ping();
// PingReply reply = pingSender.Send(ip, ms);//第一个参数为ip地址,第二个参数为ping的时间
// if (reply.Status == IPStatus.Success)
// {
// //通
// return true;
// }
// else
// {
// //不通
// return false;
// }
// }
// return true;
//}
/// <summary>
///
/// </summary>
/// <param name="url"></param>
/// <param name="operation"></param>
/// <param name="simulate">是否模拟服务器返回结果</param>
/// <returns></returns>
//public static Operation Post(string url, Operation operation, bool simulate)
//{
// try
// {
// ////如果Op=0或者Op=5,先拼Ip,不通不发送
// //if (operation.op < 0 || operation.op.Equals(5))
// //{
// // if (PingURLIP(url, 100).Equals(false))
// // {
// // return null;
// // }
// //}
// if (simulate)
// {//模拟服务器返回
// operation.status = 200;
// operation.data.Clear();
// operation.data.Add("posId", "A001");
// string pos = "D100-111#D102-222#D104-333";
// operation.data.Add("pos", pos);
// if (operation.op == 1 || operation.op == 2)
// {//入库或出库
// string json = JsonHelper.SerializeObject(operation);
// LogUtil.error("模拟HTTP服务器返回出库入库信息:" + json);
// return operation;
// }
// }
// else
// {
// string json = "";
// try
// {
// json = JsonHelper.SerializeObject(operation);
// }
// catch (Exception ex)
// {
// LogUtil.error("JsonHelper.SerializeObject(operation) 出错【operation.op=" + operation.op + "】" + ex);
// }
// string result = Post(url, json);
// if (!string.IsNullOrEmpty(result))
// {
// try
// {
// return JsonHelper.DeserializeJsonToObject<Operation>(result);
// }
// catch (Exception ex)
// {
// LogUtil.error("JsonHelper.DeserializeJsonToObject 出错【result=" + result + "】" + ex);
// }
// }
// }
// }
// catch (Exception ex)
// {
// LogUtil.error("Post 出错【operation.op=" + operation.op + "】:" + ex);
// }
// return null;
//}
public static string LastServerMsg = "";
public static string Post(string url, string paramData, Encoding encoding)
{
//if (PingURLIP(url, 100).Equals(false))
//{
// return null;
//}
if (paramData != "null" && paramData != null)
{
// LogUtil.debug(LOGGER, "HTTP POST to " + url + " \n\t >> " + paramData);
}
string result = "";
if (url.ToLower().IndexOf("https", System.StringComparison.Ordinal) > -1)
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback((sender, certificate, chain, errors) => { return true; });
}
try
{
var wc = new MyWebClient(5000);
if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
wc.Encoding = encoding;
result = wc.UploadString(url, "POST", paramData);
//LogUtil.info(result);
}
catch (Exception e)
{
LogUtil.error("POST ERROR:" + e.ToString());
}
if (!result.Contains("null") && result.Length != 0)
{
//LogUtil.debug(LOGGER,"receive << " + result);
}
LastServerMsg = DateTime.Now.ToLongTimeString() + " URL:" + url + "\r\n"
+ "发送:" + paramData + "\r\n"
+ "接收:" + result + "\r\n"
;
return result;
}
public static string Get(string url)
{
return Get(url, Encoding.UTF8);
}
public static string Get(string url, Encoding encoding)
{
try
{
LogUtil.debug("HTTP GET FROM: " + url);
var wc = new WebClient { Encoding = encoding };
var readStream = wc.OpenRead(url);
using (var sr = new StreamReader(readStream, encoding))
{
var result = sr.ReadToEnd();
LogUtil.debug("receive << " + result);
return result;
}
}
catch (Exception e)
{
LogUtil.error("HTTP GET ERROR:" +url+ e.Message);
}
return "";
}
}
}
\ No newline at end of file \ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Common
{
public class IniFileHelper
{
[System.Runtime.InteropServices.DllImport("kernel32")]
//section:要读取的段落名
//key: 要读取的键点击打开链接点击打开链接
//defVal: 读取异常的情况下的缺省值
//retVal: key所对应的值,如果该key不存在则返回空值
//size: 值允许的大小
//filePath: INI文件的完整路径和文件名
private static extern int GetPrivateProfileString(string section, string key, string defVal, StringBuilder retVal, int size, string filePath);
[System.Runtime.InteropServices.DllImport("kernel32")]
//section: 要写入的段落名
//key: 要写入的键,如果该key存在则覆盖写入
//val: key所对应的值
//filePath: INI文件的完整路径和文件名
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
/// <summary>
/// 读取INI文件
/// </summary>
/// <param name="section">项目名称(如 [section] )</param>
/// <param name="skey">键</param>
/// <param name="path">路径</param>
public static string ReadValue(string section, string skey, string path)
{
StringBuilder temp = new StringBuilder(500);
GetPrivateProfileString(section, skey, "", temp, 500, path);
return temp.ToString();
}
/// <summary>
/// 写入ini文件
/// </summary>
/// <param name="section">项目名称</param>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <param name="path">路径</param>
public static void WriteValue(string section, string key, string value, string path)
{
WritePrivateProfileString(section, key, value, path);
}
}
}
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
namespace Common
{
/// <summary>
/// Json帮助类
/// </summary>
public class JsonHelper
{
/// <summary>
/// 将对象序列化为JSON格式
/// </summary>
/// <param name="o">对象</param>
/// <returns>json字符串</returns>
public static string SerializeObject(object o)
{
string json = JsonConvert.SerializeObject(o);
return json;
}
/// <summary>
/// 解析JSON字符串生成对象实体
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json字符串(eg.{"ID":"112","Name":"石子儿"})</param>
/// <returns>对象实体</returns>
public static T DeserializeJsonToObject<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(T));
T t = o as T;
return t;
}
/// <summary>
/// 解析JSON数组生成对象实体集合
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json数组字符串(eg.[{"ID":"112","Name":"石子儿"}])</param>
/// <returns>对象实体集合</returns>
public static List<T> DeserializeJsonToList<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
List<T> list = o as List<T>;
return list;
}
/// <summary>
/// 反序列化JSON到给定的匿名对象.
/// </summary>
/// <typeparam name="T">匿名对象类型</typeparam>
/// <param name="json">json字符串</param>
/// <param name="anonymousTypeObject">匿名对象</param>
/// <returns>匿名对象</returns>
public static T DeserializeAnonymousType<T>(string json, T anonymousTypeObject)
{
T t = JsonConvert.DeserializeAnonymousType(json, anonymousTypeObject);
return t;
}
/// <summary>
///写入JSON文件
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="ts"></param>
/// <param name="fileName"></param>
public static void WriteJson<T>(List<T> ts, string fileName) where T : class
{
try
{
string path = fileName + ".json";
string output = JsonConvert.SerializeObject(ts,Formatting.Indented);
File.WriteAllText(path, output);
}
catch (Exception e)
{
LogUtil.error(e.Message + "/r/n" + e.StackTrace);
}
}
/// <summary>
/// 读取JSON文件
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="ts"></param>
/// <param name="fileName"></param>
public static List<T> ReadJson<T>(string fileName) where T : class
{
try
{
string path =fileName + ".json";
StreamReader streamReader = new StreamReader(path);
string jsonStr = streamReader.ReadToEnd();
List<T> jsonObj = DeserializeJsonToList<T>(jsonStr);
streamReader.Close();
return jsonObj;
}
catch (Exception e)
{
LogUtil.error(e.Message + "/r/n" + e.StackTrace);
return null;
}
}
}
///// <summary>
///// 与服务器通信用对象
///// </summary>
//public class Operation
//{
// private string _cid = "";
// public string cid
// {
// get { return _cid; }
// set { _cid = value; }
// }
// public int seq { get; set; }
// public int op { get; set; }
// public int status { get; set; }
// private string _error = "";
// public string error
// {
// get { return _error; }
// set { _error = value; }
// }
// private Dictionary<string, string> _data = new Dictionary<string,string>();
// public Dictionary<string, string> data {
// get { return _data; }
// set { _data = value; }
// }
//}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using System.Reflection;
using System.Drawing;
namespace Common
{
public class LogUtil
{
public static readonly ILog AIOLog = LogManager.GetLogger("AGV_3D_Line");
private static LogUtil instance = new LogUtil();
public delegate void ShowLog(string msg,Color color);
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static Dictionary<int, DateTime> lastErrorLogTime = new Dictionary<int, DateTime>();
public static System.Windows.Forms.RichTextBox logBox = null;
public static int showCount = 20;
public static bool debug_opened = false;
public static void info(ILog log, string msg)
{
if (log == null)
{
return;
}
log.Info(msg);
AddToBox(msg, Color.Black);
//clear();
}
public static void info(ILog log, string msg, Color color)
{
log.Info(msg);
AddToBox(msg, color);
}
public static void debug(ILog log, string msg, Color color)
{
log.Debug(msg);
if (debug_opened)
{
AddToBox(msg, color);
}
}
public static void debug(ILog log, string msg)
{
log.Debug(msg);
if (debug_opened)
{
AddToBox(msg, Color.Gray);
}
}
public static void error(string errorMsg, int type)
{
if (lastErrorLogTime.ContainsKey(type))
{
TimeSpan span = DateTime.Now - lastErrorLogTime[type];
if (span.TotalSeconds > 10)
{
lastErrorLogTime.Remove(type);
lastErrorLogTime.Add(type, DateTime.Now);
error(LOGGER, errorMsg);
}
}
else
{
lastErrorLogTime.Add(type, DateTime.Now);
error(LOGGER, errorMsg);
}
}
public static void error(ILog log, string errorMsg, Exception ex = null)
{
if (errorMsg.Trim().Equals(""))
{
return;
}
if (ex == null)
{
log.Error(errorMsg);
}
else
{
log.Error(errorMsg, ex);
}
AddToBox(errorMsg, Color.Red);
}
private static void AddToBox(string msg, Color color)
{
try
{
ShowLogPro(msg, color);
}
catch (Exception ex)
{
LOGGER.Error("出错:", ex);
}
}
private static List<string> logList = new List<string>();
public static string LastText = "";
private static void ShowLogPro(string msg, Color color)
{
try
{
if (logList.Count > 0)
{
// logList.RemoveAt(0);
}
if (logList.Count >= showCount)
{
logList.RemoveAt(0);
}
string text = "";
foreach (string str in logList)
{
text += str;
}
System.DateTime now = System.DateTime.Now;
logList.Add(now.ToLongTimeString() + " " + msg + Environment.NewLine);
if (logBox == null)
{
return;
}
LastText = text;
if (logBox.Visible)
{
logBox.Text = text;
// logBox.Focus(); //使文本框获取焦点
logBox.AppendText(now.ToLongTimeString() + " " + msg + Environment.NewLine); //增加文本
TimeSpan span = DateTime.Now - lastTime;
if (span.TotalSeconds > 3000000)
{
lastTime = DateTime.Now;
logBox.Select(logBox.Text.Length, 0); //设置光标的位置到文本尾
logBox.ScrollToCaret(); //滚动到控件光标处
}
}
}
catch (Exception ex)
{
LOGGER.Error("出错:" + ex.ToString());
}
}
private static DateTime lastTime = DateTime.Now;
public static void UpdateLogbox()
{
if (logBox != null && logBox.Visible)
{
logBox.Text = LastText;
TimeSpan span = DateTime.Now - lastTime;
if (span.TotalSeconds > 3000000)
{
lastTime = DateTime.Now;
logBox.Select(logBox.Text.Length, 0); //设置光标的位置到文本尾
logBox.ScrollToCaret(); //滚动到控件光标处
}
}
}
public static void ClearLog()
{
if (logBox != null)
{
LastText = "";
logList.Clear();
logBox.Text = "";
}
}
public static void debug(string msg)
{
debug(LOGGER, msg);
}
public static void error(string errorMsg, Exception ex = null)
{
error(LOGGER, errorMsg, ex);
}
public static void info(string msg)
{
info(LOGGER, msg);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
namespace Common
{
public class MyWebClient:WebClient
{
private int _timeout;
/// <summary>
/// 超时时间(毫秒)
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public MyWebClient()
{
this._timeout = 60000;
}
public MyWebClient(int timeout)
{
this._timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
var result = base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}
}
}
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using Common;
using System.Threading;
namespace DeviceLibrary
{
/// <summary>
/// AGV服务端
/// </summary>
public class AgvServer
{
private static log4net.ILog log = log4net.LogManager.GetLogger("AgvServer");
private bool _loop;
private Socket _server; //服务端
private List<Client> _client; //所有客户端
private Thread tListenClient; //监听客户端连接
public int PORT = AppConfigHelper.GetIntValue(SettingString.Port_AGV_Server); //端口
private Thread tPingClient; //ping
/// <summary>
/// 节点改变事件
/// </summary>
/// <param name="nodeIndex"></param>
public delegate void NodeChangedEvent(int nodeIndex);
/// <summary>
/// 节点改变
/// </summary>
public event NodeChangedEvent NodeChanged;
/// <summary>
/// 节点在线
/// </summary>
public event NodeChangedEvent NodeOnline;
/// <summary>
/// AGV服务端
/// </summary>
public AgvServer()
{
_client = new List<Client>();
}
/// <summary>
/// 开启服务
/// </summary>
public void Start()
{
try
{
IPEndPoint localEP = new IPEndPoint(IPAddress.Any, PORT);
_server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_server.Bind(localEP);
_server.Listen(100);
log.Info("Server Start");
_loop = true;
_client = new List<Client>();
tListenClient = new Thread(new ThreadStart(ListenClient));
tListenClient.Start();
tPingClient = new Thread(new ThreadStart(KeepLiveClient));
tPingClient.Start();
}
catch (Exception ex)
{
log.Error("Start()", ex);
}
}
/// <summary>
/// 停止服务
/// </summary>
public void Stop()
{
_loop = false;
for (int i = 0; i < _client.Count; i++)
{
_client[i].Loop = false;
_client[i].IsConn = false;
_client[i].Socket.Close();
}
_server.Close();
_client = null;
Thread.Sleep(50);
log.Info("Server Stop");
}
public Dictionary<string, DateTime> readyEnterTime = new Dictionary<string, DateTime>();
public Dictionary<string, DateTime> readyLeaveTime = new Dictionary<string, DateTime>();
public bool ReadyEnter(string nodeName, string rfid = "")
{
int nodeIdx = AGVManager.nodeInfo.FindIndex(s => s.Name == nodeName);
string ip = AGVManager.nodeInfo[nodeIdx].IP;
int idx = FindClient(ip);
if (idx == -1)
{
log.Error("ReadyEnter 没有找到" + nodeName + " " + ip);
return false;
}
else
{
try
{
if (!readyEnterTime.ContainsKey(nodeName))
{
readyEnterTime.Add(nodeName, DateTime.Now);
}
else
{
TimeSpan timeSpan = DateTime.Now - readyEnterTime[nodeName];
if (timeSpan.TotalSeconds < 45)
{
log.Debug(nodeName + " " + ip + " ReadyEnter 45秒内不重复发送");
return false;
}
else if (timeSpan.TotalMinutes > 2)
{
readyEnterTime[nodeName] = DateTime.Now;
}
}
}
catch (Exception ex) { log.Debug(ex.Message + ";" + ex.StackTrace); }
ClientNode node = new ClientNode(nodeName, rfid, eNodeStatus.ReadyEnter);
byte[] buff = Encode(node);
return Send(idx, buff);
}
}
public bool ReadyLeave(string nodeName, string rfid = "")
{
int nodeIdx = AGVManager.nodeInfo.FindIndex(s => s.Name == nodeName);
string ip = AGVManager.nodeInfo[nodeIdx].IP;
int idx = FindClient(ip);
if (idx == -1)
{
log.Error("ReadyLeave 没有找到" + nodeName + " " + ip);
return false;
}
else
{
try
{
if (!readyLeaveTime.ContainsKey(nodeName))
{
readyLeaveTime.Add(nodeName, DateTime.Now);
}
else
{
TimeSpan timeSpan = DateTime.Now - readyLeaveTime[nodeName];
if (timeSpan.TotalSeconds < 45)
{
log.Debug(nodeName + " " + ip + " ReadyLeave 45秒内不重复发送");
return false;
}
else if (timeSpan.TotalMinutes > 3)
{
readyLeaveTime[nodeName] = DateTime.Now;
}
}
}
catch (Exception ex) { log.Debug(ex.Message + ";" + ex.StackTrace); }
ClientNode node = new ClientNode(nodeName, rfid, eNodeStatus.ReadyLeave);
byte[] buff = Encode(node);
return Send(idx, buff);
}
}
public bool FinishEnter(string nodeName, string rfid = "")
{
int nodeIdx = AGVManager.nodeInfo.FindIndex(s => s.Name == nodeName);
string ip = AGVManager.nodeInfo[nodeIdx].IP;
int idx = FindClient(ip);
if (idx == -1)
{
log.Error("FinishEnter 没有找到" + nodeName + " " + ip);
return false;
}
else
{
ClientNode node = new ClientNode(nodeName, rfid, eNodeStatus.FinishEnter);
byte[] buff = Encode(node);
return Send(idx, buff);
}
}
public bool FinishLeave(string nodeName, string rfid = "")
{
int nodeIdx = AGVManager.nodeInfo.FindIndex(s => s.Name == nodeName);
string ip = AGVManager.nodeInfo[nodeIdx].IP;
int idx = FindClient(ip);
if (idx == -1)
{
log.Error("FinishLeave 没有找到" + nodeName + " " + ip);
return false;
}
else
{
ClientNode node = new ClientNode(nodeName, rfid, eNodeStatus.FinishLeave);
byte[] buff = Encode(node);
return Send(idx, buff);
}
}
private void KeepLiveClient()
{
int n;
while (_loop)
{
n = 0;
while (n < 5000) //所有产线间隔
{
Thread.Sleep(50);
n += 50;
if (!_loop) return;
}
foreach (ClientNode clientNode in AGVManager.nodeInfo)
{
n = 0;
if (clientNode.IP.Trim().Equals(""))
continue;
while (n < 300) //每条产线间隔
{
Thread.Sleep(50);
n += 50;
if (!_loop) return;
}
int idx = FindClient(clientNode.IP);
if (idx == -1)
{
log.Debug("KeepLive 没有找到" + clientNode.Name);
int index = AGVManager.nodeInfo.IndexOf(clientNode);
AGVManager.nodeInfo[index].Online = false;
continue;
}
else
{
if (clientNode.StateEquals(eNodeStatus.None))
{
byte[] buff = new byte[] { 0X00, 0X00 };
int index = AGVManager.nodeInfo.IndexOf(clientNode);
if (!Send(idx, buff))
{
AGVManager.nodeInfo[index].Online = false;
log.Debug(clientNode.Name + " KeepLive 发送失败");
}
else
{
AGVManager.nodeInfo[index].Online = true;
log.Debug(clientNode.Name + " KeepLive 发送成功");
}
}
}
NodeOnline?.Invoke(AGVManager.nodeInfo.IndexOf(clientNode));
NodeChanged?.Invoke(AGVManager.nodeInfo.IndexOf(clientNode));
}
}
}
public bool CheckIP(string name, string ip)
{
//IP合法
string pattern = @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$";
bool rtn = System.Text.RegularExpressions.Regex.IsMatch(ip, pattern);
if (!rtn)
{
log.Error("非法的IP地址" + ip);
return false;
}
//Ping服务端
try
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingReply result = ping.Send(ip, 2000);
ping.Dispose();
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
{
log.Debug(name + " Ping " + ip + " 请求没有响应");
return false;
}
return true;
}
catch (Exception ex)
{
log.Error("CheckIP", ex);
return false;
}
}
/// <summary>
/// 监听客户端
/// </summary>
private void ListenClient()
{
while (_loop)
{
try
{
Socket socket = _server.Accept(); //这边会暂停,不需要sleep
IPEndPoint ep = (IPEndPoint)socket.RemoteEndPoint;
Thread listen = new Thread(new ParameterizedThreadStart(ListenNet));
//string ip = ep.Address.ToString();
//if (ip == System.Configuration.ConfigurationManager.AppSettings["LocalIP"])
// ip += ":" + ep.Port;
//新的客户端
Client client = new Client
{
IP = ep.Address.ToString() + ":" + ep.Port,
Loop = true,
IsConn = true,
Socket = socket,
ListenNet = listen,
nodeName = new List<string>(),
};
//重连后关闭旧连接
//int idx = _client.FindIndex(s => s.IP.Equals(ip));
//if (idx > -1)
//{
// _client[idx].IsConn = false;
// _client[idx].nodeName.Clear();
// _client[idx].Loop = false;
// _client[idx].Socket.Close();
// _client.RemoveAt(idx);
//}
_client.Add(client);
listen.Start(_client.Count - 1);
log.Debug(string.Format("[{0}] 已连接", client.IP));
}
catch (SocketException)
{
//关闭连接,退出阻塞Accept
log.Debug("服务端关闭连接,退出阻塞Accept");
}
catch (Exception ex)
{
log.Error("ListenClient()", ex);
}
}
}
/// <summary>
/// 客户端数据接收
/// </summary>
/// <param name="obj">索引</param>
private void ListenNet(object obj)
{
int sleep = 50;
Client client = _client[(int)obj];
byte[] temp = new byte[200];
int time = 0;
while (client.Loop)
{
Thread.Sleep(sleep);
try
{
if (!client.Loop) break;
if (client.Socket.Available > 0)
{
time = 0;
int count = client.Socket.Receive(temp);
byte[] buff = new byte[count];
Array.Copy(temp, 0, buff, 0, count);
ClientNode node = Decode(client, buff);
if (node == null)
{
log.Debug(client.IP + " 解码失败:" + HexBuff(buff));
}
else
{
log.Debug(client.IP + " 解码内容:" + HexBuff(buff));
log.Debug("Receive[" + client.IP + "] " + node.StatetText());
int idx = client.nodeName.FindIndex(s => s == node.Name);
if (idx == -1) client.nodeName.Add(node.Name);
UpdateNode(node);
}
}
else
{
time += sleep;
if (time > sleep*1000*60*60*5)
{
Offline(client);
log.Info("[" + client.IP + "] 超过5H没有收到数据,关闭连接");
}
}
}
catch (Exception ex)
{
log.Error("ListenNet()", ex);
}
}
}
/// <summary>
/// 编码
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
private byte[] Encode(ClientNode node)
{
int idx = 0;
byte[] buff = new byte[12];
buff[idx++] = 0xAD;
buff[idx++] = (byte)node.Name[0];
buff[idx++] = Convert.ToByte(node.Name.Substring(1));
buff[idx++] = (byte)node.RFID[0];
//buff[idx++] = 0X00;
//buff[idx++] = 0X00;
//buff[idx++] = 0X00;
buff[idx++] = Convert.ToByte(node.RFID.Substring(1));
buff[idx++] = (byte)node.GetState();
buff[idx++] = 0;
idx += 4; //预留
buff[idx] = 0xDA;
return buff;
}
/// <summary>
/// 解码
/// </summary>
/// <param name="buff"></param>
/// <returns></returns>
private ClientNode Decode(Client client, byte[] buff)
{
int idx = 0;
string name = "";
string rfid = "";
if (buff[idx++] != 0xAD) return null;
if (buff[idx] == 0x00 && buff[idx + 1] == 0x00)//收到产线
{
int k = AGVManager.nodeInfo.FindIndex(s => client.IP.Contains(s.IP) && !s.Name.StartsWith("A"));
if (k > -1)
{
name = AGVManager.nodeInfo[k].Name;
rfid = "";
}
idx += 2;
idx += 2;
}
else
{
name = (char)buff[idx] + buff[idx + 1].ToString();
idx += 2;
rfid = (char)buff[idx] + buff[idx + 1].ToString();
idx += 2;
}
eNodeStatus action = (eNodeStatus)buff[idx++];
ClientLevel level = (ClientLevel)buff[idx++];
idx += 4; //预留
if (buff[idx] != 0xDA) return null;
ClientNode node = new ClientNode(name, rfid, action);
node.ClientLevel = level;
return node;
}
private void UpdateNode(ClientNode node)
{
int idx = AGVManager.nodeInfo.FindIndex(s => s.Name == node.Name);
if (idx == -1)
{
//log.Error("UpdateNode " + node.Name + " 不存在");
return;
}
if (!AGVManager.nodeInfo[idx].Online)
{
AGVManager.nodeInfo[idx].Online = true;
NodeOnline?.Invoke(idx);
}
if (!AGVManager.nodeInfo[idx].StateEquals(node.GetState()) ||
AGVManager.nodeInfo[idx].RFID != node.RFID || AGVManager.nodeInfo[idx].ClientLevel != node.ClientLevel)
{
AGVManager.nodeInfo[idx].UpdateNodeStatus(node.GetState());
AGVManager.nodeInfo[idx].ClientLevel = node.ClientLevel;
AGVManager.nodeInfo[idx].RFID = node.RFID;
log.Info("节点更新 " + node.StatetText());
NodeChanged?.Invoke(idx);
}
}
private void Offline(Client client)
{
client.Loop = false;
client.IsConn = false;
client.Socket.Close();
for (int i = 0; i < client.nodeName.Count; i++)
{
int idx = AGVManager.nodeInfo.FindIndex(s => s.Name == client.nodeName[i]);
if (idx == -1) continue;
AGVManager.nodeInfo[idx].Offline();
NodeChanged(idx);
NodeOnline(idx);
}
client.nodeName.Clear();
//_client.Remove(client);
}
/// <summary>
/// 16进制
/// </summary>
/// <param name="buff"></param>
/// <returns></returns>
private string HexBuff(byte[] buff)
{
string s = "";
if (buff == null) return s;
for (int i = 0; i < buff.Length; i++)
s += buff[i].ToString("X2") + " ";
return s;
}
/// <summary>
/// 查找客户端
/// </summary>
/// <param ip="ip">ip地址</param>
/// <returns></returns>
private int FindClient(string ip)
{
int index = -1;
if (_client == null) return index;
try
{
foreach (Client item in _client)
{
if (item.IsConn)
{
//Common.log.Info("已连接客户端:" + string.Join("#", item.IP));
if (item.IP.Contains(ip))
{
index = _client.IndexOf(item);
break;
}
//int idx = item.nodeName.FindIndex(a => a == name);
//if (idx != -1)
//{
// index = _client.IndexOf(item);
// break;
//}
}
}
}
catch { };
return index;
}
/// <summary>
/// 发送命令
/// </summary>
/// <param name="idx"></param>
/// <param name="buff"></param>
/// <returns></returns>
private bool Send(int idx, byte[] buff)
{
string ip = "[" + _client[idx].IP + "]";
if (!_client[idx].IsConn)
{
log.Error(ip + " 没有连接");
return false;
}
try
{
if (_client[idx].IsConn)
_client[idx].Socket.Send(buff);
log.Debug("SendTo" + ip + ": " + HexBuff(buff));
return true;
}
catch (Exception ex)
{
log.Error("Send Error: " + ip, ex);
return false;
}
}
}
/// <summary>
/// 客户端
/// </summary>
public class Client
{
/// <summary>
/// 循环
/// </summary>
public bool Loop;
/// <summary>
/// IP地址
/// </summary>
public string IP;
/// <summary>
/// 是否连接
/// </summary>
public bool IsConn;
/// <summary>
/// 节点名称集合
/// </summary>
public List<string> nodeName;
/// <summary>
/// 套接字
/// </summary>
public Socket Socket;
/// <summary>
/// 接收数据线程
/// </summary>
public Thread ListenNet;
}
}
\ No newline at end of file \ No newline at end of file
using Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class ChargeManager
{
/// <summary>
/// 充电站
/// </summary>
public Dictionary<string, string> Station;
public const string AutoCharge1 = "AutoCharge1";
public const string AutoCharge2 = "AutoCharge2";
/// <summary>
/// 充电最大电量,小于该值或大于等待指定时间去充电
/// </summary>
public int BatteryMax { get; set; } = 90;
/// <summary>
/// 充电最小电量,小于该值直接去充电
/// </summary>
public int BatteryMin { get; set; } = 20;
public ChargeManager()
{
Station = new Dictionary<string, string>();
Station.Add(AutoCharge1, "");
Station.Add(AutoCharge2, "");
string s = AppConfigHelper.GetValue(SettingString.ChargeThreshold);
string[] arr = s.Split(',');
BatteryMin = Convert.ToInt32(arr[0]);
BatteryMax = Convert.ToInt32(arr[1]);
}
/// <summary>
/// 在空的充电桩添加占用小车
/// </summary>
/// <param name="chargeName">占用充电桩的名称</param>
/// <returns></returns>
public bool AddOccupyInfo(string chargeName,string agvName)
{
if (agvName.Equals(""))
return false;
if (Station.Keys.Contains(chargeName))
{
Station[chargeName] = agvName;
return true;
}
return false;
}
private static object loc = new object();
/// <summary>
/// 清除agv占用信息
/// </summary>
/// <param name="chargeName"></param>
/// <returns></returns>
public void DelOccupyInfo(Agv_Info agv)
{
lock(loc)
{
foreach (string item in Station.Keys)
{
if (Station[item].Equals(agv.Name))
{
Station[item] = "";
agv.IsInCharge = false;
break;
}
}
}
}
public void ClearAllOccupyInfo()
{
lock(loc)
{
if (Station != null && Station.Count > 0)
{
foreach (var item in Station.Keys)
{
Station[item] = "";
}
}
}
}
/// <summary>
/// 检查充电桩是否有小车占用
/// </summary>
/// <param name="agv"></param>
/// <returns></returns>
public bool HasEmptyChargeStation(Agv_Info agv)
{
lock (loc)
{
//if (SettingString.FixedCharge_AGV_IPs.Contains(agv.IP))//固定充电小车
// return true;
//else
//{
// if (Station[AutoCharge2].Equals(""))
// {
// return true;
// }
//}
foreach (string item in Station.Keys)
{
if (Station[item].Equals(""))
{
return true;
}
}
}
return false;
}
/// <summary>
/// 开始充电任务
/// </summary>
/// <param name="agv"></param>
/// <returns>充电任务结果</returns>
public bool StartCharge(Agv_Info agv)
{
bool rtn;
string log;
agv.Place = "";
lock(loc)
{
foreach (string chargeStation in Station.Keys)
{
if (Station[chargeStation].Equals(""))
{
rtn = MissionSys.AssignMission(agv, chargeStation);
if (rtn)
{
Station[chargeStation] = agv.Name;
agv.Place = SettingString.AutoCharge;
log = string.Format("{0} {1}", agv.Name, chargeStation);
LogUtil.info(log);
MiR_API.State_Ready(agv);
agv.IsInCharge = true;
return true;
}
else
{
Station[chargeStation] = "";
log = string.Format("{0} {1}失败", agv.Name, chargeStation);
LogUtil.info(log);
}
return false;
}
}
}
return false;
}
}
}
任务名称,任务别名,任务GUID
Init,初始化,219cd91a-61da-11eb-96a9-0001297a1dca
Standby,待机位,615cef05-61f4-11eb-96a9-0001297a1dca
AutoCharge1,充电桩4,b4a9e87a-7768-11eb-8758-54b2038d1924
AutoCharge2,充电桩5,c4326dfb-7768-11eb-8758-54b2038d1924
CheckShelf,检查负载,cc5f1d78-75a2-11eb-8565-0001297a1dca
Leave,出料,28a2ab7b-75ac-11eb-8565-0001297a1dca
Enter,进料,4bf5d4c5-75a4-11eb-8565-0001297a1dca
D1,云仓出料口1,4c533e85-75c6-11eb-a7fe-0001297a1dca
D2,云仓出料口2,3a0d8f1b-75c8-11eb-a7fe-0001297a1dca
D3,云仓出料口3,d2ee5b8e-75c5-11eb-a7fe-0001297a1dca
S1,SMT1线,968abc82-75c5-11eb-a7fe-0001297a1dca
S2,SMT2线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S3,SMT3线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S4,SMT4线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S5,SMT5线,968abc82-75c5-11eb-a7fe-0001297a1dca
S6,SMT6线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S7,SMT7线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S8,SMT8线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S9,SMT9线,968abc82-75c5-11eb-a7fe-0001297a1dca
S10,SMT10线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S11,SMT11线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S12,SMT12线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S13,SMT13线,968abc82-75c5-11eb-a7fe-0001297a1dca
S14,SMT14线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S15,SMT15线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S16,SMT16线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S17,SMT17线,968abc82-75c5-11eb-a7fe-0001297a1dca
S18,SMT18线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S19,SMT19线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S20,SMT20线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
\ No newline at end of file \ No newline at end of file
Fleet ID,agv名称,IP,授权码,IOID
1,1号车,10.85.199.123,Basic ZGlzdHJpYnV0b3I6NjJmMmYwZjFlZmYxMGQzMTUyYzk1ZjZmMDU5NjU3NmU0ODJiYjhlNDQ4MDY0MzNmNGNmOTI5NzkyODM0YjAxNA==,5d084001-6155-11eb-bee4-0001297a2016
产线名,节点名,IP,产线别名
A2,A2,127.0.0.1,料架存放线入口
A1,A1,127.0.0.1,料架存放线出口
D1,D1,127.0.0.1,云仓出料口1
D2,D2,127.0.0.1,云仓出料口2
D3,D3,127.0.0.1,云仓出料口3
SMT1,S1,,SMT1线
SMT2,S2,,SMT2线
SMT3,S3,,SMT3线
SMT4,S4,,SMT4线
SMT5,S5,,SMT5线
SMT6,S6,,SMT6线
SMT7,S7,,SMT7线
SMT8,S8,,SMT8线
SMT9,S9,,SMT9线
SMT10,S10,,SMT10
SMT11,S11,,SMT11线
SMT12,S12,,SMT12线
SMT13,S13,,SMT13线
SMT14,S14,,SMT14线
SMT15,S15,,SMT15线
SMT16,S16,,SMT16线
SMT17,S17,,SMT17线
SMT18,S18,,SMT18线
SMT19,S19,,SMT19线
SMT20,S20,,SMT20线
[18ų]
RFID=
[19ų]
RFID=
[20ų]
RFID=
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using Common;
using log4net.Util;
using RestSharp;
namespace DeviceLibrary
{
public class Control
{
private static log4net.ILog log = log4net.LogManager.GetLogger("Control");
private System.Timers.Timer AgvCallTimer;
private System.Timers.Timer AgvStateTimer;
private System.Timers.Timer NodeStateTimer;
//public List<string> Marks;
private const int REG_STATUS = 20;
//private List<string> shelfLockedNodeNames;
public delegate void AgvChangedEvent(int agvIndex);
public event AgvChangedEvent AgvChanged;
public event AgvChangedEvent AgvOnline;
public event AgvChangedEvent NodeChangedEvent;
public Control()
{
AgvCallTimer = new System.Timers.Timer
{
Interval = 300,
AutoReset = true,
Enabled = false
};
AgvCallTimer.Elapsed += AgvCallTimer_Elapsed;
AgvStateTimer = new System.Timers.Timer
{
Interval = 3000,
AutoReset = true,
Enabled = false
};
AgvStateTimer.Elapsed += AgvStateTimer_Elapsed;
NodeStateTimer = new System.Timers.Timer
{
Interval = 5000,
AutoReset = true,
Enabled = false
};
// NodeStateTimer.Elapsed += NodeStateTimer_Elapsed;
}
public void Start()
{
AgvCallTimer.Enabled = true;
AgvStateTimer.Enabled = true;
NodeStateTimer.Enabled = true;
AgvCallTimer.Start();
AgvStateTimer.Start();
NodeStateTimer.Start();
}
public void Stop()
{
AgvCallTimer.Enabled = false;
AgvStateTimer.Enabled = false;
NodeStateTimer.Enabled = false;
AgvCallTimer.Stop();
AgvStateTimer.Stop();
NodeStateTimer.Stop();
}
private bool NodeStateInProcess = false;
//private void NodeStateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
//{
// if (NodeStateInProcess) return;
// NodeStateInProcess = true;
// List<AlarmMsg> msglist = new List<AlarmMsg>();
// try
// {
// String tmp = "";
// for (int j = 0; j < AGVManager.nodeInfo.Count; j++)
// {
// bool isAlarm = false;
// if (!AGVManager.UpdateStationState(AGVManager.nodeInfo[j]))
// {
// isAlarm = true;
// msglist.Add(new AlarmMsg(AGVManager.nodeInfo[j].AliceName, "lineAgv." + AGVManager.nodeInfo[j].Name + ".WarnMsg", AGVManager.nodeInfo[j].WarnMsg));
// }
// if (!isAlarm && !AGVManager.nodeInfo[j].Online)
// {
// msglist.Add(new AlarmMsg(AGVManager.nodeInfo[j].AliceName, "lineAgv." + AGVManager.nodeInfo[j].Name + ".OffLine", "离线"));
// }
// if (AGVManager.nodeInfo[j].Name.StartsWith(SettingString.RoomS_Name_Prefix) || AGVManager.nodeInfo[j].Name.StartsWith(SettingString.RoomC_Name_Prefix))
// {
// if (!AGVManager.nodeInfo[j].Name.Equals(SettingString.RoomCFeederIn) && !AGVManager.nodeInfo[j].Name.Equals(SettingString.RoomCFeederOut) &&
// !AGVManager.nodeInfo[j].Name.Equals(SettingString.RoomDFeederIn) && !AGVManager.nodeInfo[j].Name.Equals(SettingString.RoomDFeederOut))
// {
// tmp = HttpManager.GetFirstRFID(AGVManager.nodeInfo[j].LineName);
// if (!tmp.Equals(AGVManager.nodeInfo[j].RFID))
// {
// AGVManager.nodeInfo[j].RFID = tmp;
// NodeChangedEvent?.Invoke(j);
// }
// }
// //if (AGVManager.nodeInfo[j].Name.Equals(SettingString.RoomCFeederOut) || AGVManager.nodeInfo[j].Name.Equals(SettingString.RoomDFeederOut))
// //{
// // if (AGVManager.unlockManager.GetUnlockCnt(AGVManager.nodeInfo[j].Name) > 0)
// // {
// // tmp = AGVManager.unlockManager.GetUnlockRfids(AGVManager.nodeInfo[j].Name)[0];
// // if (!tmp.Equals(AGVManager.nodeInfo[j].RFID))
// // {
// // AGVManager.nodeInfo[j].RFID = tmp;
// // NodeChangedEvent?.Invoke(j);
// // }
// // }
// //}
// }
// }
// HttpManager.updateDeviceAlarmMsg(msglist);
// }
// catch (Exception ex)
// {
// log.Error("NodeStateTimer " + ex.Message + ex.StackTrace);
// }
// NodeStateInProcess = false;
//}
private bool AgvStateInProcess = false;
//private eAGVState preAGVState = eAGVState.None;
private void AgvStateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
bool rtn;
if (AgvStateInProcess) return;
AgvStateInProcess = true;
List<AlarmMsg> msglist = new List<AlarmMsg>();
for (int i = 0; i < AGVManager.agvInfo.Count; i++)
{
//上报异常
bool isAlarm = false;
try
{
if (!CheckOnline(i)) continue;
bool change = false;
MiR_API.Get_Task_State(AGVManager.agvInfo[i], out string taskStateStr);
Thread.Sleep(50);
//获取AGV状态
rtn = MiR_API.Get_State(AGVManager.agvInfo[i], out eAGVState stateID, out string stateText, out int battery, out string mission_text, out Agv_Info.MirPosition position);
Thread.Sleep(50);
if (rtn) change = AGVManager.agvInfo[i].SetState(stateID, taskStateStr, battery, mission_text, position);
// if (change)
{
AgvChanged?.Invoke(i);
}
Thread.Sleep(50);
if (stateText.Equals("Error") || stateText.Equals("EmergencyStop") || stateText.Equals("Pause"))
{
isAlarm = true;
msglist.Add(new AlarmMsg(AGVManager.agvInfo[i].Name, "lineAgv." + AGVManager.agvInfo[i].Name + ".Msg", "状态:" + stateText + ""));
}
if (!isAlarm && AGVManager.agvInfo[i].StandTimeOut)
{
isAlarm = true;
msglist.Add(new AlarmMsg(AGVManager.agvInfo[i].Name, "lineAgv." + AGVManager.agvInfo[i].Name + ".Msg", "在" + AGVManager.agvInfo[i].PlaceAliceName + "停留超时" + (DateTime.Now - AGVManager.agvInfo[i].StandStartTime).TotalMinutes.ToString("f2") + "分钟"));
}
if (!isAlarm)
{
try
{
if (!AGVManager.agvInfo[i].Msg.Equals(""))
msglist.Add(new AlarmMsg(AGVManager.agvInfo[i].Name, "lineAgv." + AGVManager.agvInfo[i].Name + ".Msg", AGVManager.agvInfo[i].Msg, 1));
else
{
if ((AGVManager.agvInfo[i].Place.Contains(SettingString.AutoCharge) || AGVManager.agvInfo[i].Place.Contains(SettingString.Standby)))
{
msglist.Add(new AlarmMsg(AGVManager.agvInfo[i].Name, "lineAgv." + AGVManager.agvInfo[i].Name + ".Place", AGVManager.agvInfo[i].Place, 1));
}
}
}
catch (Exception ex)
{
log.Error(AGVManager.agvInfo[i].Name + "上报小车运行步骤失败" + ex.Message + ex.StackTrace);
}
}
HttpManager.updateDeviceAlarmMsg(msglist);
}
catch (Exception ex)
{
log.Error("AgvStateTimer_" + AGVManager.agvInfo[i].Name + ex.Message + ex.StackTrace);
}
}
AgvStateInProcess = false;
}
/// <summary>
/// 从节点获取任务
/// </summary>
/// <param name="agv_Info"></param>
/// <returns></returns>
public Job GetJob(Agv_Info agv_Info)
{
foreach (JobType jobType in AGVManager.jobTypes)
{
Job job = null;
if (agv_Info.IsUse)
job = jobType.GetNewJob(agv_Info);
else
return null;
if (job != null)
{
log.Debug(agv_Info.Name + " GetJob OK " + job.ToString());
return job;
}
}
return null;
}
private bool AgvCallInProcess = false;
private void AgvCallTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (AgvCallInProcess) return;
AgvCallInProcess = true;
for (int i = 0; i < AGVManager.agvInfo.Count; i++)
{
try
{
Agv_Info agv = AGVManager.agvInfo[i];
if (!agv.IsCon) continue; //AGV网络连接
if (!AGVManager.agvInfo[i].IsUse) continue; //AGV是否可用
//Ready,Pause,Executing,Error
if (!AGVManager.agvInfo[i].StateID.Equals(eAGVState.Ready) && !AGVManager.agvInfo[i].StateID.Equals(eAGVState.Pause)
&& !AGVManager.agvInfo[i].StateID.Equals(eAGVState.Executing) && !AGVManager.agvInfo[i].StateID.Equals(eAGVState.None))
{
log.Warn(string.Format("{0}不能调用 StateID={1}", AGVManager.agvInfo[i].Name, AGVManager.agvInfo[i].StateID.ToString()));
continue;
}
if (agv.CurJob == null)
{
Job job = GetJob(agv);
if (job != null)
{
agv.CurJob = job;
}
//else
//{
// //if (agv.Battery < Common.chargeStatus.chargeMax)
// agv.CurJob = new ChargeJob(agv.Place);
//}
}
if (agv.CurJob != null)
{
agv.CurJob = agv.CurJob.Execute(agv);
}
}
catch (Exception ex)
{
log.Error("AgvCall " + ex.Message + ex.StackTrace);
}
}
AgvCallInProcess = false;
}
private bool CheckOnline(int idx)
{
bool rtn = MiR_API.CheckIP(AGVManager.agvInfo[idx].IP);
if (rtn)
{
if (AGVManager.agvInfo[idx].IsCon)
{
log.Debug(AGVManager.agvInfo[idx].Name + " Online");
}
else
{
AGVManager.agvInfo[idx].IsCon = true;
log.Info(AGVManager.agvInfo[idx].Name + " Online");
AgvOnline?.Invoke(idx);
}
}
else
{
if (AGVManager.agvInfo[idx].IsCon)
{
AGVManager.agvInfo[idx].IsCon = false;
log.Info(AGVManager.agvInfo[idx].Name + " Offline");
AgvOnline?.Invoke(idx);
}
else
{
log.Debug(AGVManager.agvInfo[idx].Name + " Offline");
}
}
return rtn;
}
}
}
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F9619F07-15F1-4E59-A383-3871952BBB79}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DeviceLibrary</RootNamespace>
<AssemblyName>DeviceLibrary</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>.\log4net.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath>.\RestSharp.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.ServiceModel.Activation" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="bean\Agv_Info.cs" />
<Compile Include="bean\job\ChargeJob.cs" />
<Compile Include="bean\job\EmptyShelfBackJob.cs" />
<Compile Include="bean\job\GoEmptyShelfLineJob.cs" />
<Compile Include="bean\job\GoFullShelfStationJob.cs" />
<Compile Include="bean\job\jobType\GetEmptyShelfJobType.cs" />
<Compile Include="bean\job\jobType\SendFullShelfJobType.cs" />
<Compile Include="bean\job\SendFullShelfToLineJob.cs" />
<Compile Include="bean\Mission.cs" />
<Compile Include="bean\node\ClientNode.cs" />
<Compile Include="bean\Node.cs" />
<Compile Include="Control.cs" />
<Compile Include="manager\HttpManager.cs" />
<Compile Include="AgvServer.cs" />
<Compile Include="bean\Job.cs" />
<Compile Include="bean\JobStep.cs" />
<Compile Include="bean\JobType.cs" />
<Compile Include="bean\job\jobType\ChargeJobType.cs" />
<Compile Include="Charge.cs" />
<Compile Include="manager\AGVManager.cs" />
<Compile Include="DisplayBoard.cs" />
<Compile Include="bean\MiR_API.cs" />
<Compile Include="MissionSys.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Shelf.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AGV_UI\AGV_UI.csproj">
<Project>{c6d2fc09-46f7-4ec5-a877-15ea06342e4f}</Project>
<Name>AGV_UI</Name>
</ProjectReference>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{bafeafe6-04e2-48ee-8845-bfc7ea3e3c21}</Project>
<Name>Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="Config\AgvMission.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Config\AgvName.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Config\AgvProductionLine.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class DisplayBoard
{
/// <summary>
/// 异常列表
/// </summary>
public List<AlarmMsg> MsgList { get; private set; }
/// <summary>
/// 看板类
/// </summary>
public DisplayBoard()
{
MsgList = new List<AlarmMsg>();
}
/// <summary>
/// 添加上报信息
/// </summary>
/// <param name="name"></param>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="type">默认类型是异常,1表示正常信息</param>
public void Add(string name, string key, string value, int type = 0)
{
MsgList.Add(new AlarmMsg(name, key, value, type));
}
private void ClearAlram()
{
if (MsgList != null && MsgList.Count > 0)
MsgList.Clear();
}
public void UpdateAlarmMsg()
{
if (MsgList != null && MsgList.Count > 0)
{
HttpManager.updateDeviceAlarmMsg(MsgList);
ClearAlram();
}
}
}
}
using Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
/// <summary>
/// 任务系统
/// </summary>
public class MissionSys
{
/// <summary>
/// 任务列表
/// </summary>
public static List<Mission> Missions;
/// <summary>
/// 加载任务列表
/// </summary>
public static void Init()
{
try
{
Missions = new List<Mission>();
string path = AGVManager.CONFIG_PATH + SettingString.FileName_AgvMission;
string[] line = System.IO.File.ReadAllLines(path, Encoding.UTF8);
string[] temp;
for (int i = 1; i < line.Length; i++)
{
temp = line[i].Split(',');
if (temp.Length != 3) continue;
Missions.Add(new Mission(temp[0], temp[1], temp[2]));
}
LogUtil.info("加载任务成功");
}
catch (Exception ex)
{
LogUtil.error("加载任务失败", ex);
}
}
/// <summary>
/// 根据目的地名获取guid号
/// </summary>
/// <param name="taskName"></param>
/// <returns></returns>
public static string GetMissionGuidByAliceName(string aliceName)
{
Mission mission = Missions.Find(s => s.AliceName.Equals(aliceName));
if (mission != null)
return mission.Guid;
else
LogUtil.error(string.Format("任务[{0}]不存在,请检查!", aliceName));
return "";
}
/// <summary>
/// 根据任务名获取guid号
/// </summary>
/// <param name="taskName"></param>
/// <returns></returns>
public static string GetMissionGuidByTaskName(string taskName)
{
Mission mission = Missions.Find(s => s.Name.Equals(taskName));
if (mission != null)
return mission.Guid;
else
LogUtil.error(string.Format("任务{0}不存在,请检查!", taskName));
return "";
}
public static string GetAliceNameByTaskName(string taskName)
{
Mission mission = Missions.Find(s => s.Name.Equals(taskName));
if (mission != null)
return mission.AliceName;
else
LogUtil.error(string.Format("任务{0}不存在,请检查!", taskName));
return "";
}
public static string GetTaskNameByAliceName(string aliceName)
{
Mission mission = Missions.Find(s => s.AliceName.Equals(aliceName));
if (mission != null)
return mission.Name;
else
LogUtil.error(string.Format("任务[{0}]不存在,请检查!", aliceName));
return "";
}
/// <summary>
/// 向小车发送任务
/// </summary>
/// <returns></returns>
public static bool AssignMission(Agv_Info agv, string taskName)
{
bool rtn = false;
string guid = GetMissionGuidByTaskName(taskName);
if (!guid.Equals(""))
{
if (!taskName.StartsWith(SettingString.AutoCharge))
agv.Place = taskName;
if (agv.UseFleet)
{
agv.CurTarName = taskName;
rtn = MiR_API.Add_Mission_Fleet(agv, guid);
MiR_API.State_Ready(agv);
if (rtn)
{
LogUtil.info(string.Format("{0} Add_Mission_Fleet [{1}] OK", agv.Name, taskName));
}
else
{
LogUtil.info(string.Format("{0} Add_Mission_Fleet [{1}] Fail", agv.Name, taskName));
}
}
else
{
agv.CurTarName = taskName;
rtn = MiR_API.Add_Mission(agv, guid);
MiR_API.State_Ready(agv);
if (rtn)
{
LogUtil.info(string.Format("{0} Add_Mission [{1}] OK", agv.Name, taskName));
}
else
{
LogUtil.info(string.Format("{0} Add_Mission [{1}] Fail", agv.Name, taskName));
}
}
agv.StateKanban.SetCurTask(MissionSys.GetAliceNameByTaskName(taskName));
}
return rtn;
}
/// <summary>
/// 删除任务
/// </summary>
/// <returns></returns>
public static void DelMission(Agv_Info agv)
{
if (agv.UseFleet)
{
MiR_API.Del_Mission_Fleet(agv, agv.CurTaskGUID);
}
else
{
MiR_API.Del_Mission(agv);
}
LogUtil.info(string.Format("{0} DelMission [{1}] OK", agv.Name, agv.CurTarName));
}
/// <summary>
/// 检查当前任务是否结束
/// </summary>
/// <param name="taskName">任务名称</param>
/// <param name="taskGUID">任务GUID</param>
/// <returns></returns>
public static bool CheckTaskFinished(Agv_Info agv, string taskName, string curTaskState)
{
LogUtil.debug(agv.Name + " 检查当前任务是否结束: " + taskName + " " + curTaskState);
return GetMissionGuidByTaskName(taskName).Equals(agv.CurTaskGUID) && curTaskState.Equals(SettingString.Done);
}
/// <summary>
/// 检查当前是否分配成功
/// </summary>
/// <param name="taskName">任务名称</param>
/// <param name="taskGUID">任务GUID</param>
/// <returns></returns>
public static bool CheckTaskIsOK(Agv_Info agv, string taskName, string curTaskState)
{
return GetMissionGuidByTaskName(taskName).Equals(agv.CurTaskGUID) && curTaskState.Equals(SettingString.Executing);
}
/// <summary>
/// 获取Job任务状态
/// </summary>
/// <param name="CurTaskID"></param>
/// <returns></returns>
public static string GetTakJobState(Agv_Info agv)
{
if (!agv.CurTaskID.Equals(-1) && MiR_API.Get_Task_State(agv, out string st))
return st;
return SettingString.Wait;
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("DeviceLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DeviceLibrary")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("f9619f07-15f1-4e59-a383-3871952bbb79")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
此文件类型无法预览
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace DeviceLibrary
{
//public class ScopeLimit
//{
// List<string> agvIPs;
// //不规则图像坐标
// List<Agv_Info.AgvPosition> positions;
// Thread threadPoll;//监控线程
// /// <summary>
// /// 区域是否可用
// /// </summary>
// public bool Available { get; private set; } = true;
// public delegate void ScopeLimitStateChangedEventHandler(string ip, bool state);
// public event ScopeLimitStateChangedEventHandler ScopeLimitStateChangedEvent;
// public ScopeLimit(List<Agv_Info.AgvPosition> positions)
// {
// agvIPs = new List<string>();
// agvIPs.AddRange(new string[]
// {
// "10.85.199.68",
// "10.85.199.69",
// "10.85.199.70",
// "10.85.199.71",
// "10.85.199.72",
// "10.85.199.73",
// "10.85.199.74",
// "10.85.199.80",
// "10.85.199.81",
// "10.85.199.114"
// });
// this.positions = positions;
// threadPoll = new Thread(ScopeDetecting);
// threadPoll.IsBackground = true;
// threadPoll.Start();
// }
// private void ScopeDetecting()
// {
// bool rtn;
// while (true)
// {
// Thread.Sleep(5000);
// List<string> agvs = new List<string>();
// foreach (string ip in agvIPs)
// {
// Thread.Sleep(1000);
// rtn = MiR_API.Get_Position(ip, AGVManager.agvInfo[0].Authorization, out Agv_Info.AgvPosition position);
// if (rtn)
// {
// if (IsInPolygon(position, positions))
// {
// agvs.Add(ip);
// }
// }
// }
// if (agvs.Count > 0)
// {
// Available = false;
// ScopeLimitStateChangedEvent?.Invoke(string.Join(";", agvs), Available);
// }
// else //不在限制区域
// {
// if (!Available)
// {
// Available = true;
// ScopeLimitStateChangedEvent?.Invoke("", Available);
// }
// }
// }
// }
// /// <summary>
// /// 判断点是否在多边形内.
// /// ----------原理----------
// /// 注意到如果从P作水平向左的射线的话,如果P在多边形内部,那么这条射线与多边形的交点必为奇数,
// /// 如果P在多边形外部,则交点个数必为偶数(0也在内)。
// /// </summary>
// /// <param name="checkPoint">要判断的点</param>
// /// <param name="polygonPoints">多边形的顶点</param>
// /// <returns></returns>
// bool IsInPolygon(Agv_Info.AgvPosition checkPoint, List<Agv_Info.AgvPosition> polygonPoints)
// {
// bool inside = false;
// int pointCount = polygonPoints.Count;
// Agv_Info.AgvPosition p1, p2;
// for (int i = 0, j = pointCount - 1; i < pointCount; j = i, i++)//第一个点和最后一个点作为第一条线,之后是第一个点和第二个点作为第二条线,之后是第二个点与第三个点,第三个点与第四个点...
// {
// p1 = polygonPoints[i];
// p2 = polygonPoints[j];
// if (checkPoint.y < p2.y)
// {//p2在射线之上
// if (p1.y <= checkPoint.y)
// {//p1正好在射线中或者射线下方
// if ((checkPoint.y - p1.y) * (p2.x - p1.x) > (checkPoint.x - p1.x) * (p2.y - p1.y))//斜率判断,在P1和P2之间且在P1P2右侧
// {
// //射线与多边形交点为奇数时则在多边形之内,若为偶数个交点时则在多边形之外。
// //由于inside初始值为false,即交点数为零。所以当有第一个交点时,则必为奇数,则在内部,此时为inside=(!inside)
// //所以当有第二个交点时,则必为偶数,则在外部,此时为inside=(!inside)
// inside = (!inside);
// }
// }
// }
// else if (checkPoint.y < p1.y)
// {
// //p2正好在射线中或者在射线下方,p1在射线上
// if ((checkPoint.y - p1.y) * (p2.x - p1.x) < (checkPoint.x - p1.x) * (p2.y - p1.y))//斜率判断,在P1和P2之间且在P1P2右侧
// {
// inside = (!inside);
// }
// }
// }
// return inside;
// }
//}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public enum eShelfType
{
BigShelf,
SmallShelf
}
class Shelf
{
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class StandbyManager
{
/// <summary>
/// 待机位
/// </summary>
public List<string> Station;
private const int Station_CNT = 3;
public StandbyManager()
{
Station = new List<string>();
Station.AddRange(new string[Station_CNT]);
}
/// <summary>
/// 在空的待机位添加占用小车
/// </summary>
/// <param name="standName">占用待机位的名称</param>
/// <returns></returns>
public bool AddOccupyInfo(string standName)
{
if (standName.Equals(""))
return false;
int i = Station.FindIndex(s => (s == null || s.Equals("")));
if (i > -1)
{
Station[i] = standName;
return true;
}
return false;
}
/// <summary>
/// 清除占用信息
/// </summary>
/// <param name="standName"></param>
/// <returns></returns>
public bool DelOccupyInfo(string standName)
{
if (standName.Equals(""))
return false;
int i = Station.FindIndex(s => s != null && s.Equals(standName));
if (i > -1)
{
Station[i] = "";
return true;
}
return false;
}
public void ClearAllInfo()
{
if (Station != null && Station.Count > 0)
{
Station.Clear();
Station = new List<string>();
Station.AddRange(new string[Station_CNT]);
}
}
public string GetInfoByID(int index)
{
if (Station ==null ||index<0 || index >= Station_CNT || Station[index] ==null)
return "";
else
return Station[index];
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Dolen.Communication.TCP
{
public class TCPServer
{
Thread threadWatch = null; // 负责监听客户端连接请求的线程;
Socket socketWatch = null;
int buffLength = 1024;// 定义一个1M的缓存区;
Dictionary<string, Socket> dict = new Dictionary<string, Socket>();
Dictionary<string, Thread> dictThread = new Dictionary<string, Thread>();
log4net.ILog Log;
private bool loop = false;
/// <summary>
/// 消息变化委托
/// </summary>
/// <param name="clientKey">客户端信息</param>
/// <param name="msg">客户端发送的消息</param>
public delegate void MsgEventHandler(string clientKey, string msg);
public delegate void ClientChangedEventHandler(List<string> clientKey);
public delegate void ServerStateChangedEventHandler(bool state);
/// <summary>
/// 消息接收事件 (string clientKey, string msg)
/// </summary>
public event MsgEventHandler RecvMsgEvent;
/// <summary>
/// 客户端变化事件 (List<string> clientKey)
/// </summary>
public event ClientChangedEventHandler ClientChangedEvent;
public event ServerStateChangedEventHandler ServerStateChangedEvent;
/// <summary>
/// 是否打开调试
/// </summary>
public bool IsDebug { get; set; } = false;
/// <summary>
/// 服务端IP
/// </summary>
public string IP { get; private set; }
/// <summary>
/// 服务端信息
/// </summary>
public string ServerInfo
{
get
{
return string.Format("{0}:{1}", IP, Port.ToString());
}
}
/// <summary>
/// 服务端端口
/// </summary>
public int Port { get; private set; }
/// <summary>
/// 启动状态
/// </summary>
public bool Started { get; private set; }
public TCPServer(string ip = "127.0.0.1", int port = 8888, string logName = "TCPServer")
{
Log = log4net.LogManager.GetLogger(logName);
IP = ip;
Port = port;
// 创建负责监听的套接字,注意其中的参数;
socketWatch = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
// 获得文本框中的IP对象;
IPAddress address = IPAddress.Parse(IP);
// 创建包含ip和端口号的网络节点对象;
IPEndPoint endPoint = new IPEndPoint(address, Port);
try
{
// 将负责监听的套接字绑定到唯一的ip和端口上;
socketWatch.Bind(endPoint);
}
catch (SocketException se)
{
Log.Error(string.Format("套接字绑定到服务端[{0}]出现异常", ServerInfo), se);
return;
}
// 设置监听队列的长度;
socketWatch.Listen(10);
// 创建负责监听的线程;
threadWatch = new Thread(WatchConnecting);
threadWatch.IsBackground = true;
threadWatch.Start();
}
/// <summary>
/// 设置缓存区长度
/// </summary>
public void SetBuffLength(int len)
{
buffLength = len;
}
/// <summary>
/// 开启服务
/// </summary>
public void Start()
{
if (Started)
return;
loop = true;
Started = true;
Log.Info(string.Format("TCP服务端[{0}]开启监听成功!", ServerInfo));
ServerStateChangedEvent?.Invoke(Started);
}
public void Stop()
{
loop = false;
foreach (string t in dictThread.Keys)
{
try
{
dictThread[t].Abort();
}
catch (Exception ex)
{
Log.Error(string.Format("关闭连接客户端[{0}]的线程失败", t), ex);
}
}
if (dictThread.Count > 0) dictThread.Clear();
foreach (string socket in dict.Keys)
{
try
{
dict[socket].Close();
}
catch (Exception ex)
{
Log.Error(string.Format("关闭连接客户端[{0}]Socket失败", socket), ex);
}
}
if (dict.Count > 0) dict.Clear();
Started = false;
ServerStateChangedEvent?.Invoke(Started);
ClientChangedEvent?.Invoke(dict.Keys.ToList<string>());
Log.Info(string.Format("TCP服务端[{0}]关闭监听成功!", ServerInfo));
}
/// <summary>
/// 监听客户端请求的方法;
/// </summary>
void WatchConnecting()
{
while (true) // 持续不断的监听客户端的连接请求;
{
while (loop)
{
// 开始监听客户端连接请求,Accept方法会阻断当前的线程;
Socket sokConnection = socketWatch.Accept(); // 一旦监听到一个客户端的请求,就返回一个与该客户端通信的 套接字;
// 将与客户端连接的 套接字 对象添加到集合中;
dict.Add(sokConnection.RemoteEndPoint.ToString(), sokConnection);
Log.Info(string.Format("客户端[{0}]连接服务端[{1}]成功", sokConnection.RemoteEndPoint.ToString(), ServerInfo));
Thread thr = new Thread(RecMsg);
thr.IsBackground = true;
thr.Start(sokConnection);
dictThread.Add(sokConnection.RemoteEndPoint.ToString(), thr); // 将新建的线程添加到线程的集合中去。
ClientChangedEvent?.Invoke(dict.Keys.ToList<string>());
}
}
}
void RecMsg(object sokConnectionparn)
{
Socket sokClient = sokConnectionparn as Socket;
while (loop)
{
// 定义一个缓存区;
byte[] arrMsgRec = new byte[buffLength];
// 将接收到的数据存入到输入 arrMsgRec中;
int length = -1;
if (sokClient.Poll(-1, SelectMode.SelectRead))
{
try
{
length = sokClient.Receive(arrMsgRec); // 接收数据,并返回数据的长度;
if (length == 0)//连接正常断开
{
Log.Info(string.Format("客户端[{0}]断开与服务端[{1}]的连接", sokClient.RemoteEndPoint.ToString(), ServerInfo));
// 从 通信套接字 集合中删除被中断连接的通信套接字;
dict.Remove(sokClient.RemoteEndPoint.ToString());
// 从通信线程集合中删除被中断连接的通信线程对象;
dictThread.Remove(sokClient.RemoteEndPoint.ToString());
ClientChangedEvent?.Invoke(dict.Keys.ToList<string>());
break;
}
}
catch (SocketException se)
{
Log.Error(string.Format("客户端[{0}]接收服务端[{1}]的消息出现异常", sokClient.RemoteEndPoint.ToString(), ServerInfo), se);
// 从 通信套接字 集合中删除被中断连接的通信套接字;
dict.Remove(sokClient.RemoteEndPoint.ToString());
// 从通信线程集合中删除被中断连接的通信线程对象;
dictThread.Remove(sokClient.RemoteEndPoint.ToString());
break;
}
catch (Exception e)
{
Log.Error(string.Format("客户端[{0}]接收服务端[{1}]的消息出现异常", sokClient.RemoteEndPoint.ToString(), ServerInfo), e);
// 从 通信套接字 集合中删除被中断连接的通信套接字;
dict.Remove(sokClient.RemoteEndPoint.ToString());
// 从通信线程集合中删除被中断连接的通信线程对象;
dictThread.Remove(sokClient.RemoteEndPoint.ToString());
ClientChangedEvent?.Invoke(dict.Keys.ToList<string>());
break;
}
}
if (length > 0)
{
string strMsg = System.Text.Encoding.UTF8.GetString(arrMsgRec, 0, length);// 将接收到的字节数据转化成字符串;
//if (IsDebug)
Log.Debug(string.Format("服务端[{0}]收到客户端[{1}]的消息:{2}[{3}][{4} Bytes]",
ServerInfo, sokClient.RemoteEndPoint.ToString(), strMsg, string.Join(" ", arrMsgRec.Take(length)), length));
//Log.Info(string.Format("服务端[{0}]收到客户端[{1}]的消息:{2}[{3} Bytes]", ServerInfo, sokClient.RemoteEndPoint.ToString(), strMsg,length));
RecvMsgEvent?.Invoke(sokClient.RemoteEndPoint.ToString(), strMsg);
}
}
}
/// <summary>
/// 向客户端发送信息
/// </summary>
public void SendMsg(string clientKey, string txt)
{
try
{
byte[] arrMsg = System.Text.Encoding.UTF8.GetBytes(txt); // 将要发送的字符串转换成Utf-8字节数组;
// arrSendMsg[0] = 0; // 表示发送的是消息数据
//Buffer.BlockCopy(arrMsg, 0, arrSendMsg, 1, arrMsg.Length);
int len = dict[clientKey].Send(arrMsg);
Log.Debug(string.Format("服务端[{0}]向客户端[{1}]发送消息:{2}[{3}][{4} Bytes]", ServerInfo, clientKey, txt, string .Join(" ", arrMsg),len));
}
catch (Exception e)
{
Log.Error(string.Format("服务端[{0}]向客户端[{1}]发送消息异常:{2}", ServerInfo, clientKey, txt), e);
// 从 通信套接字 集合中删除被中断连接的通信套接字;
dict.Remove(clientKey);
// 从通信线程集合中删除被中断连接的通信线程对象;
dictThread.Remove(clientKey);
ClientChangedEvent?.Invoke(dict.Keys.ToList<string>());
}
}
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common;
namespace DeviceLibrary
{
public class Agv_Info
{
/// <summary>
/// 小车名称
/// </summary>
public string Name { private set; get; }
/// <summary>
/// 小车在FLEET中的ID号
/// </summary>
public string ID { private set; get; }
/// <summary>
/// IP地址
/// </summary>
public string IP { private set; get; }
/// <summary>
/// IO模块GUID
/// </summary>
public string IOID { private set; get; }
/// <summary>
/// 授权码
/// </summary>
public string Authorization { private set; get; }
/// <summary>
/// 当前架子的RFID
/// </summary>
public string RFID { set; get; }
/// <summary>
/// 是否在线
/// </summary>
public bool IsCon
{
set
{
if (!value.Equals(isCon))
{
isCon = value;
StateKanban.SetConnectState(isCon);
}
}
get { return isCon; }
}
private bool isCon = false;
public bool IsInCharge { get; set; }
/// <summary>
/// 是否可用
/// </summary>
private bool _IsUse = true;
public bool IsUse
{
set
{
if (!value.Equals(_IsUse))
{
_IsUse = value;
AGVManager.WriteIni(Name, SettingString.IsUse, _IsUse.ToString());
}
}
get { return _IsUse; }
}
/// <summary>
/// 地点
/// </summary>
public string Place { set; get; } = SettingString.Standby;
/// <summary>
/// 地点
/// </summary>
public string PlaceAliceName { set; get; } = "";
/// <summary>
/// 小车的状态ID,(从小车获取)
/// </summary>
public eAGVState StateID { private set; get; }
/// <summary>
/// 负载
/// </summary>
public bool IsExistShelf { set; get; } = false;
/// <summary>
/// 电量百分比,(从小车获取)
/// </summary>
public int Battery { private set; get; }
/// <summary>
/// 当前任务文本,(从小车获取)
/// </summary>
public string MissionText { set; get; } = "";
public class MirPosition
{
public float orientation { get; set; }
public PointF Point;
}
/// <summary>
/// 当前位置
/// </summary>
public MirPosition Position;
/// <summary>
/// 任务内容
/// </summary>
public string Msg
{
get;
set;
} = "";
/// <summary>
/// 当前任务
/// </summary>
public Job CurJob { get; set; }
/// <summary>
/// 使用Fleet发任务
/// </summary>
public bool UseFleet=AppConfigHelper.GetBoolValue(SettingString.UseFleet);
/// <summary>
/// 当前任务的ID号
/// </summary>
public int CurTaskID { get; set; } = -1;
public string CurTaskState { get; set; } = "";
/// <summary>
/// 当前任务目的地名
/// </summary>
public string CurTarName { get; set; }
/// <summary>
/// 当前任务的GUID
/// </summary>
public string CurTaskGUID { get; set; }
/// <summary>
/// 当前料架的工单信息
/// </summary>
public string BoxDestInfo { get; set; } = "";
/// <summary>
/// 任务重发
/// </summary>
public void Resend(bool must=false)
{
if (CurJob != null)
{
CurJob.ResendTask(this,must);
}
}
/// <summary>
/// 停在同一处超时
/// </summary>
public bool StandTimeOut { get; set; } = false;
public AGV_UI.Status StateKanban;
public Agv_Info(string id, string name, string ip, string authorization, string ioID, bool isUse, string rfid)
{
ID = id;
Name = name;
IP = ip;
Authorization = authorization;
IOID = ioID;
RFID = rfid;
IsCon = false;
_IsUse = isUse;
Place = "";
Msg = "";
Position = new MirPosition();
RunInfos = new List<string>() { "状态", "目的地", "RFID", "负载", "运行模式", "任务信息", "AGV运行信息" };
StateKanban = new AGV_UI.Status(name, RunInfos);
}
public List<string> RunInfos;
DateTime IoStartTime = DateTime.MaxValue;
int IoLastTime = 5000;
int StandLastTimeMinute = 5;
public DateTime StandStartTime = DateTime.MaxValue;
public bool SetState(eAGVState stateID, string taskStateText, int battery, string missionText, MirPosition position)
{
bool isChange = false;
bool preShelfState = IsExistShelf;
MiR_API.Get_IO_Status(this, out bool[] input, out bool[] output);
if (input != null && input.Length == 4)
{
bool reachIoValue = input[3].Equals(true);
if (reachIoValue)
{
//满足给定的IO值,计算持续时间
if (IoStartTime == DateTime.MaxValue)
{
IoStartTime = DateTime.Now;
}
if (IoLastTime > 0)
{
//持续时间
TimeSpan lastTimeSpan = DateTime.Now - IoStartTime;
IsExistShelf = (lastTimeSpan.TotalMilliseconds >= IoLastTime);
}
else
{
IsExistShelf = false;
}
}
else
{
//重新计时
IoStartTime = DateTime.MinValue;
IsExistShelf = false;
}
}
if (!StateID.Equals(stateID) || !CurTaskState.Equals(taskStateText) || !Battery.Equals(battery)
|| !MissionText.Equals(missionText) || !IsExistShelf.Equals(preShelfState))
isChange = true;
if (!StateID.Equals(stateID))
{
StateID = stateID;
StateKanban.ShowInfo("状态", stateID.ToString());
}
if (!CurTaskState.Equals(taskStateText))
{
CurTaskState = taskStateText;
StateKanban.SetCurState(taskStateText);
}
if (!Battery.Equals(battery) && isCon)
{
Battery = battery;
StateKanban.SetBattery(battery, IsInCharge);
}
//"目的地", "RFID", "负载", "运行模式","任务信息", "AGV运行信息"
if (AGVManager.nodeInfo != null && AGVManager.nodeInfo.Count != 0)
{
ClientNode node = AGVManager.nodeInfo.Find(ss => ss.Name == Place);
if (node != null)
PlaceAliceName = node.AliceName;
else
PlaceAliceName = Place;
}
StateKanban.ShowInfo("目的地", PlaceAliceName);
StateKanban.ShowInfo("RFID", RFID);
if (!IsExistShelf.Equals(preShelfState))
{
StateKanban.ShowInfo("负载", IsExistShelf ? "满载" : "空载");
}
StateKanban.ShowInfo("运行模式", IsUse ? "自动" : "手动");
if (this.CurJob != null)
{
Msg = this.CurJob.RunInfo;
StateKanban.ShowInfo("任务信息", Msg);
}
if (!MissionText.Equals(missionText))
{
MissionText = missionText;
StateKanban.ShowInfo("AGV运行信息", missionText);
}
CheckStandTimeOut(position);
return isChange;
}
/// <summary>
/// 检查小车是否在原地停留超时
/// </summary>
/// <returns></returns>
private void CheckStandTimeOut(MirPosition position)
{
if (IsUse && CurJob != null && !(CurJob is ChargeJob) &&
(!CurTarName.Contains(SettingString.Standby)))//!CurTaskName.Contains(SettingString.AutoCharge) ||
{
if (Math.Abs(position.Point.X - Position.Point.X) < 1 && Math.Abs(position.Point.Y - Position.Point.Y) < 1)
{
//满足条件,计算持续时间
if (StandStartTime == DateTime.MaxValue)
{
StandStartTime = DateTime.Now;
}
TimeSpan lastTimeSpan = DateTime.Now - StandStartTime;
StandTimeOut = (lastTimeSpan.TotalMinutes >= StandLastTimeMinute);
}
else
{
//重新计时
StandStartTime = DateTime.Now;
StandTimeOut = false;
}
}
else if (CurJob != null && (CurJob is ChargeJob))
{
StandTimeOut = false;
StandStartTime = DateTime.Now;
}
else
{
StandTimeOut = false;
StandStartTime = DateTime.Now;
}
Position = position;
}
}
}
using Common;
namespace DeviceLibrary
{
public abstract class Job
{
/// <summary>
/// 是否任务正在执行,防止任务执行时间过长产生多线程问题
/// </summary>
public bool IsProcess { get; set; }
/// <summary>
/// 运行信息
/// </summary>
public abstract string RunInfo { get; }
/// <summary>
/// 根据任务状态继续执行任务
/// </summary>
public abstract Job Execute(Agv_Info agv);
public int CurTaskID { get; set; } = -1;
/// <summary>
/// 当前的任务目的地(与任务GUID对应)
/// </summary>
public string CurTarName { get; set; } = "";
/// <summary>
/// 当前任务的执行状态
/// </summary>
public string CurTaskState { get; set; } = "Wait";
/// <summary>
/// 更新任务信息
/// </summary>
/// <param name="curTaskName"></param>
/// <param name="curTaskId"></param>
protected void UpdateJobTaskInfo(Agv_Info agv)
{
CurTaskID = agv.CurTaskID;
CurTarName = agv.CurTarName;
CurTaskState = MissionSys.GetTakJobState(agv);
}
/// <summary>
/// 任务重发
/// </summary>
/// <returns></returns>
public bool ResendTask(Agv_Info agv,bool must=false)
{
bool rtn = false;
if(must)
{
rtn = MissionSys.AssignMission(agv, CurTarName);
if (rtn)
{
UpdateJobTaskInfo(agv);
return true;
}
}
else if (!CurTaskID.Equals(-1) && MiR_API.Get_Task_State(agv, out string stateStr))
{
if (stateStr.Equals(SettingString.Aborted) || stateStr.Equals(SettingString.Invalid))
{
rtn = MissionSys.AssignMission(agv, CurTarName);
if (rtn)
{
UpdateJobTaskInfo(agv);
return true;
}
}
}
else if (!CurTarName.Equals("") && !MissionSys.GetMissionGuidByTaskName(CurTarName).Equals(agv.CurTaskGUID))//Job的当前任务与agv最新任务不一致
{
rtn = MissionSys.AssignMission(agv, CurTarName);
if (rtn)
{
UpdateJobTaskInfo(agv);
return true;
}
}
else if (CurTaskID.Equals(-1))//任务发送失败,重新发送
{
rtn = MissionSys.AssignMission(agv, CurTarName);
if (rtn)
{
UpdateJobTaskInfo(agv);
return true;
}
}
return false;
}
}
}

using Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class JobStep<T> where T : Enum
{
private T step;
private string msg = "";
public string Msg
{
get { return msg; }
set
{
if (!string.IsNullOrEmpty(value))
{
//不为空,且与上一个消息不一样才打印
if (!value.Equals(msg))
{
LogUtil.info(value);
}
}
msg = value;
}
}
private DateTime startTime = DateTime.Now;
public JobStep(T initStep)
{
this.step = initStep;
this.msg = "";
}
/// <summary>
/// 当前步骤是否是某个步骤
/// </summary>
/// <param name="step"></param>
/// <returns></returns>
public bool IsStep(T step)
{
return this.step.Equals(step);
}
/// <summary>
/// 是否超时
/// </summary>
/// <param name="timeOutMilliseconds"></param>
/// <returns></returns>
public bool IsTimeOut(int timeOutMilliseconds,out double timeOutValue)
{
timeOutValue = 0;
TimeSpan span = DateTime.Now - startTime;
if (span.TotalMilliseconds > timeOutMilliseconds)
{
timeOutValue = span.TotalSeconds;
return true;
}
return false;
}
/// <summary>
/// 进入下一个步骤
/// </summary>
/// <param name="nextStep"></param>
public void ToNextStep(T nextStep)
{
step = nextStep;
startTime = DateTime.Now;
}
public void ResetStartTime()
{
startTime = DateTime.Now;
}
public string CurStep()
{
return step.ToString();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class JobType
{
public JobType()
{
}
public virtual Job GetNewJob(Agv_Info agv)
{
return null;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Script.Serialization;
using Common;
using Microsoft.SqlServer.Server;
using RestSharp;
using static DeviceLibrary.Agv_Info;
namespace DeviceLibrary
{
public class MiR_API
{
private const int httpTimeout = 5000;
private static log4net.ILog log = log4net.LogManager.GetLogger("MiR_API");
/// <summary>
/// 获取IO模块guid列表
/// </summary>
/// <param name="info"></param>
/// <param name="guid"></param>
/// <returns></returns>
public static bool Get_IO_Modules(Agv_Info info, out string[] guid)
{
try
{
guid = null;
string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text";
string json = HttpGet(url, info.IP, info.Authorization);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
object[] obj = (object[])serializer.DeserializeObject(json);
if (obj == null)
{
log.Error("URL: " + url + "\n" + "Return: " + json);
return false;
}
guid = new string[obj.Length];
for (int i = 0; i < obj.Length; i++)
{
Dictionary<string, object> dic = (Dictionary<string, object>)obj[i];
guid[i] = dic["guid"].ToString();
}
log.Info("URL: " + url + "\n" + "Return: " + json);
return true;
}
catch (Exception ex)
{
guid = null;
log.Error("Get_IO_Modules", ex);
return false;
}
}
/// <summary>
/// 获取IO模块的状态
/// </summary>
/// <param name="info"></param>
/// <param name="input"></param>
/// <param name="output"></param>
/// <returns></returns>
public static bool Get_IO_Status(Agv_Info info, out bool[] input, out bool[] output)
{
try
{
input = null;
output = null;
string url = "http://" + info.IP + "/api/v2.0.0/io_modules/" + info.IOID + "/status";
string json = HttpGet(url, info.IP, info.Authorization);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null)
{
log.Error("URL: " + url + "\n" + "Return: " + json);
return false;
}
object[] objInput = (object[])dic["input_state"];
input = new bool[objInput.Length];
for (int i = 0; i < input.Length; i++)
input[i] = Convert.ToBoolean(objInput[i]);
object[] objOutput = (object[])dic["output_state"];
output = new bool[objOutput.Length];
for (int i = 0; i < output.Length; i++)
output[i] = Convert.ToBoolean(objOutput[i]);
return true;
}
catch (Exception ex)
{
input = null;
output = null;
//log.Error("Get_IO_Status", ex);
return false;
}
}
/// <summary>
/// 获取PLC寄存器的内容
/// </summary>
/// <param name="info"></param>
/// <param name="reg"></param>
/// <param name="regValue"></param>
/// <returns></returns>
public static bool Get_Register(Agv_Info info, int reg, out int regValue)
{
try
{
regValue = -1;
string url = "http://" + info.IP + "/api/v2.0.0/registers/" + reg + "?whitelist=value";
string json = HttpGet(url, info.IP, info.Authorization);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null)
{
log.Error("URL: " + url + "\n" + "Return: " + json);
return false;
}
string s = dic["value"].ToString();
float f = Convert.ToSingle(s);
regValue = Convert.ToInt32(f);
return true;
}
catch (Exception ex)
{
regValue = -1;
log.Error("Get_Register", ex);
return false;
}
}
/// <summary>
/// 设置PLC寄存器的内容
/// </summary>
/// <param name="info"></param>
/// <param name="reg"></param>
/// <param name="regValue"></param>
/// <returns></returns>
public static bool Set_Register(Agv_Info info, int reg, int regValue)
{
try
{
string url = "http://" + info.IP + "/api/v2.0.0/registers/" + reg;
string body = "{\"value\": " + regValue + "}";
string json = HttpPost(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null)
{
log.Error("URL: " + url + "\n" + "Return: " + json);
return false;
}
string s = dic["value"].ToString();
float f = Convert.ToSingle(s);
if (regValue == Convert.ToInt32(f))
return true;
else
return false;
}
catch (Exception ex)
{
log.Error("Set_Register", ex);
return false;
}
}
/// <summary>
/// 添加任务到任务队列
/// </summary>
/// <param name="info"></param>
/// <param name="mission_id"></param>
/// <returns></returns>
public static bool Add_Mission(Agv_Info info, string mission_id, bool isRemovePreMission = true)
{
try
{
info.CurTaskID = -1;
info.CurTaskGUID = "";
info.CurTaskState = SettingString.Wait;
log.Debug(string.Format("{0} Add_Mission [{1}]", info.Name, mission_id));
//删除上一任务
Del_Mission(info);
string url = "http://" + info.IP + "/api/v2.0.0/mission_queue";
string body = "{\"mission_id\":\"" + mission_id + "\"}";
string json = HttpPost(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null)
{
return false;
}
log.Debug("URL: " + url + "\n" + "Return: " + json);
string s = dic["mission_id"].ToString();
string id = dic["id"].ToString();
if (s == mission_id)
{
try
{
info.CurTaskGUID = mission_id;
if (info.IsUse)
info.CurTaskID = Convert.ToInt32(id);
}
catch
{
log.Error(string.Format("{0} Add_Mission [{1}]", info.Name, mission_id));
info.CurTarName = "";
}
return true;
}
else
return false;
}
catch (Exception ex)
{
log.Error("Add_Mission", ex);
return false;
}
}
/// <summary>
/// 添加任务到任务队列
/// </summary>
/// <param name="info"></param>
/// <param name="mission_id"></param>
/// <returns></returns>
public static bool Add_Mission_Fleet(Agv_Info info, string mission_id, bool isRemovePreMission = true)
{
try
{
info.CurTaskID = -1;
info.CurTaskGUID = "";
info.CurTaskState = SettingString.Wait;
//防止上一个任务已执行但返回失败时,删除任务
Del_Mission(info);
string ip = AppConfigHelper.GetValue(SettingString.FLEET);
string url = "http://" + ip + "/api/v2.0.0/mission_scheduler";
string body = "{\"mission_id\":\"" + mission_id + "\",\"robot_id\":" + info.ID + "}";
string json = HttpPost(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null)
{
return false;
}
log.Debug("URL: " + url + "\n" + "Return: " + json);
string s = dic["mission_id"].ToString();
string id = dic["id"].ToString();
if (s == mission_id)
{
try
{
info.CurTaskID = Convert.ToInt32(id);
info.CurTaskGUID = mission_id;
}
catch
{
log.Info(string.Format("{0} Add_Mission_Fleet [{1}]", info.Name, mission_id));
info.CurTarName = "";
}
return true;
}
else
return false;
}
catch (Exception ex)
{
log.Error("Add_Mission_Fleet", ex);
return false;
}
}
/// <summary>
/// 获取所有任务列表
/// </summary>
/// <param name="info"></param>
/// <param name="mission">任务(名称,guid)</param>
/// <returns></returns>
public static bool Get_Mission(Agv_Info info, out Dictionary<string, string> mission)
{
mission = null;
try
{
string url = "http://" + info.IP + "/api/v2.0.0/missions/search?whitelist=guid,name";
string body = "{\"filters\" :[]}";
string json = HttpPost(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
object[] obj = (object[])serializer.DeserializeObject(json);
if (obj == null) return false;
mission = new Dictionary<string, string>();
for (int i = 0; i < obj.Length; i++)
{
Dictionary<string, object> dic = (Dictionary<string, object>)obj[i];
mission.Add(dic["name"].ToString(), dic["guid"].ToString());
}
return true;
}
catch (Exception ex)
{
log.Error("Get_Mission", ex);
return false;
}
}
/// <summary>
/// 获取当前任务队列guid
/// </summary>
/// <param name="info"></param>
/// <param name="mission"></param>
/// <returns></returns>
public static bool Get_Mission_Queue(Agv_Info info, out List<string> mission)
{
mission = null;
try
{
string url = "http://" + info.IP + "/api/v2.0.0/mission_queue/search";
string body = "{\"filters\" : [{\"fieldname\": \"state\", \"operator\": \"IN\", \"value\": [\"Pending\", \"Executing\"]}]}";
string json = HttpPost(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
object[] obj = (object[])serializer.DeserializeObject(json);
if (obj == null) return false;
mission = new List<string>();
Dictionary<string, object> dic;
for (int i = 0; i < obj.Length; i++)
{
dic = (Dictionary<string, object>)obj[i];
mission.Add(dic["id"].ToString());
}
for (int i = 0; i < mission.Count; i++)
{
url = "http://" + info.IP + "/api/v2.0.0/mission_queue/" + mission[i];
json = HttpGet(url, info.IP, info.Authorization);
serializer = new JavaScriptSerializer();
dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
mission[i] = dic["mission_id"].ToString();
}
return true;
}
catch (Exception ex)
{
log.Error("Get_Mission_Queue", ex);
return false;
}
}
/// <summary>
/// 删除当前所有任务
/// </summary>
/// <param name="info"></param>
public static void Del_Mission(Agv_Info info)
{
try
{
string url = "http://" + info.IP + "/api/v2.0.0/mission_queue";
HttpDel(url, info.IP, info.Authorization);
}
catch (Exception ex)
{
log.Error("Del_Mission", ex);
}
}
/// <summary>
/// 删除Fleet尽快中指定id的任务,已运行的无法删除
/// </summary>
/// <param name="authorization"></param>
/// <param name="id"></param>
public static void Del_Mission_Fleet(Agv_Info agv, string id)
{
try
{
string ip = AppConfigHelper.GetValue(SettingString.FLEET);
string url = "http://" + ip + "/api/v2.0.0/mission_scheduler/" + id;
HttpDel(url, ip, agv.Authorization);
}
catch (Exception ex)
{
log.Error(ex);
}
}
/// <summary>
/// 获取Fleet任务状态
/// </summary>
/// <param name="CurTaskID"></param>
/// <param name="stateStr"></param>
/// <returns></returns>
public static bool Get_Task_State(Agv_Info agv, out string stateStr)
{
stateStr = SettingString.Wait;
try
{
if (agv.CurTaskID == -1)
return true;
if (agv.UseFleet)
{
string ip = AppConfigHelper.GetValue(SettingString.FLEET);
string url = "http://" + ip + "/api/v2.0.0/mission_scheduler/" + agv.CurTaskID;
string json = HttpGet(url, ip, AGVManager.agvInfo[0].Authorization);
log.Debug("URL: " + url + "\n" + "Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null) return false;
// "mission_id": "2e433130-c045-11ea-9a66-94c691a7387d",
// "id": 7178,
// "state": "Done"
string s = dic["id"].ToString();
if (s.Equals(agv.CurTaskID.ToString()))
{
stateStr = dic["state"].ToString();
return true;
}
}
else
{
string url = "http://" + agv.IP + "/api/v2.0.0/mission_queue/" + agv.CurTaskID;
string json = HttpGet(url, agv.IP, agv.Authorization);
log.Debug("URL: " + url + "\n" + "Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null) return false;
// "mission_id": "2e433130-c045-11ea-9a66-94c691a7387d",
// "id": 7178,
// "state": "Done"
string s = dic["id"].ToString();
if (s.Equals(agv.CurTaskID.ToString()))
{
stateStr = dic["state"].ToString();
return true;
}
}
return false;
}
catch (Exception ex)
{
log.Error("Get_Task_State", ex);
return false;
}
}
/// <summary>
/// 获取当前小车状态
/// </summary>
/// <param name="info"></param>
/// <param name="stateID"></param>
/// <param name="stateText"></param>
/// <param name="battery"></param>
/// <param name="mission_text"></param>
/// <returns></returns>
public static bool Get_State(Agv_Info info, out eAGVState stateID, out string stateText, out int battery, out string mission_text, out MirPosition position)
{
stateID = eAGVState.UNKNOWN;
stateText = "";
battery = 0;
mission_text = "";
position = new MirPosition();
try
{
string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage,mission_text,position";
string json = HttpGet(url, info.IP, info.Authorization);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null) return false;
//state_id不存在:{"args":{},"error_code":"service_unavailable","error_human":"\u670d\u52a1\u4e0d\u53ef\u7528\uff0c\u8bf7\u7a0d\u540e\u91cd\u8bd5"}
log.Debug("Get_State URL:" + url + " Return" + json);
try
{
stateID = (eAGVState)(Convert.ToInt32(dic["state_id"].ToString()));
}
catch
{
log.Error("获取状态失败:" + info.IP + " " + json);
return false;
}
stateID = (eAGVState)(Convert.ToInt32(dic["state_id"].ToString()));
stateText = dic["state_text"].ToString();
mission_text = dic["mission_text"].ToString();
string s = dic["battery_percentage"].ToString();
float f = Convert.ToSingle(s);
battery = Convert.ToInt32(f);
Dictionary<string, object> posDic = (Dictionary<string, object>)dic["position"];
if (posDic == null) return false;
position.orientation = Convert.ToSingle(posDic["orientation"].ToString());
position.Point.X = Convert.ToSingle(posDic["x"]);
position.Point.Y = Convert.ToSingle(posDic["y"]);
return true;
}
catch (Exception ex)
{
log.Error("Get_State: ", ex);
return false;
}
}
/// <summary>
/// 小车状态改为Ready
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
public static bool State_Ready(Agv_Info info)
{
try
{
string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text";
string body = "{\"state_id\": 3}";
string json = HttpPut(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null) return false;
string s = dic["state_id"].ToString();
if (s == "3")
return true;
else
return false;
}
catch (Exception ex)
{
log.Error("State_Ready", ex);
return false;
}
}
/// <summary>
/// 小车状态改为Pause
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
public static bool State_Pause(Agv_Info info)
{
try
{
string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text";
string body = "{\"state_id\": 4}";
string json = HttpPut(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null) return false;
string s = dic["state_id"].ToString();
if (s == "4")
return true;
else
return false;
}
catch (Exception ex)
{
log.Error("State_Pause", ex);
return false;
}
}
/// <summary>
/// 清除错误
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
public static bool Clear_Error(Agv_Info info)
{
try
{
string url = "http://" + info.IP + "/api/v2.0.0/status";
string body = "{\"clear_error\": true}";
string json = HttpPut(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
return true;
}
catch (Exception ex)
{
log.Error("Clear_Error", ex);
return false;
}
}
/// <summary>
/// 检查IP地址
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public static bool CheckIP(string ip)
{
//IP合法
string pattern = @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$";
bool rtn = System.Text.RegularExpressions.Regex.IsMatch(ip, pattern);
if (!rtn)
{
log.Error("非法的IP地址" + ip);
return false;
}
//Ping服务端
try
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingReply result = ping.Send(ip, 2000);
ping.Dispose();
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
{
log.Error("Ping " + ip + " 请求没有响应");
return false;
}
return true;
}
catch (Exception ex)
{
log.Error("CheckIP", ex);
return false;
}
}
#region HTTP GET POST PUT DEL
private static string HttpGet(string url, string ip, string authorization)
{
RestClient client = new RestClient(url) { Timeout = httpTimeout };
RestRequest request = new RestRequest(Method.GET);
request.AddHeader("Host", ip);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept-Language", "zh_CN");
request.AddHeader("Authorization", authorization);
IRestResponse response = client.Execute(request);
string s = response.Content;
s = s.Replace("\n", "");
s = s.Replace(" ", "");
log.Debug("HttpGet URL: " + url + " Return: " + s);
return s;
}
private static string HttpPost(string url, string ip, string authorization, string body)
{
var client = new RestClient(url) { Timeout = httpTimeout };
var request = new RestRequest(Method.POST);
request.AddHeader("Host", ip);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept-Language", "zh_CN");
request.AddHeader("Authorization", authorization);
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
string s = response.Content;
s = s.Replace("\n", "");
s = s.Replace(" ", "");
log.Debug(string.Format("HttpPost URL: {0}; Body: {1} Return: {2}", url, body, s));
return s;
}
private static string HttpPut(string url, string ip, string authorization, string body)
{
RestClient client = new RestClient(url) { Timeout = httpTimeout };
RestRequest request = new RestRequest(Method.PUT);
request.AddHeader("Host", ip);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept-Language", "zh_CN");
request.AddHeader("Authorization", authorization);
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
string s = response.Content;
s = s.Replace("\n", "");
s = s.Replace(" ", "");
log.Debug(string.Format("HttpPut URL: {0}; Body: {1} Return: {2}", url, body, s));
return s;
}
private static void HttpDel(string url, string ip, string authorization)
{
RestClient client = new RestClient(url) { Timeout = httpTimeout };
RestRequest request = new RestRequest(Method.DELETE);
request.AddHeader("Host", ip);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", authorization);
request.AddHeader("Accept-Language", "zh_CN");
request.AddParameter("application/json", "", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
string s = response.Content;
log.Debug("HttpDel URL: " + url);
}
#endregion
}
/// <summary>
/// MIR 状态,与状态ID对应
/// </summary>
public enum eAGVState
{
None = 0,
Starting,
ShuttingDown,
Ready,
Pause,
Executing,
Aborted,
Completed,
Docked,
Docking,
EmergencyStop,
ManualControl,
Error,
UNKNOWN
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class Mission
{
/// <summary>
/// 任务名称
/// </summary>
public string Name { private set; get; }
/// <summary>
/// 任务别名
/// </summary>
public string AliceName { private set; get; }
/// <summary>
/// 任务guid
/// </summary>
public string Guid { private set; get; }
/// <summary>
/// 任务
/// </summary>
/// <param name="name">任务名称</param>
/// <param name="aliceName">任务别名</param>
/// <param name="targetName">目的地名</param>
/// <param name="targetAliceName">目的地别名</param>
/// <param name="guid">任务guid</param>
public Mission(string name,string aliceName,string guid)
{
Name = name;
AliceName = aliceName;
Guid = guid;
}
}
}
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace DeviceLibrary
{
public abstract class Node
{
/// <summary>
/// 节点名称
/// </summary>
public string Name { get;}
/// <summary>
/// 节点IP
/// </summary>
public string IP { get; }
/// <summary>
/// 在线状态
/// </summary>
public bool Online { get; set; }
/// <summary>
/// 是否可调用
/// </summary>
public bool IsUse { set; get; }
/// <summary>
/// 节点状态
/// </summary>
protected eNodeStatus nodeStatus;
public Node(string name,string ip,bool isUse=false)
{
Name = name;
IP = ip;
Online = false;
IsUse = isUse;
nodeStatus = eNodeStatus.None;
}
public Node(string name)
{
Name = name;
}
/// <summary>
/// 状态比较
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public bool StateEquals(eNodeStatus obj)
{
return nodeStatus.Equals(obj);
}
/// <summary>
/// 获取当前状态
/// </summary>
/// <returns></returns>
public eNodeStatus GetState()
{
return nodeStatus;
}
/// <summary>
/// 更新节点状态
/// </summary>
/// <param name="status"></param>
public void UpdateNodeStatus(eNodeStatus status)
{
nodeStatus = status;
}
}
/// <summary>
/// 节点状态
/// </summary>
public enum eNodeStatus : byte
{
/// <summary>
/// 没有动作
/// </summary>
None = 0,
/// <summary>
/// 需要7寸D料架
/// </summary>
NeedD = 1,
/// <summary>
/// 需要大尺寸C料架
/// </summary>
NeedC = 2,
/// <summary>
/// 需要进入料架
/// </summary>
NeedEnter = 3,
/// <summary>
/// 需要出去料架
/// </summary>
NeedLeave = 4,
/// <summary>
/// 需要进入离开料架
/// </summary>
NeedEnterLeave = 5,
/// <summary>
/// 准备进入料架,服务器发送
/// </summary>
ReadyEnter = 6,
/// <summary>
/// 可以进入料架
/// </summary>
MayEnter = 7,
/// <summary>
/// 完成进入料架
/// </summary>
FinishEnter = 8,
/// <summary>
/// 准备离开料架,服务器发送
/// </summary>
ReadyLeave = 9,
/// <summary>
/// 可以出去料架
/// </summary>
MayLeave = 10,
/// <summary>
/// 完成出去料架
/// </summary>
FinishLeave = 11,
}
/// <summary>
/// 客户端的优先级
/// </summary>
public enum ClientLevel : byte
{
/// <summary>
/// 低
/// </summary>
Low = 0,
/// <summary>
/// 中等
/// </summary>
Middle = 1,
/// <summary>
/// 高
/// </summary>
High = 2
}
}
using Common;
namespace DeviceLibrary
{
/// <summary>
/// 充电任务
/// </summary>
public class ChargeJob : Job
{
/// <summary>
/// 充电任务
/// </summary>
/// <param name="agvPlae">小车当前位置</param>
public ChargeJob(string agvPlae)
{
this.agvPlace = agvPlae;
}
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlace = SettingString.Standby;
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return string.Format("充电任务[{0}]:{1} ", CurTaskID, runInfo); }
}
private JobStep<CHARGE_STEP> jobStep = new JobStep<CHARGE_STEP>(CHARGE_STEP.NONE);
/// <summary>
/// 充电任务
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = string.Format("{0} 充电任务: ", agv.Name);
//bool rtn = false;
CurTaskState = MissionSys.GetTakJobState(agv);
if (jobStep.IsStep(CHARGE_STEP.NONE))
{
if (agv.Battery > AGVManager.Charge.BatteryMax)
{
if (agvPlace.Equals(SettingString.Standby) || agvPlace.Equals(""))//在待机位
{
jobStep.ToNextStep(CHARGE_STEP.END);
runInfo = "在待机位,电量充足[" + agv.Battery + "%],等待任务";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Standby);
UpdateJobTaskInfo(agv);
}
else
{
jobStep.ToNextStep(CHARGE_STEP.WAIT_REACH_STANDBY);
runInfo = "电量充足[" + agv.Battery + "%],从当前位置" + agvPlace + "回到待机位";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Standby);
UpdateJobTaskInfo(agv);
}
}
else
{
if (!AGVManager.Charge.StartCharge(agv))
{
jobStep.ToNextStep(CHARGE_STEP.WAIT_REACH_STANDBY);
runInfo = "电量" + agv.Battery + "%小于最大电量" + AGVManager.Charge.BatteryMax + "%,充电桩有小车,从当前位置" + agvPlace + "回到待机位";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Standby);
UpdateJobTaskInfo(agv);
}
else
{
jobStep.ToNextStep(CHARGE_STEP.WAIT_REACH_CHARGE_STATION);
runInfo = "电量" + agv.Battery + "%小于最大电量" + AGVManager.Charge.BatteryMax + "%,从当前位置" + agvPlace + "去充电位";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
UpdateJobTaskInfo(agv);
}
}
}
else if (jobStep.IsStep(CHARGE_STEP.WAIT_REACH_CHARGE_STATION))
{
if (MissionSys.CheckTaskIsOK(agv, CurTarName, CurTaskState))
{
jobStep.ToNextStep(CHARGE_STEP.WAIT_REACH_CHARGE_OK);
runInfo = "开始充电任务";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
}
}
else if (jobStep.IsStep(CHARGE_STEP.WAIT_REACH_CHARGE_OK))
{
if (agv.Battery >= AGVManager.Charge.BatteryMax)
{
jobStep.ToNextStep(CHARGE_STEP.WAIT_REACH_STANDBY);
runInfo = "电量充足,回待机位";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
AGVManager.Charge.DelOccupyInfo(agv);
MissionSys.AssignMission(agv, SettingString.Standby);
UpdateJobTaskInfo(agv);
}
else if (agv.Battery >= AGVManager.Charge.BatteryMin)
{
Job job = AGVManager.control.GetJob(agv);
if (job != null && !(job is ChargeJob))
{
AGVManager.Charge.DelOccupyInfo(agv);
runInfo = "充电过程检测到任务,电量" + agv.Battery + "%大于最小电量" + AGVManager.Charge.BatteryMin + "%,中断充电执行任务";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
return job;
}
}
}
else if (jobStep.IsStep(CHARGE_STEP.WAIT_REACH_STANDBY))
{
if (MissionSys.CheckTaskFinished(agv, SettingString.Standby, CurTaskState))
{
jobStep.ToNextStep(CHARGE_STEP.END);
runInfo = "充电完成,到达待机位";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
}
}
else if (jobStep.IsStep(CHARGE_STEP.END))
{
runInfo = "等待任务";
Job job = AGVManager.control.GetJob(agv);
if (job != null && !(job is ChargeJob))
{
runInfo = "在待机位检测到任务,执行任务";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
AGVManager.Charge.DelOccupyInfo(agv);
return job;
}
else if (agv.Battery < AGVManager.Charge.BatteryMax / 2 && job is ChargeJob)
{
jobStep.ToNextStep(CHARGE_STEP.NONE);
runInfo = "在待机位暂无任务,且当前电量小于" + AGVManager.Charge.BatteryMax / 2 + "%,去充电位";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
AGVManager.Charge.DelOccupyInfo(agv);
}
}
return this;
}
/// <summary>
/// AGV充电流程
/// </summary>
private enum CHARGE_STEP
{
/// <summary>
///
/// </summary>
NONE,
/// <summary>
/// 等待AGV到达充电位
/// </summary>
WAIT_REACH_CHARGE_STATION,
/// <summary>
/// 等待充电完成
/// </summary>
WAIT_REACH_CHARGE_OK,
/// <summary>
/// 充电完成去待机位
/// </summary>
WAIT_REACH_STANDBY,
/// <summary>
///
/// </summary>
END
}
}
}

using Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.PeerResolvers;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceLibrary
{
/// <summary>
/// 空车返回任务
/// </summary>
public class EmptyAGVBackJob : Job
{
/// <summary>
/// 出完满料后-空车返回任务
/// </summary>
/// <param name="agvPlae">小车当前位置,空表示在待机位</param>
public EmptyAGVBackJob(string agvPlae)
{
this.agvPlace = agvPlae;
}
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlace { get; set; }
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return string.Format("返回任务[{0}]:{1}", CurTaskID,runInfo); }
}
private JobStep<EMPTY_AGV_BACK_STEP> jobStep = new JobStep<EMPTY_AGV_BACK_STEP>(EMPTY_AGV_BACK_STEP.NONE);
/// <summary>
/// 空车返回执行
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = string.Format("{0} 返回任务: ", agv.Name);
//bool rtn = false;
CurTaskState = MissionSys.GetTakJobState(agv);
if (jobStep.IsStep(EMPTY_AGV_BACK_STEP.NONE))
{
if (AGVManager.FindEmptyShelfNode(agv, out string nodeName, true))
{
int i = AGVManager.agvInfo.FindIndex(s => s.CurJob is GoEmptyShelfLineJob && ((GoEmptyShelfLineJob)s.CurJob).EmptyShelfPlace.Equals(nodeName));
if (i == -1)
{
ClientNode clientNode = AGVManager.nodeInfo.Find(s => s.Name.Equals(nodeName));
if (AGVManager.CheckStationState(clientNode, out string rfid))
{
runInfo = "小车在产线 " + agvPlace + " 准备返回时检测到 " + nodeName + " 有空料架";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
return new GoEmptyShelfLineJob(agvPlace, nodeName, rfid);
}
else
{
if (AGVManager.CheckIsInAirDoor(agvPlace))
{
jobStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_RoomC_AIR_DOOR);
runInfo = string.Format("从产线{0}回待机位,先过{1}风淋门", agvPlace,SettingString.RoomC_Name);
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.DoorAirOut);
UpdateJobTaskInfo(agv);
}
else if (agvPlace.StartsWith(SettingString.RoomC_Name_Prefix))
{
jobStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_RoomD_DOOR);
runInfo = string.Format("从产线{0}回待机位,先过{1}门", agvPlace,SettingString.RoomC_Name);
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv);
}
else
{
jobStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_REACH_STANDBY);
runInfo = "从产线" + agvPlace + "回待机位";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Standby);
UpdateJobTaskInfo(agv);
}
}
}
else
{
if (AGVManager.CheckIsInAirDoor(agvPlace))
{
jobStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_RoomC_AIR_DOOR);
runInfo = string.Format("从产线{0}回待机位,先过{1}风淋门", agvPlace,SettingString.RoomC_Name);
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.DoorAirOut);
UpdateJobTaskInfo(agv);
}
else if (agvPlace.StartsWith(SettingString.RoomC_Name_Prefix))
{
jobStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_RoomD_DOOR);
runInfo = string.Format("从产线{0}回待机位,先过{1}门", agvPlace, SettingString.RoomC_Name);
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv);
}
else
{
jobStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_REACH_STANDBY);
runInfo = "从产线" + agvPlace + "回待机位";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Standby);
UpdateJobTaskInfo(agv);
}
}
}
else
{
if (AGVManager.CheckIsInAirDoor(agvPlace))
{
jobStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_RoomC_AIR_DOOR);
runInfo = string.Format("从产线{0}回待机位,先过{1}风淋门", agvPlace, SettingString.RoomC_Name);
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.DoorAirOut);
UpdateJobTaskInfo(agv);
}
else if (agvPlace.StartsWith(SettingString.RoomC_Name_Prefix))
{
jobStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_RoomD_DOOR);
runInfo = string.Format("从产线{0}回待机位,先过{1}门", agvPlace, SettingString.RoomC_Name);
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv);
}
else
{
jobStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_REACH_STANDBY);
runInfo = "从产线" + agvPlace + "回待机位";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Standby);
UpdateJobTaskInfo(agv);
}
}
}
else if (jobStep.IsStep(EMPTY_AGV_BACK_STEP.WAIT_REACH_STANDBY))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.Standby, CurTaskState))
{
Job job = AGVManager.control.GetJob(agv);
if (job == null && agv.Battery < AGVManager.Charge.BatteryMax)
{
runInfo = "到达待机位,电量" + agv.Battery + "小于最大电量" + AGVManager.Charge.BatteryMax + ",暂无任务,去充电";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
return new ChargeJob(SettingString.Standby);
}
else
{
runInfo = "到达待机位,检测到新任务,执行任务";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
return job;
}
}
else
{
if (AGVManager.FindFullShelfTask(agv))
{
runInfo = "从产线" + agvPlace + "回待机位过程中,检测到A6出满料,去A6";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
return new GoFullShelfStationJob(SettingString.Standby);
}
}
}
else if (jobStep.IsStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_RoomC_AIR_DOOR))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorAirOut, CurTaskState))
{
jobStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_RoomD_DOOR);
runInfo = string.Format("从产线{0}回待机位,先过{1}门", agvPlace, SettingString.RoomC_Name);
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv);
}
}
else if (jobStep.IsStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_RoomD_DOOR))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorCToD, CurTaskState))
{
if (AGVManager.FindFullShelfTask(agv))
{
runInfo = string.Format("从产线{0}到达{1}门,检测到A6出满料,去A6", agvPlace, SettingString.RoomD_Name);
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
return new GoFullShelfStationJob(SettingString.DoorCToD);
}
else
{
runInfo = string.Format("从产线{0}到达{1}门,暂无任务,去充电位", agvPlace, SettingString.RoomD_Name);
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
return new ChargeJob(SettingString.DoorCToD);
}
}
}
return this;
}
/// <summary>
/// AGV回收空料架流程
/// </summary>
private enum EMPTY_AGV_BACK_STEP
{
/// <summary>
/// 查询任务
/// </summary>
NONE,
/// <summary>
/// 等待到达C风淋门
/// </summary>
WAIT_AGV_REACH_RoomC_AIR_DOOR,
/// <summary>
/// 等待到达D门
/// </summary>
WAIT_AGV_REACH_RoomD_DOOR,
/// <summary>
/// 等待恒邑反馈
/// </summary>
WAIT_HY_RESPONSE,
/// <summary>
/// 等待AGV到达待机位
/// </summary>
WAIT_REACH_STANDBY,
/// <summary>
///
/// </summary>
END
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.ModelBinding;
using System.Windows.Forms;
using Common;
namespace DeviceLibrary
{
/// <summary>
/// 载空料架返回任务
/// </summary>
public class EmptyShelfBackJob : Job
{
/// <summary>
/// 载空料架返回任务
/// </summary>
/// <param name="lineName">产线的节点名称</param>
public EmptyShelfBackJob(string lineName, eShelfType shelfType)
{
EmptyShelfPlace = lineName;
this.shelfType = shelfType;
}
/// <summary>
/// 空料架的产线位置
/// </summary>
private string EmptyShelfPlace { get; set; }
/// <summary>
/// 空料架目的地
/// </summary>
public string EmptyShelfTargetPlace { get; set; } = "";
private int tryTimes = 0;
private eShelfType shelfType;
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return string.Format("空料架[{0}][{1}]返回:{2} ", shelfType.ToString(), CurTaskID, runInfo); }
}
private JobStep<EMPTY_SHELF_BACK_STEP> jobStep = new JobStep<EMPTY_SHELF_BACK_STEP>(EMPTY_SHELF_BACK_STEP.NONE);
/// <summary>
/// 空架任务执行
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = string.Format("{0} 空料架[{1}]返回: ", agv.Name, shelfType.ToString());
//bool rtn = false;
//runInfo = "空料架返回:";
if (jobStep.IsStep(EMPTY_SHELF_BACK_STEP.NONE))
{
if (AGVManager.CheckBoxNeedShelfState(agv, out string nodeName))
{
EmptyShelfTargetPlace = nodeName;
jobStep.ToNextStep(EMPTY_SHELF_BACK_STEP.WAIT_AGV_REACH_Target);
runInfo = "从线体 [" + EmptyShelfPlace + "]送往" + EmptyShelfTargetPlace;
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
if (!EmptyShelfTargetPlace.Equals(""))
{
MissionSys.AssignMission(agv, EmptyShelfTargetPlace);
UpdateJobTaskInfo(agv);
}
}
else if (AGVManager.CheckShelfStorageInState(agv))
{
jobStep.ToNextStep(EMPTY_SHELF_BACK_STEP.WAIT_AGV_REACH_STANDBY);
runInfo = "云仓暂不需要空料架,从线体[" + EmptyShelfPlace + "]到料架缓存处";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.A2);
UpdateJobTaskInfo(agv);
}
else
{
jobStep.ToNextStep(EMPTY_SHELF_BACK_STEP.WAIT_AGV_REACH_STANDBY);
runInfo = "云仓和料架缓存处均不需要空料架,从线体[" + EmptyShelfPlace + "]到待机位";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Standby);
UpdateJobTaskInfo(agv);
}
}
else if (jobStep.IsStep(EMPTY_SHELF_BACK_STEP.WAIT_AGV_REACH_STANDBY))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (AGVManager.CheckNeedEmptyShelf(agv, out string nodeName))
{
EmptyShelfTargetPlace = nodeName;
jobStep.ToNextStep(EMPTY_SHELF_BACK_STEP.WAIT_AGV_REACH_Target);
runInfo = "待机位检测到"+ EmptyShelfTargetPlace + "需要料架,送往 " + EmptyShelfTargetPlace;
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, EmptyShelfTargetPlace);
UpdateJobTaskInfo(agv);
}
}
else if (jobStep.IsStep(EMPTY_SHELF_BACK_STEP.WAIT_AGV_REACH_Target))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, EmptyShelfTargetPlace, CurTaskState))
{
jobStep.ToNextStep(EMPTY_SHELF_BACK_STEP.WAIT_DOUBLE_LINE_RESPONSE);
runInfo = "AGV到达 " + EmptyShelfTargetPlace + ",并发送入料架请求[ReadyEnter]";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
AGVManager.server.ReadyEnter(EmptyShelfTargetPlace);
}
}
else if (jobStep.IsStep(EMPTY_SHELF_BACK_STEP.WAIT_DOUBLE_LINE_RESPONSE))
{
int id = AGVManager.FindNode(EmptyShelfTargetPlace);
ClientNode node = AGVManager.nodeInfo[id];
if (node.StateEquals(eNodeStatus.MayEnter))
{
if (!agv.CurTarName.Equals(SettingString.Leave))
{
jobStep.ToNextStep(EMPTY_SHELF_BACK_STEP.WAIT__EMPTY_SHELF_IN_LINE);
runInfo = "收到入料架请求[ReadyEnter]的响应 " + EmptyShelfTargetPlace + "入料架,小车链条运行";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Leave);
UpdateJobTaskInfo(agv);
}
}
else if (jobStep.IsTimeOut(15000, out double timeOutValue))
{
tryTimes++;
if (tryTimes < 3)
return this;
tryTimes = 0;
jobStep.ToNextStep(EMPTY_SHELF_BACK_STEP.WAIT_AGV_REACH_STANDBY);
runInfo = EmptyShelfTargetPlace + "暂不需要空料架,从[" + EmptyShelfTargetPlace + "]到待机位";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Standby);
UpdateJobTaskInfo(agv);
}
}
else if (jobStep.IsStep(EMPTY_SHELF_BACK_STEP.WAIT__EMPTY_SHELF_IN_LINE))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.Leave, CurTaskState))
{
AGVManager.SetNodeOccupy(EmptyShelfTargetPlace,LineState.None);
agv.RFID = "";
Job job = AGVManager.control.GetJob(agv);
if (job != null)
{
runInfo = "检测到新任务,开始执行";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
return job;
}
else
{
runInfo = "空料架进入" + EmptyShelfTargetPlace + "完成,暂无任务,回充电位";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
agv.RFID = "";
agv.BoxDestInfo = "";
return new ChargeJob(EmptyShelfTargetPlace);
}
}
else if (jobStep.IsTimeOut(60000, out double timeOutValue))
{
runInfo = "空料架在[" + EmptyShelfTargetPlace + "]离开小车超时[" + timeOutValue.ToString("f1") + "秒],请检查料架离开小车的情况";
}
}
else if (jobStep.IsStep(EMPTY_SHELF_BACK_STEP.END))
{
}
return this;
}
/// <summary>
/// AGV载空料架回收流程
/// </summary>
private enum EMPTY_SHELF_BACK_STEP
{
/// <summary>
/// 料架已进入小车,寻找目的地
/// </summary>
NONE,
/// <summary>
/// 等待小车到达目的地
/// </summary>
WAIT_AGV_REACH_Target,
/// <summary>
/// 等待双层线回应
/// </summary>
WAIT_DOUBLE_LINE_RESPONSE,
/// <summary>
/// 等待料架进入线体
/// </summary>
WAIT__EMPTY_SHELF_IN_LINE,
/// <summary>
/// A5,A6暂时不需要,等待AGV到达待机位
/// </summary>
WAIT_AGV_REACH_STANDBY,
/// <summary>
/// 送上双层线
/// </summary>
END
}
}
}
using Common;
namespace DeviceLibrary
{
/// <summary>
/// 小车进出料类型
/// </summary>
public enum eEnterLeaveType
{
/// <summary>
/// 小车进料
/// </summary>
Enter,
/// <summary>
/// 小车出料
/// </summary>
Leave,
}
/// <summary>
/// 进出料任务
/// </summary>
public class EnterLeaveShelfJob : Job
{
/// <summary>
/// 进出料任务
/// </summary>
/// <param name="palce">位置点名称</param>
/// <param name="rfid">RFID</param>
public EnterLeaveShelfJob(string palce, eEnterLeaveType type,eShelfType shelfType= eShelfType.SmallShelf,string rfid="")
{
LineName = palce;
RFID = rfid;
ActionType = type;
this.shelfType = shelfType;
}
/// <summary>
/// 位置名
/// </summary>
public new string LineName { get; set; }
public string RFID { get; set; }
public eEnterLeaveType ActionType { get; set; }
private eShelfType shelfType;
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return runInfo; }
}
private JobStep<ENTER_LEAVE_SHELF_STEP> jobStep = new JobStep<ENTER_LEAVE_SHELF_STEP>(ENTER_LEAVE_SHELF_STEP.NONE);
public override Job Execute(Agv_Info agv)
{
string msg = string.Format("{0} 进出料: ", agv.Name, shelfType.ToString());
//bool rtn = false;
//if (!CurTaskID.Equals(-1) && Common.mir.Get_Task_State(CurTaskID, out string st))
// CurTaskState = st;
if (jobStep.IsStep(ENTER_LEAVE_SHELF_STEP.NONE))
{
if (ActionType.Equals(eEnterLeaveType.Leave))
{
//EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT_LINE_ReadyEnter_RESPONSE);
//msg = "AGV到达 " + LineName + ",并发送入料架请求[ReadyEnter]";
//EnterLeaveShelfStep.Msg = msg;
//Common.server.ReadyEnter(LineName);
jobStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_IN_LINE);
runInfo = LineName + "入料架,小车链条运行";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Leave);
UpdateJobTaskInfo(agv);
}
else if(ActionType.Equals(eEnterLeaveType.Enter))
{
//EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT_LINE_ReadyLeave_RESPONSE);
//msg = "AGV到达 " + LineName + ",并发送出料架请求[ReadyLeave]";
//EnterLeaveShelfStep.Msg = msg;
//Common.server.ReadyLeave(LineName);
jobStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_OUT_LINE);
runInfo = LineName + "出料架,小车链条运行";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Enter);
UpdateJobTaskInfo(agv);
}
}
else if (jobStep.IsStep(ENTER_LEAVE_SHELF_STEP.WAIT_LINE_ReadyEnter_RESPONSE))
{
int id = AGVManager.FindNode(LineName);
ClientNode node = AGVManager.nodeInfo[id];
if (node.StateEquals(eNodeStatus.MayEnter))
{
jobStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_IN_LINE);
runInfo= "收到产线入料架请求[ReadyEnter]的响应, " + LineName + "入料架,小车链条运行";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Leave);
UpdateJobTaskInfo(agv);
}
else if (jobStep.IsTimeOut(15000, out double timeOutValue))
{
jobStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.NONE);
runInfo = "AGV到达 " + LineName + ",15秒后重新向产线发送入料架请求[ReadyEnter]";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
}
}
else if (jobStep.IsStep(ENTER_LEAVE_SHELF_STEP.WAIT_LINE_ReadyLeave_RESPONSE))
{
int id = AGVManager.FindNode(LineName);
ClientNode node = AGVManager.nodeInfo[id];
if (node.StateEquals(eNodeStatus.MayLeave))
{
jobStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_OUT_LINE);
runInfo= "收到产线出料架请求[ReadyLeave]的响应, " + LineName + "出料架,小车链条运行";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Enter);
UpdateJobTaskInfo(agv);
}
else if (jobStep.IsTimeOut(15000, out double timeOutValue))
{
jobStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.NONE);
runInfo= "AGV到达 " + LineName + ",15秒后重新向产线发送入料架请求[ReadyLeave]";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
}
}
else if (jobStep.IsStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_IN_LINE))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv,SettingString.Leave, CurTaskState))
{
//EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.END);
runInfo= "料架进入" + LineName + "完成 [" + RFID + "]";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
agv.RFID = "";
return new EmptyAGVBackJob(LineName);
}
else if (jobStep.IsTimeOut(60000, out double timeOutValue))
{
//链条停止
runInfo= "料架在[" + LineName + "]离开小车超时[" + timeOutValue.ToString("f1") + "秒],请检查料架离开小车的情况";
//msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
//EnterLeaveShelfStep.Msg = msg;
}
}
else if (jobStep.IsStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_OUT_LINE))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.Enter, CurTaskState))
{
//EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.END);
runInfo = "料架在" + LineName + "出去完成 [" + RFID + "]";
msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
jobStep.Msg = msg;
AGVManager.unlockManager.DelMission(LineName,RFID);
return new EmptyShelfBackJob(LineName,eShelfType.BigShelf);
}
else if (jobStep.IsTimeOut(60000, out double timeOutValue))
{
//链条停止
runInfo= "料架在[" + LineName + "]进入小车超时[" + timeOutValue.ToString("f1") + "秒],请检查料架进入小车的情况";
//msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
//EnterLeaveShelfStep.Msg = msg;
}
}
else if (jobStep.IsStep(ENTER_LEAVE_SHELF_STEP.END))
{
}
return this;
}
}
/// <summary>
/// AGV进出料
/// </summary>
public enum ENTER_LEAVE_SHELF_STEP
{
/// <summary>
///
/// </summary>
NONE,
/// <summary>
/// 等待产线ReadyEnter回应
/// </summary>
WAIT_LINE_ReadyEnter_RESPONSE,
/// <summary>
/// 等待产线ReadyLeave回应
/// </summary>
WAIT_LINE_ReadyLeave_RESPONSE,
/// <summary>
/// 等待料架离开产线
/// </summary>
WAIT__SHELF_OUT_LINE,
/// <summary>
/// 等待料架进入产线
/// </summary>
WAIT__SHELF_IN_LINE,
/// <summary>
/// 进入/离开完成
/// </summary>
END
}
}
using Common;
namespace DeviceLibrary
{
/// <summary>
/// 去空料架任务点
/// </summary>
public class GoEmptyShelfLineJob : Job
{
/// <summary>
/// 去空料架任务点
/// </summary>
/// <param name="agvPlae">小车当前位置,空表示在待机位</param>
/// <param name="palce">空料架位置点</param>
public GoEmptyShelfLineJob(string agvPlae, string palce, string rfid)
{
EmptyShelfPlace = palce;
this.agvPlae = agvPlae;
RFID = rfid;
}
public string RFID { get; set; }
/// <summary>
/// 空料架位置点
/// </summary>
public string EmptyShelfPlace { get; set; }
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlae { get; set; }
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return string.Format("取空料架[RFID={0}][{1}]:{2}", RFID, CurTaskID, runInfo); }
}
private JobStep<TAKE_EMPTY_STEP> jobStep = new JobStep<TAKE_EMPTY_STEP>(TAKE_EMPTY_STEP.NONE);
/// <summary>
/// 空架任务执行,去目的地
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = string.Format("{0} 取空料架[RFID={1}]: ", agv.Name, RFID);
//bool rtn = false;
int nodeIdx = AGVManager.FindNode(EmptyShelfPlace);
if (jobStep.IsStep(TAKE_EMPTY_STEP.NONE))
{
jobStep.ToNextStep(TAKE_EMPTY_STEP.ASSIGN_AGV_TASK);
runInfo = "开始任务[" + agvPlae + "->" + EmptyShelfPlace + "]" + "[RFID=" + RFID + "]";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
}
else if (jobStep.IsStep(TAKE_EMPTY_STEP.ASSIGN_AGV_TASK))
{
if (nodeIdx > -1)
{
jobStep.ToNextStep(TAKE_EMPTY_STEP.WAIT_AGV_START_TASK);
runInfo = "AGV 添加任务:移动到" + EmptyShelfPlace + "[RFID=" + RFID + "]";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, EmptyShelfPlace);
UpdateJobTaskInfo(agv);
}
else
{
jobStep.ToNextStep(TAKE_EMPTY_STEP.ASSIGN_AGV_TASK);
runInfo = EmptyShelfPlace + " 不存在或未开启调用";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
}
}
else if (jobStep.IsStep(TAKE_EMPTY_STEP.WAIT_AGV_START_TASK))
{
if (agv.CurTaskState.Equals(SettingString.Executing))
{
jobStep.ToNextStep(TAKE_EMPTY_STEP.WAIT_REACH_PLACE);
runInfo = "AGV开始向目的地[" + EmptyShelfPlace + "]移动" + "[RFID=" + RFID + "]";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
}
}
else if (jobStep.IsStep(TAKE_EMPTY_STEP.WAIT_REACH_PLACE))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, EmptyShelfPlace, CurTaskState))
{
{
jobStep.ToNextStep(TAKE_EMPTY_STEP.WAIT_LINE_RESPONSE);
runInfo = "AGV到达 " + EmptyShelfPlace + " 向产线发送出料架请求[ReadyLeave]" + "[RFID=" + RFID + "]";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
if (nodeIdx == -1)
{
runInfo = EmptyShelfPlace + " 未开启调用";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
return this;
}
ClientNode node = AGVManager.nodeInfo[nodeIdx];
agv.RFID = node.RFID;
AGVManager.server.ReadyLeave(EmptyShelfPlace);
}
}
}
else if (jobStep.IsStep(TAKE_EMPTY_STEP.WAIT_LINE_RESPONSE))
{
if (nodeIdx == -1)
{
runInfo = EmptyShelfPlace + " 未开启调用";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
return this;
}
ClientNode node = AGVManager.nodeInfo[nodeIdx];
agv.RFID = node.RFID;
if (node.StateEquals(eNodeStatus.MayLeave))
{
if (!agv.CurTarName.Equals("Enter"))
{
jobStep.ToNextStep(TAKE_EMPTY_STEP.WAIT_TAKE_EMPTY_SHELF);
runInfo = "收到产线出料请求[ReadyLeave]的响应 " + EmptyShelfPlace + "出料架,小车链条运行" + "[RFID=" + RFID + "]";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
//agv.RFID = node.RFID;
MissionSys.AssignMission(agv, SettingString.Enter);
UpdateJobTaskInfo(agv);
}
}
else if (jobStep.IsTimeOut(15000, out double timeOutValue))
{
jobStep.ToNextStep(TAKE_EMPTY_STEP.WAIT_REACH_PLACE);
}
}
else if (jobStep.IsStep(TAKE_EMPTY_STEP.WAIT_TAKE_EMPTY_SHELF))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.Enter, CurTaskState))
{
ClientNode node = AGVManager.nodeInfo[nodeIdx];
runInfo = "空料架在[" + EmptyShelfPlace + "]进入小车完成" + "[RFID=" + RFID + "]";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
return new EmptyShelfBackJob(EmptyShelfPlace, eShelfType.SmallShelf);
}
else if (jobStep.IsTimeOut(60000, out double timeOutValue))
{
//链条停止
runInfo = "空料架在[" + EmptyShelfPlace + "]进入小车超时[" + timeOutValue.ToString("f1") + "秒],请检查料架进入小车的情况" + "[RFID=" + RFID + "]";
}
}
else if (jobStep.IsStep(TAKE_EMPTY_STEP.END))
{
}
return this;
}
/// <summary>
/// AGV回收空料架流程
/// </summary>
private enum TAKE_EMPTY_STEP
{
/// <summary>
/// 准备,发送给AGV
/// </summary>
NONE,
/// <summary>
/// 给AGV分配任务
/// </summary>
ASSIGN_AGV_TASK,
/// <summary>
/// 等待AGV开始执行去取架点任务
/// </summary>
WAIT_AGV_START_TASK,
/// <summary>
/// 等待AGV到达取架点
/// </summary>
WAIT_REACH_PLACE,
/// <summary>
/// 等待AGV到达临时停车位
/// </summary>
WAIT_REACH_TEMP_PLACE,
/// <summary>
/// 等待产线回应
/// </summary>
WAIT_LINE_RESPONSE,
/// <summary>
/// 等待料架进入小车
/// </summary>
WAIT_TAKE_EMPTY_SHELF,
/// <summary>
/// 料架进入小车完成
/// </summary>
END
}
}
}
using Common;
namespace DeviceLibrary
{
/// <summary>
/// 检查AGV是否有负载,去A6入料口并装车
/// </summary>
public class GoFullShelfStationJob : Job
{
/// <summary>
/// 去云仓出料口任务
/// </summary>
/// <param name="agvCurPlace">接到任务时,AGV的位置(空表示待机位)</param>
/// <param name="palce"></param>
public GoFullShelfStationJob(string palce,string agvCurPlace = SettingString.Standby)
{
FullShelfStationPlace = palce;
agvPlace = agvCurPlace;
}
/// <summary>
/// 出满料位置点
/// </summary>
public string FullShelfStationPlace { get; set; }
/// <summary>
/// 接到任务时,AGV的位置
/// </summary>
public string agvPlace { get; set; }
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return string.Format("接满料任务[{0}]:{1}", CurTaskID, runInfo); }
}
/// <summary>
/// AGV上是否有负载
/// </summary>
public bool IsLoadOnAGV { get; private set; } = false;
public HttpManager.BoxDestInfo FullShelfDestInfo = null;
private JobStep<GO_FULL_SHELF_STATION_STEP> jobStep = new JobStep<GO_FULL_SHELF_STATION_STEP>(GO_FULL_SHELF_STATION_STEP.NONE);
public override Job Execute(Agv_Info agv)
{
string msg = string.Format("{0} 接满料任务: ", agv.Name);
//bool rtn = false;
if (jobStep.IsStep(GO_FULL_SHELF_STATION_STEP.NONE))
{
jobStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_CHECK_RESULT);
runInfo = "检查AGV负载";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.CheckShelf);
UpdateJobTaskInfo(agv);
}
else if (jobStep.IsStep(GO_FULL_SHELF_STATION_STEP.WAIT_CHECK_RESULT))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.CheckShelf, CurTaskState))
{
if (agv.IsExistShelf)
{
jobStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.END);
runInfo = "车上有料架,无法去云仓接满料";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
IsLoadOnAGV = true;
}
else if (!agv.IsExistShelf)
{
//if (agvPlace.Equals("") || agvPlace.Equals(SettingString.Standby) || agvPlace.StartsWith(SettingString.AutoCharge))//待机位/充电位接到任务
{
jobStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_AGV_REACH_SMD);
runInfo = "无负载,去云仓接满料" + FullShelfStationPlace;
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, FullShelfStationPlace);
UpdateJobTaskInfo(agv);
}
}
}
}
else if (jobStep.IsStep(GO_FULL_SHELF_STATION_STEP.WAIT_AGV_REACH_SMD))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, FullShelfStationPlace, CurTaskState))
{
//if (HttpManager.FindFullShelfTarget(node.RFID, out FullShelfDestInfo))
//{
// jobStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_DOUBLE_LINE_RESPONSE);
// if (FullShelfDestInfo != null)
// {
// AGVManager.GetLineNameByNodeName(FullShelfDestInfo.location, out string line);
// agv.BoxDestInfo = FullShelfDestInfo.ShowInfo(line);
// }
// runInfo = "AGV到达 " + FullShelfStationPlace + ",并发送出料架请求[ReadyLeave]";
// msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
// jobStep.Msg = msg;
// AGVManager.server.ReadyLeave(FullShelfStationPlace);
//}
//else
//{
// if (FullShelfDestInfo != null)
// {
// AGVManager.GetLineNameByNodeName(FullShelfDestInfo.location, out string line);
// runInfo = "AGV到达 " + FullShelfStationPlace + ",查询满料架目的地:" + FullShelfDestInfo.ShowInfo(line);
// msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo); ;
// jobStep.Msg = msg;
// }
// else
// {
// //[{"msg":"0料车已解绑或未发新料"}]
// jobStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_REACH_STANDBY);
// runInfo = "从产线" + agvPlace + "回到待机位";
// msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
// jobStep.Msg = msg;
// MissionSys.AssignMission(agv, SettingString.Standby);
// UpdateJobTaskInfo(agv);
// }
//}
}
}
else if (jobStep.IsStep(GO_FULL_SHELF_STATION_STEP.WAIT_REACH_STANDBY))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.Standby, CurTaskState))
{
jobStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.END);
runInfo = "到达待机位";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
}
}
else if (jobStep.IsStep(GO_FULL_SHELF_STATION_STEP.WAIT_DOUBLE_LINE_RESPONSE))
{
int id = AGVManager.FindNode(FullShelfStationPlace);
if (id == -1)
{
runInfo = "未找到节点:" + FullShelfStationPlace;
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
return this;
}
ClientNode node = AGVManager.nodeInfo[id];
if (node.StateEquals(eNodeStatus.MayLeave))
{
if (!agv.CurTarName.Equals("Enter"))
{
jobStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT__FULL_SHELF_IN_AGV);
runInfo = "收到双层线出料架请求[ReadyLeave]的响应 " + FullShelfStationPlace + "出料架,小车链条运行";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv,SettingString.Enter);
UpdateJobTaskInfo(agv);
}
}
else if (jobStep.IsTimeOut(15000, out double timeOutValue))
{
jobStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_AGV_REACH_SMD);
}
}
else if (jobStep.IsStep(GO_FULL_SHELF_STATION_STEP.WAIT__FULL_SHELF_IN_AGV))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.Enter, CurTaskState))
{
//GoFullShelfStationStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.END);
runInfo = FullShelfStationPlace + "满料架进入小车完成";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
return new SendFullShelfToLineJob(FullShelfDestInfo);
}
else if (jobStep.IsTimeOut(60000, out double timeOutValue))
{
//链条停止
runInfo = "满料架在[" + FullShelfStationPlace + "]进入小车超时[" + timeOutValue.ToString("f1") + "秒],请检查料架进入小车的情况";
//msg +=runInfo;
//GoFullShelfStationStep.Msg = msg;
}
}
return this;
}
}
/// <summary>
/// 出满料步骤
/// </summary>
public enum GO_FULL_SHELF_STATION_STEP
{
/// <summary>
/// 负载检查
/// </summary>
NONE,
/// <summary>
/// 负载检查结果
/// </summary>
WAIT_CHECK_RESULT,
/// <summary>
/// 等待到达云仓
/// </summary>
WAIT_AGV_REACH_SMD,
/// <summary>
/// 等待双层线回应
/// </summary>
WAIT_DOUBLE_LINE_RESPONSE,
/// <summary>
/// 等待料架进入小车
/// </summary>
WAIT__FULL_SHELF_IN_AGV,
/// <summary>
/// 等待AGV到达待机位
/// </summary>
WAIT_REACH_STANDBY,
/// <summary>
/// 送上双层线
/// </summary>
END
}
}
using Common;
namespace DeviceLibrary
{
/// <summary>
/// 从云仓向产线运行任务(出满料)
/// </summary>
public class SendFullShelfToLineJob : Job
{
/// <summary>
/// 从A6向产线运行任务(出满料)
/// </summary>
/// <param name="palce">产线名</param>
/// <param name="rfid">料架RFID</param>
/// <param name="isIgNoreBigShelf">是否忽略大料架</param>
public SendFullShelfToLineJob(HttpManager.BoxDestInfo boxDestInfo, bool isIgNoreBigShelf = false)
{
FullShelfPlace = boxDestInfo.location;
RFID = boxDestInfo.id;
BoxDestInfo = boxDestInfo;
IsIgnoreBigShelf = isIgNoreBigShelf;
}
/// <summary>
/// 满料架目标位置点
/// </summary>
public string FullShelfPlace { get; set; }
public string RFID { get; set; }
public HttpManager.BoxDestInfo BoxDestInfo { get; private set; }
/// <summary>
/// 是否忽略大料架移库解绑
/// </summary>
public bool IsIgnoreBigShelf { get; private set; }
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return string.Format("送满料任务[RFID={0}][{1}]:{2}", RFID, CurTaskID, runInfo); }
}
private JobStep<SEND_FULL_SHELF_STEP> jobStep = new JobStep<SEND_FULL_SHELF_STEP>(SEND_FULL_SHELF_STEP.NONE);
public override Job Execute(Agv_Info agv)
{
string msg = string.Format("{0} 送满料任务[RFID={1}]: ", agv.Name, RFID);
//bool rtn = false;
agv.RFID = RFID;
if (jobStep.IsStep(SEND_FULL_SHELF_STEP.NONE))
{
HttpManager.AgvRemoveRfid(RFID);
jobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE);
runInfo = "从云仓送往[" + FullShelfPlace + "]";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
MissionSys.AssignMission(agv, FullShelfPlace);
UpdateJobTaskInfo(agv);
}
else if (jobStep.IsStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE))
{
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, FullShelfPlace, CurTaskState))
{
jobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_BIG_SHELF_UNLOCK);
runInfo = "AGV到达 " + FullShelfPlace + ",等待人员操作";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
}
}
else if (jobStep.IsStep(SEND_FULL_SHELF_STEP.WAIT_BIG_SHELF_UNLOCK))
{
MiR_API.Get_IO_Status(agv, out bool[] input, out bool[] output);
System.Threading.Thread.Sleep(500);
if ((input != null && input[0]))
{
runInfo = "人员在" + FullShelfPlace + "卸料完成";
msg += string.Format("[{0}] {1}", jobStep.CurStep(), runInfo);
jobStep.Msg = msg;
return new EmptyShelfBackJob(FullShelfPlace, eShelfType.SmallShelf);
}
}
return this;
}
}
/// <summary>
/// AGV送满料架到产线
/// </summary>
public enum SEND_FULL_SHELF_STEP
{
/// <summary>
/// 料架已进入小车,去目的地
/// </summary>
NONE,
/// <summary>
/// 等待小车到达目的地
/// </summary>
WAIT_AGV_REACH_LINE,
/// <summary>
/// 等待大料架解绑
/// </summary>
WAIT_BIG_SHELF_UNLOCK,
/// <summary>
/// 进入产线完成
/// </summary>
END
}
}
using Common;
namespace DeviceLibrary
{
/// <summary>
/// 待机任务
/// </summary>
public class StandyJob : Job
{
/// <summary>
/// 出完满料后-空车返回任务
/// </summary>
/// <param name="agvPlae">小车当前位置,空表示在待机位</param>
public StandyJob(string agvPlae)
{
this.agvPlace = agvPlae;
}
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlace = "";
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return string.Format("待机任务[{0}][{1}]:{2}", CurTaskID, CurTaskState, runInfo); }
}
private JobStep<EXECUTE_STEP> curJobStep = new JobStep<EXECUTE_STEP>(EXECUTE_STEP.NONE);
/// <summary>
/// 空车返回执行
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = "";
CurTaskState = MissionSys.GetTakJobState(agv);
if (curJobStep.IsStep(EXECUTE_STEP.NONE))
{
if (agvPlace.Equals(SettingString.Standby))//在待机位不操作
{
curJobStep.ToNextStep(EXECUTE_STEP.END);
runInfo = "在待机位,不执行操作";
msg += runInfo;
curJobStep.Msg = msg;
}
else if (agvPlace.StartsWith(SettingString.RoomC_Name_Prefix))
{
curJobStep.ToNextStep(EXECUTE_STEP.WAIT_AGV_REACH_4D_DOOR);
runInfo = "从当前位置" + agvPlace + "回到待机位,先到"+SettingString.RoomD_Name+"门";
msg += runInfo;
curJobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv);
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.WAIT_REACH_STANDBY);
runInfo = "从当前位置" + agvPlace + "回到待机位";
msg += runInfo;
curJobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Standby);
UpdateJobTaskInfo(agv);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.WAIT_AGV_REACH_4D_DOOR))
{
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorCToD, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.WAIT_REACH_STANDBY);
runInfo = "从"+SettingString.RoomD_Name+"门回到待机位";
msg += runInfo;
curJobStep.Msg = msg;
MissionSys.AssignMission(agv, SettingString.Standby);
UpdateJobTaskInfo(agv);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.WAIT_REACH_STANDBY))
{
if (MissionSys.CheckTaskFinished(agv, SettingString.Standby, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.END);
runInfo = "到达待机位";
msg += runInfo;
curJobStep.Msg = msg;
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.END))
{
Job job = AGVManager.control.GetJob(agv);
if (job != null && !(job is StandyJob))
{
runInfo = "在待机位检测到任务,执行任务";
msg += runInfo;
curJobStep.Msg = msg;
return job;
}
}
return this;
}
/// <summary>
/// 执行流程
/// </summary>
private enum EXECUTE_STEP
{
/// <summary>
///
/// </summary>
NONE,
/// <summary>
/// 等待到达4D门
/// </summary>
WAIT_AGV_REACH_4D_DOOR,
/// <summary>
/// 等待到达待机位
/// </summary>
WAIT_REACH_STANDBY,
/// <summary>
///
/// </summary>
END
}
}
}

namespace DeviceLibrary
{
/// <summary>
/// 待机任务
/// </summary>
public class ChargeJobType : JobType
{
/// <summary>
/// 待机任务
/// </summary>
/// <param name="currentAgv"></param>
/// <returns></returns>
public override Job GetNewJob(Agv_Info currentAgv)
{
//if (currentAgv.Battery < AGVManager.Charge.BatteryMax - 10 && AGVManager.Charge.HasEmptyChargeStation(currentAgv))
{
return new ChargeJob(currentAgv.Place);
}
//else
//{
// return new StandyJob(currentAgv.Place);
//}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common;
namespace DeviceLibrary
{
/// <summary>
/// 云仓需要空料架
/// </summary>
public class GetEmptyShelfJobType : JobType
{
/// <summary>
/// 云仓需要空料架任务
/// </summary>
/// <param name="agv"></param>
/// <returns></returns>
public override Job GetNewJob(Agv_Info agv)
{
if (!AGVManager.CheckCanExecuteMission(agv))
return null;
if (!AGVManager.CheckAGVStatusNone(agv))
return null;
string nodename = "";
//查找料仓口是否需要料架
if (AGVManager.CheckBoxNeedShelfState(agv, out nodename))
{
if (AGVManager.CheckShelfStorageOutState(agv))
{
AGVManager.SetNodeOccupy(nodename,LineState.Busy);
return new GoEmptyShelfLineJob(agv.Place, SettingString.A1, "");
}
}
return null;
}
}
}

using Common;
using System.Collections.Generic;
using System.Linq;
namespace DeviceLibrary
{
/// <summary>
/// 出满料任务检查
/// </summary>
public class SendFullShelfJobType : JobType
{
/// <summary>
/// 双层线任务
/// </summary>
/// <param name="currentAgv"></param>
/// <returns></returns>
public override Job GetNewJob(Agv_Info currentAgv)
{
if (!AGVManager.CheckCanExecuteMission(currentAgv))
return null;
if (!AGVManager.CheckAGVStatusNone(currentAgv))
return null;
//查看云仓出料口情况
return null;
}
}
}
using System.Drawing;
namespace DeviceLibrary
{
/// <summary>
/// 客户端的节点
/// </summary>
public class ClientNode : Node
{
private string rfid = "00";
/// <summary>
/// RFID
/// </summary>
public string RFID
{
set
{
if (value.Length < 2)
rfid = value.PadLeft(2, '0');
else
rfid = value;
}
get
{
return rfid;
}
}
/// <summary>
/// 线体名(佳世达)
/// </summary>
public string LineName { set; get; }
public ClientLevel ClientLevel { get; set; } = ClientLevel.Low;
/// <summary>
/// 节点状态(AGV占用情况)
/// </summary>
public LineState State = LineState.None;
public string AliceName { get; set; }
/// <summary>
/// 客户端节点
/// </summary>
/// <param name="name"></param>
/// <param name="ip"></param>
/// <param name="isUse"></param>
public ClientNode(string lineName, string name, string ip, string aliceName, bool isUse) : base(name, ip, isUse)
{
AliceName = aliceName;
RFID = rfid;
Online = false;
IsUse = isUse;
LineName = lineName;
}
public string WarnMsg { get; set; } = "";
/// <summary>
/// 客户端节点
/// </summary>
/// <param name="name"></param>
/// <param name="rfid"></param>
/// <param name="action"></param>
/// <param name="level"></param>
public ClientNode(string name, string rfid = "", eNodeStatus status = eNodeStatus.None) : base(name)
{
RFID = rfid;
nodeStatus = status;
}
/// <summary>
/// 节点状态的文本形式
/// </summary>
/// <returns></returns>
public string StatetText()
{
string s = string.Format("[Name={0}, NodeStatus={1}, RFID={2},ClientLevel ={3}]", Name, nodeStatus.ToString(), RFID, ClientLevel.ToString());
return s;
}
public string[] ToRow()
{
//节点,IP,动作,RFID,AGV名称,在线,调用,清除AGV
string[] s = new string[8];
s[0] = AliceName;
s[1] = IP;
// if (Online)
// {
s[2] = nodeStatus.ToString();
s[3] = State.ToString();
s[4] = RFID;
// s[5] = AgvName;
// }
s[5] = Online ? "在线" : "离线";
s[6] = IsUse ? "是" : "否";
// s[8] = "清除";
return s;
}
/// <summary>
/// 脱机
/// </summary>
public void Offline()
{
RFID = "00";
nodeStatus = eNodeStatus.None;
Online = false;
}
}
}
此文件类型无法预览
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Common;
using static DeviceLibrary.Agv_Info;
namespace DeviceLibrary
{
public enum LineState
{
None,
Busy
}
public static class AGVManager
{
static log4net.ILog log = log4net.LogManager.GetLogger("AGVManager");
/// <summary>
/// 节点信息
/// </summary>
public static List<ClientNode> nodeInfo;
/// <summary>
/// 小车信息
/// </summary>
public static List<Agv_Info> agvInfo;
public static AgvServer server;
public static Control control;
//public static WebService web;
//public static UnlockMissionManager unlockManager;
public static ChargeManager Charge;
//public static StandbyManager Standby;
public static List<JobType> jobTypes;
public static readonly string CONFIG_PATH = AppDomain.CurrentDomain.BaseDirectory + "Config\\";
/// <summary>
/// 初始化配置
/// </summary>
public static void Init()
{
string path;
string[] line;
string[] temp;
bool isuse;
string rfid = "";
Charge = new ChargeManager();
//Standby = new StandbyManager();
agvInfo = new List<Agv_Info>();
jobTypes = new List<JobType>();
jobTypes.Add(new GetEmptyShelfJobType());
jobTypes.Add(new SendFullShelfJobType());
jobTypes.Add(new ChargeJobType());
path = CONFIG_PATH + SettingString.FileName_AGV;
line = File.ReadAllLines(path, Encoding.UTF8);
for (int i = 1; i < line.Length; i++)
{
temp = line[i].Split(',');
if (temp.Length != 5) continue;
bool.TryParse(ReadIni(temp[1], SettingString.IsUse), out isuse);
rfid = ReadIni(temp[1], SettingString.RFID);
agvInfo.Add(new Agv_Info(temp[0], temp[1], temp[2], temp[3], temp[4], isuse, rfid));
}
//任务加载
MissionSys.Init();
//节点加载
nodeInfo = new List<ClientNode>();
path = CONFIG_PATH + SettingString.FileName_AgvProductionLine;
line = System.IO.File.ReadAllLines(path, Encoding.GetEncoding("gb2312"));
for (int i = 1; i < line.Length; i++)
{
temp = line[i].Split(',');
if (temp.Length != 4) continue;
Boolean.TryParse(ReadIni(temp[1], SettingString.IsUse), out bool isUse);
nodeInfo.Add(new ClientNode(temp[0], temp[1], temp[2], temp[3], isUse));
}
}
/// <summary>
/// 读取配置
/// </summary>
/// <param name="section"></param>
/// <param name="key"></param>
/// <returns></returns>
public static string ReadIni(string section, string key)
{
return IniFileHelper.ReadValue(section, key, CONFIG_PATH + SettingString.FileName_tempData);
}
/// <summary>
/// 写入配置
/// </summary>
/// <param name="section"></param>
/// <param name="key"></param>
/// <param name="value"></param>
public static void WriteIni(string section, string key, string value)
{
IniFileHelper.WriteValue(section, key, value, CONFIG_PATH + SettingString.FileName_tempData);
}
/// <summary>
/// 根据线体名获取节点名
/// </summary>
/// <param name="lineName"></param>
/// <param name="nodeName"></param>
/// <returns></returns>
public static bool GetNodeNameByLineName(string lineName, out string nodeName)
{
nodeName = "";
int id = nodeInfo.FindIndex(s => s.LineName.Equals(lineName));
if (id > -1)
{
nodeName = nodeInfo[id].Name;
return true;
}
else
{
return false;
}
}
/// <summary>
/// 根据节点名获取线体名
/// </summary>
/// <param name="nodeName"></param>
/// <param name="lineName"></param>
/// <returns></returns>
public static bool GetLineNameByNodeName(string nodeName, out string lineName)
{
lineName = "";
int id = nodeInfo.FindIndex(s => s.Name.Equals(nodeName));
if (id > -1)
{
lineName = nodeInfo[id].LineName;
return true;
}
else
{
return false;
}
}
/// <summary>
/// 查找节点是否存在以及是否调用
/// </summary>
/// <param name="nodeName">节点名称</param>
/// <returns>-1:不存在/未调用</returns>
public static int FindNode(string nodeName)
{
int idx = nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.IsUse);
return idx;
}
/// <summary>
/// 设置节点的状态占用
/// </summary>
/// <param name="nodeName"></param>
/// <param name="state"></param>
public static void SetNodeOccupy(string nodeName,LineState state)
{
int i = nodeInfo.FindIndex(s=>s.Name.Equals(nodeName));
if(i>-1)
{
if (nodeInfo[i].State.Equals(state))
return;
nodeInfo[i].State = state;
log.Debug(string.Format("设置{0}的占用状态为{1}", nodeName, state));
}
}
private static object checkLocObj = new object();
/// <summary>
/// 查看云仓需要料架的状况
/// </summary>
/// <param name="agv"></param>
/// <param name="node"></param>
public static bool CheckBoxNeedShelfState(Agv_Info agv, out string nodeName)
{
nodeName = "";
if (Monitor.TryEnter(checkLocObj))
{
try
{
int tarIdx = nodeInfo.FindIndex(s => s.Name == SettingString.D1 && s.StateEquals(eNodeStatus.NeedEnter) && s.IsUse);
if (tarIdx > -1)
{
if (!CheckLineBusy(SettingString.D1))
{
nodeName = SettingString.D1;
log.Debug(string.Format("{0} {1}需要料架", agv.Name, SettingString.D1));
return true;
}
}
tarIdx = nodeInfo.FindIndex(s => s.Name == SettingString.D2 && s.StateEquals(eNodeStatus.NeedEnter) && s.IsUse);
if (tarIdx > -1)
{
if (!CheckLineBusy(SettingString.D2))
{
nodeName = SettingString.D2;
log.Debug(string.Format("{0} {1}需要料架", agv.Name, SettingString.D2));
return true;
}
}
tarIdx = nodeInfo.FindIndex(s => s.Name == SettingString.D3 && s.StateEquals(eNodeStatus.NeedEnter) && s.IsUse);
if (tarIdx > -1)
{
if (!CheckLineBusy(SettingString.D3))
{
nodeName = SettingString.D3;
log.Debug(string.Format("{0} {1}需要料架", agv.Name, SettingString.D3));
return true;
}
}
}
catch (Exception ex)
{
log.Error("CheckBoxNeedShelfState", ex);
}
finally
{
Monitor.Exit(checkLocObj);
}
}
return false;
}
/// <summary>
/// 检查云仓出料口是否被agv占用
/// </summary>
/// <param name="nodeName"></param>
/// <returns></returns>
public static bool CheckLineBusy(string nodeName)
{
int i = nodeInfo.FindIndex(s=>s.Name.Equals(nodeName));
if (i>-1 && nodeInfo[i].State.Equals(LineState.Busy))
return true;
return false;
}
/// <summary>
/// 查看料架存放处是否可以放空料架
/// </summary>
/// <param name="agv"></param>
/// <param name="node"></param>
public static bool CheckShelfStorageInState(Agv_Info agv)
{
int tarIdx = nodeInfo.FindIndex(s => s.Name == SettingString.A2
&& (s.StateEquals(eNodeStatus.NeedEnter)) && s.IsUse);
if (tarIdx > -1)
{
log.Debug(string.Format("{0} {1}可以存放料架", agv.Name, SettingString.A2));
return true;
}
return false;
}
/// <summary>
/// 检查需要空料架的地方
/// </summary>
/// <param name="agv"></param>
/// <param name="nodeName"></param>
/// <returns></returns>
public static bool CheckNeedEmptyShelf(Agv_Info agv,out string nodeName)
{
if(!CheckBoxNeedShelfState(agv,out nodeName))
{
if(CheckShelfStorageInState(agv))
{
nodeName = SettingString.A2;
return true;
}
}
return false;
}
/// <summary>
/// 存放空料架出口是否有空料架
/// </summary>
/// <param name="agv"></param>
/// <param name="node"></param>
public static bool CheckShelfStorageOutState(Agv_Info agv)
{
int tarIdx = nodeInfo.FindIndex(s => s.Name == SettingString.A1
&& (s.StateEquals(eNodeStatus.NeedEnter)) && s.IsUse);
if (tarIdx > -1)
{
log.Debug(string.Format("{0} {1}可以出料架", agv.Name, SettingString.A1));
return true;
}
return false;
}
//双层线工单信息
public static string doubleLine_WO = "";
public static string warnMsg = "";
/// <summary>
/// 查找出满料架任务
/// </summary>
/// <returns></returns>
//public static bool FindFullShelfTask(Agv_Info agv)
//{
// if (!CheckCanExecuteMission(agv))
// return false;
// int idx = nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A6)
// && (s.StateEquals(eNodeStatus.NeedEnterLeave) || (s.StateEquals(eNodeStatus.NeedLeave))) && !s.RFID.Equals(""));
// if (idx > -1)
// {
// if (HttpManager.FindFullShelfTarget(nodeInfo[idx].RFID, out HttpManager.BoxDestInfo FullShelfDestInfo))
// {
// if (FullShelfDestInfo.location.StartsWith(SettingString.RoomC_Name_Prefix) && SettingString.RoomC_AGV_IPs.Contains(agv.IP))
// {
// int i = agvInfo.FindIndex(s => s.CurJob is GoFullShelfStationJob && !s.IP.Equals(agv.IP));
// if (i == -1)
// return true;
// }
// else if (FullShelfDestInfo.location.StartsWith(SettingString.RoomS_Name_Prefix) && !SettingString.RoomC_AGV_IPs.Contains(agv.IP))
// {
// int i = agvInfo.FindIndex(s => s.CurJob is SendFullShelfToLineJob && !s.IP.Equals(agv.IP)
// && ((SendFullShelfToLineJob)s.CurJob).FullShelfPlace.Equals(FullShelfDestInfo.location));
// if (i > -1)
// return false;
// i = agvInfo.FindIndex(s => s.CurJob is GoFullShelfStationJob && !s.IP.Equals(agv.IP));
// if (i == -1)
// return true;
// }
// }
// else
// {
// if (FullShelfDestInfo != null)
// {
// log.Error("A6的出料信息不正确,请检查:" + FullShelfDestInfo.ShowInfo("ERROR"));
// }
// }
// }
// return false;
//}
/// <summary>
/// 判断电量是否够执行任务
/// </summary>
/// <param name="agv"></param>
/// <returns></returns>
public static bool CheckCanExecuteMission(Agv_Info agv)
{
if (agv.Battery <= Charge.BatteryMin)
{
log.Debug(agv.Name + " 电量小于" + Charge.BatteryMin + "%,不执行任务");
return false;
}
return true;
}
/// <summary>
/// 判断小车是否能接任务
/// </summary>
/// <param name="agv"></param>
/// <returns></returns>
public static bool CheckAGVStatusNone(Agv_Info agv)
{
if ((agv.CurJob == null || agv.CurJob is ChargeJob) && !agv.IsExistShelf)
return true;
else
return false;
}
}
public static class Window_API
{
[DllImport("user32.dll", EntryPoint = "ShowWindow", CharSet = CharSet.Auto)]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("user32.dll ", SetLastError = true)]
public static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab);
public const int SW_RESTORE = 9;
}
}
\ No newline at end of file \ No newline at end of file
using Common;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Drawing;
namespace DeviceLibrary
{
public class HttpManager
{
private static log4net.ILog log = log4net.LogManager.GetLogger("HttpManager");
public static string A6_Target = "";
/// <summary>
/// 查找满料架目的地
/// </summary>
/// <param name="rfid"></param>
/// <param name="dest"></param>
/// <returns></returns>
public static bool FindFullShelfTarget(string rfid, out BoxDestInfo dest)
{
dest = null;
A6_Target = "";
try
{
if (rfid.Equals("") || rfid.Equals("00"))
return false;
string itsHttp = "http://ESMTCommonInterface/CommonService.asmx/VMIGetBoxDestInfo?boxRFID=";
string url = itsHttp + rfid;
var client = new RestClient(url) { Timeout = -1 };
var request = new RestRequest(Method.GET);
//request.AddHeader("Host", "10.85.17.233");
IRestResponse response = client.Execute(request);
string json = response.Content;
json = json.Replace("\r", "");
json = json.Replace("\n", "");
json = json.Replace(" ", "");
log.Debug("ITS URL: " + url + " Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
List<BoxDestInfo> res = JsonHelper.DeserializeJsonToList<BoxDestInfo>(json);
//JavaScriptSerializer serializer = new JavaScriptSerializer();
if (res == null || res.Count == 0)
return false;
string tempLocation = res[0].location;
if (res[0].id == rfid)
{
if (res[0].location.Equals("3DFeeder"))
{
tempLocation = "3DFeederIn";
}
else if (res[0].location.Equals("3CFeeder"))
{
tempLocation = "3CFeederIn";
}
if (AGVManager.GetNodeNameByLineName(tempLocation, out string loc))
{
int i = AGVManager.FindNode(loc);
if (i > -1)
{
#region 检查是否有空料架要出,有则先出空料架
//foreach (var item in Common.missionManager.missionList)
//{
// if (loc.Equals(item.NodeName))
// {
// Common.LogInfo("节点[" + loc + "]当前有空架任务,延迟A6出满料架任务[" + rfid + "]", false);
// return false;
// }
//}
//if (Common.nodeInfo[i].AgvName.Equals("").Equals(false))//有小车在目标任务点(限制4C车间),等待结束后再接任务
//{
// Common.LogInfo("节点[" + loc + "]当前有任务,延迟A6出满料架任务[" + rfid + "]", false);
// return false;
//}
//检查是否有车接到满料架任务,有则不再重复分配
//int id = Common.agvInfo.FindIndex(s => s.RFID == rfid);
//if (id > -1)
//{
// Common.LogInfo(Common.agvInfo[i].Name + " 正在执行满料架任务:目的地为 " + loc + " [产线名 " + res[0].location + "],不可重复分配小车");
// return false;
//}
#endregion
res[0].location = loc;
dest = res[0];
AGVManager.GetLineNameByNodeName(loc, out string line);
A6_Target = res[0].ShowInfo(line);
log.Debug("查找满料架任务[RFID=" + rfid + "]:目的地为 " + loc + " [产线名 " + line + "]");
return true;
}
else
{
log.Warn("节点[" + loc + "]不存在或者未开启调用");
return false;
}
}
}
//[{"msg":"0料车已解绑或未发新料"}]
A6_Target = json;
return false;
}
catch (Exception ex)
{
log.Error("FindA6Destination", ex);
return false;
}
}
public class BoxDestInfo
{
/// <summary>
/// RFID
/// </summary>
public string id { get; set; }
public string SO { get; set; }
public string location { get; set; }
public string ShowInfo(string loc)
{
return string.Format("RFID={0},SO={1},location={2}[{3}]", id, SO, loc, location);
}
}
public static string GetRackBy(string rfid)
{
//GET /ESMTCommonInterface/CommonService.asmx/GetRackBy?id=string HTTP/1.1
//Host: 10.85.17.233
string addr = "http://10.85.71.25/ESMTCommonInterface/CommonService.asmx/GetRackBy?id=" + rfid;
//[{"msg":"1OKD1"}]
//[{"msg":"0NGFeeder"}]
try
{
string result = HttpHelper.Get(addr);
if (!result.Equals(""))
{
List<Msg> msgs = JsonHelper.DeserializeJsonToList<Msg>(result);
if (msgs == null || msgs.Count == 0)
return "";
return result;
}
}
catch (Exception ex)
{
log.Error(ex.Message);
return "";
}
return "";
}
/// <summary>
/// 大料架接口回复
/// </summary>
public class Msg
{
public string msg { get; set; }
}
private static string Addr_updateDeviceAlarmMsg = "/rest/api/qisda/device/updateDeviceAlarmMsg";
/// <summary>
/// 异常看板
/// </summary>
/// <param name="msgList"></param>
/// <returns></returns>
public static string updateDeviceAlarmMsg(List<AlarmMsg> msgList)
{
string msg = "";
try
{
if (msgList.Count.Equals(0)) return "";
Dictionary<string, string> paramMap = new Dictionary<string, string>();
string msgListStr = JsonHelper.SerializeObject(msgList);
paramMap.Add("deviceAlarmList", msgListStr);
string server = GetAddr(Addr_updateDeviceAlarmMsg, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
msgList.ForEach(new Action<AlarmMsg>(k=>log.Debug("deviceAlarmList " + k.ToString())));
RfidData data = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr);
if (data == null)
{
return msg = " updateDeviceAlarmMsg 没有收到服务器反馈";
}
else if (data.code.Equals(0).Equals(false))
{
return msg = "【" + server + "】【" + resultStr + "】" + data.msg;
}
return "";
}
catch (Exception ex)
{
log.Error(ex);
}
return msg;
}
private static string GetAddr(string addr, Dictionary<string, string> paramsMap)
{
string server = AppConfigHelper.GetValue(SettingString.httpServer);
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;
}
/// <summary>
/// 获取接驳台料架情况
/// </summary>
/// <param name="lineName"></param>
/// <returns></returns>
//public static string GetRFIDs(string lineName)
//{
// string addr = "";
// if (lineName.StartsWith(SettingString.Line_Name_Prefix))
// {
// addr = string.Format("http://{0}/LineGetRFID?line={1}", AppConfigHelper.GetValue(SettingString.IP_3D_Light), lineName);
// }
// //else if (lineName.StartsWith(SettingString.RoomC_Name_Prefix))
// //{
// // addr = string.Format("http://{0}/LineGetRFID?line={1}", AppConfigHelper.GetValue(SettingString.IP_3C_Light), lineName);
// //}
// try
// {
// string result = HttpHelper.Get(addr);
// if (!result.Equals(""))
// {
// Msg1 msgs = JsonHelper.DeserializeJsonToObject<Msg1>(result);
// if (msgs == null)
// return ",,,";
// else
// {
// log.Debug(string.Format("{0}接驳台状态:{1}", lineName, msgs.Msg));
// return msgs.Msg;
// }
// }
// }
// catch (Exception ex)
// {
// log.Error(ex.Message);
// return ",,,";
// }
// return ",,,";
//}
/// <summary>
/// 删除接驳台料架
/// </summary>
/// <param name="lineName"></param>
/// <param name="rfid"></param>
/// <returns></returns>
//public static bool ClearRFID(string nodeName, string rfid)
//{
// string addr = "";
// string lineName = "";
// if (nodeName.StartsWith(SettingString.RoomS_Name_Prefix) && AGVManager.GetLineNameByNodeName(nodeName, out lineName))
// {
// addr = string.Format("http://{0}/LineClearRFID?line={1}&rfid={2}", AppConfigHelper.GetValue(SettingString.IP_3D_Light), lineName, rfid);
// }
// else if (nodeName.StartsWith(SettingString.RoomC_Name_Prefix) && AGVManager.GetLineNameByNodeName(nodeName, out lineName))
// {
// addr = string.Format("http://{0}/LineClearRFID?line={1}&rfid={2}", AppConfigHelper.GetValue(SettingString.IP_3C_Light), lineName, rfid);
// }
// try
// {
// string result = HttpHelper.Get(addr);
// if (!result.Equals(""))
// {
// Msg1 msgs = JsonHelper.DeserializeJsonToObject<Msg1>(result);
// if (msgs == null)
// return false;
// else
// {
// log.Info(string.Format("删除{0}接驳台料架{1}:{2}", lineName, rfid, msgs.Msg));
// return true;
// }
// }
// }
// catch (Exception ex)
// {
// log.Error(ex.Message);
// return false;
// }
// return false;
//}
private static string Addr_agvRemoveRfid = "/rest/api/qisda/device/agvRemoveRfid";
/// <summary>
/// 根据RFID清理料架的缓存信息
/// </summary>
/// <param name="rfid"></param>
/// <returns></returns>
public static bool AgvRemoveRfid(string rfid)
{
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("rfid", rfid.ToUpper());
string server = GetAddr(Addr_agvRemoveRfid, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Get(server);
log.Info("清理料架的缓存信息【" + server + "】【" + resultStr + "】");
RfidData rfidData = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr);
if (rfidData == null)
{
return false;
}
else
{
if (rfidData.code.Equals(0))
{
return true;
}
}
}
catch (Exception ex)
{
log.Error(ex);
return false;
}
return false;
}
}
public class AlarmMsg
{
//>>>name : 异常位置名称
public string name = "";
//>>>msgKey : 异常信息唯一标识
public string msgKey = "";
//>>>msgValue : 异常信息
public string msgValue = "";
//0:异常;1:正常显示
public int type = 0;
/// <summary>
/// 异常信息
/// </summary>
/// <param name="name">异常位置名称</param>
/// <param name="key">异常信息唯一标识</param>
/// <param name="value">异常信息</param>
public AlarmMsg(string name, string key, string value, int type = 0)
{
this.name = name;
this.msgKey = key;
this.msgValue = value;
this.type = type;
}
public override string ToString()
{
return string.Format("[name:{0},msgKey:{1},msgValue:{2},type:{3}]", name, msgKey, msgValue, type);
}
}
public class RfidData
{
//{"code":0,"msg":"ok","data":"7"}
public int code { get; set; }
public string msg { get; set; }
public Dictionary<string, string> data { get; set; }
}
}
using System.ServiceModel;
using System.ServiceModel.Web;
using System.ServiceModel.Activation;
using System;
using System.IO;
using System.Runtime.Serialization;
using Common;
namespace DeviceLibrary
{
[ServiceContract(Name = "Services")]
internal interface IWebService
{
[OperationContract]
[WebInvoke(UriTemplate = "CreateEmptyRecycleTask", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Xml)]
string CreateEmptyRecycleTask(Stream stream);//string line
//?emptyStation={line}
[OperationContract]
[WebInvoke(UriTemplate = "CreateEmptyRecycleTask?emptyStation={line}&rfid={RFID}", Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Xml)]
string CreateEmptyRecycleTaskGET(string line, string RFID = "");
}
[DataContract]
internal class Result
{
[DataMember]
public bool Succeed { get; set; }
[DataMember]
public string ResultData { get; set; }
[DataMember]
public string ErrorMessage { get; set; }
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single, IncludeExceptionDetailInFaults = true)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
internal class ClsWebService : IWebService
{
static log4net.ILog Log = log4net.LogManager.GetLogger("LineWebService");
internal ClsWebService()
{
}
public string CreateEmptyRecycleTask(Stream stream)
{
Result res;
StreamReader sr = new StreamReader(stream);
string s = sr.ReadToEnd();
System.Collections.Specialized.NameValueCollection nvc = System.Web.HttpUtility.ParseQueryString(s);
string emptyStation = nvc["emptyStation"];
string rfid = nvc["rfid"];
if (emptyStation == null)
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "emptyStation =null " };
else
{
if (emptyStation.Equals("3DFeeder"))
{
emptyStation = "3DFeederOut";
}
else if (emptyStation.Equals("3CFeeder"))
{
emptyStation = "3CFeederOut";
}
if (AGVManager.GetNodeNameByLineName(emptyStation, out string value))
{
if (rfid == null)
{
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "rfid=null" };
Log.Error(string.Format("Unlock Request(POST) Failed [emptyStation={0},rfid=null]", emptyStation));
}
else
{
res = new Result() { Succeed = true, ResultData = rfid, ErrorMessage = "" };
Log.Debug(string.Format("Unlock Request(POST) [emptyStation={0},rfid={1}]", emptyStation, rfid.ToUpper()));
if (!AGVManager.unlockManager.AddMission(value, rfid.ToUpper()))
{
if(rfid.Equals(""))
{
Log.Error(string.Format("添加空架任务失败 节点[{0}] RFID=null", value));
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "CreateEmptyRecycleTask failed: emptyStation=" + emptyStation + " rfid=" + rfid };
}
else
{
Log.Error(string.Format("添加空架任务失败 节点[{0}]RFID={1} 重复", value,rfid.ToUpper()));
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "CreateEmptyRecycleTask failed due it has been created: emptyStation=" + emptyStation + " rfid=" + rfid};
}
}
else
Log.Info("任务[POST]:" + value + " 出空料架 [location=" + emptyStation + ",rfid=" + rfid.ToUpper() + "]");
}
// AGVControl.Common.log.Debug("WebService POST Response OK");
}
else
{
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "Not find " + emptyStation };
Log.Error("Unlock POST Response false:" + "Not find " + emptyStation);
}
}
return JsonHelper.SerializeObject(res);
}
public string CreateEmptyRecycleTaskGET(string line, string RFID)
{
Result res;
if (line.Equals("3DFeeder"))
{
line = "3DFeederOut";
}
else if (line.Equals("3CFeeder"))
{
line = "3CFeederOut";
}
if (AGVManager.GetNodeNameByLineName(line, out string value))
{
Log.Debug(string.Format("Unlock Request(GET) [emptyStation={0},rfid={1}]", line, RFID.ToUpper()));
if (!AGVManager.unlockManager.AddMission(value,RFID.ToUpper()))
{
Log.Error(string.Format("添加空架任务失败 节点[{0}]RFID={1} 重复", value, RFID.ToUpper()));
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "CreateEmptyRecycleTask failed due it has been created: emptyStation=" + line + " rfid=" + RFID };
}
else
{
res = new Result() { Succeed = true, ResultData = RFID, ErrorMessage = "" };
Log.Info("任务[GET]:" + value + " 出空料架 [emptyStation=" + line + ",rfid=" + RFID.ToUpper() + "]");
}
}
else
{
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "Not find " + line };
Log.Error("Unlock GET Response false " + "Not find " + line);
}
//Log.Info(string.Format("WebService GET Request emptyStation={0},rfid={1}", line, RFID));
return JsonHelper.SerializeObject(res);
}
}
public class WebService
{
private WebServiceHost _serviceHost;
public void Open(string url)
{
try
{
ClsWebService service = new ClsWebService();
_serviceHost = new WebServiceHost(service, new Uri(url));//service, new Uri(url)
_serviceHost.Open();
LogUtil.info("Web服务已开启");
}
catch (Exception ex)
{
LogUtil.error("Web服务开启", ex);
}
}
public void Close()
{
try
{
if (_serviceHost != null)//判断服务是否关闭
_serviceHost.Close();//关闭服务
LogUtil.info("Web服务已关闭");
}
catch (Exception ex)
{
LogUtil.error("Web服务关闭", ex);
}
}
}
}
using Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
/// <summary>
///解绑料架任务管理
/// </summary>
public class UnlockMissionManager
{
public delegate void MissionChangedHandler(Dictionary<string, UnlockInfo> pairs);
public event MissionChangedHandler MissionChanged;
/// <summary>
/// 任务列表
/// </summary>
public Dictionary<string, UnlockedShelf> NodeUnlockMissions { get; private set; }
Dictionary<string, UnlockInfo> UnlockMissions;
public UnlockMissionManager(List<ClientNode> clientNodes)
{
NodeUnlockMissions = new Dictionary<string, UnlockedShelf>();
UnlockMissions = new Dictionary<string, UnlockInfo>();
foreach (ClientNode item in clientNodes)
{
if (item.Name.StartsWith("A") || item.Name.Equals(SettingString.RoomCFeederIn) || item.Name.Equals(SettingString.RoomDFeederIn))
continue;
NodeUnlockMissions.Add(item.Name, new UnlockedShelf());
UnlockMissions = new Dictionary<string, UnlockInfo>();
}
}
public UnlockMissionManager()
{
NodeUnlockMissions = new Dictionary<string, UnlockedShelf>();
UnlockMissions = new Dictionary<string, UnlockInfo>();
}
public void Init()
{
foreach (var item in NodeUnlockMissions.Keys)
{
UnlockMissions.Add(item, new UnlockInfo(item, NodeUnlockMissions[item].EmptyCnt, NodeUnlockMissions[item].GetRfidWithTime()));
}
MissionChanged?.Invoke(UnlockMissions);
}
public UnlockedShelf GetUnlockInfo(string nodeName)
{
if (NodeUnlockMissions.ContainsKey(nodeName))
{
return NodeUnlockMissions[nodeName];
}
return null;
}
public int GetUnlockCnt(string nodeName)
{
if (NodeUnlockMissions.ContainsKey(nodeName))
{
return NodeUnlockMissions[nodeName].EmptyCnt;
}
return -1;
}
public List<string> GetUnlockRfids(string nodeName)
{
if (NodeUnlockMissions.ContainsKey(nodeName))
{
return NodeUnlockMissions[nodeName].GetRfids();
}
return new List<string>();
}
public bool AddMission(string nodeName, string rfid)
{
bool rtn = NodeUnlockMissions[nodeName].Add(rfid);
if (rtn)
{
UnlockMissions[nodeName] = new UnlockInfo(nodeName, NodeUnlockMissions[nodeName].EmptyCnt, NodeUnlockMissions[nodeName].GetRfidWithTime());
WriteUnlockLineInfo();
AGVManager.WriteIni(nodeName, SettingString.EmptyShelfCnt, NodeUnlockMissions[nodeName].EmptyCnt.ToString());
LogUtil.info(string.Format("{0}解绑任务添加成功:RFID={1}", nodeName, rfid));
MissionChanged?.Invoke(UnlockMissions);
}
else
LogUtil.info(string.Format("{0}解绑任务添加失败:RFID={1}", nodeName, rfid));
return rtn;
}
public bool DelMission(string nodeName, string rfid)
{
bool rtn = NodeUnlockMissions[nodeName].Delete(rfid, nodeName);
if (rtn)
{
UnlockMissions[nodeName] = new UnlockInfo(nodeName, NodeUnlockMissions[nodeName].EmptyCnt, NodeUnlockMissions[nodeName].GetRfidWithTime());
WriteUnlockLineInfo();
AGVManager.WriteIni(nodeName, SettingString.EmptyShelfCnt, NodeUnlockMissions[nodeName].EmptyCnt.ToString());
LogUtil.info(string.Format("{0}解绑任务删除成功:RFID={1}", nodeName, rfid));
MissionChanged?.Invoke(UnlockMissions);
}
else
LogUtil.info(string.Format("{0}解绑任务删除失败:RFID={1}", nodeName, rfid));
return rtn;
}
/// <summary>
/// 保存料架解绑信息
/// </summary>
void WriteUnlockLineInfo()
{
using (System.IO.StreamWriter file = new System.IO.StreamWriter(AGVManager.CONFIG_PATH + "UnlockInfo.json"))
{
string s = JsonHelper.SerializeObject(this);
file.WriteLine(s);
}
}
}
public class UnlockInfo
{
public string Line { get; set; }
public int Count { get; set; }
public string RFID { get; set; }
public List<UnlockRfid> UnlockRfids { get; private set; }
public UnlockInfo(string nodeName, int count, Dictionary<string, string> rfids)
{
if (AGVManager.GetLineNameByNodeName(nodeName, out string line))
{
Line = line;
}
else
{
Line = nodeName;
}
Count = count;
RFID = string.Join(",", rfids.Keys);
UnlockRfids = new List<UnlockRfid>();
foreach (var item in rfids.Keys)
{
UnlockRfids.Add(new UnlockRfid(nodeName, rfids[item], item));
}
}
}
public class UnlockRfid
{
public String Line { get; set; }
public string RFID { get; set; }
public string Time { get; set; }
public UnlockRfid(string line, string time, string rfid)
{
Time = time;
RFID = rfid;
Line = line;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common;
namespace DeviceLibrary
{
public class UnlockedShelf
{
/// <summary>
/// 已解绑料架信息
/// </summary>
/// <param name="nodeName"></param>
public UnlockedShelf()
{
Rfids = new Dictionary<string, string>();
}
/// <summary>
/// 空料架数量
/// </summary>
public int EmptyCnt { get; set; }
/// <summary>
/// 解绑的RFID及时间
/// </summary>
public Dictionary<string, string> Rfids { get; set; }
public List<string> GetRfids()
{
if (Rfids == null || Rfids.Count <= 0)
return new List<string>();
return Rfids.Keys.ToList<string>();
}
public Dictionary<string, string> GetRfidWithTime()
{
if (Rfids == null || Rfids.Count <= 0)
return new Dictionary<string, string>();
return Rfids;
}
/// <summary>
///添加解绑的空料架,如果RFID相同,不增加数量
/// </summary>
public bool Add(string rfid)
{
if (!rfid.Equals("") && !Rfids.Keys.Contains(rfid))
{
if (EmptyCnt < 0)
{
EmptyCnt = 0;
if (Rfids.Count > 0)
Rfids.Clear();
}
int tmp = EmptyCnt;
System.Threading.Interlocked.Increment(ref tmp);
EmptyCnt = tmp;
Rfids.Add(rfid, DateTime.Now.ToString("MM/dd/HH:mm:ss,fff"));
return true;
}
return false;
}
/// <summary>
/// 删除一个解绑任务
/// </summary>
public bool Delete(string rfid, string nodeName = "")
{
if (EmptyCnt > 0)
{
if (!rfid.Equals("") && Rfids.Keys.Contains(rfid))
{
int tmp = EmptyCnt;
System.Threading.Interlocked.Decrement(ref tmp);
EmptyCnt = tmp;
if (EmptyCnt.Equals(0) && Rfids.Count > 0)
{
Rfids.Clear();
}
if (nodeName.Equals(SettingString.RoomCFeederOut) || rfid.Equals(SettingString.RoomDFeederOut))
Rfids.Remove(rfid);
return true;
}
}
else if (Rfids.Count > 0)
{
EmptyCnt = 0;
Rfids.Clear();
return true;
}
return false;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C6D2FC09-46F7-4EC5-A877-15EA06342E4F}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>AGV_UI</RootNamespace>
<AssemblyName>AGV_UI</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Status.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Status.Designer.cs">
<DependentUpon>Status.cs</DependentUpon>
</Compile>
<Compile Include="Manager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Status.resx">
<DependentUpon>Status.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="battery\charge.png" />
<None Include="state\Unknown.png" />
<None Include="state\ready.png" />
<None Include="state\pause.png" />
<None Include="state\manual.png" />
<None Include="state\Executing.png" />
<None Include="state\Error.png" />
<None Include="state\emergency.png" />
<None Include="state\Aborted.png" />
<None Include="task.png" />
<None Include="online.png" />
<None Include="battery\full.png" />
<None Include="battery\common.png" />
<None Include="battery\low.png" />
<None Include="offline.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<appSettings>
<add key="Port_AGV_Server" value="9501"/>
<add key="http.server" value="http://10.85.162.124/myproject/"/>
<add key="FLEET" value="10.85.19.3"/>
<add key="UseFleet" value="False"/>
<add key="ChargeThreshold" value="20,90"/>
</appSettings>
<log4net>
<appender name="AgvServer" type="log4net.Appender.RollingFileAppender">
<file value="logs/AgvServer.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<param name="MaxSizeRollBackups" value="30"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/>
</layout>
</appender>
<appender name="HttpManager" type="log4net.Appender.RollingFileAppender">
<file value="logs/HttpManager.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<param name="MaxSizeRollBackups" value="30"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/>
</layout>
</appender>
<appender name="AGV_3D_Line" type="log4net.Appender.RollingFileAppender">
<file value="logs/AGV_3D_Line.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][%c:%L]%-5p %m%n"/>
</layout>
</appender>
<appender name="LineWebService" type="log4net.Appender.RollingFileAppender">
<file value="logs/UnlockInfo.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<param name="MaxSizeRollBackups" value="30"/>
<!-- 切割最多文件数 -->
<param name="MaximumFileSize" value="50MB"/>
<!-- 每个文件的大小 -->
<param name="RollingStyle" value="Size"/>
<!--param name="StaticLogFileName" value="true"/-->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date]%-5p %m%n"/>
</layout>
</appender>
<logger name="LineWebService">
<level value="Info"/>
<appender-ref ref="LineWebService"/>
</logger>
<logger name="AgvServer">
<level value="Info"/>
<appender-ref ref="AgvServer"/>
</logger>
<logger name="HttpManager">
<level value="Info"/>
<appender-ref ref="HttpManager"/>
</logger>
<root name="AGV_3D_Line">
<level value="Info"/>
<appender-ref ref="AGV_3D_Line"/>
</root>
</log4net>
</configuration>
任务名称,任务别名,任务GUID
Init,初始化,219cd91a-61da-11eb-96a9-0001297a1dca
Standby,待机位,615cef05-61f4-11eb-96a9-0001297a1dca
AutoCharge1,充电桩4,b4a9e87a-7768-11eb-8758-54b2038d1924
AutoCharge2,充电桩5,c4326dfb-7768-11eb-8758-54b2038d1924
A5,双层线入口,4c533e85-75c6-11eb-a7fe-0001297a1dca
A6,双层线出口,3a0d8f1b-75c8-11eb-a7fe-0001297a1dca
D12,S12线,d2ee5b8e-75c5-11eb-a7fe-0001297a1dca
D11,S11线,968abc82-75c5-11eb-a7fe-0001297a1dca
D10,S10线,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
D9,S9线,ab97b4c1-75c4-11eb-a7fe-0001297a1dca
D8,S8线,103f9e10-75c4-11eb-a7fe-0001297a1dca
D7,S7线,d2943724-75c3-11eb-a7fe-0001297a1dca
D6,S6线,982fc7ed-75c3-11eb-a7fe-0001297a1dca
D5,S5线,5405c489-75c3-11eb-a7fe-0001297a1dca
D4,S4线,17287a21-75c3-11eb-a7fe-0001297a1dca
D3,S3线,1b074ace-75c2-11eb-a7fe-0001297a1dca
D2,S2线,1b074ace-75c2-11eb-a7fe-0001297a1dca
D1,S1线,1b074ace-75c2-11eb-a7fe-0001297a1dca
D21,备料区入口,060d5e35-75b0-11eb-8565-0001297a1dca
D22,备料区出口,fe89c587-75bf-11eb-a7fe-0001297a1dca
CheckShelf,检查负载情况,cc5f1d78-75a2-11eb-8565-0001297a1dca
Leave,出料,28a2ab7b-75ac-11eb-8565-0001297a1dca
Enter,进料,4bf5d4c5-75a4-11eb-8565-0001297a1dca
\ No newline at end of file \ No newline at end of file
Fleet ID,agv名称,IP,授权码,IOID
5,18号车,10.85.199.123,Basic ZGlzdHJpYnV0b3I6NjJmMmYwZjFlZmYxMGQzMTUyYzk1ZjZmMDU5NjU3NmU0ODJiYjhlNDQ4MDY0MzNmNGNmOTI5NzkyODM0YjAxNA==,5d084001-6155-11eb-bee4-0001297a2016
6,19号车,10.85.199.124,Basic ZGlzdHJpYnV0b3I6NjJmMmYwZjFlZmYxMGQzMTUyYzk1ZjZmMDU5NjU3NmU0ODJiYjhlNDQ4MDY0MzNmNGNmOTI5NzkyODM0YjAxNA==,5d084001-6155-11eb-bee4-0001297a2016
7,20号车,10.85.199.1138,Basic ZGlzdHJpYnV0b3I6NjJmMmYwZjFlZmYxMGQzMTUyYzk1ZjZmMDU5NjU3NmU0ODJiYjhlNDQ4MDY0MzNmNGNmOTI5NzkyODM0YjAxNA==,5d084001-6155-11eb-bee4-0001297a2016
产线名,节点名,IP,产线别名,位置名称,位置guid
A5,A5,10.85.197.167,双层线入口(A5),PA5,4c533e85-75c6-11eb-a7fe-0001297a1dca
A6,A6,10.85.197.167,双层线出(A6),PA6,3a0d8f1b-75c8-11eb-a7fe-0001297a1dca
S3,S3,10.85.197.151,S3线,DL3,1b074ace-75c2-11eb-a7fe-0001297a1dca
S4,S4,10.85.197.146,S4线,DL4,17287a21-75c3-11eb-a7fe-0001297a1dca
S5,S5,10.85.197.15,S5线,DL5,5405c489-75c3-11eb-a7fe-0001297a1dca
S6,S6,10.85.197.14,S6线,DL6,982fc7ed-75c3-11eb-a7fe-0001297a1dca
S7,S7,10.85.197.9,S7线,DL6,d2943724-75c3-11eb-a7fe-0001297a1dca
S8,S8,10.85.197.141,S8线,DL8,103f9e10-75c4-11eb-a7fe-0001297a1dca
S9,S9,10.85.197.8,S9线,DL9,ab97b4c1-75c4-11eb-a7fe-0001297a1dca
S10,S10,10.85.197.7,S10线,DL10,1d40c7c7-75c5-11eb-a7fe-0001297a1dca
S11,S11,10.85.197.131,S11线,DL11,968abc82-75c5-11eb-a7fe-0001297a1dca
S12,S12,10.85.197.6,S12线,DL12,d2ee5b8e-75c5-11eb-a7fe-0001297a1dca
3DFeederIn,S21,10.85.197.3,备料区入口,FI,060d5e35-75b0-11eb-8565-0001297a1dca
3DFeederOut,S22,10.85.197.3,备料区出口,FO,fe89c587-75bf-11eb-a7fe-0001297a1dca
文件属性发生变化
[18ų]
RFID=
[19ų]
RFID=
[20ų]
RFID=
namespace AGVControl
{
partial class FrmMain
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain));
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.lblWO = new System.Windows.Forms.Label();
this.tableLayoutPanel7 = new System.Windows.Forms.TableLayoutPanel();
this.lblWarn = new System.Windows.Forms.Label();
this.tableLayoutPanel6 = new System.Windows.Forms.TableLayoutPanel();
this.groupBox8 = new System.Windows.Forms.GroupBox();
this.lblCharge2 = new System.Windows.Forms.Label();
this.lblCharge1 = new System.Windows.Forms.Label();
this.DgvNode = new System.Windows.Forms.DataGridView();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.txtBoxLineName = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.txtBoxRFID = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.tabControlManual = new System.Windows.Forms.TabControl();
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column12 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column16 = new System.Windows.Forms.DataGridViewButtonColumn();
this.tableLayoutPanel3.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.tableLayoutPanel5.SuspendLayout();
this.groupBox3.SuspendLayout();
this.tableLayoutPanel7.SuspendLayout();
this.tableLayoutPanel6.SuspendLayout();
this.groupBox8.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.DgvNode)).BeginInit();
this.tabPage3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox2.SuspendLayout();
this.tableLayoutPanel4.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel3
//
this.tableLayoutPanel3.ColumnCount = 1;
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.Controls.Add(this.tabControl1, 0, 1);
this.tableLayoutPanel3.Controls.Add(this.tableLayoutPanel4, 0, 0);
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(2);
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.RowCount = 2;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 48.43538F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 51.56462F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel3.Size = new System.Drawing.Size(1215, 735);
this.tableLayoutPanel3.TabIndex = 7;
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(3, 359);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(1209, 373);
this.tabControl1.TabIndex = 7;
this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
//
// tabPage1
//
this.tabPage1.Controls.Add(this.tableLayoutPanel2);
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(1201, 347);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "节点状态&产线任务";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.ColumnCount = 2;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 56.39743F));
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 43.60257F));
this.tableLayoutPanel2.Controls.Add(this.groupBox1, 1, 0);
this.tableLayoutPanel2.Controls.Add(this.tableLayoutPanel6, 0, 0);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(2);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 1;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(1195, 341);
this.tableLayoutPanel2.TabIndex = 34;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.tableLayoutPanel5);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox1.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox1.Location = new System.Drawing.Point(675, 2);
this.groupBox1.Margin = new System.Windows.Forms.Padding(2);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(2);
this.groupBox1.Size = new System.Drawing.Size(518, 337);
this.groupBox1.TabIndex = 33;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "任务信息";
//
// tableLayoutPanel5
//
this.tableLayoutPanel5.ColumnCount = 1;
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel5.Controls.Add(this.groupBox3, 0, 0);
this.tableLayoutPanel5.Controls.Add(this.tableLayoutPanel7, 0, 1);
this.tableLayoutPanel5.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel5.Location = new System.Drawing.Point(2, 19);
this.tableLayoutPanel5.Margin = new System.Windows.Forms.Padding(2);
this.tableLayoutPanel5.Name = "tableLayoutPanel5";
this.tableLayoutPanel5.RowCount = 2;
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel5.Size = new System.Drawing.Size(514, 316);
this.tableLayoutPanel5.TabIndex = 2;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.lblWO);
this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox3.Location = new System.Drawing.Point(2, 2);
this.groupBox3.Margin = new System.Windows.Forms.Padding(2);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Padding = new System.Windows.Forms.Padding(2);
this.groupBox3.Size = new System.Drawing.Size(510, 154);
this.groupBox3.TabIndex = 0;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "云仓出料信息";
//
// lblWO
//
this.lblWO.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblWO.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblWO.Location = new System.Drawing.Point(2, 19);
this.lblWO.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblWO.Name = "lblWO";
this.lblWO.Size = new System.Drawing.Size(506, 133);
this.lblWO.TabIndex = 40;
this.lblWO.Text = "lblWO";
//
// tableLayoutPanel7
//
this.tableLayoutPanel7.ColumnCount = 1;
this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel7.Controls.Add(this.lblWarn, 0, 0);
this.tableLayoutPanel7.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel7.Location = new System.Drawing.Point(2, 160);
this.tableLayoutPanel7.Margin = new System.Windows.Forms.Padding(2);
this.tableLayoutPanel7.Name = "tableLayoutPanel7";
this.tableLayoutPanel7.RowCount = 1;
this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel7.Size = new System.Drawing.Size(510, 154);
this.tableLayoutPanel7.TabIndex = 3;
//
// lblWarn
//
this.lblWarn.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblWarn.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblWarn.ForeColor = System.Drawing.Color.Red;
this.lblWarn.Location = new System.Drawing.Point(2, 0);
this.lblWarn.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblWarn.Name = "lblWarn";
this.lblWarn.Size = new System.Drawing.Size(506, 154);
this.lblWarn.TabIndex = 41;
this.lblWarn.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// tableLayoutPanel6
//
this.tableLayoutPanel6.ColumnCount = 1;
this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel6.Controls.Add(this.groupBox8, 0, 1);
this.tableLayoutPanel6.Controls.Add(this.DgvNode, 0, 0);
this.tableLayoutPanel6.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel6.Name = "tableLayoutPanel6";
this.tableLayoutPanel6.RowCount = 2;
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 52.08333F));
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 47.91667F));
this.tableLayoutPanel6.Size = new System.Drawing.Size(667, 335);
this.tableLayoutPanel6.TabIndex = 34;
//
// groupBox8
//
this.groupBox8.Controls.Add(this.lblCharge2);
this.groupBox8.Controls.Add(this.lblCharge1);
this.groupBox8.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox8.Location = new System.Drawing.Point(2, 176);
this.groupBox8.Margin = new System.Windows.Forms.Padding(2);
this.groupBox8.Name = "groupBox8";
this.groupBox8.Padding = new System.Windows.Forms.Padding(2);
this.groupBox8.Size = new System.Drawing.Size(200, 53);
this.groupBox8.TabIndex = 7;
this.groupBox8.TabStop = false;
this.groupBox8.Text = "位置占用情况";
//
// lblCharge2
//
this.lblCharge2.AutoSize = true;
this.lblCharge2.Dock = System.Windows.Forms.DockStyle.Top;
this.lblCharge2.Location = new System.Drawing.Point(2, 28);
this.lblCharge2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblCharge2.Name = "lblCharge2";
this.lblCharge2.Size = new System.Drawing.Size(65, 12);
this.lblCharge2.TabIndex = 1;
this.lblCharge2.Text = "lblCharge2";
//
// lblCharge1
//
this.lblCharge1.AutoSize = true;
this.lblCharge1.Dock = System.Windows.Forms.DockStyle.Top;
this.lblCharge1.Location = new System.Drawing.Point(2, 16);
this.lblCharge1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblCharge1.Name = "lblCharge1";
this.lblCharge1.Size = new System.Drawing.Size(65, 12);
this.lblCharge1.TabIndex = 0;
this.lblCharge1.Text = "lblCharge1";
//
// DgvNode
//
this.DgvNode.AllowUserToAddRows = false;
this.DgvNode.AllowUserToDeleteRows = false;
this.DgvNode.AllowUserToResizeColumns = false;
this.DgvNode.AllowUserToResizeRows = false;
this.DgvNode.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.DgvNode.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.DgvNode.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.DgvNode.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column6,
this.Column12,
this.Column7,
this.Column10,
this.Column9,
this.Column5,
this.Column16});
this.DgvNode.Location = new System.Drawing.Point(3, 3);
this.DgvNode.MultiSelect = false;
this.DgvNode.Name = "DgvNode";
this.DgvNode.ReadOnly = true;
this.DgvNode.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
this.DgvNode.RowHeadersVisible = false;
this.DgvNode.RowHeadersWidth = 50;
this.DgvNode.RowTemplate.Height = 23;
this.DgvNode.Size = new System.Drawing.Size(661, 168);
this.DgvNode.TabIndex = 2;
this.DgvNode.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DgvNode_CellClick);
//
// tabPage3
//
this.tabPage3.Controls.Add(this.richTextBox1);
this.tabPage3.Controls.Add(this.groupBox4);
this.tabPage3.Controls.Add(this.groupBox2);
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(1201, 347);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "手动";
this.tabPage3.UseVisualStyleBackColor = true;
//
// richTextBox1
//
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBox1.Location = new System.Drawing.Point(3, 3);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(544, 341);
this.richTextBox1.TabIndex = 39;
this.richTextBox1.Text = "";
//
// groupBox4
//
this.groupBox4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.groupBox4.Controls.Add(this.txtBoxLineName);
this.groupBox4.Controls.Add(this.label8);
this.groupBox4.Controls.Add(this.label7);
this.groupBox4.Controls.Add(this.txtBoxRFID);
this.groupBox4.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBox4.Location = new System.Drawing.Point(547, 3);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(250, 341);
this.groupBox4.TabIndex = 38;
this.groupBox4.TabStop = false;
this.groupBox4.Text = " ";
//
// txtBoxLineName
//
this.txtBoxLineName.Location = new System.Drawing.Point(111, 54);
this.txtBoxLineName.Margin = new System.Windows.Forms.Padding(2);
this.txtBoxLineName.Name = "txtBoxLineName";
this.txtBoxLineName.Size = new System.Drawing.Size(111, 21);
this.txtBoxLineName.TabIndex = 44;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(60, 63);
this.label8.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(47, 12);
this.label8.TabIndex = 43;
this.label8.Text = "产线名:";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(62, 31);
this.label7.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(35, 12);
this.label7.TabIndex = 42;
this.label7.Text = "RFID:";
//
// txtBoxRFID
//
this.txtBoxRFID.Location = new System.Drawing.Point(111, 23);
this.txtBoxRFID.Margin = new System.Windows.Forms.Padding(2);
this.txtBoxRFID.Name = "txtBoxRFID";
this.txtBoxRFID.Size = new System.Drawing.Size(111, 21);
this.txtBoxRFID.TabIndex = 0;
//
// groupBox2
//
this.groupBox2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this.groupBox2.Controls.Add(this.tabControlManual);
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBox2.Location = new System.Drawing.Point(797, 3);
this.groupBox2.Margin = new System.Windows.Forms.Padding(2);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Padding = new System.Windows.Forms.Padding(2);
this.groupBox2.Size = new System.Drawing.Size(401, 341);
this.groupBox2.TabIndex = 32;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "小车操作";
//
// tabControlManual
//
this.tabControlManual.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControlManual.Location = new System.Drawing.Point(2, 16);
this.tabControlManual.Name = "tabControlManual";
this.tabControlManual.SelectedIndex = 0;
this.tabControlManual.Size = new System.Drawing.Size(397, 323);
this.tabControlManual.TabIndex = 0;
//
// tableLayoutPanel4
//
this.tableLayoutPanel4.ColumnCount = 1;
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel4.Controls.Add(this.flowLayoutPanel1, 0, 0);
this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel4.Location = new System.Drawing.Point(2, 2);
this.tableLayoutPanel4.Margin = new System.Windows.Forms.Padding(2);
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
this.tableLayoutPanel4.RowCount = 1;
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 352F));
this.tableLayoutPanel4.Size = new System.Drawing.Size(1211, 352);
this.tableLayoutPanel4.TabIndex = 8;
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 3);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(1205, 346);
this.flowLayoutPanel1.TabIndex = 0;
//
// Column6
//
this.Column6.FillWeight = 106.0331F;
this.Column6.HeaderText = "地点";
this.Column6.MinimumWidth = 6;
this.Column6.Name = "Column6";
this.Column6.ReadOnly = true;
this.Column6.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column12
//
this.Column12.FillWeight = 106.0331F;
this.Column12.HeaderText = "IP";
this.Column12.MinimumWidth = 6;
this.Column12.Name = "Column12";
this.Column12.ReadOnly = true;
this.Column12.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column7
//
this.Column7.FillWeight = 106.0331F;
this.Column7.HeaderText = "动作";
this.Column7.MinimumWidth = 6;
this.Column7.Name = "Column7";
this.Column7.ReadOnly = true;
this.Column7.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column10
//
this.Column10.FillWeight = 56.23853F;
this.Column10.HeaderText = "状态";
this.Column10.MinimumWidth = 6;
this.Column10.Name = "Column10";
this.Column10.ReadOnly = true;
//
// Column9
//
this.Column9.FillWeight = 106.0331F;
this.Column9.HeaderText = "RFID";
this.Column9.MinimumWidth = 6;
this.Column9.Name = "Column9";
this.Column9.ReadOnly = true;
this.Column9.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column5
//
this.Column5.FillWeight = 106.0331F;
this.Column5.HeaderText = "连接";
this.Column5.MinimumWidth = 6;
this.Column5.Name = "Column5";
this.Column5.ReadOnly = true;
this.Column5.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column16
//
this.Column16.FillWeight = 106.0331F;
this.Column16.HeaderText = "调用";
this.Column16.MinimumWidth = 6;
this.Column16.Name = "Column16";
this.Column16.ReadOnly = true;
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1215, 735);
this.Controls.Add(this.tableLayoutPanel3);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FrmMain";
this.Text = "AGV调度系统";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMain_FormClosing);
this.Load += new System.EventHandler(this.FrmMain_Load);
this.tableLayoutPanel3.ResumeLayout(false);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.tableLayoutPanel5.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.tableLayoutPanel7.ResumeLayout(false);
this.tableLayoutPanel6.ResumeLayout(false);
this.groupBox8.ResumeLayout(false);
this.groupBox8.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.DgvNode)).EndInit();
this.tabPage3.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.tableLayoutPanel4.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;
private System.Windows.Forms.Label lblWO;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel5;
private System.Windows.Forms.TextBox txtBoxRFID;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel7;
private System.Windows.Forms.TextBox txtBoxLineName;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label lblWarn;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.TabControl tabControlManual;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel6;
private System.Windows.Forms.GroupBox groupBox8;
private System.Windows.Forms.Label lblCharge2;
private System.Windows.Forms.Label lblCharge1;
private System.Windows.Forms.DataGridView DgvNode;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column6;
private System.Windows.Forms.DataGridViewTextBoxColumn Column12;
private System.Windows.Forms.DataGridViewTextBoxColumn Column7;
private System.Windows.Forms.DataGridViewTextBoxColumn Column10;
private System.Windows.Forms.DataGridViewTextBoxColumn Column9;
private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
private System.Windows.Forms.DataGridViewButtonColumn Column16;
}
}
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Common;
using DeviceLibrary;
namespace AGVControl
{
public partial class FrmMain : Form
{
private bool exit = false;
private NotifyIcon notify;
private ContextMenuStrip notifyMenu;
private System.Timers.Timer showTimer;
//private string[] agvRunStep;
public FrmMain()
{
InitializeComponent();
showTimer = new System.Timers.Timer();
showTimer.Interval = 5000;
//showTimer.Enabled = true;
showTimer.AutoReset = true;
showTimer.Elapsed += ShowTimer_Elapsed;
showTimer.Start();
LogUtil.logBox = richTextBox1;
}
private void ShowConfig()
{
int n;
//agvRunStep = new string[Common.agvInfo.Count];
for (int i = 0; i < AGVManager.agvInfo.Count; i++)
{
MiR_API.Get_IO_Status(AGVManager.agvInfo[i], out bool[] input, out bool[] output);
if (input != null && input.Length == 4)
AGVManager.agvInfo[i].IsExistShelf = input[3];
flowLayoutPanel1.Controls.Add(AGVManager.agvInfo[i].StateKanban);
AddForm(AGVManager.agvInfo[i].Name,new Manual(AGVManager.agvInfo[i]));
AGVManager.agvInfo[i].StateKanban.Init();
}
for (int i = 0; i < AGVManager.nodeInfo.Count; i++)
{
if (AGVManager.nodeInfo[i].IP.Trim().Equals(""))
continue;
n = DgvNode.Rows.Add(AGVManager.nodeInfo[i].ToRow());
DgvNode.Rows[n].HeaderCell.Value = (n + 1).ToString();
if (i % 2 == 0)
DgvNode.Rows[n].DefaultCellStyle.BackColor = Color.LightBlue;
if (!AGVManager.nodeInfo[i].Online)
DgvNode.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
}
}
private void Server_NodeChanged(int nodeIndex)
{
Invoke(new Action(() =>
{
DgvNode.Rows[nodeIndex].DefaultCellStyle.ForeColor = AGVManager.nodeInfo[nodeIndex].Online && AGVManager.nodeInfo[nodeIndex].IsUse ? Color.Black : Color.Red;
DgvNode.Rows[nodeIndex].SetValues(AGVManager.nodeInfo[nodeIndex].ToRow());
}));
System.GC.Collect();
}
private void Server_NodeOnline(int nodeIndex)
{
Invoke(new Action(() =>
{
DgvNode.Rows[nodeIndex].DefaultCellStyle.ForeColor = AGVManager.nodeInfo[nodeIndex].Online ? Color.Black : Color.Red;
DgvNode.Rows[nodeIndex].SetValues(AGVManager.nodeInfo[nodeIndex].ToRow());
}));
System.GC.Collect();
}
private void ItemShow_Click(object sender, EventArgs e)
{
Show();
if (WindowState == FormWindowState.Minimized)
WindowState = FormWindowState.Normal;
}
private void ItemExit_Click(object sender, EventArgs e)
{
foreach (var item in AGVManager.agvInfo)
{
AGVManager.WriteIni(item.Name, SettingString.RFID, item.RFID);
}
notify.Dispose();
exit = true;
Close();
}
private void Notify_MouseDoubleClick(object sender, MouseEventArgs e)
{
Show();
if (WindowState == FormWindowState.Minimized)
WindowState = FormWindowState.Normal;
}
private void FrmMain_Load(object sender, EventArgs e)
{
//托盘菜单
notifyMenu = new ContextMenuStrip();
ToolStripMenuItem itemShow = new ToolStripMenuItem("显示(&S)");
itemShow.Click += ItemShow_Click;
ToolStripMenuItem itemExit = new ToolStripMenuItem("退出(&X)");
itemExit.Click += ItemExit_Click;
notifyMenu.Items.Add(itemShow);
notifyMenu.Items.Add(itemExit);
//托盘控件
notify = new NotifyIcon { Icon = Icon, Visible = true, ContextMenuStrip = notifyMenu, Text = Text };
notify.MouseDoubleClick += Notify_MouseDoubleClick;
ShowConfig();
AGVManager.server.NodeChanged += Server_NodeChanged;
AGVManager.control.NodeChangedEvent += Server_NodeChanged;
AGVManager.server.NodeOnline += Server_NodeOnline;
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
if (!exit)
{
e.Cancel = true;
Hide();
}
foreach (var item in AGVManager.agvInfo)
{
AGVManager.WriteIni(item.Name, SettingString.RFID, item.RFID);
}
LogUtil.logBox = null;
//showTimer.Enabled = false;
showTimer.Stop();
AGVManager.server.NodeChanged -= Server_NodeChanged;
AGVManager.server.NodeOnline -= Server_NodeOnline;
}
private void DgvNode_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex == -1) return;
if (e.ColumnIndex == 6) //调用
{
AGVManager.nodeInfo[e.RowIndex].IsUse = !AGVManager.nodeInfo[e.RowIndex].IsUse;
DgvNode.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = AGVManager.nodeInfo[e.RowIndex].IsUse.ToString();
AGVManager.WriteIni(AGVManager.nodeInfo[e.RowIndex].Name, SettingString.IsUse, AGVManager.nodeInfo[e.RowIndex].IsUse.ToString());
DgvNode.Rows[e.RowIndex].SetValues(AGVManager.nodeInfo[e.RowIndex].ToRow());
}
}
bool InShhow = false;
private void ShowTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//ShowEmptyTask();
if (InShhow)
return;
InShhow = true;
Invoke(new Action(() =>
{
Application.DoEvents();
//if (!Common.doubleLine_WO.Equals(""))
lblWO.Text = AGVManager.doubleLine_WO;
// if (!AGVManager.A6_Target.Equals(""))
//lblDestInfo.Text = HttpManager.A6_Target;
lblCharge1.Text = "充电桩1:" ;
lblCharge2.Text = "充电桩2:" ;
lblWarn.Text = AGVManager.warnMsg;
}));
InShhow = false;
}
private void AddForm(string text, Form form)
{
text = text.PadLeft(10, ' ');
TabPage lineTabPage = new TabPage(text);
// lineTabPage.AutoScroll = true;
// lineTabPage.Tag = lineBean;
Panel linePan = new Panel();
linePan.Dock = DockStyle.Fill;
linePan.AutoScroll = true;
lineTabPage.Controls.Add(linePan);
form.FormBorderStyle = FormBorderStyle.None;
form.TopLevel = false;
linePan.Controls.Add(form);
//form.Dock = DockStyle.Fill;
//linePan.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
//form.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
form.Show();
// tabPageList.Add(lineTabPage);
tabControlManual.Controls.Add(lineTabPage);
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex == 1)
{
LogUtil.logBox = this.richTextBox1;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="Column6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column12.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column7.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column10.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column9.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column16.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAADAE
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABxYVlhnI5+wq+gjs2voI7Nr6COza+g
js2voI7Nr6COzZSGd7xrX1RDAAAAAAAAAAAAAAAAAAAAAAAAAAA+NSwdvKuZ6/Hfxv/Nvq7/wLOn/8O3
qf/Ctqn/wrap/9nJt//x38b/n4+B0gAAAAIAAAAAAAAAAAAAAAAAAAAAWkxJW+jXvv/t3MP/0M3J/9rY
1//d2tr/5eTk/93b2//Vz8r/8d/G/8e3ovUuJBscAAAAAAAAAAAAAAAAAAAAAFpMR17q17//7dzD/76z
qv+9tKr/vbWs/8C4rv/AuK7/xbuw//Hfxv/JuKP3KSEhHwAAAAAAAAAAAAAAAF9RSo5SRD/d5NG6//Hf
xv/l07z/79zE//Hfxv/x38b/7NvC/+bVvf/x38b/rZyL+GVWT89cTUl0AAAAAAAAAAB9bGLOblxW8ePQ
uf++q5j/q5+R/7Gfjv/x38b/6djB/6uai/+qnZH/ybej/6eZh/mTgHX/dWRcsgAAAAAAAAAAYE9JslVG
Qezj0Ln/uqSV/5K0s/+nlor/793E/9TDrf+sppr/m7Sw/8Csm/+nmYb5altR619PSJQAAAAAAAAAACoh
HT1JPzVm49G6/9O/qv/BrZr/yLWj//Hfxv/x38b/wK+c/8Csm//aybP/va6a8CwiH1ImJhoUAAAAAAAA
AAAqIR09KCggIKaXh9fx38b/8d/G//Hfxv/x38b/8d/G//Hfxv/x38b/8d/G/5CBcr4qIR09JiYaFAAA
AAAAAAAAMSYqQzMpMxlVSkUwiXtvmn5vZMR2Z1zddmdc3XZnXN12Z1zdgXNnvIN1aZJOOzsaMSYqQzMp
MxkAAAAAAAAAAGlowr1lY7SaAAAAAAAAAABeVVUbXE1vtVpMi9haTIvYYE9npEBAQAgAAAAAAAAAAGlo
wr1lY7SaAAAAAAAAAABaVpZEVVCMMwAAAAAAAAAAAAAAAFFDnm5sW/D/bFvv/0g7gEoAAAAAAAAAAAAA
AABaVpZEVVCMMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7JzsNT0KVTUxBhkpVAAADAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//AAD//wAA8A8AAOAHAADgBwAA4AcAAIADAACAAQAAgAEAAOAH
AADgBwAA8A8AAJw5AAD+fwAA//8AAP//AAAoAAAAIAAAAEAAAAABACAAAAAAAIAQAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAALSAgKEc7NrBPRD7SUEU/0lBFP9JQRT/SUEU/0lBFP9JQRT/SUEU/0lBFP9JQRT/SUEU/0lBF
P9JQRT/SS0E70EE4MokrKxUMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAEE2M0tgVEzo2smz//Hfxv/x38b/8d/G//Hfxv/x38b/8d/G//Hfxv/x38b/8d/G//Hf
xv/x38b/8d/G//Hfxv/x38b/uamY/E1BPNUtHh4RAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAwICAQUkZA5O7cw//x38b/8d/G//Hfxv/x38b/8d/G//Hfxv/x38b/8d/G//Hf
xv/x38b/8d/G//Hfxv/x38b/8d/G//Hfxv/x38b/0L+q/0o/OLsAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAD82MW25qZj88d/G//Hfxv/x38b/xLal/6Kblf+inJj/mJKP/62n
o/+TjIn/trGt/42IhP+2sa3/joiE/7Con//cy7b/8d/G//Hfxv/x38b/bV9V4y0eHhEAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAS0A6o93Mtv/x38b/8d/G/+/dxP+1r6r/3dvb/93b
2//Mysn/7u7t/9bU1P//////u7i3//////+7uLf//////7CmnP/x38b/8d/G//Hfxv+YiXvwKiAgNwAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABLPjmp4dG4//Hfxv/x38b/4dG4/8vI
xv/u7u3/7u7t/8zKyf/u7u3/u7i3///////Y19b//////7u4t///////t6+n//Hfxv/x38b/8d/G/52Q
f/MqIR09AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEs+Oanh0bj/8d/G//Hf
xv/h0bj/wL27/9HOzv/Rzs7/wb++/+Hg3/+xrq3/8fDw/7Kvr//x8PD/sa6t//Hw8P+xqqL/8d/G//Hf
xv/x38b/nZB/8yohHT0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASz45qeHR
uP/x38b/8d/G//Dexf/Lu6j/ybml/8m5pf/Gt6T/yrqn/8a2pP/Lu6j/xrak/8u7qP/GtqT/y7uo/9fG
sf/x38b/8d/G//Hfxv+dkH/zKiEdPQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnJycNOCsocj8z
MLU0Kybw2Mmw//Hfxv/x38b/8d/G//Hfxv/x38b/8d/G//Hfxv/x38b/8d/G//Hfxv/x38b/8d/G//Hf
xv/x38b/8d/G//Hfxv/x38b/8d/G/3lsYPc5LSvcPTIvojUoKE0AAAAAAAAAAAAAAAAAAAAAAAAAAEE0
MLGQfXL7q5WI/0I2MvbSxKz/8d/G//Hfxv/x38b/3Muz/86/qf/t3MP/8d/G//Hfxv/x38b/8d/G//Hf
xv/x38b/5dO8/8u6p//m1b3/8d/G//Hfxv/x38b/bWBV+HlpXv+lj4P/bFtU8DQpJlgAAAAAAAAAAAAA
AAAAAAAARTo2zLOcjv+znI7/QjYy9tLErP/x38b/793E/56Nf/+nkoT/sZuM/5qIev/Swqv/8d/G//Hf
xv/x38b/8d/G/7Wlk/+ein3/s52O/52Lff+7qZf/8d/G//Hfxv9tYFX4eWle/7Ocjv+YhHj/PTMtggAA
AAAAAAAAAAAAAAAAAABFOjbMs5yO/7Ocjv9CNjL20sSs//Hfxv+wn47/w6yb/5uVjP+KkIr/w66c/52L
ff/x38b/8d/G//Hfxv/Uxa7/q5eI/66fkf+Jko3/sqKU/6aShP/cyrX/8d/G/21gVfh5aV7/s5yO/5iE
eP89My2CAAAAAAAAAAAAAAAAAAAAAEQ4M8eymoz/s5yO/0I2MvbSxKz/8d/G/6aVhf/Hr57/hayv/6n0
/P+TkYj/oI5//+vawv/x38b/8d/G/66djP/Ls6H/h5qX/6r2/v+Kmpb/yLGf/7OikP/x38b/bWBV+Hlp
Xv+znI7/kXxy/jgtKXcAAAAAAAAAAAAAAAAAAAAAOy0qSTwxLdxLPjrkNCkn+dPDrP/x38b/ppaF/8uz
of9+hoH/hJ2b/7Gfkv+cinz/8d/G//Hfxv/x38b/w7Of/7iik/+UkIj/gp6e/5qVjP+xnYz/z76o//Hf
xv9tYVb4SDs38kU4NOJCNDK+MSQkFQAAAAAAAAAAAAAAAAAAAAAAAAAALCEfeywhIS5DNzK44dG4//Hf
xv/j0Ln/kYBz/8mxoP/MtKL/rJaH/7allP/x38b/8d/G//Hfxv/x38b/l4Z5/76nlv/MtKL/u6ST/5qL
fP/x38b/8d/G/5aIePQsIB1XLCEfeywfHykAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsIR97LB8fKUg8
N5TTwq3/8d/G//Hfxv/o177/qJiH/6eWhv/MvKb/8d/G//Hfxv/x38b/8d/G//Hfxv/w3sX/tKST/6aW
hv+4p5X/8d/G//Hfxv/x38b/inxv6iseHiosIR97LB8fKQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwh
H3ssHx8pMSklPol7b/Dx38b/8d/G//Hfxv/x38b/8d/G//Hfxv/x38b/8d/G//Hfxv/x38b/8d/G//Hf
xv/x38b/8d/G//Hfxv/x38b/8d/G/+7cw/9QRT/eAAAAAiwhH3ssHx8pAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAALCEfeywfHykAAAAARzs3wb+unPzx38b/8d/G//Hfxv/x38b/8d/G//Hfxv/x38b/8d/G//Hf
xv/x38b/8d/G//Hfxv/x38b/8d/G//Hfxv/v3cT/fnFm8Uk6N2YAAAAALCEfeywfHykAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAsIR97LB8fKQAAAAAzGhoKQTczuHJkWuWun47+vK2Z/7Wnk/+yo5H/sqOR/7Kj
kf+yo5H/sqOR/7Kjkf+yo5H/sqOR/7iplv+5qZf/o5WF+FNIQeJDNTFzAAAAAAAAAAAsIR97LB8fKQAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAADAnLJAxJjhEAAAAAAAAAAAAAAAALCQdIywjIFc9Mi5wTUA722pb
U/dqW1P3altT92pbU/dqW1P3altT92pbU/dqW1P3RDg0vDowK2orIR5NMyIiDwAAAAAAAAAAAAAAADAn
LJAxJjhEAAAAAAAAAAAAAAAAAAAAAAAAAABMRnaKdXTg/GlnvexBOVU/AAAAAAAAAAAAAAAAAAAAAAAA
AABaTEdseWhg3V5QU/JeUFPyXlBT8l5QU/JeUFPyY1RV8HVlXMhHNTUrAAAAAAAAAAAAAAAAAAAAAAAA
AABMRnaKdXTg/GlnvexBOVU/AAAAAAAAAAAAAAAAAAAAAFVRjbB8fPL/e3vu/0U9YXYAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAuIyMWW0278Wxb8P9sW/D/bFvw/2xb8P9PQZO7AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAFVRjbB8fPL/e3vu/0U9YXYAAAAAAAAAAAAAAAAAAAAAQztcRVZRjcNOSHq0JycnDQAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABTRZ7UbFvw/2xb8P9sW/D/bFvw/0k8gJ0AAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAQztcRVZRjcNOSHq0JycnDQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAE5Aj7RsW/D/bFvw/2xb8P9sWu3/QTJkegAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQS5YN0M4cYxEOHGORDhxjkM1
a4YnJycNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////////////AAD//gAAf/wAAD/8AAA/+AAAP/gA
AD/4AAA/+AAAP/AAAA/AAAAHwAAAA8AAAAPAAAAH4AAAB/gAAD/4AAA//AAAP/wAAH/+AAD/7+AH78fw
D8fH+B/H5/gf5//4P////D//////////////////
</value>
</data>
</root>
\ No newline at end of file \ No newline at end of file
namespace AGVControl
{
partial class Manual
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Manual));
this.panelInfo = new System.Windows.Forms.Panel();
this.lblInfo = new System.Windows.Forms.Label();
this.grpBxRunMode = new System.Windows.Forms.GroupBox();
this.chkBxAuto = new System.Windows.Forms.CheckBox();
this.btnReSendTask = new System.Windows.Forms.Button();
this.grpBxOperation = new System.Windows.Forms.GroupBox();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.btnReady = new System.Windows.Forms.Button();
this.btnPause = new System.Windows.Forms.Button();
this.btnClearErr = new System.Windows.Forms.Button();
this.grpBxMission = new System.Windows.Forms.GroupBox();
this.btnAssignTask = new System.Windows.Forms.Button();
this.cmbBxMission = new System.Windows.Forms.ComboBox();
this.panelInfo.SuspendLayout();
this.grpBxRunMode.SuspendLayout();
this.grpBxOperation.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.grpBxMission.SuspendLayout();
this.SuspendLayout();
//
// panelInfo
//
this.panelInfo.Controls.Add(this.lblInfo);
this.panelInfo.Dock = System.Windows.Forms.DockStyle.Top;
this.panelInfo.Location = new System.Drawing.Point(0, 0);
this.panelInfo.Name = "panelInfo";
this.panelInfo.Size = new System.Drawing.Size(385, 43);
this.panelInfo.TabIndex = 0;
//
// lblInfo
//
this.lblInfo.BackColor = System.Drawing.Color.LightBlue;
this.lblInfo.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblInfo.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblInfo.Location = new System.Drawing.Point(0, 0);
this.lblInfo.Name = "lblInfo";
this.lblInfo.Size = new System.Drawing.Size(385, 43);
this.lblInfo.TabIndex = 0;
this.lblInfo.Text = "#号车";
this.lblInfo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// grpBxRunMode
//
this.grpBxRunMode.Controls.Add(this.chkBxAuto);
this.grpBxRunMode.Controls.Add(this.btnReSendTask);
this.grpBxRunMode.Dock = System.Windows.Forms.DockStyle.Top;
this.grpBxRunMode.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.grpBxRunMode.Location = new System.Drawing.Point(0, 43);
this.grpBxRunMode.Name = "grpBxRunMode";
this.grpBxRunMode.Size = new System.Drawing.Size(385, 70);
this.grpBxRunMode.TabIndex = 1;
this.grpBxRunMode.TabStop = false;
this.grpBxRunMode.Text = "模式选择";
//
// chkBxAuto
//
this.chkBxAuto.AutoSize = true;
this.chkBxAuto.Location = new System.Drawing.Point(7, 21);
this.chkBxAuto.Name = "chkBxAuto";
this.chkBxAuto.Size = new System.Drawing.Size(76, 16);
this.chkBxAuto.TabIndex = 0;
this.chkBxAuto.Text = "自动模式";
this.chkBxAuto.UseVisualStyleBackColor = true;
this.chkBxAuto.CheckedChanged += new System.EventHandler(this.chkBxAuto_CheckedChanged);
//
// btnReSendTask
//
this.btnReSendTask.Location = new System.Drawing.Point(251, 11);
this.btnReSendTask.Name = "btnReSendTask";
this.btnReSendTask.Size = new System.Drawing.Size(75, 53);
this.btnReSendTask.TabIndex = 3;
this.btnReSendTask.Text = "任务重发";
this.btnReSendTask.UseVisualStyleBackColor = true;
this.btnReSendTask.Click += new System.EventHandler(this.btnReSendTask_Click);
//
// grpBxOperation
//
this.grpBxOperation.Controls.Add(this.flowLayoutPanel1);
this.grpBxOperation.Dock = System.Windows.Forms.DockStyle.Top;
this.grpBxOperation.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.grpBxOperation.Location = new System.Drawing.Point(0, 113);
this.grpBxOperation.Name = "grpBxOperation";
this.grpBxOperation.Size = new System.Drawing.Size(385, 108);
this.grpBxOperation.TabIndex = 2;
this.grpBxOperation.TabStop = false;
this.grpBxOperation.Text = "操作";
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.Controls.Add(this.btnReady);
this.flowLayoutPanel1.Controls.Add(this.btnPause);
this.flowLayoutPanel1.Controls.Add(this.btnClearErr);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 17);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(379, 88);
this.flowLayoutPanel1.TabIndex = 0;
//
// btnReady
//
this.btnReady.BackColor = System.Drawing.Color.Lime;
this.btnReady.Location = new System.Drawing.Point(30, 3);
this.btnReady.Margin = new System.Windows.Forms.Padding(30, 3, 5, 3);
this.btnReady.Name = "btnReady";
this.btnReady.Size = new System.Drawing.Size(88, 61);
this.btnReady.TabIndex = 0;
this.btnReady.Text = "运行";
this.btnReady.UseVisualStyleBackColor = false;
this.btnReady.Click += new System.EventHandler(this.btnReady_Click);
//
// btnPause
//
this.btnPause.BackColor = System.Drawing.Color.Red;
this.btnPause.Location = new System.Drawing.Point(153, 3);
this.btnPause.Margin = new System.Windows.Forms.Padding(30, 3, 3, 3);
this.btnPause.Name = "btnPause";
this.btnPause.Size = new System.Drawing.Size(88, 61);
this.btnPause.TabIndex = 1;
this.btnPause.Text = "暂停";
this.btnPause.UseVisualStyleBackColor = false;
this.btnPause.Click += new System.EventHandler(this.btnPause_Click);
//
// btnClearErr
//
this.btnClearErr.BackColor = System.Drawing.Color.Yellow;
this.btnClearErr.Location = new System.Drawing.Point(274, 3);
this.btnClearErr.Margin = new System.Windows.Forms.Padding(30, 3, 3, 3);
this.btnClearErr.Name = "btnClearErr";
this.btnClearErr.Size = new System.Drawing.Size(88, 61);
this.btnClearErr.TabIndex = 2;
this.btnClearErr.Text = "清除错误";
this.btnClearErr.UseVisualStyleBackColor = false;
this.btnClearErr.Click += new System.EventHandler(this.btnClearErr_Click);
//
// grpBxMission
//
this.grpBxMission.Controls.Add(this.btnAssignTask);
this.grpBxMission.Controls.Add(this.cmbBxMission);
this.grpBxMission.Dock = System.Windows.Forms.DockStyle.Top;
this.grpBxMission.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.grpBxMission.Location = new System.Drawing.Point(0, 221);
this.grpBxMission.Name = "grpBxMission";
this.grpBxMission.Size = new System.Drawing.Size(385, 70);
this.grpBxMission.TabIndex = 3;
this.grpBxMission.TabStop = false;
this.grpBxMission.Text = "手动任务";
//
// btnAssignTask
//
this.btnAssignTask.Location = new System.Drawing.Point(216, 12);
this.btnAssignTask.Name = "btnAssignTask";
this.btnAssignTask.Size = new System.Drawing.Size(131, 35);
this.btnAssignTask.TabIndex = 1;
this.btnAssignTask.Text = "发任务";
this.btnAssignTask.UseVisualStyleBackColor = true;
this.btnAssignTask.Click += new System.EventHandler(this.btnAssignTask_Click);
//
// cmbBxMission
//
this.cmbBxMission.FormattingEnabled = true;
this.cmbBxMission.Location = new System.Drawing.Point(12, 20);
this.cmbBxMission.Name = "cmbBxMission";
this.cmbBxMission.Size = new System.Drawing.Size(159, 20);
this.cmbBxMission.TabIndex = 0;
//
// Manual
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(385, 297);
this.Controls.Add(this.grpBxMission);
this.Controls.Add(this.grpBxOperation);
this.Controls.Add(this.grpBxRunMode);
this.Controls.Add(this.panelInfo);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Manual";
this.Load += new System.EventHandler(this.Manual_Load);
this.panelInfo.ResumeLayout(false);
this.grpBxRunMode.ResumeLayout(false);
this.grpBxRunMode.PerformLayout();
this.grpBxOperation.ResumeLayout(false);
this.flowLayoutPanel1.ResumeLayout(false);
this.grpBxMission.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panelInfo;
private System.Windows.Forms.Label lblInfo;
private System.Windows.Forms.GroupBox grpBxRunMode;
private System.Windows.Forms.CheckBox chkBxAuto;
private System.Windows.Forms.GroupBox grpBxOperation;
private System.Windows.Forms.Button btnReady;
private System.Windows.Forms.Button btnPause;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Button btnReSendTask;
private System.Windows.Forms.Button btnClearErr;
private System.Windows.Forms.GroupBox grpBxMission;
private System.Windows.Forms.Button btnAssignTask;
private System.Windows.Forms.ComboBox cmbBxMission;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DeviceLibrary;
using Common;
namespace AGVControl
{
public partial class Manual : Form
{
public Manual(Agv_Info agv)
{
InitializeComponent();
Agv = agv;
chkBxAuto.Checked = agv.IsUse;
btnReSendTask.Enabled = agv.IsUse;
btnAssignTask.Enabled = !agv.IsUse;
}
Agv_Info Agv;
private bool isIni = false;
private void Manual_Load(object sender, EventArgs e)
{
lblInfo.Text = string.Format("[{0}]", Agv.IP);
foreach (Mission mission in MissionSys.Missions)
{
cmbBxMission.Items.Add(mission.AliceName);
}
cmbBxMission.SelectedIndex = 0;
isIni = true;
}
private void chkBxAuto_CheckedChanged(object sender, EventArgs e)
{
if (!isIni) return;
this.Invoke(new Action(() =>
{
btnReSendTask.Enabled = chkBxAuto.Checked;
btnAssignTask.Enabled = !chkBxAuto.Checked;
if (!chkBxAuto.Checked)
{
AGVManager.Charge.DelOccupyInfo(Agv);
if (Agv.IsCon)
{
MiR_API.Del_Mission(Agv);
//添加Init任务
MissionSys.AssignMission(Agv, SettingString.Init);
}
}
else
{
if (Agv.IsExistShelf)
{
LogUtil.error(string.Format("{0} 车上有负载,无法开启自动模式,请先清空小车负载!", Agv.Name));
return;
}
if (MessageBox.Show(this, "是否继续上一次的任务?\r\n" + Agv.Msg, "提示", MessageBoxButtons.YesNo).Equals(DialogResult.No))
{
Agv.CurJob = null;
AGVManager.SetNodeOccupy(Agv.Place, LineState.None);
if (Agv.Place.Equals(SettingString.Standby) || Agv.Place.Equals(SettingString.AutoCharge))
Agv.Place = "";
MiR_API.Del_Mission(Agv);
Agv.RFID = "";
}
else
{
Agv.Resend(true);
}
}
Agv.IsUse = chkBxAuto.Checked;
}));
}
private void btnReSendTask_Click(object sender, EventArgs e)
{
if (Agv.IsCon)
{
if (MessageBox.Show("确定对小车重发任务?", Agv.Name, MessageBoxButtons.YesNo) == DialogResult.No)
return;
Task.Factory.StartNew(new Action(() =>
{
MiR_API.Clear_Error(Agv);
System.Threading.Thread.Sleep(1000);
MiR_API.State_Ready(Agv);
Agv.Resend(true);
LogUtil.info(string.Format("{0} 手动重发任务", Agv.Name));
}));
}
}
private void btnReady_Click(object sender, EventArgs e)
{
if (Agv.IsCon)
{
MiR_API.State_Ready(Agv);
LogUtil.info(string.Format("{0} 手动点击运行", Agv.Name));
}
}
private void btnPause_Click(object sender, EventArgs e)
{
if (Agv.IsCon)
{
MiR_API.State_Pause(Agv);
LogUtil.info(string.Format("{0} 手动点击暂停", Agv.Name));
}
}
private void btnClearErr_Click(object sender, EventArgs e)
{
if (Agv.IsCon)
{
MiR_API.Clear_Error(Agv);
LogUtil.info(string.Format("{0} 手动点击清除按钮", Agv.Name));
}
}
private void btnAssignTask_Click(object sender, EventArgs e)
{
try
{
if (Agv.IsCon)
{
string taskName = MissionSys.GetTaskNameByAliceName(cmbBxMission.SelectedItem.ToString());
if (taskName.Equals(SettingString.Enter) || taskName.Equals(SettingString.Leave))
if (MessageBox.Show("确定对小车发送进/出任务?", Agv.Name, MessageBoxButtons.YesNo) == DialogResult.No)
return;
MissionSys.AssignMission(Agv, taskName);
LogUtil.info(string.Format("{0} 手动发任务 [{1}]", Agv.Name, cmbBxMission.SelectedItem.ToString()));
}
}
catch (Exception ex)
{
LogUtil.error("手动发任务 ", ex);
}
}
private void btnExit_Click(object sender, EventArgs e)
{
Close();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAMAQAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAD/J75P/ye9d/8nvXf/J713/ye9d/8nvXf/J713/ye9d/8nvXf/J713/ye9d/8n
vXf/J713/ye+TgAAAAD/LKwu/yyuaAAAAAAAAAAAAAAAAAAAAAD/LK1d/y2ud/8trnf/LK9cAAAAAAAA
AAAAAAAAAAAAAP8ur2n/LbAt/y2lEf8zn6D/M6Cm/zOfiP8zn4j/M5+I/zWiPwAAAAAAAAAA/zWiP/8z
n4j/M5+I/zOfiP8zoKb/M5+g/y2lEQAAAAD/OJNA/zeUcP85kqb/OJKI/ziSiP84koj/OJKI/ziSiP84
koj/OJKI/ziSiP85kqb/N5Rw/ziTQAAAAAAAAAAA/0CDQP9AhHD/QINAAAAAAAAAAAD/P4FB/0CDkP9A
grT/QINn/0OFFwAAAAD/QINA/0CEcP9Ag0AAAAAAAAAAAP9IdED/R3Rw/0h0QAAAAAAAAAAA/0Z2kf9F
dTD/QnAy/0V1Vf9FdHIAAAAA/0h0QP9HdHD/SHRAAAAAAAAAAAD/TGhA/0tmcP9MaEAAAAAA/01nav9N
aEz/Y3qx/3mM6f9LZDP/TGe1AAAAAP9MaED/S2Zw/0xoQAAAAAAAAAAA/1RYQP9UV3D/VFhAAAAAAP9R
Vy//Ulif/2lfa/9rYbX/UFUw/1NakQAAAAD/VFhA/1RXcP9UWEAAAAAAAAAAAP9YTED/V0tw/1hMQAAA
AAD/gIAC/1lJp/9YS53/V0lJ/1dKlf9XSUYAAAAA/1hMQP9XS3D/WExAAAAAAAAAAAD/YDxA/106bv9d
PkIAAAAAAAAAAAAAAAD/Xj4x/188bgAAAAAAAAAAAAAAAP9dPkL/XTpu/2A8QAAAAAAAAAAA/2IrL/9l
LXL/ZC94/2MviP9jL4j/Yy+I/2MviP9jL4j/Yy+I/2MviP9jL4j/ZS13/2Utcv9kLC4AAAAAAAAAAAAA
AAD/bCFc/2sgiP9rIIj/ayCI/2sgiP9rIIj/ayCI/2sgiP9rIIj/ayCI/2sgiP9sH1oAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAA//8AAP//AAD//wAA//8AAIPBAADgBwAA/n8AAP3/AAD+XwAA/V8AAPy/AAD//wAA8A8AAOAH
AAD//wAA//8AAA==
</value>
</data>
</root>
\ No newline at end of file \ No newline at end of file
using log4net.Config;
using log4net.Util.TypeConverters;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Common;
using System.Windows.Forms;
using DeviceLibrary;
namespace AGVControl
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ThreadException += Application_ThreadException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
XmlConfigurator.Configure();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//程序只能运行一次
Process current = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName(current.ProcessName);
foreach (Process process in processes)
{
if (process.Id == current.Id) continue; //自己
if (process.MainModule.FileName == current.MainModule.FileName)
{
//显示已打开的程序
Window_API.ShowWindow(process.MainWindowHandle, Window_API.SW_RESTORE);
Window_API.SwitchToThisWindow(process.MainWindowHandle, true);
return;
}
}
LogUtil.info("=====程序开始=====");
AGVManager.Init();
AGVManager.control = new DeviceLibrary.Control();
//获取节点位置
// AGVManager.GetNodesPosition();
AGVManager.control.Start();
AGVManager.server = new AgvServer();
AGVManager.server.Start();
//AGVManager.web = new WebService();
//AGVManager.web.Open(AppConfigHelper.GetValue("WebService"));
Application.Run(new FrmMain());
AGVManager.control.Stop();
AGVManager.server.Stop();
// AGVManager.web.Close();
LogUtil.info("=====程序结束=====\r\n");
}
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
LogUtil.error("CurrentDomain_UnhandledException", (Exception)e.ExceptionObject);
}
private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
LogUtil.error("Application_ThreadException", e.Exception);
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("AGVControl-ProductionLine")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AGVControl-ProductionLine")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("e1c3207d-c67d-4b46-a9db-d182f2074ccb")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace SO827_AGV.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SO827_AGV.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace SO827_AGV.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
文件属性发生变化
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E1C3207D-C67D-4B46-A9DB-D182F2074CCB}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>SO827_AGV</RootNamespace>
<AssemblyName>SO827-AGV</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>line.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="AsaPL.AgvClient">
<HintPath>..\AgvClient\bin\Debug\AsaPL.AgvClient.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>dll\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>dll\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=106.11.4.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.11.4\lib\net452\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Activation" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmMain.Designer.cs">
<DependentUpon>FrmMain.cs</DependentUpon>
</Compile>
<Compile Include="Manual.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Manual.designer.cs">
<DependentUpon>Manual.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Manual.resx">
<DependentUpon>Manual.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="line.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AGV_UI\AGV_UI.csproj">
<Project>{c6d2fc09-46f7-4ec5-a877-15ea06342e4f}</Project>
<Name>AGV_UI</Name>
</ProjectReference>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{bafeafe6-04e2-48ee-8845-bfc7ea3e3c21}</Project>
<Name>Common</Name>
</ProjectReference>
<ProjectReference Include="..\DeviceLibrary\DeviceLibrary.csproj">
<Project>{f9619f07-15f1-4e59-a383-3871952bbb79}</Project>
<Name>DeviceLibrary</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30523.141
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SO827-AGV", "SO827-AGV.csproj", "{E1C3207D-C67D-4B46-A9DB-D182F2074CCB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AGV_UI", "..\AGV_UI\AGV_UI.csproj", "{C6D2FC09-46F7-4EC5-A877-15EA06342E4F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "..\Common\Common.csproj", "{BAFEAFE6-04E2-48EE-8845-BFC7EA3E3C21}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceLibrary", "..\DeviceLibrary\DeviceLibrary.csproj", "{F9619F07-15F1-4E59-A383-3871952BBB79}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E1C3207D-C67D-4B46-A9DB-D182F2074CCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1C3207D-C67D-4B46-A9DB-D182F2074CCB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1C3207D-C67D-4B46-A9DB-D182F2074CCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1C3207D-C67D-4B46-A9DB-D182F2074CCB}.Release|Any CPU.Build.0 = Release|Any CPU
{C6D2FC09-46F7-4EC5-A877-15EA06342E4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C6D2FC09-46F7-4EC5-A877-15EA06342E4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6D2FC09-46F7-4EC5-A877-15EA06342E4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6D2FC09-46F7-4EC5-A877-15EA06342E4F}.Release|Any CPU.Build.0 = Release|Any CPU
{BAFEAFE6-04E2-48EE-8845-BFC7EA3E3C21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BAFEAFE6-04E2-48EE-8845-BFC7EA3E3C21}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAFEAFE6-04E2-48EE-8845-BFC7EA3E3C21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAFEAFE6-04E2-48EE-8845-BFC7EA3E3C21}.Release|Any CPU.Build.0 = Release|Any CPU
{F9619F07-15F1-4E59-A383-3871952BBB79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9619F07-15F1-4E59-A383-3871952BBB79}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9619F07-15F1-4E59-A383-3871952BBB79}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9619F07-15F1-4E59-A383-3871952BBB79}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C1E472B0-A5EF-4CB3-834D-7643344D6FD9}
EndGlobalSection
EndGlobal
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AGV_UI
{
public partial class Status : UserControl
{
public Status(string name, List<string> infos)
{
InitializeComponent();
AGVName = name;
missionShow = new Dictionary<string, Control>();
if (infos != null && infos.Count > 0)
{
foreach (var item in infos)
{
missionShow.Add(item, new Label() { Name = item,
Font = new Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))),
AutoSize = true
});
}
flowPanelMissionState.Controls.AddRange(missionShow.Values.ToArray());
}
}
public Status()
{
}
public void Init()
{
foreach (string item in missionShow.Keys)
{
ShowInfo(item, item);
}
SetTitle();
}
public int MaxBattery { get; set; } = 90;
public int MinBattery { get; set; } = 20;
public string AGVName { get; private set; }
#region 私有字段
private Dictionary<string, Control> missionShow;
#endregion
void SetTitle()
{
this.Invoke(new Action(() =>
{
lblName.Text = AGVName;
}
));
}
/// <summary>
/// 设置电量
/// </summary>
/// <param name="curBattery"></param>
/// <param name="isInCharge"></param>
public void SetBattery(int curBattery, bool isInCharge = false)
{
object[] objs = Manager.SetBattery(curBattery, isInCharge, MinBattery, MaxBattery);
try
{
this.Invoke(new Action(() =>
{
lblBattery.Text = objs[0] as string;
lblBattery.Image = objs[1] as Image;
}
));
}
catch { }
}
/// <summary>
/// 设置连接状态
/// </summary>
/// <param name="state"></param>
public void SetConnectState(bool state = false)
{
Image image = Manager.SetConnState(state);
this.Invoke(new Action(() =>
{
picBxConn.Image = image;
}
));
}
public void ShowInfo(string key, string info)
{
this.Invoke(new Action(() =>
{
if (missionShow.ContainsKey(key))
missionShow[key].Text = string.Format("{0}:{1}",key, info);
}
));
}
/// <summary>
/// 设置当前任务名称
/// </summary>
/// <param name="taskName"></param>
public void SetCurTask(string taskName)
{
this.Invoke(new Action(() =>
{
lblTask.Text = taskName;
}
));
}
/// <summary>
/// 设置agv当前状态
/// </summary>
/// <param name="curState"></param>
public void SetCurState(string curState)
{
object[] objs = Manager.SetAGVState(curState);
this.Invoke(new Action(() =>
{
lblAGVState.Text = objs[0] as string;
lblAGVState.Image = objs[1] as Image;
}
));
}
}
}
namespace AGV_UI
{
partial class Status
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Status));
this.panelTitle = new System.Windows.Forms.Panel();
this.lblBattery = new System.Windows.Forms.Label();
this.picBxConn = new System.Windows.Forms.PictureBox();
this.lblName = new System.Windows.Forms.Label();
this.panelAGVState = new System.Windows.Forms.Panel();
this.lblAGVState = new System.Windows.Forms.Label();
this.lblTask = new System.Windows.Forms.Label();
this.flowPanelMissionState = new System.Windows.Forms.FlowLayoutPanel();
this.panelTitle.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picBxConn)).BeginInit();
this.panelAGVState.SuspendLayout();
this.SuspendLayout();
//
// panelTitle
//
this.panelTitle.BackColor = System.Drawing.Color.LightBlue;
this.panelTitle.Controls.Add(this.lblBattery);
this.panelTitle.Controls.Add(this.picBxConn);
this.panelTitle.Controls.Add(this.lblName);
this.panelTitle.Dock = System.Windows.Forms.DockStyle.Top;
this.panelTitle.Location = new System.Drawing.Point(0, 0);
this.panelTitle.Name = "panelTitle";
this.panelTitle.Size = new System.Drawing.Size(287, 47);
this.panelTitle.TabIndex = 0;
//
// lblBattery
//
this.lblBattery.Dock = System.Windows.Forms.DockStyle.Right;
this.lblBattery.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblBattery.ForeColor = System.Drawing.Color.Black;
this.lblBattery.Image = ((System.Drawing.Image)(resources.GetObject("lblBattery.Image")));
this.lblBattery.Location = new System.Drawing.Point(249, 0);
this.lblBattery.Name = "lblBattery";
this.lblBattery.Size = new System.Drawing.Size(38, 47);
this.lblBattery.TabIndex = 2;
this.lblBattery.Text = "0%";
this.lblBattery.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// picBxConn
//
this.picBxConn.Dock = System.Windows.Forms.DockStyle.Left;
this.picBxConn.Image = global::AGV_UI.Properties.Resources.offline;
this.picBxConn.Location = new System.Drawing.Point(0, 0);
this.picBxConn.Name = "picBxConn";
this.picBxConn.Size = new System.Drawing.Size(51, 47);
this.picBxConn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.picBxConn.TabIndex = 1;
this.picBxConn.TabStop = false;
//
// lblName
//
this.lblName.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblName.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblName.ForeColor = System.Drawing.Color.Black;
this.lblName.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.lblName.Location = new System.Drawing.Point(0, 0);
this.lblName.Name = "lblName";
this.lblName.Size = new System.Drawing.Size(287, 47);
this.lblName.TabIndex = 0;
this.lblName.Text = "#号车";
this.lblName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// panelAGVState
//
this.panelAGVState.Controls.Add(this.lblAGVState);
this.panelAGVState.Controls.Add(this.lblTask);
this.panelAGVState.Dock = System.Windows.Forms.DockStyle.Top;
this.panelAGVState.Location = new System.Drawing.Point(0, 47);
this.panelAGVState.Name = "panelAGVState";
this.panelAGVState.Size = new System.Drawing.Size(287, 50);
this.panelAGVState.TabIndex = 1;
//
// lblAGVState
//
this.lblAGVState.Dock = System.Windows.Forms.DockStyle.Right;
this.lblAGVState.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblAGVState.Image = global::AGV_UI.Properties.Resources.Unknown;
this.lblAGVState.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.lblAGVState.Location = new System.Drawing.Point(160, 0);
this.lblAGVState.Name = "lblAGVState";
this.lblAGVState.Size = new System.Drawing.Size(127, 50);
this.lblAGVState.TabIndex = 1;
this.lblAGVState.Text = "None";
this.lblAGVState.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblTask
//
this.lblTask.Dock = System.Windows.Forms.DockStyle.Left;
this.lblTask.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblTask.Image = global::AGV_UI.Properties.Resources.task;
this.lblTask.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.lblTask.Location = new System.Drawing.Point(0, 0);
this.lblTask.Name = "lblTask";
this.lblTask.Size = new System.Drawing.Size(216, 50);
this.lblTask.TabIndex = 0;
this.lblTask.Text = "无任务";
this.lblTask.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// flowPanelMissionState
//
this.flowPanelMissionState.BackColor = System.Drawing.Color.LightBlue;
this.flowPanelMissionState.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowPanelMissionState.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowPanelMissionState.Location = new System.Drawing.Point(0, 97);
this.flowPanelMissionState.Name = "flowPanelMissionState";
this.flowPanelMissionState.Size = new System.Drawing.Size(287, 230);
this.flowPanelMissionState.TabIndex = 2;
//
// Status
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.flowPanelMissionState);
this.Controls.Add(this.panelAGVState);
this.Controls.Add(this.panelTitle);
this.Name = "Status";
this.Size = new System.Drawing.Size(287, 327);
this.panelTitle.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.picBxConn)).EndInit();
this.panelAGVState.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panelTitle;
private System.Windows.Forms.Label lblName;
private System.Windows.Forms.PictureBox picBxConn;
private System.Windows.Forms.Label lblBattery;
private System.Windows.Forms.Panel panelAGVState;
private System.Windows.Forms.Label lblTask;
private System.Windows.Forms.Label lblAGVState;
private System.Windows.Forms.FlowLayoutPanel flowPanelMissionState;
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="lblBattery.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAOZJREFUaEPt
ziEOw1AQxNBcrCT3v1NKDA0CxmrBtzRspbfX6XTadd/382ac/1/2rI3z32QPLQfTZehyMF2GLgfTZehy
MF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfT
ZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2GLgfTZehyMF2G
LgfTZehyMF2GLgfT9XyupxxMl6HLwXQZuhxMl6HLwXQZuhzM6XR61XV9AQQ5qN/xmUs6AAAAAElFTkSu
QmCC
</value>
</data>
</root>
\ No newline at end of file \ No newline at end of file
文件属性发生变化
此文件类型无法预览
此文件类型无法预览
文件属性发生变化
此文件类型无法预览
此文件类型无法预览
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="RestSharp" version="106.11.4" targetFramework="net461" />
</packages>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<protocolMapping>
<add scheme="https" binding="basicHttpsBinding" />
</protocolMapping>
<bindings>
<webHttpBinding>
<binding name="webBinding" maxReceivedMessageSize="2147483647" crossDomainScriptAccessEnabled="true" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="LineWebService.ClsWebService" behaviorConfiguration="RESTBehavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:11111/BenQMIR/Webservice/AGVService.asmx" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address =""
binding="webHttpBinding"
contract="LineWebService.IWebService"
behaviorConfiguration="ESEndPointBehavior">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="RESTBehavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="ESEndPointBehavior">
<webHttp helpEnabled="true" />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace LineWebService
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的类名“Service1”。
//[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Reentrant)]
///[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
public class ClsWebService : IWebService
{
//private readonly log4net.ILog LOG = log4net.LogManager.GetLogger("ClsWebService");
public ClsWebService()
{
}
public Result CreateEmptyRecycleTask(string line)
{
//LOG.Info("CreateEmptyRecycleTask emptyStation=" + line);
Result res;
if (!line.Equals(""))
{
res = new Result() { Succeed = "true", ResultData = "", ErrorMessage = "" };
//IWebService_Callback callback = OperationContext.Current.GetCallbackChannel<IWebService_Callback>();
//callback.GetEmptyRecycleTask(line);
}
else
{
res = new Result() { Succeed = "false", ResultData = "", ErrorMessage = "Not find " + line };
}
//if (AGVControl.Common.agvProductionLine.TryGetValue(line, out string value))
//{
// res = new Result() { Succeed = "true", ResultData = "", ErrorMessage = "" };
//LOG.Info("WebService Response OK");
// //加到任务
// //int idx = AGVControl.Common.nodeInfo.FindIndex(s => s.Name == value);
// //if (idx > -1)
// // AGVControl.Common.linePlace.Add(value);
// //else
// // AGVControl.Common.log.Error("CreateEmptyRecycleTask " + value + "不存在");
// if (!Common.AddLinePlace(value))
// Common.log.Error("CreateEmptyRecycleTask 节点【" + value + "】不存在");
// else
// {
// Common.LogInfo("任务:" + value + " 出空料架 【" + line + "】");
// }
// //System.IO.File.WriteAllLines(Common.CONFIG_PATH + "LinePlace.txt", Common.linePlace);
//}
//else
//{
// res = new Result() { Succeed = "false", ResultData = "", ErrorMessage = "Not find " + line };
//LOG.Info("WebService Response false");
//}
return res;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace LineWebService
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService1”。
[ServiceContract]//(CallbackContract = typeof(IWebService_Callback))
public interface IWebService
{
[OperationContract]
[WebInvoke(UriTemplate = "CreateEmptyRecycleTask?emptyStation={line}", Method = "Get",
BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
Result CreateEmptyRecycleTask(string line);
//log4net.Config.XmlConfigurator.Configure();
// TODO: 在此添加您的服务操作
}
//[ServiceContract]
//public interface IWebService_Callback
//{
// [OperationContract(IsOneWay = true)]
// void GetEmptyRecycleTask(string lineName);
//}
// 使用下面示例中说明的数据约定将复合类型添加到服务操作。
[DataContract]
public class Result
{
[DataMember]
public string Succeed { get; set; }
[DataMember]
public string ResultData { get; set; }
[DataMember]
public string ErrorMessage { get; set; }
}
}
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{074D4597-8955-4EEE-840A-8FAA9B174603}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WebService</RootNamespace>
<AssemblyName>WebService</AssemblyName>
<ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<StartArguments>/client:"WcfTestClient.exe"</StartArguments>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<WcfConfigValidationEnabled>True</WcfConfigValidationEnabled>
<XsdCodeGenEnabled>True</XsdCodeGenEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="IWebService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ClsWebService.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<VSToolsPath Condition="'$(VSToolsPath)' == '' and '$(VisualStudioVersion)' != '' and '$(VisualStudioVersion)' != '11.0'">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio</VSToolsPath>
<WcfServiceModelTargetPath>$(VSToolsPath)\WCF</WcfServiceModelTargetPath>
</PropertyGroup>
<Import Project="$(WcfServiceModelTargetPath)\Microsoft.VisualStudio.ServiceModel.targets" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{3D9AD99F-2412-4246-B90B-4EAA41C64699}">
<WcfProjectProperties>
<AutoStart>True</AutoStart>
</WcfProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file \ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("WebService")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WebService")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("074d4597-8955-4eee-840a-8faa9b174603")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
文件属性发生变化
using BLL.BLL;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace BLL
{
public class AGVManager
{
//public static string Add_emptyMsg = "http://10.85.199.1/BenQMIR/Webservice/AGVService.asmx/CreateEmptyRecycleTask";//"http://localhost:11111/BenQMIR/Webservice/AGVService.asmx/CreateEmptyRecycleTask";//
public static string CreateEmptyTask(string Add_emptyMsg, string line)
{
try
{
//Dictionary<string, string> paramMap = new Dictionary<string, string>();
//paramMap.Add("emptyStation", "D1");
string path = Add_emptyMsg;
//foreach (string paramName in paramMap.Keys)
//{
// string par = System.Web.HttpUtility.UrlEncode(paramMap[paramName], System.Text.Encoding.UTF8);
// path += paramName + "=" + par + "&";
//}
//path = path.Substring(0, path.Length - 1);
string resultStr = HttpUtil.Post(path, "emptyStation=" + line);//HttpHelper.Post(path, "");
//Common.log.Debug("【" + path + "】【" + resultStr + "】");
//Result data = JsonHelper.DeserializeJsonToObject<Result>(resultStr);
return resultStr;
//if (data == null)
//{
// return " updateDeviceAlarmMsg 没有收到服务器反馈";
//}
//else
//{
// return data.Succeed;
//}
}
catch (Exception e)
{
return e.ToString();
}
}
public static Result GetWebservice(string Add_emptyMsg,string id)
{
Result rb = new Result();
try
{
//http://10.85.36.156/BenQMIR/Webservice/AGVService.asmx
string strURL = Add_emptyMsg + "?emptyStation=" + id;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
//request.Method="get";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream s = response.GetResponseStream();
XmlTextReader Reader = new XmlTextReader(s);
Reader.MoveToContent();
string strValue = Reader.ReadInnerXml();
strValue = strValue.Replace("&lt;", "<");
strValue = strValue.Replace("&gt;", ">");
//{"Succeed":false,"ResultData":null,"ErrorMessage":"无法通过[Feederaaaa]lineCode找到小车停靠点"}
rb = JsonConvert.DeserializeObject<Result>(strValue);
Reader.Close();
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.Message);
}
return rb;
}
/// <summary>
/// 获取大料架解绑情况
/// </summary>
/// <param name="rfid"></param>
/// <param name="lineName"></param>
/// <returns></returns>
public static bool GetRackBy(string rfid, out string lineName)
{
lineName = "";
//GET /ESMTCommonInterface/CommonService.asmx/GetRackBy?id=string HTTP/1.1
//Host: 10.85.17.233
string addr = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/GetRackBy?id=" + rfid;
//[{"msg":"1OKD1"}]
//[{"msg":"0NGFeeder"}]
try
{
string result = HttpUtil.Get(addr);
if (!result.Equals(""))
{
List<Msg> msgs = JsonHelper.DeserializeJsonToList<Msg>(result);
if (msgs == null || msgs.Count == 0)
return false;
int.TryParse(msgs[0].msg.Substring(0, 1), out int resCode);
string resStr = msgs[0].msg.Substring(1, 2);
lineName = msgs[0].msg.Substring(3);
//Common.log.Debug(string.Format("resCode={0},resStr={1},lineName={2}", resCode, resStr, lineName));
if (lineName.Equals("").Equals(true))
return false;
return true;
}
}
catch { return false; }
return false;
}
/// <summary>
/// 物料状态上报
/// </summary>
/// <param name="rfid"></param>
/// <param name="lineName"></param>
/// <returns></returns>
public static bool UpdateStatus(string rfid, string lineName)
{
//GET /ESMTCommonInterface/CommonService.asmx/UpdateStatusBy?id=string&location=string HTTP/1.1
//Host: 10.85.17.233
string addr = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/UpdateStatusBy?id=" + rfid + "&location=" + lineName;
//[{"msg":"1更新成功"}]
try
{
string result = HttpUtil.Get(addr);
if (!result.Equals(""))
{
List<Msg> msgs = JsonHelper.DeserializeJsonToList<Msg>(result);
if (msgs == null || msgs.Count == 0)
return false;
bool resRtn = int.TryParse(msgs[0].msg.Substring(0, 1), out int resCode);
if (resRtn)
{
if (resCode.Equals(1))
{
System.Windows.Forms.MessageBox.Show(string.Format("{0}物料状态更新成功[{1}]", lineName, rfid));
return true;
}
else
return false;
}
return false;
}
}
catch { return false; }
return false;
}
private class Msg
{
public string msg { get; set; }
}
}
public class Result
{
public string Succeed { get; set; }
public string ResultData { get; set; }
public string ErrorMessage { get; set; }
}
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<protocolMapping>
<add scheme="https" binding="basicHttpsBinding" />
</protocolMapping>
<bindings>
<webHttpBinding>
<binding name="webBinding" maxReceivedMessageSize="2147483647" crossDomainScriptAccessEnabled="true" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="LineWebService.ClsWebService" behaviorConfiguration="RESTBehavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:22222/BenQMIR/Webservice/AGVService.asmx/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address =""
binding="webHttpBinding"
contract="LineWebService.IWebService"
behaviorConfiguration="ESEndPointBehavior">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="RESTBehavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="ESEndPointBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
namespace WebServiceTest
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(12, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(132, 54);
this.button1.TabIndex = 0;
this.button1.Text = "监听";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(12, 90);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(132, 54);
this.button2.TabIndex = 1;
this.button2.Text = "关闭";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(26, 187);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(55, 15);
this.label1.TabIndex = 2;
this.label1.Text = "label1";
//
// button3
//
this.button3.Location = new System.Drawing.Point(273, 90);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(132, 54);
this.button3.TabIndex = 3;
this.button3.Text = "POST访问";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(150, 12);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(497, 72);
this.textBox1.TabIndex = 4;
this.textBox1.Text = "http://10.85.199.1/BenQMIR/Webservice/AGVService.asmx/CreateEmptyRecycleTask";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(160, 119);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(79, 25);
this.textBox2.TabIndex = 5;
this.textBox2.Text = "D1";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(150, 176);
this.textBox3.Multiline = true;
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(497, 160);
this.textBox3.TabIndex = 6;
//
// button4
//
this.button4.Location = new System.Drawing.Point(443, 90);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(132, 54);
this.button4.TabIndex = 7;
this.button4.Text = "feeder区访问";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Location = new System.Drawing.Point(592, 90);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(132, 54);
this.button5.TabIndex = 8;
this.button5.Text = "大料架回收访问";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button6
//
this.button6.Location = new System.Drawing.Point(735, 41);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(132, 54);
this.button6.TabIndex = 9;
this.button6.Text = "物料状态上报";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(879, 368);
this.Controls.Add(this.button6);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button3);
this.Controls.Add(this.label1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "客户端创建产线任务";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button6;
}
}
using LineWebService;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.ServiceModel.Web;
using System.ServiceModel;
using System.Linq.Expressions;
using BLL;
namespace WebServiceTest
{
public partial class Form1 : Form//, IWebService_Callback
{
public Form1()
{
InitializeComponent();
}
private WebServiceHost _serviceHost;
public void HostOpen()
{
try
{
ClsWebService service = new ClsWebService();
_serviceHost = new WebServiceHost(typeof(ClsWebService));//service, new Uri(url)
if (_serviceHost.State != CommunicationState.Opened)//判断服务是否关闭
{
_serviceHost.Open();
}
label1.Text="Web服务已开启";
}
catch (Exception ex)
{
//AGVControl.Common.log.Error("Open", ex);
MessageBox.Show(ex.ToString());
}
}
public void HostClose()
{
try
{
if (_serviceHost.State != CommunicationState.Closed)//判断服务是否关闭
{
_serviceHost.Close();//关闭服务
}
//_serviceHost.Close();
label1.Text="Web服务已关闭";
}
catch (Exception ex)
{
//AGVControl.Common.log.Error("Close", ex);
MessageBox.Show(ex.ToString());
}
}
//public void GetEmptyRecycleTask(string lineName)
//{
// label1.Text = lineName;
// MessageBox.Show(lineName);
//}
public void RecycleTask(string lineName)
{
label1.Text = lineName;
MessageBox.Show(lineName);
//if (AGVControl.Common.agvProductionLine.TryGetValue(lineName, out string value))
//{
// AGVControl.Common.LogInfo("WebService Response OK");
// //加到任务
// //int idx = AGVControl.Common.nodeInfo.FindIndex(s => s.Name == value);
// //if (idx > -1)
// // AGVControl.Common.linePlace.Add(value);
// //else
// // AGVControl.Common.log.Error("CreateEmptyRecycleTask " + value + "不存在");
// if (!Common.AddLinePlace(value))
// Common.log.Error("CreateEmptyRecycleTask 节点【" + value + "】不存在");
// else
// {
// Common.LogInfo("任务:" + value + " 出空料架 【" + lineName + "】");
// }
// //System.IO.File.WriteAllLines(Common.CONFIG_PATH + "LinePlace.txt", Common.linePlace);
//}
//else
//{
// AGVControl.Common.LogInfo("WebService Response false");
//}
}
private void button1_Click(object sender, EventArgs e)
{
HostOpen();
}
private void button2_Click(object sender, EventArgs e)
{
HostClose();
}
private void button3_Click(object sender, EventArgs e)
{
textBox3.Text=AGVManager.CreateEmptyTask(textBox1.Text,textBox2.Text);
}
private void button4_Click(object sender, EventArgs e)
{
AGVManager.GetWebservice(textBox1.Text, textBox2.Text);
}
private void button5_Click(object sender, EventArgs e)
{
bool qq = AGVManager.GetRackBy(textBox1.Text, out string kk);
textBox2.Text = qq.ToString() +" "+kk;
}
private void button6_Click(object sender, EventArgs e)
{
AGVManager.UpdateStatus("D17", "D1");
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Collections;
using System.Net;
using System.Net.Security;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Reflection;
using System.Net.NetworkInformation;
using BLL;
namespace BLL
{
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Collections;
using System.Net;
using System.Net.Security;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Reflection;
using log4net;
using Newtonsoft.Json;
using System.Windows.Forms;
namespace BLL
{
public class HttpUtil
{
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static string Post(string url, string paramData)
{
return Post(url, paramData, Encoding.UTF8);
}
public static T ObjPost<T>(string url, object o) where T : class
{
try
{
string json = JsonUtil.SerializeObject(o);
string result = Post(url, json);
if (!string.IsNullOrEmpty(result))
{
return JsonUtil.DeserializeJsonToObject<T>(result);
}
}
catch (Exception ex)
{
LOGGER.Error("Http post 出错" + ex);
}
return default(T);
}
public static List<T> ListPost<T>(string url, object o) where T : class
{
try
{
string json = JsonUtil.SerializeObject(o);
string result = Post(url, json);
if (!string.IsNullOrEmpty(result))
{
return JsonUtil.DeserializeJsonToList<T>(result);
}
}
catch (Exception ex)
{
LOGGER.Error("Http post 出错" + ex);
}
return new List<T>();
}
public static string Post(string url, string paramData, Encoding encoding)
{
string result = "";
if (url.ToLower().IndexOf("https", System.StringComparison.Ordinal) > -1)
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback((sender, certificate, chain, errors) => { return true; });
}
try
{
var wc = new TimeoutWebClient(5000);
if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
//wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
//如果需要将body中的参数以key/value格式发送到服务器,使用下面的Header
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
wc.Encoding = encoding;
//paramData = Uri.EscapeDataString(paramData);
result = wc.UploadString(url, "POST", paramData);
//LogUtil.info(result);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
LOGGER.Error("POST【" + paramData + "】 ERROR:", e);
}
//LOGGER.Info("post receive <<" + result );
return result;
}
public static string Get(string url)
{
return Get(url, Encoding.UTF8);
}
public static string Get(string url, Encoding encoding)
{
try
{
LOGGER.Info("HTTP GET FROM: " + url);
var wc = new WebClient { Encoding = encoding };
var readStream = wc.OpenRead(url);
using (var sr = new StreamReader(readStream, encoding))
{
var result = sr.ReadToEnd();
LOGGER.Info("get receive << " + result);
return result;
}
}
catch (Exception e)
{
LOGGER.Error("HTTP GET ERROR:", e);
}
return "";
}
}
/// <summary>
/// Json帮助类
/// </summary>
public class JsonUtil
{
/// <summary>
/// 将对象序列化为JSON格式
/// </summary>
/// <param name="o">对象</param>
/// <returns>json字符串</returns>
public static string SerializeObject(object o)
{
string json = JsonConvert.SerializeObject(o);
return json;
}
/// <summary>
/// 解析JSON字符串生成对象实体
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json字符串(eg.{"ID":"112","Name":"石子儿"})</param>
/// <returns>对象实体</returns>
public static T DeserializeJsonToObject<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(T));
T t = o as T;
return t;
}
/// <summary>
/// 解析JSON数组生成对象实体集合
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json数组字符串(eg.[{"ID":"112","Name":"石子儿"}])</param>
/// <returns>对象实体集合</returns>
public static List<T> DeserializeJsonToList<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
List<T> list = o as List<T>;
return list;
}
/// <summary>
/// 反序列化JSON到给定的匿名对象.
/// </summary>
/// <typeparam name="T">匿名对象类型</typeparam>
/// <param name="json">json字符串</param>
/// <param name="anonymousTypeObject">匿名对象</param>
/// <returns>匿名对象</returns>
public static T DeserializeAnonymousType<T>(string json, T anonymousTypeObject)
{
T t = JsonConvert.DeserializeAnonymousType(json, anonymousTypeObject);
return t;
}
}
public class TimeoutWebClient : WebClient
{
private int _timeout;
/// <summary>
/// 超时时间(毫秒)
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public TimeoutWebClient()
{
this._timeout = 60000;
}
public TimeoutWebClient(int timeout)
{
this._timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
var result = base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}
}
}
}
\ No newline at end of file \ No newline at end of file
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
namespace BLL
{
/// <summary>
/// Json帮助类
/// </summary>
public class JsonHelper
{
/// <summary>
/// 将对象序列化为JSON格式
/// </summary>
/// <param name="o">对象</param>
/// <returns>json字符串</returns>
public static string SerializeObject(object o)
{
string json = JsonConvert.SerializeObject(o);
return json;
}
/// <summary>
/// 解析JSON字符串生成对象实体
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json字符串(eg.{"ID":"112","Name":"石子儿"})</param>
/// <returns>对象实体</returns>
public static T DeserializeJsonToObject<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(T));
T t = o as T;
return t;
}
/// <summary>
/// 解析JSON数组生成对象实体集合
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json数组字符串(eg.[{"ID":"112","Name":"石子儿"}])</param>
/// <returns>对象实体集合</returns>
public static List<T> DeserializeJsonToList<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
List<T> list = o as List<T>;
return list;
}
/// <summary>
/// 反序列化JSON到给定的匿名对象.
/// </summary>
/// <typeparam name="T">匿名对象类型</typeparam>
/// <param name="json">json字符串</param>
/// <param name="anonymousTypeObject">匿名对象</param>
/// <returns>匿名对象</returns>
public static T DeserializeAnonymousType<T>(string json, T anonymousTypeObject)
{
T t = JsonConvert.DeserializeAnonymousType(json, anonymousTypeObject);
return t;
}
}
///// <summary>
///// 与服务器通信用对象
///// </summary>
//public class Operation
//{
// private string _cid = "";
// public string cid
// {
// get { return _cid; }
// set { _cid = value; }
// }
// public int seq { get; set; }
// public int op { get; set; }
// public int status { get; set; }
// private string _error = "";
// public string error
// {
// get { return _error; }
// set { _error = value; }
// }
// private Dictionary<string, string> _data = new Dictionary<string,string>();
// public Dictionary<string, string> data {
// get { return _data; }
// set { _data = value; }
// }
//}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
namespace BLL
{
public class MyWebClient:WebClient
{
private int _timeout;
/// <summary>
/// 超时时间(毫秒)
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public MyWebClient()
{
this._timeout = 60000;
}
public MyWebClient(int timeout)
{
this._timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
var result = base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WebServiceTest
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("WebServiceTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WebServiceTest")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("a89f6ec4-457a-4998-acdc-f1adc22c8bf8")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="Result" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>LineWebService.Result, WebService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>
\ No newline at end of file \ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace WebServiceTest.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WebServiceTest.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 覆盖当前线程的 CurrentUICulture 属性
/// 使用此强类型的资源类的资源查找。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WebServiceTest.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A89F6EC4-457A-4998-ACDC-F1ADC22C8BF8}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>WebServiceTest</RootNamespace>
<AssemblyName>WebServiceTest</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="WebService">
<HintPath>..\WebService\bin\Debug\WebService.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AGVManager.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="HttpHelper.cs" />
<Compile Include="JsonHelper.cs" />
<Compile Include="MyWebClient.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\DataSources\LineWebService.Result.datasource" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file
文件属性发生变化
云仓.png

110.0 KB

命名.png

13.2 KB

布局.png

209.7 KB

支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!