Commit 05b1c9b2 张东亮

init

0 个父辈
正在显示 85 个修改的文件 包含 12794 行增加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

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30104.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AGV_3D_SMD", "AGV_3D_SMD\AGV_3D_SMD.csproj", "{E1C3207D-C67D-4B46-A9DB-D182F2074CCB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgvClientTest", "AgvClientTest\AgvClientTest.csproj", "{E1C0827A-FA12-49A9-AC71-6D3E6518754A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgvClient", "AgvClient\AgvClient.csproj", "{7DAD8F15-0EC9-42DF-AE0B-94B45DE0F0AC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E1C3207D-C67D-4B46-A9DB-D182F2074CCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1C3207D-C67D-4B46-A9DB-D182F2074CCB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1C3207D-C67D-4B46-A9DB-D182F2074CCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1C3207D-C67D-4B46-A9DB-D182F2074CCB}.Release|Any CPU.Build.0 = Release|Any CPU
{E1C0827A-FA12-49A9-AC71-6D3E6518754A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1C0827A-FA12-49A9-AC71-6D3E6518754A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1C0827A-FA12-49A9-AC71-6D3E6518754A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1C0827A-FA12-49A9-AC71-6D3E6518754A}.Release|Any CPU.Build.0 = Release|Any CPU
{7DAD8F15-0EC9-42DF-AE0B-94B45DE0F0AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7DAD8F15-0EC9-42DF-AE0B-94B45DE0F0AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7DAD8F15-0EC9-42DF-AE0B-94B45DE0F0AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7DAD8F15-0EC9-42DF-AE0B-94B45DE0F0AC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6958A655-C82F-4C09-951F-24E629575E89}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E1C3207D-C67D-4B46-A9DB-D182F2074CCB}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>AGV_3D_SMD</RootNamespace>
<AssemblyName>AGV_3D_SMD</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>
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>dll\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>dll\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=106.11.4.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>dll\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Activation" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="bean\Agv_Info.cs" />
<Compile Include="bean\DisplayBoard.cs" />
<Compile Include="bean\Job.cs" />
<Compile Include="bean\JobStep.cs" />
<Compile Include="bean\jobType\ChargeJobType.cs" />
<Compile Include="bean\jobType\ReturnJobType.cs" />
<Compile Include="bean\JobType.cs" />
<Compile Include="bean\job\GetShelfJob.cs" />
<Compile Include="bean\job\SendShelfJob.cs" />
<Compile Include="bean\job\PackingJob_TransferShelf.cs" />
<Compile Include="bean\job\RecycleEmptyShelf.cs" />
<Compile Include="bean\job\PackingJob_SendShelf.cs" />
<Compile Include="bean\job\PackingJob_GetShelf.cs" />
<Compile Include="bean\job\StandyJob.cs" />
<Compile Include="bean\job\ChargeJob.cs" />
<Compile Include="bean\job\EnterLeaveShelfJob.cs" />
<Compile Include="bean\node\Node.cs" />
<Compile Include="bean\node\ClientNode.cs" />
<Compile Include="bean\jobType\ReelStringJobType.cs" />
<Compile Include="bean\jobType\PackingJobType.cs" />
<Compile Include="BLL\AGVManager.cs" />
<Compile Include="BLL\AgvServer.cs" />
<Compile Include="BLL\ScopeLimit.cs" />
<Compile Include="BLL\Standby.cs" />
<Compile Include="BLL\Charge.cs" />
<Compile Include="BLL\Common.cs" />
<Compile Include="BLL\Control.cs" />
<Compile Include="BLL\HttpHelper.cs" />
<Compile Include="BLL\FileHelper.cs" />
<Compile Include="BLL\JsonHelper.cs" />
<Compile Include="BLL\MyWebClient.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BLL\SettingString.cs" />
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmMain.Designer.cs">
<DependentUpon>FrmMain.cs</DependentUpon>
</Compile>
<Compile Include="BLL\MiR_API.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="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>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
</ItemGroup>
<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="AGV_3D_SMD" type="log4net.Appender.RollingFileAppender">
<file value="logs/AGV_3D_SMD.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/>
</layout>
</appender>
<appender name="AgvServer" type="log4net.Appender.RollingFileAppender">
<file value="logs/AgvServer.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/>
</layout>
</appender>
<appender name="MiR_API" type="log4net.Appender.RollingFileAppender">
<file value="logs/MiR_API.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/>
</layout>
</appender>
<logger name="MiR_API">
<level value="Error"/>
<appender-ref ref="MiR_API"/>
</logger>
<logger name="AgvServer">
<level value="Debug"/>
<appender-ref ref="AgvServer"/>
</logger>
<root>
<level value="Info"/>
<appender-ref ref="AGVControl_SMD_BOX"/>
</root>
</log4net>
<appSettings>
<add key="http_server" value="http://10.85.199.25/myproject/" />
<add key="FLEET" value="10.85.199.3" />
<add key="LocalIP" value="10.85.199.20" />
<add key="AutoCharge" value="True" />
<add key="ChargeThreshold" value="20,90" />
<add key="LimitPoints" value="0,0;0,0;0,0;0,0" />
</appSettings>
</configuration>
\ 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;
using AGVControl;
namespace AGVControl
{
public class AGVManager
{
/// <summary>
/// 小车从B区域离开前检查出库任务是否完成
/// </summary>
/// <param name="rfid"></param>
/// <returns>true:可以离开</returns>
public static bool LeaveCheck(Agv_Info agv, out int taskCount)
{
taskCount = 0;
try
{
//Common.log.Info("URL:" + Common.webService["URL"]);
string url = AppConfigHelper.GetValue(SettingString.http_server) + "rest/api/qisda/device/shelfTaskCount?rfid=" + agv.RFID;
var client = new RestSharp.RestClient(url) { Timeout = -1 };
var request = new RestSharp.RestRequest(RestSharp.Method.GET);
RestSharp.IRestResponse response = client.Execute(request);
string json = response.Content;
Common.log.Info(agv.Name + " [URL: " + url+"] [Return: " + json+"]");
if (string.IsNullOrWhiteSpace(json)) return true; //可以离开
//{"code":0,"msg":"ok","data":{"taskCount":1,"rfid":"A14"}}不能搬运锁定的料架,到待机位等待
ShelfTaskCount serverResult = JsonHelper.DeserializeJsonToObject<ShelfTaskCount>(json);
if (serverResult == null)
{
Common.log.Error(" 没有收到服务器反馈");
return true;
}
if (serverResult.code != 0) return true;
agv.LeftTaskCnt = serverResult.data.taskCount;
if (serverResult.data.taskCount == 0) //该料架出库完成
{
Common.log.Info(agv.Name+" 料架【" + agv.RFID + "】 无剩余出库任务,serverResult.shelfTaskData.taskCount=" + serverResult.data.taskCount.ToString());
return true;
}
else //该料架的出库任务未完成
{
// foreach (ShelfLockData item in serverResult.data)
// {
taskCount = serverResult.data.taskCount;
Common.log.Info(agv.Name + " [RFID=" + serverResult.data.rfid + "] [taskCount=" + serverResult.data.taskCount + "]");
// }
return false;
}
}
catch (Exception ex)
{
Common.log.Error(ex);
return true;
}
}
private static string Addr_getShelfLockInfo = "/rest/api/qisda/device/getShelfLockInfo"; //包装仓获取料架锁定状态地址
public static bool GetShelfLockInfo(string name,string rfid, List<string> shelfLockNodeNames)
{
string msg = "";
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("rfid", rfid);
string server = GetAddr(Addr_getShelfLockInfo, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
Common.log.Info("节点【"+name+ "】 料架锁定状态 " + " 【" + server + "】【" + resultStr + "】");
ShelfLockInfo serverResult = JsonHelper.DeserializeJsonToObject<ShelfLockInfo>(resultStr);
if (serverResult == null)
{
msg = "节点【" + name + "】没有收到服务器反馈";
Common.log.Error(msg);
return false;
}
if (serverResult.data.Count == 0) //该料架未锁定
{
msg = "节点【" + name + "】 料架【" + rfid + "】 没有锁定库位的料";
Common.log.Info(msg);
return false;
}
else //该料架存在锁定库位的料
{
string nodes="";
foreach (ShelfLockData item in serverResult.data)
{
Common.GetNodeNameByAliceName(item.cid,out string nodeName);
int resInt = shelfLockNodeNames.FindIndex(s=>s !=null && s.Equals(nodeName));
if(resInt==-1)
{
shelfLockNodeNames.Add(nodeName);
nodes+="锁定的CID=" + item.cid + ",节点名称=" + nodeName+";";
}
}
Common.log.Info("节点【" + name + "】获取" + rfid+"料仓锁定信息完成:"+nodes);
return true;
}
}
catch (Exception ex)
{
Common.log.Error(ex.Message);
}
return false;
}
private static string Addr_updateDeviceAlarmMsg = "/rest/api/qisda/device/updateDeviceAlarmMsg";
/// <summary>
/// 异常看板
/// </summary>
/// <param name="msgList"></param>
/// <returns></returns>
public static string updateDeviceAlarmMsg(List<AlarmMsg> msgList)
{
string msg = "";
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
string msgListStr = JsonHelper.SerializeObject(msgList);
paramMap.Add("deviceAlarmList", msgListStr);
string server = GetAddr(Addr_updateDeviceAlarmMsg, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
Common.log.Debug("updateDeviceAlarmMsg " + " 【" + server + "】【" + resultStr + "】");
RfidData data = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr);
if (data == null)
{
return msg = " updateDeviceAlarmMsg 没有收到服务器反馈";
}
else if (data.code.Equals(0).Equals(false))
{
return msg = " updateDeviceAlarmMsg 【" + server + "】【" + resultStr + "】" + data.msg;
}
return "";
}
catch (Exception ex)
{
Common.log.Error(ex);
}
return msg;
}
private static string GetAddr(string addr, Dictionary<string, string> paramsMap)
{
string server = AppConfigHelper.GetValue(SettingString.http_server);
if (server.EndsWith("/"))
{
server = server.Substring(0, server.Length - 1);
}
string path = server + addr.Trim() + "?";
foreach (string paramName in paramsMap.Keys)
{
string par = System.Web.HttpUtility.UrlEncode(paramsMap[paramName], System.Text.Encoding.UTF8);
path += paramName + "=" + par + "&";
}
path = path.Substring(0, path.Length - 1);
return path;
}
}
public class ShelfLockInfo
{
//返回: {"code":0,"msg":"ok","data":
//[{"barcode":"S20052301213","cid":"packing-20","rfid":"A12","rfidLoc":"3","lockPos":"4D2001AA0006","lockPosId":"1231"}]}
/// <summary>
/// 返回码,0为正常,其他为异常
/// </summary>
public int code { get; set; }
/// <summary>
/// 消息
/// </summary>
public string msg { get; set; }
public List<ShelfLockData> data { get; set; }
}
public class ShelfLockData
{
/// <summary>
/// 库位中料盘的条码
/// </summary>
public string barcode { get; set; }
/// <summary>
/// 库位中料盘的锁定库位对应的料仓编
/// </summary>
public string cid { get; set; }
/// <summary>
/// 料架RFID
/// </summary>
public string rfid { get; set; }
/// <summary>
/// 料架的库位
/// </summary>
public int rfidLoc { get; set; }
/// <summary>
/// 库位中料盘的锁定库位
/// </summary>
public string lockPos { get; set; }
/// <summary>
/// 料架出库的剩余数量
/// </summary>
public int taskCount { get; set; }
}
/// <summary>
/// 获取料架中的任务数
/// </summary>
public class ShelfTaskCount
{
// {"code":0,"msg":"ok","data":{"taskCount":0,"rfid":"A2"}}
/// <summary>
/// 0为正常,其他为异常
/// </summary>
public int code { get; set; }
/// <summary>
/// 消息
/// </summary>
public string msg { get; set; }
public ShelfTaskData data { get; set; }
}
public struct ShelfTaskData
{
/// <summary>
/// 当前料架剩余任务数(即还有几盘料没放上去)
/// </summary>
public int taskCount { get; set; }
/// <summary>
/// 料架RFID
/// </summary>
public string rfid { get; set; }
}
public class AlarmMsg
{
//>>>name : 异常位置名称
public string name = "";
//>>>msgKey : 异常信息唯一标识
public string msgKey = "";
//>>>msgValue : 异常信息
public string msgValue = "";
public int type;
/// <summary>
/// 异常信息
/// </summary>
/// <param name="name">异常位置名称</param>
/// <param name="key">异常信息唯一标识</param>
/// <param name="value">异常信息</param>
public AlarmMsg(string name, string key, string value,int type=0)
{
this.name = name;
this.msgKey = key;
this.msgValue = value;
this.type = type;
}
}
public class RfidData
{
//{"code":0,"msg":"ok","data":"7"}
public int code { get; set; }
public string msg { get; set; }
public Dictionary<string, string> data { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Threading;
using AGVControl;
namespace AGVControl.BLL
{
public class AgvServer
{
private bool _loop;
private Socket _server; //服务端
private List<Client> _client; //所有客户端
private Thread tListenClient; //监听客户端连接
public delegate void NodeChangedEvent(int nodeIndex);
public event NodeChangedEvent NodeChanged;
public event NodeChangedEvent NodeOnline;
private static log4net.ILog log = log4net.LogManager.GetLogger("AgvServer");
public AgvServer()
{
}
/// <summary>
/// 开启服务
/// </summary>
public void Start()
{
try
{
log.Info("AGVServer服务启动");
IPEndPoint localEP = new IPEndPoint(IPAddress.Any, 12000);
_server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_server.Bind(localEP);
_server.Listen(100);
_loop = true;
_client = new List<Client>();
tListenClient = new Thread(new ThreadStart(ListenClient));
tListenClient.Start();
}
catch (Exception ex)
{
log.Error(ex);
}
}
/// <summary>
/// 停止服务
/// </summary>
public void Stop()
{
_loop = false;
for (int i = 0; i < _client.Count; i++)
{
_client[i].Loop = false;
_client[i].IsConn = false;
_client[i].Socket.Close();
}
_server.Close();
_client = null;
log.Info("AGVServer服务关闭");
}
/// <summary>
/// 更新节点界面
/// </summary>
/// <param name="nodeIndex"></param>
public void NodeRefresh(int nodeIndex)
{
NodeChanged?.Invoke(nodeIndex);
}
/// <summary>
/// 小车到达
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
public bool Arrive(string nodeName,string RFID="")
{
int idx;
int n = 0;
do
{
idx = FindClient(nodeName);
if (idx == -1)
{
Common.log.Error("Arrive: 没有找到" + nodeName);
Thread.Sleep(500);
n++;
}
else
{
n = 10;
}
} while (n < 4);
if (idx == -1) return false;
ClientNode node = new ClientNode(nodeName, RFID, eNodeStatus.Arrive);
log.Info("SendTo " + nodeName + " RFID=" + RFID + " " +eNodeStatus.Arrive);
byte[] buff = Encode(node);
return Send(idx, buff);
}
/// <summary>
/// 小车已准备好
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
public bool Ready(string nodeName, string RFID = "")
{
int idx;
int n = 0;
do
{
idx = FindClient(nodeName);
if (idx == -1)
{
Common.log.Error("Ready: 没有找到" + nodeName);
Thread.Sleep(500);
n++;
}
else
{
n = 10;
}
} while (n < 4);
if (idx == -1) return false;
ClientNode node = new ClientNode(nodeName, RFID, eNodeStatus.Ready);
log.Info("SendTo " + nodeName + " RFID=" +RFID+" "+ eNodeStatus.Ready);
byte[] buff = Encode(node);
return Send(idx, buff);
}
/// <summary>
/// 关门
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
public bool CloseDoor(string nodeName, string RFID = "")
{
int idx;
int n = 0;
do
{
idx = FindClient(nodeName);
if (idx == -1)
{
Common.log.Error("CloseDoor: 没有找到" + nodeName);
Thread.Sleep(500);
n++;
}
else
{
n = 10;
}
} while (n < 4);
if (idx == -1) return false;
ClientNode node = new ClientNode(nodeName, RFID, eNodeStatus.CloseDoor);
log.Info("SendTo " + nodeName + " RFID=" + RFID + " " + eNodeStatus.CloseDoor);
byte[] buff = Encode(node);
return Send(idx, buff);
}
/// <summary>
/// 需要进入料架
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
public bool EnterShelf(Agv_Info info)
{
int idx;
int n = 0;
do
{
idx = FindClient(info.Place);
if (idx == -1)
{
log.Error("没有找到" + info.Place);
Thread.Sleep(500);
n++;
}
else
{
n = 10;
}
} while (n < 4);
if (idx == -1) return false;
ClientNode node = new ClientNode(info.Place, info.RFID, eNodeStatus.EnterShelf);
log.Info("SendTo " + info.Place + " RFID=" + info.RFID + " " + eNodeStatus.EnterShelf);
byte[] buff = Encode(node);
return Send(idx, buff);
}
/// <summary>
/// 监听客户端
/// </summary>
private void ListenClient()
{
while (_loop)
{
try
{
Socket socket = _server.Accept(); //这边会暂停,不需要sleep
IPEndPoint ep = (IPEndPoint)socket.RemoteEndPoint;
Thread listen = new Thread(new ParameterizedThreadStart(ListenNet));
string ip = ep.Address.ToString();
if (ip == System.Configuration.ConfigurationManager.AppSettings["LocalIP"])
ip += ":" + ep.Port;
//新的客户端
Client client = new Client
{
IP = ip,
Loop = true,
IsConn = true,
Socket = socket,
ListenNet = listen,
nodeName = new List<string>(),
};
//重连后关闭旧连接
int idx = _client.FindIndex(s => s.IP.Equals(ip));
if (idx > -1)
{
_client[idx].IsConn = false;
_client[idx].nodeName.Clear();
_client[idx].Loop = false;
_client[idx].Socket.Close();
_client.RemoveAt(idx);
}
_client.Add(client);
listen.Start(_client.Count - 1);
log.Debug(string.Format("[{0}] 已连接", client.IP));
}
catch (SocketException)
{
//关闭连接,退出阻塞Accept
}
catch (Exception ex)
{
log.Error(ex);
}
}
}
/// <summary>
/// 客户端数据接收
/// </summary>
/// <param name="obj">索引</param>
private void ListenNet(object obj)
{
int sleep = 10;
Client client = _client[(int)obj];
byte[] temp = new byte[200];
int time = 0;
while (client.Loop)
{
Thread.Sleep(sleep);
try
{
if (!client.Loop) break;
if (client.Socket.Available > 0)
{
time = 0;
int count = client.Socket.Receive(temp);
byte[] buff = new byte[count];
Array.Copy(temp, 0, buff, 0, count);
ClientNode node = Decode(buff);
if (node == null)
{
log.Error("命令解析失败: " + HexBuff(buff));
}
else
{
//Common.log.Info("Receive[" + client.IP + "] " + node.ToText());
int idx = client.nodeName.FindIndex(s => s == node.Name);
if (idx == -1) client.nodeName.Add(node.Name);
UpdateNode(node);
}
}
else
{
time += sleep;
if (time > 10000)
{
Offline(client);
log.Info("[" + client.IP + "] 超过10s没有收到数据,关闭连接");
}
}
}
catch (Exception ex)
{
log.Error(ex);
}
}
}
/// <summary>
/// 编码
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
private byte[] Encode(ClientNode node)
{
byte[] name = System.Text.Encoding.UTF8.GetBytes(node.Name);
byte[] mark = System.Text.Encoding.UTF8.GetBytes(node.Mark);
byte[] rfid = System.Text.Encoding.UTF8.GetBytes(node.RFID);
int count = name.Length + mark.Length + rfid.Length + 7;
int idx = 0;
byte[] buff = new byte[count];
buff[idx++] = 0xAB;
buff[idx++] = Convert.ToByte(name.Length);
Array.Copy(name, 0, buff, idx, name.Length);
idx += name.Length;
buff[idx++] = Convert.ToByte(mark.Length);
Array.Copy(mark, 0, buff, idx, mark.Length);
idx += mark.Length;
buff[idx++] = Convert.ToByte(rfid.Length);
Array.Copy(rfid, 0, buff, idx, rfid.Length);
idx += rfid.Length;
buff[idx++] = (byte)node.GetState();
buff[idx++] = Convert.ToByte(node.Level);
buff[idx++] = 0xBA;
return buff;
}
/// <summary>
/// 解码
/// </summary>
/// <param name="buff"></param>
/// <returns></returns>
private ClientNode Decode(byte[] buff)
{
int idx = 0;
if (buff[idx++] != 0xAB) return null;
byte[] temp1 = new byte[buff[idx++]];
Array.Copy(buff, idx, temp1, 0, temp1.Length);
string name = System.Text.Encoding.UTF8.GetString(temp1);
idx += temp1.Length;
temp1 = new byte[buff[idx++]];
Array.Copy(buff, idx, temp1, 0, temp1.Length);
string mark = System.Text.Encoding.UTF8.GetString(temp1);
idx += temp1.Length;
temp1 = new byte[buff[idx++]];
Array.Copy(buff, idx, temp1, 0, temp1.Length);
string rfid = System.Text.Encoding.UTF8.GetString(temp1);
idx += temp1.Length;
eNodeStatus action = (eNodeStatus)buff[idx++];
ClientLevel level = (ClientLevel)buff[idx++];
ClientNode node = new ClientNode(name,rfid,action, mark,level);
if (buff[idx] != 0xBA)
return null;
return node;
}
private void UpdateNode(ClientNode node)
{
int idx = Common.nodeInfo.FindIndex(s => s.Name == node.Name);
if (idx == -1)
{
log.Error(node.Name + " 不存在");
return;
}
if (!Common.nodeInfo[idx].Online)
{
Common.nodeInfo[idx].Online = true;
NodeOnline?.Invoke(idx);
NodeChanged?.Invoke(idx);
}
if (Common.nodeInfo[idx].CheckNodeStateChanged(node))
{
log.Info( "节点状态更新 " + node.StatetText());
NodeChanged?.Invoke(idx);
}
}
private void Offline(Client client)
{
client.Loop = false;
client.IsConn = false;
client.Socket.Close();
for (int i = 0; i < client.nodeName.Count; i++)
{
int idx = AGVControl.Common.nodeInfo.FindIndex(s => s.Name == client.nodeName[i]);
if (idx == -1) continue;
AGVControl.Common.nodeInfo[idx].Offline();
NodeChanged(idx);
NodeOnline(idx);
}
client.nodeName.Clear();
}
private string HexBuff(byte[] buff)
{
string s = "";
if (buff == null) return s;
for (int i = 0; i < buff.Length; i++)
s += buff[i].ToString("X2") + " ";
return s;
}
/// <summary>
/// 查找客户端
/// </summary>
/// <param name="name">节点名称</param>
/// <returns></returns>
private int FindClient(string name)
{
int index = -1;
for (int i = 0; i < _client.Count; i++)
{
if (_client[i].IsConn)
{
int idx = _client[i].nodeName.FindIndex(a => a == name);
if (idx != -1)
{
index = i;
break;
}
}
}
return index;
}
/// <summary>
/// 发送命令
/// </summary>
/// <param name="idx"></param>
/// <param name="buff"></param>
/// <returns></returns>
private bool Send(int idx, byte[] buff)
{
for (int i = 1; i <= 3; i++)
{
try
{
_client[idx].Socket.Send(buff);
log.Debug("[" + _client[idx].IP + "] " + HexBuff(buff));
return true;
}
catch (Exception ex)
{
log.Error("发送失败" + i + "次:" + ex.Message);
}
Thread.Sleep(100);
}
return false;
}
private class Client
{
public bool Loop;
public string IP;
public bool IsConn;
public List<string> nodeName;
public Socket Socket;
public Thread ListenNet;
}
}
}
\ 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 AGVControl.BLL
{
public class Charge
{
/// <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;
/// <summary>
/// 自动充电
/// </summary>
private bool _autoCharge = true;
/// <summary>
/// 自动充电
/// </summary>
public bool AutoCharge
{
set
{
_autoCharge = value;
AppConfigHelper.SaveValue(SettingString.AutoCharge, value);
}
get
{
return _autoCharge;
}
}
public Charge()
{
Station = new Dictionary<string, string>();
Station.Add(AutoCharge1, "");
Station.Add(AutoCharge2, "");
_autoCharge = AppConfigHelper.GetBoolValue(SettingString.AutoCharge);
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>
/// 清除占用信息
/// </summary>
/// <param name="chargeName"></param>
/// <returns></returns>
public bool DelOccupyInfo(string agvName)
{
lock(loc)
{
if (Station.Values.Contains(agvName))
{
foreach (string item in Station.Keys)
{
if (Station[item].Equals(agvName))
{
Station[item] = "";
return true;
}
}
}
}
return false;
}
/// <summary>
/// 清除agv占用信息
/// </summary>
/// <param name="chargeName"></param>
/// <returns></returns>
public void DelOccupyInfoByAGV(Agv_Info agv)
{
lock(loc)
{
foreach (string item in Station.Keys)
{
if (Station[item].Equals(agv.Name))
{
Station[item] = "";
break;
}
}
}
}
public void ClearAllOccupyInfo()
{
lock(loc)
{
if (Station != null && Station.Count > 0)
{
foreach (var item in Station.Keys)
{
Station[item] = "";
}
}
}
}
public bool HasEmptyChargeStation()
{
lock(loc)
{
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 = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[chargeStation]);
if (rtn)
{
Station[chargeStation] = agv.Name;
agv.Place = SettingString.AutoCharge;
log = string.Format("{0} {1}", agv.Name, chargeStation);
Common.LogInfo(log);
Common.mir.State_Ready(agv);
}
else
{
Station[chargeStation] = "";
log = string.Format("{0} {1}失败", agv.Name, chargeStation);
Common.LogInfo(log);
}
return true;
}
}
}
return false;
}
}
}
using AGVControl.BLL;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Threading;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace AGVControl
{
/// <summary>
/// 公共参数
/// </summary>
public static class Common
{
/// <summary>
/// 节点信息
/// </summary>
public static List<ClientNode> nodeInfo;
/// <summary>
/// 任务类型
/// </summary>
public static List<JobType> jobTypeInfo;
/// <summary>
/// 小车信息
/// </summary>
public static List<Agv_Info> agvInfo;
public static System.Windows.Forms.TextBox logTextBox;
public static BLL.AgvServer server;
public static MiR.API mir;
public static log4net.ILog log;
public static Dictionary<string, string> agvMission;
public static Dictionary<string, string> showNameMissionName;
public static BLL.Control control;
private static List<string> msg = new List<string>();
private static string preLog = "";
public static readonly string CONFIG_PATH = AppDomain.CurrentDomain.BaseDirectory + "Config\\";
public static Charge Charge;
public static Standby Standby;
public static string ReadIni(string section, string key)
{
return IniHelper.ReadValue(section, key, CONFIG_PATH + SettingString.FileName_tempData);
}
public static void WriteIni(string section, string key, string value)
{
IniHelper.WriteValue(section, key, value, CONFIG_PATH + SettingString.FileName_tempData);
}
public static bool GetNodeNameByAliceName(string aliceName, out string nodeName)
{
nodeName = "";
int id = nodeInfo.FindIndex(s => s.AliceName.Equals(aliceName));
if (id > -1)
{
nodeName = nodeInfo[id].Name;
return true;
}
else
{
return false;
}
}
public static bool GetLineNameByNodeName(string nodeName, out string lineName)
{
lineName = "";
int id = nodeInfo.FindIndex(s => s.Name.Equals(nodeName));
if (id > -1)
{
lineName = nodeInfo[id].LineName;
return true;
}
else
{
return false;
}
}
/// <summary>
/// 查找节点是否存在以及是否调用
/// </summary>
/// <param name="nodeName">节点名称</param>
/// <returns></returns>
public static int FindNode(string nodeName)
{
int idx = Common.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.IsUse);
return idx;
}
/// <summary>
/// 移动到节点位置
/// </summary>
/// <param name="agv"></param>
/// <param name="nodeName"></param>
/// <returns></returns>
public static bool MoveToNode(Agv_Info agv, string nodeName)
{
string log;
//清除目的地
agv.Place = "";
//执行下一个任务
int i = FindNode(nodeName);
bool rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[SettingString.Move + nodeName]);
if (rtn)
{
agv.Place = nodeName;
if (i > -1)
log = string.Format("{0} {1} To Node {2} {3}", agv.Name, SettingString.Move, nodeName, Common.nodeInfo[i].GetState().ToString());
else
log = string.Format("{0} {1} To Node {2}", agv.Name, SettingString.Move, nodeName);
Common.LogInfo(log);
Common.mir.State_Ready(agv);
}
else
{
log = string.Format("{0} {1} To Node {2} 失败", agv.Name, SettingString.Move, nodeName);
Common.LogInfo(log);
}
return rtn;
}
/// <summary>
/// 移动到节点位置
/// </summary>
/// <param name="agv"></param>
/// <param name="nodeName"></param>
/// <returns></returns>
public static bool DockToNode(Agv_Info agv, string nodeName)
{
string log;
//清除目的地
agv.Place = "";
//执行下一个任务
bool rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[SettingString.Dock + nodeName]);
if (rtn)
{
agv.Place = nodeName;
log = string.Format("{0} {1} To Node {2}", agv.Name, SettingString.Dock, nodeName);
Common.LogInfo(log);
Common.mir.State_Ready(agv);
}
else
{
log = string.Format("{0} {1} To Node {2} 失败", agv.Name, SettingString.Dock, nodeName);
Common.LogInfo(log);
}
return rtn;
}
public static bool DoorMission(Agv_Info agv, string doorName)
{
agv.Place = doorName;
return Common.mir.Add_Mission_Fleet(agv, Common.agvMission[SettingString.Move + doorName]);
}
/// <summary>
/// 检查当前移动任务是否结束
/// </summary>
/// <param name="taskName">任务名称</param>
/// <param name="taskGUID">任务GUID</param>
/// <returns></returns>
public static bool CheckTaskMoveFinished(Agv_Info agv, string nodeName, string curTaskState)
{
log.Debug(agv.Name + " 检查当前任务是否结束: " + SettingString.Move + nodeName + " " + curTaskState);
return Common.agvMission[SettingString.Move + nodeName].Equals(agv.CurTaskGUID) && curTaskState.Equals(SettingString.Done);
}
/// <summary>
/// 检查当前停靠任务是否结束
/// </summary>
/// <param name="taskName">任务名称</param>
/// <param name="taskGUID">任务GUID</param>
/// <returns></returns>
public static bool CheckTaskDockFinished(Agv_Info agv, string nodeName, string curTaskState)
{
log.Debug(agv.Name + " 检查当前任务是否结束: " + SettingString.Dock + nodeName + " " + curTaskState);
return Common.agvMission[SettingString.Dock + nodeName].Equals(agv.CurTaskGUID) && curTaskState.Equals(SettingString.Done);
}
/// <summary>
/// 检查充电任务是否分配完成
/// </summary>
/// <param name="taskName"></param>
/// <returns></returns>
public static bool CheckTaskFinished(Agv_Info agv, string taskName)
{
return taskName.Contains(SettingString.AutoCharge) && agv.CurTaskState.Equals(SettingString.Executing);
}
public static bool CheckEnterOrLeaveFinished(Agv_Info agv, string actionName, string curTaskState)
{
log.Debug(agv.Name + " 检查进出料是否结束: " + actionName + " " + curTaskState);
return Common.agvMission[actionName].Equals(agv.CurTaskGUID) && curTaskState.Equals(SettingString.Done);
}
/// <summary>
/// 判断电量是否够执行任务,默认20
/// </summary>
/// <param name="agv"></param>
/// <returns></returns>
public static bool CheckCanExecuteMission(Agv_Info agv, int threshold = 20)
{
if (agv.Battery <= threshold)
{
Common.log.Debug(agv.Name + " 电量小于20%,不执行任务,等待充电");
return false;
}
return true;
}
/// <summary>
/// 判断小车是否空闲(充电/待机位)
/// </summary>
/// <param name="agv"></param>
/// <returns></returns>
public static bool CheckAGVStatusNone(Agv_Info agv)
{
if ((agv.CurJob == null || agv.CurJob is ChargeJob || agv.CurJob is StandyJob) && !agv.IsExistShelf)
return true;
else
return false;
}
public static void LogInfo(string text, bool isShow = true)
{
if (logTextBox == null) return;
if (logTextBox.InvokeRequired)
{
logTextBox.Invoke(new Action(() => LogInfo(text, isShow)));
return;
}
if (preLog.Equals(text))//连续重复的日志只打印一次
return;
preLog = text;
if (msg.Count > 255)
{
msg.RemoveRange(0, 10);
}
log.Info(text);
string tmpStr = "";
if (isShow)
{
msg.Add(string.Format("[{0}] {1}\r\n", DateTime.Now.ToString("HH:mm:ss"), text));
msg.ForEach(s => tmpStr += s);
logTextBox.Text = tmpStr;
//logTextBox.AppendText(string.Format("[{0}] {1}\r\n", DateTime.Now.ToString("HH:mm:ss"), text));
//logTextBox.ScrollToCaret();
}
}
/// <summary>
/// 获取Job任务状态
/// </summary>
/// <param name="CurTaskID"></param>
/// <returns></returns>
public static string GetTakJobState(int CurTaskID)
{
if (!CurTaskID.Equals(-1) && Common.mir.Get_Task_State(CurTaskID, out string st))
return st;
return SettingString.Wait;
}
}
public static class API
{
[DllImport("user32.dll", EntryPoint = "ShowWindow", CharSet = CharSet.Auto)]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("user32.dll ", SetLastError = true)]
public static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab);
public const int SW_RESTORE = 9;
}
/// <summary>
/// 客户端
/// </summary>
public class Client
{
/// <summary>
/// 循环
/// </summary>
public bool Loop;
/// <summary>
/// IP地址
/// </summary>
public string IP;
/// <summary>
/// 是否连接
/// </summary>
public bool IsConn;
/// <summary>
/// 节点名称集合
/// </summary>
public List<string> nodeName;
/// <summary>
/// 套接字
/// </summary>
public Socket Socket;
/// <summary>
/// 接收数据线程
/// </summary>
public Thread ListenNet;
}
}
\ No newline at end of file \ No newline at end of file
using System;
using System.Collections.Generic;
using System.Drawing.Text;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using AGVControl;
using AGVControl.bean.jobType;
using AGVControl_SMD_BOX.BLL;
using log4net.Util;
using MiR;
using RestSharp;
namespace AGVControl.BLL
{
public class Control
{
private System.Timers.Timer AgvCallTimer;
private System.Timers.Timer AgvStateTimer;
public delegate void AgvChangedEvent(int agvIndex);
public delegate void AgvMissionEvent();
public event AgvChangedEvent AgvChanged;
public event AgvChangedEvent AgvOnline;
/// <summary>
/// 限制区域
/// </summary>
public ScopeLimit limitArea;
/// <summary>
/// 获取任务打开
/// </summary>
public static bool OpenGetJob = true;
public Control()
{
AgvCallTimer = new System.Timers.Timer
{
Interval = 500,
AutoReset = true,
Enabled = false
};
AgvCallTimer.Elapsed += AgvCallTimer_Elapsed;
AgvStateTimer = new System.Timers.Timer
{
Interval = 5000,
AutoReset = true,
Enabled = false
};
AgvStateTimer.Elapsed += AgvStateTimer_Elapsed;
string[] limitPoints = AppConfigHelper.GetValue(SettingString.LimitPoints).Split(';');
List<Agv_Info.clsPosition> clsPositions = new List<Agv_Info.clsPosition>();
string[] s1;
for (int i = 0; i < limitPoints.Length; i++)
{
s1 = limitPoints[i].Split(',');
clsPositions.Add(new Agv_Info.clsPosition(double.Parse(s1[0]), double.Parse(s1[1])));
}
limitArea = new AGVControl_SMD_BOX.BLL.ScopeLimit(clsPositions);
}
public void Start()
{
AgvCallTimer.Enabled = true;
AgvStateTimer.Enabled = true;
AgvCallTimer.Start();
AgvStateTimer.Start();
}
public void Stop()
{
AgvCallTimer.Enabled = false;
AgvStateTimer.Enabled = false;
AgvCallTimer.Stop();
AgvStateTimer.Stop();
}
private bool AgvStateInProcess = false;
private void AgvStateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
bool rtn;
if (AgvStateInProcess) return;
AgvStateInProcess = true;
for (int i = 0; i < Common.agvInfo.Count; i++)
{
try
{
// if (!CheckOnline(i)) continue;
CheckOnline(i);
bool change = false;
Common.mir.Get_Task_State(Common.agvInfo[i].CurTaskID, out string stateStr);
Thread.Sleep(50);
//获取AGV状态
rtn = Common.mir.Get_State(Common.agvInfo[i], out eAGVState stateID, out string stateText, out int battery, out string mission_text, out Agv_Info.clsPosition position);
Thread.Sleep(50);
rtn = Common.mir.Get_IO_Status(Common.agvInfo[i], out bool[] input, out bool[] output);
Thread.Sleep(50);
change = Common.agvInfo[i].SetState(stateID, stateStr, battery, mission_text, position);
//更新状态stateID.Equals(eAGVState.Executing)
if (change)
{
AgvChanged?.Invoke(i);
}
}
catch (Exception ex)
{
Common.log.Error("AgvStateTimer_" + Common.agvInfo[i].Name + ex.Message + ex.StackTrace);
}
}
AgvStateInProcess = false;
}
private static object lockGetObj = new object();
/// <summary>
/// 获取任务
/// </summary>
/// <param name="agv_Info"></param>
/// <returns></returns>
public Job GetJob(Agv_Info agv_Info)
{
lock(lockGetObj)
{
foreach (JobType find in Common.jobTypeInfo)
{
Job job = null;
if (OpenGetJob)
{
job = find.GetNewJob(agv_Info);
if (job != null)
{
Common.log.Debug(agv_Info.Name + " GetJob OK " + job.ToString());
return job;
}
}
}
}
return null;
}
private bool AgvCallInProcess = false;
private void AgvCallTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (AgvCallInProcess) return;
AgvCallInProcess = true;
for (int i = 0; i < Common.agvInfo.Count; i++)
{
try
{
Agv_Info agv = Common.agvInfo[i];
if (!agv.IsCon) continue; //AGV网络连接
if (!Common.agvInfo[i].IsUse) continue; //AGV是否可用
//Ready,Pause,Executing,Error
if (!Common.agvInfo[i].StateID.Equals(eAGVState.Ready) && !Common.agvInfo[i].StateID.Equals(eAGVState.Pause)
&& !Common.agvInfo[i].StateID.Equals(eAGVState.Executing) && !Common.agvInfo[i].StateID.Equals(eAGVState.Error))
{
Common.log.Error(Common.agvInfo[i].Name + " 不可调用 StateID=" + Common.agvInfo[i].StateID.ToString());
continue;
}
if (agv.CurJob == null)
{
Job job = GetJob(agv);
if (job != null)
{
agv.CurJob = job;
}
}
if (agv.CurJob != null)
{
agv.CurJob = agv.CurJob.Execute(agv);
}
}
catch (Exception ex)
{
Common.log.Error("AgvCall " + ex.Message + ex.StackTrace);
}
}
AgvCallInProcess = false;
}
private bool CheckOnline(int idx)
{
bool rtn = Common.mir.CheckIP(Common.agvInfo[idx].IP);
if (rtn)
{
if (Common.agvInfo[idx].IsCon)
{
Common.log.Debug(Common.agvInfo[idx].Name + " Online");
}
else
{
Common.agvInfo[idx].IsCon = true;
Common.LogInfo(Common.agvInfo[idx].Name + " Online");
AgvOnline?.Invoke(idx);
AgvChanged?.Invoke(idx);
}
}
else
{
if (Common.agvInfo[idx].IsCon)
{
Common.agvInfo[idx].IsCon = false;
Common.LogInfo(Common.agvInfo[idx].Name + " Offline");
AgvOnline?.Invoke(idx);
AgvChanged?.Invoke(idx);
}
else
{
Common.log.Debug(Common.agvInfo[idx].Name + " Offline");
}
}
return rtn;
}
}
}
\ No newline at end of file \ No newline at end of file
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
namespace AGVControl
{
public class IniHelper
{
[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);
[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);
}
}
public class AppConfigHelper
{
public static System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
public static string GetValue(string key)
{
if (config.AppSettings.Settings[key] == null)
{
Common.log.Error("未找到配置:" + 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)
{
Common.log.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)
{
Common.log.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)
{
Common.log.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)
{
Common.log.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)
{
Common.log.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)
{
Common.log.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;
using MiR;
using AGVControl;
namespace AGVControl
{
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);
//Common.LogInfo(result);
}
catch (Exception e)
{
Common.log.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
{
Common.log.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();
Common.log.Debug("receive << " + result);
return result;
}
}
catch (Exception e)
{
Common.log.Error("HTTP GET ERROR:" + e.Message);
}
return "";
}
}
}
\ No newline at end of file \ No newline at end of file
using AGVControl;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
namespace AGVControl
{
/// <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 = Common.CONFIG_PATH + fileName + ".json";
string output = JsonConvert.SerializeObject(ts,Formatting.Indented);
File.WriteAllText(path, output);
}
catch (Exception e)
{
Common.log.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 = Common.CONFIG_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)
{
Common.log.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.Web.Script.Serialization;
using AGVControl;
using Microsoft.SqlServer.Server;
using RestSharp;
namespace MiR
{
public class API
{
private const int httpTimeout = 5000;
private static log4net.ILog log = log4net.LogManager.GetLogger("MiR_API");
public API()
{
}
public bool IsDebug { get; set; } = false;
/// <summary>
/// 获取IO模块guid列表
/// </summary>
/// <param name="info"></param>
/// <param name="guid"></param>
/// <returns></returns>
public bool Get_IO_Modules(AGVControl.Agv_Info info, out string[] guid)
{
try
{
guid = null;
string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text";
string json = HttpGet(url, info.IP, info.Authorization);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
object[] obj = (object[])serializer.DeserializeObject(json);
if (obj == null)
{
log.Error("URL: " + url + "\n" + "Return: " + json);
return false;
}
guid = new string[obj.Length];
for (int i = 0; i < obj.Length; i++)
{
Dictionary<string, object> dic = (Dictionary<string, object>)obj[i];
guid[i] = dic["guid"].ToString();
}
log.Info("URL: " + url + "\n" + "Return: " + json);
return true;
}
catch (Exception ex)
{
guid = null;
log.Error("Get_IO_Modules", ex);
return false;
}
}
/// <summary>
/// 获取IO模块的状态
/// </summary>
/// <param name="info"></param>
/// <param name="input"></param>
/// <param name="output"></param>
/// <returns></returns>
public bool Get_IO_Status(Agv_Info info, out bool[] input, out bool[] output)
{
try
{
input = null;
output = null;
string url = "http://" + info.IP + "/api/v2.0.0/io_modules/" + info.IOID + "/status";
string json = HttpGet(url, info.IP, info.Authorization);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null)
{
log.Error("URL: " + url + "\n" + "Return: " + json);
return false;
}
object[] objInput = (object[])dic["input_state"];
input = new bool[objInput.Length];
for (int i = 0; i < input.Length; i++)
input[i] = Convert.ToBoolean(objInput[i]);
object[] objOutput = (object[])dic["output_state"];
output = new bool[objOutput.Length];
for (int i = 0; i < output.Length; i++)
output[i] = Convert.ToBoolean(objOutput[i]);
return true;
}
catch (Exception ex)
{
input = null;
output = null;
//log.Error("Get_IO_Status", ex);
return false;
}
}
/// <summary>
/// 获取PLC寄存器的内容
/// </summary>
/// <param name="info"></param>
/// <param name="reg"></param>
/// <param name="regValue"></param>
/// <returns></returns>
public bool Get_Register(Agv_Info info, int reg, out int regValue)
{
try
{
regValue = -1;
string url = "http://" + info.IP + "/api/v2.0.0/registers/" + reg + "?whitelist=value";
string json = HttpGet(url, info.IP, info.Authorization);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null)
{
log.Error("URL: " + url + "\n" + "Return: " + json);
return false;
}
string s = dic["value"].ToString();
float f = Convert.ToSingle(s);
regValue = Convert.ToInt32(f);
return true;
}
catch (Exception ex)
{
regValue = -1;
log.Error("Get_Register", ex);
return false;
}
}
/// <summary>
/// 设置PLC寄存器的内容
/// </summary>
/// <param name="info"></param>
/// <param name="reg"></param>
/// <param name="regValue"></param>
/// <returns></returns>
public bool Set_Register(Agv_Info info, int reg, int regValue)
{
try
{
string url = "http://" + info.IP + "/api/v2.0.0/registers/" + reg;
string body = "{\"value\": " + regValue + "}";
string json = HttpPost(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null)
{
log.Error("URL: " + url + "\n" + "Return: " + json);
return false;
}
string s = dic["value"].ToString();
float f = Convert.ToSingle(s);
if (regValue == Convert.ToInt32(f))
return true;
else
return false;
}
catch (Exception ex)
{
log.Error("Set_Register", ex);
return false;
}
}
/// <summary>
/// 添加任务到任务队列
/// </summary>
/// <param name="info"></param>
/// <param name="mission_id"></param>
/// <returns></returns>
public bool Add_Mission(Agv_Info info, string mission_id, bool isRemovePreMission = true)
{
try
{
Common.LogInfo(string.Format("{0} Add_Mission [{1}]", info.Name, mission_id));
//删除上一任务
Del_Mission(info);
string url = "http://" + info.IP + "/api/v2.0.0/mission_queue";
string body = "{\"mission_id\":\"" + mission_id + "\"}";
string json = HttpPost(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null)
{
return false;
}
log.Info("URL: " + url + "\n" + "Return: " + json);
string s = dic["mission_id"].ToString();
string id = dic["id"].ToString();
if (s == mission_id)
{
try
{
info.CurTaskID = Convert.ToInt32(id);
info.CurTaskGUID = mission_id;
var key = Common.agvMission.Where(qq => qq.Value == mission_id).Select(qq => qq.Key);
info.CurTaskName = key.ToList()[0];
log.Info(string.Format("{0} Add_Mission [{1}]", info.Name, key.ToList()[0]));
}
catch
{
log.Info(string.Format("{0} Add_Mission [{1}]", info.Name, mission_id));
info.CurTaskName = "";
}
return true;
}
else
return false;
}
catch (Exception ex)
{
log.Error("Add_Mission", ex);
return false;
}
}
/// <summary>
/// 添加任务到任务队列
/// </summary>
/// <param name="info"></param>
/// <param name="mission_id"></param>
/// <returns></returns>
public bool Add_Mission_Fleet(Agv_Info info, string mission_id, bool isRemovePreMission = true)
{
try
{
info.CurTaskID = -1;
info.CurTaskGUID = "";
info.CurTaskState = SettingString.Wait;
//防止上一个任务已执行但返回失败时,删除任务
Del_Mission(info);
string ip = AppConfigHelper.GetValue(SettingString.FLEET);
string url = "http://" + ip + "/api/v2.0.0/mission_scheduler";
string body = "{\"mission_id\":\"" + mission_id + "\",\"robot_id\":" + info.ID + "}";
string json = HttpPost(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null)
{
return false;
}
log.Info("URL: " + url + "\n" + "Return: " + json);
string s = dic["mission_id"].ToString();
string id = dic["id"].ToString();
if (s == mission_id)
{
try
{
info.CurTaskID = Convert.ToInt32(id);
info.CurTaskGUID = mission_id;
var key = Common.agvMission.Where(qq => qq.Value == mission_id).Select(qq => qq.Key);
info.CurTaskName = key.ToList()[0];
log.Info(string.Format("{0} Add_Mission_Fleet [{1}]", info.Name, key.ToList()[0]));
}
catch
{
log.Info(string.Format("{0} Add_Mission_Fleet [{1}]", info.Name, mission_id));
info.CurTaskName = "";
}
return true;
}
else
return false;
}
catch (Exception ex)
{
log.Error("Add_Mission_Fleet", ex);
return false;
}
}
/// <summary>
/// 获取所有任务列表
/// </summary>
/// <param name="info"></param>
/// <param name="mission">任务(名称,guid)</param>
/// <returns></returns>
public bool Get_Mission(Agv_Info info, out Dictionary<string, string> mission)
{
mission = null;
try
{
string url = "http://" + info.IP + "/api/v2.0.0/missions/search?whitelist=guid,name";
string body = "{\"filters\" :[]}";
string json = HttpPost(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
object[] obj = (object[])serializer.DeserializeObject(json);
if (obj == null) return false;
mission = new Dictionary<string, string>();
for (int i = 0; i < obj.Length; i++)
{
Dictionary<string, object> dic = (Dictionary<string, object>)obj[i];
mission.Add(dic["name"].ToString(), dic["guid"].ToString());
}
return true;
}
catch (Exception ex)
{
log.Error("Get_Mission", ex);
return false;
}
}
/// <summary>
/// 获取当前任务队列guid
/// </summary>
/// <param name="info"></param>
/// <param name="mission"></param>
/// <returns></returns>
public bool Get_Mission_Queue(Agv_Info info, out List<string> mission)
{
mission = null;
try
{
string url = "http://" + info.IP + "/api/v2.0.0/mission_queue/search";
string body = "{\"filters\" : [{\"fieldname\": \"state\", \"operator\": \"IN\", \"value\": [\"Pending\", \"Executing\"]}]}";
string json = HttpPost(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
object[] obj = (object[])serializer.DeserializeObject(json);
if (obj == null) return false;
mission = new List<string>();
Dictionary<string, object> dic;
for (int i = 0; i < obj.Length; i++)
{
dic = (Dictionary<string, object>)obj[i];
mission.Add(dic["id"].ToString());
}
for (int i = 0; i < mission.Count; i++)
{
url = "http://" + info.IP + "/api/v2.0.0/mission_queue/" + mission[i];
json = HttpGet(url, info.IP, info.Authorization);
serializer = new JavaScriptSerializer();
dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
mission[i] = dic["mission_id"].ToString();
}
return true;
}
catch (Exception ex)
{
log.Error("Get_Mission_Queue", ex);
return false;
}
}
/// <summary>
/// 删除当前所有任务
/// </summary>
/// <param name="info"></param>
public void Del_Mission(Agv_Info info)
{
try
{
string url = "http://" + info.IP + "/api/v2.0.0/mission_queue";
HttpDel(url, info.IP, info.Authorization);
}
catch (Exception ex)
{
log.Error("Del_Mission", ex);
}
}
/// <summary>
/// 删除Fleet尽快中指定id的任务,已运行的无法删除
/// </summary>
/// <param name="authorization"></param>
/// <param name="id"></param>
public void Del_Mission_Fleet(Agv_Info agv, string id)
{
try
{
string ip = AppConfigHelper.GetValue(SettingString.FLEET);
string url = "http://" + ip + "/api/v2.0.0/mission_scheduler/" + id;
HttpDel(url, ip, agv.Authorization);
}
catch (Exception ex)
{
log.Error(ex);
}
}
/// <summary>
/// 获取当前小车状态
/// </summary>
/// <param name="info"></param>
/// <param name="stateID"></param>
/// <param name="stateText"></param>
/// <param name="battery"></param>
/// <param name="mission_text"></param>
/// <returns></returns>
public bool Get_State(Agv_Info info, out eAGVState stateID, out string stateText, out int battery, out string mission_text, out Agv_Info.clsPosition position)
{
stateID = eAGVState.UNKNOWN;
stateText = "";
battery = 0;
mission_text = "";
position = new Agv_Info.clsPosition();
try
{
string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage,mission_text,position";
string json = HttpGet(url, info.IP, info.Authorization);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null) return false;
//state_id不存在:{"args":{},"error_code":"service_unavailable","error_human":"\u670d\u52a1\u4e0d\u53ef\u7528\uff0c\u8bf7\u7a0d\u540e\u91cd\u8bd5"}
try
{
stateID = (eAGVState)(Convert.ToInt32(dic["state_id"].ToString()));
}
catch
{
log.Error("Get_State URL:" + url + " Return" + json);
return false;
}
stateID = (eAGVState)(Convert.ToInt32(dic["state_id"].ToString()));
stateText = dic["state_text"].ToString();
mission_text = dic["mission_text"].ToString();
string s = dic["battery_percentage"].ToString();
float f = Convert.ToSingle(s);
battery = Convert.ToInt32(f);
Dictionary<string, object> posDic = (Dictionary<string, object>)dic["position"];
if (posDic == null) return false;
position.orientation = Convert.ToDouble(posDic["orientation"].ToString());
position.x = Convert.ToDouble(posDic["x"]);
position.y = Convert.ToDouble(posDic["y"]);
return true;
}
catch (Exception ex)
{
log.Error("Get_State: ", ex);
return false;
}
}
/// <summary>
/// 获取小车位置
/// </summary>
/// <param name="ip">小车ip</param>
/// <param name="author">授权码</param>
/// <param name="position">输出位置</param>
/// <returns></returns>
public bool Get_Position(string ip,string author, out Agv_Info.clsPosition position)
{
position = new Agv_Info.clsPosition();
try
{
string url = "http://" + ip + "/api/v2.0.0/status?whitelist=position";
string json = HttpGet(url, ip,author);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null) return false;
Dictionary<string, object> posDic = (Dictionary<string, object>)dic["position"];
if (posDic == null) return false;
position.orientation = Convert.ToDouble(posDic["orientation"].ToString());
position.x = Convert.ToDouble(posDic["x"]);
position.y = Convert.ToDouble(posDic["y"]);
return true;
}
catch (Exception ex)
{
log.Error("Get_Position: ", ex);
return false;
}
}
public bool Get_Task_State(int CurTaskID, out string stateStr)
{
stateStr = SettingString.Wait;
try
{
if (CurTaskID == -1)
return true;
string ip = AppConfigHelper.GetValue(SettingString.FLEET);
//http://10.85.199.3/api/v2.0.0/mission_scheduler
string url = "http://" + ip + "/api/v2.0.0/mission_scheduler/" + CurTaskID;
string json = HttpGet(url, ip, Common.agvInfo[0].Authorization);
Common.log.Debug("URL: " + url + "\n" + "Return: " + json);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null) return false;
// "mission_id": "2e433130-c045-11ea-9a66-94c691a7387d",
// "id": 7178,
// "state": "Done"
string s = dic["id"].ToString();
if (s.Equals(CurTaskID.ToString()))
{
stateStr = dic["state"].ToString();
return true;
}
return false;
}
catch (Exception ex)
{
log.Error("Get_Task_State", ex);
return false;
}
}
/// <summary>
/// 小车状态改为Ready
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
public bool State_Ready(Agv_Info info)
{
try
{
string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text";
string body = "{\"state_id\": 3}";
string json = HttpPut(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null) return false;
string s = dic["state_id"].ToString();
if (s == "3")
return true;
else
return false;
}
catch (Exception ex)
{
log.Error("State_Ready", ex);
return false;
}
}
/// <summary>
/// 小车状态改为Pause
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
public bool State_Pause(Agv_Info info)
{
try
{
string url = "http://" + info.IP + "/api/v2.0.0/status?whitelist=state_id,state_text";
string body = "{\"state_id\": 4}";
string json = HttpPut(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null) return false;
string s = dic["state_id"].ToString();
if (s == "4")
return true;
else
return false;
}
catch (Exception ex)
{
log.Error("State_Pause", ex);
return false;
}
}
/// <summary>
/// 清除错误
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
public bool Clear_Error(Agv_Info info)
{
try
{
string url = "http://" + info.IP + "/api/v2.0.0/status";
string body = "{\"clear_error\": true}";
string json = HttpPut(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
return true;
}
catch (Exception ex)
{
log.Error("Clear_Error", ex);
return false;
}
}
/// <summary>
/// 检查IP地址
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public bool CheckIP(string ip)
{
//IP合法
string pattern = @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$";
bool rtn = System.Text.RegularExpressions.Regex.IsMatch(ip, pattern);
if (!rtn)
{
log.Error("非法的IP地址" + ip);
return false;
}
//Ping服务端
try
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingReply result = ping.Send(ip, 2000);
ping.Dispose();
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
{
log.Error("Ping " + ip + " 请求没有响应");
return false;
}
return true;
}
catch (Exception ex)
{
log.Error("CheckIP", ex);
return false;
}
}
private string HttpGet(string url, string ip, string authorization)
{
RestClient client = new RestClient(url) { Timeout = httpTimeout };
RestRequest request = new RestRequest(Method.GET);
request.AddHeader("Host", ip);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept-Language", "zh_CN");
request.AddHeader("Authorization", authorization);
IRestResponse response = client.Execute(request);
string s = response.Content;
s = s.Replace("\n", "");
s = s.Replace(" ", "");
if (IsDebug)
log.Debug("HttpGet URL: " + url + " Return: " + s);
return s;
}
private string HttpPost(string url, string ip, string authorization, string body)
{
var client = new RestClient(url) { Timeout = httpTimeout };
var request = new RestRequest(Method.POST);
request.AddHeader("Host", ip);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept-Language", "zh_CN");
request.AddHeader("Authorization", authorization);
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
string s = response.Content;
s = s.Replace("\n", "");
s = s.Replace(" ", "");
if (IsDebug)
log.Debug(string.Format("HttpPost URL: {0}; Body: {1} Return: {2}", url, body, s));
return s;
}
private string HttpPut(string url, string ip, string authorization, string body)
{
RestClient client = new RestClient(url) { Timeout = httpTimeout };
RestRequest request = new RestRequest(Method.PUT);
request.AddHeader("Host", ip);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept-Language", "zh_CN");
request.AddHeader("Authorization", authorization);
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
string s = response.Content;
s = s.Replace("\n", "");
s = s.Replace(" ", "");
if (IsDebug)
log.Debug(string.Format("HttpPut URL: {0}; Body: {1} Return: {2}", url, body, s));
return s;
}
private void HttpDel(string url, string ip, string authorization)
{
RestClient client = new RestClient(url) { Timeout = httpTimeout };
RestRequest request = new RestRequest(Method.DELETE);
request.AddHeader("Host", ip);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", authorization);
request.AddHeader("Accept-Language", "zh_CN");
request.AddParameter("application/json", "", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
string s = response.Content;
if (IsDebug)
log.Debug("HttpDel URL: " + url);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
namespace MiR
{
public class MyWebClient:WebClient
{
private int _timeout;
/// <summary>
/// 超时时间(毫秒)
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public MyWebClient()
{
this._timeout = 60000;
}
public MyWebClient(int timeout)
{
this._timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
var result = base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using AGVControl;
namespace AGVControl_SMD_BOX.BLL
{
public class ScopeLimit
{
List<string> agvIPs;
//不规则图像坐标
List<Agv_Info.clsPosition> 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.clsPosition> 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 = Common.mir.Get_Position(ip, Common.agvInfo[0].Authorization, out Agv_Info.clsPosition 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.clsPosition checkPoint, List<Agv_Info.clsPosition> polygonPoints)
{
bool inside = false;
int pointCount = polygonPoints.Count;
Agv_Info.clsPosition 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;
using System.Windows.Forms;
namespace AGVControl
{
public static class SettingString
{
public const int AGVCNT = 4;
public const string Move = "Move";
public const string Dock = "Dock";
//任务名称
public const string Standby = "Standby";
public const string CheckShelf = "CheckShelf";
public const string DoorDToC = "DoorDToC";
public const string DoorCToD = "DoorCToD";
public const string Wait = "Wait";
public const string Done = "Done";
public const string Aborted = "Aborted";
public const string Invalid = "Invalid";
public const string AutoCharge = "AutoCharge";
public const string Executing = "Executing";
public const string ChargeThreshold = "ChargeThreshold";
public const string SingleMission_IP1 = "10.85.199.67";
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 EmptyShelfCnt = "EmptyShelfCnt";
public const string FLEET = "FLEET";
/// <summary>
/// 包装料架RFID前缀
/// </summary>
public const string Packing_RFID_Prefix = "A";
public const string Packing_Box_Prefix = "B";
public const string ReelString_RFID_Prefix = "B";
public const string C4_STANDBY1 = "C4_STANDBY1";
public const string C4_STANDBY2 = "C4_STANDBY2";
public const string C4FeederIn = "C21";
public const string D4FeederIn = "D21";
/// <summary>
/// 退料线
/// </summary>
public const string G23_In = "G23";
public const string G24_Out = "G24";
/// <summary>
/// 上料区
/// </summary>
public const string A6 = "A6";
/// <summary>
/// 下料区
/// </summary>
public const string A5 = "A5";
public const string D4_Name_Prefix = "D";
public const string C4_Name_Prefix = "G";
public const string http_server = "http_server";
/// <summary>
/// 包装仓出空料架位置
/// </summary>
public const string A7 = "A7";
/// <summary>
/// 包装仓出空料架位置
/// </summary>
public const string A4 = "A4";
public const string A3 = "A3";
public const string Enter = "Enter";
public const string Leave = "Leave";
/// <summary>
/// 空料串接收位置
/// </summary>
public const string C7 = "C7";
public const string A2 = "A2";
public const string A8 = "A8";
/// <summary>
/// 出满料
/// </summary>
public const string C8 = "C8";
public const string A1 = "A1";
public const string InStore_Mark = "InStore";
/// <summary>
/// 入料口1
/// </summary>
public const string C5 = "C5";
public const string C6 = "C6";
/// <summary>
/// 入料口2
/// </summary>
public const string C3 = "C3";
public const string C4 = "C4";
/// <summary>
/// 入料口3
/// </summary>
public const string C1 = "C1";
public const string C2 = "C2";
/// <summary>
/// 点料机
/// </summary>
public const string D1 = "D1";
public const string D2 = "D2";
public const string D3 = "D3";
public const string D4 = "D4";
public const string LimitPoints = "LimitPoints";
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl.BLL
{
public class Standby
{
/// <summary>
/// 待机位
/// </summary>
public List<string> Station;
private const int Station_CNT = 4;
public Standby()
{
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];
}
}
}
文件属性发生变化
任务别称,任务名称,任务GUID
移动到VMI出口,MoveA1,eec1eed4-2a04-11ea-9c84-94c691a734f1
移动到VMI入口,MoveA2,f68f18db-2f89-11ea-9ee4-94c691a734f1
移动到包装线入口,MoveA3,979d10eb-2f9d-11ea-9ee4-94c691a734f1
移动到包装线出口,MoveA4,df6d991a-2f9d-11ea-9ee4-94c691a734f1
移动到分盘线出口,MoveA7,71e01c6d-de10-11ea-a3e4-94c691a7387d
移动到分盘线入口,MoveA8,cd0544f8-de10-11ea-a3e4-94c691a7387d
移动到包装仓10-1,MoveB1,86a6ab06-261e-11ea-a30e-94c691a73861
移动到包装仓10-2,MoveB2,55fcfdc5-2623-11ea-a30e-94c691a73861
移动到包装仓11-1,MoveB3,905399c8-2623-11ea-a30e-94c691a73861
移动到包装仓11-2,MoveB4,aa33e13a-2623-11ea-a30e-94c691a73861
移动到包装仓12-2,MoveB5,2cd36cde-2624-11ea-a30e-94c691a73861
移动到包装仓12-1,MoveB6,3e713e8b-2624-11ea-a30e-94c691a73861
停靠到包装仓10-1,DockB1,339d1830-261f-11ea-a30e-94c691a73861
停靠到包装仓10-2,DockB2,a6d6f52a-2624-11ea-a30e-94c691a73861
停靠到包装仓11-1,DockB3,b66f0714-2624-11ea-a30e-94c691a73861
停靠到包装仓11-2,DockB4,d01443f2-2624-11ea-a30e-94c691a73861
停靠到包装仓12-2,DockB5,f50dd02b-2624-11ea-a30e-94c691a73861
停靠到包装仓12-1,DockB6,0e5503f2-2625-11ea-a30e-94c691a73861
移动到料串入口C1,MoveC1,a6e36b4c-2fa0-11ea-9ee4-94c691a734f1
移动到料串出口C2,MoveC2,6c6829de-2624-11ea-a30e-94c691a73861
移动到料串入口C3,MoveC3,3ffe309f-2ae6-11ea-a6cf-94c691a734f1
移动到料串出口C4,MoveC4,2ef71347-2ae7-11ea-a6cf-94c691a734f1
移动到料串入口C5,MoveC5,34ec2f1f-2ae8-11ea-a6cf-94c691a734f1
移动到料串出口C6,MoveC6,52f37677-2f96-11ea-9ee4-94c691a734f1
移动到紧急入料口,MoveC7,bcd0e389-2ab7-11ea-a6cf-94c691a734f1
移动到紧急出料口,MoveC8,8a48301d-2624-11ea-a30e-94c691a73861
移动到点料机D1口,MoveD1,931f7c6c-a97d-11ea-b91f-94c691a7387d
移动到点料机D2口,MoveD2,ae09ca1e-a97f-11ea-b91f-94c691a7387d
移动到点料机D3口,MoveD3,97b77df3-edfb-11ea-a03e-94c691a7387d
移动到点料机D4口,MoveD4,37961cd0-edfd-11ea-a03e-94c691a7387d
移动到退料线入口,MoveG23,5dc60886-ee00-11ea-a03e-94c691a7387d
移动到退料线出口,MoveG24,9a965176-ee00-11ea-a03e-94c691a7387d
移动到待机位,MoveStandby,4eb9641a-3439-11ea-984a-94c691a734f1
移动到充电位1,AutoCharge1,9e1b33c0-2886-11ea-a0d6-94c691a734f1
移动到充电位2,AutoCharge2,d756f63d-2886-11ea-a0d6-94c691a734f1
小车进料,Enter,2eadcb87-239a-11ea-8343-94c691a73861
小车出料,Leave,80943220-239a-11ea-8343-94c691a73861
小车初始化,Init,cd51e039-34eb-11ea-b4fe-94c691a734f1
Fleet ID,agv名称,IP,授权码,IOID
1,1号车,10.85.199.67,Basic ZGlzdHJpYnV0b3I6NjJmMmYwZjFlZmYxMGQzMTUyYzk1ZjZmMDU5NjU3NmU0ODJiYjhlNDQ4MDY0MzNmNGNmOTI5NzkyODM0YjAxNA==,007615a5-2220-11ea-99f2-94c691a73b53
2,2号车,10.85.199.68,Basic ZGlzdHJpYnV0b3I6NjJmMmYwZjFlZmYxMGQzMTUyYzk1ZjZmMDU5NjU3NmU0ODJiYjhlNDQ4MDY0MzNmNGNmOTI5NzkyODM0YjAxNA==,007615a5-2220-11ea-99f2-94c691a73b53
3,3号车,10.85.199.69,Basic ZGlzdHJpYnV0b3I6NjJmMmYwZjFlZmYxMGQzMTUyYzk1ZjZmMDU5NjU3NmU0ODJiYjhlNDQ4MDY0MzNmNGNmOTI5NzkyODM0YjAxNA==,007615a5-2220-11ea-99f2-94c691a73b53
4,4号车,10.85.199.70,Basic ZGlzdHJpYnV0b3I6NjJmMmYwZjFlZmYxMGQzMTUyYzk1ZjZmMDU5NjU3NmU0ODJiYjhlNDQ4MDY0MzNmNGNmOTI5NzkyODM0YjAxNA==,007615a5-2220-11ea-99f2-94c691a73b53
\ No newline at end of file \ No newline at end of file
节点名,别名,佳世达线名
B1,packing-19,包装仓10-1
B2,packing-20,包装仓10-2
B3,packing-21,包装仓11-1
B4,packing-22,包装仓11-2
B5,packing-24,包装仓12-1
B6,packing-23,包装仓12-2
A1,A1,VMI-A1出口
A2,A2,VMI-A2入口
A3,A3,包装线-A3入口
A4,A4,包装线-A4出口
A7,A7,分盘线-A7出口
A8,A8,分盘线-A8入口
C1,C1,入料3-C1入口
C2,C2,入料3-C2出口
C3,C3,入料2-C3入口
C4,C4,入料2-C4出口
C5,C5,入料1-C5入口
C6,C6,入料1-C6出口
C7,C7,紧急料-C7入口
C8,C8,紧急料-C8出口
D1,D1,点料机-D1入口
D2,D2,点料机-D2出口
D3,D3,点料机-D3口
D4,D4,点料机-D4口
G23,G23,退料线入口
G24,G24,退料线出口
\ No newline at end of file \ No newline at end of file
文件属性发生变化
namespace AGVControl
{
partial class FrmMain
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain));
this.DgvAgv = new System.Windows.Forms.DataGridView();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column14 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column21 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column18 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column23 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column13 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column19 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column11 = new System.Windows.Forms.DataGridViewButtonColumn();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.DgvNode = new System.Windows.Forms.DataGridView();
this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column22 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column16 = new System.Windows.Forms.DataGridViewButtonColumn();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.TxtLog = new System.Windows.Forms.TextBox();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.btnWriteMarks = new System.Windows.Forms.Button();
this.btnGetMarks = new System.Windows.Forms.Button();
this.txtBoxMark = new System.Windows.Forms.TextBox();
this.groupBox8 = new System.Windows.Forms.GroupBox();
this.lblStandy4 = new System.Windows.Forms.Label();
this.lblStandy3 = new System.Windows.Forms.Label();
this.lblStandy2 = new System.Windows.Forms.Label();
this.lblStandy1 = new System.Windows.Forms.Label();
this.lblCharge2 = new System.Windows.Forms.Label();
this.lblCharge1 = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.chkBoxOpenMission = new System.Windows.Forms.CheckBox();
this.btnReSendTask = new System.Windows.Forms.Button();
this.BtnClearError = new System.Windows.Forms.Button();
this.BtnMissionReady = new System.Windows.Forms.Button();
this.BtnMissionPause = new System.Windows.Forms.Button();
this.BtnMissionAdd = new System.Windows.Forms.Button();
this.LstAgvPlace = new System.Windows.Forms.ListBox();
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel6 = new System.Windows.Forms.TableLayoutPanel();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.lblLimit = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.DgvAgv)).BeginInit();
this.tableLayoutPanel3.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.DgvNode)).BeginInit();
this.tabPage2.SuspendLayout();
this.tabPage3.SuspendLayout();
this.groupBox8.SuspendLayout();
this.groupBox2.SuspendLayout();
this.tableLayoutPanel4.SuspendLayout();
this.tableLayoutPanel6.SuspendLayout();
this.SuspendLayout();
//
// DgvAgv
//
this.DgvAgv.AllowUserToAddRows = false;
this.DgvAgv.AllowUserToDeleteRows = false;
this.DgvAgv.AllowUserToResizeColumns = false;
this.DgvAgv.AllowUserToResizeRows = false;
this.DgvAgv.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.DgvAgv.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.DgvAgv.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.DgvAgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.DgvAgv.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column1,
this.Column2,
this.Column4,
this.Column14,
this.Column21,
this.Column3,
this.Column18,
this.Column23,
this.Column13,
this.Column19,
this.Column11});
this.DgvAgv.Location = new System.Drawing.Point(3, 3);
this.DgvAgv.MultiSelect = false;
this.DgvAgv.Name = "DgvAgv";
this.DgvAgv.ReadOnly = true;
this.DgvAgv.RowHeadersVisible = false;
this.DgvAgv.RowHeadersWidth = 51;
this.DgvAgv.RowTemplate.Height = 23;
this.DgvAgv.Size = new System.Drawing.Size(1061, 125);
this.DgvAgv.TabIndex = 3;
this.DgvAgv.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DgvAgv_CellClick);
//
// Column1
//
this.Column1.HeaderText = "名称";
this.Column1.MinimumWidth = 6;
this.Column1.Name = "Column1";
this.Column1.ReadOnly = true;
this.Column1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column2
//
this.Column2.HeaderText = "IP";
this.Column2.MinimumWidth = 6;
this.Column2.Name = "Column2";
this.Column2.ReadOnly = true;
this.Column2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column4
//
this.Column4.HeaderText = "小车状态";
this.Column4.MinimumWidth = 6;
this.Column4.Name = "Column4";
this.Column4.ReadOnly = true;
this.Column4.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column14
//
this.Column14.HeaderText = "任务ID";
this.Column14.MinimumWidth = 6;
this.Column14.Name = "Column14";
this.Column14.ReadOnly = true;
this.Column14.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column21
//
this.Column21.HeaderText = "任务名称";
this.Column21.MinimumWidth = 6;
this.Column21.Name = "Column21";
this.Column21.ReadOnly = true;
this.Column21.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column3
//
this.Column3.HeaderText = "任务状态";
this.Column3.MinimumWidth = 6;
this.Column3.Name = "Column3";
this.Column3.ReadOnly = true;
this.Column3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column18
//
this.Column18.HeaderText = "目的地";
this.Column18.MinimumWidth = 6;
this.Column18.Name = "Column18";
this.Column18.ReadOnly = true;
this.Column18.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column23
//
this.Column23.HeaderText = "负载";
this.Column23.MinimumWidth = 6;
this.Column23.Name = "Column23";
this.Column23.ReadOnly = true;
this.Column23.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column13
//
this.Column13.HeaderText = "连接";
this.Column13.MinimumWidth = 6;
this.Column13.Name = "Column13";
this.Column13.ReadOnly = true;
this.Column13.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column19
//
this.Column19.HeaderText = "电量";
this.Column19.MinimumWidth = 6;
this.Column19.Name = "Column19";
this.Column19.ReadOnly = true;
this.Column19.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column11
//
this.Column11.HeaderText = "自动";
this.Column11.MinimumWidth = 6;
this.Column11.Name = "Column11";
this.Column11.ReadOnly = true;
//
// tableLayoutPanel3
//
this.tableLayoutPanel3.ColumnCount = 1;
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.Controls.Add(this.tabControl1, 0, 2);
this.tableLayoutPanel3.Controls.Add(this.tableLayoutPanel4, 0, 1);
this.tableLayoutPanel3.Controls.Add(this.DgvAgv, 0, 0);
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.RowCount = 3;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 30F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel3.Size = new System.Drawing.Size(1067, 656);
this.tableLayoutPanel3.TabIndex = 7;
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(3, 330);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(1061, 323);
this.tabControl1.TabIndex = 7;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.tableLayoutPanel2);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.tabPage1.Size = new System.Drawing.Size(1053, 297);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "节点状态";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.ColumnCount = 1;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel2.Controls.Add(this.DgvNode, 0, 0);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 1;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(1047, 291);
this.tableLayoutPanel2.TabIndex = 34;
//
// DgvNode
//
this.DgvNode.AllowUserToAddRows = false;
this.DgvNode.AllowUserToDeleteRows = false;
this.DgvNode.AllowUserToResizeColumns = false;
this.DgvNode.AllowUserToResizeRows = false;
this.DgvNode.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.DgvNode.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.DgvNode.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.DgvNode.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.DgvNode.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column6,
this.Column7,
this.Column10,
this.Column22,
this.Column9,
this.Column5,
this.Column16});
this.DgvNode.Location = new System.Drawing.Point(3, 3);
this.DgvNode.MultiSelect = false;
this.DgvNode.Name = "DgvNode";
this.DgvNode.ReadOnly = true;
this.DgvNode.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
this.DgvNode.RowHeadersVisible = false;
this.DgvNode.RowHeadersWidth = 50;
this.DgvNode.RowTemplate.Height = 23;
this.DgvNode.Size = new System.Drawing.Size(1041, 285);
this.DgvNode.TabIndex = 1;
this.DgvNode.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DgvNode_CellClick);
//
// Column6
//
this.Column6.FillWeight = 107.563F;
this.Column6.HeaderText = "地点";
this.Column6.MinimumWidth = 6;
this.Column6.Name = "Column6";
this.Column6.ReadOnly = true;
this.Column6.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column7
//
this.Column7.FillWeight = 107.563F;
this.Column7.HeaderText = "动作";
this.Column7.MinimumWidth = 6;
this.Column7.Name = "Column7";
this.Column7.ReadOnly = true;
this.Column7.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column10
//
this.Column10.FillWeight = 47.05883F;
this.Column10.HeaderText = "等级";
this.Column10.MinimumWidth = 6;
this.Column10.Name = "Column10";
this.Column10.ReadOnly = true;
this.Column10.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column22
//
this.Column22.FillWeight = 107.563F;
this.Column22.HeaderText = "Mark";
this.Column22.MinimumWidth = 6;
this.Column22.Name = "Column22";
this.Column22.ReadOnly = true;
this.Column22.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column9
//
this.Column9.FillWeight = 107.563F;
this.Column9.HeaderText = "RFID";
this.Column9.MinimumWidth = 6;
this.Column9.Name = "Column9";
this.Column9.ReadOnly = true;
this.Column9.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column5
//
this.Column5.FillWeight = 107.563F;
this.Column5.HeaderText = "连接";
this.Column5.MinimumWidth = 6;
this.Column5.Name = "Column5";
this.Column5.ReadOnly = true;
this.Column5.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column16
//
this.Column16.FillWeight = 107.563F;
this.Column16.HeaderText = "调用";
this.Column16.MinimumWidth = 6;
this.Column16.Name = "Column16";
this.Column16.ReadOnly = true;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.TxtLog);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(1053, 296);
this.tabPage2.TabIndex = 3;
this.tabPage2.Text = "日志";
this.tabPage2.UseVisualStyleBackColor = true;
//
// TxtLog
//
this.TxtLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.TxtLog.Location = new System.Drawing.Point(0, 0);
this.TxtLog.Multiline = true;
this.TxtLog.Name = "TxtLog";
this.TxtLog.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.TxtLog.Size = new System.Drawing.Size(1053, 296);
this.TxtLog.TabIndex = 7;
//
// tabPage3
//
this.tabPage3.Controls.Add(this.chkBoxOpenMission);
this.tabPage3.Controls.Add(this.btnWriteMarks);
this.tabPage3.Controls.Add(this.btnGetMarks);
this.tabPage3.Controls.Add(this.txtBoxMark);
this.tabPage3.Controls.Add(this.groupBox8);
this.tabPage3.Controls.Add(this.groupBox2);
this.tabPage3.Controls.Add(this.BtnMissionAdd);
this.tabPage3.Controls.Add(this.LstAgvPlace);
this.tabPage3.Location = new System.Drawing.Point(4, 22);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.tabPage3.Size = new System.Drawing.Size(1053, 297);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "手动";
this.tabPage3.UseVisualStyleBackColor = true;
this.tabPage3.Click += new System.EventHandler(this.tabPage3_Click);
//
// btnWriteMarks
//
this.btnWriteMarks.Location = new System.Drawing.Point(506, 59);
this.btnWriteMarks.Name = "btnWriteMarks";
this.btnWriteMarks.Size = new System.Drawing.Size(68, 25);
this.btnWriteMarks.TabIndex = 40;
this.btnWriteMarks.Text = "写入Marks";
this.btnWriteMarks.UseVisualStyleBackColor = true;
this.btnWriteMarks.Click += new System.EventHandler(this.btnWriteMarks_Click);
//
// btnGetMarks
//
this.btnGetMarks.Location = new System.Drawing.Point(506, 20);
this.btnGetMarks.Name = "btnGetMarks";
this.btnGetMarks.Size = new System.Drawing.Size(68, 25);
this.btnGetMarks.TabIndex = 39;
this.btnGetMarks.Text = "获取Marks";
this.btnGetMarks.UseVisualStyleBackColor = true;
this.btnGetMarks.Click += new System.EventHandler(this.btnGetMarks_Click);
//
// txtBoxMark
//
this.txtBoxMark.Location = new System.Drawing.Point(286, 24);
this.txtBoxMark.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.txtBoxMark.Multiline = true;
this.txtBoxMark.Name = "txtBoxMark";
this.txtBoxMark.Size = new System.Drawing.Size(204, 61);
this.txtBoxMark.TabIndex = 38;
//
// groupBox8
//
this.groupBox8.Controls.Add(this.lblLimit);
this.groupBox8.Controls.Add(this.lblStandy4);
this.groupBox8.Controls.Add(this.lblStandy3);
this.groupBox8.Controls.Add(this.lblStandy2);
this.groupBox8.Controls.Add(this.lblStandy1);
this.groupBox8.Controls.Add(this.lblCharge2);
this.groupBox8.Controls.Add(this.lblCharge1);
this.groupBox8.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox8.Location = new System.Drawing.Point(218, 106);
this.groupBox8.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBox8.Name = "groupBox8";
this.groupBox8.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBox8.Size = new System.Drawing.Size(549, 154);
this.groupBox8.TabIndex = 37;
this.groupBox8.TabStop = false;
this.groupBox8.Text = "位置占用情况";
//
// lblStandy4
//
this.lblStandy4.AutoSize = true;
this.lblStandy4.Dock = System.Windows.Forms.DockStyle.Top;
this.lblStandy4.Location = new System.Drawing.Point(2, 76);
this.lblStandy4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblStandy4.Name = "lblStandy4";
this.lblStandy4.Size = new System.Drawing.Size(65, 12);
this.lblStandy4.TabIndex = 5;
this.lblStandy4.Text = "lblStandy4";
//
// lblStandy3
//
this.lblStandy3.AutoSize = true;
this.lblStandy3.Dock = System.Windows.Forms.DockStyle.Top;
this.lblStandy3.Location = new System.Drawing.Point(2, 64);
this.lblStandy3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblStandy3.Name = "lblStandy3";
this.lblStandy3.Size = new System.Drawing.Size(65, 12);
this.lblStandy3.TabIndex = 4;
this.lblStandy3.Text = "lblStandy3";
//
// lblStandy2
//
this.lblStandy2.AutoSize = true;
this.lblStandy2.Dock = System.Windows.Forms.DockStyle.Top;
this.lblStandy2.Location = new System.Drawing.Point(2, 52);
this.lblStandy2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblStandy2.Name = "lblStandy2";
this.lblStandy2.Size = new System.Drawing.Size(65, 12);
this.lblStandy2.TabIndex = 3;
this.lblStandy2.Text = "lblStandy2";
//
// lblStandy1
//
this.lblStandy1.AutoSize = true;
this.lblStandy1.Dock = System.Windows.Forms.DockStyle.Top;
this.lblStandy1.Location = new System.Drawing.Point(2, 40);
this.lblStandy1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblStandy1.Name = "lblStandy1";
this.lblStandy1.Size = new System.Drawing.Size(65, 12);
this.lblStandy1.TabIndex = 2;
this.lblStandy1.Text = "lblStandy1";
//
// lblCharge2
//
this.lblCharge2.AutoSize = true;
this.lblCharge2.Dock = System.Windows.Forms.DockStyle.Top;
this.lblCharge2.Location = new System.Drawing.Point(2, 28);
this.lblCharge2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblCharge2.Name = "lblCharge2";
this.lblCharge2.Size = new System.Drawing.Size(65, 12);
this.lblCharge2.TabIndex = 1;
this.lblCharge2.Text = "lblCharge4";
//
// lblCharge1
//
this.lblCharge1.AutoSize = true;
this.lblCharge1.Dock = System.Windows.Forms.DockStyle.Top;
this.lblCharge1.Location = new System.Drawing.Point(2, 16);
this.lblCharge1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblCharge1.Name = "lblCharge1";
this.lblCharge1.Size = new System.Drawing.Size(65, 12);
this.lblCharge1.TabIndex = 0;
this.lblCharge1.Text = "lblCharge3";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.btnReSendTask);
this.groupBox2.Controls.Add(this.BtnClearError);
this.groupBox2.Controls.Add(this.BtnMissionReady);
this.groupBox2.Controls.Add(this.BtnMissionPause);
this.groupBox2.Location = new System.Drawing.Point(790, 20);
this.groupBox2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBox2.Size = new System.Drawing.Size(231, 177);
this.groupBox2.TabIndex = 32;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "操作";
//
// chkBoxOpenMission
//
this.chkBoxOpenMission.AutoSize = true;
this.chkBoxOpenMission.Checked = true;
this.chkBoxOpenMission.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkBoxOpenMission.Location = new System.Drawing.Point(928, 217);
this.chkBoxOpenMission.Name = "chkBoxOpenMission";
this.chkBoxOpenMission.Size = new System.Drawing.Size(72, 16);
this.chkBoxOpenMission.TabIndex = 46;
this.chkBoxOpenMission.Text = "接收任务";
this.chkBoxOpenMission.UseVisualStyleBackColor = true;
this.chkBoxOpenMission.Visible = false;
this.chkBoxOpenMission.CheckedChanged += new System.EventHandler(this.chkBoxOpenMission_CheckedChanged);
//
// btnReSendTask
//
this.btnReSendTask.Location = new System.Drawing.Point(138, 106);
this.btnReSendTask.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.btnReSendTask.Name = "btnReSendTask";
this.btnReSendTask.Size = new System.Drawing.Size(75, 52);
this.btnReSendTask.TabIndex = 45;
this.btnReSendTask.Text = "任务重发";
this.btnReSendTask.UseVisualStyleBackColor = true;
this.btnReSendTask.Click += new System.EventHandler(this.btnReSendTask_Click);
//
// BtnClearError
//
this.BtnClearError.Location = new System.Drawing.Point(21, 106);
this.BtnClearError.Name = "BtnClearError";
this.BtnClearError.Size = new System.Drawing.Size(75, 52);
this.BtnClearError.TabIndex = 19;
this.BtnClearError.Text = "清除错误";
this.BtnClearError.UseVisualStyleBackColor = true;
this.BtnClearError.Click += new System.EventHandler(this.BtnClearError_Click);
//
// BtnMissionReady
//
this.BtnMissionReady.Location = new System.Drawing.Point(21, 23);
this.BtnMissionReady.Name = "BtnMissionReady";
this.BtnMissionReady.Size = new System.Drawing.Size(75, 52);
this.BtnMissionReady.TabIndex = 1;
this.BtnMissionReady.Text = "运行";
this.BtnMissionReady.UseVisualStyleBackColor = true;
this.BtnMissionReady.Click += new System.EventHandler(this.BtnMissionReady_Click);
//
// BtnMissionPause
//
this.BtnMissionPause.Location = new System.Drawing.Point(138, 19);
this.BtnMissionPause.Name = "BtnMissionPause";
this.BtnMissionPause.Size = new System.Drawing.Size(75, 52);
this.BtnMissionPause.TabIndex = 2;
this.BtnMissionPause.Text = "暂停";
this.BtnMissionPause.UseVisualStyleBackColor = true;
this.BtnMissionPause.Click += new System.EventHandler(this.BtnMissionPause_Click);
//
// BtnMissionAdd
//
this.BtnMissionAdd.Location = new System.Drawing.Point(170, 24);
this.BtnMissionAdd.Name = "BtnMissionAdd";
this.BtnMissionAdd.Size = new System.Drawing.Size(75, 60);
this.BtnMissionAdd.TabIndex = 3;
this.BtnMissionAdd.Text = "添加任务";
this.BtnMissionAdd.UseVisualStyleBackColor = true;
this.BtnMissionAdd.Click += new System.EventHandler(this.BtnMissionAdd_Click);
//
// LstAgvPlace
//
this.LstAgvPlace.Dock = System.Windows.Forms.DockStyle.Left;
this.LstAgvPlace.FormattingEnabled = true;
this.LstAgvPlace.IntegralHeight = false;
this.LstAgvPlace.ItemHeight = 12;
this.LstAgvPlace.Location = new System.Drawing.Point(3, 3);
this.LstAgvPlace.Name = "LstAgvPlace";
this.LstAgvPlace.Size = new System.Drawing.Size(150, 291);
this.LstAgvPlace.TabIndex = 0;
//
// tableLayoutPanel4
//
this.tableLayoutPanel4.ColumnCount = 1;
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel4.Controls.Add(this.tableLayoutPanel6, 0, 0);
this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel4.Location = new System.Drawing.Point(2, 133);
this.tableLayoutPanel4.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
this.tableLayoutPanel4.RowCount = 1;
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 169F));
this.tableLayoutPanel4.Size = new System.Drawing.Size(1063, 192);
this.tableLayoutPanel4.TabIndex = 8;
//
// tableLayoutPanel6
//
this.tableLayoutPanel6.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.OutsetPartial;
this.tableLayoutPanel6.ColumnCount = 2;
this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 49.99999F));
this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 15F));
this.tableLayoutPanel6.Controls.Add(this.label2, 1, 0);
this.tableLayoutPanel6.Controls.Add(this.label1, 0, 0);
this.tableLayoutPanel6.Controls.Add(this.label4, 1, 1);
this.tableLayoutPanel6.Controls.Add(this.label3, 0, 1);
this.tableLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel6.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tableLayoutPanel6.Location = new System.Drawing.Point(2, 2);
this.tableLayoutPanel6.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.tableLayoutPanel6.Name = "tableLayoutPanel6";
this.tableLayoutPanel6.RowCount = 2;
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel6.Size = new System.Drawing.Size(1059, 188);
this.tableLayoutPanel6.TabIndex = 0;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Dock = System.Windows.Forms.DockStyle.Fill;
this.label2.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(532, 3);
this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(522, 89);
this.label2.TabIndex = 1;
this.label2.Text = "label2";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
this.label1.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(5, 3);
this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(520, 89);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label4.Location = new System.Drawing.Point(532, 95);
this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(55, 15);
this.label4.TabIndex = 3;
this.label4.Text = "label4";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.Location = new System.Drawing.Point(5, 95);
this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(55, 15);
this.label3.TabIndex = 2;
this.label3.Text = "label3";
//
// lblLimit
//
this.lblLimit.AutoSize = true;
this.lblLimit.Dock = System.Windows.Forms.DockStyle.Top;
this.lblLimit.Location = new System.Drawing.Point(2, 88);
this.lblLimit.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblLimit.Name = "lblLimit";
this.lblLimit.Size = new System.Drawing.Size(35, 12);
this.lblLimit.TabIndex = 6;
this.lblLimit.Text = "limit";
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1067, 656);
this.Controls.Add(this.tableLayoutPanel3);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "FrmMain";
this.Text = "AGV料仓调度";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMain_FormClosing);
this.Load += new System.EventHandler(this.FrmMain_Load);
((System.ComponentModel.ISupportInitialize)(this.DgvAgv)).EndInit();
this.tableLayoutPanel3.ResumeLayout(false);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.DgvNode)).EndInit();
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
this.tabPage3.ResumeLayout(false);
this.tabPage3.PerformLayout();
this.groupBox8.ResumeLayout(false);
this.groupBox8.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.tableLayoutPanel4.ResumeLayout(false);
this.tableLayoutPanel6.ResumeLayout(false);
this.tableLayoutPanel6.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.DataGridView DgvAgv;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.DataGridView DgvNode;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button BtnClearError;
private System.Windows.Forms.Button BtnMissionAdd;
private System.Windows.Forms.Button BtnMissionPause;
private System.Windows.Forms.Button BtnMissionReady;
private System.Windows.Forms.ListBox LstAgvPlace;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel6;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnReSendTask;
private System.Windows.Forms.GroupBox groupBox8;
private System.Windows.Forms.Label lblStandy2;
private System.Windows.Forms.Label lblStandy1;
private System.Windows.Forms.Label lblCharge2;
private System.Windows.Forms.Label lblCharge1;
private System.Windows.Forms.Label lblStandy4;
private System.Windows.Forms.Label lblStandy3;
private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.DataGridViewTextBoxColumn Column4;
private System.Windows.Forms.DataGridViewTextBoxColumn Column14;
private System.Windows.Forms.DataGridViewTextBoxColumn Column21;
private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
private System.Windows.Forms.DataGridViewTextBoxColumn Column18;
private System.Windows.Forms.DataGridViewTextBoxColumn Column23;
private System.Windows.Forms.DataGridViewTextBoxColumn Column13;
private System.Windows.Forms.DataGridViewTextBoxColumn Column19;
private System.Windows.Forms.DataGridViewButtonColumn Column11;
private System.Windows.Forms.DataGridViewTextBoxColumn Column6;
private System.Windows.Forms.DataGridViewTextBoxColumn Column7;
private System.Windows.Forms.DataGridViewTextBoxColumn Column10;
private System.Windows.Forms.DataGridViewTextBoxColumn Column22;
private System.Windows.Forms.DataGridViewTextBoxColumn Column9;
private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
private System.Windows.Forms.DataGridViewButtonColumn Column16;
private System.Windows.Forms.CheckBox chkBoxOpenMission;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.TextBox TxtLog;
private System.Windows.Forms.Button btnWriteMarks;
private System.Windows.Forms.Button btnGetMarks;
private System.Windows.Forms.TextBox txtBoxMark;
private System.Windows.Forms.Label lblLimit;
}
}
using AGVControl.BLL;
using MiR;
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AGVControl
{
public partial class FrmMain : Form
{
private bool exit = false;
private bool change;
private NotifyIcon notify;
private ContextMenuStrip notifyMenu;
private System.Timers.Timer showTimer;
private Label[] agvRunInfo;
//private string[] agvRunStep;
public FrmMain()
{
InitializeComponent();
showTimer = new System.Timers.Timer();
showTimer.Interval = 2000;
//showTimer.Enabled = true;
//showTimer.AutoReset = true;
showTimer.Elapsed += ShowTimer_Elapsed;
showTimer.Start();
Common.logTextBox = TxtLog;
agvRunInfo = new Label[] { label1, label2, label3, label4 };
Common.control.limitArea.ScopeLimitStateChangedEvent += LimitArea_ScopeLimitStateChangedEvent;
}
/// <summary>
/// 限制区域有小车
/// </summary>
/// <param name="ip"></param>
private void LimitArea_ScopeLimitStateChangedEvent(string ip,bool state)
{
Invoke(new Action(()=>
{
if (Common.control.limitArea.Available)
lblLimit.Text = "限制区域车辆:";
else
{
lblLimit.Text = "限制区域车辆:"+ip;
}
}
));
}
private void ShowConfig()
{
int n;
//agvRunStep = new string[Common.agvInfo.Count];
for (int i = 0; i < Common.agvInfo.Count; i++)
{
Common.mir.Get_IO_Status(Common.agvInfo[i], out bool[] input, out bool[] output);
if (input != null && input.Length == 4)
Common.agvInfo[i].IsExistShelf = input[3];
n = DgvAgv.Rows.Add(Common.agvInfo[i].ToRow());
DgvAgv.Rows[n].HeaderCell.Value = (n + 1).ToString();
if (i % 2 == 0)
DgvAgv.Rows[n].DefaultCellStyle.BackColor = Color.LightBlue;
if (!Common.agvInfo[i].IsCon)
DgvAgv.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
}
for (int i = 0; i < Common.nodeInfo.Count; i++)
{
n = DgvNode.Rows.Add(Common.nodeInfo[i].ToRow());
DgvNode.Rows[n].HeaderCell.Value = (n + 1).ToString();
if (i % 2 == 0)
DgvNode.Rows[n].DefaultCellStyle.BackColor = Color.LightBlue;
if (!Common.nodeInfo[i].Online)
DgvNode.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
}
LstAgvPlace.Items.Clear();
LstAgvPlace.Items.AddRange(Common.showNameMissionName.Keys.ToArray());
LstAgvPlace.SelectedIndex = 0;
}
private void Server_NodeChanged(int nodeIndex)
{
Invoke(new Action(() =>
{
DgvNode.Rows[nodeIndex].DefaultCellStyle.ForeColor = Common.nodeInfo[nodeIndex].Online && Common.nodeInfo[nodeIndex].IsUse ? Color.Black : Color.Red;
DgvNode.Rows[nodeIndex].SetValues(Common.nodeInfo[nodeIndex].ToRow());
}));
System.GC.Collect();
}
private void Server_NodeOnline(int nodeIndex)
{
Invoke(new Action(() =>
{
DgvNode.Rows[nodeIndex].DefaultCellStyle.ForeColor = Common.nodeInfo[nodeIndex].Online ? Color.Black : Color.Red;
DgvNode.Rows[nodeIndex].SetValues(Common.nodeInfo[nodeIndex].ToRow());
}));
System.GC.Collect();
}
private void Control_AgvChanged(int agvIndex)
{
Invoke(new Action(() => { DgvAgv.Rows[agvIndex].DefaultCellStyle.ForeColor = Common.agvInfo[agvIndex].StateID.Equals(eAGVState.Error) ? Color.Red : Color.Black; }));
Invoke(new Action(() =>
{
DgvAgv.Rows[agvIndex].SetValues(Common.agvInfo[agvIndex].ToRow());
}));
System.GC.Collect();
}
private void MissionManager_MissionChanged()
{
//ShowEmptyTask();
}
private void Control_AgvOnline(int agvIndex)
{
Invoke(new Action(() => { DgvAgv.Rows[agvIndex].DefaultCellStyle.ForeColor = Common.agvInfo[agvIndex].IsCon ? Color.Black : Color.Red; }));
Invoke(new Action(() =>
{
DgvAgv.Rows[agvIndex].SetValues(Common.agvInfo[agvIndex].ToRow());
}));
GC.Collect();
}
private void ItemShow_Click(object sender, EventArgs e)
{
Show();
if (WindowState == FormWindowState.Minimized)
WindowState = FormWindowState.Normal;
}
private void ItemExit_Click(object sender, EventArgs e)
{
foreach (var item in Common.agvInfo)
{
Common.WriteIni(item.Name, SettingString.RFID, item.RFID);
}
notify.Dispose();
exit = true;
Close();
}
private void Notify_MouseDoubleClick(object sender, MouseEventArgs e)
{
Show();
if (WindowState == FormWindowState.Minimized)
WindowState = FormWindowState.Normal;
}
private void FrmMain_Load(object sender, EventArgs e)
{
//托盘菜单
notifyMenu = new ContextMenuStrip();
ToolStripMenuItem itemShow = new ToolStripMenuItem("显示(&S)");
itemShow.Click += ItemShow_Click;
ToolStripMenuItem itemExit = new ToolStripMenuItem("退出(&X)");
itemExit.Click += ItemExit_Click;
notifyMenu.Items.Add(itemShow);
notifyMenu.Items.Add(itemExit);
//托盘控件
notify = new NotifyIcon { Icon = Icon, Visible = true, ContextMenuStrip = notifyMenu, Text = Text };
notify.MouseDoubleClick += Notify_MouseDoubleClick;
ShowConfig();
change = true;
//ChkAutoCharge.Checked = Common.chargeStatus.AutoCharge;
change = false;
Common.control.AgvChanged += Control_AgvChanged;
Common.control.AgvOnline += Control_AgvOnline;
Common.server.NodeChanged += Server_NodeChanged;
Common.server.NodeOnline += Server_NodeOnline;
//foreach (var item in Common.agvInfo)
//{
// cmbBoxAGVName.Items.Add(item.Name);
//}
//cmbBoxAGVName.Items.Add("None");
//cmbBoxAGVName.SelectedIndex = Common.agvInfo.Count;
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
if (!exit)
{
e.Cancel = true;
Hide();
}
foreach (var item in Common.agvInfo)
{
Common.WriteIni(item.Name, SettingString.RFID, item.RFID);
}
//showTimer.Enabled = false;
showTimer.Stop();
Common.control.AgvChanged -= Control_AgvChanged;
Common.control.AgvOnline -= Control_AgvOnline;
Common.server.NodeChanged -= Server_NodeChanged;
Common.server.NodeOnline -= Server_NodeOnline;
}
private void DgvAgv_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex == -1) return;
if (e.ColumnIndex == 10) //调用
{
if (Common.agvInfo[e.RowIndex].IsUse.Equals(true))
{
Common.agvInfo[e.RowIndex].IsUse = false;
Common.agvInfo[e.RowIndex].CurJob = null;
Common.Standby.DelOccupyInfo(Common.agvInfo[e.RowIndex].Name);
Common.Charge.DelOccupyInfo(Common.agvInfo[e.RowIndex].Name);
Common.mir.Del_Mission_Fleet(Common.agvInfo[e.RowIndex], Common.agvInfo[e.RowIndex].CurTaskID.ToString());
}
else
{
if (Common.agvInfo[e.RowIndex].IsExistShelf)
{
Common.LogInfo(string.Format("{0} 车上有负载,无法开启自动模式,请先清空小车负载!", Common.agvInfo[e.RowIndex].Name));
return;
}
Common.agvInfo[e.RowIndex].CurJob = null;
//添加Init任务
Common.mir.Add_Mission_Fleet(Common.agvInfo[e.RowIndex], Common.agvMission["Init"]);
Common.mir.State_Ready(Common.agvInfo[e.RowIndex]);
Common.LogInfo(string.Format("{0} 手动开启小车自动模式,清空上一次的运行信息:{1}", Common.agvInfo[e.RowIndex].Name, Common.agvInfo[e.RowIndex].RunInfo()));
if (Common.agvInfo[e.RowIndex].Place.Equals(SettingString.Standby) || Common.agvInfo[e.RowIndex].Place.Equals(SettingString.AutoCharge))
Common.agvInfo[e.RowIndex].Place = "";
Common.agvInfo[e.RowIndex].RFID = "";
Common.agvInfo[e.RowIndex].IsUse = true;
}
DgvAgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Common.agvInfo[e.RowIndex].IsUse.ToString();
Common.WriteIni(Common.agvInfo[e.RowIndex].Name, SettingString.IsUse, Common.agvInfo[e.RowIndex].IsUse.ToString());
DgvAgv.Rows[e.RowIndex].SetValues(Common.agvInfo[e.RowIndex].ToRow());
}
}
private void DgvNode_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex == -1) return;
if (e.ColumnIndex == DgvNode.Columns.Count - 1) //调用
{
Common.nodeInfo[e.RowIndex].IsUse = !Common.nodeInfo[e.RowIndex].IsUse;
DgvNode.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Common.nodeInfo[e.RowIndex].IsUse.ToString();
Common.WriteIni(Common.nodeInfo[e.RowIndex].Name, SettingString.IsUse, Common.nodeInfo[e.RowIndex].IsUse.ToString());
DgvNode.Rows[e.RowIndex].SetValues(Common.nodeInfo[e.RowIndex].ToRow());
Common.LogInfo(string.Format("手动设置节点调用: {0}={1}", Common.nodeInfo[e.RowIndex].LineName, Common.nodeInfo[e.RowIndex].IsUse));
}
else if (e.ColumnIndex == 8) //清除缓存
{
//清除节点缓存
string name = Common.nodeInfo[e.RowIndex].AgvName;
Common.nodeInfo[e.RowIndex].AgvName = "";
DgvNode.Rows[e.RowIndex].Cells[5].Value = "";
Common.nodeInfo[e.RowIndex].RFID = "";
DgvNode.Rows[e.RowIndex].Cells[4].Value = "";
//清除小车缓存
int idx = Common.agvInfo.FindIndex(s => s.Name == name);
if (idx > -1)
{
Common.agvInfo[idx].Place = "";
Common.agvInfo[idx].RFID = "";
DgvAgv.Rows[idx].SetValues(Common.agvInfo[idx].ToRow());
//添加Init任务
Common.mir.Add_Mission_Fleet(Common.agvInfo[idx], Common.agvMission["Init"]);
Common.mir.State_Ready(Common.agvInfo[idx]);
}
DgvNode.Rows[e.RowIndex].SetValues(Common.nodeInfo[e.RowIndex].ToRow());
}
}
private void BtnMissionReady_Click(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
Common.mir.State_Ready(Common.agvInfo[idx]);
}
private void BtnMissionPause_Click(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
Common.mir.State_Pause(Common.agvInfo[idx]);
Common.LogInfo("手动暂停:[" + Common.agvInfo[idx].Name + "]");
}
private void BtnMissionAdd_Click(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
{
if (!Common.agvInfo[idx].IsUse)
{
if (LstAgvPlace.Text.Equals(SettingString.Enter) || LstAgvPlace.Text.Equals(SettingString.Leave))
{
Common.LogInfo(Common.agvInfo[idx].Name + " 禁止在软件添加进料/出料任务。若需要,请在AGV网页操作");
return;
}
bool rtn = Common.mir.Add_Mission_Fleet(Common.agvInfo[idx], Common.agvMission[Common.showNameMissionName[LstAgvPlace.Text]]);
if (!rtn)
return;
if (LstAgvPlace.Text.StartsWith("Move"))
Common.agvInfo[idx].Place = LstAgvPlace.Text.Substring(4);
Common.LogInfo("手动添加任务:[" + Common.agvInfo[idx].Name + "][" + Common.agvInfo[idx].CurTaskName + "]");
}
Common.Standby.DelOccupyInfo(Common.agvInfo[idx].Name);
Common.Charge.DelOccupyInfo(Common.agvInfo[idx].Name);
DgvAgv.Rows[idx].SetValues(Common.agvInfo[idx].ToRow());
}
}
private void BtnClearError_Click(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
Common.mir.Clear_Error(Common.agvInfo[idx]);
Common.LogInfo("手动清除错误:[" + Common.agvInfo[idx].Name + "]");
}
bool InShhow = false;
private void ShowTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//ShowEmptyTask();
if (InShhow)
return;
InShhow = true;
Invoke(new Action(() =>
{
for (int i = 0; i < Common.agvInfo.Count; i++)
{
agvRunInfo[i].Text = Common.agvInfo[i].RunInfo();
}
lblCharge1.Text = "充电桩1:" + Common.Charge.Station[Charge.AutoCharge1];
lblCharge2.Text = "充电桩2:" + Common.Charge.Station[Charge.AutoCharge2];
lblStandy1.Text = "待机位1:" + Common.Standby.Station[0];
lblStandy2.Text = "待机位2:" + Common.Standby.Station[1];
lblStandy3.Text = "待机位3:" + Common.Standby.Station[2];
lblStandy4.Text = "待机位4:" + Common.Standby.Station[3];
}));
Application.DoEvents();
InShhow = false;
}
private void btnReSendTask_Click(object sender, EventArgs e)
{
if (DgvAgv.SelectedCells.Count == 0) return;
int idx = DgvAgv.SelectedCells[0].RowIndex;
if (idx < 0) return;
if (Common.agvInfo[idx].IsCon)
{
if (Common.agvInfo[idx].IsUse)
{
if (MessageBox.Show("确定在自动模式下对小车重发任务?", Common.agvInfo[idx].Name, MessageBoxButtons.YesNo) == DialogResult.No)
return;
Common.agvInfo[idx].Resend();
Common.mir.State_Ready(Common.agvInfo[idx]);
//Common.agvInfo[idx].TaskSend = LstAgvPlace.Text;
Common.LogInfo("手动重发任务:[" + Common.agvInfo[idx].Name + "][" + Common.agvInfo[idx].CurTaskName + "]");
}
DgvAgv.Rows[idx].SetValues(Common.agvInfo[idx].ToRow());
}
}
private void tabPage3_Click(object sender, EventArgs e)
{
}
private void chkBoxOpenMission_CheckedChanged(object sender, EventArgs e)
{
BLL.Control.OpenGetJob = chkBoxOpenMission.Checked;
}
private void btnGetMarks_Click(object sender, EventArgs e)
{
txtBoxMark.Text=bean.jobType.PackingJobType.GetMarks();
// btnWriteMarks.Enabled = true;
}
private void btnWriteMarks_Click(object sender, EventArgs e)
{
bean.jobType.PackingJobType.WriteMarks(txtBoxMark.Text);
txtBoxMark.Text = "";
// btnWriteMarks.Enabled = false;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column14.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column21.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column18.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column23.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column13.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column19.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column11.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column7.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column10.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column22.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column9.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column16.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAADAE
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQARgoKAmoAAAAfAAAAAAAA
AAAAAAAAAAAAAAQEAEgKCgJqAAAAHQAAAAAAAAAAAAAAAAAAAAkAAAARERECaFdWDdVOTQzOQkILvAAA
AB4AAAAAAAAAABYWAmlYVw3UT04Mzz8/CroAAAAZAAAAAAAAACIPIWq7GDGfzR8jIrZYVg/TNTUZuGhm
EOkFCh6ZCxM+dwYNK3cfHwunV1YQ0DU0GLdnZA/nBAcZjwQHGUgAAABKHytftyNI7/8cOLLTLjAYsSwq
B7UMDhC8EiV4tBQog7MTKn2xChg/sSIpELQtLAe1DA8OuxIogLQLEkJ0AAAAORYriMUjSO//I0jv/xw6
w9wCEhmYDJPCzg6i194OotjiDqLY4g2YyNkMksDUDY69yQuGsssFS2K8AAAAGQAAABMWLJDHGDCizhgx
n80cOr7ZAAAAMgAAACAAAAAzAAAAKAAAACIAAAAiAAAAI1pZM8Oxr2PvHBwQbQAAAAAAAAAADRxem0FE
Obi9umvtDx9gtwAAADICHSdoAyc0ngAKDksAAAAAAAAAAAAAAAAhIROTJiUUvAAAABgAAAAAAAAAAAMD
EUoVJGy6urho6RIfVLQAAAAyAAYGKAMjLpoAAAAXAAAAAAAAAAATEw1PQT8ltQsLBi4AAAAAAAAAAAAA
AAAAAAACDBlTpRotgrkXMKDKAAAAMgAAAAAAAABZAAAAAAAAAAAGBgArLi0ZtQUFAC8AAAAAAAAAAAAA
AAAAAAAAAAAAAAAAABMDCBZdAwgWXQAAAAwAAAAAAAAAWQAAAAAAAAATLS0aqRoXDU4AAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFcAAAALKSkXnSEhEmYAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABYAAABQNTQdnigoFYcAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0Ly4asigoF5IAAAAFAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQoKCGQAAAAFAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//AAD//wAA//8AAPHjAACAwQAAgAEAAIABAACH8wAAhvMAAMb3
AADH7wAA/98AAP+/AAD/PwAA/n8AAP//AAAoAAAAIAAAAEAAAAABACAAAAAAAIAQAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAABAAAAXgMDALAICAHGBwcBuwAAAIsAAAANAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAEAAABjAwMAsQgIAcYFBQG9AAAAhgAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIkoKAfBcnAS+3RyEv90chL/UU4M1AQEAb0AAAALAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAgIAjC4uB8BzcRL9dHIS/3RyEv9PTQ3GAwMAvAAAAAgAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAApAAAAMwAAADMAAABIGhkEwnRyEv89OwnEGBgHwTU0CMV0chL/SEcLygAA
AHoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACghIQW/dHIS/zY2CcIYGAfBOzoJx3RyEv9BPgrFAAAAbwAA
AAAAAAAAAAAAAAAAAAAAAAAUAQMIvQkSPsENG1m/DBlTvwQIGMs1NQjCdHIS/wkJAtKsqWDfKioYwmBd
D91ycBL+AQEAtgAAABEAAAARAAAAEQAAABEAAAAKAAAAWj49CsR0chL/BwcC1bGwY+IgIBLFZmQP6G9t
EfcAAACoAAAAAAAAAAAAAAAAAAAAAAAAAHoTKYjHI0jv/yNI7/8jSO//EieAwzQzCMN0chL/aWcQ6xoa
BMEYFgTBcnAS+lFPDM8CBRHRCBAywggQMsIHDS7DBQojxgUKI8YCBQ/SPz4KxXRyEv9mZBDmGBYEwRoa
BMFzcRL9R0ULygIFEdAFCiPGAwUPygAAAEIAAAAAAAAAmQwOC88ePs7lI0jv/yNI7/8iRej2BQgOzEdF
C8pycRLQdHITwHNxE79FQwq2Cg4dsiBC2b0jSO7AI0juwCNI7sAjSO7AI0juwCJC3L0LDhWySkkLtnRy
E8B0chPAc3ETv0RECrUKDRy0IkPgvSNI7sAPHmS1AAAASQAAAAAAAACOVVUwwBIme8UjSO//I0jv/yNI
7/8hReX0DBhTvgoLDrQGBgHPAgIB2gABAfYCBxLVBA0gxQQNIMUEDSDFBRAlwgQOIcQEDiHEBBAezAEL
EtUABwneCBIRxw0RCMYCBQTaAAEB7wQKG8gECh/IBQwnxAMIGKoAAAARAAAAAAAAAIAGBgXbHTrC3yNI
7/8jSO//I0jv/yNI7/8jSO//FCiFxAAAAHwDIy/FEL/+/xC//v8Qv/7/EL/+/xC//v8Qv/7/EL/+/xC/
/v8Qv/7/EL/+/xC//v8Qv/7/EL/+/xC//v8Qv/7/EL/+/xC8+voIZYXDAAAAXQAAAAAAAAAAAAAAZRMo
g8cjSO//I0jv/yNI7/8jSO//I0jv/yNI7/8WLJbJAAAAZwEHCb0HSmTACWeIvAlrjcEJbZLGCW2Sxglt
ksYJbZLGCW2SxghnicQIW3jCB1l2vgdRa7oFRl29BkJYtgY/VbkEOErABDhKwAENEcMAAAAeAAAAAAAA
AAAAAABHDh5hwiNI7/8jSO//I0jv/yNI7/8jSO//I0jv/xYslskAAABjAAAAAwAAADgAAABJAAAAVQAA
AFUAAABPAAAARAAAAEQAAABEAAAARAAAAEQAAABEAAAARBUUC82gn1vkoJ9b5KCfW+QQEAnOAAAAAwAA
AAAAAAAAAAAAAAAAABEFCSDIIkfq+g0dYMAMGVW/CRVFwAoWSMMdO8XkFiyWyQAAAGMAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACEREJyM3Kc/zPzHT/zcpz/AkJ
BcEAAAAAAAAAAAAAAAAAAAAAAAAAAAEBBrMfQdjrCwwJzqGfWtivrWPioZ9a3AcMJsQWLJbJAAAAYwAA
AAAAAAALAAQGtwAAAGoAAgKoAAICfQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABRDg4IyTU1
HcAREQrOAAAAZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUQ0cXMEJETjAn5xZ0c/MdP/PzHT/CQ0XyRYs
lskAAABjAAAAAAAAABQDHSfEAQ8UyghggMIABgi5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AFsrKxjAXFszyAAAAKsAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAQMJwR9A0+gODw3Lzst0/s/M
dP8QEhnDFiyWyQAAAGMAAAAAAAAAAAACA5MFQFS/AyUywwAAAF0AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAABHLCsZw4aDTM4DAwGsAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABfEiZ7xQ0b
WsBubT3Dz8x0/wwOE8YWLJbJAAAAYwAAAAAAAAAAAAAAAQAAAJkAAABLAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAGA4OCMd6d0XJAwMCpwAAAAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAgBBAvNIUXm9gcMIcApJxbDCxRCwBYslskAAABjAAAAAAAAAAAAAAAAAAAAjwAAACMAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAgFBQS7Z2U6xwMDAqMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAGUJFELCIkbo+SBC2uojSO//FiyWyQAAAGMAAAAAAAAAAAAAAAAAAACfAAAAFAAA
AAAAAAAAAAAAAAAAAAAAAAABAwMCn3BtPsQICAS+AAAACQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFUAAQO4AQEFwAEBB7gCAgWZAAAAOQAAAAAAAAAAAAAAAAAA
AK4AAAAFAAAAAAAAAAAAAAAAAAAAAAAAAHlZVzK7EREJyAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAsgAAAAAAAAAAAAAAAAAAAAAAAABRNjUevB0dEL8AAAA6AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAACvAAAAAAAAAAAAAAAAAAAAMxQUC8A5Nx+9AAAAWQAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAALAAAAAAAAAAAAAAADAREQnCTUwrvQAAAHwAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbAAAAmQAAAAAAAAA4GRgPv3h3RMcCAgKfAAAAAQAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4AAAB1AAAAOBERCcORj1LRBgYDtwAA
AAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZQAAAJcTEwrGjIpOzwUF
A7wAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB1GxoOxZ+d
WtgFBQS7AAAADQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
ABYHBwS3BwcEwgAAABUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAQAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////////////////4f+H/4D+A/+A/gPwAH4B8AA
AAGAAAABgAAAAYAgAAPAIAADwD//B8A//wfAOv+P4Dh/j+A4/x/wPf4/8D38f/g9+P/8Pfn///3z///9
5////c////2P////H////D////x////8////////
</value>
</data>
</root>
\ No newline at end of file \ No newline at end of file
using MiR;
using log4net.Config;
using log4net.Util.TypeConverters;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AGVControl.bean.jobType;
namespace AGVControl
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ThreadException += Application_ThreadException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
XmlConfigurator.Configure();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//程序只能运行一次
Process current = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName(current.ProcessName);
foreach (Process process in processes)
{
if (process.Id == current.Id) continue; //自己
if (process.MainModule.FileName == current.MainModule.FileName)
{
//显示已打开的程序
API.ShowWindow(process.MainWindowHandle, API.SW_RESTORE);
API.SwitchToThisWindow(process.MainWindowHandle, true);
return;
}
}
Start();
Application.Run(new FrmMain());
Stop();
}
private static void Start()
{
Common.logTextBox = new TextBox();
Common.log = log4net.LogManager.GetLogger("AGVControl_SMD_BOX");
Common.log.Info("=====程序开始=====");
ReadConfig();
Common.Charge = new BLL.Charge();
Common.Standby = new BLL.Standby();
Common.mir = new MiR.API();
Common.control = new BLL.Control();
Common.control.Start();
Common.server = new BLL.AgvServer();
Common.server.Start();
}
private static void Stop()
{
Common.control.Stop();
Common.server.Stop();
Common.log.Info("=====程序结束=====\r\n");
}
private static void ReadConfig()
{
string path;
string[] line;
string[] temp;
bool isuse;
string rfid = "";
Common.agvInfo = new List<Agv_Info>();
path = Common.CONFIG_PATH + SettingString.FileName_AGV;
line = System.IO.File.ReadAllLines(path, Encoding.UTF8);
for (int i = 1; i < line.Length; i++)
{
temp = line[i].Split(',');
if (temp.Length != 5) continue;
//string val = Common.appConfig.AppSettings.Settings[temp[1]].Value;
bool.TryParse(Common.ReadIni(temp[1], SettingString.IsUse), out isuse); //Convert.ToBoolean(val.Split(',')[0]);
rfid = Common.ReadIni(temp[1], SettingString.RFID); //val.Split(',')[1];
Common.agvInfo.Add(new Agv_Info(temp[0], temp[1], temp[2], temp[3], temp[4], isuse, rfid));
}
Common.agvMission = new Dictionary<string, string>();
Common.showNameMissionName = new Dictionary<string, string>();
path = Common.CONFIG_PATH + SettingString.FileName_AgvMission;
line = System.IO.File.ReadAllLines(path, Encoding.UTF8);
for (int i = 1; i < line.Length; i++)
{
temp = line[i].Split(',');
if (temp.Length != 3) continue;
Common.agvMission.Add(temp[1], temp[2]);
Common.showNameMissionName.Add(temp[0], temp[1]);
}
Common.nodeInfo = new List<ClientNode>();
path = Common.CONFIG_PATH + SettingString.FileName_AgvProductionLine;
line = System.IO.File.ReadAllLines(path, Encoding.GetEncoding("gb2312"));
for (int i = 1; i < line.Length; i++)
{
temp = line[i].Split(',');
if (temp.Length != 3) continue;
Boolean.TryParse(Common.ReadIni(temp[0], SettingString.IsUse), out bool isUse);
Common.nodeInfo.Add(new ClientNode(temp[0], temp[1],temp[2], isUse));
}
//加载任务类型
Common.jobTypeInfo = new List<JobType>();
Common.jobTypeInfo.Add(new PackingJobType());
Common.jobTypeInfo.Add(new ReelStringJobType());
Common.jobTypeInfo.Add(new ReturnJobType());
Common.jobTypeInfo.Add(new ChargeJobType());
}
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Common.log.Error("CurrentDomain_UnhandledException", (Exception)e.ExceptionObject);
}
private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
Common.log.Error("Application_ThreadException", e.Exception);
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("AGVControl-ProductionLine")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AGVControl-ProductionLine")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("e1c3207d-c67d-4b46-a9db-d182f2074ccb")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace AGV_3D_SMD.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_3D_SMD.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace AGV_3D_SMD.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
文件属性发生变化
using AGVControl.bean;
using AGVControl_SMD_BOX.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl
{
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; }
public int LeftTaskCnt { get; set; }
/// <summary>
/// 是否在线
/// </summary>
public bool IsCon { set; get; }
/// <summary>
/// 是否可用
/// </summary>
private bool _IsUse = true;
public bool IsUse
{
set
{
if (!value.Equals(_IsUse))
{
_IsUse = value;
Common.WriteIni(Name, SettingString.IsUse, _IsUse.ToString());
}
}
get { return _IsUse; }
}
/// <summary>
/// 地点
/// </summary>
public string Place { set; get; }
/// <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 clsPosition
{
public double orientation { get; set; }
public double x { get; set; }
public double y { get; set; }
public clsPosition() { }
public clsPosition(double x,double y)
{
this.x = x;
this.y = y;
}
}
/// <summary>
/// 当前位置
/// </summary>
public clsPosition Position;
/// <summary>
/// 任务内容
/// </summary>
public string Msg
{
get;
set;
} = "";
/// <summary>
/// 当前任务
/// </summary>
public Job CurJob { get; set; }
/// <summary>
/// 当前任务的ID号
/// </summary>
public int CurTaskID { get; set; } = -1;
public string CurTaskState { get; set; } = "";
/// <summary>
/// 当前任务名称
/// </summary>
public string CurTaskName { get; set; }
/// <summary>
/// 当前任务的GUID
/// </summary>
public string CurTaskGUID { get; set; }
/// <summary>
/// 看板信息
/// </summary>
private DisplayBoard displayBoard;
public string RunInfo()
{
if (CurJob != null)
{
return string.Format("设备:{1}{0}当前步骤:{2}{0}执行信息:{3}",
"\r\n", Name, CurJob.RunInfo, MissionText);
}
else
return string.Format("设备:{1}{0}执行信息:{2}",
"\r\n", Name, MissionText);
}
/// <summary>
/// 任务重发
/// </summary>
public void Resend()
{
if (CurJob != null)
{
CurJob.ResendTask(this);
}
}
/// <summary>
/// 停在同一处超时
/// </summary>
private bool standTimeOut = false;
/// <summary>
/// 离线超时
/// </summary>
private bool offlineTimeOut = false;
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 Agv_Info.clsPosition();
displayBoard = new DisplayBoard();
}
DateTime IoStartTime = DateTime.MaxValue;
int IoLastTime = 5000;
int StandLastTimeMinute = 5;
int OfflineLastTimeSeconds = 30;
DateTime standStartTime = DateTime.MaxValue;
DateTime offlineStartTime = DateTime.MaxValue;
/// <summary>
/// 设置状态
/// </summary>
/// <param name="stateID"></param>
/// <param name="stateText"></param>
/// <param name="battery"></param>
/// <param name="missionText"></param>
/// <param name="position"></param>
/// <returns></returns>
public bool SetState(eAGVState stateID, string stateText, int battery, string missionText, clsPosition position)
{
bool isChange = false;
bool preShelfState = IsExistShelf;
Common.mir.Get_IO_Status(this, out bool[] input, out bool[] output);
if (input != null && input.Length == 4)
{
bool reachIoValue = input[3].Equals(true);//input[2] &&
if (reachIoValue)
{
//满足给定的IO值,计算持续时间
if (IoStartTime == DateTime.MaxValue)
{
IoStartTime = DateTime.Now;
}
if (IoLastTime > 0)
{
//持续时间
TimeSpan lastTimeSpan = DateTime.Now - IoStartTime;
IsExistShelf = (lastTimeSpan.TotalMilliseconds >= IoLastTime);
}
else
{
IsExistShelf = true;
}
}
else
{
//重新计时
IoStartTime = DateTime.MinValue;
IsExistShelf = input[3];
}
}
if (!StateID.Equals(stateID) || !CurTaskState.Equals(stateText) || !Battery.Equals(battery)
|| !MissionText.Equals(missionText) || !IsExistShelf.Equals(preShelfState))
isChange = true;
StateID = stateID;
CurTaskState = stateText;
Battery = battery;
MissionText = missionText;
CheckOfflineTimeOut();
CheckStandTimeOut(position);
UpdateDisplayBoard();
return isChange;
}
/// <summary>
/// 将信息添加到看板
/// </summary>
/// <param name="name">名字显示</param>
/// <param name="key">关键字</param>
/// <param name="value">值</param>
/// <param name="type">上报类型,默认0是异常;1是正常</param>
public void AddDisplayBoard(string name, string key, string value, int type = 0)
{
displayBoard.Add(name, "Agv." + Name + "." + key, value, type);
}
private void UpdateDisplayBoard()
{
bool isAlarm = false;
try
{
int nodeIdx = Common.FindNode(SettingString.G24_Out);
if (nodeIdx > -1)
displayBoard.Add("退料线出口状态", "doubleLine.ReturnLine",Common.nodeInfo[nodeIdx].GetState().ToString(),1);
if (offlineTimeOut)
{
isAlarm = true;
displayBoard.Add(Name, "Agv." + Name + ".OfflineTimeOut", "在" + PlaceAliceName + "离线" + (DateTime.Now - offlineStartTime).TotalSeconds.ToString("f2") + "秒");
}
if (standTimeOut)
{
isAlarm = true;
displayBoard.Add(Name, "Agv." + Name + ".StandTimeOut", "在" + PlaceAliceName + "停留超时" + (DateTime.Now - standStartTime).TotalMinutes.ToString("f2") + "分钟");
}
if (StateID.Equals(eAGVState.Error) || StateID.Equals(eAGVState.EmergencyStop) || StateID.Equals(eAGVState.Pause))
{
isAlarm = true;
displayBoard.Add(Name, "Agv." + Name + ".Error.EmergencyStop", "agv状态:" + StateID.ToString());
}
if (!isAlarm)
{
if (!Msg.Equals(""))
displayBoard.Add(Name, "Agv." + Name + ".Msg", Msg, 1);
else
{
if ((Place.Contains(SettingString.AutoCharge) || Place.Contains(SettingString.Standby)))
{
displayBoard.Add(Name, "Agv." + Name + ".Place", Place, 1);
}
}
}
displayBoard.UpdateAlarmMsg();
}
catch (Exception ex)
{
Common.log.Error(Name + "上报小车信息失败" + ex.Message + ex.StackTrace);
}
}
/// <summary>
/// 检查小车是否离线超时
/// </summary>
/// <returns></returns>
private void CheckOfflineTimeOut()
{
if (CurJob != null && !(CurJob is ChargeJob) && !IsCon)
{
//满足条件,计算持续时间
if (offlineStartTime == DateTime.MaxValue)
{
offlineStartTime = DateTime.Now;
}
TimeSpan lastTimeSpan = DateTime.Now - offlineStartTime;
offlineTimeOut = (lastTimeSpan.TotalSeconds >= OfflineLastTimeSeconds);
}
else
{
offlineTimeOut = false;
if ((DateTime.Now - offlineStartTime).TotalSeconds > OfflineLastTimeSeconds)
Common.log.Error(string.Format("{0} 在{1}离线{2}秒", Name, PlaceAliceName, (DateTime.Now - offlineStartTime).TotalSeconds.ToString("f2")));
offlineStartTime = DateTime.Now;
}
}
/// <summary>
/// 检查小车是否在原地停留超时
/// </summary>
/// <returns></returns>
private void CheckStandTimeOut(clsPosition position)
{
if (IsUse && CurJob != null && !(CurJob is ChargeJob) &&
(!CurTaskName.Contains(SettingString.Standby)))//!CurTaskName.Contains(SettingString.AutoCharge) ||
{
if (Math.Abs(position.x - Position.x) < 1 && Math.Abs(position.y - Position.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;
}
//public void GetPlace(int value)
//{
// // Common.log.Debug(Name + " PLC20=" + value);
// if (value == 0)
// {
// Place = "";
// PlaceState = ePlaceState.None;
// }
// else if (value > 0 && value < 1000)
// {
// //Place = "";
// //PlaceState = PlaceState.None;
// //TaskSend = "";
// }
// else if (value >= 1000)
// {
// int a = value / 1000;
// int b = (value - a * 1000) / 10;
// int c = value - a * 1000 - b * 10;
// //if (c.Equals(1) || c.Equals(3) || c.Equals(5))//Move,Enter,Leave
// // TaskSend = "";
// Place = (char)(64 + a) + b.ToString();
// if (Common.nodeInfo != null && Common.nodeInfo.Count != 0)
// {
// ClientNode node = Common.nodeInfo.Find(s => s.Name == Place);
// if (node != null)
// PlaceAliceName = node.AliceName;
// else
// PlaceAliceName = Place;
// }
// PlaceState = (ePlaceState)c;
// }
//}
public string[] ToRow()
{
//AGV名称,IP,AGV状态,任务状态,地点,后续任务,在线,电量,调用,清除缓存
List<string> s = new List<string>();
s.Add(Name);
s.Add(IP);
s.Add(StateID.ToString());
s.Add(CurTaskID.ToString());
s.Add(CurTaskName);
s.Add(CurTaskState);
//s.Add(Msg);
// s.Add(MissionText);
if (Common.nodeInfo != null && Common.nodeInfo.Count != 0)
{
ClientNode node = Common.nodeInfo.Find(ss => ss.Name == Place);
if (node != null)
PlaceAliceName = node.AliceName;
else
PlaceAliceName = Place;
}
s.Add(PlaceAliceName);
s.Add(IsExistShelf ? "满载" : "空载");
s.Add(IsCon ? "在线" : "离线");
s.Add(Battery + "%");
s.Add(IsUse ? "是" : "否");
return s.ToArray();
}
}
/// <summary>
/// MIR 状态,与状态ID对应
/// </summary>
public enum eAGVState
{
None = 0,
Starting,
ShuttingDown,
Ready,
Pause,
Executing,
Aborted,
Completed,
Docked,
Docking,
EmergencyStop,
ManualControl,
Error,
UNKNOWN
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl.bean
{
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)
{
AGVManager.updateDeviceAlarmMsg(MsgList);
ClearAlram();
}
}
}
}
using AGVControl;
using System;
using System.Collections.Generic;
namespace AGVControl
{
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 CurTaskName { get; set; } = "";
/// <summary>
/// 当前任务的执行状态
/// </summary>
public string CurTaskState { get; set; } = "Wait";
/// <summary>
/// 更新任务信息
/// </summary>
/// <param name="curTaskName"></param>
/// <param name="curTaskId"></param>
protected void UpdateJobTaskInfo(string curTaskName, int curTaskId)
{
CurTaskID = curTaskId;
CurTaskName = curTaskName;
//CurTaskState = SettingString.Wait;
CurTaskState = Common.GetTakJobState(CurTaskID);
}
/// <summary>
/// 任务重发
/// </summary>
/// <returns></returns>
public bool ResendTask(Agv_Info agv)
{
bool rtn = false;
if (!CurTaskID.Equals(-1) && Common.mir.Get_Task_State(CurTaskID, out string stateStr))
{
if (stateStr.Equals(SettingString.Aborted) || stateStr.Equals(SettingString.Invalid))
{
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[CurTaskName]);
if (rtn)
{
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
return true;
}
}
}
else if (!CurTaskName.Equals("") && !Common.agvMission[CurTaskName].Equals(agv.CurTaskGUID))//Job的当前任务与agv最新任务不一致
{
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[CurTaskName]);
if (rtn)
{
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
return true;
}
}
else if (CurTaskID.Equals(-1))//任务发送失败,重新发送
{
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[CurTaskName]);
if (rtn)
{
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
return true;
}
}
return false;
}
}
}
using AGVControl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl
{
public class JobStep<T> where T : Enum
{
private T step;
private string msg = "";
public string Msg
{
get { return msg; }
set
{
if (!string.IsNullOrEmpty(value))
{
value = step.ToString() + ":" + value;
//不为空,且与上一个消息不一样才打印
if (!value.Equals(msg))
{
Common.LogInfo(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 AGVControl.bean;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl
{
public class JobType
{
public JobType()
{
}
public virtual Job GetNewJob(Agv_Info agv)
{
return null;
}
}
}
文件属性发生变化

using AGVControl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.PeerResolvers;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AGVControl
{
/// <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 = "";
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return string.Format("充电任务:{0} [任务名称={1}][任务状态={2}]", runInfo,CurTaskName,CurTaskState); }
}
private JobStep<CHARGE_STEP> ChargeStep = new JobStep<CHARGE_STEP>(CHARGE_STEP.NONE);
/// <summary>
/// 空车返回执行
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = "";
CurTaskState = Common.GetTakJobState(CurTaskID);
if (ChargeStep.IsStep(CHARGE_STEP.NONE))
{
if (agvPlace.StartsWith(SettingString.C4_Name_Prefix))
{
ChargeStep.ToNextStep(CHARGE_STEP.WAIT_AGV_REACH_4D_DOOR);
runInfo = "电量[" + agv.Battery + "%]小于最大电量[" + Common.Charge.BatteryMax + "%],从当前位置" + agvPlace + "回到充电位,先到4D门";
msg += runInfo;
ChargeStep.Msg = msg;
Common.DoorMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
if (!Common.Charge.StartCharge(agv))
{
runInfo = "电量[" + agv.Battery + "%]小于最大电量[" + Common.Charge.BatteryMax + "%],由于充电桩有小车,从当前位置" + agvPlace + "回到待机位";
msg += runInfo;
ChargeStep.Msg = msg;
return new StandyJob(agv.Place);
}
else
{
ChargeStep.ToNextStep(CHARGE_STEP.WAIT_REACH_CHARGE_STATION);
runInfo = "电量[" + agv.Battery + "%]小于最大电量[" + Common.Charge.BatteryMax + "%],从当前位置" + agvPlace + "去到充电位";
msg += runInfo;
ChargeStep.Msg = msg;
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
}
else if (ChargeStep.IsStep(CHARGE_STEP.WAIT_AGV_REACH_4D_DOOR))
{
if (Common.CheckTaskMoveFinished(agv, SettingString.DoorCToD, CurTaskState))
{
if (agv.Battery > Common.Charge.BatteryMax)
{
runInfo = "电量充足[" + agv.Battery + "%],从当前位置" + agvPlace + "去到待机位";
msg += runInfo;
ChargeStep.Msg = msg;
return new StandyJob(agv.Place);
}
else
{
if (!Common.Charge.StartCharge(agv))
{
runInfo = "电量[" + agv.Battery + "%]小于最大电量[" + Common.Charge.BatteryMax + "%],充电桩有小车,从当前位置" + agvPlace + "回到待机位";
msg += runInfo;
ChargeStep.Msg = msg;
return new StandyJob(agv.Place);
}
else
{
ChargeStep.ToNextStep(CHARGE_STEP.WAIT_REACH_CHARGE_STATION);
runInfo = "电量[" + agv.Battery + "%]小于最大电量[" + Common.Charge.BatteryMax + "%],从当前位置" + agvPlace + "去到充电位";
msg += runInfo;
ChargeStep.Msg = msg;
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
}
}
else if (ChargeStep.IsStep(CHARGE_STEP.WAIT_REACH_CHARGE_STATION))
{
if (Common.CheckTaskFinished(agv, CurTaskName))
{
ChargeStep.ToNextStep(CHARGE_STEP.WAIT_REACH_CHARGE_OK);
runInfo = "充电任务分配完成,去充电且等待任务";
msg += runInfo;
ChargeStep.Msg = msg;
}
}
else if (ChargeStep.IsStep(CHARGE_STEP.WAIT_REACH_CHARGE_OK))
{
if (agv.Battery > Common.Charge.BatteryMax)
{
runInfo = "充电完成,回待机位";
msg += runInfo;
ChargeStep.Msg = msg;
Common.Charge.DelOccupyInfoByAGV(agv);
return new StandyJob(agv.Place);
}
else if(agv.Battery > Common.Charge.BatteryMin)
{
Job job = Common.control.GetJob(agv);
if (job != null && !(job is ChargeJob) && !(job is StandyJob))
{
runInfo = "在充电位检测到任务,电量[" + agv.Battery + " %]大于最小电量[" + Common.Charge.BatteryMin + " %],可执行任务";
msg += runInfo;
ChargeStep.Msg = msg;
Common.Charge.DelOccupyInfoByAGV(agv);
return job;
}
}
}
else if (ChargeStep.IsStep(CHARGE_STEP.END))
{
}
return this;
}
/// <summary>
/// AGV充电流程
/// </summary>
private enum CHARGE_STEP
{
/// <summary>
///
/// </summary>
NONE,
/// <summary>
/// 等待到达4D门
/// </summary>
WAIT_AGV_REACH_4D_DOOR,
/// <summary>
/// 等待AGV到达充电位
/// </summary>
WAIT_REACH_CHARGE_STATION,
/// <summary>
/// 等待充电完成
/// </summary>
WAIT_REACH_CHARGE_OK,
/// <summary>
/// 充电完成去待机位
/// </summary>
WAIT_REACH_STANDBY,
/// <summary>
///
/// </summary>
END
}
}
}

using AGVControl;
using MiR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl
{
/// <summary>
/// 小车进出料类型
/// </summary>
public enum eEnterLeaveType
{
/// <summary>
/// 小车进料
/// </summary>
Enter,
/// <summary>
/// 小车出料
/// </summary>
Leave,
}
/// <summary>
/// 进出料任务
/// </summary>
public class EnterLeaveShelfJob : Job
{
/// <summary>
/// 进出料任务
/// </summary>
/// <param name="curNode">位置点</param>
/// <param name="rfid">RFID</param>
public EnterLeaveShelfJob(ClientNode curNode, eEnterLeaveType type,string rfid="")
{
CurNode = curNode;
RFID = rfid;
ActionType = type;
runInfo = type.Equals(eEnterLeaveType.Enter) ? "小车进料任务:" : "小车出料任务:" +curNode.AliceName+" ";
}
/// <summary>
/// 位置点信息
/// </summary>
public ClientNode CurNode { get; set; }
public string RFID { get; set; }
/// <summary>
/// 动作类型
/// </summary>
public eEnterLeaveType ActionType { get; set; }
private string runInfo;
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return runInfo; }
}
private JobStep<ENTER_LEAVE_SHELF_STEP> EnterLeaveShelfStep = new JobStep<ENTER_LEAVE_SHELF_STEP>(ENTER_LEAVE_SHELF_STEP.NONE);
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name+ " ";
bool rtn = false;
agv.Msg = runInfo;
if (EnterLeaveShelfStep.IsStep(ENTER_LEAVE_SHELF_STEP.NONE))
{
if (ActionType.Equals(eEnterLeaveType.Leave))
{
EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_IN_LINE);
runInfo += "小车链条运行";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Leave"]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else if(ActionType.Equals(eEnterLeaveType.Enter))
{
EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_OUT_LINE);
runInfo +="小车链条运行";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Enter"]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (EnterLeaveShelfStep.IsStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_IN_LINE))
{
CurTaskState = Common.GetTakJobState(CurTaskID);
if (Common.CheckEnterOrLeaveFinished(agv, "Leave", CurTaskState))
{
//EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.END);
runInfo+= "料架/料串进入完成 [" + RFID + "]";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
agv.RFID = "";
// return new EmptyAGVBackJob(LineName);
}
else if (EnterLeaveShelfStep.IsTimeOut(60000, out double timeOutValue))
{
runInfo= "料架离开小车超时[" + timeOutValue.ToString("f1") + "秒],请检查料架离开小车的情况";
//msg += runInfo;
//EnterLeaveShelfStep.Msg = msg;
}
}
else if (EnterLeaveShelfStep.IsStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_OUT_LINE))
{
CurTaskState = Common.GetTakJobState(CurTaskID);
if (Common.CheckEnterOrLeaveFinished(agv, "Enter", CurTaskState))
{
//EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.END);
runInfo = "料架/料串出去完成 [" + RFID + "]";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
//return new EmptyShelfBackJob(LineName,eShelfType.BigShelf);
}
else if (EnterLeaveShelfStep.IsTimeOut(60000, out double timeOutValue))
{
//链条停止
runInfo= "料架进入小车超时[" + timeOutValue.ToString("f1") + "秒],请检查料架进入小车的情况";
//msg += runInfo;
//EnterLeaveShelfStep.Msg = msg;
}
}
else if (EnterLeaveShelfStep.IsStep(ENTER_LEAVE_SHELF_STEP.END))
{
}
return this;
}
}
/// <summary>
/// AGV进出料
/// </summary>
public enum ENTER_LEAVE_SHELF_STEP
{
/// <summary>
///
/// </summary>
NONE,
/// <summary>
/// 等待料架离开产线
/// </summary>
WAIT__SHELF_OUT_LINE,
/// <summary>
/// 等待料架进入产线
/// </summary>
WAIT__SHELF_IN_LINE,
/// <summary>
/// 进入/离开完成
/// </summary>
END
}
}
using AGVControl;
using AGVControl.bean.jobType;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.PeerResolvers;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AGVControl
{
/// <summary>
/// 取料串
/// </summary>
public class GetShelfJob : Job
{
/// <summary>
///取料串
/// </summary>
/// <param name="agvPlae">agv当前位置</param>
/// <param name="tarPlace">目的地</param>
/// <param name="RFID">RFID</param>
/// <param name="fullShelf">是否是满料串</param>
public GetShelfJob(string agvPlae, string tarPlace, string RFID = "", bool fullShelf = false)
{
this.agvPlace = agvPlae;
TargetPlace = tarPlace;
this.isFullShelf = fullShelf;
this.RFID = RFID;
}
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlace = "";
/// <summary>
/// 是否是满料串
/// </summary>
private bool isFullShelf = false;
/// <summary>
/// 目的地
/// </summary>
public string TargetPlace { get; private set; }
private string runInfo = "";
private string RFID = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get
{
int t1 = Common.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
string from = "";
if (t1 > -1)
from = Common.nodeInfo[t1].AliceName;
else
from = agvPlace;
int t2 = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
string to = "";
if (t2 > -1)
to = Common.nodeInfo[t2].AliceName;
else
to = TargetPlace;
return string.Format("取{5}料串任务[RFID={4}]: {0}[目的地={1}][任务名称={2}][任务状态={3}]", runInfo,to, CurTaskName, CurTaskState, RFID, isFullShelf ? "满" : "空");
}
}
private JobStep<EXECUTE_STEP> curJobStep = new JobStep<EXECUTE_STEP>(EXECUTE_STEP.P1_NONE);
private string GetShowInfo()
{
int t1 = Common.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
string from = "";
if (t1 > -1)
from = Common.nodeInfo[t1].AliceName;
else
from = agvPlace;
int t2 = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
string to = "";
if (t2 > -1)
to = Common.nodeInfo[t2].AliceName;
else
to = TargetPlace;
return string.Format("取料串任务[RFID={3}]: {0}[{1}->{2}]", runInfo, from, to, RFID); ;
}
/// <summary>
/// 任务执行
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = GetShowInfo();
CurTaskState = Common.GetTakJobState(CurTaskID);
if (curJobStep.IsStep(EXECUTE_STEP.P1_NONE))
{
if ((agvPlace.Equals(SettingString.Standby) || agvPlace.Equals(SettingString.AutoCharge)) && !TargetPlace.StartsWith(SettingString.C4_Name_Prefix))//D D
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_SHELF_PLACE);
runInfo = "待机位/充电位收到任务,开始执行";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else if (agvPlace.StartsWith(SettingString.C4_Name_Prefix) && !TargetPlace.StartsWith(SettingString.C4_Name_Prefix))//C D
{
curJobStep.ToNextStep(EXECUTE_STEP.P3_WAIT_REACH_4D_DOOR);
runInfo = "4C车间收到任务,先到4D门";
msg += runInfo;
curJobStep.Msg = msg;
Common.DoorMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else if (!agvPlace.StartsWith(SettingString.C4_Name_Prefix) && TargetPlace.StartsWith(SettingString.C4_Name_Prefix))// D C
{
curJobStep.ToNextStep(EXECUTE_STEP.P3_WAIT_REACH_4C_DOOR);
runInfo = "4D车间收到任务,先到4C门";
msg += runInfo;
curJobStep.Msg = msg;
Common.DoorMission(agv, SettingString.DoorDToC);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_SHELF_PLACE);
runInfo = "默认位置收到任务,开始执行";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P3_WAIT_REACH_4D_DOOR))
{
if (Common.CheckTaskMoveFinished(agv, SettingString.DoorCToD, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_SHELF_PLACE);
runInfo = "到达4D门,去料架处" + TargetPlace;
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P3_WAIT_REACH_4C_DOOR))
{
if (Common.CheckTaskMoveFinished(agv, SettingString.DoorDToC, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_SHELF_PLACE);
runInfo = "到达4C门,去料架处" + TargetPlace;
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P2_WAIT_REACH_SHELF_PLACE))
{
if (Common.CheckTaskMoveFinished(agv, TargetPlace, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.P4_WAIT_LINE_RESPONSE);
runInfo = "到达料架处" + TargetPlace + ",并向线体发送出料请求";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.Ready(TargetPlace, "");
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P4_WAIT_LINE_RESPONSE))
{
int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.MayLeave));
if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.P5_WAIT_SHELF_IN_AGV);
runInfo = "线体" + TargetPlace + "出料,链条运行";
msg += runInfo;
curJobStep.Msg = msg;
if (IsPlace(SettingString.A1) || IsPlace(SettingString.A7))//两位置出的架子需判断类型
{
RFID = Common.nodeInfo[i].RFID;
}
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[SettingString.Enter]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else if (curJobStep.IsTimeOut(15000, out double timeOutTime))
{
if (TargetPlace.Equals(SettingString.D3) || TargetPlace.Equals(SettingString.D4))
{
runInfo = string.Format("线体[{0}]允许出料信号[{1}]超时{2}秒,该处料串可能被手动干预,回待机位", TargetPlace, eNodeStatus.MayLeave, timeOutTime.ToString("f2"));
msg += string.Format("线体[{0}]允许出料信号[{1}]超时15S,该处料串可能被手动干预,回待机位", TargetPlace, eNodeStatus.MayLeave);
curJobStep.Msg = msg;
return new ChargeJob(TargetPlace);
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_SHELF_PLACE);
runInfo = string.Format("线体[{0}]允许出料信号[{1}]超时{2}秒,重发出料请求", TargetPlace, eNodeStatus.MayLeave, timeOutTime.ToString("f2"));
msg += string.Format("线体[{0}]允许出料信号[{1}]超时15S,重发出料请求", TargetPlace, eNodeStatus.MayLeave);
curJobStep.Msg = msg;
//去待机位
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P5_WAIT_SHELF_IN_AGV))
{
if (Common.CheckEnterOrLeaveFinished(agv, SettingString.Enter, CurTaskState))
{
Common.server.CloseDoor(TargetPlace);
if (IsPlace(SettingString.A1) || IsPlace(SettingString.A7))//两位置出的架子需判断类型
{
string tarNodeName1 = TargetPlace.Equals(SettingString.A1) ? SettingString.A2 : SettingString.A8;
if (RFID.StartsWith(SettingString.Packing_RFID_Prefix) || RFID.StartsWith("0"))//料串任务接到包装料架,任务取消
{
runInfo = "料架进入小车完成,由于该小车任务为料串任务,将该料架送回" + tarNodeName1;
msg += runInfo;
curJobStep.Msg = msg;
return new SendShelfJob(TargetPlace, tarNodeName1, RFID);
}
}
if (FindShelfTarget(agv, out string tarNodeName))
{
runInfo = "料串进入小车完成,任务结束";
msg += runInfo;
curJobStep.Msg = msg;
return new SendShelfJob(TargetPlace, tarNodeName, RFID);
}
else
{
if (TargetPlace.Equals(SettingString.G24_Out))
{
curJobStep.ToNextStep(EXECUTE_STEP.P7_WAIT_REACH_4D_DOOR);
runInfo = "在4C车间,去待机位先到4D门";
msg += runInfo;
curJobStep.Msg = msg;
Common.DoorMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.P6_WAIT_REACH_STANDBY);
runInfo = "料串进入小车完成,当前无节点需要料串,去待机位";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, SettingString.Standby);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
}
else if (curJobStep.IsTimeOut(60000, out double timeOutTime))
{
runInfo = string.Format("线体[{0}]出料超时{1}秒,请检查出料情况", TargetPlace, timeOutTime.ToString("f2"));
msg += string.Format("线体[{0}]出料超时,请检查出料情况", TargetPlace);
curJobStep.Msg = msg;
//去待机位
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P7_WAIT_REACH_4D_DOOR))
{
if (Common.CheckTaskMoveFinished(agv, SettingString.DoorCToD, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.P6_WAIT_REACH_STANDBY);
runInfo = "到达4D门,待机位";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, SettingString.Standby);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P6_WAIT_REACH_STANDBY))
{
if (Common.CheckTaskMoveFinished(agv, SettingString.Standby, CurTaskState))
{
runInfo = "到达待机位并搜索任务";
msg += runInfo;
curJobStep.Msg = msg;
if (FindShelfTarget(agv, out string tarNodeName))
{
runInfo = "搜索到料串目的地,任务结束";
msg += runInfo;
curJobStep.Msg = msg;
return new SendShelfJob(SettingString.Standby, tarNodeName, RFID);
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P8_END))
{
return null;
}
return this;
}
private bool FindShelfTarget(Agv_Info currentAgv, out string tarPlace)
{
tarPlace = "";
if (currentAgv.IP.Equals(SettingString.SingleMission_IP1))
{
//检查入料口1的C5是否需要满料串
if (isFullShelf)
{
if (!Common.control.limitArea.Available)
return false;
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.C5))
{
tarPlace = SettingString.C5;
return true;
}
}
else
{
//检查入料口1的C6是否有空料串要出
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.D1))
{
tarPlace = SettingString.D1;
return true;
}
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.A2))
{
tarPlace = SettingString.A2;
return true;
}
}
}
else//其他小车
{
if (isFullShelf)
{
//检查紧急出料口的C8出满料串
if (IsPlace(SettingString.C8))
{
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.A8))
{
tarPlace = SettingString.A8;
return true;
}
}
if (IsPlace(SettingString.D2) || IsPlace(SettingString.A1))
{
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.C1))
{
tarPlace = SettingString.C1;
return true;
}
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.C3))
{
tarPlace = SettingString.C3;
return true;
}
}
//退料线
if (IsPlace(SettingString.G24_Out))
{
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.D3))
{
tarPlace = SettingString.D3;
return true;
}
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.D4))
{
tarPlace = SettingString.D4;
return true;
}
}
}
else
{
if (IsPlace(SettingString.A7) || IsPlace(SettingString.C2) || IsPlace(SettingString.C4))
{
//检查紧急出料口C7需要空料串
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.C7))
{
tarPlace = SettingString.C7;
return true;
}
//检查点料机D1是否需要空料串
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.D1))
{
tarPlace = SettingString.D1;
return true;
}
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.A2))
{
tarPlace = SettingString.A2;
return true;
}
}
//退料线
if (IsPlace(SettingString.D3) || IsPlace(SettingString.D4))
{
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.G23_In))
{
tarPlace = SettingString.G23_In;
return true;
}
}
}
}
return false;
}
private bool IsPlace(string place)
{
return TargetPlace.Equals(place);
}
/// <summary>
/// 执行流程
/// </summary>
private enum EXECUTE_STEP
{
/// <summary>
/// 接收到任务
/// </summary>
P1_NONE,
/// <summary>
/// 等待到达包装料架处
/// </summary>
P2_WAIT_REACH_SHELF_PLACE,
/// <summary>
/// 等待到达4D
/// </summary>
P3_WAIT_REACH_4D_DOOR,
/// <summary>
/// 等待到达4C
/// </summary>
P3_WAIT_REACH_4C_DOOR,
/// <summary>
/// 等待线体回复
/// </summary>
P4_WAIT_LINE_RESPONSE,
/// <summary>
/// 等待料架进入AGV
/// </summary>
P5_WAIT_SHELF_IN_AGV,
/// <summary>
/// 等待到达待机位
/// </summary>
P6_WAIT_REACH_STANDBY,
/// <summary>
/// 等待到达4D
/// </summary>
P7_WAIT_REACH_4D_DOOR,
/// <summary>
/// 任务结束
/// </summary>
P8_END
}
}
}

