Commit 88824370 张东亮

init

0 个父辈
正在显示 97 个修改的文件 包含 4844 行增加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_Line", "AGV_3D_Line\AGV_3D_Line.csproj", "{E1C3207D-C67D-4B46-A9DB-D182F2074CCB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgvClient", "AgvClient\AgvClient.csproj", "{D9154766-67B0-4082-AF8B-DCC7C4CFB5A2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgvClientTest", "AgvClientTest\AgvClientTest.csproj", "{E1C0827A-FA12-49A9-AC71-6D3E6518754A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebServiceHost", "WebServiceTest\WebServiceHost.csproj", "{A89F6EC4-457A-4998-ACDC-F1ADC22C8BF8}"
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
{D9154766-67B0-4082-AF8B-DCC7C4CFB5A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9154766-67B0-4082-AF8B-DCC7C4CFB5A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9154766-67B0-4082-AF8B-DCC7C4CFB5A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9154766-67B0-4082-AF8B-DCC7C4CFB5A2}.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
{A89F6EC4-457A-4998-ACDC-F1ADC22C8BF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A89F6EC4-457A-4998-ACDC-F1ADC22C8BF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A89F6EC4-457A-4998-ACDC-F1ADC22C8BF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A89F6EC4-457A-4998-ACDC-F1ADC22C8BF8}.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_Line</RootNamespace>
<AssemblyName>AGV_3D_Line</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>line.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="AsaPL.AgvClient">
<HintPath>..\AgvClient\bin\Debug\AsaPL.AgvClient.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>dll\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>dll\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=106.11.4.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.11.4\lib\net452\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Activation" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="bean\Agv_Info.cs" />
<Compile Include="bean\Job.cs" />
<Compile Include="bean\JobStep.cs" />
<Compile Include="bean\job\ChargeJob.cs" />
<Compile Include="bean\job\EnterLeaveShelfJob.cs" />
<Compile Include="bean\job\SendFullShelfToLineJob.cs" />
<Compile Include="bean\job\GoFullShelfStationJob.cs" />
<Compile Include="bean\job\EmptyShelfBackJob.cs" />
<Compile Include="bean\job\EmptyAGVBackJob.cs" />
<Compile Include="bean\job\GoEmptyShelfLineJob.cs" />
<Compile Include="bean\Node.cs" />
<Compile Include="bean\node\ClientNode.cs" />
<Compile Include="bean\node\DoubleLineNodeFor4D.cs" />
<Compile Include="bean\node\DoubleLineNodeFor4C.cs" />
<Compile Include="BLL\AGVManager.cs" />
<Compile Include="BLL\AgvServer.cs" />
<Compile Include="BLL\Common.cs" />
<Compile Include="BLL\ConfigAppSettings.cs" />
<Compile Include="BLL\Control.cs" />
<Compile Include="BLL\HttpHelper.cs" />
<Compile Include="BLL\IniHelper.cs" />
<Compile Include="BLL\JsonHelper.cs" />
<Compile Include="BLL\MyWebClient.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BLL\LineWebService.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="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="line.ico" />
</ItemGroup>
<ItemGroup />
<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="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="LineWebService" type="log4net.Appender.RollingFileAppender">
<file value="logs/LineWebService.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 ="LineWebService">
<level value="Info"/>
<appender-ref ref="LineWebService"/>
</logger>
<root>
<level value="Info"/>
<appender-ref ref="AgvServer"/>
</root>
</log4net>
<appSettings>
<add key="ITS" value="http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/VMIGetBoxDestInfo?boxRFID=" />
<add key="WebService" value="http://127.0.0.1/BenQMIR/Webservice/AGVService.asmx/" />
<add key="http.server" value="http://10.85.199.25/myproject/" />
<add key="FLEET" value="10.85.199.3" />
<add key="AutoCharge" value="True" />
<add key="ChargeWait" value="1" />
<add key="ChargeThreshold" value="20,70" />
</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.Configuration;
using System.Threading;
using System.Xml;
using System.Windows.Forms;
using AGVControl;
namespace BLL
{
public class ConfigAppSettings
{
public static string GetValue(string key)
{
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
Common.LogInfo("未找到配置:" + 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.Info("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
Int32.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, 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 BLL;
using AGVControl;
namespace BLL
{
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 System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl
{
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);
}
}
}
using AGVControl;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
namespace BLL
{
/// <summary>
/// Json帮助类
/// </summary>
public class JsonHelper
{
/// <summary>
/// 将对象序列化为JSON格式
/// </summary>
/// <param name="o">对象</param>
/// <returns>json字符串</returns>
public static string SerializeObject(object o)
{
string json = JsonConvert.SerializeObject(o);
return json;
}
/// <summary>
/// 解析JSON字符串生成对象实体
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json字符串(eg.{"ID":"112","Name":"石子儿"})</param>
/// <returns>对象实体</returns>
public static T DeserializeJsonToObject<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(T));
T t = o as T;
return t;
}
/// <summary>
/// 解析JSON数组生成对象实体集合
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json数组字符串(eg.[{"ID":"112","Name":"石子儿"}])</param>
/// <returns>对象实体集合</returns>
public static List<T> DeserializeJsonToList<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
List<T> list = o as List<T>;
return list;
}
/// <summary>
/// 反序列化JSON到给定的匿名对象.
/// </summary>
/// <typeparam name="T">匿名对象类型</typeparam>
/// <param name="json">json字符串</param>
/// <param name="anonymousTypeObject">匿名对象</param>
/// <returns>匿名对象</returns>
public static T DeserializeAnonymousType<T>(string json, T anonymousTypeObject)
{
T t = JsonConvert.DeserializeAnonymousType(json, anonymousTypeObject);
return t;
}
/// <summary>
///写入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.ServiceModel;
using System.ServiceModel.Web;
using System.Runtime.Serialization;
using System.ServiceModel.Activation;
using System;
using AGVControl;
using System.IO;
using System.Xml;
using System.Text;
namespace BLL
{
[ServiceContract(Name = "Services")]
internal interface IWebService
{
[OperationContract]
[WebInvoke(UriTemplate = "CreateEmptyRecycleTask", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Xml)]
string CreateEmptyRecycleTask(Stream stream);//string line
//?emptyStation={line}
[OperationContract]
[WebInvoke(UriTemplate = "CreateEmptyRecycleTask?emptyStation={line}&rfid={RFID}", Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Xml)]
string CreateEmptyRecycleTaskGET(string line,string RFID="");
}
[DataContract]
internal class Result
{
[DataMember]
public bool Succeed { get; set; }
[DataMember]
public string ResultData { get; set; }
[DataMember]
public string ErrorMessage { get; set; }
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single, IncludeExceptionDetailInFaults = true)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
internal class ClsWebService : IWebService
{
static log4net.ILog Log = log4net.LogManager.GetLogger("LineWebService");
internal ClsWebService()
{
}
public string CreateEmptyRecycleTask(Stream stream)
{
Result res;
StreamReader sr = new StreamReader(stream);
string s = sr.ReadToEnd();
System.Collections.Specialized.NameValueCollection nvc = System.Web.HttpUtility.ParseQueryString(s);
string emptyStation = nvc["emptyStation"];
string rfid = nvc["rfid"];
if (emptyStation == null)
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "emptyStation =null " };
else
{
if (emptyStation.Equals("Feeder"))
{
emptyStation = "FeederOut";
}
else if (emptyStation.Equals("4CFeeder"))
{
emptyStation = "4CFeederOut";
}
if (Common.GetNodeNameByLineName(emptyStation, out string value))
{
if (!Common.AddEmptyShelfTask(value))
{
Common.log.Error("CreateEmptyRecycleTask(POST) 节点[" + value + "]不存在");
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "CreateEmptyRecycleTask failed: " + emptyStation };
}
else
{
if (rfid == null)
{
res = new Result() { Succeed = true, ResultData = null, ErrorMessage = "" };
Log.Info(string.Format("WebService Request(POST) emptyStation={0},rfid=null", emptyStation));
Common.LogInfo("任务[POST]:" + value + " 出空料架 [" + emptyStation + "]");
}
else
{
res = new Result() { Succeed = true, ResultData = rfid, ErrorMessage = "" };
Log.Info(string.Format("WebService Request(POST) emptyStation={0},rfid={1}", emptyStation, rfid));
Common.LogInfo("任务[POST]:" + value + " 出空料架 [location=" + emptyStation + ",rfid=" + rfid + "]");
}
}
// AGVControl.Common.log.Debug("WebService POST Response OK");
}
else
{
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "Not find " + emptyStation };
AGVControl.Common.log.Error("WebService POST Response false " + "Not find " + emptyStation);
}
}
return JsonHelper.SerializeObject(res);
}
public string CreateEmptyRecycleTaskGET(string line,string RFID)
{
Result res;
if (line.Equals("Feeder"))
{
line = "FeederOut";
}
else if (line.Equals("4CFeeder"))
{
line = "4CFeederOut";
}
if (Common.GetNodeNameByLineName(line, out string value))
{
if (!Common.AddEmptyShelfTask(value))
{
Common.log.Error("CreateEmptyRecycleTask 节点[" + value + "]不存在");
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "CreateEmptyRecycleTask failed: " + line };
}
else
{
res = new Result() { Succeed = true, ResultData = RFID, ErrorMessage = "" };
Log.Info(string.Format("WebService Request(GET) emptyStation={0},rfid={1}", line, RFID));
Common.LogInfo("任务[GET]:" + value + " 出空料架 [emptyStation=" + line + ",rfid="+RFID+"]");
}
}
else
{
res = new Result() { Succeed = false, ResultData = null, ErrorMessage = "Not find " + line };
AGVControl.Common.LogInfo("WebService GET Response false " + "Not find " + line);
}
//Log.Info(string.Format("WebService GET Request emptyStation={0},rfid={1}", line, RFID));
return JsonHelper.SerializeObject(res);
}
}
public class WebService
{
private WebServiceHost _serviceHost;
public void Open(string url)
{
try
{
ClsWebService service = new ClsWebService();
_serviceHost = new WebServiceHost(service, new Uri(url));//service, new Uri(url)
_serviceHost.Open();
AGVControl.Common.LogInfo("Web服务已开启");
}
catch (Exception ex)
{
AGVControl.Common.log.Error("Open", ex);
}
}
public void Close()
{
try
{
if (_serviceHost != null)//判断服务是否关闭
_serviceHost.Close();//关闭服务
Common.log.Info("Web服务已关闭");
}
catch (Exception ex)
{
Common.log.Error("Close", ex);
}
}
//public void RecycleTask(string lineName)
//{
// if (AGVControl.Common.agvProductionLine.TryGetValue(lineName, out string value))
// {
// AGVControl.Common.LogInfo("WebService Response OK");
// //加到任务
// //int idx = AGVControl.Common.nodeInfo.FindIndex(s => s.Name == value);
// //if (idx > -1)
// // AGVControl.Common.linePlace.Add(value);
// //else
// // AGVControl.Common.log.Error("CreateEmptyRecycleTask " + value + "不存在");
// if (!Common.AddLinePlace(value))
// Common.log.Error("CreateEmptyRecycleTask 节点【" + value + "】不存在");
// else
// {
// Common.LogInfo("任务:" + value + " 出空料架 【" + lineName + "】");
// }
// //System.IO.File.WriteAllLines(Common.CONFIG_PATH + "LinePlace.txt", Common.linePlace);
// }
// else
// {
// AGVControl.Common.LogInfo("WebService Response false");
// }
//}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
namespace BLL
{
public class MyWebClient:WebClient
{
private int _timeout;
/// <summary>
/// 超时时间(毫秒)
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public MyWebClient()
{
this._timeout = 60000;
}
public MyWebClient(int timeout)
{
this._timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
var result = base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}
}
}
文件属性发生变化
此文件的差异被折叠, 点击展开。
using BLL;
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;
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;
}
}
//Common.logTextBox = new TextBox();
//Common.missionView = new DataGridView();
Common.missionManager = new MissionManager();
Common.log = log4net.LogManager.GetLogger("AgvServer");
Common.log.Info("=====程序开始=====");
ReadConfig();
Common.ReadLinePlace();
Common.mir = new MiR_API();
Common.control = new BLL.Control();
//获取节点位置
Common.GetNodesPosition();
Common.control.Start();
Common.server = new AgvServer();
Common.server.Start();
Common.web = new WebService();
Common.web.Open(Common.appConfig.AppSettings.Settings["WebService"].Value);
Application.Run(new FrmMain());
Common.control.Stop();
Common.server.Stop();
Common.web.Close();
Common.log.Info("=====程序结束=====\r\n");
}
private static void ReadConfig()
{
string path;
string[] line;
string[] temp;
bool isuse;
string rfid = "";
Common.appConfig = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
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 != 6) continue;
Boolean.TryParse(Common.ReadIni(temp[1], SettingString.IsUse), out bool isUse);
Int32.TryParse(Common.ReadIni(temp[1], SettingString.EmptyShelfCnt), out int emptyShelfCnt);
if (temp[1].Equals("A5"))
{
Common.nodeInfo.Add(new DoubleLineNodeFor4C(temp[1], temp[2], temp[3], temp[0], temp[4], temp[5], isUse, emptyShelfCnt));
}
else if (temp[1].Equals("A6"))
{
Common.nodeInfo.Add(new DoubleLineNodeFor4D(temp[1], temp[2], temp[3], temp[0], temp[4], temp[5], isUse, emptyShelfCnt));
}
else
Common.nodeInfo.Add(new ClientNode(temp[1], temp[2], temp[3], temp[0], temp[4], temp[5], isUse, emptyShelfCnt));
}
Common.chargeStatus = new ChargeStatus();
Common.itsHttp = Common.appConfig.AppSettings.Settings["ITS"].Value;
}
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_Line.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_Line.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_Line.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;
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))
{
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 string CurStep()
{
return step.ToString();
}
}
}
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace AGVControl
{
public abstract class Node
{
/// <summary>
/// 节点名称
/// </summary>
public string Name { get;}
/// <summary>
/// 节点IP
/// </summary>
public string IP { get; }
/// <summary>
/// 在线状态
/// </summary>
public bool Online { get; set; }
/// <summary>
/// 是否可调用
/// </summary>
public bool IsUse { set; get; }
/// <summary>
/// 节点状态
/// </summary>
protected eNodeStatus nodeStatus;
public Node(string name,string ip,bool isUse=false)
{
Name = name;
IP = ip;
Online = false;
IsUse = isUse;
nodeStatus = eNodeStatus.None;
}
public Node(string name)
{
Name = name;
}
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>
/// 需要7寸D料架
/// </summary>
NeedD = 1,
/// <summary>
/// 需要大尺寸C料架
/// </summary>
NeedC = 2,
/// <summary>
/// 需要进入料架
/// </summary>
NeedEnter = 3,
/// <summary>
/// 需要出去料架
/// </summary>
NeedLeave = 4,
/// <summary>
/// 需要进入离开料架
/// </summary>
NeedEnterLeave = 5,
/// <summary>
/// 准备进入料架,服务器发送
/// </summary>
ReadyEnter = 6,
/// <summary>
/// 可以进入料架
/// </summary>
MayEnter = 7,
/// <summary>
/// 完成进入料架
/// </summary>
FinishEnter = 8,
/// <summary>
/// 准备离开料架,服务器发送
/// </summary>
ReadyLeave = 9,
/// <summary>
/// 可以出去料架
/// </summary>
MayLeave = 10,
/// <summary>
/// 完成出去料架
/// </summary>
FinishLeave = 11,
}
/// <summary>
/// 客户端的优先级
/// </summary>
public enum ClientLevel : byte
{
/// <summary>
/// 低
/// </summary>
Low = 0,
/// <summary>
/// 中等
/// </summary>
Middle = 1,
/// <summary>
/// 高
/// </summary>
High = 2
}
}
文件属性发生变化

