Commit b4ab9229 顾剑亮

上传

0 个父辈
正在显示 145 个修改的文件 包含 3344 行增加0 行删除
此文件类型无法预览
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
\ No newline at end of file
此文件类型无法预览

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30611.23
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AGVControl_Elevator", "AGVControl_Elevator\AGVControl_Elevator.csproj", "{749094A1-C8BB-44FC-9DEC-B6DE9B88EB8D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BLL", "BLL\BLL.csproj", "{87310AAD-CF4B-4F34-8F5E-A69D83233621}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{A61B66DD-2B04-41A5-8366-69477C0534E4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{749094A1-C8BB-44FC-9DEC-B6DE9B88EB8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{749094A1-C8BB-44FC-9DEC-B6DE9B88EB8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{749094A1-C8BB-44FC-9DEC-B6DE9B88EB8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{749094A1-C8BB-44FC-9DEC-B6DE9B88EB8D}.Release|Any CPU.Build.0 = Release|Any CPU
{87310AAD-CF4B-4F34-8F5E-A69D83233621}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87310AAD-CF4B-4F34-8F5E-A69D83233621}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87310AAD-CF4B-4F34-8F5E-A69D83233621}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87310AAD-CF4B-4F34-8F5E-A69D83233621}.Release|Any CPU.Build.0 = Release|Any CPU
{A61B66DD-2B04-41A5-8366-69477C0534E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A61B66DD-2B04-41A5-8366-69477C0534E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A61B66DD-2B04-41A5-8366-69477C0534E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A61B66DD-2B04-41A5-8366-69477C0534E4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5AB8FC50-C861-4ECD-B5CF-632BB0704358}
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>{749094A1-C8BB-44FC-9DEC-B6DE9B88EB8D}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>AGVControl_Elevator</RootNamespace>
<AssemblyName>AGVControl_Elevator</AssemblyName>
<TargetFrameworkVersion>v4.6</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>elevator.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<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="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmMain.Designer.cs">
<DependentUpon>FrmMain.cs</DependentUpon>
</Compile>
<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>
</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>
<ItemGroup>
<ProjectReference Include="..\BLL\BLL.csproj">
<Project>{87310aad-cf4b-4f34-8f5e-a69d83233621}</Project>
<Name>BLL</Name>
</ProjectReference>
<ProjectReference Include="..\Model\Model.csproj">
<Project>{a61b66dd-2b04-41a5-8366-69477c0534e4}</Project>
<Name>Model</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="elevator.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<appSettings>
<add key="FLEET_IP" value="10.85.199.3"/>
<add key="FleetSend" value="true"/>
<add key="BatteryMax" value="100"/>
<add key="BatteryMin" value="20"/>
<add key="BatteryIdle" value="80"/>
<add key="ElevatorIOIP" value="10.85.199.148"/>
<add key="FirstFloorCount" value="2"/>
<add key="AutoCharge" value="true"/>
</appSettings>
</configuration>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using Model;
namespace AGVControl_Elevator
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ThreadException += Application_ThreadException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (BLL.RunMode.IsRun()) return;
Common.log = new Log("AGVControl");
Common.log.Info("=====程序开始=====");
ReadConfig();
Application.Run(new FrmMain());
Common.log.Info("=====程序结束=====\r\n");
}
private static void ReadConfig()
{
Common.appConfig = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
Common.FleetSend = Convert.ToBoolean(Common.appConfig.AppSettings.Settings["FleetSend"].Value);
Common.BatteryMax = Convert.ToInt32(Common.appConfig.AppSettings.Settings["BatteryMax"].Value);
Common.BatteryMin = Convert.ToInt32(Common.appConfig.AppSettings.Settings["BatteryMin"].Value);
Common.BatteryIdle = Convert.ToInt32(Common.appConfig.AppSettings.Settings["BatteryIdle"].Value);
Common.ElevatorIOIP = Common.appConfig.AppSettings.Settings["ElevatorIOIP"].Value;
Common.FirstFloorCount = Convert.ToInt32(Common.appConfig.AppSettings.Settings["FirstFloorCount"].Value);
Common.FirstFloorCurr = Convert.ToInt32(System.IO.File.ReadAllText(Common.PATH_FIRST_FLOOR_CURR, System.Text.Encoding.UTF8));
Common.AutoCharge = Convert.ToBoolean(Common.appConfig.AppSettings.Settings["AutoCharge"].Value);
Common.mir = new MiR_API { FleetIP = Common.appConfig.AppSettings.Settings["FLEET_IP"].Value };
ReadAgvInfo();
ReadAgvMission();
ReadLine();
ReadElevator();
}
private static void ReadAgvInfo()
{
Common.agvInfos = new List<AgvInfo>();
string[] lines = System.IO.File.ReadAllLines(Common.PATH_AGV_NAME, System.Text.Encoding.UTF8);
for (int i = 0; i < lines.Length; i++)
{
string[] str = lines[i].Split(',');
if (str.Length != 4) continue;
string isUse = "false";
if (Common.appConfig.AppSettings.Settings[str[1]] == null)
{
Common.appConfig.AppSettings.Settings.Add(str[1], "false");
Common.appConfig.Save();
System.Configuration.ConfigurationManager.RefreshSection("appSettings");
}
else
{
isUse = Common.appConfig.AppSettings.Settings[str[1]].Value;
}
AgvInfo info = new AgvInfo(str[0], str[1], str[2], str[3]) { IsAuto = Convert.ToBoolean(isUse) };
Common.agvInfos.Add(info);
}
Common.log.Info("读取配置文件 " + Common.PATH_AGV_NAME);
}
private static void ReadAgvMission()
{
Common.agvMissions = new Dictionary<string, string>();
string[] lines = System.IO.File.ReadAllLines(Common.PATH_AGV_MISSION, System.Text.Encoding.UTF8);
for (int i = 0; i < lines.Length; i++)
{
string[] str = lines[i].Split(',');
if (str.Length != 2) continue;
Common.agvMissions.Add(str[0], str[1]);
}
Common.mir.MissionList = Common.agvMissions;
Common.log.Info("读取配置文件 " + Common.PATH_AGV_MISSION);
}
private static void ReadLine()
{
Common.lineInfos = new List<LineIOInfo>();
string[] lines = System.IO.File.ReadAllLines(Common.PATH_LINE, System.Text.Encoding.UTF8);
for (int i = 0; i < lines.Length; i++)
{
string[] str = lines[i].Split(',');
if (str.Length != 4) continue;
LineIOInfo info = new LineIOInfo(str[0], str[1], str[2], str[3]);
Common.lineInfos.Add(info);
}
Common.log.Info("读取配置文件 " + Common.PATH_LINE);
}
private static void ReadElevator()
{
Common.elevatorInfos = new List<IOInfo>();
string[] lines = System.IO.File.ReadAllLines(Common.PATH_ELEVATOR, System.Text.Encoding.UTF8);
for (int i = 0; i < lines.Length; i++)
{
string[] str = lines[i].Split(',');
if (str.Length != 4) continue;
IOInfo info = new IOInfo(str[0], str[1], str[2], str[3]);
Common.elevatorInfos.Add(info);
}
Common.log.Info("读取配置文件 " + Common.PATH_ELEVATOR);
}
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_Elevator")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AGVControl_Elevator")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("749094a1-c8bb-44fc-9dec-b6de9b88eb8d")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [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 AGVControl_Elevator.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("AGVControl_Elevator.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
//------------------------------------------------------------------------------
// <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 AGVControl_Elevator.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>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<appSettings>
<add key="FLEET_IP" value="10.85.199.3" />
<add key="FleetSend" value="true" />
<add key="BatteryMax" value="100" />
<add key="BatteryMin" value="20" />
<add key="BatteryIdle" value="80" />
<add key="ElevatorIOIP" value="10.85.199.148" />
<add key="FirstFloorCount" value="2" />
<add key="AutoCharge" value="true" />
<add key="12号车" value="false" />
</appSettings>
</configuration>
\ No newline at end of file
此文件类型无法预览
此文件类型无法预览
AutoCharge,ede902d2-1e69-11eb-b091-94c691a7387d
MoveStandby,1ca1ba19-1e6a-11eb-b091-94c691a7387d
MoveElevatorSide,3383a4dc-1e6a-11eb-b091-94c691a7387d
EnterElevatorFull,4b3ffeba-1e6a-11eb-b091-94c691a7387d
EnterElevatorEmpty,5fcad6a1-1ea9-11eb-b091-94c691a7387d
CarryFullD1,43cc7897-200c-11eb-b091-94c691a7387d
CarryFullD2,5fa6b99e-200c-11eb-b091-94c691a7387d
CarryFullD3,73ddebc6-200c-11eb-b091-94c691a7387d
CarryFullD4,8949860d-200c-11eb-b091-94c691a7387d
CarryFullD5,9e21bda5-200c-11eb-b091-94c691a7387d
CarryFullD6,b4675165-200c-11eb-b091-94c691a7387d
CarryFullT1,454ed53a-1e6c-11eb-b091-94c691a7387d
CarryFullT2,2a9486be-2008-11eb-b091-94c691a7387d
CarryFullT3,9bbc5654-200b-11eb-b091-94c691a7387d
CarryFullT4,b3a06c62-200b-11eb-b091-94c691a7387d
CarryFullT5,c998b57f-200b-11eb-b091-94c691a7387d
CarryFullT6,df62810a-200b-11eb-b091-94c691a7387d
CarryFullT7,f539cfdc-200b-11eb-b091-94c691a7387d
CarryFullT8,0a9d5102-200c-11eb-b091-94c691a7387d
CarryFullT9,20d5e2f4-200c-11eb-b091-94c691a7387d
CarryEmptyD1,c976e8f1-200d-11eb-b091-94c691a7387d
CarryEmptyD2,0dcfaf0e-200e-11eb-b091-94c691a7387d
CarryEmptyD3,225250d5-200e-11eb-b091-94c691a7387d
CarryEmptyD4,369be7d0-200e-11eb-b091-94c691a7387d
CarryEmptyD5,4c868b33-200e-11eb-b091-94c691a7387d
CarryEmptyD6,5e7e41f6-200e-11eb-b091-94c691a7387d
CarryEmptyT1,77fa9e77-200e-11eb-b091-94c691a7387d
CarryEmptyT2,8ed8ce62-200e-11eb-b091-94c691a7387d
CarryEmptyT3,a26eba18-200e-11eb-b091-94c691a7387d
CarryEmptyT4,b8907818-200e-11eb-b091-94c691a7387d
CarryEmptyT5,cb2a3634-200e-11eb-b091-94c691a7387d
CarryEmptyT6,e0fb038d-200e-11eb-b091-94c691a7387d
CarryEmptyT7,f2619898-200e-11eb-b091-94c691a7387d
CarryEmptyT8,05a18e78-200f-11eb-b091-94c691a7387d
CarryEmptyT9,1d13831b-200f-11eb-b091-94c691a7387d
LeaveShelf,887f0e4b-20d1-11eb-b091-94c691a7387d
CarryElevatorSide,c7242eee-20d2-11eb-b091-94c691a7387d
PickShelf,9807e65c-1e9b-11eb-998e-94c691a7334a
PlaceShelf,dbfd5a43-1e9b-11eb-998e-94c691a7334a
\ No newline at end of file
13,12号车,10.85.199.114,Basic ZGlzdHJpYnV0b3I6NjJmMmYwZjFlZmYxMGQzMTUyYzk1ZjZmMDU5NjU3NmU0ODJiYjhlNDQ4MDY0MzNmNGNmOTI5NzkyODM0YjAxNA==
\ No newline at end of file
请求应答(DI1),DI,0,DI1
到达任务楼层(DI2),DI,1,DI2
电梯门已开(DI3),DI,2,DI3
电梯送空架(DI4),DI,3,DI4
电梯故障(DI5),DI,4,DI5
请求使用电梯(DO1),DO,0,DO1
小车离开(DO2),DO,1,DO2
呼叫电梯(DO3),DO,2,DO3
送满料信号(DO4),DO,3,DO4
\ No newline at end of file
D1线,10.85.199.97,0,D1
D2线,10.85.199.98,0,D2
D3线,10.85.199.99,0,D3
D4线,10.85.199.100,0,D4
D5线,10.85.199.101,0,D5
D6线,10.85.199.102,0,D6
T1线,10.85.199.103,0,T1
T2线,10.85.199.104,0,T2
T3线,10.85.199.105,0,T3
T4线,10.85.199.106,0,T4
T5线,10.85.199.107,0,T5
T6线,10.85.199.108,0,T6
T7线,10.85.199.109,0,T7
T8线,10.85.199.110,0,T8
T9线,10.85.199.111,0,T9
\ No newline at end of file
产线名,呼叫,架子,时间
D1,False,True,2020-11-02 17:25:32
D2,False,True,2020-11-02 17:25:32
D3,False,True,2020-11-02 17:25:32
D4,False,True,2020-11-02 17:25:32
D5,False,True,2020-11-02 17:25:32
D6,False,True,2020-11-02 17:25:32
T1,False,True,2020-11-02 17:25:32
T2,False,True,2020-11-02 17:25:32
T3,False,True,2020-11-02 17:25:32
T4,False,True,2020-11-02 17:25:32
T5,False,True,2020-11-02 17:25:32
T6,False,True,2020-11-02 17:25:32
T7,False,True,2020-11-02 17:25:32
T8,False,True,2020-11-02 17:25:32
T9,False,True,2020-11-02 17:25:32
[2020-11-10 10:15:04,691][1][AGVControl:18]INFO =====程序开始=====
[2020-11-10 10:15:04,749][1][AGVControl:18]INFO 读取配置文件 D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Config\AgvName.csv
[2020-11-10 10:15:04,755][1][AGVControl:18]INFO 读取配置文件 D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Config\AgvMission.csv
[2020-11-10 10:15:04,762][1][AGVControl:18]INFO 读取配置文件 D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Config\Line.csv
[2020-11-10 10:15:04,768][1][AGVControl:18]INFO 读取配置文件 D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Config\Elevator.csv
[2020-11-10 10:15:04,887][1][AGVControl:18]INFO 加载缓存文件 D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Config\LineWork.txt
[2020-11-10 10:15:07,371][12][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:09,863][6][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:11,873][11][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:13,873][9][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:15,873][11][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:17,873][9][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:19,875][10][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:21,864][6][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:23,874][8][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:25,869][6][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:28,360][12][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:30,376][13][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:32,865][6][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:34,861][8][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:37,369][14][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:39,363][13][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:41,361][14][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:43,367][13][AGVControl:28]WARN 12号车[10.85.199.114] 脱机
[2020-11-10 10:15:44,659][1][AGVControl:18]INFO =====程序结束=====
[2020-11-10 10:15:04,911][1][IO_Elevator:63]INFO ===== IO[10.85.199.148] Open =====
[2020-11-10 10:15:06,874][6][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:08,866][7][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:10,861][8][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:13,365][13][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:15,369][13][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:17,363][13][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:19,368][13][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:21,369][12][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:23,363][12][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:25,373][12][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:27,373][14][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:29,863][6][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:31,875][10][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:33,872][11][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:36,361][12][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:38,869][9][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:40,867][9][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:42,871][9][IO_Elevator:251]INFO Ping 10.85.199.148 请求没有响应
[2020-11-10 10:15:44,641][1][IO_Elevator:78]INFO ===== IO[10.85.199.148] Close =====
此文件的差异太大,无法显示。
[2020-11-10 10:15:07,370][12][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:09,863][6][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:11,873][11][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:13,873][9][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:15,873][11][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:17,873][9][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:19,875][10][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:21,864][6][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:23,874][8][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:25,869][6][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:28,360][12][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:30,375][13][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:32,865][6][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:34,861][8][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:37,369][14][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:39,363][13][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:41,361][14][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
[2020-11-10 10:15:43,367][13][MiR_API:619]INFO Ping 10.85.199.114 请求没有响应
此文件类型无法预览
此文件类型无法预览
此文件的差异太大,无法显示。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<log4net>
<logger name="AGVControl">
<level value="Debug"/>
<appender-ref ref="AGVControl"/>
</logger>
<logger name="MiR_API">
<level value="Debug"/>
<appender-ref ref="api"/>
</logger>
<logger name="IO_Line">
<level value="Debug"/>
<appender-ref ref="IO_Line"/>
</logger>
<logger name="IO_Elevator">
<level value="Debug"/>
<appender-ref ref="IO_Elevator"/>
</logger>
<appender name="AGVControl" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log\\AGVControl.log" />
<param name="Encoding" value="UTF-8"/>
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy-MM-dd" />
<param name="MaxSizeRollBackups" value="100" />
<param name="MaxFileSize" value="10240" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d][%t][%c:%L]%-5p %m%n" />
</layout>
</appender>
<appender name="api" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log\\MiR_API.log" />
<param name="Encoding" value="UTF-8"/>
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy-MM-dd" />
<param name="MaxSizeRollBackups" value="100" />
<param name="MaxFileSize" value="10240" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d][%t][%c:%L]%-5p %m%n" />
</layout>
</appender>
<appender name="IO_Line" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log\\IO_Line.log" />
<param name="Encoding" value="UTF-8"/>
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy-MM-dd" />
<param name="MaxSizeRollBackups" value="100" />
<param name="MaxFileSize" value="10240" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d][%t][%c:%L]%-5p %m%n" />
</layout>
</appender>
<appender name="IO_Elevator" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log\\IO_Elevator.log" />
<param name="Encoding" value="UTF-8"/>
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy-MM-dd" />
<param name="MaxSizeRollBackups" value="100" />
<param name="MaxFileSize" value="10240" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d][%t][%c:%L]%-5p %m%n" />
</layout>
</appender>
</log4net>
</configuration>
\ No newline at end of file
此文件的差异太大,无法显示。
此文件类型无法预览
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\obj\Debug\AGVControl_Elevator.csprojAssemblyReference.cache
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\obj\Debug\AGVControl_Elevator.Properties.Resources.resources
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\obj\Debug\AGVControl_Elevator.csproj.GenerateResource.cache
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\obj\Debug\AGVControl_Elevator.csproj.CoreCompileInputs.cache
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\log4net.config
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\AGVControl_Elevator.exe.config
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\AGVControl_Elevator.exe
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\AGVControl_Elevator.pdb
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\BLL.dll
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Model.dll
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\log4net.dll
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\RestSharp.dll
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\BLL.pdb
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Model.pdb
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\log4net.xml
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\RestSharp.xml
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\obj\Debug\AGVControl_Elevator.csproj.CopyComplete
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\obj\Debug\AGVControl_Elevator.exe
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\obj\Debug\AGVControl_Elevator.pdb
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Advantech_IO.dll
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\bin\Debug\Advantech_IO.pdb
D:\Neotel\AGVControl_Elevator\AGVControl_Elevator\obj\Debug\AGVControl_Elevator.FrmMain.resources
<?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>{87310AAD-CF4B-4F34-8F5E-A69D83233621}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BLL</RootNamespace>
<AssemblyName>BLL</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Advantech_IO">
<HintPath>..\..\..\DLL\Advantech_IO\Advantech_IO.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="RunMode.cs" />
<Compile Include="Work\LineWork.cs" />
<Compile Include="Work\ElevatorWork.cs" />
<Compile Include="Job\ChargeJob.cs" />
<Compile Include="Control.cs" />
<Compile Include="Job\FullShelfJob.cs" />
<Compile Include="Work\ManageWork.cs" />
<Compile Include="Job\MissionJob.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Job\RecycleJob.cs" />
<Compile Include="Job\StandbyJob.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj">
<Project>{a61b66dd-2b04-41a5-8366-69477c0534e4}</Project>
<Name>Model</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Threading;
using Model;
namespace BLL
{
public class Control
{
private Timer timerCall;
//private PointF[] position;
//private DateTime[] timeout;
public delegate void AgvChangedEvent(int agvIndex);
public event AgvChangedEvent AgvChanged;
public event AgvChangedEvent AgvOnline;
public Control()
{
ThreadPool.SetMaxThreads(5, 5); //线程池最大数量
}
public void Start()
{
//position = new PointF[Common.agvInfos.Count];
//for (int i = 0; i < position.Length; i++)
// position[i] = new PointF();
//timeout = new DateTime[Common.agvInfos.Count];
//for (int i = 0; i < timeout.Length; i++)
// timeout[i] = DateTime.Now;
timerCall = new Timer(CallProcess, null, 0, 2000);
}
public void Stop()
{
if (timerCall != null)
timerCall.Dispose();
}
private void CallProcess(object obj)
{
for (int i = 0; i < Common.agvInfos.Count; i++)
{
AgvInfo info = Common.agvInfos[i];
if (info.IsCall) continue;
try
{
info.IsCall = true;
CheckAgvOnline(info);
if (!info.IsOnline) continue; //脱机
GetAgvState(info);
if (!info.IsAuto) continue; //手动
if (info.StateID == (int)StateID.Pause)
Common.mir.State_Ready(info.IP, info.Authorization);
if (info.CurrentJob == null)
{
//软件刚打开时,防止有任务在运行
Common.mir.Del_Mission(info.IP, info.Authorization);
info.CurrentJob = new StandbyJob();
}
else
{
info.CurrentJob = info.CurrentJob.Execute(info);
}
}
catch (Exception ex)
{
Common.log.Error("CallProcess " + info.Name, ex);
}
finally
{
info.IsCall = false;
}
}
UpdateBoard();
}
private void GetAgvState(AgvInfo info)
{
if (!info.IsOnline) return;
bool rtn = Common.mir.Get_State(info.IP, info.Authorization, out int stateID, out string stateText, out int battery, out string missionText, out PointF position);
//Common.log.Debug(string.Format("{0}[{1}] AgvState[{2}] stateID={3}, stateText={4}, battery={5}, missionText={6}, position={7}", info.Name, info.IP, rtn, stateID, stateText, battery, missionText, position.ToString()));
if (rtn)
{
info.StateID = stateID;
info.StateText = stateText;
info.Battery = battery;
info.MissionExplain = missionText;
info.Position = position;
int idx = Common.agvInfos.FindIndex(s => s.IP == info.IP);
if (idx > -1) AgvChanged?.Invoke(idx);
}
}
private void CheckAgvOnline(AgvInfo info)
{
bool rtn = Common.mir.CheckIP(info.IP);
if (rtn)
{
if (!info.IsOnline)
{
info.IsOnline = true;
int idx = Common.agvInfos.FindIndex(s => s.IP == info.IP);
if (idx > -1) AgvOnline?.Invoke(idx);
Common.log.Info(string.Format("{0}[{1}] 上线", info.Name, info.IP));
}
}
else
{
if (info.IsOnline)
{
info.IsOnline = false;
int idx = Common.agvInfos.FindIndex(s => s.IP == info.IP);
if (idx > -1) AgvOnline?.Invoke(idx);
}
Common.log.Warn(string.Format("{0}[{1}] 脱机", info.Name, info.IP));
}
}
private void UpdateBoard()
{
//for (int i = 0; i < Common.agvInfos.Count; i++)
//{
// if (Common.agvInfos[i].CurrentJob == null)
// {
// timeout[i] = DateTime.Now;
// continue;
// }
// string name = "";
// if (Common.agvInfos[i].Name.IndexOf("11") >= 0)
// name = "11号车";
// else if (Common.agvInfos[i].Name.IndexOf("13") >= 0)
// name = "13号车";
// if (Math.Abs(Common.agvInfos[i].Position.X - position[i].X) < 2 && Math.Abs(Common.agvInfos[i].Position.Y - position[i].Y) < 2)
// {
// TimeSpan span = DateTime.Now - timeout[i];
// if (span.TotalMinutes >= Common.BoardTimeout)
// {
// if (Common.agvInfos[i].CurrentJob is ChargeJob)
// {
// DisplayBoard.Add(name, "lineAgv." + name + ".Place", "AutoCharge", 1);
// }
// else if (Common.agvInfos[i].CurrentJob is StandbyJob)
// {
// DisplayBoard.Add(name, "lineAgv." + name + ".Place", "Standby", 1);
// }
// else
// {
// string value = string.Format("在{0}停留超时{1:F}分钟", Common.agvInfos[i].Place, span.TotalMinutes);
// DisplayBoard.Add(name, "lineAgv." + name + ".StandTimeOut", value, 0);
// }
// }
// else
// {
// DisplayBoard.Add(name, "lineAgv." + name + ".Msg", Common.agvInfos[i].CurrentJob.Msg, 1);
// }
// }
// else
// {
// DisplayBoard.Add(name, "lineAgv." + name + ".Msg", Common.agvInfos[i].CurrentJob.Msg, 1);
// timeout[i] = DateTime.Now;
// position[i] = new PointF(Common.agvInfos[i].Position.X, Common.agvInfos[i].Position.Y);
// }
//}
//DisplayBoard.UpdateAlarmMsg();
}
private enum StateID : int
{
None,
Starting,
ShuttingDown,
Ready,
Pause,
Executing,
Aborted,
Completed,
Docked,
Docking,
EmergencyStop,
ManualControl,
Error
}
}
}
\ No newline at end of file
using System;
using Model;
namespace BLL
{
public class ChargeJob : IJob
{
private AgvInfo _info;
private MissionJob move;
private string mission;
private JobStep<ChargeStep> chargeStep;
private const int CHARGE_PLC = 20;
public ChargeJob()
{
IsEnd = false;
chargeStep = new JobStep<ChargeStep>(ChargeStep.None);
Common.log.Debug("加载ChargeJob");
}
public bool IsEnd { get; private set; }
public IJob Execute(AgvInfo info)
{
_info = info;
if (chargeStep.Equals(ChargeStep.None))
{
_info.Place = "去充电位";
SendCharge();
}
else if (chargeStep.Equals(ChargeStep.MoveStation))
{
move.Execute(_info);
MoveStation();
}
else if (chargeStep.Equals(ChargeStep.Charging))
{
move.Execute(_info);
if (_info.Battery == Common.BatteryMax)
{
chargeStep.NextStep(ChargeStep.End);
chargeStep.Msg = string.Format("{0} 电量达到{1}%,充电工作结束,回待机位", _info.Name, Common.BatteryMax);
}
else if (_info.Battery > Common.BatteryMin)
{
IJob job = ManageWork.GetJob();
if (job != null)
{
_info.Place = "";
Common.mir.Del_Mission(_info.IP, _info.Authorization);
Common.log.Info(_info.Name + " 获取到任务,结束ChargeJob");
return job;
}
}
}
else if (chargeStep.Equals(ChargeStep.End))
{
IsEnd = true;
_info.Place = "";
Common.mir.Del_Mission(_info.IP, _info.Authorization);
return new StandbyJob();
}
return this;
}
private void SendCharge()
{
mission = Common.MISSION_CHARGE;
move = new MissionJob(mission);
move.Execute(_info);
chargeStep.NextStep(ChargeStep.MoveStation);
chargeStep.Msg = string.Format("{0} 去充电位,[{1}]", _info.Name, mission);
}
private void MoveStation()
{
bool rtn = Common.mir.Get_Register(_info.IP, _info.Authorization, CHARGE_PLC, out int value);
if (rtn)
{
if (value == 1)
{
_info.Place = "充电中";
chargeStep.NextStep(ChargeStep.Charging);
chargeStep.Msg = _info.Name + " 到达充电位,准备充电";
}
}
}
private enum ChargeStep
{
None,
End,
MoveStation,
Charging
}
}
}
using System;
using Model;
namespace BLL
{
public class FullShelfJob : IJob
{
private AgvInfo _info;
private MissionJob move;
private string mission;
private DateTime getTime;
private string key;
//private bool recycleFirst;
private JobStep<FullShelfStep> fullShelfStep;
public FullShelfJob()
{
IsEnd = false;
fullShelfStep = new JobStep<FullShelfStep>(FullShelfStep.None);
Common.log.Debug("加载FullShelfJob");
}
public bool IsEnd { get; private set; }
public IJob Execute(AgvInfo info)
{
_info = info;
if (fullShelfStep.Equals(FullShelfStep.None))
{
if (ManageWork.PauseFull)
EnterElevatorSideShelf();
else
FindLine();
}
else if (fullShelfStep.Equals(FullShelfStep.MoveLine))
{
MoveLine();
}
else if (fullShelfStep.Equals(FullShelfStep.MoveElevator))
{
MoveElevator();
}
else if (fullShelfStep.Equals(FullShelfStep.SendUseAsk))
{
ManageWork.SendElevatorUseAsk();
fullShelfStep.NextStep(FullShelfStep.UseAnswer);
fullShelfStep.Msg = string.Format("{0} 发送电梯使用请求", _info.Name);
}
else if (fullShelfStep.Equals(FullShelfStep.UseAnswer))
{
if (ManageWork.ElevatorUseAnswer())
{
ManageWork.PauseFull = false;
fullShelfStep.NextStep(FullShelfStep.CallElevator);
fullShelfStep.Msg = string.Format("{0} 电梯可以使用", _info.Name);
}
//else if (ManageWork.FindElevatorWork())
//{
// //送满架子时,同时要回收空架子
// ManageWork.PauseFull = true;
// mission = Common.MISSION_LEAVE_SHELF;
// move = new MissionJob(mission);
// move.Execute(_info);
// fullShelfStep.NextStep(FullShelfStep.LeaveShelf);
// fullShelfStep.Msg = string.Format("{0} 暂停送满货架,优先拉空货架", _info.Name);
//}
else
{
Common.log.Debug(string.Format("{0} 电梯还未应答使用请求", _info.Name));
}
}
else if (fullShelfStep.Equals(FullShelfStep.CallElevator))
{
ManageWork.ElevatorCall(true);
getTime = DateTime.Now;
fullShelfStep.NextStep(FullShelfStep.CancelCallElevator);
fullShelfStep.Msg = string.Format("{0} 发送电梯呼叫", _info.Name);
}
else if (fullShelfStep.Equals(FullShelfStep.CancelCallElevator))
{
TimeSpan ts = DateTime.Now - getTime;
if (ts.Seconds >= 3)
{
//呼叫信号不能长时间保持,3s-5s即可。
ManageWork.ElevatorCall(false);
fullShelfStep.Msg = string.Format("{0} 满3s以上取消呼叫保持", _info.Name);
fullShelfStep.NextStep(FullShelfStep.OpenDoorAnswer);
}
}
else if (fullShelfStep.Equals(FullShelfStep.OpenDoorAnswer))
{
if (ManageWork.ElevatorReady())
{
fullShelfStep.Msg = string.Format("{0} 电梯已开门", _info.Name);
fullShelfStep.NextStep(FullShelfStep.EnterInto);
}
else
{
Common.log.Debug(string.Format("{0} 电梯还未开门", _info.Name));
}
}
else if (fullShelfStep.Equals(FullShelfStep.EnterInto))
{
_info.Place = "送满架进电梯";
EnterInto();
}
else if (fullShelfStep.Equals(FullShelfStep.Leave))
{
move.Execute(_info);
if (move.IsEnd)
{
_info.Place = "电梯门外";
ManageWork.ElevatorFullShelf();
getTime = DateTime.Now;
fullShelfStep.Msg = string.Format("{0} 发送满料信号", _info.Name);
fullShelfStep.NextStep(FullShelfStep.EndTask);
}
}
else if (fullShelfStep.Equals(FullShelfStep.EndTask))
{
TimeSpan ts = DateTime.Now - getTime;
if (ts.Seconds >= 3)
{
//离开信号保持几秒后,取消所有信号
ManageWork.ElevatorEnd();
Common.FirstFloorCurr++;
fullShelfStep.Msg = string.Format("{0} 送满料任务结束,当前一楼货架数量{1}个", _info.Name, Common.FirstFloorCurr);
fullShelfStep.NextStep(FullShelfStep.End);
}
}
else if (fullShelfStep.Equals(FullShelfStep.LeaveShelf))
{
move.Execute(_info);
if (move.IsEnd)
{
fullShelfStep.NextStep(FullShelfStep.End);
fullShelfStep.Msg = string.Format("{0} 退出货架,[{1}]", _info.Name, mission);
}
}
else if (fullShelfStep.Equals(FullShelfStep.End))
{
IsEnd = true;
if (ManageWork.PauseFull)
return new RecycleJob();
else
return new StandbyJob();
}
return this;
}
private void FindLine()
{
bool rtn = ManageWork.FindLineWork(out string key, out string name);
if (rtn)
{
_info.Place = name;
this.key = key;
mission = Common.MISSION_CARRY_FULL + key;
move = new MissionJob(mission);
move.Execute(_info);
fullShelfStep.NextStep(FullShelfStep.MoveLine);
fullShelfStep.Msg = string.Format("{0} 送满货架任务,去{1},[{2}]", _info.Name, name, mission);
}
else
{
fullShelfStep.NextStep(FullShelfStep.End);
fullShelfStep.Msg = string.Format("{0} 没有找到产线呼叫,或产线没有货架", _info.Name);
}
}
private void MoveLine()
{
move.Execute(_info);
if (move.IsEnd)
{
ManageWork.LineTakeAway(key);
_info.Place = "去电梯";
mission = Common.MISSION_MOVE_ELEVATOR;
move = new MissionJob(mission);
move.Execute(_info);
fullShelfStep.NextStep(FullShelfStep.MoveElevator);
fullShelfStep.Msg = string.Format("{0} 送满货架任务,去电梯,[{1}]", _info.Name, mission);
}
}
private void EnterElevatorSideShelf()
{
_info.Place = "进入电梯旁货架";
mission = Common.MISSION_CARRY_ELEVATOR;
move = new MissionJob(mission);
move.Execute(_info);
fullShelfStep.NextStep(FullShelfStep.MoveElevator);
fullShelfStep.Msg = string.Format("{0} 送满货架任务,去电梯,[{1}]", _info.Name, mission);
}
private void MoveElevator()
{
move.Execute(_info);
if (move.IsEnd)
{
ManageWork.PauseFull = false;
_info.Place = "电梯等待位";
fullShelfStep.NextStep(FullShelfStep.SendUseAsk);
fullShelfStep.Msg = string.Format("{0} 到达电梯等待位", _info.Name);
}
}
private void EnterInto()
{
mission = Common.MISSION_ENTER_ELEVATOR_FULL;
move = new MissionJob(mission);
move.Execute(_info);
fullShelfStep.Msg = string.Format("{0} 送满货架进电梯,[{1}]", _info.Name, mission);
fullShelfStep.NextStep(FullShelfStep.Leave);
}
private enum FullShelfStep
{
None,
End,
MoveLine,
MoveElevator,
SendUseAsk,
UseAnswer,
CallElevator,
CancelCallElevator,
OpenDoorAnswer,
EnterInto,
Leave,
LeaveShelf,
EndTask
}
}
}
/*
* 这是一个子job,只运行一个小车任务,需要其他job来调用
*
*/
using System;
using Model;
namespace BLL
{
public class MissionJob : IJob
{
private string _id;
private string _mission;
private AgvInfo _info;
private int _times; //发送次数
private DateTime _getTime; //用于调用API的间隔时间
private JobStep<MissionStep> missionStep;
public MissionJob(string mission)
{
_times = 0;
_mission = mission;
IsEnd = false;
missionStep = new JobStep<MissionStep>(MissionStep.Send);
Common.log.Debug(string.Format("加载MissionJob[{0}]", _mission));
}
public bool IsEnd { get; private set; }
public IJob Execute(AgvInfo info)
{
_info = info;
if (missionStep.Equals(MissionStep.Send))
Send();
else if (missionStep.Equals(MissionStep.Working))
Working();
else if (missionStep.Equals(MissionStep.Error))
Error();
else if (missionStep.Equals(MissionStep.End))
IsEnd = true;
return this;
}
private void Send()
{
bool rtn;
string log;
_info.MissionName = _mission;
if (Common.FleetSend)
rtn = Common.mir.Add_Mission_Fleet(_info.FleetID, _info.Authorization, _mission, out _id);
else
rtn = Common.mir.Add_Mission(_info.IP, _info.Authorization, _mission, out _id);
if (rtn)
{
_times = 0;
log = string.Format("MissionJob To:{0},[{1}]发送成功", _info.Name, _mission);
Common.log.Info(log);
_getTime = DateTime.Now;
missionStep.NextStep(MissionStep.Working);
}
else
{
_times++;
log = string.Format("MissionJob To:{0},[{1}]发送失败{2}次", _info.Name, _mission, _times);
Common.log.Warn(log);
}
}
private void Working()
{
//TimeSpan span = DateTime.Now - _getTime;
//if (span.TotalMilliseconds >= 5000)
//{
bool rtn;
string state;
string log;
if (Common.FleetSend)
rtn = Common.mir.Get_MissionState_Fleet(_info.Authorization, _id, out state);
else
rtn = Common.mir.Get_MissionState(_info.IP, _info.Authorization, _id, out state);
if (rtn)
{
log = string.Format("MissionJob To:{0},[{1}]任务状态{2}", _info.Name, _mission, state);
if (state == MissionState.Done.ToString())
{
missionStep.NextStep(MissionStep.End);
Common.log.Info(log);
}
else if (state == MissionState.Aborted.ToString())
{
missionStep.NextStep(MissionStep.Error);
Common.log.Warn(log);
}
else if (state == MissionState.Executing.ToString())
{
_getTime = DateTime.Now;
Common.log.Debug(log);
}
else if (state == MissionState.Pending.ToString())
{
_getTime = DateTime.Now;
Common.log.Debug(log);
}
}
else
{
log = string.Format("MissionJob To:{0},[{1}]获取状态失败", _info.Name, _mission);
Common.log.Warn(log);
}
//}
}
private void Error()
{
Common.mir.Clear_Error(_info.IP, _info.Authorization);
Common.mir.Del_Mission(_info.IP, _info.Authorization);
Common.log.Info(string.Format("MissionJob To:{0},[{1}]重新发送", _info.Name, _mission));
missionStep.NextStep(MissionStep.Send);
}
private enum MissionStep
{
Send,
Working,
Error,
End
}
private enum MissionState
{
/// <summary>
/// 异常
/// </summary>
Aborted,
/// <summary>
/// 正在执行
/// </summary>
Executing,
/// <summary>
/// 未发送(fleet收到任务,还未分配给小车)
/// </summary>
Pending,
/// <summary>
/// 完成
/// </summary>
Done
}
}
}
using System;
using Model;
namespace BLL
{
public class RecycleJob : IJob
{
private AgvInfo _info;
private MissionJob move;
private string mission;
private DateTime getTime;
private string key;
//private bool fullNext;
private JobStep<RecycleStep> recycleStep;
public RecycleJob()
{
IsEnd = false;
recycleStep = new JobStep<RecycleStep>(RecycleStep.None);
Common.log.Debug("加载RecycleJob");
}
public bool IsEnd { get; private set; }
public IJob Execute(AgvInfo info)
{
_info = info;
if (recycleStep.Equals(RecycleStep.None))
{
_info.Place = "进入电梯";
MoveElevator();
}
else if (recycleStep.Equals(RecycleStep.EnterInto))
{
move.Execute(_info);
if (move.IsEnd)
{
ManageWork.ElevatorEmptyShelf();
getTime = DateTime.Now;
recycleStep.NextStep(RecycleStep.Leave);
recycleStep.Msg = string.Format("{0} 发送离开信号", _info.Name);
}
}
else if (recycleStep.Equals(RecycleStep.Leave))
{
TimeSpan ts = DateTime.Now - getTime;
if (ts.Seconds >= 3)
{
ManageWork.ElevatorEnd();
Common.FirstFloorCurr--;
recycleStep.Msg = string.Format("{0} 回收空货架任务,当前一楼货架数量{1}个", _info.Name, Common.FirstFloorCurr);
FindLine();
}
}
else if (recycleStep.Equals(RecycleStep.MoveLine))
{
move.Execute(_info);
if (move.IsEnd)
{
ManageWork.LineSendTo(key);
recycleStep.NextStep(RecycleStep.End);
if (ManageWork.PauseFull)
recycleStep.Msg = string.Format("{0} 回收空货架任务完成,继续满货架任务", _info.Name);
else
recycleStep.Msg = string.Format("{0} 回收空货架任务完成,回待机位", _info.Name);
}
}
else if (recycleStep.Equals(RecycleStep.End))
{
IsEnd = true;
if (ManageWork.PauseFull)
return new FullShelfJob();
else
return new StandbyJob();
}
return this;
}
private void MoveElevator()
{
mission = Common.MISSION_ENTER_ELEVATOR_EMPTY;
move = new MissionJob(mission);
move.Execute(_info);
recycleStep.NextStep(RecycleStep.EnterInto);
recycleStep.Msg = string.Format("{0} 回收空货架任务,进入电梯,[{1}]", _info.Name, mission);
}
private void FindLine()
{
bool rtn = ManageWork.FindLineWithoutShelf(out string key, out string name);
if (rtn)
{
_info.Place = name;
this.key = key;
mission = Common.MISSION_CARRY_EMPTY + key;
move = new MissionJob(mission);
move.Execute(_info);
recycleStep.Msg = string.Format("{0} 回收空货架任务,去{1},[{2}]", _info.Name, name, mission);
recycleStep.NextStep(RecycleStep.MoveLine);
}
else
{
recycleStep.Msg = string.Format("{0} 没有找到回收空货架任务", _info.Name);
recycleStep.NextStep(RecycleStep.End);
}
}
private enum RecycleStep
{
None,
End,
EnterInto,
Leave,
FindLine,
MoveLine
}
}
}
using System;
using Model;
namespace BLL
{
public class StandbyJob : IJob
{
private AgvInfo _info;
private MissionJob move;
private string mission;
private JobStep<StandbyStep> standbyStep;
public StandbyJob()
{
IsEnd = false;
standbyStep = new JobStep<StandbyStep>(StandbyStep.None);
Common.log.Debug("加载StandbyJob");
}
public bool IsEnd { get; private set; }
public IJob Execute(AgvInfo info)
{
_info = info;
if (standbyStep.Equals(StandbyStep.None))
{
_info.Place = "去待机位";
SendStandby();
}
else if (standbyStep.Equals(StandbyStep.MoveStandby))
{
move.Execute(_info);
if (move.IsEnd)
{
_info.Place = "待机位";
standbyStep.NextStep(StandbyStep.End);
standbyStep.Msg = _info.Name + " 到达待机位";
}
}
else if (standbyStep.Equals(StandbyStep.End))
{
IsEnd = true;
if (_info.Battery <= Common.BatteryMin)
{
if (Common.AutoCharge)
{
_info.Place = "";
standbyStep.Msg = string.Format("{0} 电量小于{1}%,执行充电任务", _info.Name, Common.BatteryMin);
return new ChargeJob();
}
}
else
{
IJob job = ManageWork.GetJob();
if (job == null)
{
if (_info.Battery <= Common.BatteryIdle)
{
if (Common.AutoCharge)
{
_info.Place = "";
standbyStep.Msg = string.Format("{0} 空闲并且电量小于{1}%,执行充电任务", _info.Name, Common.BatteryIdle);
return new ChargeJob();
}
}
}
else
{
_info.Place = "";
return job;
}
}
}
return this;
}
private void SendStandby()
{
mission = Common.MISSION_STANDBY;
move = new MissionJob(mission);
move.Execute(_info);
standbyStep.NextStep(StandbyStep.MoveStandby);
standbyStep.Msg = string.Format("{0} 去待机位,[{1}]", _info.Name, mission);
}
private enum StandbyStep
{
None,
End,
MoveStandby
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("BLL")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BLL")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("87310aad-cf4b-4f34-8f5e-a69d83233621")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Drawing;
using System.Diagnostics;
namespace BLL
{
public static class RunMode
{
[DllImport("user32.dll", EntryPoint = "ShowWindow", CharSet = CharSet.Auto)]
private static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("user32.dll ", SetLastError = true)]
private static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab);
private const int SW_RESTORE = 9;
private static Form frm;
private static FormWindowState state;
private static bool exit = false;
private static ToolStripItem[] items;
private static NotifyIcon notify;
private static ContextMenuStrip notifyMenu;
private static void AddItem()
{
notifyMenu = new ContextMenuStrip();
items = new ToolStripItem[4];
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetEntryAssembly();
string text = assembly.GetName().Version.ToString();
text = frm.Text + (frm.Text.Contains(text) ? "" : " " + text);
items[0] = new ToolStripMenuItem(text) { Font = new Font("微软雅黑", 11f, FontStyle.Bold), Image = frm.Icon.ToBitmap() };
items[1] = new ToolStripSeparator();
items[2] = new ToolStripMenuItem("显示") { Font = new Font("微软雅黑", 11f) };
items[3] = new ToolStripMenuItem("退出") { Font = new Font("微软雅黑", 11f) };
notifyMenu.Items.AddRange(items);
items[2].Click += ItemShow_Click;
items[3].Click += ItemExit_Click;
notify = new NotifyIcon { Icon = frm.Icon, Visible = true, ContextMenuStrip = notifyMenu, Text = frm.Text };
notify.MouseDoubleClick += Notify_MouseDoubleClick;
}
private static void ItemShow_Click(object sender, EventArgs e)
{
frm.Show();
if (frm.WindowState == FormWindowState.Minimized)
frm.WindowState = state;
}
private static void ItemExit_Click(object sender, EventArgs e)
{
notify.Dispose();
exit = true;
frm.Close();
}
private static void Notify_MouseDoubleClick(object sender, MouseEventArgs e)
{
frm.Show();
if (frm.WindowState == FormWindowState.Minimized)
frm.WindowState = state;
}
public static void Init(Form frm)
{
RunMode.frm = frm;
state = frm.WindowState;
frm.StartPosition = FormStartPosition.CenterScreen;
AddItem();
}
public static void MenuLanguage(params string[] name)
{
if (items == null || name == null) return;
if (name.Length >= 1) items[2].Text = name[0];
if (name.Length >= 2) items[3].Text = name[1];
}
public static bool Closing(FormClosingEventArgs e)
{
if (!exit)
{
e.Cancel = true;
state = frm.WindowState;
frm.WindowState = FormWindowState.Minimized;
}
return exit;
}
public static bool IsRun()
{
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)
{
//显示已打开的程序
ShowWindow(process.MainWindowHandle, SW_RESTORE);
SwitchToThisWindow(process.MainWindowHandle, true);
return true;
}
}
return false;
}
public static bool IsAdmin()
{
System.Security.Principal.WindowsIdentity current = System.Security.Principal.WindowsIdentity.GetCurrent();
System.Security.Principal.WindowsPrincipal windowsPrincipal = new System.Security.Principal.WindowsPrincipal(current);
return windowsPrincipal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator);
}
public static void AdminRun()
{
string path = Process.GetCurrentProcess().MainModule.FileName;
ProcessStartInfo startInfo = new ProcessStartInfo
{
UseShellExecute = true,
WorkingDirectory = Environment.CurrentDirectory,
FileName = path,
Verb = "runas"
};
Process.Start(startInfo);
}
/// <summary>
/// 复制文件
/// </summary>
/// <param name="srcPath">原路径</param>
/// <param name="dstPath">目标路径</param>
/// <param name="overwrite">是否覆盖</param>
/// <returns></returns>
//public static bool CopyFile(string srcPath, string dstPath, bool overwrite)
//{
// bool rtn = false;
// try
// {
// if (!srcPath.EndsWith("\\")) srcPath += "\\";
// if (!dstPath.EndsWith("\\")) dstPath += "\\";
// if (System.IO.Directory.Exists(srcPath))
// {
// //目录是否存在
// if (!System.IO.Directory.Exists(dstPath))
// System.IO.Directory.CreateDirectory(dstPath);
// //复制文件
// string[] files = System.IO.Directory.GetFiles(srcPath);
// foreach (string file in files)
// {
// System.IO.FileInfo fInfo = new System.IO.FileInfo(file);
// fInfo.CopyTo(dstPath + fInfo.Name, overwrite);
// }
// rtn = true;
// //复制文件夹
// string[] dirs = System.IO.Directory.GetDirectories(srcPath);
// foreach (string dir in dirs)
// {
// System.IO.DirectoryInfo dInfo = new System.IO.DirectoryInfo(dir);
// rtn = CopyFile(dir, dstPath + dInfo.Name, overwrite);
// if (!rtn) break;
// }
// }
// }
// catch (Exception ex)
// {
// rtn = false;
// }
// return rtn;
//}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
using Model;
namespace BLL
{
public class ElevatorWork
{
private Advantech.IO_Module module;
public delegate void IOChanged(bool[] sta);
public event IOChanged DI_Changed;
public event IOChanged DO_Changed;
public delegate void Connected(bool con);
public event Connected Connect_Event;
public ElevatorWork()
{
module = new Advantech.IO_Module(0, 8, 8, 8, "IO_Elevator") { IP = Common.ElevatorIOIP };
module.Connect_Event += Module_Connect_Event;
module.DO_Changed_Event += Module_DO_Changed_Event;
module.DI_Changed_Event += Module_DI_Changed_Event;
}
public void Open()
{
module.Open();
}
public void Close()
{
module.Close();
}
public void WriteDO(int index)
{
int add = Common.elevatorInfos[index].Address;
Advantech.IO_State sta = module.ReadDO(add);
sta = module.ReverseStatus(sta);
module.WriteDO(add, sta);
}
public IJob GetJob()
{
bool sta = GetRecycle();
if (sta)
{
Common.log.Info("电梯送空架子呼叫");
return new RecycleJob();
}
else
{
Common.log.Debug("没有找到电梯送空架子呼叫");
return null;
}
}
public bool GetRecycle()
{
int idx1 = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_EMPTY_SHELF);
if (idx1 == -1) return false;
bool sta1 = Common.elevatorInfos[idx1].State;
int idx2 = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_OPEN_DOOR);
if (idx2 == -1) return false;
bool sta2 = Common.elevatorInfos[idx2].State;
return sta1 && sta2;
}
public void UseAsk()
{
int idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_USE_ASK);
if (idx == -1) return;
module.WriteDO(Common.elevatorInfos[idx].Address, Advantech.IO_State.On);
}
public bool UseAnswer()
{
int idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_USE_ANSWER);
if (idx == -1) return false;
return Common.elevatorInfos[idx].State;
}
public void CallElevator(bool sta)
{
int idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_CALL);
if (idx == -1) return;
module.WriteDO(Common.elevatorInfos[idx].Address, sta ? Advantech.IO_State.On : Advantech.IO_State.Off);
}
public bool ArriveFloor()
{
int idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_ARRIVE_FLOOR);
if (idx == -1) return false;
return Common.elevatorInfos[idx].State;
}
public bool OpenDoor()
{
int idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_OPEN_DOOR);
if (idx == -1) return false;
return Common.elevatorInfos[idx].State;
}
public void FullShelf()
{
//送满料
int idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_FULL_SHELF);
if (idx == -1) return;
module.WriteDO(Common.elevatorInfos[idx].Address, Advantech.IO_State.On);
//离开信号
idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_LEAVE);
if (idx == -1) return;
module.WriteDO(Common.elevatorInfos[idx].Address, Advantech.IO_State.On);
}
public void EmptyShelf()
{
//离开信号
int idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_LEAVE);
if (idx == -1) return;
module.WriteDO(Common.elevatorInfos[idx].Address, Advantech.IO_State.On);
}
public void EndTask()
{
int idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_FULL_SHELF);
if (idx == -1) return;
module.WriteDO(Common.elevatorInfos[idx].Address, Advantech.IO_State.Off);
idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_LEAVE);
if (idx == -1) return;
module.WriteDO(Common.elevatorInfos[idx].Address, Advantech.IO_State.Off);
idx = Common.elevatorInfos.FindIndex(s => s.Key == Common.ELEVATOR_USE_ASK);
if (idx == -1) return;
module.WriteDO(Common.elevatorInfos[idx].Address, Advantech.IO_State.Off);
}
private void Module_Connect_Event(Advantech.IO_Module box)
{
Connect_Event?.Invoke(box.IsConn);
}
private void Module_DO_Changed_Event(Advantech.IO_Module box, Advantech.IO_State[] sta)
{
List<bool> work = new List<bool>();
for (int i = 0; i < Common.elevatorInfos.Count; i++)
{
if (Common.elevatorInfos[i].Type == "DO")
{
int idx = Common.elevatorInfos[i].Address;
if (idx < sta.Length)
{
Common.elevatorInfos[i].State = sta[idx] == Advantech.IO_State.On;
}
work.Add(Common.elevatorInfos[i].State);
}
}
DO_Changed?.Invoke(work.ToArray());
}
private void Module_DI_Changed_Event(Advantech.IO_Module box, Advantech.IO_State[] sta)
{
List<bool> work = new List<bool>();
List<string> content = new List<string>();
for (int i = 0; i < Common.elevatorInfos.Count; i++)
{
if (Common.elevatorInfos[i].Type == "DI")
{
int idx = Common.elevatorInfos[i].Address;
if (idx < sta.Length)
{
Common.elevatorInfos[i].State = sta[idx] == Advantech.IO_State.On;
}
work.Add(Common.elevatorInfos[i].State);
content.Add(Common.elevatorInfos[i].ToText());
}
}
//System.IO.File.WriteAllLines(Common.PATH_ELEVATOR_WORK, content, Encoding.UTF8);
DI_Changed?.Invoke(work.ToArray());
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Model;
namespace BLL
{
public class LineWork
{
private Advantech.IO_Module[] module;
public delegate void IOChanged();
public event IOChanged DI_Changed;
public delegate void Connected(bool con);
public event Connected Connect_Event;
public LineWork()
{
Load();
module = new Advantech.IO_Module[Common.lineInfos.Count];
for (int i = 0; i < module.Length; i++)
{
module[i] = new Advantech.IO_Module(0, 4, 4, 4, "IO_Line") { IP = Common.lineInfos[i].IP };
module[i].DI_Changed_Event += Module_DI_Changed_Event;
}
}
public void Open()
{
for (int i = 0; i < module.Length; i++)
module[i].Open();
}
public void Close()
{
for (int i = 0; i < module.Length; i++)
module[i].Close();
}
public IJob GetJob()
{
if (Common.FirstFloorCurr < Common.FirstFloorCount)
{
int index = Common.lineInfos.FindIndex(s => s.Call && s.Exist); //有呼叫状态同时存在架子
if (index > -1)
{
Common.log.Info(Common.lineInfos[index].Name + "呼叫送满架");
return new FullShelfJob();
}
else
{
Common.log.Debug("没有找到任何产线呼叫送满架");
return null;
}
}
else
{
Common.log.Debug("一楼货架已满" + Common.FirstFloorCount + "个");
return null;
}
}
public void TakeAway(string key)
{
int index = Common.lineInfos.FindIndex(s => s.Key == key);
if (index == -1) return;
Common.lineInfos[index].Call = false;
Common.lineInfos[index].Exist = false;
Common.lineInfos[index].FinalDate = DateTime.Now;
Save();
DI_Changed?.Invoke();
}
public void SendTo(string key)
{
int index = Common.lineInfos.FindIndex(s => s.Key == key);
if (index == -1) return;
Common.lineInfos[index].Call = false;
Common.lineInfos[index].Exist = true;
Save();
DI_Changed?.Invoke();
}
private void Load()
{
if (System.IO.File.Exists(Common.PATH_LINE_WORK))
{
string[] lines = System.IO.File.ReadAllLines(Common.PATH_LINE_WORK, Encoding.UTF8);
for (int i = 0; i < lines.Length; i++)
{
if (i == 0) continue; //第一行是标题
string[] str = lines[i].Split(',');
if (str.Length != 4) continue;
int index = Common.lineInfos.FindIndex(s => s.Key == str[0]);
if (index == -1) continue;
Common.lineInfos[index].Call = Convert.ToBoolean(str[1]);
Common.lineInfos[index].Exist = Convert.ToBoolean(str[2]);
Common.lineInfos[index].FinalDate = Convert.ToDateTime(str[3]);
}
Common.log.Info("加载缓存文件 " + Common.PATH_LINE_WORK);
}
else
{
Save();
}
}
public void Save()
{
string[] content = new string[Common.lineInfos.Count + 1];
content[0] = "产线名,呼叫,架子,时间";
for (int i = 0; i < Common.lineInfos.Count; i++)
content[i + 1] = string.Format("{0},{1},{2},{3:yyyy-MM-dd HH:mm:ss}", Common.lineInfos[i].Key, Common.lineInfos[i].Call, Common.lineInfos[i].Exist, Common.lineInfos[i].FinalDate);
System.IO.File.WriteAllLines(Common.PATH_LINE_WORK, content, Encoding.UTF8);
Common.log.Info("保存缓存文件 " + Common.PATH_LINE_WORK);
}
private void Module_Connect_Event(Advantech.IO_Module box)
{
Connect_Event?.Invoke(box.IsConn);
}
private void Module_DO_Changed_Event(Advantech.IO_Module box, Advantech.IO_State[] sta)
{
}
private void Module_DI_Changed_Event(Advantech.IO_Module box, Advantech.IO_State[] sta)
{
int lineIdx = Common.lineInfos.FindIndex(s => s.IP == box.IP);
if (lineIdx == -1) return;
int add = Common.lineInfos[lineIdx].Address;
if (add >= sta.Length) return;
bool change = false;
if (sta[add] == Advantech.IO_State.On)
{
Common.lineInfos[lineIdx].Call = true;
Common.lineInfos[lineIdx].FinalDate = DateTime.Now;
change = true;
}
if (change) Save();
DI_Changed?.Invoke();
//List<bool> work = new List<bool>();
//List<string> content = new List<string>();
//for (int i = 0; i < Common.lineInfos.Count; i++)
//{
// if (Common.lineInfos[i].Type == "DI")
// {
// int idx = Common.lineInfos[i].Address;
// if (idx < sta.Length)
// {
// if (sta[idx] == Advantech.IO_State.On)
// Common.lineInfos[i].State = true;
// }
// work.Add(Common.lineInfos[i].State);
// content.Add(Common.lineInfos[i].ToText());
// }
//}
//System.IO.File.WriteAllLines(Common.PATH_LINE_WORK, content, Encoding.UTF8);
//DI_Changed?.Invoke(work.ToArray());
}
}
}
using System;
using System.Text;
using Model;
namespace BLL
{
public static class ManageWork
{
public static LineWork line;
public static ElevatorWork elevator;
public static bool PauseFull;
public static void Init()
{
PauseFull = false;
line = new LineWork();
elevator = new ElevatorWork();
}
public static void Start()
{
line.Open();
elevator.Open();
}
public static void Stop()
{
line.Close();
elevator.Close();
}
/// <summary>
/// 获取产线或电梯任务
/// </summary>
/// <returns></returns>
public static IJob GetJob()
{
IJob job = elevator.GetJob();
if (job == null)
job = line.GetJob();
return job;
}
/// <summary>
/// 查找产线呼叫
/// </summary>
/// <param name="key"></param>
/// <param name="name"></param>
/// <returns></returns>
public static bool FindLineWork(out string key, out string name)
{
int index = Common.lineInfos.FindIndex(s => s.Call && s.Exist);
if (index == -1)
{
key = "";
name = "";
return false;
}
else
{
key = Common.lineInfos[index].Key;
name = Common.lineInfos[index].Name;
return true;
}
}
/// <summary>
/// 查找电梯回收呼叫
/// </summary>
/// <returns></returns>
public static bool FindElevatorWork()
{
return elevator.GetRecycle();
}
/// <summary>
/// 查找不带货架的产线
/// </summary>
/// <param name="key"></param>
/// <param name="name"></param>
/// <returns></returns>
public static bool FindLineWithoutShelf(out string key, out string name)
{
int index = Common.lineInfos.FindIndex(s => s.Exist == false);
if (index == -1)
{
key = "";
name = "";
return false;
}
else
{
key = Common.lineInfos[index].Key;
name = Common.lineInfos[index].Name;
return true;
}
}
/// <summary>
/// 小车从产线取走货架
/// </summary>
/// <param name="key"></param>
public static void LineTakeAway(string key)
{
line.TakeAway(key);
}
/// <summary>
/// 小车拉取货架送到产线
/// </summary>
/// <param name="key"></param>
public static void LineSendTo(string key)
{
line.SendTo(key);
}
/// <summary>
/// 发送电梯使用请求
/// </summary>
public static void SendElevatorUseAsk()
{
elevator.UseAsk();
}
/// <summary>
/// 电梯使用应答
/// </summary>
/// <returns></returns>
public static bool ElevatorUseAnswer()
{
return elevator.UseAnswer();
}
public static void ElevatorCall(bool sta)
{
elevator.CallElevator(sta);
}
public static bool ElevatorReady()
{
bool rtn1 = elevator.ArriveFloor();
bool rtn2 = elevator.OpenDoor();
return rtn1 && rtn2;
}
/// <summary>
/// 电梯送满架子
/// </summary>
public static void ElevatorFullShelf()
{
elevator.FullShelf();
}
/// <summary>
/// 电梯回收空架子
/// </summary>
public static void ElevatorEmptyShelf()
{
elevator.EmptyShelf();
}
/// <summary>
/// 电梯任务结束,可以离开
/// </summary>
public static void ElevatorEnd()
{
elevator.EndTask();
}
}
}
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件的差异太大,无法显示。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<log4net>
<logger name="AGVControl">
<level value="Debug"/>
<appender-ref ref="AGVControl"/>
</logger>
<logger name="MiR_API">
<level value="Debug"/>
<appender-ref ref="api"/>
</logger>
<logger name="IO_Line">
<level value="Debug"/>
<appender-ref ref="IO_Line"/>
</logger>
<logger name="IO_Elevator">
<level value="Debug"/>
<appender-ref ref="IO_Elevator"/>
</logger>
<appender name="AGVControl" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log\\AGVControl.log" />
<param name="Encoding" value="UTF-8"/>
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy-MM-dd" />
<param name="MaxSizeRollBackups" value="100" />
<param name="MaxFileSize" value="10240" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d][%t][%c:%L]%-5p %m%n" />
</layout>
</appender>
<appender name="api" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log\\MiR_API.log" />
<param name="Encoding" value="UTF-8"/>
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy-MM-dd" />
<param name="MaxSizeRollBackups" value="100" />
<param name="MaxFileSize" value="10240" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d][%t][%c:%L]%-5p %m%n" />
</layout>
</appender>
<appender name="IO_Line" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log\\IO_Line.log" />
<param name="Encoding" value="UTF-8"/>
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy-MM-dd" />
<param name="MaxSizeRollBackups" value="100" />
<param name="MaxFileSize" value="10240" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d][%t][%c:%L]%-5p %m%n" />
</layout>
</appender>
<appender name="IO_Elevator" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log\\IO_Elevator.log" />
<param name="Encoding" value="UTF-8"/>
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy-MM-dd" />
<param name="MaxSizeRollBackups" value="100" />
<param name="MaxFileSize" value="10240" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d][%t][%c:%L]%-5p %m%n" />
</layout>
</appender>
</log4net>
</configuration>
\ No newline at end of file
此文件类型无法预览
此文件的差异太大,无法显示。
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
d22cc3aa0a86c997cf5178afbca689c280490bd7
D:\Neotel\AGVControl_Elevator\BLL\obj\Debug\BLL.csprojAssemblyReference.cache
D:\Neotel\AGVControl_Elevator\BLL\obj\Debug\BLL.csproj.CoreCompileInputs.cache
D:\Neotel\AGVControl_Elevator\BLL\bin\Debug\log4net.config
D:\Neotel\AGVControl_Elevator\BLL\bin\Debug\BLL.dll
D:\Neotel\AGVControl_Elevator\BLL\bin\Debug\BLL.pdb
D:\Neotel\AGVControl_Elevator\BLL\bin\Debug\Model.dll
D:\Neotel\AGVControl_Elevator\BLL\bin\Debug\log4net.dll
D:\Neotel\AGVControl_Elevator\BLL\bin\Debug\RestSharp.dll
D:\Neotel\AGVControl_Elevator\BLL\bin\Debug\Model.pdb
D:\Neotel\AGVControl_Elevator\BLL\bin\Debug\log4net.xml
D:\Neotel\AGVControl_Elevator\BLL\bin\Debug\RestSharp.xml
D:\Neotel\AGVControl_Elevator\BLL\obj\Debug\BLL.csproj.CopyComplete
D:\Neotel\AGVControl_Elevator\BLL\obj\Debug\BLL.dll
D:\Neotel\AGVControl_Elevator\BLL\obj\Debug\BLL.pdb
D:\Neotel\AGVControl_Elevator\BLL\bin\Debug\Advantech_IO.dll
D:\Neotel\AGVControl_Elevator\BLL\bin\Debug\Advantech_IO.pdb
此文件类型无法预览
此文件类型无法预览
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class AgvInfo
{
/// <summary>
/// 小车名称
/// </summary>
public string Name { private set; get; } = "";
/// <summary>
/// 在Fleet中的ID
/// </summary>
public string FleetID { private set; get; } = "";
/// <summary>
/// 小车IP地址
/// </summary>
public string IP { private set; get; } = "";
/// <summary>
/// 授权码
/// </summary>
public string Authorization { private set; get; } = "";
/// <summary>
/// 是否自动使用
/// </summary>
public bool IsAuto { set; get; } = false;
/// <summary>
/// 是否在线
/// </summary>
public bool IsOnline { set; get; } = false;
/// <summary>
/// 电量百分比
/// </summary>
public int Battery { set; get; } = 0;
/// <summary>
/// 小车状态ID号
/// </summary>
public int StateID { set; get; } = -1;
/// <summary>
/// 小车状态文本
/// </summary>
public string StateText { set; get; } = "";
/// <summary>
/// 小车当前任务名称
/// </summary>
public string MissionName { set; get; } = "";
/// <summary>
/// 小车当前任务说明描述
/// </summary>
public string MissionExplain { set; get; } = "";
/// <summary>
/// 小车坐标位置
/// </summary>
public System.Drawing.PointF Position { set; get; }
/// <summary>
/// 是否正在被调用
/// </summary>
public bool IsCall { set; get; } = false;
/// <summary>
/// 当前地点
/// </summary>
public string Place { set; get; } = "";
/// <summary>
/// 当前的工作
/// </summary>
public IJob CurrentJob { set; get; } = null;
public AgvInfo(string fleetID, string name, string ip, string authorization)
{
Name = name;
FleetID = fleetID;
IP = ip;
Authorization = authorization;
}
public string[] ToGridRow()
{
string[] arr = new string[] { Name, Place, MissionName, StateText, Battery.ToString(), IsOnline.ToString(), IsAuto.ToString(), "清除" };
return arr;
}
public string ToMissionState()
{
string s = Name + " [" + IP + "]\r\n\r\n" + MissionExplain;
return s;
}
}
}
using System;
using System.Collections.Generic;
namespace Model
{
public static class Common
{
public static MiR_API mir;
public static Log log;
public static List<AgvInfo> agvInfos;
public static Dictionary<string, string> agvMissions;
public static List<LineIOInfo> lineInfos;
public static List<IOInfo> elevatorInfos;
public static System.Configuration.Configuration appConfig;
//public static System.Windows.Forms.TextBox txtLog;
//public static System.Windows.Forms.ListBox lstOldSteel;
//public static System.Windows.Forms.ListBox lstNewSteel;
//public static System.Windows.Forms.ListBox lstStorage;
//public static System.Windows.Forms.Label lblStorageIO;
public static string ElevatorIOIP;
public static bool FleetSend;
public static int BatteryMax;
public static int BatteryMin;
public static int BatteryIdle;
public static int FirstFloorCount;
public static int FirstFloorCurr;
public static bool AutoCharge;
//public static string BoardURL;
//public static int BoardTimeout;
//public static bool WorkTimeoutDel = false;
//public static bool WorkAutoDel = false;
//public static int WorkTimeout;
//public static bool StorageDockFinish = false; //停靠完成
//public static bool StorageDockAlway = false; //指定停靠状态,一直不改变
public const string ELEVATOR_USE_ANSWER = "DI1"; //请求应答
public const string ELEVATOR_ARRIVE_FLOOR = "DI2"; //到达任务楼层
public const string ELEVATOR_OPEN_DOOR = "DI3"; //电梯门已开
public const string ELEVATOR_EMPTY_SHELF = "DI4"; //电梯送空架
public const string ELEVATOR_FAULT = "DI5"; //电梯故障
public const string ELEVATOR_USE_ASK = "DO1"; //请求使用电梯
public const string ELEVATOR_LEAVE = "DO2"; //发送离开信号
public const string ELEVATOR_CALL = "DO3"; //呼叫电梯
public const string ELEVATOR_FULL_SHELF = "DO4"; //发送送满料信号
public const string MISSION_ENTER_ELEVATOR_FULL = "EnterElevatorFull";
public const string MISSION_ENTER_ELEVATOR_EMPTY = "EnterElevatorEmpty";
public const string MISSION_MOVE_ELEVATOR = "MoveElevatorSide";
public const string MISSION_LEAVE_SHELF = "LeaveShelf";
public const string MISSION_CARRY_ELEVATOR = "CarryElevatorSide";
public const string MISSION_CHARGE = "AutoCharge";
public const string MISSION_STANDBY = "MoveStandby";
public const string MISSION_CARRY_FULL = "CarryFull";
public const string MISSION_CARRY_EMPTY = "CarryEmpty";
public static readonly string PATH_AGV_NAME = Environment.CurrentDirectory + "\\Config\\AgvName.csv";
public static readonly string PATH_AGV_MISSION = Environment.CurrentDirectory + "\\Config\\AgvMission.csv";
public static readonly string PATH_LINE = Environment.CurrentDirectory + "\\Config\\Line.csv";
public static readonly string PATH_ELEVATOR = Environment.CurrentDirectory + "\\Config\\Elevator.csv";
public static readonly string PATH_LINE_WORK = Environment.CurrentDirectory + "\\Config\\LineWork.txt";
public static readonly string PATH_ELEVATOR_WORK = Environment.CurrentDirectory + "\\Config\\ElevatorWork.txt";
public static readonly string PATH_FIRST_FLOOR_CURR = Environment.CurrentDirectory + "\\Config\\FirstFloorCurr.txt";
}
}
using System;
namespace Model
{
public interface IJob
{
public bool IsEnd { get; }
//public string Msg { get; }
public IJob Execute(AgvInfo info);
}
}
using System;
namespace Model
{
public class IOInfo
{
public string Name { private set; get; }
public string Type { private set; get; }
public int Address { private set; get; }
public string Key { private set; get; }
public bool State { set; get; }
public DateTime FinalDate { private set; get; }
public IOInfo(string name, string type, string address, string key)
{
Name = name;
Type = type.ToUpper();
Address = Convert.ToInt32(address);
Key = key;
State = false;
FinalDate = DateTime.Now;
}
public string ToText()
{
return string.Format("{0},{1},{2:yyyy-MM-dd HH:mm:ss}", Key, State, FinalDate);
}
}
public class LineIOInfo
{
public string Name { private set; get; }
public string IP { private set; get; }
public int Address { private set; get; }
public string Key { private set; get; }
public bool Call { set; get; }
public bool Exist { set; get; }
public DateTime FinalDate { set; get; }
public LineIOInfo(string name, string ip, string address, string key)
{
Name = name;
IP = ip;
Address = Convert.ToInt32(address);
Key = key;
Call = false;
Exist = true;
FinalDate = DateTime.Now;
}
}
}
using System;
using Model;
namespace BLL
{
public class JobStep<T>
{
private T _step;
private DateTime _time;
private string _msg;
public JobStep(T step)
{
_step = step;
_time = DateTime.Now;
_msg = "";
}
public bool Equals(T step)
{
return _step.Equals(step);
}
public bool TimeOut(int ms)
{
TimeSpan span = DateTime.Now - _time;
if (span.TotalMilliseconds > ms)
return true;
else
return false;
}
public void NextStep(T step)
{
_step = step;
_time = DateTime.Now;
_msg = "";
}
public string Msg
{
get
{
return _msg;
}
set
{
if (!string.IsNullOrEmpty(value) && !_msg.Equals(value))
{
_msg = value;
string s = string.Format("{0} (step={1})", _msg, _step.ToString());
Common.log.Info(s);
Common.log.UI_Display(_msg);
}
}
}
}
}
using System;
namespace Model
{
public class Log
{
private readonly log4net.ILog LOG;
public Log(string name)
{
LOG = log4net.LogManager.GetLogger(name);
}
public System.Windows.Forms.TextBox LogBox { set; get; }
public void Info(string s)
{
LOG.Info(s);
}
public void Debug(string s)
{
LOG.Debug(s);
}
public void Warn(string s)
{
LOG.Warn(s);
}
public void Error(string s, Exception ex)
{
LOG.Error(s, ex);
}
public void UI_Display(string s)
{
if (LogBox == null) return;
string text = string.Format("[{0:HH:mm:ss}] {1}\r\n", DateTime.Now, s);
LogBox.Invoke(new Action(() =>
{
LogBox.AppendText(text);
LogBox.ScrollToCaret();
}));
}
}
}
此文件的差异被折叠, 点击展开。
using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using RestSharp;
namespace Model
{
/// <summary>
/// MiR小车API
/// </summary>
public class MiR_API_Test
{
private int count;
/// <summary>
/// Fleet的IP地址
/// </summary>
public string FleetIP { set; get; }
/// <summary>
/// 任务列表
/// </summary>
public Dictionary<string, string> MissionList { set; get; }
/// <summary>
/// MiR小车API
/// </summary>
public MiR_API_Test()
{
}
/// <summary>
/// 获取IO模块guid列表
/// </summary>
/// <param name="ip"></param>
/// <param name="authorization"></param>
/// <param name="guid"></param>
/// <returns></returns>
public bool Get_IO_Modules(string ip, string authorization, out string[] guid)
{
guid = new string[] { "1234", "5678" };
return true;
}
/// <summary>
/// 获取IO模块的状态
/// </summary>
/// <param name="ip"></param>
/// <param name="authorization"></param>
/// <param name="guid"></param>
/// <param name="input"></param>
/// <param name="output"></param>
/// <returns></returns>
public bool Get_IO_Status(string ip, string authorization, string guid, out bool[] input, out bool[] output)
{
input = new bool[] { true, true, true, true };
output = new bool[] { true, true, true, true };
return true;
}
/// <summary>
/// 获取任务状态
/// </summary>
/// <param name="authorization"></param>
/// <param name="id"></param>
/// <param name="state"></param>
/// <returns></returns>
public bool Get_MissionState_Fleet(string authorization, string id, out string state)
{
if (count == 1)
state = "Done";
else
{
state = "Executing";
count++;
}
return true;
}
/// <summary>
/// 获取任务状态
/// </summary>
/// <param name="ip"></param>
/// <param name="authorization"></param>
/// <param name="id"></param>
/// <param name="state"></param>
/// <returns></returns>
public bool Get_MissionState(string ip, string authorization, string id, out string state)
{
state = "";
return true;
}
/// <summary>
/// 获取PLC寄存器的内容
/// </summary>
/// <param name="ip"></param>
/// <param name="authorization"></param>
/// <param name="reg"></param>
/// <param name="regValue"></param>
/// <returns></returns>
public bool Get_Register(string ip, string authorization, int reg, out int regValue)
{
regValue = 1;
return true;
}
/// <summary>
/// 设置PLC寄存器的内容
/// </summary>
/// <param name="ip"></param>
/// <param name="authorization"></param>
/// <param name="reg"></param>
/// <param name="regValue"></param>
/// <returns></returns>
public bool Set_Register(string ip, string authorization, int reg, int regValue)
{
return true;
}
/// <summary>
/// 添加任务到小车自身任务队列
/// </summary>
/// <param name="ip"></param>
/// <param name="authorization"></param>
/// <param name="missionName"></param>
/// <param name="id"></param>
/// <returns></returns>
public bool Add_Mission(string ip, string authorization, string missionName, out string id)
{
id = "123";
return true;
}
/// <summary>
/// 添加任务到Fleet任务队列
/// </summary>
/// <param name="fleetID"></param>
/// <param name="authorization"></param>
/// <param name="missionName"></param>
/// <param name="id"></param>
/// <returns></returns>
public bool Add_Mission_Fleet(string fleetID, string authorization, string missionName, out string id)
{
id = "123";
count = 0;
return true;
}
/// <summary>
/// 删除小车所有任务
/// </summary>
/// <param name="ip"></param>
/// <param name="authorization"></param>
public void Del_Mission(string ip, string authorization)
{
}
/// <summary>
/// 删除Fleet尽快中指定id的任务,已运行的无法删除
/// </summary>
/// <param name="authorization"></param>
/// <param name="id"></param>
public void Del_Mission_Fleet(string authorization, string id)
{
}
/// <summary>
/// 获取当前小车状态
/// </summary>
/// <param name="ip"></param>
/// <param name="authorization"></param>
/// <param name="stateID"></param>
/// <param name="stateText"></param>
/// <param name="battery"></param>
/// <param name="missionText"></param>
/// <param name="position"></param>
/// <returns></returns>
public bool Get_State(string ip, string authorization, out int stateID, out string stateText, out int battery, out string missionText, out System.Drawing.PointF position)
{
stateID = -1;
stateText = "123";
battery = 90;
missionText = "fgfg";
if (ip == "10.85.199.82")
position = new System.Drawing.PointF(0, 65);
else if (ip == "10.85.199.84")
position = new System.Drawing.PointF(0, 50);
else
position = new System.Drawing.PointF();
return true;
}
/// <summary>
/// 小车状态改为Ready
/// </summary>
/// <param name="ip"></param>
/// <param name="authorization"></param>
/// <returns></returns>
public bool State_Ready(string ip, string authorization)
{
return true;
}
/// <summary>
/// 小车状态改为Pause
/// </summary>
/// <param name="ip"></param>
/// <param name="authorization"></param>
/// <returns></returns>
public bool State_Pause(string ip, string authorization)
{
return true;
}
/// <summary>
/// 清除错误
/// </summary>
/// <param name="ip"></param>
/// <param name="authorization"></param>
/// <returns></returns>
public bool Clear_Error(string ip, string authorization)
{
return true;
}
public bool CheckIP(string ip)
{
return true;
}
}
}
<?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>{A61B66DD-2B04-41A5-8366-69477C0534E4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Model</RootNamespace>
<AssemblyName>Model</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=106.11.7.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.11.7\lib\net452\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AgvInfo.cs" />
<Compile Include="Common.cs" />
<Compile Include="IJob.cs" />
<Compile Include="JobStep.cs" />
<Compile Include="IOInfo.cs" />
<Compile Include="Log.cs" />
<Compile Include="MiR_API.cs" />
<Compile Include="MiR_API_Test.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Model")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Model")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("a61b66dd-2b04-41a5-8366-69477c0534e4")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [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)]
\ No newline at end of file
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件的差异太大,无法显示。
此文件类型无法预览
此文件的差异太大,无法显示。
此文件的差异被折叠, 点击展开。
此文件类型无法预览
此文件类型无法预览
此文件的差异被折叠, 点击展开。
此文件类型无法预览
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件类型无法预览
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!