using AGVControl;
using AGVControl.bean.jobType;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.PeerResolvers;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AGVControl
{
/// <summary>
/// 包装仓任务:取包装料架
/// </summary>
public class PackingJob_GetShelf : Job
{
/// <summary>
/// 接料架:空料架目的为出库;满料架目的为入库
/// </summary>
/// <param name="agvPlae">agv当前位置</param>
/// <param name="tarPlace">目的地</param>
/// <param name="mark">标志:出库任务则显示mark;入库任务显示Mark=InStore</param>
public PackingJob_GetShelf(string agvPlae, string tarPlace, string mark)
{
this.agvPlace = agvPlae;
TargetPlace = tarPlace;
this.mark = mark;
if (PackingJobType.IsInStoreMark(mark))
{
}
else
{
//修改mark状态
PackingJobType.ChangeMarkState(mark, eMarkState.Assigned);
}
}
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlace = "";
string RFID = "";
/// <summary>
/// 目的地
/// </summary>
public string TargetPlace { get; private set; }
/// <summary>
/// 标记
/// </summary>
public string mark = "";
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get
{
int t1 = Common.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
string from = "";
if (t1 > -1)
from = Common.nodeInfo[t1].AliceName;
else
from = agvPlace;
int t2 = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
string to = "";
if (t2 > -1)
to = Common.nodeInfo[t2].AliceName;
else
to = TargetPlace;
return string.Format("取包装料架任务:{0} [Mark={2}][目的地={1}][任务名称={3}][任务状态={4}]", runInfo,to, mark, CurTaskName, CurTaskState);
}
}
private JobStep<EXECUTE_STEP> curJobStep = new JobStep<EXECUTE_STEP>(EXECUTE_STEP.P1_NONE);
/// <summary>
/// 包装仓任务执行
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = runInfo;
CurTaskState = Common.GetTakJobState(CurTaskID);
if (curJobStep.IsStep(EXECUTE_STEP.P1_NONE))
{
if (agvPlace.Equals(SettingString.Standby) || agvPlace.Equals(SettingString.AutoCharge))
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_PACKING_SHELF_PLACE);
runInfo = "待机位/充电位收到任务,开始执行";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else if (agvPlace.StartsWith(SettingString.C4_Name_Prefix))
{
curJobStep.ToNextStep(EXECUTE_STEP.P1_1_WAIT_REACH_4D_DOOR);
runInfo = "4C车间收到任务,先到4D门";
msg += runInfo;
curJobStep.Msg = msg;
Common.DoorMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_PACKING_SHELF_PLACE);
runInfo = "默认位置收到任务,开始执行";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P1_1_WAIT_REACH_4D_DOOR))
{
if (Common.CheckTaskMoveFinished(agv, SettingString.DoorCToD, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_PACKING_SHELF_PLACE);
runInfo = "到达4D门,去包装料架处" + TargetPlace;
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P2_WAIT_REACH_PACKING_SHELF_PLACE))
{
if (Common.CheckTaskMoveFinished(agv, TargetPlace, CurTaskState))
{
if (PackingJobType.IsInStoreMark(mark))
{
curJobStep.ToNextStep(EXECUTE_STEP.P4_WAIT_LINE_RESPONSE);
runInfo = "到达包装料架处" + TargetPlace + ",并向线体发送出料请求";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.Ready(TargetPlace, "");
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.P3_CHECK_PACKING_STATION_STATE);
runInfo = "到达包装料架处" + TargetPlace;
msg += runInfo;
curJobStep.Msg = msg;
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P3_CHECK_PACKING_STATION_STATE))
{
if (PackingJobType.CheckNodeMark(mark))
{
curJobStep.ToNextStep(EXECUTE_STEP.P4_WAIT_LINE_RESPONSE);
runInfo = "当前任务" + mark + "确认存在,并向线体" + TargetPlace + "发送出料请求";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.Ready(TargetPlace, "");
}
else//
{
PackingJobType.DelMark(mark);
int nodeId = PackingJobType.CheckOutStroePackingJob();
if (nodeId == -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.P12_END);
runInfo = "当前任务" + mark + "不存在,且无其他包装任务";
msg += runInfo;
curJobStep.Msg = msg;
}
else if (nodeId > -1)
{
mark = Common.nodeInfo[nodeId].Mark;
//修改mark状态
PackingJobType.ChangeMarkState(mark, eMarkState.Assigned);
curJobStep.ToNextStep(EXECUTE_STEP.P4_WAIT_LINE_RESPONSE);
runInfo = "切换任务为" + mark + ",并向线体" + TargetPlace + "发送出料请求";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.Ready(TargetPlace, "");
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P4_WAIT_LINE_RESPONSE))
{
int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.P5_WAIT_SHELF_IN_AGV);
runInfo = "线体" + TargetPlace + "允许出料,链条运行";
msg += runInfo;
curJobStep.Msg = msg;
RFID = Common.nodeInfo[i].RFID;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[SettingString.Enter]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P5_WAIT_SHELF_IN_AGV))
{
if (Common.CheckEnterOrLeaveFinished(agv, SettingString.Enter, CurTaskState))
{
Common.server.CloseDoor(TargetPlace);
if (PackingJobType.IsInStoreMark(mark))
{
if (RFID.StartsWith(SettingString.ReelString_RFID_Prefix) || RFID.StartsWith("0"))
{
runInfo = "料串进入小车完成,由于当前任务是料架任务,将该料串送回,修改mark状态"+ mark+"="+eMarkState.None.ToString();
msg += runInfo;
curJobStep.Msg = msg;
//return new PackingJob_SendShelf(TargetPlace, SettingString.A2, mark, RFID);
PackingJobType.ChangeMarkState(mark, eMarkState.None);
return new SendShelfJob(TargetPlace, SettingString.A2, RFID);
}
}
if (FindPackingPlace(agv, out string packingPlace, out string rfid))
{
runInfo = "包装料架进入小车完成";
msg += runInfo;
curJobStep.Msg = msg;
return new PackingJob_SendShelf(TargetPlace, packingPlace, mark, rfid);
}
else
{
runInfo = "包装料架进入小车完成,包装仓无剩余任务," + packingPlace + "回收该料架";
msg += runInfo;
curJobStep.Msg = msg;
return new RecycleEmptyShelf(agvPlace, packingPlace, true, ShelfType.PackingShelf);
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P12_END))
{
return null;
}
return this;
}
/// <summary>
/// 查找包装仓目的地
/// </summary>
/// <param name="agv"></param>
/// <param name="packPlace"></param>
/// <returns></returns>
private bool FindPackingPlace(Agv_Info agv, out string packPlace, out string rfid)
{
if (mark.Equals(SettingString.InStore_Mark))
{
packPlace = SettingString.A2;//
rfid = "A#";
int i = Common.nodeInfo.FindIndex(s => s.Mark.Equals("0") && s.StateEquals(eNodeStatus.NeedEnter) && s.IsUse);
if (i > -1)
{
packPlace = Common.nodeInfo[i].Name;
Common.log.Info(string.Format("{0} 查找包装仓目的地{1}[Mark={2}][Marks={3}]", agv.Name, packPlace, mark, PackingJobType.GetMarks()));
return true;
}
else
{
PackingJobType.DelMark(mark);
//int nodeIdx = PackingJobType.CheckOutStroePackingJob();
//if (nodeIdx > -1)
//{
// string _mark = Common.nodeInfo[nodeIdx].Mark;
// //PackingJobType.ChangeMarkState(_mark, eMarkState.Executing);
// packPlace = Common.nodeInfo[nodeIdx].Name;
// rfid = Common.nodeInfo[nodeIdx].RFID;
// Common.log.Info(string.Format("{0} 找不到Mark={1}任务,切换为包装仓{2}的Mark={3}的任务[Marks={4}]", agv.Name, mark, packPlace, _mark, PackingJobType.GetMarks()));
// mark = _mark;
// return true;
//}
}
}
else
{
packPlace = SettingString.A3;//默认为回收料架处
rfid = "00";
int i = Common.nodeInfo.FindIndex(s => s.Mark.Equals(mark) && s.StateEquals(eNodeStatus.NeedEnter) && s.IsUse);
if (i > -1)
{
packPlace = Common.nodeInfo[i].Name;
Common.log.Info(string.Format("{0} 查找包装仓目的地{1}[Mark={2}][Marks={3}]", agv.Name, packPlace, mark, PackingJobType.GetMarks()));
return true;
}
else
{
PackingJobType.DelMark(mark);
int nodeIdx = PackingJobType.CheckOutStroePackingJob();
if (nodeIdx > -1)
{
string _mark = Common.nodeInfo[nodeIdx].Mark;
//PackingJobType.ChangeMarkState(_mark, eMarkState.Executing);
packPlace = Common.nodeInfo[nodeIdx].Name;
Common.log.Info(string.Format("{0} 找不到Mark={1}任务,切换为包装仓{2}的Mark={3}的任务[Marks={4}]", agv.Name, mark, packPlace, _mark, PackingJobType.GetMarks()));
mark = _mark;
return true;
}
}
}
Common.log.Info(string.Format("{0} 找不到Mark={1}任务及其他包装任务,将该料架送往回收处。[{2}]", agv.Name, mark, PackingJobType.GetMarks()));
return false;
}
/// <summary>
/// 执行流程
/// </summary>
private enum EXECUTE_STEP
{
/// <summary>
/// 接收到任务
/// </summary>
P1_NONE,
/// <summary>
/// 等待到达4D
/// </summary>
P1_1_WAIT_REACH_4D_DOOR,
/// <summary>
/// 等待到达包装料架处
/// </summary>
P2_WAIT_REACH_PACKING_SHELF_PLACE,
/// <summary>
/// 确认包装仓是否有该任务,防止该任务被手动出掉
/// </summary>
P3_CHECK_PACKING_STATION_STATE,
/// <summary>
/// 等待线体回复
/// </summary>
P4_WAIT_LINE_RESPONSE,
/// <summary>
/// 等待料架进入AGV
/// </summary>
P5_WAIT_SHELF_IN_AGV,
/// <summary>
/// 等待到达包装仓
/// </summary>
P6_WAIT_REACH_PACKING_STATION,
/// <summary>
/// 到达包装仓,再次确认是否有任务,防止该任务被手动出掉
/// </summary>
P7_CHECK_PACKING_STATION_STATE,
/// <summary>
/// 等待包装仓回复
/// </summary>
P8_WAIT_PACKING_STATION_RESPONSE,
/// <summary>
/// 等待AGV停靠完成
/// </summary>
P9_WAIT_AGV_DOCK_FINISH,
/// <summary>
/// 等待料架进入包装仓
/// </summary>
P10_WAIT_SHELF_IN_STATION,
/// <summary>
/// 等待到达空料架回收处
/// </summary>
P11_WAIT_REACH_RECYCLE_STATION,
/// <summary>
/// 任务结束
/// </summary>
P12_END
}
}
}