using 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 EmptyAGVBackJob : Job
{
/// <summary>
/// 出完满料后-空车返回任务
/// </summary>
/// <param name="agvPlae">小车当前位置,空表示在待机位</param>
/// <param name="palce">空料架位置点</param>
public EmptyAGVBackJob(string agvPlae)
{
this.agvPlace = agvPlae;
}
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlace { get; set; }
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return runInfo; }
}
private JobStep<EMPTY_AGV_BACK_STEP> EmptyAGVBackStep = new JobStep<EMPTY_AGV_BACK_STEP>(EMPTY_AGV_BACK_STEP.NONE);
/// <summary>
/// 空车返回执行
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = runInfo;
//if (!CurTaskID.Equals(-1) && Common.mir.Get_Task_State(CurTaskID, out string st))
// CurTaskState = st;
CurTaskState = Common.GetTakJobState(CurTaskID);
if (EmptyAGVBackStep.IsStep(EMPTY_AGV_BACK_STEP.NONE))
{
if (Common.FindEmptyShelfNode(agv, out string nodeName, true))
{
int i = Common.agvInfo.FindIndex(s => s.CurJob is GoEmptyShelfLineJob && ((GoEmptyShelfLineJob)s.CurJob).EmptyShelfPlace.Equals(nodeName));
if(i==-1)
{
runInfo= "小车在产线 " + agvPlace + " 准备返回时检测到 " + nodeName + " 有空料架";
msg += runInfo;
EmptyAGVBackStep.Msg = msg;
return new GoEmptyShelfLineJob(agvPlace, nodeName);
}
else
{
if (agvPlace.StartsWith(SettingString.C4_Name_Prefix))
{
EmptyAGVBackStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_4D_DOOR);
runInfo= "从产线" + agvPlace + "回待机位,先到4D门";
msg += runInfo;
EmptyAGVBackStep.Msg = msg;
Common.DoorMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
EmptyAGVBackStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_REACH_STANDBY);
runInfo= "从产线" + agvPlace + "回待机位";
msg += runInfo;
EmptyAGVBackStep.Msg = msg;
Common.MoveToNode(agv, SettingString.Standby);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
//EmptyAGVBackStep.ToNextStep(EMPTY_AGV_BACK_STEP.END);
}
else
{
if (agvPlace.StartsWith(SettingString.C4_Name_Prefix))
{
EmptyAGVBackStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_4D_DOOR);
runInfo= "从产线" + agvPlace + "回待机位,先到4D门";
msg += runInfo;
EmptyAGVBackStep.Msg = msg;
Common.DoorMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
EmptyAGVBackStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_REACH_STANDBY);
runInfo= "从产线" + agvPlace + "回待机位";
msg += runInfo;
EmptyAGVBackStep.Msg = msg;
Common.MoveToNode(agv, SettingString.Standby);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
}
else if (EmptyAGVBackStep.IsStep(EMPTY_AGV_BACK_STEP.WAIT_REACH_STANDBY))
{
CurTaskState = Common.GetTakJobState(CurTaskID);
if (Common.CheckTaskFinished(agv, SettingString.Standby,CurTaskState))
{
Job job = Common.control.GetJob(agv);
if (job == null && agv.Battery < Common.chargeStatus.chargeMax)
{
runInfo= "到达待机位,电量[" + agv.Battery + "]小于最大电量[" + Common.chargeStatus.chargeMax + "],暂无任务,去充电";
msg += runInfo;
EmptyAGVBackStep.Msg = msg;
return new ChargeJob("");
}
else
{
runInfo= "到达待机位,检测到新任务,执行任务";
msg += runInfo;
EmptyAGVBackStep.Msg = msg;
return job;
}
}
else
{
if (Common.FindFullShelfTask(agv))
{
runInfo= "从产线" + agvPlace + "回待机位过程中,检测到A6出满料,去A6";
msg += runInfo;
EmptyAGVBackStep.Msg = msg;
return new GoFullShelfStationJob(SettingString.Standby);
}
//else
//{
// msg = "从产线" + agvPlace + "到达4D门,暂无任务,去充电位";
// EmptyAGVBackStep.Msg = msg;
// return new ChargeJob(SettingString.D4_DOOR_Name);
//}
}
}
//else if (EmptyAGVBackStep.IsStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_4D_DOOR))
//{
// CurTaskState = Common.GetTakJobState(CurTaskID);
// if (Common.CheckTaskFinished(agv, SettingString.DoorCToD, CurTaskState))
// {
// EmptyAGVBackStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_REACH_STANDBY);
// runInfo = "从产线" + agvPlace + "回待机位";
// msg += runInfo;
// EmptyAGVBackStep.Msg = msg;
// }
//}
else if (EmptyAGVBackStep.IsStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_4D_DOOR))
{
CurTaskState = Common.GetTakJobState(CurTaskID);
if (Common.CheckTaskFinished(agv, SettingString.DoorCToD, CurTaskState))
{
if (Common.FindFullShelfTask(agv))
{
runInfo = "从产线" + agvPlace + "到达4D门,检测到A6出满料,去A6";
msg += runInfo;
EmptyAGVBackStep.Msg = msg;
return new GoFullShelfStationJob(SettingString.DoorCToD);
}
else
{
runInfo = "从产线" + agvPlace + "到达4D门,暂无任务,去充电位";
msg += runInfo;
EmptyAGVBackStep.Msg = msg;
return new ChargeJob(SettingString.DoorCToD);
}
}
}
return this;
}
/// <summary>
/// AGV回收空料架流程
/// </summary>
private enum EMPTY_AGV_BACK_STEP
{
/// <summary>
/// 查询任务
/// </summary>
NONE,
/// <summary>
/// 等待到达4D门
/// </summary>
WAIT_AGV_REACH_4D_DOOR,
/// <summary>
/// 等待恒邑反馈
/// </summary>
WAIT_HY_RESPONSE,
/// <summary>
/// 等待AGV到达待机位
/// </summary>
WAIT_REACH_STANDBY,
/// <summary>
///
/// </summary>
END
}
}
}

