Commit 8c2b595c 张东亮

init

0 个父辈
正在显示 163 个修改的文件 包含 4983 行增加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
此文件的差异被折叠, 点击展开。
<?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
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 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=
<?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.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.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 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
}
}
}
此文件类型无法预览
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
云仓.png

110.0 KB

命名.png

13.2 KB

布局.png

209.7 KB

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