using AGVControl;
using AGVControl.bean.jobType;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.PeerResolvers;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AGVControl
{
/// <summary>
/// 包装仓任务:将包装料架送往包装仓
/// </summary>
public class PackingJob_SendShelf : Job
{
/// <summary>
/// 将包装料架送往包装仓
/// </summary>
/// <param name="agvPlae">agv当前位置</param>
/// <param name="tarPlace">目的地</param>
/// <param name="mark">标志:出库任务则显示mark;入库任务显示Mark=InStore</param>
public PackingJob_SendShelf(string agvPlae, string tarPlace, string mark,string RFID= "")
{
this.agvPlace = agvPlae;
TargetPlace = tarPlace;
this.mark = mark;
this.RFID = RFID;
if (PackingJobType.IsInStoreMark(mark))
{
}
else
{
//修改mark状态
PackingJobType.ChangeMarkState(mark, eMarkState.Executing);
}
}
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlace = "";
private string RFID = "";
/// <summary>
/// 目的地
/// </summary>
public string TargetPlace { get; private set; }
/// <summary>
/// 标记
/// </summary>
public string mark = "";
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get
{
int t1 = Common.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
string from = "";
if (t1 > -1)
from = Common.nodeInfo[t1].AliceName;
else
from = agvPlace;
int t2 = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
string to = "";
if (t2 > -1)
to = Common.nodeInfo[t2].AliceName;
else
to = TargetPlace;
return string.Format("送包装料架任务:{0} [RFID={5}][Mark={2}][目的地={1}][任务名称={3}][任务状态={4}]", runInfo, to, mark,CurTaskName,CurTaskState,RFID);
}
}
private JobStep<EXECUTE_STEP> curJobStep = new JobStep<EXECUTE_STEP>(EXECUTE_STEP.P1_NONE);
/// <summary>
/// 任务执行
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = runInfo;
CurTaskState = Common.GetTakJobState(CurTaskID);
if (curJobStep.IsStep(EXECUTE_STEP.P1_NONE))
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_PACKING_STATION);
runInfo = "收到任务,向包装仓" + TargetPlace + "运行";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else if (curJobStep.IsStep(EXECUTE_STEP.P2_WAIT_REACH_PACKING_STATION))
{
if (Common.CheckTaskMoveFinished(agv, TargetPlace, CurTaskState))
{
if (PackingJobType.IsInStoreMark(mark))
{
curJobStep.ToNextStep(EXECUTE_STEP.P4_WAIT_PACKING_STATION_RESPONSE);
runInfo = "到达包装仓" + TargetPlace + ",并发送到达信号";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.Arrive(TargetPlace, RFID);
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.P3_CHECK_PACKING_STATION_STATE);
runInfo = "到达包装仓" + TargetPlace;
msg += runInfo;
curJobStep.Msg = msg;
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P3_CHECK_PACKING_STATION_STATE))
{
if (PackingJobType.CheckNodeMark(mark, TargetPlace))
{
curJobStep.ToNextStep(EXECUTE_STEP.P4_WAIT_PACKING_STATION_RESPONSE);
runInfo = "到达包装仓" + TargetPlace + ",并发送到达信号";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.Arrive(TargetPlace, RFID);
}
else
{
if (PackingJobType.IsInStoreMark(mark))
{
runInfo = "包装仓" + TargetPlace + "无入库任务,回收该料架";
msg += runInfo;
curJobStep.Msg = msg;
return new SendShelfJob(TargetPlace,SettingString.A2,RFID);
}
else
{
runInfo = "包装仓" + TargetPlace + "无任务,回收该料架";
msg += runInfo;
curJobStep.Msg = msg;
return new RecycleEmptyShelf(agvPlace, "", true, ShelfType.PackingShelf);
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P4_WAIT_PACKING_STATION_RESPONSE))
{
int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.MayEnter));
if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.P5_WAIT_AGV_DOCK_FINISH);
runInfo = "收到线体对接请求,开始停靠";
msg += runInfo;
curJobStep.Msg = msg;
Common.DockToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else if (curJobStep.IsTimeOut(6000, out double timeOutTime))
{
runInfo = string.Format("线体[{0}]允许对接信号[{1}]超时{2}秒", TargetPlace, eNodeStatus.MayEnter, timeOutTime.ToString("f2"));
msg += string.Format("线体[{0}]允许对接信号[{1}]超时", TargetPlace, eNodeStatus.MayEnter);
curJobStep.Msg = msg;
curJobStep.ToNextStep(EXECUTE_STEP.P3_CHECK_PACKING_STATION_STATE);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P5_WAIT_AGV_DOCK_FINISH))
{
if (Common.CheckTaskDockFinished(agv, TargetPlace, CurTaskState))
{
Common.server.Ready(TargetPlace);
curJobStep.ToNextStep(EXECUTE_STEP.P6_WAIT_SHELF_IN_STATION);
runInfo = "停靠包装仓完成,链条运行";
msg += runInfo;
curJobStep.Msg = msg;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[SettingString.Leave]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P6_WAIT_SHELF_IN_STATION))
{
if (Common.CheckEnterOrLeaveFinished(agv, SettingString.Leave, CurTaskState))
{
Common.server.CloseDoor(TargetPlace);
//int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.FinishEnter));
//if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.P7_END);
runInfo = "包装料架进入包装仓"+TargetPlace+"完成";
msg += runInfo;
curJobStep.Msg = msg;
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P7_END))
{
//Job job = Common.control.GetJob(agv);
//if (job != null)
//{
// runInfo = "送料架任务完成,检测到任务,开始执行";
// msg += runInfo;
// curJobStep.Msg = msg;
// return job;
//}
return null;
}
return this;
}
/// <summary>
/// 执行流程
/// </summary>
private enum EXECUTE_STEP
{
/// <summary>
/// 接收到任务
/// </summary>
P1_NONE,
/// <summary>
/// 等待到达包装仓
/// </summary>
P2_WAIT_REACH_PACKING_STATION,
/// <summary>
/// 到达包装仓,再次确认是否有任务,防止该任务被手动出掉
/// </summary>
P3_CHECK_PACKING_STATION_STATE,
/// <summary>
/// 等待包装仓回复
/// </summary>
P4_WAIT_PACKING_STATION_RESPONSE,
/// <summary>
/// 等待AGV停靠完成
/// </summary>
P5_WAIT_AGV_DOCK_FINISH,
/// <summary>
/// 等待料架进入包装仓
/// </summary>
P6_WAIT_SHELF_IN_STATION,
/// <summary>
/// 任务结束
/// </summary>
P7_END
}
}
}

