Commit 757c5c07 张东亮

init

0 个父辈
正在显示 177 个修改的文件 包含 4856 行增加0 行删除
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
*.DS_Store

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31515.178
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiftController", "LiftController\LiftController.csproj", "{1193FA19-DA5B-438F-9346-B3BA967BF011}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "source\Common\Common.csproj", "{BAFEAFE6-04E2-48EE-8845-BFC7EA3E3C21}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceLibrary", "source\DeviceLibrary\DeviceLibrary.csproj", "{F9619F07-15F1-4E59-A383-3871952BBB79}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadCSVLibrary", "source\LoadCVSLibrary\LoadCSVLibrary.csproj", "{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserFromControl", "source\UserFromControl\UserFromControl.csproj", "{F018462A-D9BC-4365-97F2-F6D71751641E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1193FA19-DA5B-438F-9346-B3BA967BF011}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1193FA19-DA5B-438F-9346-B3BA967BF011}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1193FA19-DA5B-438F-9346-B3BA967BF011}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1193FA19-DA5B-438F-9346-B3BA967BF011}.Release|Any CPU.Build.0 = Release|Any CPU
{BAFEAFE6-04E2-48EE-8845-BFC7EA3E3C21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BAFEAFE6-04E2-48EE-8845-BFC7EA3E3C21}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAFEAFE6-04E2-48EE-8845-BFC7EA3E3C21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAFEAFE6-04E2-48EE-8845-BFC7EA3E3C21}.Release|Any CPU.Build.0 = Release|Any CPU
{F9619F07-15F1-4E59-A383-3871952BBB79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9619F07-15F1-4E59-A383-3871952BBB79}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9619F07-15F1-4E59-A383-3871952BBB79}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9619F07-15F1-4E59-A383-3871952BBB79}.Release|Any CPU.Build.0 = Release|Any CPU
{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}.Debug|Any CPU.Build.0 = Debug|Any CPU
{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}.Release|Any CPU.ActiveCfg = Release|Any CPU
{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}.Release|Any CPU.Build.0 = Release|Any CPU
{F018462A-D9BC-4365-97F2-F6D71751641E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F018462A-D9BC-4365-97F2-F6D71751641E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F018462A-D9BC-4365-97F2-F6D71751641E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F018462A-D9BC-4365-97F2-F6D71751641E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7F44F515-AD52-4A99-A020-2BA408801466}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<appSettings>
<add key="UseAIOBOX" value="1"/>
<add key="Line_Config" value="LineConfig.csv"/>
<add key="ServiceBaseUrl" value="http://127.0.0.1:8887"/>
<add key="Lift_Ids" value="LIFT_D2,LIFT_C1"/>
<add key="Lift_Buffs" value="[{&quot;liftId&quot;:&quot;D2&quot;,&quot;Status&quot;:{&quot;floor&quot;:0,&quot;door&quot;:&quot;&quot;,&quot;sourceClient&quot;:&quot;&quot;,&quot;sourceFloor&quot;:0,&quot;sourcePoint&quot;:&quot;&quot;,&quot;destinationClient&quot;:&quot;&quot;,&quot;destinationFloor&quot;:0,&quot;destinationPoint&quot;:&quot;&quot;},&quot;State&quot;:0,&quot;RunState&quot;:0,&quot;Clients&quot;:[]},{&quot;liftId&quot;:&quot;C1&quot;,&quot;Status&quot;:{&quot;floor&quot;:0,&quot;door&quot;:&quot;&quot;,&quot;sourceClient&quot;:&quot;HY1F&quot;,&quot;sourceFloor&quot;:1,&quot;sourcePoint&quot;:&quot;4DLine5&quot;,&quot;destinationClient&quot;:&quot;ZJ4D&quot;,&quot;destinationFloor&quot;:4,&quot;destinationPoint&quot;:&quot;1CLine3&quot;},&quot;State&quot;:0,&quot;RunState&quot;:0,&quot;Clients&quot;:[{&quot;sourceClient&quot;:&quot;ZJ4D&quot;,&quot;hasIdleAgv&quot;:true,&quot;Online&quot;:true}]}]"/>
</appSettings>
</configuration>
using Common;
using DeviceLibrary;
using LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using UserFromControl;
namespace LiftController
{
public partial class FrmIO : Form
{
public FrmIO(LineConfig config)
{
Control.CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
groupBox4.Enabled = false;
LoadIOList(config);
}
Dictionary<string, IOTextControl> DIControlList = new Dictionary<string, IOTextControl>();
Dictionary<string, IOTextControl> DOControlList = new Dictionary<string, IOTextControl>();
private void LoadIOList(LineConfig config)
{
this.tableLayoutPanel2.RowStyles.Clear();
this.tableLayoutPanel2.RowCount = config.DIList.Count;
int roleindex = 0;
foreach (ConfigIO ioValue in config.DIList.Values)
{
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
this.tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
this.tableLayoutPanel2.Controls.Add(control, 0, roleindex);
roleindex++;
DIControlList.Add(ioValue.ProName, control);
}
tableLayoutPanel3.RowStyles.Clear();
this.tableLayoutPanel3.RowCount = config.DOList.Count;
roleindex = 0;
foreach (ConfigIO ioValue in config.DOList.Values)
{
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
control.Click += Control_Click;
this.tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
this.tableLayoutPanel3.Controls.Add(control, 0, roleindex);
roleindex++;
DOControlList.Add(ioValue.ProName, control);
}
this.SuspendLayout(); //此处为不闪屏,一定要有的!
cmbWriteIO.DataSource = new List<ConfigIO>(config.DOList.Values);
cmbWriteIO.ValueMember = "ProName";
cmbWriteIO.DisplayMember = "DisplayStr";
}
private void Control_Click(object sender, EventArgs e)
{
IOTextControl control = (IOTextControl)sender;
string name = control.Name.Substring(3, control.Name.Length - 3);
List<string> keyList = new List<string>(DOControlList.Keys);
int index = keyList.IndexOf(name);
if (index >= 0)
{
cmbWriteIO.SelectedIndex = index;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (this.Visible)
{
ReadIOList();
}
}
private void ReadIOList()
{
foreach (string key in DIControlList.Keys)
{
IOTextControl control = DIControlList[key];
int iov = (int)IOManager.IOValue(key);
if (iov != control.IOValue)
{
control.IOValue = iov;
control.ShowData();
LogUtil.info($"IO状态DI更新:{key}={iov}");
}
}
foreach (string key in this.DOControlList.Keys)
{
IOTextControl control = DOControlList[key];
int iov = (int)IOManager.DOValue(key);
if (iov != control.IOValue)
{
control.IOValue = iov;
control.ShowData();
LogUtil.info($"IO状态DO更新:{key}={iov}");
}
}
}
private void FrmIO_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
if (this.timer1.Enabled)
{
this.timer1.Enabled = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace, "Exception(异常)", MessageBoxButtons.OK, MessageBoxIcon.Error);
LogUtil.error("", ex);
}
}
private ConfigIO GetSelectDO()
{
string text = cmbWriteIO.SelectedValue.ToString();
if (LineManager.Config.DOList.ContainsKey(text))
{
ConfigIO io = LineManager.Config.DOList[text];
return io;
}
return null;
}
IOTextControl selectControl = null;
private void WriteDO(IO_VALUE value)
{
string deviceName = txtDoName.Text;
int.TryParse(txtDOIndex.Text, out int index);
int.TryParse(txtWriteTime.Text,out int time);
if (time > 0)
{
IOManager.instance.WriteSingleDO(deviceName, (byte)0, (ushort)index, value, time);
}
else
{
IOManager.instance.WriteSingleDO(deviceName, (byte)0, (ushort)index, value);
}
LogUtil.info($"手动写入DO:{deviceName},{index},{value},{time}");
}
private void cmbWriteIO_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbWriteIO.SelectedIndex >= 0)
{
ConfigIO io = GetSelectDO();
if (io != null)
{
// txtIp.Text = io.DeviceName;
txtDOIndex.Text = io.GetIOAddr().ToString();
txtDoName.Text = io.IO_IP;
IOTextControl newControl = DOControlList[io.ProName];
if (selectControl != null) { selectControl.BackColor = Color.White; }
newControl.BackColor = Color.SkyBlue;
selectControl = newControl;
}
}
}
private void btnWriteSingleDO_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.HIGH);
}
private void button1_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.LOW);
}
private void cmbWriteIO_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index < 0)
{
return;
}
e.DrawBackground();
e.DrawFocusRectangle();
if (cmbWriteIO.Items.Count > e.Index)
{
ConfigIO io = (ConfigIO)cmbWriteIO.Items[e.Index];
e.Graphics.DrawString(io.DisplayStr, e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3);
}
}
private void FrmIOStatus_Shown(object sender, EventArgs e)
{
timer1.Start();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
bool chked=checkBox1.Checked;
groupBox4.Enabled=chked;
LogUtil.info($"IO调试状态:{chked}");
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file

namespace LogisticsIntelligence
{
partial class FrmMain
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain));
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.tableLayoutPanel1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.tabControl1, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.groupBox1, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 44.22222F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 55.77778F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(1216, 620);
this.tableLayoutPanel1.TabIndex = 1;
//
// tabControl1
//
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tabControl1.Location = new System.Drawing.Point(3, 277);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(1210, 340);
this.tabControl1.TabIndex = 0;
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox1.Location = new System.Drawing.Point(3, 3);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(1210, 268);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "电梯状态";
//
// label1
//
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(3, 19);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(1204, 246);
this.label1.TabIndex = 2;
this.label1.Text = "label1";
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1216, 620);
this.Controls.Add(this.tableLayoutPanel1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "FrmMain";
this.Text = "LiftController";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMain_FormClosing);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmMain_FormClosed);
this.Load += new System.EventHandler(this.FrmMain_Load);
this.tableLayoutPanel1.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.ComponentModel.BackgroundWorker backgroundWorker1;
}
}
using DeviceLibrary;
using LiftController;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LogisticsIntelligence
{
public partial class FrmMain : Form
{
public FrmMain()
{
InitializeComponent();
appContext.Init();
}
DeviceLibrary.Context.Context appContext = new DeviceLibrary.Context.Context();
private void FrmMain_Load(object sender, EventArgs e)
{
appContext.Open();
timer1.Enabled = true;
FrmIO frmi = new FrmIO(LineManager.Config);
AddForm(" IO列表 ", frmi);
timer1.Start();
}
private void FrmMain_FormClosed(object sender, FormClosedEventArgs e)
{
//appContext.Close();
timer1.Enabled = false;
}
private void UpdateLift()
{
this.Invoke(new Action(()=> {
label1.Text = DeviceLibrary.Context.LiftContext.ToListInfos();
}));
}
private void timer1_Tick(object sender, EventArgs e)
{
UpdateLift();
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("确定退出该软件?退出后智能搬运系统内的小车将无法使用电梯。", "提示", MessageBoxButtons.YesNo).Equals(DialogResult.No))
{
e.Cancel = true;
}
}
private void AddForm(string text, Form form)
{
text = text.PadLeft(10, ' ');
TabPage lineTabPage = new TabPage(text);
// lineTabPage.AutoScroll = true;
// lineTabPage.Tag = lineBean;
Panel linePan = new Panel();
linePan.Dock = DockStyle.Fill;
linePan.AutoScroll = true;
lineTabPage.Controls.Add(linePan);
form.FormBorderStyle = FormBorderStyle.None;
form.TopLevel = false;
linePan.Controls.Add(form);
form.Dock = DockStyle.Fill;
linePan.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
form.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
form.Show();
// tabPageList.Add(lineTabPage);
tabControl1.Controls.Add(lineTabPage);
}
}
}
<?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>{1193FA19-DA5B-438F-9346-B3BA967BF011}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>LiftController</RootNamespace>
<AssemblyName>LiftController</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icons8_administrative_tools.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\source\dll\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FrmIO.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmIO.Designer.cs">
<DependentUpon>FrmIO.cs</DependentUpon>
</Compile>
<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="FrmIO.resx">
<DependentUpon>FrmIO.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<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="..\source\Common\Common.csproj">
<Project>{bafeafe6-04e2-48ee-8845-bfc7ea3e3c21}</Project>
<Name>Common</Name>
</ProjectReference>
<ProjectReference Include="..\source\DeviceLibrary\DeviceLibrary.csproj">
<Project>{f9619f07-15f1-4e59-a383-3871952bbb79}</Project>
<Name>DeviceLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\source\LoadCVSLibrary\LoadCSVLibrary.csproj">
<Project>{064bebf5-8faa-4ea2-a5f3-a06e6e7d9251}</Project>
<Name>LoadCSVLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\source\UserFromControl\UserFromControl.csproj">
<Project>{f018462a-d9bc-4365-97f2-f6d71751641e}</Project>
<Name>UserFromControl</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="icons8_administrative_tools.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using Common;
using log4net.Config;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LogisticsIntelligence
{
static class Program
{
///// <summary>
///// 应用程序的主入口点。
///// </summary>
//[STAThread]
//static void Main()
//{
// Application.EnableVisualStyles();
// Application.SetCompatibleTextRenderingDefault(false);
// Application.Run(new FrmMain());
//}
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ThreadException += Application_ThreadException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
XmlConfigurator.Configure(new FileInfo(SettingString.log4net_configname));
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//程序只能运行一次
Process current = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName(current.ProcessName);
foreach (Process process in processes)
{
if (process.Id == current.Id) continue; //自己
if (process.MainModule.FileName == current.MainModule.FileName)
{
//显示已打开的程序
Window_API.ShowWindow(process.MainWindowHandle, Window_API.SW_RESTORE);
Window_API.SwitchToThisWindow(process.MainWindowHandle, true);
return;
}
}
LogUtil.info("=====程序开始=====");
Application.Run(new FrmMain());
LogUtil.info("=====程序结束=====\r\n");
}
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
LogUtil.error("CurrentDomain_UnhandledException", (Exception)e.ExceptionObject);
}
private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
LogUtil.error("Application_ThreadException", e.Exception);
}
}
static class Window_API
{
[DllImport("user32.dll", EntryPoint = "ShowWindow", CharSet = CharSet.Auto)]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("user32.dll ", SetLastError = true)]
public static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab);
public const int SW_RESTORE = 9;
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("LogisticsIntelligence")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LogisticsIntelligence")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("1193fa19-da5b-438f-9346-b3ba967bf011")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [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 LiftController.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LiftController.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>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace LiftController.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.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>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<log4net>
<appender name="AppLog" type="log4net.Appender.RollingFileAppender">
<file value="logs/AppLog/AppLog.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<param name="MaxSizeRollBackups" value="30"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/>
</layout>
</appender>
<appender name="Service" type="log4net.Appender.RollingFileAppender">
<file value="logs/Service/Service.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<param name="MaxSizeRollBackups" value="30"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/>
</layout>
</appender>
<appender name="AIOBOX" type="log4net.Appender.RollingFileAppender">
<file value="logs/AIOBOX/AIOBOX.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<param name="MaxSizeRollBackups" value="30"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/>
</layout>
</appender>
<logger name="AIOBOX">
<level value="info"/>
<appender-ref ref="AIOBOX"/>
</logger>
<logger name="Service">
<level value="info"/>
<appender-ref ref="Service"/>
</logger>
<root name="AppLog">
<level value="debug"/>
<appender-ref ref="AppLog"/>
</root>
</log4net>
</configuration>
\ No newline at end of file
文件属性发生变化
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BAFEAFE6-04E2-48EE-8845-BFC7EA3E3C21}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Common</RootNamespace>
<AssemblyName>Common</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>.\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath>.\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="util\AppConfigHelper.cs" />
<Compile Include="util\IniFileHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingString.cs" />
<Compile Include="util\HttpHelper.cs" />
<Compile Include="util\JsonHelper.cs" />
<Compile Include="util\LogUtil.cs" />
<Compile Include="util\MyWebClient.cs">
<SubType>Component</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
此文件类型无法预览
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Common")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Common")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("bafeafe6-04e2-48ee-8845-bfc7ea3e3c21")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
此文件类型无法预览
此文件的差异太大,无法显示。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Common
{
public static class SettingString
{
#region 配置名
public const string log4net_configname = "log4net.config";
public const string UseAIOBOX = "UseAIOBOX";
public const string Line_Config = "Line_Config";
public const string ServiceBaseUrl = "ServiceBaseUrl";
public const string Lift_Ids = "Lift_Ids";
public const string Lift_Buffs = "Lift_Buffs";
#endregion
#region 电梯
/// <summary>
/// DI,D2-任务应答,_Response
/// </summary>
public static string _Response = "_Response";
/// <summary>
/// DI,D2-到达1F,_AtFirst
/// </summary>
public static string _AtFirst = "_AtFirst";
/// <summary>
/// DI,D2-到达3F,_AtThird
/// </summary>
public static string _AtThird = "_AtThird";
/// <summary>
/// DI,D2-到达4F,_AtFourth
/// </summary>
public static string _AtFourth = "_AtFourth";
/// <summary>
/// DI,D2-门已开,_DoorOpen
/// </summary>
public static string _DoorOpen = "_DoorOpen";
/// <summary>
/// DI,D2-故障中,_InFault
/// </summary>
public static string _InFault = "_InFault";
/// <summary>
/// DI,D2-运行中,_InRun
/// </summary>
public static string _InRun = "_InRun";
/// <summary>
/// DO,D2-AGV请求,_AGVRequest
/// </summary>
public static string _AGVRequest = "_AGVRequest";
/// <summary>
/// DO,D2-AGV离开,_AGVLeave
/// </summary>
public static string _AGVLeave = "_AGVLeave";
/// <summary>
/// DO,D2-AGV呼叫1F,_FirstCall
/// </summary>
public static string _FirstCall = "_FirstCall";
/// <summary>
/// DO,D2-AGV呼叫3F,_ThirdCall
/// </summary>
public static string _ThirdCall = "_ThirdCall";
/// <summary>
/// DO,D2-AGV呼叫4F,_FourthCall
/// </summary>
public static string _FourthCall = "_FourthCall";
/// <summary>
/// DO,D2-送料信号1F,_RunToFirst
/// </summary>
public static string _RunToFirst = "_RunToFirst";
/// <summary>
/// DO,D2-送料信号3F,_RunToThird
/// </summary>
public static string _RunToThird = "_RunToThird";
/// <summary>
/// DO,D2-送料信号4F,_RunToFourth
/// </summary>
public static string _RunToFourth = "_RunToFourth";
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.Common
{
/// <summary>
/// 记录配置的key
/// </summary>
public class Setting_Init
{
public static string Server_Log_Open = "Server_Log_Open";
/// <summary>
/// 系统启动时自动启动双层流水线,=1时自动启动,并隐藏窗口,=0时不需要
/// </summary>
public static string App_AutoRun = "App_AutoRun";
/// <summary>
/// 系统主界面标题
/// </summary>
public static string App_Title = "App_Title";
public static string httpAddr = "httpAddr";
public static string Line_Config = "Line_Config";
public static string UseAIOBOX = "UseAIOBOX";
/// <summary>
/// 是否调试状态
/// </summary>
public static string IsInDebug = "IsInDebug";
public static string AgvServerIp = "AgvServerIp";
public static string Agv_Log_Open = "Agv_Log_Open";
public static string ABBServerPort = "ABBServerPort";
public static string BenQ_AGV = "BenQ_AGV";
public static string DefaultSpeed = "DefaultSpeed";
}
}
文件属性发生变化
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.Common
{
/// <summary>
/// 与服务器通信用对象
/// </summary>
public class Operation
{
/// <summary>
/// 双层流水线唯一标识
/// </summary>
private string _cid = "";
public string cid
{
get { return _cid; }
set { _cid = value; }
}
/// <summary>
/// 请求序列号
/// </summary>
public int seq { get; set; }
/// <summary>
/// 操作码(0无操作(发送双层流水线状态给服务器),
/// 1扫码入库(扫码成功后发送给服务器),
/// 2 出库(服务器发送),3表示错误信息 )
/// 4,发送给服务表示二维码扫码入库,收到开始扫码
/// </summary>
public int op { get; set; }
/// <summary>
/// 操作相关数据,
/// op=1时,客户端发送 code 二维码给服务器,服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度
/// 如果需要更新温湿度的报警值,服务器会发送alarmTemperature,alarmHumidity给客户端,客户端缓存,如果没有发送,不处理
/// op=3时,data发送BoxID和AlarmCode
/// =4时扫码入库
/// =5时服务器发送预警温度
/// </summary>
private Dictionary<string, string> _data = new Dictionary<string, string>();
public Dictionary<string, string> data
{
get { return _data; }
set { _data = value; }
}
/// <summary>
/// 整体双层流水线状态
/// 1=正常运行中
/// 2=急停中
/// 3=故障(气压检测不到等,用msg发送详细故障说明)
/// 4=警告(用msg发送提醒,如出库到达工位但是没有工人操作)
/// </summary>
public int status { get; set; }
/// <summary>
/// 提示消息
/// 出入库错误: BOX正在调试中,不能出入库
/// 出入库错误: 急停了不能出入库
/// 入库错误:料盘过大,放不到指定的位置中去
/// 故障:气压信号检测不到
/// 警告:出库盘到达工位但是没有工人操作
/// </summary>
public string msg { get; set; }
/// <summary>
/// 包含的多个 BOX 的状态信息
/// </summary>
public Dictionary<int, BoxStatus> boxStatus = new Dictionary<int, BoxStatus>();
/// <summary>
/// 报警集合
/// </summary>
public List<AlarmInfo> alarmList = new List<AlarmInfo>();
}
/// <summary>
/// 单台双层流水线状态(包含流水线)
/// </summary>
public class BoxStatus
{
/// <summary>
/// Box编号,从1开始
/// </summary>
public int boxId { get; set; }
/// <summary>
/// 单台BOX状态
/// 急停,故障,调试中,就绪状态(正常待机)
/// 入库执行中,入库完成,入库失败
/// 出库执行中,出库完成,出库失败
/// </summary>
public int status { get; set; }
/// <summary>
/// 单台BOX的消息
/// 正在调试中,不能出入库
/// 入库失败原因:
/// 出库失败原因:
/// </summary>
public string msg { get; set; }
/// <summary>
/// 温度
/// </summary>
public string temperature { get; set; }
/// <summary>
/// 湿度
/// </summary>
public string humidity { get; set; }
/// <summary>
/// 操作相关数据,
/// 出库完成后发送posId库位编号给服务器
/// </summary>
private Dictionary<string, string> _data = new Dictionary<string, string>();
public Dictionary<string, string> data
{
get { return _data; }
set { _data = value; }
}
}
public class AlarmInfo
{
public AlarmInfo(int StoreID, int aType, string alarmDetial, string WarnMsg, int inoutStatus)
{
// TODO: Complete member initialization
this.boxId = StoreID;
this.alarmType = aType;
this.alarmDetail = alarmDetial;
this.alarmMsg = WarnMsg;
this.inOutStatus = inoutStatus;
}
public AlarmInfo()
{
// TODO: Complete member initialization
}
/// <summary>
/// 双层流水线ID,0表示流水线
/// </summary>
public int boxId { get; set; }
/// <summary>
/// 报警类型,
/// </summary>
public int alarmType { get; set; }
/// <summary>
/// 报警详情
///AlarmType= 0 消息 "1=原点返回
//AlarmType= 0 消息 2=复位"
//AlarmType=1 总体错误 "1=急停
//AlarmType=1 总体错误 2=没有气压信号
//AlarmType=1 总体错误,3=盘错乱"
//AlarmType=2 运动轴错误 1=第一轴(旋转)
//AlarmType=2 运动轴错误 2=第二轴(上下轴)
//AlarmType=2 运动轴错误 3=第三轴(前进轴)
//AlarmType=2 运动轴错误 4=第四轴(压紧轴)"
//AlarmType=2 电钢报警 5=上下电钢
//AlarmType=3 IO报警,信号超时 io电器定义(电器定义)
/// </summary>
public string alarmDetail { get; set; }
/// <summary>
/// 报警消息
/// </summary>
public string alarmMsg { get; set; }
/// <summary>
/// 0,1=入库,2=出库
/// </summary>
public int inOutStatus { get; set; }
}
public class ParamDefine
{
/// <summary>
/// 库位 ID
/// </summary>
public static string posId = "posId";
/// <summary>
/// 料盘宽
/// </summary>
public static string plateW = "plateW";
/// <summary>
/// 料盘高
/// </summary>
public static string plateH = "plateH";
/// <summary>
/// 双层流水线ID
/// </summary>
public static string storeId = "storeId";
/// <summary>
/// 报警码
/// </summary>
public static string alarmCode = "alarmCode";
/// <summary>
/// 报警详情或参数
/// </summary>
public static string alarmDetial = "alarmDetial";
/// <summary>
/// 湿度报警值
/// </summary>
public static string maxHumidity = "humi";
/// <summary>
/// 温度报警值
/// </summary>
public static string maxTemperature = "temp";
/// <summary>
/// urgentReel: true 表示紧急料,需要出到料串上
/// </summary>
public static string urgentReel = "urgentReel";
/// <summary>
/// cutReel: true 表示分盘料,需要出到料串上
/// </summary>
public static string cutReel = "cutReel";
/// <summary>
/// smallReel: true 小料(7x8),放置到小料架上
/// </summary>
public static string smallReel = "smallReel";
/// <summary>
/// rfid: 分配的料架RFID
/// </summary>
public static string rfid = "rfid";
/// <summary>
/// rfidLoc: 料架的架位,值为 - 1时,可以自由分配皮带线, 小料时,架位为1 - 46优先走1 / 2号皮带线,47 - 92优先走3 / 4号皮带线,
/// 70,71,72时只能分配到3 / 4号皮带线; 大料时,架位1 - 6优先走1 / 2号皮带线, 7 - 12优先走3 / 4号皮带线
/// </summary>
public static string rfidLoc = "rfidLoc";
public static string barcode = "barcode";
}
}
文件属性发生变化
此文件类型无法预览
using System;
using System.Windows.Forms;
using System.Xml;
namespace Common
{
public class AppConfigHelper
{
public static System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
public static string GetValue(string key)
{
if (config.AppSettings.Settings[key] == null)
{
LogUtil.info("未找到配置:" + key + ",请检查配置是否完整!");
return "";
}
else
{
return config.AppSettings.Settings[key].Value;
}
}
public static decimal GetNumValue(string key)
{
decimal a = 0;
//System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
Decimal.TryParse(config.AppSettings.Settings[key].Value, out a);
}
}
return a;
}
public static int GetIntValue(string key)
{
int a = 0;
//System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
}
return a;
}
public static bool GetBoolValue(string key)
{
bool a = false;
//System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
bool.TryParse(config.AppSettings.Settings[key].Value, out a);
}
}
return a;
}
public static void SaveValue(string key, int value)
{
SaveValue(key, value.ToString());
}
public static void SaveValue(string key, bool value)
{
SaveValue(key, value.ToString());
}
public static void SaveValue(string key, string value)
{
try
{
if (key.Equals("") || value.Equals(""))
{
return;
}
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
//System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
SetValue(key, value);
}
else
{
UpdateConfig(key, value);
}
}
catch (Exception ex)
{
LogUtil.error("SaveValue保存配置出错:AppKey=" + key + ",AppValue=" + value + "," + ex.StackTrace);
}
}
/// <summary>
/// 更新配置文件信息
/// </summary>
/// <param name="name">配置文件字段名称</param>
/// <param name="Xvalue">值</param>
private static void UpdateConfig(string name, string Xvalue)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(Application.ExecutablePath + ".config");
XmlNode node = doc.SelectSingleNode(@"//add[@key='" + name + "']");
XmlElement ele = (XmlElement)node;
ele.SetAttribute("value", Xvalue);
doc.Save(Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
LogUtil.error("UpdateConfig保存配置出错:name=" + name + ",Xvalue=" + Xvalue + "," + ex.StackTrace);
}
}
///<summary>
///向.config文件的appKey结写入信息AppValue 保存设置
///</summary>
///<param name="AppKey">节点名</param>
///<param name="AppValue">值</param>
private static void SetValue(String AppKey, String AppValue)
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
if (xElem1 != null)
xElem1.SetAttribute("value", AppValue);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key", AppKey);
xElem2.SetAttribute("value", AppValue);
xNode.AppendChild(xElem2);
}
xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
LogUtil.error("SetValue保存配置出错:AppKey=" + AppKey + ",AppValue=" + AppValue + "," + ex.StackTrace);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Threading;
using System.Xml;
using System.Windows.Forms;
using log4net;
namespace OnlineStore.Common
{
public class ConfigAppSettings
{
//public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static int seq = 1;
public static int nextSeq()
{
if (seq.Equals(Int32.MaxValue))
{
LogUtil.info("seq当前值:" + seq + ",重置seq=0");
seq = 0;
}
Interlocked.Increment(ref seq);
return seq;
}
public static string GetValue(string keyStr, string storeStr)
{
string key = keyStr + storeStr;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
return GetValue(keyStr);
}
else
{
return config.AppSettings.Settings[key].Value;
}
}
public static decimal GetNumValue(string keyStr, string storeStr)
{
string key = keyStr + storeStr;
decimal a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
return GetNumValue(keyStr);
}
else
{
Decimal.TryParse(config.AppSettings.Settings[key].Value, out a);
}
return a;
}
public static int GetIntValue(string keyStr, string storeStr)
{
string key = keyStr + storeStr;
int a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
return GetIntValue(keyStr);
}
else
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
return a;
}
public static string GetValue(string key)
{
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.info("未找到配置:" + key + ",请检查配置是否完整!");
return "";
}
else
{
return config.AppSettings.Settings[key].Value;
}
}
public static decimal GetNumValue(string key)
{
decimal a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.info("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
Decimal.TryParse(config.AppSettings.Settings[key].Value, out a);
}
return a;
}
public static int GetIntValue(string key)
{
int a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.info("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
return a;
}
public static void SaveValue(string key, int value)
{
SaveValue(key, value.ToString());
}
public static void SaveValue(string key, string value)
{
try
{
if (key.Equals("") || value.Equals(""))
{
//return;
}
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
SetValue(key, value);
}
else
{
UpdateConfig(key, value);
}
}
catch (Exception ex)
{
LogUtil.error( "SaveValue保存配置出错:AppKey=" + key + ",AppValue=" + value + "," + ex.StackTrace);
}
}
/// <summary>
/// 更新配置文件信息
/// </summary>
/// <param name="name">配置文件字段名称</param>
/// <param name="Xvalue">值</param>
private static void UpdateConfig(string name, string Xvalue)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(Application.ExecutablePath + ".config");
XmlNode node = doc.SelectSingleNode(@"//add[@key='" + name + "']");
XmlElement ele = (XmlElement)node;
ele.SetAttribute("value", Xvalue);
doc.Save(Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
LogUtil.error( "UpdateConfig保存配置出错:name=" + name + ",Xvalue=" + Xvalue + "," + ex.StackTrace);
}
}
///<summary>
///向.config文件的appKey结写入信息AppValue 保存设置
///</summary>
///<param name="AppKey">节点名</param>
///<param name="AppValue">值</param>
private static void SetValue(String AppKey, String AppValue)
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
if (xElem1 != null)
xElem1.SetAttribute("value", AppValue);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key", AppKey);
xElem2.SetAttribute("value", AppValue);
xNode.AppendChild(xElem2);
}
xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
LogUtil.error( "SetValue保存配置出错:AppKey=" + AppKey + ",AppValue=" + AppValue + "," + ex.StackTrace);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace OnlineStore.Common
{
public class FormUtil
{
public static int GetIntValue(TextBox txt)
{
int value = 0;
try
{
value = int.Parse(txt.Text);
}
catch (Exception ex)
{
value = 0;
}
return value;
}
public static short GetShortValue(TextBox txt)
{
short value = 0;
try
{
value = short.Parse(txt.Text);
}
catch (Exception ex)
{
value = 0;
}
return value;
}
public static double getDoubleValue(TextBox txt)
{
double value = 0;
try
{
value = double.Parse(txt.Text);
}
catch (Exception ex)
{
value = 0;
}
return value;
}
public static short get16ShortValue(TextBox txt)
{
short value = 0;
try
{
value = System.Convert.ToInt16(txt.Text,16);
}
catch
{
value = 0;
}
return value;
}
public static string GetShowStr(double value)
{
string wStr = "";
if (value == (int)value)
{
wStr = string.Format("{0:d}", (int)value);
}
else
{
wStr = string.Format("{0:f}", value);
}
return wStr;
}
public static string GetSpanStr(TimeSpan span)
{
//return Convert.ToDateTime(span.ToString()).ToString("HH:mm:ss");
string seconds = Math.Round(span.TotalSeconds % 60, 1).ToString();
if (seconds.IndexOf(".") >= 0)
{
seconds = seconds.ToString().PadLeft(4, '0');
}
else
{
seconds = seconds.ToString().PadLeft(2, '0');
}
return span.Hours.ToString().PadLeft(2, '0') + ":" + span.Minutes.ToString().PadLeft(2, '0') + ":" + seconds;
}
public static bool GetBoolData(Dictionary<string, string> data, string key, bool defaultValue=false)
{
if (data.ContainsKey(key))
{
try
{
return Convert.ToBoolean(data[key]);
}
catch (Exception ex)
{
}
}
return defaultValue;
}
public static int GetIntData(Dictionary<string, string> data, string key, int defaultValue = 0)
{
if (data.ContainsKey(key))
{
try
{
return Convert.ToInt32(data[key]);
}
catch (Exception ex)
{
}
}
return defaultValue;
}
}
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Collections;
using System.Net;
using System.Net.Security;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Reflection;
using System.Net.NetworkInformation;
namespace Common
{
public class HttpHelper
{
// public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static string Post(string url, string paramData)
{
return Post(url, paramData, Encoding.UTF8);
}
//public static bool PingURLIP(string url, int ms=100)
//{
// string[] urlArray = url.Split('/');
// if (urlArray.Length > 3)
// {
// string ip = urlArray[2];
// Ping pingSender = new Ping();
// PingReply reply = pingSender.Send(ip, ms);//第一个参数为ip地址,第二个参数为ping的时间
// if (reply.Status == IPStatus.Success)
// {
// //通
// return true;
// }
// else
// {
// //不通
// return false;
// }
// }
// return true;
//}
/// <summary>
///
/// </summary>
/// <param name="url"></param>
/// <param name="operation"></param>
/// <param name="simulate">是否模拟服务器返回结果</param>
/// <returns></returns>
//public static Operation Post(string url, Operation operation, bool simulate)
//{
// try
// {
// ////如果Op=0或者Op=5,先拼Ip,不通不发送
// //if (operation.op < 0 || operation.op.Equals(5))
// //{
// // if (PingURLIP(url, 100).Equals(false))
// // {
// // return null;
// // }
// //}
// if (simulate)
// {//模拟服务器返回
// operation.status = 200;
// operation.data.Clear();
// operation.data.Add("posId", "A001");
// string pos = "D100-111#D102-222#D104-333";
// operation.data.Add("pos", pos);
// if (operation.op == 1 || operation.op == 2)
// {//入库或出库
// string json = JsonHelper.SerializeObject(operation);
// LogUtil.error("模拟HTTP服务器返回出库入库信息:" + json);
// return operation;
// }
// }
// else
// {
// string json = "";
// try
// {
// json = JsonHelper.SerializeObject(operation);
// }
// catch (Exception ex)
// {
// LogUtil.error("JsonHelper.SerializeObject(operation) 出错【operation.op=" + operation.op + "】" + ex);
// }
// string result = Post(url, json);
// if (!string.IsNullOrEmpty(result))
// {
// try
// {
// return JsonHelper.DeserializeJsonToObject<Operation>(result);
// }
// catch (Exception ex)
// {
// LogUtil.error("JsonHelper.DeserializeJsonToObject 出错【result=" + result + "】" + ex);
// }
// }
// }
// }
// catch (Exception ex)
// {
// LogUtil.error("Post 出错【operation.op=" + operation.op + "】:" + ex);
// }
// return null;
//}
public static string LastServerMsg = "";
public static string Post(string url, string paramData, Encoding encoding)
{
//if (PingURLIP(url, 100).Equals(false))
//{
// return null;
//}
if (paramData != "null" && paramData != null)
{
// LogUtil.debug(LOGGER, "HTTP POST to " + url + " \n\t >> " + paramData);
}
string result = "";
if (url.ToLower().IndexOf("https", System.StringComparison.Ordinal) > -1)
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback((sender, certificate, chain, errors) => { return true; });
}
try
{
var wc = new MyWebClient(5000);
if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
wc.Encoding = encoding;
result = wc.UploadString(url, "POST", paramData);
//LogUtil.info(result);
}
catch (Exception e)
{
LogUtil.error("POST ERROR:" + e.ToString());
}
if (!result.Contains("null") && result.Length != 0)
{
//LogUtil.debug(LOGGER,"receive << " + result);
}
LastServerMsg = DateTime.Now.ToLongTimeString() + " URL:" + url + "\r\n"
+ "发送:" + paramData + "\r\n"
+ "接收:" + result + "\r\n"
;
return result;
}
public static string Get(string url)
{
return Get(url, Encoding.UTF8);
}
public static string Get(string url, Encoding encoding)
{
try
{
LogUtil.debug("HTTP GET FROM: " + url);
var wc = new WebClient { Encoding = encoding };
var readStream = wc.OpenRead(url);
using (var sr = new StreamReader(readStream, encoding))
{
var result = sr.ReadToEnd();
LogUtil.debug("receive << " + result);
return result;
}
}
catch (Exception e)
{
LogUtil.error("HTTP GET ERROR:" +url+ e.Message);
}
return "";
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Common
{
public class IniFileHelper
{
[System.Runtime.InteropServices.DllImport("kernel32")]
//section:要读取的段落名
//key: 要读取的键点击打开链接点击打开链接
//defVal: 读取异常的情况下的缺省值
//retVal: key所对应的值,如果该key不存在则返回空值
//size: 值允许的大小
//filePath: INI文件的完整路径和文件名
private static extern int GetPrivateProfileString(string section, string key, string defVal, StringBuilder retVal, int size, string filePath);
[System.Runtime.InteropServices.DllImport("kernel32")]
//section: 要写入的段落名
//key: 要写入的键,如果该key存在则覆盖写入
//val: key所对应的值
//filePath: INI文件的完整路径和文件名
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
/// <summary>
/// 读取INI文件
/// </summary>
/// <param name="section">项目名称(如 [section] )</param>
/// <param name="skey">键</param>
/// <param name="path">路径</param>
public static string ReadValue(string section, string skey, string path)
{
StringBuilder temp = new StringBuilder(500);
GetPrivateProfileString(section, skey, "", temp, 500, path);
return temp.ToString();
}
/// <summary>
/// 写入ini文件
/// </summary>
/// <param name="section">项目名称</param>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <param name="path">路径</param>
public static void WriteValue(string section, string key, string value, string path)
{
WritePrivateProfileString(section, key, value, path);
}
}
}
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
namespace Common
{
/// <summary>
/// Json帮助类
/// </summary>
public class JsonHelper
{
/// <summary>
/// 将对象序列化为JSON格式
/// </summary>
/// <param name="o">对象</param>
/// <returns>json字符串</returns>
public static string SerializeObject(object o)
{
string json = JsonConvert.SerializeObject(o);
return json;
}
/// <summary>
/// 解析JSON字符串生成对象实体
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json字符串(eg.{"ID":"112","Name":"石子儿"})</param>
/// <returns>对象实体</returns>
public static T DeserializeJsonToObject<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(T));
T t = o as T;
return t;
}
/// <summary>
/// 解析JSON数组生成对象实体集合
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json数组字符串(eg.[{"ID":"112","Name":"石子儿"}])</param>
/// <returns>对象实体集合</returns>
public static List<T> DeserializeJsonToList<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
List<T> list = o as List<T>;
return list;
}
/// <summary>
/// 反序列化JSON到给定的匿名对象.
/// </summary>
/// <typeparam name="T">匿名对象类型</typeparam>
/// <param name="json">json字符串</param>
/// <param name="anonymousTypeObject">匿名对象</param>
/// <returns>匿名对象</returns>
public static T DeserializeAnonymousType<T>(string json, T anonymousTypeObject)
{
T t = JsonConvert.DeserializeAnonymousType(json, anonymousTypeObject);
return t;
}
/// <summary>
///写入JSON文件
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="ts"></param>
/// <param name="fileName"></param>
public static void WriteJson<T>(List<T> ts, string fileName) where T : class
{
try
{
string path = fileName + ".json";
string output = JsonConvert.SerializeObject(ts,Formatting.Indented);
File.WriteAllText(path, output);
}
catch (Exception e)
{
LogUtil.error(e.Message + "/r/n" + e.StackTrace);
}
}
/// <summary>
/// 读取JSON文件
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="ts"></param>
/// <param name="fileName"></param>
public static List<T> ReadJson<T>(string fileName) where T : class
{
try
{
string path =fileName + ".json";
StreamReader streamReader = new StreamReader(path);
string jsonStr = streamReader.ReadToEnd();
List<T> jsonObj = DeserializeJsonToList<T>(jsonStr);
streamReader.Close();
return jsonObj;
}
catch (Exception e)
{
LogUtil.error(e.Message + "/r/n" + e.StackTrace);
return null;
}
}
}
///// <summary>
///// 与服务器通信用对象
///// </summary>
//public class Operation
//{
// private string _cid = "";
// public string cid
// {
// get { return _cid; }
// set { _cid = value; }
// }
// public int seq { get; set; }
// public int op { get; set; }
// public int status { get; set; }
// private string _error = "";
// public string error
// {
// get { return _error; }
// set { _error = value; }
// }
// private Dictionary<string, string> _data = new Dictionary<string,string>();
// public Dictionary<string, string> data {
// get { return _data; }
// set { _data = value; }
// }
//}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using System.Reflection;
using System.Drawing;
namespace Common
{
public class LogUtil
{
public delegate void ShowLog(string msg,Color color);
public static readonly ILog LOGGER = LogManager.GetLogger("AppLog");
public static Dictionary<int, DateTime> lastErrorLogTime = new Dictionary<int, DateTime>();
public static System.Windows.Forms.RichTextBox logBox = null;
public static int showCount = 20;
public static bool debug_opened = false;
public static void info(ILog log, string msg)
{
if (log == null)
{
return;
}
log.Info(msg);
AddToBox(msg, Color.Black);
//clear();
}
public static void info(ILog log, string msg, Color color)
{
log.Info(msg);
AddToBox(msg, color);
}
public static void debug(ILog log, string msg, Color color)
{
log.Debug(msg);
if (debug_opened)
{
AddToBox(msg, color);
}
}
public static void debug(ILog log, string msg)
{
log.Debug(msg);
if (debug_opened)
{
AddToBox(msg, Color.Gray);
}
}
public static void error(string errorMsg, int type)
{
if (lastErrorLogTime.ContainsKey(type))
{
TimeSpan span = DateTime.Now - lastErrorLogTime[type];
if (span.TotalSeconds > 10)
{
lastErrorLogTime.Remove(type);
lastErrorLogTime.Add(type, DateTime.Now);
error(LOGGER, errorMsg);
}
}
else
{
lastErrorLogTime.Add(type, DateTime.Now);
error(LOGGER, errorMsg);
}
}
public static void error(ILog log, string errorMsg, Exception ex = null)
{
if (errorMsg.Trim().Equals(""))
{
return;
}
if (ex == null)
{
log.Error(errorMsg);
}
else
{
log.Error(errorMsg, ex);
}
AddToBox(errorMsg, Color.Red);
}
private static void AddToBox(string msg, Color color)
{
try
{
ShowLogPro(msg, color);
}
catch (Exception ex)
{
LOGGER.Error("出错:", ex);
}
}
private static List<string> logList = new List<string>();
public static string LastText = "";
private static void ShowLogPro(string msg, Color color)
{
try
{
if (logList.Count > 0)
{
// logList.RemoveAt(0);
}
if (logList.Count >= showCount)
{
logList.RemoveAt(0);
}
string text = "";
foreach (string str in logList)
{
text += str;
}
System.DateTime now = System.DateTime.Now;
logList.Add(now.ToLongTimeString() + " " + msg + Environment.NewLine);
if (logBox == null)
{
return;
}
LastText = text;
if (logBox.Visible)
{
logBox.Text = text;
// logBox.Focus(); //使文本框获取焦点
logBox.AppendText(now.ToLongTimeString() + " " + msg + Environment.NewLine); //增加文本
TimeSpan span = DateTime.Now - lastTime;
if (span.TotalSeconds > 3000000)
{
lastTime = DateTime.Now;
logBox.Select(logBox.Text.Length, 0); //设置光标的位置到文本尾
logBox.ScrollToCaret(); //滚动到控件光标处
}
}
}
catch (Exception ex)
{
LOGGER.Error("出错:" + ex.ToString());
}
}
private static DateTime lastTime = DateTime.Now;
public static void UpdateLogbox()
{
if (logBox != null && logBox.Visible)
{
logBox.Text = LastText;
TimeSpan span = DateTime.Now - lastTime;
if (span.TotalSeconds > 3000000)
{
lastTime = DateTime.Now;
logBox.Select(logBox.Text.Length, 0); //设置光标的位置到文本尾
logBox.ScrollToCaret(); //滚动到控件光标处
}
}
}
public static void ClearLog()
{
if (logBox != null)
{
LastText = "";
logList.Clear();
logBox.Text = "";
}
}
public static void debug(string msg)
{
debug(LOGGER, msg);
}
public static void error(string errorMsg, Exception ex = null)
{
error(LOGGER, errorMsg, ex);
}
public static void info(string msg)
{
info(LOGGER, msg);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
namespace Common
{
public class MyWebClient:WebClient
{
private int _timeout;
/// <summary>
/// 超时时间(毫秒)
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public MyWebClient()
{
this._timeout = 60000;
}
public MyWebClient(int timeout)
{
this._timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
var result = base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace OnlineStore.Common
{
/// <summary>
/// 扫码枪连接类
/// </summary>
public class ScanSocket
{
private readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public event ScanRevice OnScanRevice;
public delegate void ScanRevice(string message);
/// <summary>
/// 扫码枪链接
/// </summary>
private TcpClient scannerSocket;
/// <summary>
/// 扫描枪 是否开始运行
/// </summary>
public bool isScannerRun = false;
/// <summary>
/// 连接扫码枪
/// </summary>
/// <param name="serverIp">扫码枪Ip</param>
/// <param name="port">扫码枪端口号</param>
/// <returns>是否连接成功</returns>
public bool ConnectScanner(string serverIp, int port)
{
return StartScanner(serverIp, port, false);
}
/// <summary>
/// 停止扫码枪
/// </summary>
public void StopScanner()
{
try
{
scannerSocket.close();
isScannerRun = false;
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "出错:" + ex);
}
}
/// <summary>
/// 发送扫码命令开始扫码
/// </summary>
public void BeginScannering()
{
string str = ConfigAppSettings.GetValue(Setting_Init.scanner_start_command);
if (str.Equals(""))
{
str = "S";
}
scannerSocket.send(str);
//onCodeReceived("AAAA");
}
/// <summary>
/// 开启扫码枪
/// </summary>
private bool StartScanner(string serverIp, int port, bool isMustCon)
{
bool result = true;
try
{
if (!isScannerRun || isMustCon)
{
if (scannerSocket == null)
{
scannerSocket = new TcpClient();
}
result = scannerSocket.connect(serverIp, port, new TcpClient.HandleMessage(onCodeReceived));
if (result)
{
isScannerRun = true;
}
}
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "出错:" + ex);
}
return result;
}
/// <summary>
/// 扫码枪数据接收
/// </summary>
/// <param name="message"></param>
private void onCodeReceived(string message)
{
try
{
message = ScanCodeManager.ReplaceCode(message);
if (OnScanRevice != null)
{
OnScanRevice.Invoke(message);
}
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "出错:" + ex.ToString());
}
}
}
}
using System;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using log4net;
namespace OnlineStore.Common
{
public class TcpServer
{
//public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// 接受消息时的间隔
/// </summary>
public static int ReviceMsgMS = 100;
private Thread m_serverThread;
private Socket m_serverSocket;
public delegate void ReviceMsg(Client client, string Msg);
public event ReviceMsg ReviceMsgEvent;
private delegate void ReceiveMessageDelegate(Client client);
public event AcceptClientDelegate AcceptClientEvent;
public delegate void AcceptClientDelegate(Client client);
ReceiveMessageDelegate receiveMessageDelegate;
private bool isRun = true;
private int serverPort = 0;
private void logLocalIp()
{
string[] addresses = GetLocalAddresses();
string iplist = "本机IP:[";
if (addresses.Length > 0)
{
for (int i = 0; i < addresses.Length; i++)
{
if (addresses.Length != 0)
{
iplist = iplist + " " + addresses[i];
}
}
}
LogUtil.info(iplist + "]");
}
/// <summary>
/// 开始服务
/// </summary>
public void Start(int m_serverPort)
{
try
{
isRun = true;
m_serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, m_serverPort);
this.serverPort = m_serverPort;
m_serverSocket.Bind(localEndPoint);
m_serverSocket.Listen(10);
m_serverThread = new Thread(new ThreadStart(ReceiveAccept));
m_serverThread.Start();
LogUtil.info(" Server start listen : " + m_serverPort);
logLocalIp();
//this.AddRunningInfo(">> " + DateTime.Now.ToString() + " Server started.");
}
catch (SocketException se)
{
throw new Exception(se.Message);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
/// <summary>
/// 停止服务
/// </summary>
public void Stop()
{
try
{
isRun = false;
m_serverThread.Interrupt(); // 线程终止
m_serverSocket.Close(); // Socket Close
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
private void ReceiveAccept()
{
while (isRun)
{
Client client = new Client();
try
{
client.ClientSocket = m_serverSocket.Accept();
IPEndPoint clientipe = (IPEndPoint)client.ClientSocket.RemoteEndPoint;
client.ipAdd = clientipe.Address;
LogUtil.info("[" + serverPort + "]有新的客户端链接上:[" + client.ipAdd.ToString() + "]");
AcceptClientEvent?.Invoke(client);
receiveMessageDelegate = new ReceiveMessageDelegate(ReceiveMessages);
receiveMessageDelegate.BeginInvoke(client, ReceiveMessagesCallback, "");
}
catch (Exception ex)
{
LogUtil.error("ReceiveAccept方法,客户端【" + client.ipAdd.ToString() + "】:" + ex.Message);
//throw new Exception(ex.Message);
}
}
}
// private StringBuilder sb = new StringBuilder(); //这个是用来保存:接收到了的,但是还没有结束的消息
private int receiveBufferSize = 1024;
private string terminateString = ";";
public void ReceiveMessages(Client client) //这个函数会被以线程方式运行
{
try
{
StringBuilder sb = new StringBuilder();
Socket socket = (Socket)client.ClientSocket;
while (true)
{
byte[] buffer = new byte[receiveBufferSize]; //buffer大小,此处为1024
int receivedSize = socket.Receive(buffer);
if (receivedSize > 0)
{
string rawMsg = Encoding.ASCII.GetString(buffer, 0, receivedSize);
int rnFixLength = terminateString.Length; //这个是指消息结束符的长度,此处为\r\n
for (int i = 0; i < rawMsg.Length;) //遍历接收到的整个buffer文本
{
if (i <= rawMsg.Length - rnFixLength)
{
if (rawMsg.Substring(i, rnFixLength) != terminateString)//非消息结束符,则加入sb
{
sb.Append(rawMsg[i]);
i++;
}
else
{
this.ReviceMsgEvent.Invoke(client, sb.ToString());//找到了消息结束符,触发消息接收完成事件
sb = new StringBuilder();
i += rnFixLength;
}
}
else
{
sb.Append(rawMsg[i]);
i++;
}
}
}
Thread.Sleep(ReviceMsgMS);
}
}
catch (SocketException e)
{
LogUtil.error("客户端{" + client.ipAdd.ToString() + "]:" + e.ToString(), 106);
}
catch (Exception ex)
{
LogUtil.error("客户端{" + client.ipAdd.ToString() + "]:" + ex.ToString(), 105);
}
}
//private void ReceiveMessages(Client client)
//{
// try
// {
// while (true)
// {
// byte[] receiveBuffer = new byte[1024];
// //int size = ;
// int size = client.ClientSocket.Receive(receiveBuffer);
// string strReceiveData = Encoding.ASCII.GetString(receiveBuffer, 0, size);
// if (!string.IsNullOrEmpty(strReceiveData))
// {
// LogUtil.info(LOGGER, "收到数据:" + strReceiveData);
// // this.AddRunningInfo(">> Receive data from [" + client.ClientSocket.RemoteEndPoint.ToString()+ "]:" + strReceiveData);
// string strSendData = "OK. The content is:" + strReceiveData;
// //LogUtil.info(LOGGER, "OK. The content is:" + strReceiveData);
// int sendBufferSize = Encoding.Unicode.GetByteCount(strSendData);
// byte[] sendBuffer = new byte[sendBufferSize];
// sendBuffer = Encoding.Unicode.GetBytes(strSendData);
// client.ClientSocket.Send(sendBuffer);
// }
// }
// }
// catch (SocketException e)
// {
// LogUtil.error(LOGGER, e.ToString());
// }
// catch (Exception ex)
// {
// LOGGER.Error(ex.ToString());
// }
//}
private void ReceiveMessagesCallback(IAsyncResult AR)
{
try
{
receiveMessageDelegate.EndInvoke(AR);
}
catch (Exception ex)
{
LogUtil.error(ex.ToString());
}
}
/// <summary>
/// 获取本机地址列表
/// </summary>
public string[] GetLocalAddresses()
{
// 获取主机名
string strHostName = Dns.GetHostName();
// 根据主机名进行查找
IPHostEntry iphostentry = Dns.GetHostEntry(strHostName);
string[] retval = new string[iphostentry.AddressList.Length];
int i = 0;
foreach (IPAddress ipaddress in iphostentry.AddressList)
{
if (ipaddress.AddressFamily != AddressFamily.InterNetworkV6)
{
retval[i] = ipaddress.ToString();
i++;
}
}
return retval;
}
}
/// <summary>
/// 客户端会话信息类
/// </summary>
public class Client
{
Socket m_clientSocket;
public Client() { }
public IPAddress ipAdd { get; set; }
public Socket ClientSocket
{
get { return m_clientSocket; }
set { this.m_clientSocket = value; }
}
}
}
文件属性发生变化
类型,说明,名称,属性值,设备名称,默认值,描述,电器定义,代码定义,SlaveID
PRO,IO模块对应的DI数量,IO_DILength,192.168.103.21#8;192.168.103.22#8,,,,,,
PRO,模块对应的DO数量,IO_DOLength,192.168.103.21#8;192.168.103.22#8,,,,,,
PRO,IO模块IP,PRO_AOI_IP_1,192.168.103.21,,,,,,
PRO,IO模块IP,PRO_AOI_IP_2,192.168.103.22,,,,,,
,,,,,,,,,
DI,D2-任务应答,LIFT_D2_Response,0,PRO_AOI_IP_1,0,D2-任务应答,X21,X21,0
DI,D2-到达1F,LIFT_D2_AtFirst,1,PRO_AOI_IP_1,0,D2-到达1F,X22,X22,0
DI,D2-到达3F,LIFT_D2_AtThird,2,PRO_AOI_IP_1,0,D2-到达3F,X23,X23,0
DI,D2-到达4F,LIFT_D2_AtFourth,3,PRO_AOI_IP_1,0,D2-到达4F,X24,X24,0
DI,D2-门已开,LIFT_D2_DoorOpen,4,PRO_AOI_IP_1,0,D2-门已开,X25,X25,0
DI,D2-故障中,LIFT_D2_InFault,5,PRO_AOI_IP_1,0,D2-故障中,X26,X26,0
DI,D2-运行中,LIFT_D2_InRun,6,PRO_AOI_IP_1,0,D2-运行中,X27,X27,0
,,,,,,,,,
DO,D2-AGV请求,LIFT_D2_AGVRequest,0,PRO_AOI_IP_1,0,D2-AGV请求,Y21,Y21,0
DO,D2-AGV离开,LIFT_D2_AGVLeave,1,PRO_AOI_IP_1,0,D2-AGV离开,Y22,Y22,0
DO,D2-AGV呼叫1F,LIFT_D2_FirstCall,2,PRO_AOI_IP_1,0,D2-AGV呼叫1F,Y23,Y23,0
DO,D2-AGV呼叫3F,LIFT_D2_ThirdCall,3,PRO_AOI_IP_1,0,D2-AGV呼叫3F,Y24,Y24,0
DO,D2-AGV呼叫4F,LIFT_D2_FourthCall,4,PRO_AOI_IP_1,0,D2-AGV呼叫4F,Y25,Y25,0
DO,D2-送料信号1F,LIFT_D2_RunToFirst,5,PRO_AOI_IP_1,0,D2-送料信号1F,Y26,Y26,0
DO,D2-送料信号3F,LIFT_D2_RunToThird,6,PRO_AOI_IP_1,0,D2-送料信号3F,Y27,Y27,0
DO,D2-送料信号4F,LIFT_D2_RunToFourth,7,PRO_AOI_IP_1,0,D2-送料信号4F,Y27,Y27,0
,,,,,,,,,
[]
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<agvs>
<agv id="49" ip="10.85.199.81">
<name>10号车</name>
<!--负责区域:D,C,Air_C-->
<ResponsAreas>
<Area>D</Area>
</ResponsAreas>
<!--是否调用-->
<IsUse>False</IsUse>
<UseFleet>true</UseFleet>
<Authorization>Basic ZGlzdHJpYnV0b3I6NjJmMmYwZjFlZmYxMGQzMTUyYzk1ZjZmMDU5NjU3NmU0ODJiYjhlNDQ4MDY0MzNmNGNmOTI5NzkyODM0YjAxNA==</Authorization>
<IO_GUIDs>
<IO_GUID index="0">6ad07e3a-e0e9-11eb-a184-0001299981d4</IO_GUID>
<IO_GUID index="1">3b5c0497-e2f2-11eb-95df-000129922ca6</IO_GUID>
<IO_GUID index="2">4e49e4c8-e2f2-11eb-95df-000129922ca6</IO_GUID>
</IO_GUIDs>
</agv>
</agvs>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<root>
<!--最小充电电量,小于该电量将不会执行任务-->
<min>20</min>
<!--空闲车辆需要充电的电量-->
<mid>50</mid>
<!--充电完成电量-->
<max>90</max>
<piles>
<pile id ="0">
<!--名称-->
<name>AutoCharge1</name>
<!--别名-->
<alicename>充电位1</alicename>
<!--固定充电桩-->
<fixed>true</fixed>
<!--固定充电桩为true,取第一个;false则判断所有agv.填写AGV编号-->
<agvs>
<agv>49</agv>
</agvs>
</pile>
</piles>
</root>
此文件类型无法预览
<?xml version="1.0" encoding="utf-8" ?>
<tasks>
<task id ="0">
<name>Init</name>
<alicename>初始化</alicename>
<guid>2bcd29b8-e2f2-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>None</type>
</task>
<task id ="1">
<name>Standby</name>
<alicename>待机位</alicename>
<guid>501522b3-e2f2-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>None</type>
</task>
<task id ="2">
<name>AutoCharge</name>
<alicename>充电位</alicename>
<guid>40c17cb4-e2f2-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>None</type>
</task>
<task id ="3">
<name>Enter</name>
<alicename>进料</alicename>
<guid>31a3a69e-e310-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>InOut</type>
</task>
<task id ="4">
<name>Leave</name>
<alicename>出料</alicename>
<guid>ba68ea32-e310-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>InOut</type>
</task>
<task id ="5">
<name>CheckShelf</name>
<alicename>负载检查</alicename>
<guid>7f6edf46-e316-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>None</type>
</task>
<task id ="6">
<name>D1</name>
<alicename>移动到D1线</alicename>
<guid>03925a62-e2fa-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="7">
<name>D2</name>
<alicename>移动到D2线</alicename>
<guid>17419a7e-e2fa-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="8">
<name>D3</name>
<alicename>移动到D3线</alicename>
<guid>39052eb5-e2fa-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="9">
<name>D4</name>
<alicename>移动到D4线</alicename>
<guid>4cbec837-e2fa-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="10">
<name>D5</name>
<alicename>移动到D5线</alicename>
<guid>63241a92-e2fa-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="11">
<name>D6</name>
<alicename>移动到D6线</alicename>
<guid>d264a9c2-e2fb-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="12">
<name>D7</name>
<alicename>移动到D7线</alicename>
<guid>e2d00611-e2fb-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="13">
<name>D8</name>
<alicename>移动到D8线</alicename>
<guid>f636e5a8-e2fb-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="14">
<name>D9</name>
<alicename>移动到D9线</alicename>
<guid>164a436d-e2fc-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="15">
<name>D10</name>
<alicename>移动到D10线</alicename>
<guid>663d8278-e2fc-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="16">
<name>D11</name>
<alicename>移动到D11线</alicename>
<guid>7e0996dd-e2fc-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="17">
<name>D12</name>
<alicename>移动到D12线</alicename>
<guid>93bc0500-e2fc-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="18">
<name>D13</name>
<alicename>移动到D13线</alicename>
<guid>b2e5d20e-e2fc-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="19">
<name>D14</name>
<alicename>移动到D14线</alicename>
<guid>dd1da0b8-e2fc-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="20">
<name>D15</name>
<alicename>移动到D15线</alicename>
<guid>f1109e49-e2fc-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="21">
<name>D16</name>
<alicename>移动到D16线</alicename>
<guid>6e984dd1-e30a-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="22">
<name>T01</name>
<alicename>移动到T1线</alicename>
<guid>532c7cda-e2f4-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="23">
<name>T02</name>
<alicename>移动到T2线</alicename>
<guid>27dc2449-e2f9-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="24">
<name>T03</name>
<alicename>移动到T3线</alicename>
<guid>576a579b-e2f9-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="25">
<name>T04</name>
<alicename>移动到T4线</alicename>
<guid>7c474d94-e2f9-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="26">
<name>T05</name>
<alicename>移动到T5线</alicename>
<guid>9779e5bb-e2f9-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="27">
<name>T06</name>
<alicename>移动到T6线</alicename>
<guid>a6a092a2-e2f9-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="28">
<name>T07</name>
<alicename>移动到T7线</alicename>
<guid>ba68467a-e2f9-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="29">
<name>T08</name>
<alicename>移动到T8线</alicename>
<guid>d4e59d24-e2f9-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="30">
<name>T09</name>
<alicename>移动到T9线</alicename>
<guid>ed9b0352-e2f9-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>Move</type>
</task>
<task id ="31">
<name>Adjust</name>
<alicename>调宽</alicename>
<guid>45f417f6-e316-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>None</type>
</task>
<task id ="32">
<name>治具智能仓储</name>
<alicename>治具智能仓储</alicename>
<guid>111486eb-e3b4-11eb-8a99-94c691a7387d</guid>
<!--任务类型:None,Move,Dock,InOut-->
<type>None</type>
</task>
</tasks>
\ No newline at end of file
using Common;
namespace DeviceLibrary.Context
{
public class Context
{
ServiceContext serviceContext = new ServiceContext();
LineManager lineManager = new LineManager();
public void Init()
{
LiftContext.Init();
lineManager.Init();
IOManager.Init();
}
public void Open()
{
string baseurl = AppConfigHelper.GetValue(SettingString.ServiceBaseUrl);
serviceContext.Open(baseurl);
}
public void Close()
{
serviceContext.Close();
}
}
}

using DeviceLibrary.Models;
using DeviceLibrary.Models.Service.Request;
using DeviceLibrary.Models.Service.Response;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace DeviceLibrary.Context
{
public class LiftContext
{
static List<LiftInfo> elevatorInfos;
public static void Init()
{
string[] lifts = Common.AppConfigHelper.GetValue(Common.SettingString.Lift_Ids).Split(',');
string buff = Common.AppConfigHelper.GetValue(Common.SettingString.Lift_Buffs);
elevatorInfos = Common.JsonHelper.DeserializeJsonToList<LiftInfo>(buff);
if (elevatorInfos == null)
{
elevatorInfos = new List<LiftInfo>();
foreach (var item in lifts)
{
elevatorInfos.Add(new LiftInfo(item));
}
}
else
{
if (!lifts.Length.Equals(elevatorInfos.Count))
{
elevatorInfos = new List<LiftInfo>();
foreach (var item in lifts)
{
elevatorInfos.Add(new LiftInfo(item));
}
}
else
{
foreach (var item in lifts)
{
LiftInfo liftInfo = elevatorInfos.Find(s => s.liftId.Equals(item));
if (liftInfo == null)
{
elevatorInfos = new List<LiftInfo>();
foreach (var lift in lifts)
{
elevatorInfos.Add(new LiftInfo(lift));
}
break;
}
}
}
}
}
public static string ToListInfos()
{
StringBuilder sb = new StringBuilder();
foreach (var item in elevatorInfos)
{
sb.Append(Common.JsonHelper.SerializeObject(item));
sb.Append("\r\n");
sb.Append(item.OccupiedInfo());
sb.Append("\r\n");
sb.Append("\r\n");
}
return sb.ToString();
}
static object savelock = new object();
/// <summary>
/// 保存所有电梯状态
/// </summary>
static void SaveLiftInfo()
{
if (Monitor.TryEnter(savelock, 1000))
{
try
{
Common.AppConfigHelper.SaveValue(Common.SettingString.Lift_Buffs, Common.JsonHelper.SerializeObject(elevatorInfos));
}
catch (Exception e)
{
Common.LogUtil.error("SaveLiftInfo", e);
}
finally
{
Monitor.Exit(savelock);
}
}
else
{
Common.LogUtil.error($"SaveLiftInfo Fail:{Common.JsonHelper.SerializeObject(elevatorInfos)}");
}
}
/// <summary>
/// 请求电梯
/// </summary>
/// <param name="liftId"></param>
/// <returns></returns>
public static bool RequestSendIn(SendInInfo lift, out string msg)
{
msg = "ok";
if (elevatorInfos.Count == 0)
{
msg = "系统未添加电梯信息";
return false;
}
LiftInfo elevatorInfo = elevatorInfos.Find(s => s.liftId.Equals(lift.liftId));
if (elevatorInfo == null)
{
msg = $"系统不存在该电梯标识:{lift.liftId}";
return false;
}
bool rtn = elevatorInfo.RequestUse(lift, out msg);
SaveLiftInfo();
return rtn;
}
/// <summary>
/// 更新客户端使用电梯信息
/// </summary>
/// <param name="clientStatus"></param>
/// <param name="msg"></param>
public static void UpdateClient(ClientStatus clientStatus, out string msg)
{
msg = "ok";
if (elevatorInfos.Count == 0)
{
msg = "系统未添加电梯信息";
return;
}
LiftInfo elevatorInfo = elevatorInfos.Find(s => s.liftId.Equals(clientStatus.liftId));
if (elevatorInfo == null)
{
msg = $"系统不存在该电梯标识:{clientStatus.liftId}";
return;
}
elevatorInfo.UpdateClient(clientStatus);
}
/// <summary>
/// 获取电梯状态
/// </summary>
/// <param name="clientStatus"></param>
/// <param name="msg"></param>
/// <returns></returns>
public static Status GetLiftStatus(ClientStatus clientStatus, out string msg)
{
msg = "ok";
if (elevatorInfos.Count == 0)
{
msg = "系统未添加电梯信息";
return new Status();
}
LiftInfo elevatorInfo = elevatorInfos.Find(s => s.liftId.Equals(clientStatus.liftId));
if (elevatorInfo == null)
{
msg = $"系统不存在该电梯标识:{clientStatus.liftId}";
return new Status();
}
return elevatorInfo.Status;
}
/// <summary>
/// 小车离开
/// </summary>
/// <param name="doorInfo"></param>
/// <param name="msg"></param>
public static void AGVLeave(DoorInfo doorInfo, out string msg)
{
msg = "ok";
if (elevatorInfos.Count == 0)
{
msg = "系统未添加电梯信息";
return;
}
LiftInfo elevatorInfo = elevatorInfos.Find(s => s.liftId.Equals(doorInfo.liftId));
if (elevatorInfo == null)
{
msg = $"系统不存在该电梯标识:{doorInfo.liftId}";
return;
}
bool rtn = elevatorInfo.AGVLeave(doorInfo);
msg = rtn ? "ok" : "fail, " + elevatorInfo.OccupiedInfo();
SaveLiftInfo();
}
/// <summary>
/// 小车呼叫
/// </summary>
/// <param name="doorInfo"></param>
/// <param name="msg"></param>
public static void AGVCall(DoorInfo doorInfo, out string msg)
{
msg = "ok";
if (elevatorInfos.Count == 0)
{
msg = "系统未添加电梯信息";
return;
}
LiftInfo elevatorInfo = elevatorInfos.Find(s => s.liftId.Equals(doorInfo.liftId));
if (elevatorInfo == null)
{
msg = $"系统不存在该电梯标识:{doorInfo.liftId}";
return;
}
bool rtn = elevatorInfo.AGVCall(doorInfo);
msg = rtn ? "ok" : "fail, " + elevatorInfo.OccupiedInfo();
SaveLiftInfo();
}
}
}
using System;
using DeviceLibrary.Service;
using System.ServiceModel.Web;
using Common;
namespace DeviceLibrary.Context
{
public class ServiceContext
{
private LiftService liftService = new LiftService();
public void Open(string baseurl)
{
liftService.Open(baseurl);
}
public void Close()
{
liftService.Close();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F9619F07-15F1-4E59-A383-3871952BBB79}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DeviceLibrary</RootNamespace>
<AssemblyName>DeviceLibrary</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Asa.IOModule.AIOBOX, Version=2.3.0.4, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Asa.IOModule.AIOBOX.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>.\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL" />
<Reference Include="RestSharp">
<HintPath>.\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Activation" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="bean\Line\LineBean.cs" />
<Compile Include="Context\Context.cs" />
<Compile Include="Context\LiftContext.cs" />
<Compile Include="Context\ServiceContext.cs" />
<Compile Include="IO\AIOBOX\AIOBOXManager.cs" />
<Compile Include="IO\IOManager.cs" />
<Compile Include="IO\KangNaiDe\KNDManager.cs" />
<Compile Include="IO\KangNaiDe\MasterTcpClient.cs" />
<Compile Include="manager\LineManager.cs" />
<Compile Include="Models\ClientInfo.cs" />
<Compile Include="Models\LiftInfo.cs" />
<Compile Include="Models\Service\Request\DoorInfo.cs" />
<Compile Include="Models\Service\Request\SendInInfo.cs" />
<Compile Include="Models\Service\Request\ClientStatus.cs" />
<Compile Include="Models\Service\Response\Status.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Service\IService.cs" />
<Compile Include="Service\Services.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{bafeafe6-04e2-48ee-8845-bfc7ea3e3c21}</Project>
<Name>Common</Name>
</ProjectReference>
<ProjectReference Include="..\LoadCVSLibrary\LoadCSVLibrary.csproj">
<Project>{064bebf5-8faa-4ea2-a5f3-a06e6e7d9251}</Project>
<Name>LoadCSVLibrary</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Config\agvinfos.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Config\chargeinfos.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Config\nodeinfos.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Config\taskinfos.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="Config\LineConfig.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using Common;
using LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace DeviceLibrary
{
public abstract class IOManager
{
public static IOManager instance = null;
public abstract void ConnectionIOList(List<string> dIODeviceNameList);
#region KNDIO
public static void IOMove(string ioType, IO_VALUE ioValue)
{
if (LineManager.Config.DOList.ContainsKey(ioType))
{
int trytimes = 5;
ConfigIO configIo = LineManager.Config.DOList[ioType];
instance.WriteSingleDO(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr(), ioValue);
Thread.Sleep(60);
while(trytimes>0 && !IOValue(ioType).Equals(ioValue))
{
instance.WriteSingleDO(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr(), ioValue);
trytimes--;
}
}
else
{
LogUtil.error("没有DO=" + ioType);
}
}
public static void CIOMove(string ioType,IO_VALUE ioValue)
{
if (!IOValue(ioType).Equals(ioValue))
{
IOMove(ioType, ioValue);
}
}
public static IO_VALUE IOValue(string ioType)
{
IO_VALUE ioValue = IO_VALUE.None;
if (LineManager.Config.DIList.ContainsKey(ioType))
{
ConfigIO configIo = LineManager.Config.DIList[ioType];
ioValue = instance.GetDIValue(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr());
//UpdateDoValue(ioType, ioValue);
}
else if (LineManager.Config.DOList.ContainsKey(ioType))
{
ConfigIO configIo = LineManager.Config.DOList[ioType];
ioValue = instance.GetDOValue(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr());
}
else
{
LogUtil.error("没有DO=" + ioType);
}
return ioValue;
}
public static IO_VALUE DOValue(string ioType )
{
IO_VALUE ioValue = IO_VALUE.None;
ConfigIO configIo = GetDO(ioType );
if (configIo != null)
{
ioValue = instance.GetDOValue(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr());
}
else
{
LogUtil.error("没有DO=" + ioType);
}
return ioValue;
}
public static IO_VALUE DIValue(string ioType )
{
IO_VALUE ioValue = IO_VALUE.None;
ConfigIO configIo = GetDI(ioType );
if (configIo != null)
{
ioValue = instance.GetDIValue(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr());
}
else
{
LogUtil.error("未找到 DI [" + ioType + "] ");
}
return ioValue;
}
private static ConfigIO GetDI(string ioType )
{
ConfigIO configIo = null;
if (LineManager.Config.DIList.ContainsKey(ioType))
{
return LineManager.Config.DIList[ioType];
}
return configIo;
}
private static ConfigIO GetDO(string ioType )
{
ConfigIO configIo = null;
if (LineManager.Config.DOList.ContainsKey(ioType))
{
return LineManager.Config.DOList[ioType];
}
return configIo;
}
#endregion
public static void Init()
{
bool isAIOBox = AppConfigHelper.GetIntValue(SettingString.UseAIOBOX).Equals(1);
if (isAIOBox)
{
instance = new AIOBOXManager();
}
else
{
instance = new KNDManager();
}
}
public abstract void ReadAllDI(string deviceName, byte slaveId);
public abstract void ReadAllDO(string deviceName, byte slaveId);
public abstract void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value, int time);
public abstract void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value);
public abstract IO_VALUE GetDIValue(string deviceName, byte slaveID, ushort v);
public abstract IO_VALUE GetDOValue(string deviceName, byte slaveID, ushort v);
public abstract IO_VALUE GetIOValue(ConfigIO configIO);
public abstract void CloseAllDO();
public abstract void CloseAllConnection();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary.Models
{
public class ClientInfo
{
/// <summary>
/// 任务来源系统标识
/// </summary>
public string sourceClient { get; set; }
private bool idleAgv = false;
/// <summary>
/// 是否有空闲AGV可用
/// </summary>
public bool hasIdleAgv {
get { return idleAgv && Online; }
set { idleAgv = value; }
}
/// <summary>
/// 在线状态
/// </summary>
public bool Online { get
{
double upInterval = (DateTime.Now - lastUpdateTime).TotalSeconds;
if (upInterval > 5)
return false;
return true;
} }
private DateTime lastUpdateTime = new DateTime();
public void SetInfo(string client,bool hasIdleAdv)
{
sourceClient = client;
this.idleAgv = hasIdleAdv;
lastUpdateTime = DateTime.Now;
}
public ClientInfo() { }
public ClientInfo(string sourceclient,bool hasidleagv)
{
sourceClient = sourceclient;
idleAgv = hasidleagv;
lastUpdateTime = DateTime.Now;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary.Models
{
/// <summary>
/// 任务信息
/// </summary>
public class MissionInfo
{
/// <summary>
/// 任务ID:呼叫时间
/// </summary>
public string ID { get; set; } = "";
/// <summary>
/// 任务名称
/// </summary>
public string Name { get; set; } = "";
/// <summary>
/// 产品ID
/// </summary>
public int ProductID { get; set; } = 0;
/// <summary>
/// 任务执行信息
/// </summary>
public ExecuteMissionInfo ExecuteMissionInfo { get; set; }
/// <summary>
/// 产品起始地
/// </summary>
public LocationInfo Source { get; set; }
/// <summary>
/// 产品目的地
/// </summary>
public LocationInfo Destination { get; set; }
/// <summary>
/// 任务状态
/// </summary>
public MissionState State { get; set; } = MissionState.Allocated;
/// <summary>
/// 是否空料架返回,默认为true
/// </summary>
public bool NeedEmptyShelfBack { get; set; } = true;
}
/// <summary>
/// 任务状态
/// </summary>
public enum MissionState
{
/// <summary>
/// 已分配任务,未执行
/// </summary>
Allocated,
/// <summary>
/// 正在执行
/// </summary>
Executing,
/// <summary>
/// 已呼叫,但还未开始执行
/// </summary>
Cancel,
/// <summary>
/// 任务已执行被中止
/// </summary>
Aborted,
/// <summary>
/// 任务完成
/// </summary>
Done
}
public class ExecuteMissionInfo
{
/// <summary>
/// 任务开始时间
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 执行任务的AGV
/// </summary>
public List<string> AGVs { get; set; }
/// <summary>
/// 任务结束时间
/// </summary>
public DateTime FinishTime { get; set; }
}
public class LocationInfo
{
public int Floor { get; set; }
public List<string> Lines { get; set; }
public LocationInfo(int floor,string[] lines)
{
Lines = new List<string>();
Lines.AddRange(lines);
Floor = floor;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary.Models
{
/// <summary>
/// 产品信息
/// </summary>
public class ProductInfo
{
/// <summary>
/// 产品ID
/// </summary>
public int ID { get; set; }
/// <summary>
/// 产品名称
/// </summary>
public string Name { get; set; } = "";
/// <summary>
/// 产品类型
/// </summary>
public ProductType Type { get; set; } = ProductType.NONE;
/// <summary>
/// 备注信息
/// </summary>
public string Remark { get; set; } = "";
}
/// <summary>
/// 产品类型
/// </summary>
public enum ProductType
{
/// <summary>
/// 默认:无
/// </summary>
NONE,
/// <summary>
/// PCB
/// </summary>
PCB,
/// <summary>
/// 托盘
/// </summary>
Tray,
/// <summary>
/// PCBA
/// </summary>
PCBA,
/// <summary>
/// 治具
/// </summary>
HealingGear,
/// <summary>
/// 包材
/// </summary>
PackageMaterial,
/// <summary>
/// 模块
/// </summary>
Module,
/// <summary>
/// 静电箱
/// </summary>
StaticBox,
/// <summary>
/// 成品
/// </summary>
FinishedProduct,
/// <summary>
/// 台车
/// </summary>
Trolley,
/// <summary>
/// SMT物料
/// </summary>
SMTMaterial,
/// <summary>
/// 垃圾
/// </summary>
Litter,
/// <summary>
/// 半成品
/// </summary>
SemiFinishedProducts
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary.Models.Service.Request
{
/// <summary>
/// AGV调度系统的状态信息
/// </summary>
public class ClientStatus
{
/// <summary>
/// 电梯标识
/// </summary>
public string liftId { get; set; }
/// <summary>
/// 任务来源系统标识
/// </summary>
public string sourceClient { get; set; }
/// <summary>
/// 是否有空闲AGV可用
/// </summary>
public bool hasIdleAgv { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary.Models.Service.Request
{
/// <summary>
/// 开/关电梯门信息
/// </summary>
public class DoorInfo
{
/// <summary>
/// 电梯标识
/// </summary>
public string liftId { get; set; } = "";
/// <summary>
/// 任务来源AGV系统标识
/// </summary>
public string sourceClient { get; set; } = "";
/// <summary>
/// 架子来源层
/// </summary>
public int sourceFloor { get; set; } = 0;
public override string ToString()
{
return $"{sourceClient}[{sourceFloor}]:{liftId}";
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary.Models.Service.Request
{
/// <summary>
/// 电梯请求信息
/// </summary>
public class SendInInfo
{
/// <summary>
/// 电梯标识
/// </summary>
public string liftId { get; set; }
/// <summary>
/// 任务来源AGV系统标识
/// </summary>
public string sourceClient { get; set; }
/// <summary>
/// 架子来源层
/// </summary>
public int sourceFloor { get; set; }
/// <summary>
/// 架子来源点位
/// </summary>
public string sourcePoint { get; set; }
/// <summary>
/// 任务目的地AGV系统标识
/// </summary>
public string destinationClient { get; set; }
/// <summary>
/// 目的楼层
/// </summary>
public int destinationFloor { get; set; }
/// <summary>
/// 目的地点位
/// </summary>
public string destinationPoint { get; set; }
public override string ToString()
{
return $"请求使用电梯[{liftId}]:[{sourceClient}][{sourceFloor}][{sourcePoint}]-->" +
$"[{destinationClient}][{destinationFloor}][{destinationPoint}]";
}
}
}

using Common;
using DeviceLibrary.Models.Service.Request;
using Newtonsoft.Json;
namespace DeviceLibrary.Models.Service.Response
{
/// <summary>
/// 电梯状态信息
/// </summary>
public class Status
{
/// <summary>
/// 当前电梯处于哪一层
/// </summary>
public int floor { get; set; } = 0;
/// <summary>
/// 电梯门是否打开,打开=opened,关闭=closed
/// </summary>
public string door { get; set; } = "";
/// <summary>
/// 任务来源系统标识
/// </summary>
public string sourceClient { get; set; } = "";
/// <summary>
/// 架子来源楼层
/// </summary>
public int sourceFloor { get; set; } = 0;
/// <summary>
/// 架子来源点位
/// </summary>
public string sourcePoint { get; set; } = "";
/// <summary>
/// 任务目的地系统标识
/// </summary>
public string destinationClient { get; set; } = "";
/// <summary>
/// 目的地楼层
/// </summary>
public int destinationFloor { get; set; } = 0;
/// <summary>
/// 目的地点位
/// </summary>
public string destinationPoint { get; set; } = "";
[JsonIgnore]
public bool Occupied { get { return !string.IsNullOrEmpty(sourceClient); } }
public Status()
{
}
public void Set(SendInInfo sendInInfo)
{
sourceClient = sendInInfo.sourceClient;
sourceFloor = sendInInfo.sourceFloor;
sourcePoint = sendInInfo.sourcePoint;
destinationClient = sendInInfo.destinationClient;
destinationFloor = sendInInfo.destinationFloor;
destinationPoint = sendInInfo.destinationPoint;
LogUtil.info($"请求电梯成功:From: {sourceClient}[{sourceFloor}][{sourcePoint}] To: {destinationClient}[{destinationFloor}][{destinationPoint}]");
}
/// <summary>
/// 清理任务信息
/// </summary>
public void Clear()
{
sourceClient = "";
sourceFloor = 0;
sourcePoint = "";
destinationClient = "";
destinationFloor = 0;
destinationPoint = "";
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("DeviceLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DeviceLibrary")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("f9619f07-15f1-4e59-a383-3871952bbb79")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
此文件类型无法预览
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace DeviceLibrary
{
//public class ScopeLimit
//{
// List<string> agvIPs;
// //不规则图像坐标
// List<Agv_Info.AgvPosition> positions;
// Thread threadPoll;//监控线程
// /// <summary>
// /// 区域是否可用
// /// </summary>
// public bool Available { get; private set; } = true;
// public delegate void ScopeLimitStateChangedEventHandler(string ip, bool state);
// public event ScopeLimitStateChangedEventHandler ScopeLimitStateChangedEvent;
// public ScopeLimit(List<Agv_Info.AgvPosition> positions)
// {
// agvIPs = new List<string>();
// agvIPs.AddRange(new string[]
// {
// "10.85.199.68",
// "10.85.199.69",
// "10.85.199.70",
// "10.85.199.71",
// "10.85.199.72",
// "10.85.199.73",
// "10.85.199.74",
// "10.85.199.80",
// "10.85.199.81",
// "10.85.199.114"
// });
// this.positions = positions;
// threadPoll = new Thread(ScopeDetecting);
// threadPoll.IsBackground = true;
// threadPoll.Start();
// }
// private void ScopeDetecting()
// {
// bool rtn;
// while (true)
// {
// Thread.Sleep(5000);
// List<string> agvs = new List<string>();
// foreach (string ip in agvIPs)
// {
// Thread.Sleep(1000);
// rtn = MiR_API.Get_Position(ip, AGVManager.agvInfo[0].Authorization, out Agv_Info.AgvPosition position);
// if (rtn)
// {
// if (IsInPolygon(position, positions))
// {
// agvs.Add(ip);
// }
// }
// }
// if (agvs.Count > 0)
// {
// Available = false;
// ScopeLimitStateChangedEvent?.Invoke(string.Join(";", agvs), Available);
// }
// else //不在限制区域
// {
// if (!Available)
// {
// Available = true;
// ScopeLimitStateChangedEvent?.Invoke("", Available);
// }
// }
// }
// }
// /// <summary>
// /// 判断点是否在多边形内.
// /// ----------原理----------
// /// 注意到如果从P作水平向左的射线的话,如果P在多边形内部,那么这条射线与多边形的交点必为奇数,
// /// 如果P在多边形外部,则交点个数必为偶数(0也在内)。
// /// </summary>
// /// <param name="checkPoint">要判断的点</param>
// /// <param name="polygonPoints">多边形的顶点</param>
// /// <returns></returns>
// bool IsInPolygon(Agv_Info.AgvPosition checkPoint, List<Agv_Info.AgvPosition> polygonPoints)
// {
// bool inside = false;
// int pointCount = polygonPoints.Count;
// Agv_Info.AgvPosition p1, p2;
// for (int i = 0, j = pointCount - 1; i < pointCount; j = i, i++)//第一个点和最后一个点作为第一条线,之后是第一个点和第二个点作为第二条线,之后是第二个点与第三个点,第三个点与第四个点...
// {
// p1 = polygonPoints[i];
// p2 = polygonPoints[j];
// if (checkPoint.y < p2.y)
// {//p2在射线之上
// if (p1.y <= checkPoint.y)
// {//p1正好在射线中或者射线下方
// if ((checkPoint.y - p1.y) * (p2.x - p1.x) > (checkPoint.x - p1.x) * (p2.y - p1.y))//斜率判断,在P1和P2之间且在P1P2右侧
// {
// //射线与多边形交点为奇数时则在多边形之内,若为偶数个交点时则在多边形之外。
// //由于inside初始值为false,即交点数为零。所以当有第一个交点时,则必为奇数,则在内部,此时为inside=(!inside)
// //所以当有第二个交点时,则必为偶数,则在外部,此时为inside=(!inside)
// inside = (!inside);
// }
// }
// }
// else if (checkPoint.y < p1.y)
// {
// //p2正好在射线中或者在射线下方,p1在射线上
// if ((checkPoint.y - p1.y) * (p2.x - p1.x) < (checkPoint.x - p1.x) * (p2.y - p1.y))//斜率判断,在P1和P2之间且在P1P2右侧
// {
// inside = (!inside);
// }
// }
// }
// return inside;
// }
//}
}
using System.IO;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
namespace DeviceLibrary.Service
{
[ServiceContract(Name = "LiftServices")]
internal interface IService
{
//[OperationContract]
//[WebInvoke(UriTemplate = "call?target={target}&type={type}&id={id}", Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
//Result CallByGet(string target, int type, string id);
[OperationContract]
[WebInvoke(UriTemplate = "/lift/sendIn", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
Result sendIn(Stream stream);
//[OperationContract]
//[WebInvoke(UriTemplate = "/lift/closeDoor", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
//Result closeDoor(Stream stream);
//[OperationContract]
//[WebInvoke(UriTemplate = "/lift/openDoor", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
//Result openDoor(Stream stream);
[OperationContract]
[WebInvoke(UriTemplate = "/lift/call", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
Result Call(Stream stream);
[OperationContract]
[WebInvoke(UriTemplate = "/lift/leave", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
Result Leave(Stream stream);
[OperationContract]
[WebInvoke(UriTemplate = "/lift/status", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
StatusResult status(Stream stream);
}
[DataContract]
internal class Result
{
/// <summary>
/// 状态码。0为正常。其他为异常。
/// </summary>
[DataMember]
public int code { get; set; } = 0;
/// <summary>
/// 提示消息
/// </summary>
[DataMember]
public string msg { get; set; } = "ok";
/// <summary>
/// 返回数据
/// </summary>
[DataMember]
public string data { get; set; } = "";
}
[DataContract]
internal class StatusResult
{
/// <summary>
/// 状态码。0为正常。其他为异常。
/// </summary>
[DataMember]
public int code { get; set; } = 0;
/// <summary>
/// 提示消息
/// </summary>
[DataMember]
public string msg { get; set; } = "ok";
/// <summary>
/// 返回数据
/// </summary>
[DataMember]
public Models.Service.Response.Status data { get; set; }
public StatusResult()
{
data = new Models.Service.Response.Status();
}
}
}
此文件类型无法预览
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件类型无法预览
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!