using AGVControl;
using BLL;
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="palce">位置点名称</param>
/// <param name="rfid">RFID</param>
public EnterLeaveShelfJob(string palce, eEnterLeaveType type,eShelfType shelfType= eShelfType.SmallShelf,string rfid="")
{
LineName = palce;
RFID = rfid;
ActionType = type;
this.shelfType = shelfType;
}
/// <summary>
/// 位置名
/// </summary>
public new string LineName { get; set; }
public string RFID { get; set; }
public eEnterLeaveType ActionType { get; set; }
private eShelfType shelfType;
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return runInfo; }
}
private JobStep<ENTER_LEAVE_SHELF_STEP> 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 (!CurTaskID.Equals(-1) && Common.mir.Get_Task_State(CurTaskID, out string st))
// CurTaskState = st;
if (EnterLeaveShelfStep.IsStep(ENTER_LEAVE_SHELF_STEP.NONE))
{
if (ActionType.Equals(eEnterLeaveType.Leave))
{
//EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT_LINE_ReadyEnter_RESPONSE);
//msg = "AGV到达 " + LineName + ",并发送入料架请求[ReadyEnter]";
//EnterLeaveShelfStep.Msg = msg;
//Common.server.ReadyEnter(LineName);
EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_IN_LINE);
runInfo = LineName + "入料架,小车链条运行";
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_LINE_ReadyLeave_RESPONSE);
//msg = "AGV到达 " + LineName + ",并发送出料架请求[ReadyLeave]";
//EnterLeaveShelfStep.Msg = msg;
//Common.server.ReadyLeave(LineName);
EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_OUT_LINE);
runInfo = LineName + "出料架,小车链条运行";
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_LINE_ReadyEnter_RESPONSE))
{
int id = Common.FindNode(LineName);
ClientNode node = Common.nodeInfo[id];
if (node.StateEquals(eNodeStatus.MayEnter))
{
EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_IN_LINE);
runInfo= "收到产线入料架请求[ReadyEnter]的响应, " + LineName + "入料架,小车链条运行";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Leave"]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else if (EnterLeaveShelfStep.IsTimeOut(15000, out double timeOutValue))
{
EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.NONE);
runInfo = "AGV到达 " + LineName + ",15秒后重新向产线发送入料架请求[ReadyEnter]";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
}
}
else if (EnterLeaveShelfStep.IsStep(ENTER_LEAVE_SHELF_STEP.WAIT_LINE_ReadyLeave_RESPONSE))
{
int id = Common.FindNode(LineName);
ClientNode node = Common.nodeInfo[id];
if (node.StateEquals(eNodeStatus.MayLeave))
{
EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_OUT_LINE);
runInfo= "收到产线出料架请求[ReadyLeave]的响应, " + LineName + "出料架,小车链条运行";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Enter"]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else if (EnterLeaveShelfStep.IsTimeOut(15000, out double timeOutValue))
{
EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.NONE);
runInfo= "AGV到达 " + LineName + ",15秒后重新向产线发送入料架请求[ReadyLeave]";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
}
}
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= "料架进入" + LineName + "完成 [" + RFID + "]";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
agv.RFID = "";
return new EmptyAGVBackJob(LineName);
}
else if (EnterLeaveShelfStep.IsTimeOut(60000, out double timeOutValue))
{
//链条停止
runInfo= "料架在[" + LineName + "]离开小车超时[" + 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 = "料架在" + LineName + "出去完成 [" + RFID + "]";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
Common.DelEmptyShelfTask(LineName);
return new EmptyShelfBackJob(LineName,eShelfType.BigShelf);
}
else if (EnterLeaveShelfStep.IsTimeOut(60000, out double timeOutValue))
{
//链条停止
runInfo= "料架在[" + LineName + "]进入小车超时[" + 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>
/// 等待产线ReadyEnter回应
/// </summary>
WAIT_LINE_ReadyEnter_RESPONSE,
/// <summary>
/// 等待产线ReadyLeave回应
/// </summary>
WAIT_LINE_ReadyLeave_RESPONSE,
/// <summary>
/// 等待料架离开产线
/// </summary>
WAIT__SHELF_OUT_LINE,
/// <summary>
/// 等待料架进入产线
/// </summary>
WAIT__SHELF_IN_LINE,
/// <summary>
/// 进入/离开完成
/// </summary>
END
}
}
文件属性发生变化
using 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; }
/// <summary>
/// 节点位置的guid
/// </summary>
public string Pos_guid { set; get; }
/// <summary>
/// 节点位置名称
/// </summary>
public string Pos_name { get; set; }
public ClientLevel ClientLevel { get; set; } = ClientLevel.Low;
/// <summary>
/// 节点位置坐标
/// </summary>
public PositionStru position;
/// <summary>
/// 空料架数量
/// </summary>
public int EmptyShelfCnt
{
get { return _EmptyShelfCnt; }
set
{
EmptyShelfCnt = _EmptyShelfCnt;
}
}
/// <summary>
/// 空架子的RFID
/// </summary>
public List<string> EmptyShelfRFIDs;
private int _EmptyShelfCnt = 0;
public string AliceName { get; set; }
/// <summary>
/// 客户端节点
/// </summary>
/// <param name="name"></param>
/// <param name="ip"></param>
/// <param name="isUse"></param>
public ClientNode(string name, string ip, string aliceName,string lineName, string pos_name, string pos_guid, bool isUse,int emptyCnt) : base(name, ip, isUse)
{
AliceName = aliceName;
RFID = rfid;
AgvName = "";
Online = false;
IsUse = isUse;
_EmptyShelfCnt = emptyCnt;
this.Pos_name = pos_name;
this.Pos_guid = pos_guid;
LineName = lineName;
EmptyShelfRFIDs = new List<string>();
}
/// <summary>
/// 客户端节点
/// </summary>
/// <param name="name"></param>
/// <param name="rfid"></param>
/// <param name="action"></param>
/// <param name="level"></param>
public ClientNode(string name, string rfid = "", eNodeStatus status = eNodeStatus.None) : base(name)
{
RFID = rfid;
nodeStatus = status;
AgvName = "";
}
/// <summary>
///空料架数量增加,如果RFID相同,不增加数量
/// </summary>
public void IncreEmptyShelfCnt(string rfid="")
{
if(!rfid.Equals("") && !EmptyShelfRFIDs.Contains(rfid))
{
System.Threading.Interlocked.Increment(ref _EmptyShelfCnt);
EmptyShelfRFIDs.Add(rfid);
Common.WriteIni(Name, SettingString.EmptyShelfCnt,_EmptyShelfCnt.ToString());
}
else if(rfid.Equals(""))
{
System.Threading.Interlocked.Increment(ref _EmptyShelfCnt);
Common.WriteIni(Name, SettingString.EmptyShelfCnt, _EmptyShelfCnt.ToString());
}
}
/// <summary>
/// 空料架数量减少1
/// </summary>
public void DecreEmptyShelfCnt()
{
if (_EmptyShelfCnt > 0)
{
System.Threading.Interlocked.Decrement(ref _EmptyShelfCnt);
Common.WriteIni(Name, SettingString.EmptyShelfCnt, _EmptyShelfCnt.ToString());
}
if(_EmptyShelfCnt.Equals(0) && EmptyShelfRFIDs.Count>0)
{
EmptyShelfRFIDs.Clear();
}
}
/// <summary>
/// 节点状态的文本形式
/// </summary>
/// <returns></returns>
public string StatetText()
{
string s = string.Format("[Name={0}, NodeStatus={1}, RFID={2},ClientLevel ={3}]", Name, nodeStatus.ToString(), RFID, ClientLevel.ToString());
return s;
}
public string[] ToRow()
{
//节点,IP,动作,RFID,AGV名称,在线,调用,清除AGV
string[] s = new string[8];
s[0] = AliceName;
s[1] = IP;
// if (Online)
// {
s[2] = EmptyShelfCnt.ToString();//string.Format("({0},{1})", position.X.ToString("f2"), position.Y.ToString("f2"));
s[3] = nodeStatus.ToString();
s[4] = ClientLevel.ToString();
s[5] = RFID;
// s[5] = AgvName;
// }
s[6] = Online ? "在线" : "离线";
s[7] = IsUse ? "是" : "否";
// s[8] = "清除";
return s;
}
/// <summary>
/// 脱机
/// </summary>
public void Offline()
{
RFID = "00";
nodeStatus = eNodeStatus.None;
AgvName = "";
Online = false;
}
public virtual Job GetNewJob(Agv_Info agv)
{
return null;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl
{
/// <summary>
/// 双层线有料料架出口
/// </summary>
public class DoubleLineNodeFor4C : ClientNode
{
public DoubleLineNodeFor4C(string name, string ip, string aliceName, string lineName, string pos_name, string pos_guid, bool isUse, int emptyCnt) : base(name, ip, aliceName, lineName, pos_name, pos_guid, isUse, emptyCnt)
{
}
/// <summary>
/// 双层线任务
/// </summary>
/// <param name="currentAgv"></param>
/// <returns></returns>
public override Job GetNewJob(Agv_Info currentAgv)
{
if (!SettingString.C4_AGV_IPs.Contains(currentAgv.IP))
return null;
if (!Common.CheckCanExecuteMission(currentAgv))
return null;
if (!Common.CheckAGVStatusNone(currentAgv))
return null;
//执行空料架任务的小车数量
int emptyJobCnt = 0;
foreach (Agv_Info agv in Common.agvInfo)
{
if (!SettingString.C4_AGV_IPs.Contains(agv.IP))
continue;
if (agv.CurJob is GoEmptyShelfLineJob || agv.CurJob is EmptyShelfBackJob)
{
emptyJobCnt++;
}
}
if ((SettingString.AGVCNT - emptyJobCnt).Equals(2))//保留2辆小车出满料架
{
return null;
}
//出工单料的目的地是否有空料架
if (Common.FindEmptyShelfBeforeSendFullShelf(out string nodeName))
{
if (nodeName.StartsWith(SettingString.C4_Name_Prefix) && SettingString.C4_AGV_IPs.Contains(currentAgv.IP))
{
ClientNode clientNode = Common.nodeInfo.Find(s => s.Name.Equals(nodeName));
int cnt = 0;
foreach (Agv_Info agv in Common.agvInfo)
{
if (agv.CurJob is GoEmptyShelfLineJob)
{
if (((GoEmptyShelfLineJob)agv.CurJob).EmptyShelfPlace.Equals(nodeName))
cnt++;
}
}
if (cnt < clientNode.EmptyShelfCnt)
{
return new GoEmptyShelfLineJob(currentAgv.Place, nodeName);
}
}
}
//回收空料架
if (Common.FindEmptyShelfNode(currentAgv, out string emptyNodeName))
{
if (SettingString.C4_AGV_IPs.Contains(currentAgv.IP))
{
int i = Common.agvInfo.FindIndex(s => s.CurJob is GoEmptyShelfLineJob && ((GoEmptyShelfLineJob)s.CurJob).EmptyShelfPlace.Equals(emptyNodeName));
if (i == -1)
return new GoEmptyShelfLineJob(currentAgv.Place, emptyNodeName);
}
}
//出满料
if (Common.FindFullShelfTask(currentAgv))
{
if (SettingString.C4_AGV_IPs.Contains(currentAgv.IP))
{
int i = Common.agvInfo.FindIndex(s => s.CurJob is GoFullShelfStationJob && !s.IP.Equals(currentAgv.IP));
if (i == -1)
return new GoFullShelfStationJob(currentAgv.Place);
}
}
return null;
}
}
}
using BLL;
using log4net.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl
{
/// <summary>
///
/// </summary>
public class DoubleLineNodeFor4D : ClientNode
{
public DoubleLineNodeFor4D(string name, string ip, string aliceName, string lineName, string pos_name, string pos_guid, bool isUse, int emptyCnt) : base(name, ip, aliceName, lineName, pos_name, pos_guid, isUse, emptyCnt)
{
}
/// <summary>
/// 双层线任务
/// </summary>
/// <param name="currentAgv"></param>
/// <returns></returns>
public override Job GetNewJob(Agv_Info currentAgv)
{
if (SettingString.C4_AGV_IPs.Contains(currentAgv.IP))
return null;
if (!Common.CheckCanExecuteMission(currentAgv))
return null;
if (!Common.CheckAGVStatusNone(currentAgv))
return null;
//执行空料架任务的小车数量
int emptyJobCnt = 0;
foreach (Agv_Info agv in Common.agvInfo)
{
if (SettingString.C4_AGV_IPs.Contains(agv.IP))
continue;
if (agv.CurJob is GoEmptyShelfLineJob || agv.CurJob is EmptyShelfBackJob)
{
emptyJobCnt++;
}
}
if ((SettingString.AGVCNT / 2 - emptyJobCnt).Equals(1))//保留1辆小车出满料架
{
return null;
}
//出工单料的目的地是否有空料架
if (Common.FindEmptyShelfBeforeSendFullShelf(out string nodeName))
{
if (nodeName.StartsWith(SettingString.D4_Name_Prefix) && !SettingString.C4_AGV_IPs.Contains(currentAgv.IP))
{
ClientNode clientNode = Common.nodeInfo.Find(s => s.Name.Equals(nodeName));
int cnt = 0;
foreach (Agv_Info agv in Common.agvInfo)
{
if (SettingString.C4_AGV_IPs.Contains(agv.IP))
continue;
if (agv.CurJob is GoEmptyShelfLineJob)
{
if (((GoEmptyShelfLineJob)agv.CurJob).EmptyShelfPlace.Equals(nodeName))
cnt++;
}
}
if (cnt < clientNode.EmptyShelfCnt)
{
return new GoEmptyShelfLineJob(currentAgv.Place, nodeName);
}
}
}
//回收空料架
if (Common.FindEmptyShelfNode(currentAgv, out string emptyNodeName))
{
if (!SettingString.C4_AGV_IPs.Contains(currentAgv.IP))
{
int i = Common.agvInfo.FindIndex(s => s.CurJob is GoEmptyShelfLineJob && ((GoEmptyShelfLineJob)s.CurJob).EmptyShelfPlace.Equals(emptyNodeName));
if (i == -1)
return new GoEmptyShelfLineJob(currentAgv.Place, emptyNodeName);
}
}
//出满料
if (Common.FindFullShelfTask(currentAgv))
{
if (!SettingString.C4_AGV_IPs.Contains(currentAgv.IP))
{
int i = Common.agvInfo.FindIndex(s => s.CurJob is GoFullShelfStationJob && !s.IP.Equals(currentAgv.IP));
if (i > -1)
{
return null;
}
ClientNode node = Common.nodeInfo.Find(s => s.Name.Equals(SettingString.A6)
&& (s.StateEquals(eNodeStatus.NeedLeave) || s.StateEquals(eNodeStatus.NeedEnterLeave)) && !s.RFID.Equals("00"));
if (node != null && node.Name.Equals(SettingString.A6))
{
if (AGVManager.FindFullShelfTarget(node.RFID, out AGVManager.BoxDestInfo boxDestInfo))
{
if (boxDestInfo != null)
{
i = Common.agvInfo.FindIndex(s => s.CurJob is SendFullShelfToLineJob && !s.IP.Equals(currentAgv.IP)
&& ((SendFullShelfToLineJob)s.CurJob).FullShelfPlace.Equals(boxDestInfo.location));
if (i > -1)
return null;
}
}
}
return new GoFullShelfStationJob(currentAgv.Place);
}
}
return null;
}
}
}
此文件类型无法预览
此文件类型无法预览
文件属性发生变化
此文件类型无法预览
此文件类型无法预览
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="RestSharp" version="106.11.4" targetFramework="net461" />
</packages>
\ No newline at end of file \ No newline at end of file
此文件类型无法预览
此文件的差异被折叠, 点击展开。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D9154766-67B0-4082-AF8B-DCC7C4CFB5A2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AgvClient</RootNamespace>
<AssemblyName>AsaPL.AgvClient</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\..\..\DLL\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AgvClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("AgvClient")]
[assembly: AssemblyDescription("AGV对接双层线生产线客户端")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("挚锦科技")]
[assembly: AssemblyProduct("AgvClient")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("d9154766-67b0-4082-af8b-dcc7c4cfb5a2")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
文件属性发生变化
文件属性发生变化
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E1C0827A-FA12-49A9-AC71-6D3E6518754A}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>AgvClientTest</RootNamespace>
<AssemblyName>AgvClientTest</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="AsaPL.AgvClient, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\AgvClient\bin\Debug\AsaPL.AgvClient.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\..\..\DLL\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<log4net>
<appender name="AgvClient" type="log4net.Appender.RollingFileAppender">
<file value="logs/AgvClient.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<root>
<level value="Info"/>
<appender-ref ref="AgvClient"/>
</root>
</log4net>
</configuration>
\ No newline at end of file \ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AgvClientTest
{
public partial class Form1 : Form
{
private AsaPL.AgvClient client;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 12; i++)
comboBox1.Items.Add((AsaPL.ClientAction)i);
comboBox1.SelectedIndex = 0;
comboBox2.SelectedIndex = 0;
comboBox3.Items.Add(AsaPL.ClientAction.MayEnter);
comboBox3.Items.Add(AsaPL.ClientAction.MayLeave);
comboBox3.SelectedIndex = 0;
client = new AsaPL.AgvClient("10.85.199.1");
client.ReadyEnter += AGV_ReadyEnter;
client.ReadyLeave += AGV_ReadyLeave;
//client.SetStatus("E1", "", AsaPL.ClientAction.None);
//client.SetStatus("E2", "", AsaPL.ClientAction.None);
//client.SetStatus("E3", "", AsaPL.ClientAction.None);
//client.SetStatus("E4", "", AsaPL.ClientAction.None);
//client.SetStatus("E5", "", AsaPL.ClientAction.None);
//client.SetStatus("E6", "", AsaPL.ClientAction.None);
//client.SetStatus("E8", "", AsaPL.ClientAction.None);
//client.SetStatus("E9", "", AsaPL.ClientAction.None);
//client.SetStatus("E10", "", AsaPL.ClientAction.None);
//client.SetStatus("E11", "", AsaPL.ClientAction.None);
//client.SetStatus("E12", "", AsaPL.ClientAction.None);
//client.SetStatus("E14", "", AsaPL.ClientAction.None);
//client.SetStatus("E15", "", AsaPL.ClientAction.None);
//client.SetStatus("E16", "", AsaPL.ClientAction.None);
//client.SetStatus("D4FeederIn", "", AsaPL.ClientAction.None);
//client.SetStatus("D4FeederOut", "", AsaPL.ClientAction.None);
//client.SetStatus("C4FeederIn", "", AsaPL.ClientAction.None);
//client.SetStatus("C4FeederOut", "", AsaPL.ClientAction.None);
client.Connect();
}
private void AGV_ReadyEnter(string nodeName)
{
if (checkBox1.Checked)
{
if (nodeName.StartsWith("A") || nodeName.EndsWith("A"))//|| nodeName.Equals("G10") || nodeName.Equals("G7")
return;
label4.Text = "收到" + nodeName + "ReadyEnter,节点状态变为MayEnter";
client.SetStatus(nodeName, "", AsaPL.ClientAction.MayEnter);
System.Threading.Thread.Sleep(10000);
client.SetStatus(nodeName, "", AsaPL.ClientAction.None);
label4.Text = "设置" + nodeName + " None";
}
}
private void AGV_ReadyLeave(string nodeName)
{
if (checkBox1.Checked)
{
if (nodeName.StartsWith("A") || nodeName.EndsWith("A"))//|| nodeName.Equals("G10") || nodeName.Equals("G7")
return;
label4.Text = "收到" + nodeName + "ReadyLeave,节点状态变为MayLeave";
client.SetStatus(nodeName, "", AsaPL.ClientAction.MayLeave);
System.Threading.Thread.Sleep(10000);
client.SetStatus(nodeName, "", AsaPL.ClientAction.None);
label4.Text = "设置" + nodeName + " None";
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
client.Close();
}
private void button1_Click(object sender, EventArgs e)
{
Task task = new Task(new Action(() => {
client.SetStatus(comboBox2.SelectedItem.ToString(), textBox1.Text, (AsaPL.ClientAction)comboBox1.SelectedIndex);
System.Threading.Thread.Sleep(10000);
client.SetStatus(comboBox2.SelectedItem.ToString(), "", AsaPL.ClientAction.None);
label4.Text = "设置" + comboBox2.SelectedItem.ToString() + " None";
}));
task.Start();
}
private void SetLineState(object sender, EventArgs e)
{
Task task = new Task(new Action(()=>{
if (comboBox3.SelectedItem == null)
return;
string name = ((Button)sender).Text;
client.SetStatus(name, "", (AsaPL.ClientAction)Enum.Parse(typeof(AsaPL.ClientAction), comboBox3.SelectedItem.ToString()));
label5.Text = name + " " + comboBox3.SelectedItem.ToString();
System.Threading.Thread.Sleep(10000);
client.SetStatus(name, "", AsaPL.ClientAction.None);
label5.Text = "设置" + name + " None";
}));
task.Start();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
using log4net.Config;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AgvClientTest
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
XmlConfigurator.Configure();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("AgvClientTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AgvClientTest")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("e1c0827a-fa12-49a9-ac71-6d3e6518754a")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace AgvClientTest.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AgvClientTest.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 覆盖当前线程的 CurrentUICulture 属性
/// 使用此强类型的资源类的资源查找。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AgvClientTest.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
文件属性发生变化
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<protocolMapping>
<add scheme="https" binding="basicHttpsBinding" />
</protocolMapping>
<bindings>
<webHttpBinding>
<binding name="webBinding" maxReceivedMessageSize="2147483647" crossDomainScriptAccessEnabled="true" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="LineWebService.ClsWebService" behaviorConfiguration="RESTBehavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:11111/BenQMIR/Webservice/AGVService.asmx" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address =""
binding="webHttpBinding"
contract="LineWebService.IWebService"
behaviorConfiguration="ESEndPointBehavior">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="RESTBehavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="ESEndPointBehavior">
<webHttp helpEnabled="true" />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace LineWebService
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的类名“Service1”。
//[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Reentrant)]
///[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
public class ClsWebService : IWebService
{
//private readonly log4net.ILog LOG = log4net.LogManager.GetLogger("ClsWebService");
public ClsWebService()
{
}
public Result CreateEmptyRecycleTask(string line)
{
//LOG.Info("CreateEmptyRecycleTask emptyStation=" + line);
Result res;
if (!line.Equals(""))
{
res = new Result() { Succeed = "true", ResultData = "", ErrorMessage = "" };
//IWebService_Callback callback = OperationContext.Current.GetCallbackChannel<IWebService_Callback>();
//callback.GetEmptyRecycleTask(line);
}
else
{
res = new Result() { Succeed = "false", ResultData = "", ErrorMessage = "Not find " + line };
}
//if (AGVControl.Common.agvProductionLine.TryGetValue(line, out string value))
//{
// res = new Result() { Succeed = "true", ResultData = "", ErrorMessage = "" };
//LOG.Info("WebService Response OK");
// //加到任务
// //int idx = AGVControl.Common.nodeInfo.FindIndex(s => s.Name == value);
// //if (idx > -1)
// // AGVControl.Common.linePlace.Add(value);
// //else
// // AGVControl.Common.log.Error("CreateEmptyRecycleTask " + value + "不存在");
// if (!Common.AddLinePlace(value))
// Common.log.Error("CreateEmptyRecycleTask 节点【" + value + "】不存在");
// else
// {
// Common.LogInfo("任务:" + value + " 出空料架 【" + line + "】");
// }
// //System.IO.File.WriteAllLines(Common.CONFIG_PATH + "LinePlace.txt", Common.linePlace);
//}
//else
//{
// res = new Result() { Succeed = "false", ResultData = "", ErrorMessage = "Not find " + line };
//LOG.Info("WebService Response false");
//}
return res;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace LineWebService
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService1”。
[ServiceContract]//(CallbackContract = typeof(IWebService_Callback))
public interface IWebService
{
[OperationContract]
[WebInvoke(UriTemplate = "CreateEmptyRecycleTask?emptyStation={line}", Method = "Get",
BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
Result CreateEmptyRecycleTask(string line);
//log4net.Config.XmlConfigurator.Configure();
// TODO: 在此添加您的服务操作
}
//[ServiceContract]
//public interface IWebService_Callback
//{
// [OperationContract(IsOneWay = true)]
// void GetEmptyRecycleTask(string lineName);
//}
// 使用下面示例中说明的数据约定将复合类型添加到服务操作。
[DataContract]
public class Result
{
[DataMember]
public string Succeed { get; set; }
[DataMember]
public string ResultData { get; set; }
[DataMember]
public string ErrorMessage { get; set; }
}
}
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{074D4597-8955-4EEE-840A-8FAA9B174603}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WebService</RootNamespace>
<AssemblyName>WebService</AssemblyName>
<ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<StartArguments>/client:"WcfTestClient.exe"</StartArguments>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<WcfConfigValidationEnabled>True</WcfConfigValidationEnabled>
<XsdCodeGenEnabled>True</XsdCodeGenEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="IWebService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ClsWebService.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<VSToolsPath Condition="'$(VSToolsPath)' == '' and '$(VisualStudioVersion)' != '' and '$(VisualStudioVersion)' != '11.0'">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio</VSToolsPath>
<WcfServiceModelTargetPath>$(VSToolsPath)\WCF</WcfServiceModelTargetPath>
</PropertyGroup>
<Import Project="$(WcfServiceModelTargetPath)\Microsoft.VisualStudio.ServiceModel.targets" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{3D9AD99F-2412-4246-B90B-4EAA41C64699}">
<WcfProjectProperties>
<AutoStart>True</AutoStart>
</WcfProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file \ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("WebService")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WebService")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("074d4597-8955-4eee-840a-8faa9b174603")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
文件属性发生变化
using BLL.BLL;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace BLL
{
public class AGVManager
{
//public static string Add_emptyMsg = "http://10.85.199.1/BenQMIR/Webservice/AGVService.asmx/CreateEmptyRecycleTask";//"http://localhost:11111/BenQMIR/Webservice/AGVService.asmx/CreateEmptyRecycleTask";//
public static string CreateEmptyTask(string Add_emptyMsg, string line)
{
try
{
//Dictionary<string, string> paramMap = new Dictionary<string, string>();
//paramMap.Add("emptyStation", "D1");
string path = Add_emptyMsg;
//foreach (string paramName in paramMap.Keys)
//{
// string par = System.Web.HttpUtility.UrlEncode(paramMap[paramName], System.Text.Encoding.UTF8);
// path += paramName + "=" + par + "&";
//}
//path = path.Substring(0, path.Length - 1);
string resultStr = HttpUtil.Post(path, "emptyStation=" + line);//HttpHelper.Post(path, "");
//Common.log.Debug("【" + path + "】【" + resultStr + "】");
//Result data = JsonHelper.DeserializeJsonToObject<Result>(resultStr);
return resultStr;
//if (data == null)
//{
// return " updateDeviceAlarmMsg 没有收到服务器反馈";
//}
//else
//{
// return data.Succeed;
//}
}
catch (Exception e)
{
return e.ToString();
}
}
public static Result GetWebservice(string Add_emptyMsg,string id)
{
Result rb = new Result();
try
{
//http://10.85.36.156/BenQMIR/Webservice/AGVService.asmx
string strURL = Add_emptyMsg + "?emptyStation=" + id;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
//request.Method="get";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream s = response.GetResponseStream();
XmlTextReader Reader = new XmlTextReader(s);
Reader.MoveToContent();
string strValue = Reader.ReadInnerXml();
strValue = strValue.Replace("&lt;", "<");
strValue = strValue.Replace("&gt;", ">");
//{"Succeed":false,"ResultData":null,"ErrorMessage":"无法通过[Feederaaaa]lineCode找到小车停靠点"}
rb = JsonConvert.DeserializeObject<Result>(strValue);
Reader.Close();
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.Message);
}
return rb;
}
/// <summary>
/// 获取大料架解绑情况
/// </summary>
/// <param name="rfid"></param>
/// <param name="lineName"></param>
/// <returns></returns>
public static bool GetRackBy(string rfid, out string lineName)
{
lineName = "";
//GET /ESMTCommonInterface/CommonService.asmx/GetRackBy?id=string HTTP/1.1
//Host: 10.85.17.233
string addr = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/GetRackBy?id=" + rfid;
//[{"msg":"1OKD1"}]
//[{"msg":"0NGFeeder"}]
try
{
string result = HttpUtil.Get(addr);
if (!result.Equals(""))
{
List<Msg> msgs = JsonHelper.DeserializeJsonToList<Msg>(result);
if (msgs == null || msgs.Count == 0)
return false;
int.TryParse(msgs[0].msg.Substring(0, 1), out int resCode);
string resStr = msgs[0].msg.Substring(1, 2);
lineName = msgs[0].msg.Substring(3);
//Common.log.Debug(string.Format("resCode={0},resStr={1},lineName={2}", resCode, resStr, lineName));
if (lineName.Equals("").Equals(true))
return false;
return true;
}
}
catch { return false; }
return false;
}
/// <summary>
/// 物料状态上报
/// </summary>
/// <param name="rfid"></param>
/// <param name="lineName"></param>
/// <returns></returns>
public static bool UpdateStatus(string rfid, string lineName)
{
//GET /ESMTCommonInterface/CommonService.asmx/UpdateStatusBy?id=string&location=string HTTP/1.1
//Host: 10.85.17.233
string addr = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/UpdateStatusBy?id=" + rfid + "&location=" + lineName;
//[{"msg":"1更新成功"}]
try
{
string result = HttpUtil.Get(addr);
if (!result.Equals(""))
{
List<Msg> msgs = JsonHelper.DeserializeJsonToList<Msg>(result);
if (msgs == null || msgs.Count == 0)
return false;
bool resRtn = int.TryParse(msgs[0].msg.Substring(0, 1), out int resCode);
if (resRtn)
{
if (resCode.Equals(1))
{
System.Windows.Forms.MessageBox.Show(string.Format("{0}物料状态更新成功[{1}]", lineName, rfid));
return true;
}
else
return false;
}
return false;
}
}
catch { return false; }
return false;
}
private class Msg
{
public string msg { get; set; }
}
}
public class Result
{
public string Succeed { get; set; }
public string ResultData { get; set; }
public string ErrorMessage { get; set; }
}
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<protocolMapping>
<add scheme="https" binding="basicHttpsBinding" />
</protocolMapping>
<bindings>
<webHttpBinding>
<binding name="webBinding" maxReceivedMessageSize="2147483647" crossDomainScriptAccessEnabled="true" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="LineWebService.ClsWebService" behaviorConfiguration="RESTBehavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:22222/BenQMIR/Webservice/AGVService.asmx/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address =""
binding="webHttpBinding"
contract="LineWebService.IWebService"
behaviorConfiguration="ESEndPointBehavior">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="RESTBehavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="ESEndPointBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
namespace WebServiceTest
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(12, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(132, 54);
this.button1.TabIndex = 0;
this.button1.Text = "监听";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(12, 90);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(132, 54);
this.button2.TabIndex = 1;
this.button2.Text = "关闭";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(26, 187);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(55, 15);
this.label1.TabIndex = 2;
this.label1.Text = "label1";
//
// button3
//
this.button3.Location = new System.Drawing.Point(273, 90);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(132, 54);
this.button3.TabIndex = 3;
this.button3.Text = "POST访问";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(150, 12);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(497, 72);
this.textBox1.TabIndex = 4;
this.textBox1.Text = "http://10.85.199.1/BenQMIR/Webservice/AGVService.asmx/CreateEmptyRecycleTask";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(160, 119);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(79, 25);
this.textBox2.TabIndex = 5;
this.textBox2.Text = "D1";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(150, 176);
this.textBox3.Multiline = true;
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(497, 160);
this.textBox3.TabIndex = 6;
//
// button4
//
this.button4.Location = new System.Drawing.Point(443, 90);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(132, 54);
this.button4.TabIndex = 7;
this.button4.Text = "feeder区访问";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Location = new System.Drawing.Point(592, 90);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(132, 54);
this.button5.TabIndex = 8;
this.button5.Text = "大料架回收访问";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button6
//
this.button6.Location = new System.Drawing.Point(735, 41);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(132, 54);
this.button6.TabIndex = 9;
this.button6.Text = "物料状态上报";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(879, 368);
this.Controls.Add(this.button6);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button3);
this.Controls.Add(this.label1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "客户端创建产线任务";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button6;
}
}
using LineWebService;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.ServiceModel.Web;
using System.ServiceModel;
using System.Linq.Expressions;
using BLL;
namespace WebServiceTest
{
public partial class Form1 : Form//, IWebService_Callback
{
public Form1()
{
InitializeComponent();
}
private WebServiceHost _serviceHost;
public void HostOpen()
{
try
{
ClsWebService service = new ClsWebService();
_serviceHost = new WebServiceHost(typeof(ClsWebService));//service, new Uri(url)
if (_serviceHost.State != CommunicationState.Opened)//判断服务是否关闭
{
_serviceHost.Open();
}
label1.Text="Web服务已开启";
}
catch (Exception ex)
{
//AGVControl.Common.log.Error("Open", ex);
MessageBox.Show(ex.ToString());
}
}
public void HostClose()
{
try
{
if (_serviceHost.State != CommunicationState.Closed)//判断服务是否关闭
{
_serviceHost.Close();//关闭服务
}
//_serviceHost.Close();
label1.Text="Web服务已关闭";
}
catch (Exception ex)
{
//AGVControl.Common.log.Error("Close", ex);
MessageBox.Show(ex.ToString());
}
}
//public void GetEmptyRecycleTask(string lineName)
//{
// label1.Text = lineName;
// MessageBox.Show(lineName);
//}
public void RecycleTask(string lineName)
{
label1.Text = lineName;
MessageBox.Show(lineName);
//if (AGVControl.Common.agvProductionLine.TryGetValue(lineName, out string value))
//{
// AGVControl.Common.LogInfo("WebService Response OK");
// //加到任务
// //int idx = AGVControl.Common.nodeInfo.FindIndex(s => s.Name == value);
// //if (idx > -1)
// // AGVControl.Common.linePlace.Add(value);
// //else
// // AGVControl.Common.log.Error("CreateEmptyRecycleTask " + value + "不存在");
// if (!Common.AddLinePlace(value))
// Common.log.Error("CreateEmptyRecycleTask 节点【" + value + "】不存在");
// else
// {
// Common.LogInfo("任务:" + value + " 出空料架 【" + lineName + "】");
// }
// //System.IO.File.WriteAllLines(Common.CONFIG_PATH + "LinePlace.txt", Common.linePlace);
//}
//else
//{
// AGVControl.Common.LogInfo("WebService Response false");
//}
}
private void button1_Click(object sender, EventArgs e)
{
HostOpen();
}
private void button2_Click(object sender, EventArgs e)
{
HostClose();
}
private void button3_Click(object sender, EventArgs e)
{
textBox3.Text=AGVManager.CreateEmptyTask(textBox1.Text,textBox2.Text);
}
private void button4_Click(object sender, EventArgs e)
{
AGVManager.GetWebservice(textBox1.Text, textBox2.Text);
}
private void button5_Click(object sender, EventArgs e)
{
bool qq = AGVManager.GetRackBy(textBox1.Text, out string kk);
textBox2.Text = qq.ToString() +" "+kk;
}
private void button6_Click(object sender, EventArgs e)
{
AGVManager.UpdateStatus("D17", "D1");
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file \ No newline at end of file
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Collections;
using System.Net;
using System.Net.Security;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Reflection;
using System.Net.NetworkInformation;
using BLL;
namespace BLL
{
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Collections;
using System.Net;
using System.Net.Security;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Reflection;
using log4net;
using Newtonsoft.Json;
using System.Windows.Forms;
namespace BLL
{
public class HttpUtil
{
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static string Post(string url, string paramData)
{
return Post(url, paramData, Encoding.UTF8);
}
public static T ObjPost<T>(string url, object o) where T : class
{
try
{
string json = JsonUtil.SerializeObject(o);
string result = Post(url, json);
if (!string.IsNullOrEmpty(result))
{
return JsonUtil.DeserializeJsonToObject<T>(result);
}
}
catch (Exception ex)
{
LOGGER.Error("Http post 出错" + ex);
}
return default(T);
}
public static List<T> ListPost<T>(string url, object o) where T : class
{
try
{
string json = JsonUtil.SerializeObject(o);
string result = Post(url, json);
if (!string.IsNullOrEmpty(result))
{
return JsonUtil.DeserializeJsonToList<T>(result);
}
}
catch (Exception ex)
{
LOGGER.Error("Http post 出错" + ex);
}
return new List<T>();
}
public static string Post(string url, string paramData, Encoding encoding)
{
string result = "";
if (url.ToLower().IndexOf("https", System.StringComparison.Ordinal) > -1)
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback((sender, certificate, chain, errors) => { return true; });
}
try
{
var wc = new TimeoutWebClient(5000);
if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
//wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
//如果需要将body中的参数以key/value格式发送到服务器,使用下面的Header
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
wc.Encoding = encoding;
//paramData = Uri.EscapeDataString(paramData);
result = wc.UploadString(url, "POST", paramData);
//LogUtil.info(result);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
LOGGER.Error("POST【" + paramData + "】 ERROR:", e);
}
//LOGGER.Info("post receive <<" + result );
return result;
}
public static string Get(string url)
{
return Get(url, Encoding.UTF8);
}
public static string Get(string url, Encoding encoding)
{
try
{
LOGGER.Info("HTTP GET FROM: " + url);
var wc = new WebClient { Encoding = encoding };
var readStream = wc.OpenRead(url);
using (var sr = new StreamReader(readStream, encoding))
{
var result = sr.ReadToEnd();
LOGGER.Info("get receive << " + result);
return result;
}
}
catch (Exception e)
{
LOGGER.Error("HTTP GET ERROR:", e);
}
return "";
}
}
/// <summary>
/// Json帮助类
/// </summary>
public class JsonUtil
{
/// <summary>
/// 将对象序列化为JSON格式
/// </summary>
/// <param name="o">对象</param>
/// <returns>json字符串</returns>
public static string SerializeObject(object o)
{
string json = JsonConvert.SerializeObject(o);
return json;
}
/// <summary>
/// 解析JSON字符串生成对象实体
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json字符串(eg.{"ID":"112","Name":"石子儿"})</param>
/// <returns>对象实体</returns>
public static T DeserializeJsonToObject<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(T));
T t = o as T;
return t;
}
/// <summary>
/// 解析JSON数组生成对象实体集合
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json数组字符串(eg.[{"ID":"112","Name":"石子儿"}])</param>
/// <returns>对象实体集合</returns>
public static List<T> DeserializeJsonToList<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
List<T> list = o as List<T>;
return list;
}
/// <summary>
/// 反序列化JSON到给定的匿名对象.
/// </summary>
/// <typeparam name="T">匿名对象类型</typeparam>
/// <param name="json">json字符串</param>
/// <param name="anonymousTypeObject">匿名对象</param>
/// <returns>匿名对象</returns>
public static T DeserializeAnonymousType<T>(string json, T anonymousTypeObject)
{
T t = JsonConvert.DeserializeAnonymousType(json, anonymousTypeObject);
return t;
}
}
public class TimeoutWebClient : WebClient
{
private int _timeout;
/// <summary>
/// 超时时间(毫秒)
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public TimeoutWebClient()
{
this._timeout = 60000;
}
public TimeoutWebClient(int timeout)
{
this._timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
var result = base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}
}
}
}
\ No newline at end of file \ No newline at end of file
此文件的差异被折叠, 点击展开。
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!