using AGVControl;
using AGVControl.bean.jobType;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.PeerResolvers;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AGVControl
{
/// <summary>
/// 包装仓任务:在包装仓间转移包装料架,
/// </summary>
public class PackingJob_TransferShelf : Job
{
/// <summary>
/// 包装仓任务
/// </summary>
/// <param name="agvPlae">小车当前位置</param>
public PackingJob_TransferShelf(string agvPlae, string tarPlace, string RFID, string mark)
{
this.agvPlace = agvPlae;
TargetPlace = tarPlace;
this.mark = mark;
this.RFID = RFID;
}
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlace = "";
/// <summary>
/// 料架RFID
/// </summary>
public string RFID = "";
/// <summary>
/// 目的地
/// </summary>
public string TargetPlace { get; private set; }
/// <summary>
/// 标记
/// </summary>
public string mark = "";
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get
{
int t1 = Common.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
string from = "";
if (t1 > -1)
from = Common.nodeInfo[t1].AliceName;
else
from = agvPlace;
int t2 = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
string to = "";
if (t2 > -1)
to = Common.nodeInfo[t2].AliceName;
else
to = TargetPlace;
return string.Format("包装料架转移任务:{0} [RFID={1}][Mark={2}][目的地={3}][任务名称={4}][任务状态={5}]", runInfo, RFID, mark,to,CurTaskName,CurTaskState);
}
}
private JobStep<EXECUTE_STEP> curJobStep = new JobStep<EXECUTE_STEP>(EXECUTE_STEP.P1_NONE);
/// <summary>
/// 任务执行
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = runInfo;
CurTaskState = Common.GetTakJobState(CurTaskID);
if (curJobStep.IsStep(EXECUTE_STEP.P1_NONE))
{
agv.RFID = RFID;
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_PACKING_STATION);
runInfo = "收到任务,向包装仓" + TargetPlace + "运行";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else if (curJobStep.IsStep(EXECUTE_STEP.P2_WAIT_REACH_PACKING_STATION))
{
if (Common.CheckTaskMoveFinished(agv, TargetPlace, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.P3_CHECK_PACKING_STATION_STATE);
runInfo = "到达包装仓" + TargetPlace;
msg += runInfo;
curJobStep.Msg = msg;
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P3_CHECK_PACKING_STATION_STATE))
{
if (PackingJobType.IsInStoreMark(mark))
{
curJobStep.ToNextStep(EXECUTE_STEP.P4_WAIT_PACKING_STATION_RESPONSE);
runInfo = "到达包装仓" + TargetPlace + ",并发送到达信号";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.Arrive(TargetPlace, RFID);
}
else
{
if (PackingJobType.CheckNodeMark(mark, TargetPlace))
{
curJobStep.ToNextStep(EXECUTE_STEP.P4_WAIT_PACKING_STATION_RESPONSE);
runInfo = "到达包装仓" + TargetPlace + ",并发送到达信号";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.Arrive(TargetPlace, RFID);
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.P15_END);
runInfo = "包装仓" + TargetPlace + "无任务,任务结束";
msg += runInfo;
curJobStep.Msg = msg;
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P4_WAIT_PACKING_STATION_RESPONSE))
{
int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.MayLeave));
if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.P5_WAIT_AGV_DOCK_FINISH);
runInfo = "收到线体对接请求,开始停靠";
msg += runInfo;
curJobStep.Msg = msg;
Common.DockToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
//else if (curJobStep.IsTimeOut(6000, out double timeOutTime))
//{
// runInfo = string.Format("线体[{0}]允许对接信号[{1}]超时{2}秒", TargetPlace, eNodeStatus.MayLeave, timeOutTime.ToString("f2"));
// msg += string.Format("线体[{0}]允许对接信号[{1}]超时", TargetPlace, eNodeStatus.MayLeave);
// curJobStep.Msg = msg;
//}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P5_WAIT_AGV_DOCK_FINISH))
{
if (Common.CheckTaskDockFinished(agv, TargetPlace, CurTaskState))
{
Common.server.Ready(TargetPlace);
curJobStep.ToNextStep(EXECUTE_STEP.P6_WAIT_SHELF_IN_AGV);
runInfo = "停靠包装仓完成,链条运行";
msg += runInfo;
curJobStep.Msg = msg;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[SettingString.Enter]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P6_WAIT_SHELF_IN_AGV))
{
if (Common.CheckEnterOrLeaveFinished(agv, SettingString.Enter, CurTaskState))
{
Common.server.CloseDoor(TargetPlace);
int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.FinishLeave));
if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.P7_FIND_LEFT_TASK);
runInfo = "包装料架进入小车完成";
msg += runInfo;
curJobStep.Msg = msg;
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P7_FIND_LEFT_TASK))
{
if(PackingJobType.IsInStoreMark(mark))//入库任务
{
if(CheckShelfLockInfo(agv,out string nodeName,out string lockedNodeNames))
{
if(nodeName.Equals(""))//有锁定节点,但目前忙碌,无法入料,去待机位
{
curJobStep.ToNextStep(EXECUTE_STEP.P14_WAIT_REACH_STANDBY);
runInfo = "入库任务Mark=" + mark + "有剩余任务,但包装仓忙碌,去待机位";
msg += runInfo+";锁定的节点:"+ lockedNodeNames;
curJobStep.Msg = msg;
agvPlace = agv.Place;
TargetPlace = SettingString.Standby;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else//有锁定节点
{
curJobStep.ToNextStep(EXECUTE_STEP.P8_TRANSFER_SHELF);
runInfo = "入库任务Mark=" + mark + "存在剩余任务,到下一包装仓执行任务";
msg += runInfo;
curJobStep.Msg = msg;
agvPlace = agv.Place;
TargetPlace = nodeName;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else//无锁定节点,去A2
{
curJobStep.ToNextStep(EXECUTE_STEP.P12_SEND_FULL_SHELF);
TargetPlace = SettingString.A2;
agvPlace = agv.Place;
runInfo = "入库任务Mark=" + mark + "完成, 去" + TargetPlace;
msg += runInfo;
curJobStep.Msg = msg;
PackingJobType.DelMark(mark);
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else
{
if (FindNextTask(agv, out int nodeIdx))
{
if (nodeIdx > -1)//该mark还有剩余任务
{
curJobStep.ToNextStep(EXECUTE_STEP.P8_TRANSFER_SHELF);
runInfo = "任务Mark=" + mark + "到下一包装仓执行任务";
msg += runInfo;
curJobStep.Msg = msg;
agvPlace = agv.Place;
TargetPlace = Common.nodeInfo[nodeIdx].Name;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else //pack任务还有剩余,但目前包装仓还未生成任务,去待机位
{
curJobStep.ToNextStep(EXECUTE_STEP.P14_WAIT_REACH_STANDBY);
runInfo = "任务Mark=" + mark + "有剩余任务,但包装仓还未生成,去待机位";
msg += runInfo;
curJobStep.Msg = msg;
agvPlace = agv.Place;
TargetPlace = SettingString.Standby;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else//出库任务完成
{
string name;
string[] ss = mark.Split(',');
switch (ss[1])
{
case "urgent": name = SettingString.A8; break; //紧急
case "cut": name = SettingString.A8; break; //分盘
case "pack": name = SettingString.A3; break; //包装
default: name = SettingString.A8; break;
}
curJobStep.ToNextStep(EXECUTE_STEP.P12_SEND_FULL_SHELF);
TargetPlace = name;
agvPlace = agv.Place;
runInfo = "任务Mark=" + mark + "出库完成, 去" + TargetPlace;
msg += runInfo;
curJobStep.Msg = msg;
PackingJobType.DelMark(mark);
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P8_TRANSFER_SHELF))
{
if (Common.CheckTaskMoveFinished(agv, TargetPlace, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.P9_WAIT_LINE_RESPONSE);
runInfo = "到达包装仓,发送到达信号";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.Arrive(TargetPlace, RFID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P9_WAIT_LINE_RESPONSE))
{
int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.MayEnter));
if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.P10_WAIT_AGV_DOCK_FINISH);
runInfo = "收到线体对接请求,开始停靠";
msg += runInfo;
curJobStep.Msg = msg;
Common.DockToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else if (curJobStep.IsTimeOut(6000, out double timeOutTime))
{
runInfo = string.Format("线体[{0}]允许对接信号[{1}]超时{2}秒", TargetPlace, eNodeStatus.MayEnter, timeOutTime.ToString("f2"));
msg += string.Format("线体[{0}]允许对接信号[{1}]超时", TargetPlace, eNodeStatus.MayEnter);
curJobStep.Msg = msg;
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P10_WAIT_AGV_DOCK_FINISH))
{
if (Common.CheckTaskDockFinished(agv, TargetPlace, CurTaskState))
{
Common.server.Ready(TargetPlace, RFID);
curJobStep.ToNextStep(EXECUTE_STEP.P11_WAIT_SHELF_IN_LINE);
runInfo = "停靠包装仓完成,链条运行";
msg += runInfo;
curJobStep.Msg = msg;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[SettingString.Leave]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P11_WAIT_SHELF_IN_LINE))
{
if (Common.CheckEnterOrLeaveFinished(agv, SettingString.Leave, CurTaskState))
{
Common.server.CloseDoor(TargetPlace);
//int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.FinishEnter));
//if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.P15_END);
runInfo = "包装料架进入" + TargetPlace + "完成,任务结束";
msg += runInfo;
curJobStep.Msg = msg;
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P12_SEND_FULL_SHELF))
{
if (Common.CheckTaskMoveFinished(agv, TargetPlace, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.P13_WAIT_TARGET_RESPONSE);
runInfo = "到达目的地" + TargetPlace + ",并发送准备信号";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.Ready(TargetPlace, RFID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P13_WAIT_TARGET_RESPONSE))
{
//int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.MayEnter));
//if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.P11_WAIT_SHELF_IN_LINE);
runInfo = "收到线体入料请求,链条运行";
msg += runInfo;
curJobStep.Msg = msg;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[SettingString.Leave]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
//else if (curJobStep.IsTimeOut(6000, out double timeOutTime))
//{
// runInfo = string.Format("线体[{0}]允许入料信号[{1}]超时{2}秒", TargetPlace, eNodeStatus.MayEnter, timeOutTime.ToString("f2"));
// msg += string.Format("线体[{0}]允许入料信号[{1}]超时", TargetPlace, eNodeStatus.MayEnter);
// curJobStep.Msg = msg;
//}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P14_WAIT_REACH_STANDBY))
{
if (Common.CheckTaskMoveFinished(agv, SettingString.Standby, CurTaskState))
{
if (FindNextTask(agv, out int nodeIdx))
{
if (nodeIdx > -1)//该mark还有剩余任务
{
curJobStep.ToNextStep(EXECUTE_STEP.P8_TRANSFER_SHELF);
runInfo = "任务Mark=" + mark + "到下一包装仓执行任务";
msg += runInfo;
curJobStep.Msg = msg;
TargetPlace = Common.nodeInfo[nodeIdx].Name;
agvPlace = agv.Place;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P15_END))
{
agv.RFID = "";
return null;
//Job job = Common.control.GetJob(agv);
//if (job != null)
//{
// runInfo = "包装仓转移料架任务完成,检测到任务,开始执行";
// msg += runInfo;
// curJobStep.Msg = msg;
// return job;
//}
}
return this;
}
/// <summary>
/// 根据mark查找下一个任务
/// </summary>
/// <returns></returns>
private bool FindNextTask(Agv_Info agv, out int nodeIdx)
{
//寻找下一个任务点
nodeIdx = Common.nodeInfo.FindIndex(s => s.StateEquals(eNodeStatus.NeedEnter) && s.Mark == mark && s.AgvName == "" && s.IsUse);
if (nodeIdx > -1)
return true;
else
{
if (!mark.Split(',')[1].Equals("pack"))
{
string log = " [Mark=" + mark + "] 出库任务完成";
Common.LogInfo(log);
return false;
}
bool rtn = AGVManager.LeaveCheck(agv, out int taskCount);
Thread.Sleep(1000);
if (!rtn)//出库任务还未完成
{
string log = agv.Name + " [Mark=" + mark + "] 出库任务未完成,[taskCount=" + taskCount.ToString() + "]";
Common.LogInfo(log);
return true;
}
else
{
string log = agv.Name + " [Mark=" + mark + "] [taskCount = " + taskCount.ToString() + "] 出库任务完成";
Common.LogInfo(log);
return false;
}
}
}
private bool CheckShelfLockInfo(Agv_Info agv, out string nodeName,out string lockedNodeNames)
{
List<string> shelfLockedNodeNames = new List<string>();
nodeName = "";
lockedNodeNames = "";
//获取料架锁定信息
AGVManager.GetShelfLockInfo(TargetPlace, RFID, shelfLockedNodeNames);
Thread.Sleep(1000);
if (shelfLockedNodeNames != null && shelfLockedNodeNames.Count > 0)
{
foreach (string item in shelfLockedNodeNames)
{
int nodeIdx = Common.nodeInfo.FindIndex(s => s.Name == item && s.StateEquals(eNodeStatus.NeedEnter) && s.Mark.Equals("") && (s.AgvName == "" || s.AgvName == agv.Name) && s.IsUse);
if (nodeIdx > -1)
{
nodeName = item;
shelfLockedNodeNames.Remove(item);
return true;
}
}
lockedNodeNames = string.Join(";", shelfLockedNodeNames);
return true;
}
return false;
}
/// <summary>
/// 执行流程
/// </summary>
private enum EXECUTE_STEP
{
/// <summary>
/// 接收到任务
/// </summary>
P1_NONE,
/// <summary>
/// 等待到达包装仓
/// </summary>
P2_WAIT_REACH_PACKING_STATION,
/// <summary>
/// 到达包装仓
/// </summary>
P3_CHECK_PACKING_STATION_STATE,
/// <summary>
/// 等待包装仓回复
/// </summary>
P4_WAIT_PACKING_STATION_RESPONSE,
/// <summary>
/// 等待AGV停靠完成
/// </summary>
P5_WAIT_AGV_DOCK_FINISH,
/// <summary>
/// 等待料架进入AGV
/// </summary>
P6_WAIT_SHELF_IN_AGV,
/// <summary>
/// 查询剩余任务
/// </summary>
P7_FIND_LEFT_TASK,
/// <summary>
/// 转移料架
/// </summary>
P8_TRANSFER_SHELF,
/// <summary>
/// 等待线体回复
/// </summary>
P9_WAIT_LINE_RESPONSE,
/// <summary>
/// 等待AGV停靠完成
/// </summary>
P10_WAIT_AGV_DOCK_FINISH,
/// <summary>
/// 等待料架进入线体
/// </summary>
P11_WAIT_SHELF_IN_LINE,
/// <summary>
/// 运送满料架
/// </summary>
P12_SEND_FULL_SHELF,
/// <summary>
/// 等待满料目的地回复
/// </summary>
P13_WAIT_TARGET_RESPONSE,
/// <summary>
/// 等待到达待机位
/// </summary>
P14_WAIT_REACH_STANDBY,
/// <summary>
/// 任务结束
/// </summary>
P15_END
}
}
}

using AGVControl;
using AGVControl.bean.jobType;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.PeerResolvers;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AGVControl
{
public enum ShelfType
{
/// <summary>
/// 包装料架
/// </summary>
PackingShelf,
/// <summary>
/// 料串
/// </summary>
ReelString
}
/// <summary>
/// 回收空料架
/// </summary>
public class RecycleEmptyShelf : Job
{
/// <summary>
/// 回收空料架
/// </summary>
/// <param name="agvPlae">小车当前位置,空表示在待机位</param>
public RecycleEmptyShelf(string agvPlae, string tarPlace, bool hasLoad=false,ShelfType type = ShelfType.ReelString)
{
this.agvPlace = agvPlae;
TargetPlace = tarPlace;
shelfType = type;
this.hasLoad = hasLoad;
}
/// <summary>
/// 车上有负载
/// </summary>
private bool hasLoad = false;
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlace = "";
/// <summary>
/// 目的地
/// </summary>
public string TargetPlace { get; private set; }
/// <summary>
/// 料架类型
/// </summary>
public ShelfType shelfType;
/// <summary>
/// 回收料架处
/// </summary>
public string RecycleStation = "";
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get
{
int t1 = Common.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
string from = "";
if (t1 > -1)
from = Common.nodeInfo[t1].AliceName;
else
from = agvPlace;
int t2 = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
string to = "";
if (t2 > -1)
to = Common.nodeInfo[t2].AliceName;
else
to = TargetPlace;
return string.Format("回收空料架任务:{0} [ShelfType={1}][任务名称={2}][任务状态={3}]", runInfo, shelfType.ToString(),CurTaskName,CurTaskState);
}
}
private JobStep<EXECUTE_STEP> curJobStep = new JobStep<EXECUTE_STEP>(EXECUTE_STEP.R1_NONE);
/// <summary>
/// 任务执行
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = runInfo;
CurTaskState = Common.GetTakJobState(CurTaskID);
if (curJobStep.IsStep(EXECUTE_STEP.R1_NONE))
{
if(hasLoad)
{
if (FindRecycleStation())
{
curJobStep.ToNextStep(EXECUTE_STEP.R5_WAIT_REACH_RECYCLE_STATION);
runInfo = "车上已有空料架,向" + RecycleStation + "运行";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, RecycleStation);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.R8_WAIT_REACH_STANDY);
runInfo = "车上已有空料架,由于未找到接收空料架处,先回待机位";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, SettingString.Standby);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else//车上无料
{
if (agvPlace.Equals(SettingString.Standby) || agvPlace.Equals(SettingString.AutoCharge))
{
curJobStep.ToNextStep(EXECUTE_STEP.R2_WAIT_REACH_EMPTY_SHELF_PLACE);
runInfo = "待机位/充电位收到任务,开始执行";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.R2_WAIT_REACH_EMPTY_SHELF_PLACE);
runInfo = "默认位置收到任务,开始执行";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.R2_WAIT_REACH_EMPTY_SHELF_PLACE))
{
if (Common.CheckTaskMoveFinished(agv, TargetPlace, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.R3_WAIT_LINE_RESPONSE);
runInfo = "到达空料架处"+TargetPlace+",向线体发送出料请求";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.Ready(TargetPlace, "");
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.R3_WAIT_LINE_RESPONSE))
{
//int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.MayLeave));
//if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.R4_WAIT_SHELF_IN_AGV);
runInfo = "线体"+TargetPlace+"允许出料,链条运行";
msg += runInfo;
curJobStep.Msg = msg;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[SettingString.Enter]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
//else if(curJobStep.IsTimeOut(6000,out double timeOutTime))
//{
// runInfo = string.Format("线体[{0}]允许出料信号[{1}]超时{2}秒",TargetPlace,eNodeStatus.MayLeave,timeOutTime.ToString("f2"));
// msg += string.Format("线体[{0}]允许出料信号[{1}]超时", TargetPlace, eNodeStatus.MayLeave);;
// curJobStep.Msg = msg;
//}
}
else if (curJobStep.IsStep(EXECUTE_STEP.R4_WAIT_SHELF_IN_AGV))
{
if (Common.CheckEnterOrLeaveFinished(agv, SettingString.Enter, CurTaskState))
{
Common.server.CloseDoor(TargetPlace);
if (FindRecycleStation())
{
curJobStep.ToNextStep(EXECUTE_STEP.R5_WAIT_REACH_RECYCLE_STATION);
runInfo = "空料架进入小车完成,向"+TargetPlace+"运行";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, RecycleStation);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.R8_WAIT_REACH_STANDY);
runInfo = "空料架进入小车完成,由于未找到接收空料架处,先回待机位";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, SettingString.Standby);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.R5_WAIT_REACH_RECYCLE_STATION))
{
if (Common.CheckTaskMoveFinished(agv, RecycleStation, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.R6_WAIT_RECYCLE_STATION_RESPONSE);
runInfo = "到达"+TargetPlace+",发送入料请求";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.Ready(RecycleStation,"00");
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.R6_WAIT_RECYCLE_STATION_RESPONSE))
{
//int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(RecycleStation) && s.StateEquals(eNodeStatus.MayEnter));
//if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.R7_WAIT_SHELF_IN_LINE);
runInfo = "收到线体入料请求,链条运行";
msg += runInfo;
curJobStep.Msg = msg;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[SettingString.Leave]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
//else if (curJobStep.IsTimeOut(6000, out double timeOutTime))
//{
// runInfo = string.Format("线体[{0}]允许入料信号[{1}]超时{2}秒", RecycleStation, eNodeStatus.MayEnter, timeOutTime.ToString("f2"));
// msg += string.Format("线体[{0}]允许入料信号[{1}]超时", RecycleStation, eNodeStatus.MayEnter);
// curJobStep.Msg = msg;
//}
}
else if (curJobStep.IsStep(EXECUTE_STEP.R7_WAIT_SHELF_IN_LINE))
{
if (Common.CheckEnterOrLeaveFinished(agv, SettingString.Leave, CurTaskState))
{
Common.server.CloseDoor(RecycleStation);
//int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(RecycleStation) && s.StateEquals(eNodeStatus.FinishEnter));
//if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.R9_END);
runInfo = "空料架进入"+RecycleStation+"完成";
msg += runInfo;
curJobStep.Msg = msg;
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.R8_WAIT_REACH_STANDY))
{
if (Common.CheckTaskMoveFinished(agv, SettingString.Standby, CurTaskState))
{
if (FindRecycleStation())
{
curJobStep.ToNextStep(EXECUTE_STEP.R5_WAIT_REACH_RECYCLE_STATION);
runInfo = "检测到"+RecycleStation+"需要空料架,向" + RecycleStation + "运行";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, RecycleStation);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.R9_END))
{
//Job job = Common.control.GetJob(agv);
//if (job != null)
//{
// runInfo = "回收空料架任务完成,检测到任务,开始执行";
// msg += runInfo;
// curJobStep.Msg = msg;
// return job;
//}
return null;
}
return this;
}
/// <summary>
/// 搜索接收空料架的地方
/// </summary>
/// <returns></returns>
private bool FindRecycleStation()
{
if(shelfType.Equals(ShelfType.ReelString))
{
int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.C7) && s.StateEquals(eNodeStatus.NeedEnter));
if(i==-1) i = Common.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.D1) && s.StateEquals(eNodeStatus.NeedEnter));
if (i == -1) i = Common.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A2) && s.StateEquals(eNodeStatus.NeedEnter));
if(i>-1)
{
RecycleStation = Common.nodeInfo[i].Name;
return true;
}
}
else if(shelfType.Equals(ShelfType.PackingShelf))
{
int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A3) && s.StateEquals(eNodeStatus.NeedEnter));
if (i == -1) i = Common.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A2) && s.StateEquals(eNodeStatus.NeedEnter));
if (i == -1) i = Common.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A8) && s.StateEquals(eNodeStatus.NeedEnter));
if (i > -1)
{
RecycleStation = Common.nodeInfo[i].Name;
return true;
}
}
return false;
}
/// <summary>
/// 执行流程
/// </summary>
private enum EXECUTE_STEP
{
/// <summary>
/// 接收到任务
/// </summary>
R1_NONE,
/// <summary>
/// 等待到达空料架处
/// </summary>
R2_WAIT_REACH_EMPTY_SHELF_PLACE,
/// <summary>
/// 等待线体回复
/// </summary>
R3_WAIT_LINE_RESPONSE,
/// <summary>
/// 等待料架进入AGV
/// </summary>
R4_WAIT_SHELF_IN_AGV,
/// <summary>
/// 等待到达空料架回收处
/// </summary>
R5_WAIT_REACH_RECYCLE_STATION,
/// <summary>
/// 等待回收线体回复
/// </summary>
R6_WAIT_RECYCLE_STATION_RESPONSE,
/// <summary>
/// 等待料架进入线体
/// </summary>
R7_WAIT_SHELF_IN_LINE,
/// <summary>
/// 等待到达待机位
/// </summary>
R8_WAIT_REACH_STANDY,
/// <summary>
/// 任务结束
/// </summary>
R9_END
}
}
}

using AGVControl;
using AGVControl.bean.jobType;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.PeerResolvers;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AGVControl
{
/// <summary>
///送料串
/// </summary>
public class SendShelfJob : Job
{
/// <summary>
/// 送料串
/// </summary>
/// <param name="agvPlae">agv当前位置</param>
/// <param name="tarPlace">目的地</param>
public SendShelfJob(string agvPlae, string tarPlace, string RFID = "")
{
this.agvPlace = agvPlae;
TargetPlace = tarPlace;
this.RFID = RFID;
}
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlace = "";
private string RFID = "";
/// <summary>
/// 目的地
/// </summary>
public string TargetPlace { get; private set; }
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get
{
int t1 = Common.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
string from = "";
if (t1 > -1)
from = Common.nodeInfo[t1].AliceName;
else
from = agvPlace;
int t2 = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
string to = "";
if (t2 > -1)
to = Common.nodeInfo[t2].AliceName;
else
to = TargetPlace;
return string.Format("送料串任务[RFID={4}]:{0} [目的地={1}][任务名称={2}][任务状态={3}]", runInfo, to, CurTaskName, CurTaskState, RFID);
}
}
private JobStep<EXECUTE_STEP> curJobStep = new JobStep<EXECUTE_STEP>(EXECUTE_STEP.P1_NONE);
private string GetShowInfo()
{
int t1 = Common.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
string from = "";
if (t1 > -1)
from = Common.nodeInfo[t1].AliceName;
else
from = agvPlace;
int t2 = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
string to = "";
if (t2 > -1)
to = Common.nodeInfo[t2].AliceName;
else
to = TargetPlace;
return string.Format("取料串任务[RFID={3}]: {0}[{1}->{2}]", runInfo, from, to, RFID);
}
/// <summary>
/// 任务执行
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = GetShowInfo();
CurTaskState = Common.GetTakJobState(CurTaskID);
if (curJobStep.IsStep(EXECUTE_STEP.P1_NONE))
{
if (!agvPlace.StartsWith(SettingString.C4_Name_Prefix) && TargetPlace.StartsWith(SettingString.C4_Name_Prefix))//D C
{
curJobStep.ToNextStep(EXECUTE_STEP.P3_WAIT_REACH_4C_DOOR);
runInfo = "收到任务,在4D车间,向" + TargetPlace + "运行,先过门";
msg += runInfo;
curJobStep.Msg = msg;
Common.DoorMission(agv, SettingString.DoorDToC);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else if (agvPlace.StartsWith(SettingString.C4_Name_Prefix) && !TargetPlace.StartsWith(SettingString.C4_Name_Prefix))//C D
{
curJobStep.ToNextStep(EXECUTE_STEP.P3_WAIT_REACH_4D_DOOR);
runInfo = "收到任务,在4C车间,向" + TargetPlace + "运行,先过门";
msg += runInfo;
curJobStep.Msg = msg;
Common.DoorMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else//DD CC
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_STATION);
runInfo = "收到任务,向" + TargetPlace + "运行";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P2_WAIT_REACH_STATION))
{
if (Common.CheckTaskMoveFinished(agv, TargetPlace, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.P4_WAIT_STATION_RESPONSE);
runInfo = "到达" + TargetPlace + ",并发送进料请求";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.Ready(TargetPlace, RFID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P3_WAIT_REACH_4D_DOOR))
{
if (Common.CheckTaskMoveFinished(agv, SettingString.DoorCToD, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_STATION);
runInfo = "到达4D门,去料架处" + TargetPlace;
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P3_WAIT_REACH_4C_DOOR))
{
if (Common.CheckTaskMoveFinished(agv, SettingString.DoorDToC, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_STATION);
runInfo = "到达4C门,去料架处" + TargetPlace;
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P4_WAIT_STATION_RESPONSE))
{
int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.MayEnter));
if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.P5_WAIT_SHELF_IN_STATION);
runInfo = "收到线体允许进料信号,链条运行";
msg += runInfo;
curJobStep.Msg = msg;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission[SettingString.Leave]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else if (curJobStep.IsTimeOut(15000, out double timeOutTime))
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_STATION);
runInfo = string.Format("线体[{0}]允许进料信号[{1}]超时{2}秒,重发进料请求", TargetPlace, eNodeStatus.MayEnter, timeOutTime.ToString("f2"));
msg += string.Format("线体[{0}]允许进料信号[{1}]超时15S,重发进料请求", TargetPlace, eNodeStatus.MayEnter);
curJobStep.Msg = msg;
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P5_WAIT_SHELF_IN_STATION))
{
if (Common.CheckEnterOrLeaveFinished(agv, SettingString.Leave, CurTaskState))
{
Common.server.CloseDoor(TargetPlace);
if (IsPlace(SettingString.G23_In) && FindReturnShelf(agv))
{
runInfo = "料架进入" + TargetPlace + "完成,去退料线出口取一个料串回点料机";
msg += runInfo;
curJobStep.Msg = msg;
return new GetShelfJob(TargetPlace, SettingString.G24_Out, "B#", true);
}
else
{
if(agv.IP.Equals(SettingString.SingleMission_IP1))
{
if (IsPlace(SettingString.A2) && !Common.control.limitArea.Available)
{
runInfo = "料架进入" + TargetPlace + "完成,等待限制区域无车";
msg += runInfo;
curJobStep.Msg = msg;
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.P6_END);
runInfo = "料架进入" + TargetPlace + "完成";
msg += runInfo;
curJobStep.Msg = msg;
}
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.P6_END);
runInfo = "料架进入" + TargetPlace + "完成";
msg += runInfo;
curJobStep.Msg = msg;
}
}
}
else if (curJobStep.IsTimeOut(60000, out double timeOutTime))
{
runInfo = string.Format("线体[{0}]出料超时{1}秒,请检查料架情况", TargetPlace, timeOutTime.ToString("f2"));
msg += string.Format("线体[{0}]出料超时,请检查料架情况", TargetPlace);
curJobStep.Msg = msg;
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P6_END))
{
return null;
}
return this;
}
private bool IsPlace(string place)
{
return TargetPlace.Equals(place);
}
private bool FindReturnShelf(Agv_Info currentAgv)
{
string rfid = "";
if (ReelStringJobType.FindNeedLeaveMission(currentAgv, SettingString.G24_Out, out rfid))
{
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.D3))
{
Common.LogInfo(string.Format("{0} 在退料线生成任务(D3需要满料串,G24出满料串):Place={1},rfid={2}", currentAgv.Name, SettingString.D3, rfid));
return true;
}
}
if (ReelStringJobType.FindNeedLeaveMission(currentAgv, SettingString.D4, out rfid))
{
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.G23_In))
{
Common.LogInfo(string.Format("{0} 在退料线生成任务(D4需要满料串,G24出满料串):Place={1},rfid={2}", currentAgv.Name, SettingString.D4, rfid));
return true;
}
}
return false;
}
/// <summary>
/// 执行流程
/// </summary>
private enum EXECUTE_STEP
{
/// <summary>
/// 接收到任务
/// </summary>
P1_NONE,
/// <summary>
/// 等待到达目的地
/// </summary>
P2_WAIT_REACH_STATION,
/// <summary>
/// 等待到达4D
/// </summary>
P3_WAIT_REACH_4D_DOOR,
/// <summary>
/// 等待到达4C
/// </summary>
P3_WAIT_REACH_4C_DOOR,
/// <summary>
/// 等待线体回复
/// </summary>
P4_WAIT_STATION_RESPONSE,
/// <summary>
/// 等待料架进入线体
/// </summary>
P5_WAIT_SHELF_IN_STATION,
/// <summary>
/// 任务结束
/// </summary>
P6_END
}
}
}

using AGVControl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.PeerResolvers;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AGVControl
{
/// <summary>
/// 待机任务
/// </summary>
public class StandyJob : Job
{
/// <summary>
/// 出完满料后-空车返回任务
/// </summary>
/// <param name="agvPlae">小车当前位置,空表示在待机位</param>
public StandyJob(string agvPlae)
{
this.agvPlace = agvPlae;
}
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlace = "";
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return string.Format("待机任务:{0} [任务名称={1}][任务状态={2}]", runInfo,CurTaskName,CurTaskState); }
}
private JobStep<EXECUTE_STEP> curJobStep = new JobStep<EXECUTE_STEP>(EXECUTE_STEP.NONE);
/// <summary>
/// 空车返回执行
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = "";
CurTaskState = Common.GetTakJobState(CurTaskID);
if (curJobStep.IsStep(EXECUTE_STEP.NONE))
{
if (agvPlace.Equals(SettingString.Standby))//在待机位不操作
{
curJobStep.ToNextStep(EXECUTE_STEP.END);
runInfo = "在待机位,不执行操作";
msg += runInfo;
curJobStep.Msg = msg;
}
else if (agvPlace.StartsWith(SettingString.C4_Name_Prefix))
{
curJobStep.ToNextStep(EXECUTE_STEP.WAIT_AGV_REACH_4D_DOOR);
runInfo = "从当前位置" + agvPlace + "回到待机位,先到4D门";
msg += runInfo;
curJobStep.Msg = msg;
Common.DoorMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.WAIT_REACH_STANDBY);
runInfo = "从当前位置" + agvPlace + "回到待机位";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, SettingString.Standby);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.WAIT_AGV_REACH_4D_DOOR))
{
if (Common.CheckTaskMoveFinished(agv, SettingString.DoorCToD, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.WAIT_REACH_STANDBY);
runInfo = "从4D门回到待机位";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveToNode(agv, SettingString.Standby);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.WAIT_REACH_STANDBY))
{
if (Common.CheckTaskMoveFinished(agv, SettingString.Standby, CurTaskState))
{
curJobStep.ToNextStep(EXECUTE_STEP.END);
runInfo = "到达待机位";
msg += runInfo;
curJobStep.Msg = msg;
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.END))
{
Job job = Common.control.GetJob(agv);
if (job != null && !(job is StandyJob))
{
runInfo = "在待机位检测到任务,执行任务";
msg += runInfo;
curJobStep.Msg = msg;
return job;
}
}
return this;
}
/// <summary>
/// 执行流程
/// </summary>
private enum EXECUTE_STEP
{
/// <summary>
///
/// </summary>
NONE,
/// <summary>
/// 等待到达4D门
/// </summary>
WAIT_AGV_REACH_4D_DOOR,
/// <summary>
/// 等待到达待机位
/// </summary>
WAIT_REACH_STANDBY,
/// <summary>
///
/// </summary>
END
}
}
}
文件属性发生变化
using MiR;
using log4net.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl.bean.jobType
{
/// <summary>
/// 待机任务
/// </summary>
public class ChargeJobType : JobType
{
/// <summary>
/// 待机任务
/// </summary>
/// <param name="currentAgv"></param>
/// <returns></returns>
public override Job GetNewJob(Agv_Info currentAgv)
{
if (currentAgv.Battery < Common.Charge.BatteryMax - 10 && Common.Charge.HasEmptyChargeStation())
{
return new ChargeJob(currentAgv.Place);
}
else
{
return new StandyJob(currentAgv.Place);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Management;
namespace AGVControl.bean.jobType
{
public enum eMarkState
{
None,
Assigned,
Executing,
Finished
}
/// <summary>
/// 搜索包装仓任务
/// </summary>
public class PackingJobType : JobType
{
/// <summary>
/// 标记
/// </summary>
private static Dictionary<string, eMarkState> Marks = new Dictionary<string, eMarkState>();
private static object locBoj = new object();
public PackingJobType()
{
}
public static string GetMarks()
{
if (Marks != null && Marks.Count > 0)
{
StringBuilder temp = new StringBuilder();
foreach (var item in Marks.Keys)
{
temp.Append(string.Format("{0}={1} ", item, Marks[item]));
}
return temp.ToString().Trim();
}
return "";
}
public static void WriteMarks(string marks = "")
{
if (Marks != null && Marks.Count > 0)
{
Marks.Clear();
string[] tempMarks = marks.Split(' ');
foreach (string item in tempMarks)
{
string[] t1 = item.Split('=');
Marks.Add(t1[0], (eMarkState)Enum.Parse(typeof(eMarkState), t1[1]));
}
}
}
/// <summary>
/// 判断是否为入库标志
/// </summary>
/// <returns></returns>
public static bool IsInStoreMark(string mark)
{
return mark.Equals(SettingString.InStore_Mark);
}
public static bool DelMark(string mark)
{
lock (locBoj)
{
if (Marks != null && Marks.ContainsKey(mark))
{
Marks.Remove(mark);
return true;
}
}
return false;
}
public static bool AddMark(string mark)
{
lock (locBoj)
{
if (Marks != null && !Marks.ContainsKey(mark))
{
Marks.Add(mark, eMarkState.None);
return true;
}
}
return false;
}
public static bool ChangeMarkState(string mark, eMarkState value)
{
lock (locBoj)
{
if (Marks != null && Marks.ContainsKey(mark))
{
Marks[mark] = value;
return true;
}
}
return false;
}
/// <summary>
/// 包装仓任务
/// </summary>
/// <param name="currentAgv"></param>
/// <returns></returns>
public override Job GetNewJob(Agv_Info currentAgv)
{
if (currentAgv.IP.Equals(SettingString.SingleMission_IP1))
return null;
if (!Common.CheckCanExecuteMission(currentAgv))
return null;
if (!Common.CheckAGVStatusNone(currentAgv))
return null;
SearchMarks();
return FindPackingJob(currentAgv);
}
private void SearchMarks()
{
//Mark.Length>1防止Mark为0的情况,Mark=0是VMI的进料
int nodeIdx = Common.nodeInfo.FindIndex(s => s.StateEquals(eNodeStatus.NeedEnter)
&& s.Mark.Length > 1 && !Marks.ContainsKey(s.Mark) && s.IsUse);
if (nodeIdx > -1)
{
string mark = Common.nodeInfo[nodeIdx].Mark;
AddMark(mark);
Common.LogInfo(string.Format("包装仓出库任务生成:{0}={1}", mark, Marks[mark].ToString()));
}
else
{
nodeIdx = Common.nodeInfo.FindIndex(s => s.StateEquals(eNodeStatus.NeedEnter)
&& s.Mark.Equals("0") && !Marks.ContainsKey(SettingString.InStore_Mark) && s.IsUse);
if (nodeIdx > -1)
{
string mark = SettingString.InStore_Mark;
AddMark(mark);
Common.LogInfo(string.Format("包装仓入库任务生成:{0}={1}", mark, Marks[mark].ToString()));
}
}
}
/// <summary>
/// 检查节点mark是否存在
/// </summary>
/// <param name="mark"></param>
/// <returns>true:存在</returns>
public static bool CheckNodeMark(string mark, string nodeName = "")
{
if (nodeName.Equals(""))
{
int i = Common.nodeInfo.FindIndex(s => s.Mark.Equals(mark));
if (i == -1)
return false;
else
return true;
}
else
{
int i = Common.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.Mark.Equals(mark));
if (i == -1)
return false;
else
return true;
}
}
private static object checkObj = new object();
/// <summary>
/// 检查是否有包装仓出库任务
/// </summary>
/// <returns></returns>
public static int CheckOutStroePackingJob()
{
lock (checkObj)
{
return Common.nodeInfo.FindIndex(s => s.StateEquals(eNodeStatus.NeedEnter)
&& Marks.ContainsKey(s.Mark) && Marks[s.Mark].Equals(eMarkState.None) && s.IsUse);
}
}
/// <summary>
/// 检查是否有包装仓入库任务
/// </summary>
/// <returns></returns>
public static int CheckInStroePackingJob()
{
lock (checkObj)
{
int id = Common.nodeInfo.FindIndex(s => s.StateEquals(eNodeStatus.NeedEnter) && s.Mark.Equals("0") && s.IsUse);
if (id > -1)
return Common.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A1) && s.RFID.StartsWith(SettingString.Packing_RFID_Prefix));
else
return id;
}
}
/// <summary>
/// 检查是否有包装仓出料架
/// </summary>
/// <returns></returns>
public static int CheckPackingOutShelf(out ClientNode tarNode, out string taskMark)
{
lock (checkObj)
{
taskMark = SettingString.InStore_Mark;
tarNode = null;
int id = Common.nodeInfo.FindIndex(s => s.Name.StartsWith(SettingString.Packing_Box_Prefix) && s.StateEquals(eNodeStatus.NeedLeave) && s.RFID.StartsWith(SettingString.Packing_RFID_Prefix) && s.Mark.Equals("0") && s.IsUse);
if (id > -1)
{
taskMark = SettingString.InStore_Mark;
tarNode = Common.nodeInfo[id];
return id;
}
else
{
id = Common.nodeInfo.FindIndex(s => s.Name.StartsWith(SettingString.Packing_Box_Prefix) && s.StateEquals(eNodeStatus.NeedLeave)
&& s.RFID.StartsWith(SettingString.Packing_RFID_Prefix) && Marks.ContainsKey(s.Mark) && s.IsUse);
if (id > -1)
{
taskMark = Common.nodeInfo[id].Mark;
tarNode = Common.nodeInfo[id];
return id;
}
}
return -1;
}
}
/// <summary>
/// 搜索包装仓任务
/// </summary>
/// <returns>true:有任务</returns>
private Job FindPackingJob(Agv_Info agv)
{
//检查包装仓出料架
int nodeIdx = CheckPackingOutShelf(out ClientNode tarNode, out string taskMark);
if (nodeIdx > -1)
{
int agvId = Common.agvInfo.FindIndex(s => !s.IP.Equals(agv.IP) && s.CurJob is PackingJob_TransferShelf && ((PackingJob_TransferShelf)s.CurJob).TargetPlace.Equals(tarNode.Name));
if (agvId == -1)
return new PackingJob_TransferShelf(agv.Place, tarNode.Name, "", taskMark);// tarNode.RFID
}
//检查出库任务,没有出库,找入库任务
nodeIdx = CheckOutStroePackingJob();
if (nodeIdx == -1) //搜索包装仓入库任务
{
Common.log.Debug("B区没有找到需要出库的节点");
nodeIdx = CheckInStroePackingJob();
if (nodeIdx > -1)
{
//检查是否有小车去同一个目的地
int agvId = Common.agvInfo.FindIndex(s => !s.IP.Equals(agv.IP) && s.CurJob != null && s.CurJob is PackingJob_GetShelf && ((PackingJob_GetShelf)s.CurJob).TargetPlace.Equals(Common.nodeInfo[nodeIdx].Name));
if (agvId == -1)
{
string Place = Common.nodeInfo[nodeIdx].Name;
Common.LogInfo(string.Format("{0} 任务生成:Place={1},Type={2}", agv.Name, Place, SettingString.InStore_Mark));
return new PackingJob_GetShelf(agv.Place, Place, SettingString.InStore_Mark);
}
}
}
else//B区域需要出库,寻找空料架
{
//检查是否有小车去同一个包装仓
int agvId = Common.agvInfo.FindIndex(s => !s.IP.Equals(agv.IP) && s.CurJob != null && s.CurJob is PackingJob_GetShelf && ((PackingJob_GetShelf)s.CurJob).TargetPlace.Equals(Common.nodeInfo[nodeIdx].Name));
if (agvId > -1)
return null;
int n = Common.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A7) && s.StateEquals(eNodeStatus.NeedLeave) &&
s.RFID.StartsWith(SettingString.Packing_RFID_Prefix) && s.IsUse);
if (n > -1)
{
string Place = Common.nodeInfo[n].Name;
string Mark = Common.nodeInfo[nodeIdx].Mark;
Common.LogInfo(string.Format("{0} 任务生成:Place={1},Type={2}", agv.Name, Place, Mark));
return new PackingJob_GetShelf(agv.Place, Place, Mark);
}
else
{
//A4没有被占用
n = Common.nodeInfo.FindIndex(s => s.Name == SettingString.A4 && s.StateEquals(eNodeStatus.NeedLeave)
&& s.IsUse);
if (n == -1)
{
nodeIdx = -1;
Common.log.Error("A7,A4不是NeedLeave或被占用");
agv.AddDisplayBoard("包装料架", "PackingShelf", "分盘线出口A7、包装线出口A4均无包装料架,请检查!");
}
else
{
string Place = Common.nodeInfo[n].Name;
string Mark = Common.nodeInfo[nodeIdx].Mark;
Common.LogInfo(string.Format("{0} 任务生成:Place={1},Type={2}", agv.Name, Place, Mark));
return new PackingJob_GetShelf(agv.Place, Place, Mark);
}
}
}
return null;
}
}
}
using MiR;
using log4net.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl.bean.jobType
{
/// <summary>
/// 料仓料串任务
/// </summary>
public class ReelStringJobType : JobType
{
/// <summary>
/// 料仓料串任务
/// </summary>
/// <param name="currentAgv"></param>
/// <returns></returns>
public override Job GetNewJob(Agv_Info currentAgv)
{
if (!Common.CheckCanExecuteMission(currentAgv))
return null;
if (!Common.CheckAGVStatusNone(currentAgv))
return null;
string rfid = "";
if (currentAgv.IP.Equals(SettingString.SingleMission_IP1))
{
if (!Common.control.limitArea.Available)
return null;
//检查入料口1的C5是否需要满料串
if (FindNeedEnterMission(currentAgv, SettingString.C5))
{
if (FindNeedLeaveMission(currentAgv, SettingString.D2, out rfid))
{
Common.LogInfo(string.Format("{0} 任务生成:Place={1},rfid={2}", currentAgv.Name, SettingString.D2, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.D2, "B#", true);
}
if (FindNeedLeaveMission(currentAgv, SettingString.A1, out rfid, SettingString.ReelString_RFID_Prefix))
{
Common.LogInfo(string.Format("{0} 任务生成:Place={1},rfid={2}", currentAgv.Name, SettingString.A1, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.A1, rfid, true);
}
}
//检查入料口1的C6是否有空料串要出
if (FindNeedLeaveMission(currentAgv, SettingString.C6, out rfid))
{
if (FindNeedEnterMission(currentAgv, SettingString.D1) || FindNeedEnterMission(currentAgv, SettingString.A2))
{
Common.LogInfo(string.Format("{0} 任务生成:Place={1},rfid={2}", currentAgv.Name, SettingString.C6, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.C6, rfid);
}
}
}
else//其他小车
{
//检查紧急出料口的C8出满料串
if (FindNeedLeaveMission(currentAgv, SettingString.C8, out rfid))
{
if (FindNeedEnterMission(currentAgv, SettingString.A8))
{
Common.LogInfo(string.Format("{0} 任务生成:Place={1},rfid={2}", currentAgv.Name, SettingString.C8, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.C8, rfid, true);
}
}
//检查紧急出料口C7需要空料串
if (FindNeedEnterMission(currentAgv, SettingString.C7))
{
if (FindNeedLeaveMission(currentAgv, SettingString.A7, out rfid, SettingString.ReelString_RFID_Prefix))
{
Common.LogInfo(string.Format("{0} 任务生成:Place={1},rfid={2}", currentAgv.Name, SettingString.A7, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.A7, rfid);
}
if (FindNeedLeaveMission(currentAgv, SettingString.C2, out rfid, SettingString.ReelString_RFID_Prefix))
{
Common.LogInfo(string.Format("{0} 任务生成:Place={1},rfid={2}", currentAgv.Name, SettingString.C2, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.C2, rfid);
}
if (FindNeedLeaveMission(currentAgv, SettingString.C4, out rfid, SettingString.ReelString_RFID_Prefix))
{
Common.LogInfo(string.Format("{0} 任务生成:Place={1},rfid={2}", currentAgv.Name, SettingString.C4, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.C4, rfid);
}
}
//检查点料机D1是否需要空料串
if (FindNeedEnterMission(currentAgv, SettingString.D1))
{
if (FindNeedLeaveMission(currentAgv, SettingString.C2, out rfid, SettingString.ReelString_RFID_Prefix))
{
Common.LogInfo(string.Format("{0} 任务生成:Place={1},rfid={2}", currentAgv.Name, SettingString.C2, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.C2, rfid);
}
if (FindNeedLeaveMission(currentAgv, SettingString.C4, out rfid, SettingString.ReelString_RFID_Prefix))
{
Common.LogInfo(string.Format("{0} 任务生成:Place={1},rfid={2}", currentAgv.Name, SettingString.C4, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.C4, rfid);
}
}
//检查入料口2是否有空料串要出
if (FindNeedLeaveMission(currentAgv, SettingString.C2, out rfid))
{
if (FindNeedEnterMission(currentAgv, SettingString.D1) || FindNeedEnterMission(currentAgv, SettingString.A2))
{
Common.LogInfo(string.Format("{0} 任务生成:Place={1},rfid={2}", currentAgv.Name, SettingString.C2, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.C2, rfid);
}
}
//检查入料口3是否有空料串要出
if (FindNeedLeaveMission(currentAgv, SettingString.C4, out rfid))
{
if (FindNeedEnterMission(currentAgv, SettingString.D1) || FindNeedEnterMission(currentAgv, SettingString.A2))
{
Common.LogInfo(string.Format("{0} 任务生成:Place={1},rfid={2}", currentAgv.Name, SettingString.C4, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.C4, rfid);
}
}
//检查入料2,3需要满料,且点料机D2/A1出满料串
if (FindNeedEnterMission(currentAgv, SettingString.C1) || FindNeedEnterMission(currentAgv, SettingString.C3))
{
if (FindNeedLeaveMission(currentAgv, SettingString.D2, out rfid))
{
Common.LogInfo(string.Format("{0} 任务生成:Place={1},rfid={2}", currentAgv.Name, SettingString.D2, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.D2, "B#", true);
}
if (FindNeedLeaveMission(currentAgv, SettingString.A1, out rfid, SettingString.ReelString_RFID_Prefix))
{
Common.LogInfo(string.Format("{0} 任务生成:Place={1},rfid={2}", currentAgv.Name, SettingString.A1, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.A1, rfid, true);
}
}
}
return null;
}
public static bool FindNeedLeave(Agv_Info agv, string nodeName, out string RFID, string RFID_Prefix = "")
{
int nodeIdx = Common.FindNode(nodeName);
RFID = "";
if (nodeIdx > -1)
{
if (RFID_Prefix.Equals(""))
{
nodeIdx = Common.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedLeave));
}
else if (RFID_Prefix.Trim().Length == 1)
{
nodeIdx = Common.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedLeave) && s.RFID.StartsWith(RFID_Prefix));
}
else
{
nodeIdx = Common.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedLeave));
}
if (nodeIdx > -1)
{
RFID = Common.nodeInfo[nodeIdx].RFID;
return true;
}
}
else
{
agv.AddDisplayBoard(nodeName, "Using."+ nodeName, "调用关闭");
}
return false;
}
public static bool FindNeedEnter(Agv_Info agv, string nodeName)
{
int nodeIdx = Common.FindNode(nodeName);
if (nodeIdx > -1)
{
nodeIdx = Common.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedEnter));
if (nodeIdx > -1)
return true;
}
else
{
agv.AddDisplayBoard(nodeName, "Using." + nodeName, "调用关闭");
}
return false;
}
/// <summary>
/// 查询节点进料任务
/// </summary>
/// <param name="agv">当前agv</param>
/// <param name="nodeName">需要查询的节点</param>
/// <returns></returns>
public static bool FindNeedEnterMission(Agv_Info agv, string nodeName)
{
if (FindNeedEnter(agv, nodeName))
{
//if(agv.IP.Equals(SettingString.SingleMission_IP1))
//{
// return true;
//}
//else
{
int idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(agv.IP) && s.CurJob !=null && s.CurJob is SendShelfJob && (((SendShelfJob)s.CurJob).TargetPlace.Equals(nodeName)));
if (idx == -1)
{
Common.log.Debug(string.Format("{0} FindNeedEnterMission ", agv.Name));
return true;
}
//int idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(agv.IP) && (s.CurJob == null || !(s.CurJob is SendShelfJob)));
//if(idx>-1)
//{
// Common.log.Debug(string.Format("{0} FindNeedEnterMission 1", agv.Name));
// return true;
//}
//else
//{
// idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(agv.IP) && s.CurJob is SendShelfJob && !(((SendShelfJob)s.CurJob).TargetPlace.Equals(nodeName)));
// if (idx > -1)
// {
// Common.log.Debug(string.Format("{0} FindNeedEnterMission 2", agv.Name));
// return true;
// }
//}
}
}
return false;
}
/// <summary>
/// 查询节点出料任务
/// </summary>
/// <param name="agv">当前agv</param>
/// <param name="nodeName">需要查询的节点</param>
/// <returns></returns>
public static bool FindNeedLeaveMission(Agv_Info agv, string nodeName, out string RFID, string RFID_Prefix = "")
{
RFID = "";
if (FindNeedLeave(agv, nodeName, out string rfid, RFID_Prefix))
{
//if (agv.IP.Equals(SettingString.SingleMission_IP1))
//{
// return true;
//}
//else
{
int idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(agv.IP) && s.CurJob !=null && s.CurJob is GetShelfJob && (((GetShelfJob)s.CurJob).TargetPlace.Equals(nodeName)));
if (idx == -1)
{
RFID = rfid;
Common.log.Debug(string.Format("{0} FindNeedLeaveMission", agv.Name));
return true;
}
//int idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(agv.IP) && (s.CurJob == null || !(s.CurJob is GetShelfJob)));
//if(idx>-1)
//{
// RFID = rfid;
// Common.log.Debug(string.Format("{0} FindNeedLeaveMission 1", agv.Name));
// return true;
//}
//else
//{
// idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(agv.IP) && s.CurJob is GetShelfJob && !(((GetShelfJob)s.CurJob).TargetPlace.Equals(nodeName)));
// if (idx > -1)
// {
// RFID = rfid;
// Common.log.Debug(string.Format("{0} FindNeedLeaveMission 2", agv.Name));
// return true;
// }
//}
}
}
return false;
}
}
}
using MiR;
using log4net.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl.bean.jobType
{
/// <summary>
/// 退料任务
/// </summary>
public class ReturnJobType : JobType
{
/// <summary>
/// 退料任务
/// </summary>
/// <param name="currentAgv"></param>
/// <returns></returns>
public override Job GetNewJob(Agv_Info currentAgv)
{
if (currentAgv.IP.Equals(SettingString.SingleMission_IP1))
return null;
if (!Common.CheckCanExecuteMission(currentAgv))
return null;
if (!Common.CheckAGVStatusNone(currentAgv))
return null;
string rfid="";
//查找退料线出满料架且点料机需要架子
if (ReelStringJobType.FindNeedLeave(currentAgv, SettingString.G24_Out,out rfid))
{
if (ReelStringJobType.FindNeedEnter(currentAgv, SettingString.D3) )
{
int idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(currentAgv.IP) && s.CurJob != null && s.CurJob is SendShelfJob && (((SendShelfJob)s.CurJob).TargetPlace.Equals(SettingString.G23_In)));
if (idx == -1) idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(currentAgv.IP) && s.CurJob != null && s.CurJob is SendShelfJob && (((SendShelfJob)s.CurJob).TargetPlace.Equals(SettingString.D3)));
if (idx == -1) idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(currentAgv.IP) && s.CurJob != null && s.CurJob is GetShelfJob && (((GetShelfJob)s.CurJob).TargetPlace.Equals(SettingString.D3)));
if (idx==-1) idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(currentAgv.IP) && s.CurJob != null && s.CurJob is GetShelfJob && (((GetShelfJob)s.CurJob).TargetPlace.Equals(SettingString.G24_Out)));
if (idx == -1)
{
Common.LogInfo(string.Format("{0} 退料任务生成(D3需要满料串,G24出满料串):Place={1},rfid={2}", currentAgv.Name, SettingString.D3, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.G24_Out, "B#",true);
}
}
if (ReelStringJobType.FindNeedEnter(currentAgv, SettingString.D4))
{
int idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(currentAgv.IP) && s.CurJob != null && s.CurJob is SendShelfJob && (((SendShelfJob)s.CurJob).TargetPlace.Equals(SettingString.G23_In)));
if (idx == -1) idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(currentAgv.IP) && s.CurJob != null && s.CurJob is SendShelfJob && (((SendShelfJob)s.CurJob).TargetPlace.Equals(SettingString.D4)));
if (idx == -1) idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(currentAgv.IP) && s.CurJob != null && s.CurJob is GetShelfJob && (((GetShelfJob)s.CurJob).TargetPlace.Equals(SettingString.D4)));
if (idx == -1) idx = Common.agvInfo.FindIndex(s => !s.IP.Equals(currentAgv.IP) && s.CurJob != null && s.CurJob is GetShelfJob && (((GetShelfJob)s.CurJob).TargetPlace.Equals(SettingString.G24_Out)));
if (idx == -1)
{
Common.LogInfo(string.Format("{0} 退料任务生成(D4需要满料串,G24出满料串):Place={1},rfid={2}", currentAgv.Name, SettingString.D3, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.G24_Out, "B#",true);
}
}
}
////点料机出空架子
if (ReelStringJobType.FindNeedLeaveMission(currentAgv, SettingString.D3, out rfid))
{
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.G23_In))
{
Common.LogInfo(string.Format("{0} 退料任务生成(D3出空料串,G23需要空料串):Place={1},rfid={2}", currentAgv.Name, SettingString.D3, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.D3, "B#");
}
}
if (ReelStringJobType.FindNeedLeaveMission(currentAgv, SettingString.D4, out rfid))
{
if (ReelStringJobType.FindNeedEnterMission(currentAgv, SettingString.G23_In))
{
Common.LogInfo(string.Format("{0} 退料任务生成(D4出空料串,G23需要空料串):Place={1},rfid={2}", currentAgv.Name, SettingString.D4, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.D4, "B#");
}
}
return null;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl
{
/// <summary>
/// 客户端的节点
/// </summary>
public class ClientNode : Node
{
private string rfid = "00";
/// <summary>
/// RFID
/// </summary>
public string RFID
{
set
{
//if (value.Length < 2)
// rfid = value.PadLeft(2, '0');
//else
rfid = value;
}
get
{
return rfid;
}
}
/// <summary>
/// 小车名称
/// </summary>
public string AgvName { set; get; }
/// <summary>
/// 线体名(佳世达)
/// </summary>
public string LineName { set; get; }
public ClientLevel Level { get; set; } = ClientLevel.Low;
public string Mark { get; set; } = "";
public string AliceName { get; set; }
/// <summary>
/// 查看节点状态是否更新
/// </summary>
/// <returns></returns>
public bool CheckNodeStateChanged(ClientNode node)
{
if (!Mark.Equals(node.Mark) ||
!StateEquals(node.GetState()) ||
!Level.Equals(node.Level) || RFID != node.RFID)
{
Mark = node.Mark;
nodeStatus = node.GetState();
Level = node.Level;
RFID = node.RFID;
return true;
}
else
{
return false;
}
}
/// <summary>
/// 客户端节点
/// </summary>
/// <param name="name"></param>
/// <param name="ip"></param>
/// <param name="isUse"></param>
public ClientNode(string name, string aliceName, string lineName, bool isUse) : base(name, isUse)
{
LineName = lineName;
AliceName = aliceName;
RFID = rfid;
AgvName = "";
Online = false;
IsUse = isUse;
}
/// <summary>
/// 客户端节点
/// </summary>
/// <param name="name"></param>
/// <param name="rfid"></param>
/// <param name="action"></param>
/// <param name="level"></param>
public ClientNode(string name, string rfid = "", eNodeStatus status = eNodeStatus.None, string mark = "", ClientLevel level = ClientLevel.Low) : base(name)
{
RFID = rfid;
Mark = mark;
Level = level;
nodeStatus = status;
AgvName = "";
}
/// <summary>
/// 节点状态的文本形式
/// </summary>
/// <returns></returns>
public string StatetText()
{
string s = string.Format("[Name={0}, NodeStatus={1}, RFID={2},ClientLevel ={3}]", Name, nodeStatus.ToString(), RFID, Level.ToString());
return s;
}
protected void UpdateDisplayBoard()
{
try
{
if (!Online)
displayBoard.Add(AliceName, "agv." + Name + ".OffLine", "离线");
if (!IsUse)
displayBoard.Add(AliceName, "agv." + Name + ".IsUse", "调用关闭");
displayBoard.UpdateAlarmMsg();
}
catch (Exception ex)
{
Common.log.Error(Name + "上报节点信息失败" + ex.Message + ex.StackTrace);
}
}
public string[] ToRow()
{
//节点,IP,动作,RFID,AGV名称,在线,调用,清除AGV
string[] s = new string[7];
s[0] = LineName;
s[1] = nodeStatus.ToString();
s[2] = Level.ToString();
s[3] = Mark;
s[4] = RFID;
s[5] = Online ? "在线" : "离线";
s[6] = IsUse ? "是" : "否";
return s;
}
/// <summary>
/// 脱机
/// </summary>
public void Offline()
{
RFID = "00";
nodeStatus = eNodeStatus.None;
AgvName = "";
Online = false;
}
}
}
using AGVControl.bean;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace AGVControl
{
public abstract class Node
{
/// <summary>
/// 节点名称
/// </summary>
public string Name { get; }
/// <summary>
/// 在线状态
/// </summary>
public bool Online { get; set; }
/// <summary>
/// 是否可调用
/// </summary>
public bool IsUse { set; get; }
/// <summary>
/// 节点状态
/// </summary>
protected eNodeStatus nodeStatus;
/// <summary>
/// 看板信息
/// </summary>
protected DisplayBoard displayBoard;
public Node(string name, bool isUse = false)
{
Name = name;
Online = false;
IsUse = isUse;
nodeStatus = eNodeStatus.None;
displayBoard = new DisplayBoard();
}
public Node(string name)
{
Name = name;
}
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;
}
public virtual Job GetNewJob(Agv_Info currentAgvBean)
{
return null;
}
}
/// <summary>
/// 节点状态
/// </summary>
public enum eNodeStatus : byte
{
/// <summary>
/// 没有动作
/// </summary>
None = 0,
/// <summary>
/// 关门(仅包装料仓)
/// </summary>
CloseDoor = 1,
/// <summary>
/// 可以进入料架(仅包装料仓)
/// </summary>
MayEnter = 2,
/// <summary>
/// 可以出去料架(仅包装料仓)
/// </summary>
MayLeave = 3,
/// <summary>
/// 需要进入料架
/// </summary>
NeedEnter = 4,
/// <summary>
/// 需要出去料架
/// </summary>
NeedLeave = 5,
/// <summary>
/// 完成进入料架
/// </summary>
FinishEnter = 6,
/// <summary>
/// 完成出去料架
/// </summary>
FinishLeave = 7,
/// <summary>
/// 小车到达
/// </summary>
Arrive = 8,
/// <summary>
/// 小车已准备好
/// </summary>
Ready = 9,
/// <summary>
/// 只能入料不能出料(仅包装料仓)
/// </summary>
EnterShelf = 10,
/// <summary>
/// 不允许
/// </summary>
MayNot = 11
}
/// <summary>
/// 客户端的优先级
/// </summary>
public enum ClientLevel : byte
{
/// <summary>
/// 低
/// </summary>
Low = 0,
/// <summary>
/// 中等
/// </summary>
Middle = 1,
/// <summary>
/// 高
/// </summary>
High = 2
}
}
文件属性发生变化
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件的差异太大,无法显示。
文件属性发生变化
此文件类型无法预览
此文件类型无法预览
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="RestSharp" version="106.11.4" targetFramework="net461" />
</packages>
\ No newline at end of file \ No newline at end of file
此文件类型无法预览
//using System;
//using System.Collections.Generic;
//using System.Net;
//using System.Net.Sockets;
//using System.Threading;
//namespace Asa
//{
// /// <summary>
// /// AGV客户端
// /// </summary>
// public class AgvClient
// {
// private bool _loopClient;
// private int _countRecon;
// private bool _loopRecon;
// private Socket _clientSocket; //客户端
// private List<ClientNode> _node;
// private Thread tSend; //发送
// private Thread tListen; //监听网络
// private Thread tRecon;
// private readonly log4net.ILog LOG;
// private readonly string SERVER_IP; //远程IP地址
// private const int SERVER_PORT = 12000; //端口
// /// <summary>
// /// 小车接收事件
// /// </summary>
// /// <param name="name">名称</param>
// /// <param name="realRfid">真实RFID</param>
// /// <param name="virtualRfid">虚拟RFID</param>
// /// <param name="action">动作</param>
// /// <param name="level">优先级</param>
// /// <param name="shelf">料架</param>
// /// <param name="type">放置地点</param>
// public delegate void ReceiveEvent(ClientNode node);
// /// <summary>
// /// 服务器连接事件
// /// </summary>
// /// <param name="status"></param>
// public delegate void ConnectEvent(bool status);
// /// <summary>
// /// 小车接收事件
// /// </summary>
// public event ReceiveEvent Received;
// /// <summary>
// /// 服务器连接事件
// /// </summary>
// public event ConnectEvent Connected;
// /// <summary>
// /// AGV客户端
// /// </summary>
// /// <param name="serverIP">服务器IP地址</param>
// /// <param name="logName"></param>
// public AgvClient(string serverIP, string logName = "AgvClient")
// {
// SERVER_IP = serverIP;
// _node = new List<ClientNode>();
// LOG = log4net.LogManager.GetLogger(logName);
// }
// /// <summary>
// /// 是否连接服务器
// /// </summary>
// public bool IsConn { private set; get; } = false;
// /// <summary>
// /// 发送命令的时间间隔,不能大于10s(单位:秒)
// /// </summary>
// public int SendSleep { set; get; } = 3;
// /// <summary>
// /// 连接
// /// </summary>
// public void Connect()
// {
// _countRecon = 0;
// _loopRecon = true;
// IsConn = false;
// _loopClient = true;
// tListen = new Thread(new ThreadStart(ListenServerNet));
// tSend = new Thread(new ThreadStart(SendStatus));
// tRecon = new Thread(new ThreadStart(Reconnect));
// tRecon.Start();
// tListen.Start();
// tSend.Start();
// LOG.Info("连接服务器");
// }
// /// <summary>
// /// 关闭
// /// </summary>
// public void Close()
// {
// _loopClient = false;
// _loopRecon = false;
// if (_clientSocket != null)
// {
// _clientSocket.Close();
// _clientSocket = null;
// }
// LOG.Info("客户端关闭");
// }
// /// <summary>
// /// 设置状态
// /// </summary>
// /// <param name="nodeName">节点名称</param>
// /// <param name="realRfid">真实RFID</param>
// /// <param name="virtualRfid">虚拟RFID</param>
// /// <param name="action">动作</param>
// /// <param name="level">优先级</param>
// /// <param name="shelf">料架</param>
// /// <param name="type">类型</param>
// public void SetStatus(string nodeName, string realRfid = "", string virtualRfid = "", ClientAction action = ClientAction.None, ClientLevel level = ClientLevel.None, ClientShelf shelf = ClientShelf.None, ClientType type = ClientType.None)
// {
// int index = _node.FindIndex(s => s.Name == nodeName);
// if (index == -1) //没有找到
// {
// ClientNode node = new ClientNode
// {
// Name = nodeName,
// RealRfid = realRfid,
// VirtualRfid = virtualRfid,
// Action = action,
// Level = level,
// Shelf = shelf,
// Type = type
// };
// _node.Add(node);
// LOG.Info("SetStatus " + node.ToText());
// }
// else
// {
// _node[index].RealRfid = realRfid;
// _node[index].VirtualRfid = virtualRfid;
// _node[index].Action = action;
// _node[index].Level = level;
// _node[index].Shelf = shelf;
// _node[index].Type = type;
// LOG.Info("SetStatus " + _node[index].ToText());
// }
// }
// /// <summary>
// /// 设置状态
// /// </summary>
// /// <param name="nodeName">节点名称</param>
// /// <param name="action">动作</param>
// public void SetStatus(string nodeName, ClientAction action)
// {
// int index = _node.FindIndex(s => s.Name == nodeName);
// if (index == -1) //没有找到
// {
// LOG.Info("SetStatus 没有找到" + nodeName);
// }
// else
// {
// _node[index].Action = action;
// LOG.Info("SetStatus " + _node[index].ToText());
// }
// }
// /// <summary>
// /// 重连线程
// /// </summary>
// private void Reconnect()
// {
// while (_loopRecon)
// {
// if (!IsConn)
// {
// Open();
// if (IsConn)
// {
// _countRecon = 0;
// LOG.Info("连接服务器成功");
// Connected?.Invoke(IsConn);
// }
// else
// {
// LOG.Info("连接服务器失败" + ++_countRecon + "次");
// }
// }
// Thread.Sleep(2000);
// }
// LOG.Info("Quit Thread Reconnect");
// }
// /// <summary>
// /// 打开,连接到服务器
// /// </summary>
// private void Open()
// {
// try
// {
// if (CheckIP(SERVER_IP))
// {
// _clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
// _clientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 2000);
// _clientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 2000);
// _clientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, 1);
// _clientSocket.Connect(IPAddress.Parse(SERVER_IP), SERVER_PORT);
// if (!_loopRecon) return;
// IsConn = true;
// }
// }
// catch (Exception ex)
// {
// IsConn = false;
// LOG.Error("Open Error", ex);
// }
// }
// /// <summary>
// /// 监听服务端发送的内容
// /// </summary>
// private void ListenServerNet()
// {
// byte[] temp = new byte[200];
// int timeout = 100;
// while (_loopClient)
// {
// Thread.Sleep(timeout);
// if (!IsConn) continue;
// if (_clientSocket == null) continue;
// if (!_loopClient) break;
// try
// {
// if (_clientSocket.Available > 0)
// {
// int count = _clientSocket.Receive(temp);
// byte[] buff = new byte[count];
// Array.Copy(temp, 0, buff, 0, count);
// ClientNode node = Decode(buff);
// if (node == null)
// {
// LOG.Info("命令解析失败");
// }
// else
// {
// LOG.Info("触发Received事件," + node.ToText());
// Received?.Invoke(node);
// }
// }
// }
// catch (Exception ex)
// {
// IsConn = false;
// LOG.Error("ListenNet Error", ex);
// Connected?.Invoke(IsConn);
// }
// }
// LOG.Info("Quit Thread ListenNet");
// }
// /// <summary>
// /// 连续发送状态线程
// /// </summary>
// private void SendStatus()
// {
// while (_loopClient)
// {
// Thread.Sleep(SendSleep * 1000);
// if (!IsConn) continue;
// if (_clientSocket == null) continue;
// for (int i = 0; i < _node.Count; i++)
// {
// if (!_loopClient) break;
// Thread.Sleep(100);
// byte[] buff = Encode(_node[i]);
// bool bln = Send(buff);
// if (!bln) continue;
// }
// }
// LOG.Info("Quit Thread SendStatus");
// }
// /// <summary>
// /// 编码
// /// </summary>
// /// <param name="node"></param>
// /// <returns></returns>
// private byte[] Encode(ClientNode node)
// {
// try
// {
// System.Reflection.PropertyInfo[] info = node.GetType().GetProperties();
// string[] arr = new string[info.Length];
// for (int i = 0; i < info.Length; i++)
// arr[i] = string.Format("\"{0}\":\"{1}\"", info[i].Name, info[i].GetValue(node));
// string json = "{" + string.Join(",", arr) + "}";
// LOG.Info("编码json " + json);
// byte[] buff = System.Text.Encoding.UTF8.GetBytes(json);
// return buff;
// }
// catch (Exception ex)
// {
// LOG.Error("Encode Error", ex);
// return null;
// }
// }
// /// <summary>
// /// 解码
// /// </summary>
// /// <param name="buff"></param>
// /// <returns></returns>
// private ClientNode Decode(byte[] buff)
// {
// try
// {
// string json = System.Text.Encoding.UTF8.GetString(buff);
// LOG.Info("解码json " + json);
// string[] arr = json.Trim(new char[] { '{', '}' }).Split(',');
// ClientNode node = new ClientNode();
// System.Reflection.PropertyInfo[] info = node.GetType().GetProperties();
// for (int i = 0; i < info.Length; i++)
// {
// string name = string.Format("\"{0}\":", info[i].Name);
// int index = Array.FindIndex(arr, s => s.StartsWith(name));
// if (index == -1) continue;
// string value = arr[index].Replace(name, "").Trim('\"');
// switch (info[i].Name)
// {
// case "Action":
// Enum.TryParse(value, out ClientAction action);
// node.Action = action;
// break;
// case "Level":
// Enum.TryParse(value, out ClientLevel level);
// node.Level = level;
// break;
// case "Type":
// Enum.TryParse(value, out ClientType type);
// node.Type = type;
// break;
// case "Shelf":
// Enum.TryParse(value, out ClientShelf shelf);
// node.Shelf = shelf;
// break;
// default:
// info[i].SetValue(node, value);
// break;
// }
// }
// return node;
// }
// catch (Exception ex)
// {
// LOG.Error("Decode Error", ex);
// return null;
// }
// }
// /// <summary>
// /// 发送命令
// /// </summary>
// /// <param name="buff"></param>
// /// <returns></returns>
// private bool Send(byte[] buff)
// {
// if (!IsConn)
// {
// LOG.Info("Send 服务器没有连接");
// return false;
// }
// try
// {
// if (!_loopRecon) return false;
// if (buff == null) return false;
// _clientSocket.Send(buff);
// LOG.Info("发送到服务器");
// return true;
// }
// catch (Exception ex)
// {
// LOG.Error("Send Error", ex);
// IsConn = false;
// Connected?.Invoke(IsConn);
// return false;
// }
// }
// /// <summary>
// /// 16进制
// /// </summary>
// /// <param name="buff"></param>
// /// <returns></returns>
// private string HexBuff(byte[] buff)
// {
// string s = "";
// if (buff == null) return s;
// for (int i = 0; i < buff.Length; i++)
// s += buff[i].ToString("X2") + " ";
// return s;
// }
// /// <summary>
// /// 检查IP地址
// /// </summary>
// /// <param name="ip"></param>
// /// <returns></returns>
// private bool CheckIP(string ip)
// {
// //IP合法
// string pattern = @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$";
// bool rtn = System.Text.RegularExpressions.Regex.IsMatch(ip, pattern);
// if (!rtn)
// {
// LOG.Info("非法的IP地址" + ip);
// return false;
// }
// //Ping服务端
// try
// {
// System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
// System.Net.NetworkInformation.PingReply result = ping.Send(ip, 2000);
// ping.Dispose();
// if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
// {
// LOG.Info("Ping " + ip + " 请求没有响应");
// return false;
// }
// return true;
// }
// catch (Exception ex)
// {
// LOG.Error("CheckIP Error", ex);
// return false;
// }
// }
// }
// /// <summary>
// /// 客户端的节点
// /// </summary>
// public class ClientNode
// {
// /// <summary>
// /// 节点名称
// /// </summary>
// public string Name { set; get; } = "";
// /// <summary>
// /// 真实的料架号
// /// </summary>
// public string RealRfid { set; get; } = "";
// /// <summary>
// /// 虚拟的料架号
// /// </summary>
// public string VirtualRfid { set; get; } = "";
// /// <summary>
// /// 动作
// /// </summary>
// public ClientAction Action { set; get; } = ClientAction.None;
// /// <summary>
// /// 优先级
// /// </summary>
// public ClientLevel Level { set; get; } = ClientLevel.None;
// /// <summary>
// /// 类型
// /// </summary>
// public ClientType Type { set; get; } = ClientType.None;
// /// <summary>
// /// 料架
// /// </summary>
// public ClientShelf Shelf { set; get; } = ClientShelf.None;
// /// <summary>
// /// 来自上一个节点名称
// /// </summary>
// public string From { set; get; } = "";
// /// <summary>
// /// 客户端的节点
// /// </summary>
// public ClientNode()
// {
// }
// /// <summary>
// /// 所有属性的文本形式
// /// </summary>
// /// <returns></returns>
// public string ToText()
// {
// System.Reflection.PropertyInfo[] info = this.GetType().GetProperties();
// string[] arr = new string[info.Length];
// for (int i = 0; i < info.Length; i++)
// arr[i] = info[i].Name + "=" + info[i].GetValue(this).ToString();
// return string.Join(",", arr);
// }
// /// <summary>
// /// 拷贝一个新的实例
// /// </summary>
// /// <returns></returns>
// public ClientNode ToCopy()
// {
// ClientNode node = new ClientNode();
// System.Reflection.PropertyInfo[] info1 = node.GetType().GetProperties();
// System.Reflection.PropertyInfo[] info2 = this.GetType().GetProperties();
// for (int i = 0; i < info1.Length; i++)
// info1[i].SetValue(node, info2[i].GetValue(this));
// return node;
// }
// }
// /// <summary>
// /// 客户端的动作
// /// </summary>
// public enum ClientAction
// {
// /// <summary>
// /// 没有动作
// /// </summary>
// None,
// /// <summary>
// /// 需要进入A料架
// /// </summary>
// NeedEnterA,
// /// <summary>
// /// 需要进入B料架
// /// </summary>
// NeedEnterB,
// /// <summary>
// /// 需要进入C料架
// /// </summary>
// NeedEnterC,
// /// <summary>
// /// 需要进入D料架
// /// </summary>
// NeedEnterD,
// /// <summary>
// /// 需要进入料架
// /// </summary>
// NeedEnter,
// /// <summary>
// /// 需要流出料架
// /// </summary>
// NeedLeave,
// /// <summary>
// /// 需要进入流出料架
// /// </summary>
// NeedEnterLeave,
// /// <summary>
// /// 可以进入料架
// /// </summary>
// MayEnter,
// /// <summary>
// /// 可以流出料架
// /// </summary>
// MayLeave,
// /// <summary>
// /// 可以停靠
// /// </summary>
// MayDock,
// /// <summary>
// /// 不可以进入料架
// /// </summary>
// MayNotEnter,
// /// <summary>
// /// 不可以流出料架
// /// </summary>
// MayNotLeave,
// /// <summary>
// /// 不可以停靠
// /// </summary>
// MayNotDock,
// /// <summary>
// /// 完成进入料架
// /// </summary>
// FinishEnter,
// /// <summary>
// /// 完成流出料架
// /// </summary>
// FinishLeave,
// /// <summary>
// /// 小车准备好(服务器发送)
// /// </summary>
// ReadyEnter,
// /// <summary>
// /// 小车准备好(服务器发送)
// /// </summary>
// ReadyLeave,
// /// <summary>
// /// 到达包装料仓门口(服务器发送)
// /// </summary>
// Arrive,
// /// <summary>
// /// 完成(服务器发送)
// /// </summary>
// Complete
// }
// /// <summary>
// /// 客户端的优先级
// /// </summary>
// public enum ClientLevel
// {
// None,
// /// <summary>
// /// 低
// /// </summary>
// Low,
// /// <summary>
// /// 中等
// /// </summary>
// Middle,
// /// <summary>
// /// 高
// /// </summary>
// High
// }
// /// <summary>
// /// 客户端的料架
// /// </summary>
// public enum ClientShelf
// {
// /// <summary>
// /// 没有架子
// /// </summary>
// None,
// /// <summary>
// /// 空架子
// /// </summary>
// Empty,
// /// <summary>
// /// 满料架子
// /// </summary>
// Full
// }
// /// <summary>
// /// 类型
// /// </summary>
// public enum ClientType
// {
// /// <summary>
// /// 无
// /// </summary>
// None,
// /// <summary>
// /// 紧急料
// /// </summary>
// Urgent,
// /// <summary>
// /// 包装料
// /// </summary>
// Pack,
// /// <summary>
// /// 分盘料
// /// </summary>
// Cut
// }
//}
<?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>{7DAD8F15-0EC9-42DF-AE0B-94B45DE0F0AC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Asa</RootNamespace>
<AssemblyName>Asa.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>
<LangVersion>8.0</LangVersion>
</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>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\..\..\..\DLL\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Client.cs" />
<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;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace Asa
{
/// <summary>
/// AGV客户端
/// </summary>
public class AgvClient
{
private bool loop;
private string _ip; //远程IP地址
private Socket client; //客户端
private Thread tSend; //发送
private Thread tListen; //监听网络
private Thread tReceive; //接收事件
private int countRecon;
private bool loopRecon;
private Thread tRecon;
private List<ClientNode> _node;
private System.Collections.Concurrent.ConcurrentQueue<ClientNode> _receive;
private const int PORT = 12000; //端口
/// <summary>
/// 小车动作事件
/// </summary>
public delegate void ActionEvent(string name, string rfid);
/// <summary>
/// 日志事件
/// </summary>
/// <param name="s"></param>
public delegate void LogEvent(string s);
/// <summary>
/// 小车到达,仅包装料仓
/// </summary>
public event ActionEvent Arrive;
/// <summary>
/// 小车已准备,对接完成
/// </summary>
public event ActionEvent Ready;
/// <summary>
/// 关门,仅包装料仓
/// </summary>
public event ActionEvent CloseDoor;
/// <summary>
/// 准备进入料架不能出料,仅包装料仓
/// </summary>
public event ActionEvent EnterShelf;
/// <summary>
/// 日志
/// </summary>
public event LogEvent Log;
/// <summary>
/// AGV客户端
/// </summary>
/// <param name="serverIP">服务器IP地址</param>
public AgvClient(string serverIP)
{
_ip = serverIP;
_node = new List<ClientNode>();
_receive = new System.Collections.Concurrent.ConcurrentQueue<ClientNode>();
}
/// <summary>
/// 是否连接服务器
/// </summary>
public bool IsConn { private set; get; } = false;
/// <summary>
/// 发送命令的日志是否打印,不影响其他日志
/// </summary>
public bool SendLog { set; get; } = false;
/// <summary>
/// 发送命令的时间间隔,不能大于10s(单位:秒)
/// </summary>
public int SendSleep { set; get; } = 3;
/// <summary>
/// 取消状态,true发送none,false发送实际状态
/// </summary>
public bool CancelState { set; get; } = false;
/// <summary>
/// 连接
/// </summary>
public void Connect()
{
countRecon = 0;
loopRecon = true;
IsConn = false;
tRecon = new Thread(new ThreadStart(Reconnect));
tRecon.Start();
}
/// <summary>
/// 关闭
/// </summary>
public void Close()
{
loop = false;
loopRecon = false;
if (client != null)
{
client.Close();
client = null;
}
Log?.Invoke("客户端关闭");
}
/// <summary>
/// 设置状态
/// </summary>
/// <param name="name">节点名称</param>
/// <param name="mark">节点标记</param>
/// <param name="rfid">架子RFID</param>
/// <param name="action"></param>
/// <param name="level"></param>
public void SetStatus(string name, string mark = "", string rfid = "", ClientAction action = ClientAction.None, ClientLevel level = ClientLevel.Low)
{
int idx = _node.FindIndex(s => s.Name.Equals(name));
if (idx == -1)
{
ClientNode node = new ClientNode(name, mark, rfid, action, level);
_node.Add(node);
Log?.Invoke("SetStatus " + node.ToText());
}
else
{
_node[idx].Mark = mark;
_node[idx].RFID = rfid;
_node[idx].Action = action;
_node[idx].Level = level;
Log?.Invoke("SetStatus " + _node[idx].ToText());
}
}
/// <summary>
/// 重连线程
/// </summary>
private void Reconnect()
{
while (loopRecon)
{
if (!IsConn)
{
Open();
if (IsConn)
{
countRecon = 0;
Log?.Invoke("连接服务器成功");
}
else
{
Log?.Invoke("连接服务器失败" + ++countRecon + "次");
}
}
Thread.Sleep(5000);
}
}
/// <summary>
/// 打开,连接到服务器
/// </summary>
private void Open()
{
try
{
if (CheckIP(_ip))
{
client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 2000);
client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 2000);
client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, 1);
client.Connect(IPAddress.Parse(_ip), PORT);
if (!loopRecon) return;
IsConn = true;
loop = true;
tListen = new Thread(new ThreadStart(ListenNet));
tListen.Start();
tReceive = new Thread(new ThreadStart(Resolve));
tReceive.Start();
tSend = new Thread(new ThreadStart(SendStatus));
tSend.Start();
}
}
catch (Exception ex)
{
IsConn = false;
Log?.Invoke(ex.Message);
}
}
/// <summary>
/// 监听线程
/// </summary>
private void ListenNet()
{
byte[] temp = new byte[200];
int time = 100;
while (loop)
{
try
{
if (client.Available > 0)
{
int count = client.Receive(temp);
byte[] _buffer = new byte[count];
Array.Copy(temp, 0, _buffer, 0, count);
ClientNode node = Decode(_buffer);
if (node == null)
{
Log?.Invoke("命令解析失败: " + HexBuff(_buffer));
}
else
{
_receive.Enqueue(node);
Log?.Invoke("From Server: " + node.ToServerText());
}
}
}
catch (Exception ex)
{
IsConn = false;
Log?.Invoke(ex.Message);
}
Thread.Sleep(time);
}
}
/// <summary>
/// 分析数据包
/// </summary>
private void Resolve()
{
int time = 100;
while (loop)
{
Thread.Sleep(time);
try
{
if (!_receive.TryDequeue(out ClientNode result))
continue;
switch (result.Action)
{
case ClientAction.Arrive:
Log?.Invoke("触发Arrive事件");
Arrive?.Invoke(result.Name, result.RFID);
break;
case ClientAction.Ready:
Log?.Invoke("触发Ready事件");
Ready?.Invoke(result.Name, result.RFID);
break;
case ClientAction.CloseDoor:
Log?.Invoke("触发CloseDoor事件");
CloseDoor?.Invoke(result.Name, result.RFID);
break;
case ClientAction.EnterShelf:
Log?.Invoke("触发EnterShelf事件");
EnterShelf?.Invoke(result.Name, result.RFID);
break;
}
}
catch (Exception ex)
{
Log?.Invoke(ex.Message);
}
}
}
/// <summary>
/// 连续发送状态线程
/// </summary>
private void SendStatus()
{
while (loop)
{
//Socket没有建立连接
if (!IsConn)
{
Thread.Sleep(1000);
continue;
}
if (_node.Count == 0)
{
Thread.Sleep(5000);
continue;
}
for (int i = 0; i < _node.Count; i++)
{
if (!loop) break;
Thread.Sleep(100);
byte[] buff = Encode(_node[i]);
bool bln = Send(buff);
if (!bln)
{
IsConn = false;
loop = false;
break;
}
}
Thread.Sleep(SendSleep * 1000);
}
}
/// <summary>
/// 编码
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
private byte[] Encode(ClientNode node)
{
byte[] name = System.Text.Encoding.UTF8.GetBytes(node.Name);
byte[] mark = System.Text.Encoding.UTF8.GetBytes(node.Mark);
byte[] rfid = System.Text.Encoding.UTF8.GetBytes(node.RFID);
int count = name.Length + mark.Length + rfid.Length + 7;
int idx = 0;
byte[] buff = new byte[count];
buff[idx++] = 0xAB;
buff[idx++] = Convert.ToByte(name.Length);
Array.Copy(name, 0, buff, idx, name.Length);
idx += name.Length;
buff[idx++] = Convert.ToByte(mark.Length);
Array.Copy(mark, 0, buff, idx, mark.Length);
idx += mark.Length;
buff[idx++] = Convert.ToByte(rfid.Length);
Array.Copy(rfid, 0, buff, idx, rfid.Length);
idx += rfid.Length;
if (CancelState)
buff[idx++] = (byte)ClientAction.None;
else
buff[idx++] = (byte)node.Action;
buff[idx++] = Convert.ToByte(node.Level);
buff[idx++] = 0xBA;
return buff;
}
/// <summary>
/// 发送命令
/// </summary>
/// <param name="buff"></param>
/// <returns></returns>
private bool Send(byte[] buff)
{
if (!IsConn)
{
Log?.Invoke("Send 服务器没有连接");
return false;
}
try
{
if (!loopRecon) return false;
if (SendLog) Log?.Invoke("Send: " + HexBuff(buff));
client.Send(buff);
return true;
}
catch (Exception ex)
{
Log?.Invoke(ex.Message);
IsConn = false;
return false;
}
}
/// <summary>
/// 解码
/// </summary>
/// <param name="buff"></param>
/// <returns></returns>
private ClientNode Decode(byte[] buff)
{
int idx = 0;
if (buff[idx++] != 0xAB) return null;
byte[] temp1 = new byte[buff[idx++]];
Array.Copy(buff, idx, temp1, 0, temp1.Length);
string name = System.Text.Encoding.UTF8.GetString(temp1);
idx += temp1.Length;
temp1 = new byte[buff[idx++]];
Array.Copy(buff, idx, temp1, 0, temp1.Length);
string mark = System.Text.Encoding.UTF8.GetString(temp1);
idx += temp1.Length;
temp1 = new byte[buff[idx++]];
Array.Copy(buff, idx, temp1, 0, temp1.Length);
string rfid = System.Text.Encoding.UTF8.GetString(temp1);
idx += temp1.Length;
ClientAction action = (ClientAction)buff[idx++];
ClientLevel level = (ClientLevel)buff[idx++];
ClientNode node = new ClientNode(name, mark, rfid, action, level);
if (buff[idx] != 0xBA)
return null;
return node;
}
/// <summary>
/// 16进制
/// </summary>
/// <param name="buff"></param>
/// <returns></returns>
private string HexBuff(byte[] buff)
{
string s = "";
if (buff == null) return s;
for (int i = 0; i < buff.Length; i++)
s += buff[i].ToString("X2") + " ";
return s;
}
/// <summary>
/// 检查IP地址
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
private bool CheckIP(string ip)
{
//IP合法
string pattern = @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$";
bool rtn = System.Text.RegularExpressions.Regex.IsMatch(ip, pattern);
if (!rtn)
{
Log?.Invoke("非法的IP地址" + ip);
return false;
}
//Ping服务端
try
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingReply result = ping.Send(ip, 2000);
ping.Dispose();
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
{
Log?.Invoke("Ping " + ip + " 请求没有响应");
return false;
}
return true;
}
catch (Exception ex)
{
Log?.Invoke(ex.Message);
return false;
}
}
}
/// <summary>
/// 客户端的节点
/// </summary>
public class ClientNode
{
/// <summary>
/// 节点名称
/// </summary>
public string Name { set; get; }
/// <summary>
/// 标记,用于包装料仓
/// </summary>
public string Mark { set; get; }
/// <summary>
/// 当前架子的RFID
/// </summary>
public string RFID { set; get; }
/// <summary>
/// 动作
/// </summary>
public ClientAction Action { set; get; }
/// <summary>
/// 优先级
/// </summary>
public ClientLevel Level { set; get; }
/// <summary>
/// 客户端节点
/// </summary>
/// <param name="name"></param>
/// <param name="mark"></param>
/// <param name="rfid"></param>
/// <param name="action"></param>
/// <param name="level"></param>
public ClientNode(string name, string mark, string rfid, ClientAction action, ClientLevel level)
{
Name = name;
Mark = mark;
RFID = rfid;
Action = action;
Level = level;
}
/// <summary>
/// 所有属性的文本形式
/// </summary>
/// <returns></returns>
public string ToText()
{
string s = string.Format("Name={0}, Action={1}, Level={2}, Mark={3}, RFID={4}", Name, Action, Level, Mark, RFID);
return s;
}
/// <summary>
/// 服务端的命令
/// </summary>
/// <returns></returns>
public string ToServerText()
{
string s = string.Format("Name={0}, Action={1}, RFID={2}", Name, Action, RFID);
return s;
}
}
/// <summary>
/// 客户端的动作
/// </summary>
public enum ClientAction : byte
{
/// <summary>
/// 没有动作
/// </summary>
None = 0,
/// <summary>
/// 包装料仓关门
/// </summary>
CloseDoor = 1,
/// <summary>
/// 可以进入料架,Arrive事件使用,让小车开始对接
/// </summary>
MayEnter = 2,
/// <summary>
/// 可以出去料架,Arrive事件使用,让小车开始对接
/// </summary>
MayLeave = 3,
/// <summary>
/// 需要进入料架
/// </summary>
NeedEnter = 4,
/// <summary>
/// 需要出去料架
/// </summary>
NeedLeave = 5,
/// <summary>
/// 完成进入料架
/// </summary>
FinishEnter = 6,
/// <summary>
/// 完成出去料架
/// </summary>
FinishLeave = 7,
/// <summary>
/// 小车到达,到达包装料仓门口,等待开门
/// </summary>
Arrive = 8,
/// <summary>
/// 小车已准备,已对接上流水线
/// </summary>
Ready = 9,
/// <summary>
/// 包装料仓只能入料不能出料
/// </summary>
EnterShelf = 10,
/// <summary>
/// 不允许
/// </summary>
MayNot = 11
}
/// <summary>
/// 客户端的优先级
/// </summary>
public enum ClientLevel : byte
{
/// <summary>
/// 低
/// </summary>
Low = 0,
/// <summary>
/// 中等
/// </summary>
Middle = 1,
/// <summary>
/// 高
/// </summary>
High = 2
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Client")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Client")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("7dad8f15-0ec9-42df-ae0b-94b45de0f0ac")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E1C0827A-FA12-49A9-AC71-6D3E6518754A}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>AgvClientTest</RootNamespace>
<AssemblyName>AgvClientTest</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="AsaPL.AgvClient, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\AgvClient\bin\Debug\AsaPL.AgvClient.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\..\..\DLL\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<log4net>
<appender name="AgvClient" type="log4net.Appender.RollingFileAppender">
<file value="logs/AgvClient.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<root>
<level value="Info"/>
<appender-ref ref="AgvClient"/>
</root>
</log4net>
</configuration>
\ No newline at end of file \ No newline at end of file
namespace AgvClientTest
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.button7 = new System.Windows.Forms.Button();
this.button8 = new System.Windows.Forms.Button();
this.button9 = new System.Windows.Forms.Button();
this.button10 = new System.Windows.Forms.Button();
this.button11 = new System.Windows.Forms.Button();
this.button12 = new System.Windows.Forms.Button();
this.button13 = new System.Windows.Forms.Button();
this.button14 = new System.Windows.Forms.Button();
this.button15 = new System.Windows.Forms.Button();
this.button16 = new System.Windows.Forms.Button();
this.button17 = new System.Windows.Forms.Button();
this.button19 = new System.Windows.Forms.Button();
this.button20 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button18 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.label5 = new System.Windows.Forms.Label();
this.comboBox3 = new System.Windows.Forms.ComboBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button1.Location = new System.Drawing.Point(455, 49);
this.button1.Margin = new System.Windows.Forms.Padding(4);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(115, 37);
this.button1.TabIndex = 0;
this.button1.Text = "设置";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(285, 54);
this.comboBox1.Margin = new System.Windows.Forms.Padding(4);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(153, 32);
this.comboBox1.TabIndex = 2;
//
// comboBox2
//
this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Items.AddRange(new object[] {
"A5",
"A6",
"E1",
"E2",
"E3",
"E4",
"E5",
"E6",
"E8",
"E9",
"E10",
"E11",
"E12",
"E14",
"E15",
"E16",
"E21",
"E22",
"G1",
"G2",
"G3",
"G4",
"G5",
"G6",
"G7",
"G8",
"G9",
"G10",
"G11",
"G12",
"G13",
"G14",
"G15",
"G16"});
this.comboBox2.Location = new System.Drawing.Point(81, 54);
this.comboBox2.Margin = new System.Windows.Forms.Padding(4);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(153, 32);
this.comboBox2.TabIndex = 3;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(105, 22);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 25);
this.textBox1.TabIndex = 4;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(17, 25);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(71, 15);
this.label1.TabIndex = 5;
this.label1.Text = "A6_RFID:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(8, 65);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(37, 15);
this.label2.TabIndex = 6;
this.label2.Text = "节点";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(241, 71);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(37, 15);
this.label3.TabIndex = 7;
this.label3.Text = "状态";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(239, 22);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(55, 15);
this.label4.TabIndex = 8;
this.label4.Text = "label4";
//
// button3
//
this.button3.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button3.Location = new System.Drawing.Point(372, 108);
this.button3.Margin = new System.Windows.Forms.Padding(4);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(63, 47);
this.button3.TabIndex = 10;
this.button3.Text = "E6";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.SetLineState);
//
// button4
//
this.button4.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button4.Location = new System.Drawing.Point(84, 108);
this.button4.Margin = new System.Windows.Forms.Padding(4);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(63, 47);
this.button4.TabIndex = 11;
this.button4.Text = "E2";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.SetLineState);
//
// button6
//
this.button6.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button6.Location = new System.Drawing.Point(443, 47);
this.button6.Margin = new System.Windows.Forms.Padding(4);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(63, 47);
this.button6.TabIndex = 13;
this.button6.Text = "G10";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.SetLineState);
//
// button7
//
this.button7.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button7.Location = new System.Drawing.Point(585, 108);
this.button7.Margin = new System.Windows.Forms.Padding(4);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(63, 47);
this.button7.TabIndex = 14;
this.button7.Text = "E9";
this.button7.UseVisualStyleBackColor = true;
this.button7.Click += new System.EventHandler(this.SetLineState);
//
// button8
//
this.button8.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button8.Location = new System.Drawing.Point(301, 108);
this.button8.Margin = new System.Windows.Forms.Padding(4);
this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(63, 47);
this.button8.TabIndex = 15;
this.button8.Text = "E5";
this.button8.UseVisualStyleBackColor = true;
this.button8.Click += new System.EventHandler(this.SetLineState);
//
// button9
//
this.button9.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button9.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button9.Location = new System.Drawing.Point(13, 108);
this.button9.Margin = new System.Windows.Forms.Padding(4);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(63, 47);
this.button9.TabIndex = 16;
this.button9.Text = "E1";
this.button9.UseVisualStyleBackColor = true;
this.button9.Click += new System.EventHandler(this.SetLineState);
//
// button10
//
this.button10.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button10.Location = new System.Drawing.Point(13, 163);
this.button10.Margin = new System.Windows.Forms.Padding(4);
this.button10.Name = "button10";
this.button10.Size = new System.Drawing.Size(63, 47);
this.button10.TabIndex = 17;
this.button10.Text = "E10";
this.button10.UseVisualStyleBackColor = true;
this.button10.Click += new System.EventHandler(this.SetLineState);
//
// button11
//
this.button11.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button11.Location = new System.Drawing.Point(301, 163);
this.button11.Margin = new System.Windows.Forms.Padding(4);
this.button11.Name = "button11";
this.button11.Size = new System.Drawing.Size(63, 47);
this.button11.TabIndex = 18;
this.button11.Text = "E14";
this.button11.UseVisualStyleBackColor = true;
this.button11.Click += new System.EventHandler(this.SetLineState);
//
// button12
//
this.button12.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button12.Location = new System.Drawing.Point(443, 163);
this.button12.Margin = new System.Windows.Forms.Padding(4);
this.button12.Name = "button12";
this.button12.Size = new System.Drawing.Size(63, 47);
this.button12.TabIndex = 28;
this.button12.Text = "E16";
this.button12.UseVisualStyleBackColor = true;
this.button12.Click += new System.EventHandler(this.SetLineState);
//
// button13
//
this.button13.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button13.Location = new System.Drawing.Point(155, 163);
this.button13.Margin = new System.Windows.Forms.Padding(4);
this.button13.Name = "button13";
this.button13.Size = new System.Drawing.Size(63, 47);
this.button13.TabIndex = 27;
this.button13.Text = "E12";
this.button13.UseVisualStyleBackColor = true;
this.button13.Click += new System.EventHandler(this.SetLineState);
//
// button14
//
this.button14.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button14.Location = new System.Drawing.Point(159, 108);
this.button14.Margin = new System.Windows.Forms.Padding(4);
this.button14.Name = "button14";
this.button14.Size = new System.Drawing.Size(63, 47);
this.button14.TabIndex = 26;
this.button14.Text = "E3";
this.button14.UseVisualStyleBackColor = true;
this.button14.Click += new System.EventHandler(this.SetLineState);
//
// button15
//
this.button15.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button15.Location = new System.Drawing.Point(514, 47);
this.button15.Margin = new System.Windows.Forms.Padding(4);
this.button15.Name = "button15";
this.button15.Size = new System.Drawing.Size(63, 47);
this.button15.TabIndex = 25;
this.button15.Text = "G21";
this.button15.UseVisualStyleBackColor = true;
this.button15.Click += new System.EventHandler(this.SetLineState);
//
// button16
//
this.button16.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button16.Location = new System.Drawing.Point(84, 163);
this.button16.Margin = new System.Windows.Forms.Padding(4);
this.button16.Name = "button16";
this.button16.Size = new System.Drawing.Size(63, 47);
this.button16.TabIndex = 24;
this.button16.Text = "E11";
this.button16.UseVisualStyleBackColor = true;
this.button16.Click += new System.EventHandler(this.SetLineState);
//
// button17
//
this.button17.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button17.Location = new System.Drawing.Point(372, 163);
this.button17.Margin = new System.Windows.Forms.Padding(4);
this.button17.Name = "button17";
this.button17.Size = new System.Drawing.Size(63, 47);
this.button17.TabIndex = 23;
this.button17.Text = "E15";
this.button17.UseVisualStyleBackColor = true;
this.button17.Click += new System.EventHandler(this.SetLineState);
//
// button19
//
this.button19.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button19.Location = new System.Drawing.Point(230, 108);
this.button19.Margin = new System.Windows.Forms.Padding(4);
this.button19.Name = "button19";
this.button19.Size = new System.Drawing.Size(63, 47);
this.button19.TabIndex = 21;
this.button19.Text = "E4";
this.button19.UseVisualStyleBackColor = true;
this.button19.Click += new System.EventHandler(this.SetLineState);
//
// button20
//
this.button20.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button20.Location = new System.Drawing.Point(514, 108);
this.button20.Margin = new System.Windows.Forms.Padding(4);
this.button20.Name = "button20";
this.button20.Size = new System.Drawing.Size(63, 47);
this.button20.TabIndex = 20;
this.button20.Text = "E8";
this.button20.UseVisualStyleBackColor = true;
this.button20.Click += new System.EventHandler(this.SetLineState);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.button18);
this.groupBox1.Controls.Add(this.button5);
this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.checkBox1);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.comboBox3);
this.groupBox1.Controls.Add(this.button8);
this.groupBox1.Controls.Add(this.button12);
this.groupBox1.Controls.Add(this.button3);
this.groupBox1.Controls.Add(this.button13);
this.groupBox1.Controls.Add(this.button4);
this.groupBox1.Controls.Add(this.button14);
this.groupBox1.Controls.Add(this.button6);
this.groupBox1.Controls.Add(this.button15);
this.groupBox1.Controls.Add(this.button7);
this.groupBox1.Controls.Add(this.button16);
this.groupBox1.Controls.Add(this.button9);
this.groupBox1.Controls.Add(this.button17);
this.groupBox1.Controls.Add(this.button10);
this.groupBox1.Controls.Add(this.button19);
this.groupBox1.Controls.Add(this.button11);
this.groupBox1.Controls.Add(this.button20);
this.groupBox1.Location = new System.Drawing.Point(11, 109);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(692, 260);
this.groupBox1.TabIndex = 29;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "产线";
//
// button18
//
this.button18.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button18.Location = new System.Drawing.Point(585, 47);
this.button18.Margin = new System.Windows.Forms.Padding(4);
this.button18.Name = "button18";
this.button18.Size = new System.Drawing.Size(63, 47);
this.button18.TabIndex = 34;
this.button18.Text = "G22";
this.button18.UseVisualStyleBackColor = true;
this.button18.Click += new System.EventHandler(this.SetLineState);
//
// button5
//
this.button5.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button5.Location = new System.Drawing.Point(585, 163);
this.button5.Margin = new System.Windows.Forms.Padding(4);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(63, 47);
this.button5.TabIndex = 33;
this.button5.Text = "E22";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.SetLineState);
//
// button2
//
this.button2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button2.Location = new System.Drawing.Point(514, 163);
this.button2.Margin = new System.Windows.Forms.Padding(4);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(63, 47);
this.button2.TabIndex = 32;
this.button2.Text = "E21";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.SetLineState);
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Checked = true;
this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox1.Location = new System.Drawing.Point(13, 24);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(89, 19);
this.checkBox1.TabIndex = 31;
this.checkBox1.Text = "自动回复";
this.checkBox1.UseVisualStyleBackColor = true;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(206, 24);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(55, 15);
this.label5.TabIndex = 30;
this.label5.Text = "label5";
//
// comboBox3
//
this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox3.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.comboBox3.FormattingEnabled = true;
this.comboBox3.Location = new System.Drawing.Point(8, 62);
this.comboBox3.Margin = new System.Windows.Forms.Padding(4);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(166, 32);
this.comboBox3.TabIndex = 29;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(723, 388);
this.ControlBox = false;
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.button1);
this.Margin = new System.Windows.Forms.Padding(4);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.ShowIcon = false;
this.Text = "agv对接模拟客户端";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.ComboBox comboBox2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button button8;
private System.Windows.Forms.Button button9;
private System.Windows.Forms.Button button10;
private System.Windows.Forms.Button button11;
private System.Windows.Forms.Button button12;
private System.Windows.Forms.Button button13;
private System.Windows.Forms.Button button14;
private System.Windows.Forms.Button button15;
private System.Windows.Forms.Button button16;
private System.Windows.Forms.Button button17;
private System.Windows.Forms.Button button19;
private System.Windows.Forms.Button button20;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.ComboBox comboBox3;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button18;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AgvClientTest
{
public partial class Form1 : Form
{
private AsaPL.AgvClient client;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 12; i++)
comboBox1.Items.Add((AsaPL.ClientAction)i);
comboBox1.SelectedIndex = 0;
comboBox2.SelectedIndex = 0;
comboBox3.Items.Add(AsaPL.ClientAction.MayEnter);
comboBox3.Items.Add(AsaPL.ClientAction.MayLeave);
comboBox3.SelectedIndex = 0;
client = new AsaPL.AgvClient("10.85.199.1");
client.ReadyEnter += AGV_ReadyEnter;
client.ReadyLeave += AGV_ReadyLeave;
//client.SetStatus("E1", "", AsaPL.ClientAction.None);
//client.SetStatus("E2", "", AsaPL.ClientAction.None);
//client.SetStatus("E3", "", AsaPL.ClientAction.None);
//client.SetStatus("E4", "", AsaPL.ClientAction.None);
//client.SetStatus("E5", "", AsaPL.ClientAction.None);
//client.SetStatus("E6", "", AsaPL.ClientAction.None);
//client.SetStatus("E8", "", AsaPL.ClientAction.None);
//client.SetStatus("E9", "", AsaPL.ClientAction.None);
//client.SetStatus("E10", "", AsaPL.ClientAction.None);
//client.SetStatus("E11", "", AsaPL.ClientAction.None);
//client.SetStatus("E12", "", AsaPL.ClientAction.None);
//client.SetStatus("E14", "", AsaPL.ClientAction.None);
//client.SetStatus("E15", "", AsaPL.ClientAction.None);
//client.SetStatus("E16", "", AsaPL.ClientAction.None);
//client.SetStatus("D4FeederIn", "", AsaPL.ClientAction.None);
//client.SetStatus("D4FeederOut", "", AsaPL.ClientAction.None);
//client.SetStatus("C4FeederIn", "", AsaPL.ClientAction.None);
//client.SetStatus("C4FeederOut", "", AsaPL.ClientAction.None);
client.Connect();
}
private void AGV_ReadyEnter(string nodeName)
{
if (checkBox1.Checked)
{
if (nodeName.StartsWith("A") || nodeName.EndsWith("A"))//|| nodeName.Equals("G10") || nodeName.Equals("G7")
return;
label4.Text = "收到" + nodeName + "ReadyEnter,节点状态变为MayEnter";
client.SetStatus(nodeName, "", AsaPL.ClientAction.MayEnter);
System.Threading.Thread.Sleep(10000);
client.SetStatus(nodeName, "", AsaPL.ClientAction.None);
label4.Text = "设置" + nodeName + " None";
}
}
private void AGV_ReadyLeave(string nodeName)
{
if (checkBox1.Checked)
{
if (nodeName.StartsWith("A") || nodeName.EndsWith("A"))//|| nodeName.Equals("G10") || nodeName.Equals("G7")
return;
label4.Text = "收到" + nodeName + "ReadyLeave,节点状态变为MayLeave";
client.SetStatus(nodeName, "", AsaPL.ClientAction.MayLeave);
System.Threading.Thread.Sleep(10000);
client.SetStatus(nodeName, "", AsaPL.ClientAction.None);
label4.Text = "设置" + nodeName + " None";
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
client.Close();
}
private void button1_Click(object sender, EventArgs e)
{
Task task = new Task(new Action(() => {
client.SetStatus(comboBox2.SelectedItem.ToString(), textBox1.Text, (AsaPL.ClientAction)comboBox1.SelectedIndex);
System.Threading.Thread.Sleep(10000);
client.SetStatus(comboBox2.SelectedItem.ToString(), "", AsaPL.ClientAction.None);
label4.Text = "设置" + comboBox2.SelectedItem.ToString() + " None";
}));
task.Start();
}
private void SetLineState(object sender, EventArgs e)
{
Task task = new Task(new Action(()=>{
if (comboBox3.SelectedItem == null)
return;
string name = ((Button)sender).Text;
client.SetStatus(name, "", (AsaPL.ClientAction)Enum.Parse(typeof(AsaPL.ClientAction), comboBox3.SelectedItem.ToString()));
label5.Text = name + " " + comboBox3.SelectedItem.ToString();
System.Threading.Thread.Sleep(10000);
client.SetStatus(name, "", AsaPL.ClientAction.None);
label5.Text = "设置" + name + " None";
}));
task.Start();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
using log4net.Config;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AgvClientTest
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
XmlConfigurator.Configure();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("AgvClientTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AgvClientTest")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("e1c0827a-fa12-49a9-ac71-6d3e6518754a")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace AgvClientTest.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AgvClientTest.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 覆盖当前线程的 CurrentUICulture 属性
/// 使用此强类型的资源类的资源查找。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AgvClientTest.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
文件属性发生变化
文件属性发生变化
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!