Commit 3e2506fa LN

单色灯料架,三色灯料架整合为一个项目

1 个父辈 4a14a7e3
正在显示 108 个修改的文件 包含 4869 行增加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
\ No newline at end of file
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{43CDD09E-FCF3-4960-A01D-3BBFE9933122}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.Common</RootNamespace>
<AssemblyName>Common</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<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>
<Prefer32Bit>false</Prefer32Bit>
</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>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\dll\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="bean\Bean.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Setting_Init.cs" />
<Compile Include="util\AcSerialBean.cs" />
<Compile Include="util\ConfigAppSettings.cs" />
<Compile Include="util\FormUtil.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>
<Compile Include="util\NetTCPServer.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
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 © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("f8eab140-5f98-4df7-842c-0d866e759c9a")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [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;
namespace SmartShelf.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 http_server = "http.server";
//以下为流水线料仓的配置
public static string Store_ConfigPath = "Store_ConfigPath";
public static string Store_Position_Config = "Store_Position_Config";
public static string Store_CID = "Store_CID";
public static string BoxCount = "BoxCount";
/// <summary>
/// 料架灯类型,0=单色灯料架,1=三色灯料架
/// </summary>
public static string DeviceLedType = "DeviceLedType";
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.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表示错误信息 )
/// </summary>
public int op { get; set; }
/// <summary>
/// 操作相关数据,
/// op=1时,客户端发送 code 二维码给服务器,服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度
/// 如果需要更新温湿度的报警值,服务器会发送alarmTemperature,alarmHumidity给客户端,客户端缓存,如果没有发送,不处理
/// op=3时,data发送BoxID和AlarmCode
/// </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>
/// 开灯: key为open value为库位信息,如果多个用|分割
/// </summary>
public static string open = "open";
/// <summary>
/// 关灯: key为close value为库位信息,如果多个用|分割
/// </summary>
public static string close = "close";
/// <summary>
/// 关灯: key为closeAll value为库位信息,如果多个用|分割
/// </summary>
public static string closeAll = "closeAll";
/// <summary>
/// 客户端发送 当前灯的状态:key为posOpened value为当前亮灯的库位,如果多个用|分割
/// </summary>
public static string posOpened = "posOpened";
///// <summary>
///// 卡信息: key为card value为读取到的卡内容,卡号-内容
///// </summary>
//public static string card = "card";
///// <summary>
///// 写卡: key=writeCard value为要写的内容
///// </summary>
//public static string writeCard = "writeCard";
///// <summary>
///// key= cardResult value = OK表示写成功
///// </summary>
//public static string cardResult = "cardResult";
}
}
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 SmartShelf.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))
{
LOGGER.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)
{
LOGGER.Error("未找到配置:" + key + ",请检查配置是否完整!");
return "";
}
else
{
return config.AppSettings.Settings[key].Value;
}
}
public static int GetIntValue(object aCBaudRate)
{
throw new NotImplementedException();
}
public static decimal GetNumValue(string key)
{
decimal a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LOGGER.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)
{
LOGGER.Error("未找到配置:" + 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(LOGGER, "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(LOGGER, "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(LOGGER, "SetValue保存配置出错:AppKey=" + AppKey + ",AppValue=" + AppValue + "," + ex.StackTrace);
}
}
public static string GetValue(object debugPosId)
{
throw new NotImplementedException();
}
public static void SaveValue(object default_Language, string str)
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SmartShelf.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).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;
}
}
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Collections;
using System.Net;
using System.Net.Security;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Reflection;
using log4net;
namespace SmartShelf.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);
}
/// <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
{
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(LOGGER, "模拟HTTP服务器返回出库入库信息:" + json);
return operation;
}
}
else
{
string json = "";
try
{
json = JsonHelper.SerializeObject(operation);
}
catch (Exception ex)
{
LOGGER.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)
{
LOGGER.Error("JsonHelper.DeserializeJsonToObject 出错【result=" + result + "】" + ex);
}
}
}
}
catch (Exception ex)
{
LOGGER.Error("Post 出错【operation.op=" + operation.op + "】:" + ex);
}
return null;
}
public static int isLog = ConfigAppSettings.GetIntValue(Setting_Init.Server_Log_Open);
public static string Post(string url, string paramData, Encoding encoding)
{
if (isLog == 1)
{
LOGGER.Info("给服务器发送数据【" + paramData + "】 ");
}
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;
//paramData = Uri.EscapeDataString(paramData);
result = wc.UploadString(url, "POST", paramData);
//LogUtil.info(result);
}
catch (Exception e)
{
LogUtil.error( "POST【"+ paramData + "】 ERROR:" + e.StackTrace, 1);
}
if (!result.Contains("null") && result.Length != 0)
{
//LogUtil.debug(LOGGER,"receive << " + result);
}
if (isLog == 1)
{
LOGGER.Info("收到服务器数据【" + result + "】");
}
return result;
}
public static string Get(string url)
{
return Get(url, Encoding.UTF8);
}
public static string Get(string url, Encoding encoding)
{
try
{
LogUtil.info(LOGGER, "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.info(LOGGER, "receive << " + result);
return result;
}
}
catch (Exception e)
{
LogUtil.error( "HTTP GET ERROR:" + e.Message, 2);
}
return "";
}
}
}
\ No newline at end of file
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
namespace SmartShelf.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>
///// 与服务器通信用对象
///// </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 SmartShelf.Common
{
public class LogUtil
{
public static readonly ILog AIOLog = LogManager.GetLogger("AIOBOXLog");
private static LogUtil instance = new LogUtil();
public delegate void ShowLog(string msg, Color color);
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static Dictionary<int, DateTime> lastErrorLogTime = new Dictionary<int, DateTime>();
public static System.Windows.Forms.RichTextBox logBox = null;
public static int showCount = 20;
public static bool debug_opened = false;
public static void info(ILog log,string msg )
{
if (log == null)
{
return;
}
log.Info(log.Logger.Name + " - " + msg);
if (logBox == null)
{
return;
}
AddToBox(msg, Color.Black);
//clear();
}
public static void info(ILog log,string msg, Color color)
{
log.Info(log.Logger.Name + " - " + msg);
if (logBox == null)
{
return;
}
AddToBox(msg, color);
}
public static void debug(ILog log, string msg, Color color)
{
log.Debug(log.Logger.Name + " - " + msg);
if (debug_opened)
{
if (logBox == null)
{
return;
}
AddToBox(msg, color);
}
}
public static void debug(ILog log, string msg)
{
log.Debug(log.Logger.Name + " - " + msg);
if (debug_opened)
{
if (logBox == null)
{
return;
}
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)
{
return;
}
else
{
lastErrorLogTime.Remove(type);
lastErrorLogTime.Add(type, DateTime.Now);
error( errorMsg);
}
}
else
{
lastErrorLogTime.Add(type, DateTime.Now);
error( errorMsg);
}
}
public static void error(ILog log, string errorMsg)
{
//if (!lasErrorLogList.Contains(errorMsg))
{
log.Error(log.Logger.Name + " - " + errorMsg);
if (logBox == null)
{
return;
}
AddToBox(errorMsg, Color.Red);
}
//lasErrorLogList.Add(errorMsg);
//if (lasErrorLogList.Count > errCount)
//{
// lasErrorLogList.RemoveAt(0);
//}
}
private static void AddToBox(string msg, Color color)
{
try
{
ShowLogPro(msg);
}
catch (Exception ex)
{
LOGGER.Error("出错:" + ex.StackTrace);
}
}
private static int count = 0;
private static void ShowLogPro(string msg )
{
try
{
//clear();
if (count > showCount)
{
count = 0;
logBox.Clear();
}
//logBox.SelectionColor = color;
System.DateTime now = System.DateTime.Now;
logBox.AppendText(now.ToLongTimeString() + " " + msg + Environment.NewLine);
count++;
}
catch (Exception ex)
{
LOGGER.Error("出错:" + ex.ToString());
}
}
public static void debug(string msg)
{
debug(LOGGER, msg);
}
public static void error(string errorMsg)
{
error( LOGGER,errorMsg);
}
public static void ClearLog()
{
if (logBox != null)
{
logBox.Text = "";
count = 0;
}
}
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 SmartShelf.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 System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Net.Sockets;
using System.Net;
using System.IO;
using log4net;
using System.Text;
namespace OnlineStore
{
public class NetTCPServer
{
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// TCP服务端监听
/// </summary>
TcpListener tcpsever = null;
/// <summary>
/// 监听状态
/// </summary>
bool isListen = false;
public BindingList<NewClient> lstClient = new BindingList<NewClient>();
public IPAddress[] getLoacalIPAddress()
{
IPHostEntry ipHostEntry = Dns.GetHostEntry(Dns.GetHostName());
return ipHostEntry.AddressList;
}
public delegate void ReviceData(NewClient client, string ip, byte[] data);
public event ReviceData ReviceDataEvent;
/// <summary>
/// 开启TCP监听
/// </summary>
/// <returns></returns>
public void StartTCPServer(int port)
{
try
{
tcpsever = new TcpListener(IPAddress.Any, port);
tcpsever.Start();
tcpsever.BeginAcceptTcpClient(new AsyncCallback(Acceptor), tcpsever);
isListen = true;
}
catch (Exception ex)
{
}
}
/// <summary>
/// 停止TCP监听
/// </summary>
/// <returns></returns>
public void StopTCPServer()
{
tcpsever.Stop();
isListen = false;
}
/// <summary>
/// 客户端连接初始化
/// </summary>
/// <param name="o"></param>
private void Acceptor(IAsyncResult o)
{
TcpListener server = o.AsyncState as TcpListener;
try
{
//初始化连接的客户端
NewClient newClient = new NewClient();
newClient.tcpClient = server.EndAcceptTcpClient(o);
lstClient.Add(newClient);
newClient.tcpClient.GetStream().BeginRead(newClient.Buffer, 0, newClient.Buffer.Length, new AsyncCallback(TCPCallBack), newClient);
server.BeginAcceptTcpClient(new AsyncCallback(Acceptor), server);//继续监听客户端连接
}
catch (ObjectDisposedException ex)
{ //监听被关闭
}
catch (Exception ex)
{
}
}
/// <summary>
/// 对当前选中的客户端发送数据
/// </summary>
/// <param name="sender"></param>
/// <param name="data"></param>
public bool SendData(NewClient selClient, byte[] data)
{
try
{
selClient.tcpClient.GetStream().Write(data, 0, data.Length);
}
catch (Exception ex)
{
return false;
}
return true;
}
/// <summary>
/// 客户端通讯回调函数
/// </summary>
/// <param name="ar"></param>
private void TCPCallBack(IAsyncResult ar)
{
NewClient client = (NewClient)ar.AsyncState;
if (client.tcpClient.Connected)
{
NetworkStream ns = client.tcpClient.GetStream();
StreamReader sr = new StreamReader(ns);
string str = sr.ReadLine();
LOGGER.Info("读取到数据:"+str);
byte[] recdata = new byte[ns.EndRead(ar)];
if (recdata.Length > 0)
{
//Array.Copy(client.Buffer, recdata, recdata.Length);
LOGGER.Info("读取到数据1111:" + Encoding.ASCII.GetString(recdata));
//ns.BeginRead(client.Buffer, 0, client.Buffer.Length, new AsyncCallback(TCPCallBack), client);
}
else
{
client.tcpClient.Close();
lstClient.Remove(client);
}
}
}
/// <summary>
/// 清理
/// </summary>
public void ClearSelf()
{
foreach (NewClient client in lstClient)
{
client.tcpClient.Close();
}
lstClient.Clear();
if (tcpsever != null)
{
tcpsever.Stop();
}
}
}
public class NewClient
{
public TcpClient tcpClient { get; set; }
public byte[] Buffer = new byte[1024];
}
}
类型,说明,名称,属性值
PRO,端口号,Door_PortName,COM1
PRO,IOIP,AIO_IP,192.168.200.11
PRO,使用哪种IP模块,UseAIOBOX,1
λÖÃ,ÓÅÏȼ¶,¸ß¶È,¿í¶È,ÁϲÖID,É豸IP,ÇøÓòID,µÆË÷Òý
1#A1_1,10,8,7,1,192.168.200.221,0,0
1#A1_2,10,8,7,1,192.168.200.221,0,1
1#A1_3,10,8,7,1,192.168.200.221,0,2
1#A1_4,10,8,7,1,192.168.200.221,0,3
1#A1_5,10,8,7,1,192.168.200.221,0,4
1#A1_6,10,8,7,1,192.168.200.221,0,5
1#A1_7,10,8,7,1,192.168.200.221,0,6
1#A1_8,10,8,7,1,192.168.200.221,0,7
1#A1_9,10,8,7,1,192.168.200.221,0,8
1#A1_10,10,8,7,1,192.168.200.221,0,9
1#A1_11,10,8,7,1,192.168.200.221,0,10
1#A1_12,10,8,7,1,192.168.200.221,0,11
1#A1_13,10,8,7,1,192.168.200.221,0,12
1#A1_14,10,8,7,1,192.168.200.221,0,13
1#A1_15,10,8,7,1,192.168.200.221,0,14
1#A1_16,10,8,7,1,192.168.200.221,0,15
1#A1_17,10,8,7,1,192.168.200.221,0,16
1#A1_18,10,8,7,1,192.168.200.221,0,17
1#A1_19,10,8,7,1,192.168.200.221,0,18
1#A1_20,10,8,7,1,192.168.200.221,0,19
1#A1_21,10,8,7,1,192.168.200.221,0,20
1#A1_22,10,8,7,1,192.168.200.221,0,21
1#A1_23,10,8,7,1,192.168.200.221,0,22
1#A1_24,10,8,7,1,192.168.200.221,0,23
1#A1_25,10,8,7,1,192.168.200.221,0,24
1#A1_26,10,8,7,1,192.168.200.221,0,25
1#A1_27,10,8,7,1,192.168.200.221,0,26
1#A1_28,10,8,7,1,192.168.200.221,0,27
1#A1_29,10,8,7,1,192.168.200.221,0,28
1#A1_30,10,8,7,1,192.168.200.221,0,29
1#A1_31,10,8,7,1,192.168.200.221,0,30
1#A1_32,10,8,7,1,192.168.200.221,0,31
1#A1_33,10,8,7,1,192.168.200.221,0,32
1#A1_34,10,8,7,1,192.168.200.221,0,33
1#A1_35,10,8,7,1,192.168.200.221,0,34
1#A1_36,10,8,7,1,192.168.200.221,0,35
1#A1_37,10,8,7,1,192.168.200.221,0,36
1#A1_38,10,8,7,1,192.168.200.221,0,37
1#A1_39,10,8,7,1,192.168.200.221,0,38
1#A1_40,10,8,7,1,192.168.200.221,0,39
,,,,,,,
1#A2_1,10,8,13,1,192.168.200.221,0,79
1#A2_2,10,8,13,1,192.168.200.221,0,78
1#A2_3,10,8,13,1,192.168.200.221,0,77
1#A2_4,10,8,13,1,192.168.200.221,0,76
1#A2_5,10,8,13,1,192.168.200.221,0,75
1#A2_6,10,8,13,1,192.168.200.221,0,74
1#A2_7,10,8,13,1,192.168.200.221,0,73
1#A2_8,10,8,13,1,192.168.200.221,0,72
1#A2_9,10,8,13,1,192.168.200.221,0,71
1#A2_10,10,8,13,1,192.168.200.221,0,70
1#A2_11,10,8,13,1,192.168.200.221,0,69
1#A2_12,10,8,13,1,192.168.200.221,0,68
1#A2_13,10,8,13,1,192.168.200.221,0,67
1#A2_14,10,8,13,1,192.168.200.221,0,66
1#A2_15,10,8,13,1,192.168.200.221,0,65
1#A2_16,10,8,13,1,192.168.200.221,0,64
1#A2_17,10,8,13,1,192.168.200.221,0,63
1#A2_18,10,8,13,1,192.168.200.221,0,62
1#A2_19,10,8,13,1,192.168.200.221,0,61
1#A2_20,10,8,13,1,192.168.200.221,0,60
1#A2_21,10,8,13,1,192.168.200.221,0,59
1#A2_22,10,8,13,1,192.168.200.221,0,58
1#A2_23,10,8,13,1,192.168.200.221,0,57
1#A2_24,10,8,13,1,192.168.200.221,0,56
1#A2_25,10,8,13,1,192.168.200.221,0,55
1#A2_26,10,8,13,1,192.168.200.221,0,54
1#A2_27,10,8,13,1,192.168.200.221,0,53
1#A2_28,10,8,13,1,192.168.200.221,0,52
1#A2_29,10,8,13,1,192.168.200.221,0,51
1#A2_30,10,8,13,1,192.168.200.221,0,50
1#A2_31,10,8,13,1,192.168.200.221,0,49
1#A2_32,10,8,13,1,192.168.200.221,0,48
1#A2_33,10,8,13,1,192.168.200.221,0,47
1#A2_34,10,8,13,1,192.168.200.221,0,46
1#A2_35,10,8,13,1,192.168.200.221,0,45
1#A2_36,10,8,13,1,192.168.200.221,0,44
1#A2_37,10,8,13,1,192.168.200.221,0,43
1#A2_38,10,8,13,1,192.168.200.221,0,42
1#A2_39,10,8,13,1,192.168.200.221,0,41
1#A2_40,10,8,13,1,192.168.200.221,0,40
,,,,,,,
1#A3_1,10,8,15,1,192.168.200.221,0,80
1#A3_2,10,8,15,1,192.168.200.221,0,81
1#A3_3,10,8,15,1,192.168.200.221,0,82
1#A3_4,10,8,15,1,192.168.200.221,0,83
1#A3_5,10,8,15,1,192.168.200.221,0,84
1#A3_6,10,8,15,1,192.168.200.221,0,85
1#A3_7,10,8,15,1,192.168.200.221,0,86
1#A3_8,10,8,15,1,192.168.200.221,0,87
1#A3_9,10,8,15,1,192.168.200.221,0,88
1#A3_10,10,8,15,1,192.168.200.221,0,89
1#A3_11,10,8,15,1,192.168.200.221,0,90
1#A3_12,10,8,15,1,192.168.200.221,0,91
1#A3_13,10,8,15,1,192.168.200.221,0,92
1#A3_14,10,8,15,1,192.168.200.221,0,93
1#A3_15,10,8,15,1,192.168.200.221,0,94
1#A3_16,10,8,15,1,192.168.200.221,0,95
1#A3_17,10,8,15,1,192.168.200.221,0,96
1#A3_18,10,8,15,1,192.168.200.221,0,97
1#A3_19,10,8,15,1,192.168.200.221,0,98
1#A3_20,10,8,15,1,192.168.200.221,0,99
1#A3_21,10,8,15,1,192.168.200.221,0,100
1#A3_22,10,8,15,1,192.168.200.221,0,101
1#A3_23,10,8,15,1,192.168.200.221,0,102
1#A3_24,10,8,15,1,192.168.200.221,0,103
1#A3_25,10,8,15,1,192.168.200.221,0,104
1#A3_26,10,8,15,1,192.168.200.221,0,105
1#A3_27,10,8,15,1,192.168.200.221,0,106
1#A3_28,10,8,15,1,192.168.200.221,0,107
1#A3_29,10,8,15,1,192.168.200.221,0,108
1#A3_30,10,8,15,1,192.168.200.221,0,109
1#A3_31,10,8,15,1,192.168.200.221,0,110
1#A3_32,10,8,15,1,192.168.200.221,0,111
1#A3_33,10,8,15,1,192.168.200.221,0,112
1#A3_34,10,8,15,1,192.168.200.221,0,113
1#A3_35,10,8,15,1,192.168.200.221,0,114
1#A3_36,10,8,15,1,192.168.200.221,0,115
1#A3_37,10,8,15,1,192.168.200.221,0,116
1#A3_38,10,8,15,1,192.168.200.221,0,117
1#A3_39,10,8,15,1,192.168.200.221,0,118
1#A3_40,10,8,15,1,192.168.200.221,0,119
位置,优先级,高度,宽度,料仓ID,设备IP,区域ID,灯索引
1#B1_1,10,8,7,1,192.168.200.222,0,0
1#B1_2,10,8,7,1,192.168.200.222,0,1
1#B1_3,10,8,7,1,192.168.200.222,0,2
1#B1_4,10,8,7,1,192.168.200.222,0,3
1#B1_5,10,8,7,1,192.168.200.222,0,4
1#B1_6,10,8,7,1,192.168.200.222,0,5
1#B1_7,10,8,7,1,192.168.200.222,0,6
1#B1_8,10,8,7,1,192.168.200.222,0,7
1#B1_9,10,8,7,1,192.168.200.222,0,8
1#B1_10,10,8,7,1,192.168.200.222,0,9
1#B1_11,10,8,7,1,192.168.200.222,0,10
1#B1_12,10,8,7,1,192.168.200.222,0,11
1#B1_13,10,8,7,1,192.168.200.222,0,12
1#B1_14,10,8,7,1,192.168.200.222,0,13
1#B1_15,10,8,7,1,192.168.200.222,0,14
1#B1_16,10,8,7,1,192.168.200.222,0,15
1#B1_17,10,8,7,1,192.168.200.222,0,16
1#B1_18,10,8,7,1,192.168.200.222,0,17
1#B1_19,10,8,7,1,192.168.200.222,0,18
1#B1_20,10,8,7,1,192.168.200.222,0,19
1#B1_21,10,8,7,1,192.168.200.222,0,20
1#B1_22,10,8,7,1,192.168.200.222,0,21
1#B1_23,10,8,7,1,192.168.200.222,0,22
1#B1_24,10,8,7,1,192.168.200.222,0,23
1#B1_25,10,8,7,1,192.168.200.222,0,24
1#B1_26,10,8,7,1,192.168.200.222,0,25
1#B1_27,10,8,7,1,192.168.200.222,0,26
1#B1_28,10,8,7,1,192.168.200.222,0,27
1#B1_29,10,8,7,1,192.168.200.222,0,28
1#B1_30,10,8,7,1,192.168.200.222,0,29
1#B1_31,10,8,7,1,192.168.200.222,0,30
1#B1_32,10,8,7,1,192.168.200.222,0,31
1#B1_33,10,8,7,1,192.168.200.222,0,32
1#B1_34,10,8,7,1,192.168.200.222,0,33
1#B1_35,10,8,7,1,192.168.200.222,0,34
1#B1_36,10,8,7,1,192.168.200.222,0,35
1#B1_37,10,8,7,1,192.168.200.222,0,36
1#B1_38,10,8,7,1,192.168.200.222,0,37
1#B1_39,10,8,7,1,192.168.200.222,0,38
1#B1_40,10,8,7,1,192.168.200.222,0,39
,,,,,,,
1#B2_1,10,8,13,1,192.168.200.222,0,79
1#B2_2,10,8,13,1,192.168.200.222,0,78
1#B2_3,10,8,13,1,192.168.200.222,0,77
1#B2_4,10,8,13,1,192.168.200.222,0,76
1#B2_5,10,8,13,1,192.168.200.222,0,75
1#B2_6,10,8,13,1,192.168.200.222,0,74
1#B2_7,10,8,13,1,192.168.200.222,0,73
1#B2_8,10,8,13,1,192.168.200.222,0,72
1#B2_9,10,8,13,1,192.168.200.222,0,71
1#B2_10,10,8,13,1,192.168.200.222,0,70
1#B2_11,10,8,13,1,192.168.200.222,0,69
1#B2_12,10,8,13,1,192.168.200.222,0,68
1#B2_13,10,8,13,1,192.168.200.222,0,67
1#B2_14,10,8,13,1,192.168.200.222,0,66
1#B2_15,10,8,13,1,192.168.200.222,0,65
1#B2_16,10,8,13,1,192.168.200.222,0,64
1#B2_17,10,8,13,1,192.168.200.222,0,63
1#B2_18,10,8,13,1,192.168.200.222,0,62
1#B2_19,10,8,13,1,192.168.200.222,0,61
1#B2_20,10,8,13,1,192.168.200.222,0,60
1#B2_21,10,8,13,1,192.168.200.222,0,59
1#B2_22,10,8,13,1,192.168.200.222,0,58
1#B2_23,10,8,13,1,192.168.200.222,0,57
1#B2_24,10,8,13,1,192.168.200.222,0,56
1#B2_25,10,8,13,1,192.168.200.222,0,55
1#B2_26,10,8,13,1,192.168.200.222,0,54
1#B2_27,10,8,13,1,192.168.200.222,0,53
1#B2_28,10,8,13,1,192.168.200.222,0,52
1#B2_29,10,8,13,1,192.168.200.222,0,51
1#B2_30,10,8,13,1,192.168.200.222,0,50
1#B2_31,10,8,13,1,192.168.200.222,0,49
1#B2_32,10,8,13,1,192.168.200.222,0,48
1#B2_33,10,8,13,1,192.168.200.222,0,47
1#B2_34,10,8,13,1,192.168.200.222,0,46
1#B2_35,10,8,13,1,192.168.200.222,0,45
1#B2_36,10,8,13,1,192.168.200.222,0,44
1#B2_37,10,8,13,1,192.168.200.222,0,43
1#B2_38,10,8,13,1,192.168.200.222,0,42
1#B2_39,10,8,13,1,192.168.200.222,0,41
1#B2_40,10,8,13,1,192.168.200.222,0,40
,,,,,,,
1#B3_1,10,8,15,1,192.168.200.222,0,80
1#B3_2,10,8,15,1,192.168.200.222,0,81
1#B3_3,10,8,15,1,192.168.200.222,0,82
1#B3_4,10,8,15,1,192.168.200.222,0,83
1#B3_5,10,8,15,1,192.168.200.222,0,84
1#B3_6,10,8,15,1,192.168.200.222,0,85
1#B3_7,10,8,15,1,192.168.200.222,0,86
1#B3_8,10,8,15,1,192.168.200.222,0,87
1#B3_9,10,8,15,1,192.168.200.222,0,88
1#B3_10,10,8,15,1,192.168.200.222,0,89
1#B3_11,10,8,15,1,192.168.200.222,0,90
1#B3_12,10,8,15,1,192.168.200.222,0,91
1#B3_13,10,8,15,1,192.168.200.222,0,92
1#B3_14,10,8,15,1,192.168.200.222,0,93
1#B3_15,10,8,15,1,192.168.200.222,0,94
1#B3_16,10,8,15,1,192.168.200.222,0,95
1#B3_17,10,8,15,1,192.168.200.222,0,96
1#B3_18,10,8,15,1,192.168.200.222,0,97
1#B3_19,10,8,15,1,192.168.200.222,0,98
1#B3_20,10,8,15,1,192.168.200.222,0,99
1#B3_21,10,8,15,1,192.168.200.222,0,100
1#B3_22,10,8,15,1,192.168.200.222,0,101
1#B3_23,10,8,15,1,192.168.200.222,0,102
1#B3_24,10,8,15,1,192.168.200.222,0,103
1#B3_25,10,8,15,1,192.168.200.222,0,104
1#B3_26,10,8,15,1,192.168.200.222,0,105
1#B3_27,10,8,15,1,192.168.200.222,0,106
1#B3_28,10,8,15,1,192.168.200.222,0,107
1#B3_29,10,8,15,1,192.168.200.222,0,108
1#B3_30,10,8,15,1,192.168.200.222,0,109
1#B3_31,10,8,15,1,192.168.200.222,0,110
1#B3_32,10,8,15,1,192.168.200.222,0,111
1#B3_33,10,8,15,1,192.168.200.222,0,112
1#B3_34,10,8,15,1,192.168.200.222,0,113
1#B3_35,10,8,15,1,192.168.200.222,0,114
1#B3_36,10,8,15,1,192.168.200.222,0,115
1#B3_37,10,8,15,1,192.168.200.222,0,116
1#B3_38,10,8,15,1,192.168.200.222,0,117
1#B3_39,10,8,15,1,192.168.200.222,0,118
1#B3_40,10,8,15,1,192.168.200.222,0,119
λÖÃ,ÓÅÏȼ¶,¸ß¶È,¿í¶È,ÁϲÖID,É豸IP,ÇøÓòID,µÆË÷Òý
3#E1_1,10,16,13,3,192.168.201.223,0,0;1
3#E1_2,10,16,13,3,192.168.201.223,0,2;3
3#E1_3,10,16,13,3,192.168.201.223,0,4;5
3#E1_4,10,16,13,3,192.168.201.223,0,6;7
3#E1_5,10,16,13,3,192.168.201.223,0,8;9
3#E1_6,10,16,13,3,192.168.201.223,0,10;11
3#E1_7,10,16,13,3,192.168.201.223,0,12;13
3#E1_8,10,16,13,3,192.168.201.223,0,14;15
3#E1_9,10,16,13,3,192.168.201.223,0,16;17
3#E1_10,10,16,13,3,192.168.201.223,0,18;19
3#E1_11,10,16,13,3,192.168.201.223,0,20;21
3#E1_12,10,16,13,3,192.168.201.223,0,22;23
3#E1_13,10,16,13,3,192.168.201.223,0,24;25
3#E1_14,10,16,13,3,192.168.201.223,0,26;27
3#E1_15,10,16,13,3,192.168.201.223,0,28;29
3#E1_16,10,16,13,3,192.168.201.223,0,30;31
3#E1_17,10,16,13,3,192.168.201.223,0,32;33
3#E1_18,10,16,13,3,192.168.201.223,0,34;35
3#E1_19,10,16,13,3,192.168.201.223,0,36;37
3#E1_20,10,16,13,3,192.168.201.223,0,38;39
3#E1_21,10,16,13,3,192.168.201.223,0,40;41
3#E1_22,10,16,13,3,192.168.201.223,0,42;43
3#E1_23,10,16,13,3,192.168.201.223,0,44;45
3#E1_24,10,16,13,3,192.168.201.223,0,46;47
3#E1_25,10,16,13,3,192.168.201.223,0,48;49
3#E1_26,10,16,13,3,192.168.201.223,0,50;51
3#E1_27,10,16,13,3,192.168.201.223,0,52;53
3#E1_28,10,16,13,3,192.168.201.223,0,54;55
3#E1_29,10,16,13,3,192.168.201.223,0,56;57
3#E1_30,10,16,13,3,192.168.201.223,0,58;59
3#E1_31,10,16,13,3,192.168.201.223,0,60;61
3#E1_32,10,16,13,3,192.168.201.223,0,62;63
3#E1_33,10,16,13,3,192.168.201.223,0,64;65
3#E1_34,10,16,13,3,192.168.201.223,0,66;67
3#E1_35,10,16,13,3,192.168.201.223,0,68;69
3#E1_36,10,16,13,3,192.168.201.223,0,70;71
3#E1_37,10,16,13,3,192.168.201.223,0,72;73
3#E1_38,10,16,13,3,192.168.201.223,0,74;75
3#E1_39,10,16,13,3,192.168.201.223,0,76;77
3#E1_40,10,16,13,3,192.168.201.223,0,78;79
3#E1_41,10,16,13,3,192.168.201.223,0,80;81
3#E1_42,10,16,13,3,192.168.201.223,0,82;83
3#E1_43,10,16,13,3,192.168.201.223,0,84;85
3#E1_44,10,16,13,3,192.168.201.223,0,86;87
3#E1_45,10,16,13,3,192.168.201.223,0,88;89
3#E1_46,10,16,13,3,192.168.201.223,0,90;91
3#E1_47,10,16,13,3,192.168.201.223,0,92;93
3#E1_48,10,16,13,3,192.168.201.223,0,94;95
3#E1_49,10,16,13,3,192.168.201.223,0,96;97
3#E1_50,10,16,13,3,192.168.201.223,0,98;99
,,,,,,,
3#E2_1,10,16,13,3,192.168.201.223,0,199;198
3#E2_2,10,16,13,3,192.168.201.223,0,197;196
3#E2_3,10,16,13,3,192.168.201.223,0,195;194
3#E2_4,10,16,13,3,192.168.201.223,0,193;192
3#E2_5,10,16,13,3,192.168.201.223,0,191;190
3#E2_6,10,16,13,3,192.168.201.223,0,189;188
3#E2_7,10,16,13,3,192.168.201.223,0,187;186
3#E2_8,10,16,13,3,192.168.201.223,0,185;184
3#E2_9,10,16,13,3,192.168.201.223,0,183;182
3#E2_10,10,16,13,3,192.168.201.223,0,181;180
3#E2_11,10,16,13,3,192.168.201.223,0,179;178
3#E2_12,10,16,13,3,192.168.201.223,0,177;176
3#E2_13,10,16,13,3,192.168.201.223,0,175;174
3#E2_14,10,16,13,3,192.168.201.223,0,173;172
3#E2_15,10,16,13,3,192.168.201.223,0,171;170
3#E2_16,10,16,13,3,192.168.201.223,0,169;168
3#E2_17,10,16,13,3,192.168.201.223,0,167;166
3#E2_18,10,16,13,3,192.168.201.223,0,165;164
3#E2_19,10,16,13,3,192.168.201.223,0,163;162
3#E2_20,10,16,13,3,192.168.201.223,0,161;160
3#E2_21,10,16,13,3,192.168.201.223,0,159;158
3#E2_22,10,16,13,3,192.168.201.223,0,157;156
3#E2_23,10,16,13,3,192.168.201.223,0,155;154
3#E2_24,10,16,13,3,192.168.201.223,0,153;152
3#E2_25,10,16,13,3,192.168.201.223,0,151;150
3#E2_26,10,16,13,3,192.168.201.223,0,149;148
3#E2_27,10,16,13,3,192.168.201.223,0,147;146
3#E2_28,10,16,13,3,192.168.201.223,0,145;144
3#E2_29,10,16,13,3,192.168.201.223,0,143;142
3#E2_30,10,16,13,3,192.168.201.223,0,141;140
3#E2_31,10,16,13,3,192.168.201.223,0,139;138
3#E2_32,10,16,13,3,192.168.201.223,0,137;136
3#E2_33,10,16,13,3,192.168.201.223,0,135;134
3#E2_34,10,16,13,3,192.168.201.223,0,133;132
3#E2_35,10,16,13,3,192.168.201.223,0,131;130
3#E2_36,10,16,13,3,192.168.201.223,0,129;128
3#E2_37,10,16,13,3,192.168.201.223,0,127;126
3#E2_38,10,16,13,3,192.168.201.223,0,125;124
3#E2_39,10,16,13,3,192.168.201.223,0,123;122
3#E2_40,10,16,13,3,192.168.201.223,0,121;120
3#E2_41,10,16,13,3,192.168.201.223,0,119;118
3#E2_42,10,16,13,3,192.168.201.223,0,117;116
3#E2_43,10,16,13,3,192.168.201.223,0,115;114
3#E2_44,10,16,13,3,192.168.201.223,0,113;112
3#E2_45,10,16,13,3,192.168.201.223,0,111;110
3#E2_46,10,16,13,3,192.168.201.223,0,109;108
3#E2_47,10,16,13,3,192.168.201.223,0,107;106
3#E2_48,10,16,13,3,192.168.201.223,0,105;104
3#E2_49,10,16,13,3,192.168.201.223,0,103;102
3#E2_50,10,16,13,3,192.168.201.223,0,101;100
,,,,,,,
3#E3_1,10,16,13,3,192.168.201.223,0,200;201
3#E3_2,10,16,13,3,192.168.201.223,0,202;203
3#E3_3,10,16,13,3,192.168.201.223,0,204;205
3#E3_4,10,16,13,3,192.168.201.223,0,206;207
3#E3_5,10,16,13,3,192.168.201.223,0,208;209
3#E3_6,10,16,13,3,192.168.201.223,0,210;211
3#E3_7,10,16,13,3,192.168.201.223,0,212;213
3#E3_8,10,16,13,3,192.168.201.223,0,214;215
3#E3_9,10,16,13,3,192.168.201.223,0,216;217
3#E3_10,10,16,13,3,192.168.201.223,0,218;219
3#E3_11,10,16,13,3,192.168.201.223,0,220;221
3#E3_12,10,16,13,3,192.168.201.223,0,222;223
3#E3_13,10,16,13,3,192.168.201.223,0,224;225
3#E3_14,10,16,13,3,192.168.201.223,0,226;227
3#E3_15,10,16,13,3,192.168.201.223,0,228;229
3#E3_16,10,16,13,3,192.168.201.223,0,230;231
3#E3_17,10,16,13,3,192.168.201.223,0,232;233
3#E3_18,10,16,13,3,192.168.201.223,0,234;235
3#E3_19,10,16,13,3,192.168.201.223,0,236;237
3#E3_20,10,16,13,3,192.168.201.223,0,238;239
3#E3_21,10,16,13,3,192.168.201.223,0,240;241
3#E3_22,10,16,13,3,192.168.201.223,0,242;243
3#E3_23,10,16,13,3,192.168.201.223,0,244;245
3#E3_24,10,16,13,3,192.168.201.223,0,246;247
3#E3_25,10,16,13,3,192.168.201.223,0,248;249
3#E3_26,10,16,13,3,192.168.201.223,0,250;251
3#E3_27,10,16,13,3,192.168.201.223,0,252;253
3#E3_28,10,16,13,3,192.168.201.223,0,254;255
3#E3_29,10,16,13,3,192.168.201.223,0,256;257
3#E3_30,10,16,13,3,192.168.201.223,0,258;259
3#E3_31,10,16,13,3,192.168.201.223,0,260;261
3#E3_32,10,16,13,3,192.168.201.223,0,262;263
3#E3_33,10,16,13,3,192.168.201.223,0,264;265
3#E3_34,10,16,13,3,192.168.201.223,0,266;267
3#E3_35,10,16,13,3,192.168.201.223,0,268;269
3#E3_36,10,16,13,3,192.168.201.223,0,270;271
3#E3_37,10,16,13,3,192.168.201.223,0,272;273
3#E3_38,10,16,13,3,192.168.201.223,0,274;275
3#E3_39,10,16,13,3,192.168.201.223,0,276;277
3#E3_40,10,16,13,3,192.168.201.223,0,278;279
3#E3_41,10,16,13,3,192.168.201.223,0,280;281
3#E3_42,10,16,13,3,192.168.201.223,0,282;283
3#E3_43,10,16,13,3,192.168.201.223,0,284;285
3#E3_44,10,16,13,3,192.168.201.223,0,286;287
3#E3_45,10,16,13,3,192.168.201.223,0,288;289
3#E3_46,10,16,13,3,192.168.201.223,0,290;291
3#E3_47,10,16,13,3,192.168.201.223,0,292;293
3#E3_48,10,16,13,3,192.168.201.223,0,294;295
3#E3_49,10,16,13,3,192.168.201.223,0,296;297
3#E3_50,10,16,13,3,192.168.201.223,0,298;299
,,,,,,,
3#E4_1,10,24,13,3,192.168.201.223,0,399;398;397
3#E4_2,10,24,13,3,192.168.201.223,0,396;395;394
3#E4_3,10,24,13,3,192.168.201.223,0,393;392;391
3#E4_4,10,24,13,3,192.168.201.223,0,390;389;388
3#E4_5,10,24,13,3,192.168.201.223,0,387;386;385
3#E4_6,10,24,13,3,192.168.201.223,0,384;383;382
3#E4_7,10,24,13,3,192.168.201.223,0,381;380;379
3#E4_8,10,24,13,3,192.168.201.223,0,378;377;376
3#E4_9,10,24,13,3,192.168.201.223,0,375;374;373
3#E4_10,10,24,13,3,192.168.201.223,0,372;371;370
3#E4_11,10,24,13,3,192.168.201.223,0,369;368;367
3#E4_12,10,24,13,3,192.168.201.223,0,366;365;364
3#E4_13,10,24,13,3,192.168.201.223,0,363;362;361
3#E4_14,10,24,13,3,192.168.201.223,0,360;359;358
3#E4_15,10,24,13,3,192.168.201.223,0,357;356;355
3#E4_16,10,24,13,3,192.168.201.223,0,354;353;352
3#E4_17,10,24,13,3,192.168.201.223,0,351;350;349
3#E4_18,10,24,13,3,192.168.201.223,0,348;347;346
3#E4_19,10,24,13,3,192.168.201.223,0,345;344;343
3#E4_20,10,24,13,3,192.168.201.223,0,342;341;340
3#E4_21,10,24,13,3,192.168.201.223,0,339;338;337
3#E4_22,10,24,13,3,192.168.201.223,0,336;335;334
3#E4_23,10,24,13,3,192.168.201.223,0,333;332;331
3#E4_24,10,24,13,3,192.168.201.223,0,330;329;328
3#E4_25,10,24,13,3,192.168.201.223,0,327;326;325
3#E4_26,10,24,13,3,192.168.201.223,0,324;323;322
3#E4_27,10,24,13,3,192.168.201.223,0,321;320;319
3#E4_28,10,24,13,3,192.168.201.223,0,318;317;316
3#E4_29,10,24,13,3,192.168.201.223,0,315;314;313
3#E4_30,10,24,13,3,192.168.201.223,0,312;311;310
3#E4_31,10,24,13,3,192.168.201.223,0,309;308;307
3#E4_32,10,24,13,3,192.168.201.223,0,306;305;304
3#E4_33,10,24,13,3,192.168.201.223,0,303;302;301
,,,,,,,
3#E5_1,10,24,13,3,192.168.201.223,0,400;401;402
3#E5_2,10,24,13,3,192.168.201.223,0,403;404;405
3#E5_3,10,24,13,3,192.168.201.223,0,406;407;408
3#E5_4,10,24,13,3,192.168.201.223,0,409;410;411
3#E5_5,10,24,13,3,192.168.201.223,0,412;413;414
3#E5_6,10,24,13,3,192.168.201.223,0,415;416;417
3#E5_7,10,24,13,3,192.168.201.223,0,418;419;420
3#E5_8,10,24,13,3,192.168.201.223,0,421;422;423
3#E5_9,10,24,13,3,192.168.201.223,0,424;425;426
3#E5_10,10,24,13,3,192.168.201.223,0,427;428;429
3#E5_11,10,24,13,3,192.168.201.223,0,430;431;432
3#E5_12,10,24,13,3,192.168.201.223,0,433;434;435
3#E5_13,10,24,13,3,192.168.201.223,0,436;437;438
3#E5_14,10,24,13,3,192.168.201.223,0,439;440;441
3#E5_15,10,24,13,3,192.168.201.223,0,442;443;444
3#E5_16,10,24,13,3,192.168.201.223,0,445;446;447
3#E5_17,10,24,13,3,192.168.201.223,0,448;449;450
3#E5_18,10,24,13,3,192.168.201.223,0,451;452;453
3#E5_19,10,24,13,3,192.168.201.223,0,454;455;456
3#E5_20,10,24,13,3,192.168.201.223,0,457;458;459
3#E5_21,10,24,13,3,192.168.201.223,0,460;461;462
3#E5_22,10,24,13,3,192.168.201.223,0,463;464;465
3#E5_23,10,24,13,3,192.168.201.223,0,466;467;468
3#E5_24,10,24,13,3,192.168.201.223,0,469;470;471
3#E5_25,10,24,13,3,192.168.201.223,0,472;473;474
3#E5_26,10,24,13,3,192.168.201.223,0,475;476;477
3#E5_27,10,24,13,3,192.168.201.223,0,478;479;480
3#E5_28,10,24,13,3,192.168.201.223,0,481;482;483
3#E5_29,10,24,13,3,192.168.201.223,0,484;485;486
3#E5_30,10,24,13,3,192.168.201.223,0,487;488;489
3#E5_31,10,24,13,3,192.168.201.223,0,490;491;492
3#E5_32,10,24,13,3,192.168.201.223,0,493;494;495
3#E5_33,10,24,13,3,192.168.201.223,0,496;497;498
λÖÃ,ÓÅÏȼ¶,¸ß¶È,¿í¶È,ÁϲÖID,É豸IP,ÇøÓòID,µÆË÷Òý
1#A1_1,10,8,7,1,192.168.200.222,0,0
1#A1_2,10,8,7,1,192.168.200.222,0,1
1#A1_3,10,8,7,1,192.168.200.222,0,2
1#A1_4,10,8,7,1,192.168.200.222,0,3
1#A1_5,10,8,7,1,192.168.200.222,0,4
1#A1_6,10,8,7,1,192.168.200.222,0,5
1#A1_7,10,8,7,1,192.168.200.222,0,6
1#A1_8,10,8,7,1,192.168.200.222,0,7
1#A1_9,10,8,7,1,192.168.200.222,0,8
1#A1_10,10,8,7,1,192.168.200.222,0,9
1#A1_11,10,8,7,1,192.168.200.222,0,10
1#A1_12,10,8,7,1,192.168.200.222,0,11
1#A1_13,10,8,7,1,192.168.200.222,0,12
1#A1_14,10,8,7,1,192.168.200.222,0,13
1#A1_15,10,8,7,1,192.168.200.222,0,14
1#A1_16,10,8,7,1,192.168.200.222,0,15
1#A1_17,10,8,7,1,192.168.200.222,0,16
1#A1_18,10,8,7,1,192.168.200.222,0,17
1#A1_19,10,8,7,1,192.168.200.222,0,18
1#A1_20,10,8,7,1,192.168.200.222,0,19
1#A1_21,10,8,7,1,192.168.200.222,0,20
1#A1_22,10,8,7,1,192.168.200.222,0,21
1#A1_23,10,8,7,1,192.168.200.222,0,22
1#A1_24,10,8,7,1,192.168.200.222,0,23
1#A1_25,10,8,7,1,192.168.200.222,0,24
1#A1_26,10,8,7,1,192.168.200.222,0,25
1#A1_27,10,8,7,1,192.168.200.222,0,26
1#A1_28,10,8,7,1,192.168.200.222,0,27
1#A1_29,10,8,7,1,192.168.200.222,0,28
1#A1_30,10,8,7,1,192.168.200.222,0,29
1#A1_31,10,8,7,1,192.168.200.222,0,30
1#A1_32,10,8,7,1,192.168.200.222,0,31
1#A1_33,10,8,7,1,192.168.200.222,0,32
1#A1_34,10,8,7,1,192.168.200.222,0,33
1#A1_35,10,8,7,1,192.168.200.222,0,34
1#A1_36,10,8,7,1,192.168.200.222,0,35
1#A1_37,10,8,7,1,192.168.200.222,0,36
1#A1_38,10,8,7,1,192.168.200.222,0,37
1#A1_39,10,8,7,1,192.168.200.222,0,38
1#A1_40,10,8,7,1,192.168.200.222,0,39
,,,,,,,
1#A2_1,10,8,13,1,192.168.200.222,0,79
1#A2_2,10,8,13,1,192.168.200.222,0,78
1#A2_3,10,8,13,1,192.168.200.222,0,77
1#A2_4,10,8,13,1,192.168.200.222,0,76
1#A2_5,10,8,13,1,192.168.200.222,0,75
1#A2_6,10,8,13,1,192.168.200.222,0,74
1#A2_7,10,8,13,1,192.168.200.222,0,73
1#A2_8,10,8,13,1,192.168.200.222,0,72
1#A2_9,10,8,13,1,192.168.200.222,0,71
1#A2_10,10,8,13,1,192.168.200.222,0,70
1#A2_11,10,8,13,1,192.168.200.222,0,69
1#A2_12,10,8,13,1,192.168.200.222,0,68
1#A2_13,10,8,13,1,192.168.200.222,0,67
1#A2_14,10,8,13,1,192.168.200.222,0,66
1#A2_15,10,8,13,1,192.168.200.222,0,65
1#A2_16,10,8,13,1,192.168.200.222,0,64
1#A2_17,10,8,13,1,192.168.200.222,0,63
1#A2_18,10,8,13,1,192.168.200.222,0,62
1#A2_19,10,8,13,1,192.168.200.222,0,61
1#A2_20,10,8,13,1,192.168.200.222,0,60
1#A2_21,10,8,13,1,192.168.200.222,0,59
1#A2_22,10,8,13,1,192.168.200.222,0,58
1#A2_23,10,8,13,1,192.168.200.222,0,57
1#A2_24,10,8,13,1,192.168.200.222,0,56
1#A2_25,10,8,13,1,192.168.200.222,0,55
1#A2_26,10,8,13,1,192.168.200.222,0,54
1#A2_27,10,8,13,1,192.168.200.222,0,53
1#A2_28,10,8,13,1,192.168.200.222,0,52
1#A2_29,10,8,13,1,192.168.200.222,0,51
1#A2_30,10,8,13,1,192.168.200.222,0,50
1#A2_31,10,8,13,1,192.168.200.222,0,49
1#A2_32,10,8,13,1,192.168.200.222,0,48
1#A2_33,10,8,13,1,192.168.200.222,0,47
1#A2_34,10,8,13,1,192.168.200.222,0,46
1#A2_35,10,8,13,1,192.168.200.222,0,45
1#A2_36,10,8,13,1,192.168.200.222,0,44
1#A2_37,10,8,13,1,192.168.200.222,0,43
1#A2_38,10,8,13,1,192.168.200.222,0,42
1#A2_39,10,8,13,1,192.168.200.222,0,41
1#A2_40,10,8,13,1,192.168.200.222,0,40
,,,,,,,
1#A3_1,10,8,15,1,192.168.200.222,0,80
1#A3_2,10,8,15,1,192.168.200.222,0,81
1#A3_3,10,8,15,1,192.168.200.222,0,82
1#A3_4,10,8,15,1,192.168.200.222,0,83
1#A3_5,10,8,15,1,192.168.200.222,0,84
1#A3_6,10,8,15,1,192.168.200.222,0,85
1#A3_7,10,8,15,1,192.168.200.222,0,86
1#A3_8,10,8,15,1,192.168.200.222,0,87
1#A3_9,10,8,15,1,192.168.200.222,0,88
1#A3_10,10,8,15,1,192.168.200.222,0,89
1#A3_11,10,8,15,1,192.168.200.222,0,90
1#A3_12,10,8,15,1,192.168.200.222,0,91
1#A3_13,10,8,15,1,192.168.200.222,0,92
1#A3_14,10,8,15,1,192.168.200.222,0,93
1#A3_15,10,8,15,1,192.168.200.222,0,94
1#A3_16,10,8,15,1,192.168.200.222,0,95
1#A3_17,10,8,15,1,192.168.200.222,0,96
1#A3_18,10,8,15,1,192.168.200.222,0,97
1#A3_19,10,8,15,1,192.168.200.222,0,98
1#A3_20,10,8,15,1,192.168.200.222,0,99
1#A3_21,10,8,15,1,192.168.200.222,0,100
1#A3_22,10,8,15,1,192.168.200.222,0,101
1#A3_23,10,8,15,1,192.168.200.222,0,102
1#A3_24,10,8,15,1,192.168.200.222,0,103
1#A3_25,10,8,15,1,192.168.200.222,0,104
1#A3_26,10,8,15,1,192.168.200.222,0,105
1#A3_27,10,8,15,1,192.168.200.222,0,106
1#A3_28,10,8,15,1,192.168.200.222,0,107
1#A3_29,10,8,15,1,192.168.200.222,0,108
1#A3_30,10,8,15,1,192.168.200.222,0,109
1#A3_31,10,8,15,1,192.168.200.222,0,110
1#A3_32,10,8,15,1,192.168.200.222,0,111
1#A3_33,10,8,15,1,192.168.200.222,0,112
1#A3_34,10,8,15,1,192.168.200.222,0,113
1#A3_35,10,8,15,1,192.168.200.222,0,114
1#A3_36,10,8,15,1,192.168.200.222,0,115
1#A3_37,10,8,15,1,192.168.200.222,0,116
1#A3_38,10,8,15,1,192.168.200.222,0,117
1#A3_39,10,8,15,1,192.168.200.222,0,118
1#A3_40,10,8,15,1,192.168.200.222,0,119
位置,优先级,高度,宽度,料仓ID,设备IP,区域ID,灯索引
1#B1_1,10,8,7,1,192.168.200.222,0,0
1#B1_2,10,8,7,1,192.168.200.222,0,1
1#B1_3,10,8,7,1,192.168.200.222,0,2
1#B1_4,10,8,7,1,192.168.200.222,0,3
1#B1_5,10,8,7,1,192.168.200.222,0,4
1#B1_6,10,8,7,1,192.168.200.222,0,5
1#B1_7,10,8,7,1,192.168.200.222,0,6
1#B1_8,10,8,7,1,192.168.200.222,0,7
1#B1_9,10,8,7,1,192.168.200.222,0,8
1#B1_10,10,8,7,1,192.168.200.222,0,9
1#B1_11,10,8,7,1,192.168.200.222,0,10
1#B1_12,10,8,7,1,192.168.200.222,0,11
1#B1_13,10,8,7,1,192.168.200.222,0,12
1#B1_14,10,8,7,1,192.168.200.222,0,13
1#B1_15,10,8,7,1,192.168.200.222,0,14
1#B1_16,10,8,7,1,192.168.200.222,0,15
1#B1_17,10,8,7,1,192.168.200.222,0,16
1#B1_18,10,8,7,1,192.168.200.222,0,17
1#B1_19,10,8,7,1,192.168.200.222,0,18
1#B1_20,10,8,7,1,192.168.200.222,0,19
1#B1_21,10,8,7,1,192.168.200.222,0,20
1#B1_22,10,8,7,1,192.168.200.222,0,21
1#B1_23,10,8,7,1,192.168.200.222,0,22
1#B1_24,10,8,7,1,192.168.200.222,0,23
1#B1_25,10,8,7,1,192.168.200.222,0,24
1#B1_26,10,8,7,1,192.168.200.222,0,25
1#B1_27,10,8,7,1,192.168.200.222,0,26
1#B1_28,10,8,7,1,192.168.200.222,0,27
1#B1_29,10,8,7,1,192.168.200.222,0,28
1#B1_30,10,8,7,1,192.168.200.222,0,29
1#B1_31,10,8,7,1,192.168.200.222,0,30
1#B1_32,10,8,7,1,192.168.200.222,0,31
1#B1_33,10,8,7,1,192.168.200.222,0,32
1#B1_34,10,8,7,1,192.168.200.222,0,33
1#B1_35,10,8,7,1,192.168.200.222,0,34
1#B1_36,10,8,7,1,192.168.200.222,0,35
1#B1_37,10,8,7,1,192.168.200.222,0,36
1#B1_38,10,8,7,1,192.168.200.222,0,37
1#B1_39,10,8,7,1,192.168.200.222,0,38
1#B1_40,10,8,7,1,192.168.200.222,0,39
,,,,,,,
1#B2_1,10,8,13,1,192.168.200.222,0,79
1#B2_2,10,8,13,1,192.168.200.222,0,78
1#B2_3,10,8,13,1,192.168.200.222,0,77
1#B2_4,10,8,13,1,192.168.200.222,0,76
1#B2_5,10,8,13,1,192.168.200.222,0,75
1#B2_6,10,8,13,1,192.168.200.222,0,74
1#B2_7,10,8,13,1,192.168.200.222,0,73
1#B2_8,10,8,13,1,192.168.200.222,0,72
1#B2_9,10,8,13,1,192.168.200.222,0,71
1#B2_10,10,8,13,1,192.168.200.222,0,70
1#B2_11,10,8,13,1,192.168.200.222,0,69
1#B2_12,10,8,13,1,192.168.200.222,0,68
1#B2_13,10,8,13,1,192.168.200.222,0,67
1#B2_14,10,8,13,1,192.168.200.222,0,66
1#B2_15,10,8,13,1,192.168.200.222,0,65
1#B2_16,10,8,13,1,192.168.200.222,0,64
1#B2_17,10,8,13,1,192.168.200.222,0,63
1#B2_18,10,8,13,1,192.168.200.222,0,62
1#B2_19,10,8,13,1,192.168.200.222,0,61
1#B2_20,10,8,13,1,192.168.200.222,0,60
1#B2_21,10,8,13,1,192.168.200.222,0,59
1#B2_22,10,8,13,1,192.168.200.222,0,58
1#B2_23,10,8,13,1,192.168.200.222,0,57
1#B2_24,10,8,13,1,192.168.200.222,0,56
1#B2_25,10,8,13,1,192.168.200.222,0,55
1#B2_26,10,8,13,1,192.168.200.222,0,54
1#B2_27,10,8,13,1,192.168.200.222,0,53
1#B2_28,10,8,13,1,192.168.200.222,0,52
1#B2_29,10,8,13,1,192.168.200.222,0,51
1#B2_30,10,8,13,1,192.168.200.222,0,50
1#B2_31,10,8,13,1,192.168.200.222,0,49
1#B2_32,10,8,13,1,192.168.200.222,0,48
1#B2_33,10,8,13,1,192.168.200.222,0,47
1#B2_34,10,8,13,1,192.168.200.222,0,46
1#B2_35,10,8,13,1,192.168.200.222,0,45
1#B2_36,10,8,13,1,192.168.200.222,0,44
1#B2_37,10,8,13,1,192.168.200.222,0,43
1#B2_38,10,8,13,1,192.168.200.222,0,42
1#B2_39,10,8,13,1,192.168.200.222,0,41
1#B2_40,10,8,13,1,192.168.200.222,0,40
,,,,,,,
1#B3_1,10,8,15,1,192.168.200.222,0,80
1#B3_2,10,8,15,1,192.168.200.222,0,81
1#B3_3,10,8,15,1,192.168.200.222,0,82
1#B3_4,10,8,15,1,192.168.200.222,0,83
1#B3_5,10,8,15,1,192.168.200.222,0,84
1#B3_6,10,8,15,1,192.168.200.222,0,85
1#B3_7,10,8,15,1,192.168.200.222,0,86
1#B3_8,10,8,15,1,192.168.200.222,0,87
1#B3_9,10,8,15,1,192.168.200.222,0,88
1#B3_10,10,8,15,1,192.168.200.222,0,89
1#B3_11,10,8,15,1,192.168.200.222,0,90
1#B3_12,10,8,15,1,192.168.200.222,0,91
1#B3_13,10,8,15,1,192.168.200.222,0,92
1#B3_14,10,8,15,1,192.168.200.222,0,93
1#B3_15,10,8,15,1,192.168.200.222,0,94
1#B3_16,10,8,15,1,192.168.200.222,0,95
1#B3_17,10,8,15,1,192.168.200.222,0,96
1#B3_18,10,8,15,1,192.168.200.222,0,97
1#B3_19,10,8,15,1,192.168.200.222,0,98
1#B3_20,10,8,15,1,192.168.200.222,0,99
1#B3_21,10,8,15,1,192.168.200.222,0,100
1#B3_22,10,8,15,1,192.168.200.222,0,101
1#B3_23,10,8,15,1,192.168.200.222,0,102
1#B3_24,10,8,15,1,192.168.200.222,0,103
1#B3_25,10,8,15,1,192.168.200.222,0,104
1#B3_26,10,8,15,1,192.168.200.222,0,105
1#B3_27,10,8,15,1,192.168.200.222,0,106
1#B3_28,10,8,15,1,192.168.200.222,0,107
1#B3_29,10,8,15,1,192.168.200.222,0,108
1#B3_30,10,8,15,1,192.168.200.222,0,109
1#B3_31,10,8,15,1,192.168.200.222,0,110
1#B3_32,10,8,15,1,192.168.200.222,0,111
1#B3_33,10,8,15,1,192.168.200.222,0,112
1#B3_34,10,8,15,1,192.168.200.222,0,113
1#B3_35,10,8,15,1,192.168.200.222,0,114
1#B3_36,10,8,15,1,192.168.200.222,0,115
1#B3_37,10,8,15,1,192.168.200.222,0,116
1#B3_38,10,8,15,1,192.168.200.222,0,117
1#B3_39,10,8,15,1,192.168.200.222,0,118
1#B3_40,10,8,15,1,192.168.200.222,0,119
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{513BC1C9-800D-43A6-9499-3700BAEC3554}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SmartShelf.DeviceLibrary</RootNamespace>
<AssemblyName>DeviceLibrary</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PlatformTarget>AnyCPU</PlatformTarget>
</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>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Box\BOXManager.cs" />
<Compile Include="DeviceLibrary\led\BaseLedManager.cs" />
<Compile Include="DeviceLibrary\led\LEDColorModule.cs" />
<Compile Include="DeviceLibrary\led\LEDSingleModule.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Box\ServerManager.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{43cdd09e-fcf3-4960-a01d-3bbfe9933122}</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="function.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="Config\linePositions_A.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Config\linePositions_B.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Config\linePositions-A.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Config\linePositions.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Config\linePositions_4.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Config\linePositions_3.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Config\linePositions_2.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Config\linePositions_1.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Config\StoreConfig.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Config\XBYConfig\linePositions_1.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Config\XBYConfig\linePositions_2.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
using SmartShelf.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.DeviceLibrary
{
public class LEDManager
{
public static Dictionary<string, LEDBaseModule> deviceMap = new Dictionary<string, LEDBaseModule>();
public static byte DefaultLight = 100;
public static int DeviceLedType = ConfigAppSettings.GetIntValue(Setting_Init.DeviceLedType);
public void Init()
{
}
public static LEDBaseModule GetLedModule(string ip)
{
LEDBaseModule led = null;
if (deviceMap.ContainsKey(ip))
{
led = deviceMap[ip];
}
else
{
led = LEDBaseModule.GetModule(ip);
deviceMap.Add(ip, led);
}
return led;
}
public static int CurrLedStatus = -1;
private static int StatusLedDmx = 3;
public static void OpenSGreenLed()
{
if (DeviceLedType.Equals(1))
{
}
else
{
CloseSLed();
CurrLedStatus = 1;
foreach (LEDBaseModule module in deviceMap.Values)
{
if (module is LEDSingleModule)
{
List<int> list = new List<int>();
for (int i = 2; i < LEDSingleModule.LIGHT_COUNT_PER_DMX; i += 3)
{
list.Add(i);
}
module.OnlyLightOn(Light.GetLights(StatusLedDmx, list, 200));
}
}
}
}
public static void OpenSYellowLed()
{
if (DeviceLedType.Equals(1))
{
}
else
{
CloseSLed();
CurrLedStatus = 2;
foreach (LEDBaseModule module in deviceMap.Values)
{
if (module is LEDSingleModule)
{
List<int> list = new List<int>();
for (int i = 2; i < LEDSingleModule.LIGHT_COUNT_PER_DMX; i += 3)
{
list.Add(i - 2);
list.Add(i);
}
module.OnlyLightOn(Light.GetLights(StatusLedDmx, list, 200));
}
}
}
}
public static void CloseSLed()
{
if (DeviceLedType.Equals(1))
{
}
else
{
CurrLedStatus = 0;
foreach (LEDBaseModule module in deviceMap.Values)
{
if (module is LEDSingleModule)
{
module.AllLightOff(StatusLedDmx);
}
}
}
}
}
public abstract class LEDBaseModule
{
//DMX端口为6454, SPI端口为6858
protected IPEndPoint iep = null;
public string ModuleIP = "";
public static LEDBaseModule GetModule(string ip)
{
if (LEDManager.DeviceLedType.Equals(1))
{
LEDColorModule module = new LEDColorModule(ip);
return module;
}else
{
LEDSingleModule module = new LEDSingleModule(ip);
return module;
}
}
internal LEDBaseModule(string ip)
{
ModuleIP = ip;
iep = new IPEndPoint(IPAddress.Parse(ip), 6858);
AllLightOff();
}
public abstract void AllLightOff(int dmx = -1);
public abstract void AllLightOn(int dmx = -1);
public abstract void AllLightOn(Light light);
public abstract void OnlyLightOn(params Light[] lights);
public abstract void LightOn(params Light[] lights);
public abstract void LightOff(int dmx, params int[] lightIndexs);
public abstract void LightOff(params Light[] lights);
/// <summary>
/// 打包方法,可以将十六制字符串转成byte[] ,字符串没有空格
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
protected byte[] StringToByte(string s)
{
string temps = s.Replace(" ", "").Replace(":", "");
if (temps.Length % 2 != 0)
{
temps = "0" + temps;
}
byte[] tempb = new byte[temps.Length / 2];
int j = 0;
for (int i = 0; i < temps.Length; i = i + 2, j++)
{
tempb[j] = Convert.ToByte(temps.Substring(i, 2), 16);
}
byte[] send = new byte[j];
Array.Copy(tempb, send, j);
return send;
}
}
public class Light
{
public static Light StoreLight(int index)
{
return new Light(index, 50, 0, 0);
}
public static Light GetLight(int index, string color)
{
return GetLight(index, color, 50);
}
public static Light[] GetLights(string color, params int[] indexes)
{
List<Light> lights = new List<Light>();
foreach (int index in indexes)
{
lights.Add(GetLight(index, color));
}
return lights.ToArray();
}
public static Light GetLight(int index, string color, byte bright)
{
color = color.ToLower();
switch (color)
{
case "green":
return GreenLight(index, bright);
case "red":
return RedLight(index, bright);
case "yellow":
return YellowLight(index, bright);
case "blue":
return BlueLight(index, bright);
}
return StoreLight(index);
}
public static Light RedLight(int index, byte bright)
{
return new Light(index, bright, 0, 0);
}
public static Light RedLight(int index)
{
return RedLight(index, 50);
}
public static Light YellowLight(int index)
{
return YellowLight(index, 50);
}
public static Light YellowLight(int index, byte bright)
{
return new Light(index, bright, bright, 0);
}
public static Light BlueLight(int index)
{
return BlueLight(index, 50);
}
public static Light BlueLight(int index, byte bright)
{
return new Light(index, 0, 0, bright);
}
public static Light GreenLight(int index)
{
return new Light(index, 0, 50, 0);
}
public static Light GreenLight(int index, byte bright)
{
return new Light(index, 0, bright, 0);
}
public static Light CyanLight(int index)
{
return new Light(index, 0, 255, 255);
}
public static Light ChocolateLight(int index)
{
return new Light(index, 210, 105, 30);
}
public Light(int index, byte Red, byte Green, byte Blue)
{
this.index = index;
this.Red = Red;
this.Green = Green;
this.Blue = Blue;
}
public int index { get; set; }
public byte Red { get; set; }
public byte Green { get; set; }
public byte Blue { get; set; }
/// <summary>
/// 单色灯
/// </summary>
public static Light DefaultLight(int dmx, int index)
{
return new Light(dmx, index, LEDManager.DefaultLight);
}
/// <summary>
/// 单色灯
/// </summary>
public static Light[] GetLights(int dmx, List<int> leds, byte light = 200)
{
Light[] lights = new Light[leds.Count];
int i = 0;
foreach (int led in leds)
{
lights[i] = new Light(dmx, led, light);
i++;
}
return lights;
}
/// <summary>
/// 单色灯
/// </summary>
/// <param name="dmx">区域ID</param>
/// <param name="index">索引号</param>
/// <param name="lightValue">亮度</param>
public Light(int dmx, int index, byte lightValue)
{
this.index = index;
this.dmx = dmx;
this.lightValue = lightValue;
}
public int dmx { get; set; }
public byte lightValue { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.DeviceLibrary
{
/// <summary>
/// 三色灯
/// </summary>
public class LEDColorModule : LEDBaseModule
{
private const ushort MAX_RGBDMX_UNI = 8;//定义8个RGB灯的DMX域缓存
//每个DMX域的灯数量
private const int LIGHT_COUNT_PER_DMX = 170;
//byte[][] dmxData = new byte[MAX_RGBDMX_UNI][];
private List<byte[]> dmxDatas = new List<byte[]>(MAX_RGBDMX_UNI);
internal LEDColorModule(string ip) : base(ip)
{
iep = new IPEndPoint(IPAddress.Parse(ip), 6858);
AllLightOff();
}
private void InitDatas()
{
dmxDatas = new List<byte[]>(MAX_RGBDMX_UNI);
for (int i = 0; i < MAX_RGBDMX_UNI; i++)
{
dmxDatas.Add(new byte[512]);
}
}
public override void AllLightOff(int dmx = -1)
{
InitDatas();
PushToDevice();
}
public override void AllLightOn(int dmx = -1)
{
AllLightOn(Light.StoreLight(1));
}
public override void AllLightOn(Light light)
{
for (int i = 0; i < MAX_RGBDMX_UNI; i++)
{
byte[] data = dmxDatas[i];
for (int lightIndex = 0; lightIndex < LIGHT_COUNT_PER_DMX; lightIndex++)
{
data[lightIndex * 3] = light.Red;
data[lightIndex * 3 + 1] = light.Blue;
data[lightIndex * 3 + 2] = light.Green;
//dmxDatas[i] = data;
}
}
PushToDevice();
}
/// <summary>
/// 只有某些灯亮,其他灯灭掉
/// </summary>
/// <param name="lights"></param>
public override void OnlyLightOn(params Light[] lights)
{
AllLightOff();
LightOn(lights);
}
/// <summary>
/// 在之前的状态之上点亮某些灯
/// </summary>
/// <param name="lights"></param>
public override void LightOn(params Light[] lights)
{
foreach (Light light in lights)
{
int dmxIndex = light.index / LIGHT_COUNT_PER_DMX;
int lightIndex = light.index % LIGHT_COUNT_PER_DMX;
byte[] data = dmxDatas[dmxIndex];
//SPI第二通道为蓝色,DMX第二通道为绿色
data[lightIndex * 3] = light.Green;
data[lightIndex * 3 + 1] = light.Red;
data[lightIndex * 3 + 2] = light.Blue;
}
PushToDevice();
}
public override void LightOff(int dmx, params int[] lightIndexs)
{
foreach (int lightId in lightIndexs)
{
int dmxIndex = lightId / LIGHT_COUNT_PER_DMX;
int lightIndex = lightId % LIGHT_COUNT_PER_DMX;
byte[] data = dmxDatas[dmxIndex];
//SPI第二通道为蓝色,DMX第二通道为绿色
data[lightIndex * 3] = 0;
data[lightIndex * 3 + 1] = 0;
data[lightIndex * 3 + 2] = 0;
}
PushToDevice();
}
public override void LightOff(params Light[] lights)
{
foreach (Light light in lights)
{
int lightId = light.index;
int dmxIndex = lightId / LIGHT_COUNT_PER_DMX;
int lightIndex = lightId % LIGHT_COUNT_PER_DMX;
byte[] data = dmxDatas[dmxIndex];
//SPI第二通道为蓝色,DMX第二通道为绿色
data[lightIndex * 3] = 0;
data[lightIndex * 3 + 1] = 0;
data[lightIndex * 3 + 2] = 0;
}
PushToDevice();
}
private void PushToDevice()
{
//闲置的时候会有不起作用的情况,这里多发几遍
for (int time = 0; time < 2; time++)
{
UdpClient myUdpClient = new UdpClient();
try
{
for (int i = 0; i < dmxDatas.Count; i++)
{
byte[] toSend = ToSPIData(i, dmxDatas[i]);
myUdpClient.Send(toSend, toSend.Length, iep);
}
}
catch (Exception err)
{
Console.WriteLine("发送失败");
}
finally
{
myUdpClient.Close();
}
}
}
/// <summary>
/// 46:51:35:31:32:4e:65:74: 数据包头[16]
//0b:00: OpCode
//40:
//06: 序列号
//00:
//01: 更新标准:0=写到缓存,未输出到dmxData;1=无缓存,立即输出到dmxData
//03: 0=没有广播,只控制指定域;1=对设备的所有端口广播;2=对某个子网内的所有域广播;3,对网络下的所有子网广播;0xff=对所有网络设备的所有口广播
//34: 字节的高4位为子网,字节的低4位为dmxData域,;子网:0~15,DMX域:0~15;
//02: IP灯光网络地址:0~127
//02:00: 通道数512
//00:00:00: 第0个灯RBG
//00:00:00: 第1个灯RBG
//...: 第n个灯RBG
/// </summary>
/// <returns></returns>
private byte[] ToSPIData(int dmxIndex, byte[] dmxData)
{
string head = "46:51:35:31:32:4e:65:74:";// 8字节数据包头: "FQ512Net"
string OpCode = "0b:00:"; //指令2字节
string beforeSeq = "40";
string seq = "ca";
string afterSeq = "aa";
string UpdateFlag = "01";//更新标准:0=写到缓存,未输出到dmxData;1=无缓存,立即输出到dmxData
string Broadcast = "0";//0=没有广播,只控制指定域;1=对设备的所有端口广播;2=对某个子网内的所有域广播;3,对网络下的所有子网广播;0xff=对所有网络设备的所有口广播
string SubUni = "00";// IP灯光子网地址:0~255;子网又可分,字节的高4位为子网,字节的低4位为dmxData域,;子网:0~15,DMX域:0~15;
string net = "" + dmxIndex + "00"; //IP灯光网络地址:0~127
string preStr = head + OpCode + beforeSeq + seq + afterSeq + UpdateFlag + Broadcast + SubUni + net;
//preStr = "46513531324e65740b00400000010003";
byte[] preBytes = StringToByte(preStr);
byte[] toSend = new byte[preBytes.Length + dmxData.Length];
Array.Copy(preBytes, 0, toSend, 0, preBytes.Length);
Array.Copy(dmxData, 0, toSend, preBytes.Length, dmxData.Length);
return toSend;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.DeviceLibrary
{
/// <summary>
/// 单通道LED灯控制
/// </summary>
public class LEDSingleModule : LEDBaseModule
{
//DMX端口为6454, SPI端口为6858
// IPEndPoint iep;
internal const ushort MAX_RGBDMX_UNI = 4;//定义4个RGB灯的DMX域缓存
//每个DMX域的灯数量
internal const int LIGHT_COUNT_PER_DMX = 512;
private List<byte[]> dmxDatas = new List<byte[]>(MAX_RGBDMX_UNI);
public string ModuleIP = "";
internal LEDSingleModule(string ip) : base(ip)
{
// iep = new IPEndPoint(IPAddress.Parse("192.168.1.220"), 6454);
// iep = new IPEndPoint(IPAddress.Parse(ip), 6454);
ModuleIP = ip;
// AllLightOff();
}
private void InitDatas()
{
dmxDatas = new List<byte[]>(MAX_RGBDMX_UNI);
for (int i = 0; i < MAX_RGBDMX_UNI; i++)
{
dmxDatas.Add(new byte[512]);
}
}
public override void AllLightOn(Light light)
{
SAllLightOn(light.dmx, light.lightValue);
}
public override void AllLightOff(int dmx = -1)
{
if (dmx < 0)
{
InitDatas();
for (int i = 0; i < MAX_RGBDMX_UNI; i++)
{
AllLightOff(i);
}
}
else
{
byte[] data = GetDmxData(dmx);
data = new byte[512];
UpdateDmxData(dmx, data);
PushToDevice(dmx);
}
}
public override void AllLightOn(int dmx = -1)
{
SAllLightOn(dmx, LEDManager.DefaultLight);
}
private void SAllLightOn(int dmx,int lightValue)
{
if (dmx < 0)
{
for (int i = 0; i < MAX_RGBDMX_UNI; i++)
{
AllLightOn(i);
}
}
else
{
byte[] data = GetDmxData(dmx);
for (int lightIndex = 0; lightIndex < LIGHT_COUNT_PER_DMX; lightIndex++)
{
data[lightIndex] =(byte) lightValue;
}
UpdateDmxData(dmx, data);
PushToDevice(dmx);
}
}
/// <summary>
/// 只有某些灯亮,其他灯灭掉
/// </summary>
/// <param name="lights"></param>
public override void OnlyLightOn(params Light[] lights)
{
for (int i = 0; i < MAX_RGBDMX_UNI; i++)
{
dmxDatas.Add(new byte[512]);
}
LightOn(lights);
}
/// <summary>
/// 在之前的状态之上点亮某些灯
/// </summary>
/// <param name="lights"></param>
public override void LightOn(params Light[] lights)
{
List<int> dmxs = new List<int>();
foreach (Light light in lights)
{
byte[] data = GetDmxData(light.dmx);
data[light.index] = LEDManager.DefaultLight;
UpdateDmxData(light.dmx, data);
if (!dmxs.Contains(light.dmx))
{
dmxs.Add(light.dmx);
}
}
PushToDevice(dmxs);
}
public override void LightOff(params Light[] lights)
{
List<int> dmxs = new List<int>();
foreach (Light light in lights)
{
byte[] data = GetDmxData(light.dmx);
data[light.index] = 0;
UpdateDmxData(light.dmx, data);
if (!dmxs.Contains(light.dmx))
{
dmxs.Add(light.dmx);
}
}
PushToDevice(dmxs);
}
public override void LightOff(int dmx, params int[] lightIndexs)
{
byte[] data = dmxDatas[dmx];
foreach (int lightId in lightIndexs)
{
data[lightId] = 0;
}
UpdateDmxData(dmx, data);
PushToDevice(dmx);
}
private byte[] GetDmxData(int dmx)
{
if (dmx < dmxDatas.Count)
{
return dmxDatas[dmx];
}
return new byte[512];
}
private bool UpdateDmxData(int dmx, byte[] data)
{
if (dmx < dmxDatas.Count)
{
dmxDatas[dmx] = data;
return true;
}
return false;
}
private void PushToDevice(List<int> dmxList)
{
foreach (int dmx in dmxList)
{
PushToDevice(dmx);
}
}
private void PushToDevice(int dmx)
{
//闲置的时候会有不起作用的情况,这里多发几遍
for (int time = 0; time < 2; time++)
{
UdpClient myUdpClient = new UdpClient();
try
{
if (dmx < 0)
{
for (int i = 0; i < MAX_RGBDMX_UNI; i++)
{
PushToDevice(i);
}
}
else
{
byte[] data = dmxDatas[dmx];
byte[] toSend = ToDmx(dmx, data);
myUdpClient.Send(toSend, toSend.Length, iep);
}
}
catch (Exception err)
{
Console.WriteLine("发送失败");
}
finally
{
myUdpClient.Close();
}
}
}
private byte[] ToDmx(int dmx, byte[] dmxdata)
{
string dmxStr = dmx.ToString().PadLeft(2, '0');
string preStr = "4172742d4e6574" + "000050" + "000e" + "0000" + dmxStr + "000200";
byte[] preBytes = StringToByte(preStr);
byte[] toSend = new byte[preBytes.Length + dmxdata.Length];
Array.Copy(preBytes, 0, toSend, 0, preBytes.Length);
Array.Copy(dmxdata, 0, toSend, preBytes.Length, dmxdata.Length);
return toSend;
}
}
}
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 © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("10193426-c259-4528-930a-9bdd47a6c8be")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [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;
namespace SmartShelf.LoadCSVLibrary
{
//这里利用AttributeUsage 来设置我们的自定义属性的应用范围,这里定义的可以用于类,结构和方法的声明
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public class CSVAttribute : Attribute
{
public CSVAttribute(string fieldName)
{
FieldName = fieldName;
}
private string fieldName;
public string FieldName
{
get { return fieldName; }
set { fieldName = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.LoadCSVLibrary
{
public class CVSFieldNotMatchingExection : ApplicationException
{
public CVSFieldNotMatchingExection(string message)
: base(message)
{
}
public override string Message
{
get
{
return base.Message;
}
}
}
public class PositionAlreadyExistingExection : ApplicationException
{
public PositionAlreadyExistingExection(string message)
: base(message)
{
}
public override string Message
{
get
{
return base.Message;
}
}
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.LoadCSVLibrary
{
public class CSVReaderBase
{
public static char Spilt_Char = ',';
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// 获取一个类所有的《字段,AttributeName列名》集合
/// </summary>
public static Dictionary<string, string> getProAttributeMap(Type type)
{
Dictionary<string, string> proCsvMap = new Dictionary<string, string>();
PropertyInfo[] props = type.GetProperties();
foreach (PropertyInfo prop in props)
{
CSVAttribute att = (CSVAttribute)prop.GetCustomAttribute(typeof(CSVAttribute), false);
if (att != null)
{
string csvName = att.FieldName;
proCsvMap.Add(prop.Name, csvName);
}
}
return proCsvMap;
}
/// <summary>
/// 获取一个类所有的《字段,AttributeName列名》集合
/// </summary>
public static Dictionary<string, string> getConfigProAttributeMap(Type type)
{
Dictionary<string, string> proCsvMap = new Dictionary<string, string>();
PropertyInfo[] props = type.GetProperties();
foreach (PropertyInfo prop in props)
{
ConfigProAttribute att = (ConfigProAttribute)prop.GetCustomAttribute(typeof(ConfigProAttribute), false);
if (att != null)
{
string csvName = att.FieldName;
if (proCsvMap.ContainsKey(csvName))
{
}
else
{
proCsvMap.Add(csvName, prop.Name);
}
}
}
return proCsvMap;
}
/// <summary>
/// 读取一个csv文件的所有内容
/// </summary>
protected static string[] ReadCSVFile(string filePath)
{
if (!File.Exists(filePath))
{
throw new FileNotFoundException("未找到文件:" + filePath);
}
string[] lines = File.ReadAllLines(filePath, Encoding.GetEncoding("gbk"));
return lines;
}
/// <summary>
/// 把数据写入csv中
/// </summary>
protected static bool WriteCSVFile(string filePath, string[] lines)
{
try
{
if (File.Exists(filePath))
{
File.Delete(filePath);
}
File.WriteAllLines(filePath, lines, Encoding.GetEncoding("gbk"));
//备份保存
try
{
FileInfo file = new FileInfo(filePath);
string date = DateTime.Now.ToString("yyyy-MM-dd");
string targetBackPath = @"C:\configBack\" + date + @"\";
if (!Directory.Exists(targetBackPath))
{
Directory.CreateDirectory(targetBackPath);
}
string fileName = file.Name;
string backFile = targetBackPath + fileName;
if (File.Exists(backFile))
{
File.Delete(backFile);
}
File.WriteAllLines(backFile, lines, Encoding.GetEncoding("gbk"));
}
catch (Exception e)
{
LOGGER.Error("出错:", e);
}
}
catch (Exception ex)
{
LOGGER.Error(ex.ToString());
return false;
}
return true;
}
protected static Dictionary<string, int> GetAllTitleIndex(string lineValue)
{
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
var array = lineValue.Split(',');
//验证列
for (int i = 0; i < array.Length; i++)
{
string title = array[i];
titleIndex.Add(title, i);
}
return titleIndex;
}
protected static Dictionary<string, int> GetTitleIndex(string lineValue, List<string> cvsTitleList)
{
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
var array = lineValue.Split(',');
//验证列
for (int i = 0; i < array.Length; i++)
{
string title = array[i];
if (cvsTitleList.Contains(title))
{
titleIndex.Add(title, i);
}
}
if (titleIndex.Count < cvsTitleList.Count)
{
foreach (string str in cvsTitleList)
{
if (!titleIndex.ContainsKey(str))
{
LOGGER.Error("未找到必须列:" + str + ",加载数据失败!");
throw new CVSFieldNotMatchingExection("未找到必须列:" + str + ",加载数据失败!");
}
}
}
return titleIndex;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.LoadCSVLibrary</RootNamespace>
<AssemblyName>LoadCSVLibrary</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<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>
<Prefer32Bit>false</Prefer32Bit>
</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>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CSVExection.cs" />
<Compile Include="position\CSVPositionReader.cs" />
<Compile Include="position\BoxPosition.cs" />
<Compile Include="storeConfig\ConfigItemBase.cs" />
<Compile Include="storeConfig\ConfigProAttribute.cs" />
<Compile Include="storeConfig\config\BOX_Config.cs" />
<Compile Include="storeConfig\config\StoreType.cs" />
<Compile Include="storeConfig\config\Store_IO_Type.cs" />
<Compile Include="CSVAttribute.cs" />
<Compile Include="storeConfig\CSVConfigReader.cs" />
<Compile Include="CSVReaderBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="storeConfig\config\StoreConfig.cs" />
<Compile Include="position\StorePostionBase.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{43CDD09E-FCF3-4960-A01D-3BBFE9933122}</Project>
<Name>Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("LoadCVSLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LoadCVSLibrary")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("f9998ad1-83a5-4191-8109-7e255e71744e")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using SmartShelf.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.LoadCSVLibrary
{
public class BoxPosition : StorePostionBase
{
/// <summary>
/// 对应的料仓ID(流水线料仓需要用此字段区分哪个BOX)
/// </summary>
[CSVAttribute("料仓ID")]
public int StoreId { get; set; }
[CSVAttribute("区域ID")]
public int DmxId { get; set; }
[CSVAttribute("灯索引")]
public string LedIndex { get; set; }
[CSVAttribute("设备IP")]
public string DeviceIp { get; set; }
private List<int> LedList = null;
public List<int> GetLedList()
{
if (LedList == null)
{
LedList = new List<int>();
string[] arrays = LedIndex.Split(';');
if (arrays.Length > 0)
{
foreach (string str in arrays)
{
try
{
int led = Convert.ToInt32(str.Trim());
LedList.Add(led);
}catch(Exception ex)
{
}
}
}
}
return LedList;
}
}
}

using log4net;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.LoadCSVLibrary
{
public class CSVPositionReader<T> : CSVReaderBase where T : StorePostionBase
{
/// <summary>
/// 所有的位置集合,key=位置
/// </summary>
public static Dictionary<string, T> allPositionMap = new Dictionary<string, T>();
public static List<string> hasReadFileList = new List<string>();
/// <summary>
/// 重新加载配置,会删除之前的所有信息,重新读取
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static Dictionary<String, T> ReloadCSVFile(string filePath)
{
allPositionMap = new Dictionary<string, T>();
hasReadFileList = new List<string>();
return AddCSVFile(filePath);
}
public static List<string> getPositionKeyList()
{
return new List<string>(allPositionMap.Keys);
}
public static List<T> getPositionList()
{
List<T> list = new List<T>(allPositionMap.Values);
return list;
}
/// <summary>
/// 添加一个csv文件的数据到位置集合中
/// </summary>
/// <param name="filePath">cvs文件路径+文件名</param>
/// <returns></returns>
public static Dictionary<String, T> AddCSVFile(string filePath)
{
if (hasReadFileList.Contains(filePath))
{
LOGGER.Error("文件" + filePath + "已经加载过,直接返回null");
return null;
}
Type type = typeof(T);
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T));
if (proTitleMap.Count <= 4)
{
LOGGER.Error(typeof(T).ToString() + "只读取到" + proTitleMap.Count + "个属性");
}
List<string> cvsTitleList = new List<string>(proTitleMap.Values);
List<string> propertyList = new List<string>(proTitleMap.Keys);
Dictionary<String, T> result = new Dictionary<String, T>();
string[] lines =ReadCSVFile(filePath);
int index = 0;
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
foreach (var line in lines)
{
var array = line.Split(Spilt_Char);
if (index == 0)
{
titleIndex = GetTitleIndex(line, cvsTitleList);
}
else
{
try
{
if (array.Length >= titleIndex.Count)
{
if (array.Length > 0 && array[0].Equals(""))
{
continue;
}
var bllIns = type.Assembly.CreateInstance(type.FullName);
//取得属性集合
PropertyInfo[] props = type.GetProperties();
int listIndex = 0;
string PositionNum = "";
foreach (string key in cvsTitleList)
{
int titIndex = titleIndex[key];
string value = array[titIndex];
string proName = propertyList[listIndex];
PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性
if (prop != null && value != "")
{//如果属性存在
prop.SetValue(bllIns, Convert.ChangeType(value, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
if (proName.Equals("PositionNum"))
{
PositionNum = value;
}
listIndex++;
}
result.Add(PositionNum, (T)bllIns);
if (allPositionMap.ContainsKey(PositionNum))
{
throw new PositionAlreadyExistingExection("仓位:" + PositionNum + "已存在!");
}
allPositionMap.Add(PositionNum, (T)bllIns);
}
else
{
LOGGER.Error("读取csv,index=" + index + ",数据格式不匹配!,line=" + line);
}
}
catch (Exception ex)
{
LOGGER.Debug( "CSV 读取行【" + line + "】行转换失败"+ex.ToString());
}
}
index++;
}
LOGGER.Info("CSV 读取到[" + result.Count + "]条数据");
return result;
}
/// <summary>
/// 根据Key获得一个位置信息
/// </summary>
public static T GetPositon(string positionNum)
{
if (positionNum == null)
{
return null;
}
StorePostionBase result = null;
if (allPositionMap.ContainsKey(positionNum))
{
result = allPositionMap[positionNum];
return (T)result;
}
else
{
return null;
}
}
public static bool SavePostion(string filePath, T position)
{
Type type = typeof(T);
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T));
if (proTitleMap.Count <= 4)
{
LOGGER.Error(typeof(T).ToString() + "只读取到" + proTitleMap.Count + "个属性");
}
List<string> cvsTitleList = new List<string>(proTitleMap.Values);
List<string> propertyList = new List<string>(proTitleMap.Keys);
int positionNumIndex = propertyList.IndexOf("PositionNum");
int csvIndex = -1;
string[] lines = ReadCSVFile(filePath);
int index = 0;
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
foreach (var line in lines)
{
var array = line.Split(',');
if (index == 0)
{
titleIndex = GetTitleIndex(line, cvsTitleList);
}
else
{
if (array.Length == titleIndex.Count)
{
if (csvIndex < 0)
{
csvIndex = titleIndex[cvsTitleList[positionNumIndex]];
}
string value = array[csvIndex];
if (value.Equals(position.PositionNum))
{
//更新缓存
allPositionMap.Remove(position.PositionNum);
allPositionMap.Add(position.PositionNum, position);
string newValue = PostionToString(position, titleIndex, proTitleMap);
lines[index] = newValue;
return WriteCSVFile(filePath, lines);
}
}
}
index++;
}
return true;
}
private static string PostionToString(StorePostionBase position, Dictionary<string, int> titleIndex, Dictionary<string, string> proTitleMap)
{
//取得属性集合
PropertyInfo[] props = typeof(T).GetProperties();
List<string> cvsTitleList = new List<string>(proTitleMap.Values);
List<string> propertyList = new List<string>(proTitleMap.Keys);
String[] array = new String[titleIndex.Count];
foreach (string proName in proTitleMap.Keys)
{
PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性
if (prop != null)
{//如果属性存在
string value = prop.GetValue(position).ToString();
int index = titleIndex[proTitleMap[proName]];
array[index] = value;
}
}
string newStr = "";
foreach (string str in array)
{
if (newStr.Equals(""))
{
newStr = str;
}
else
{
newStr = newStr+Spilt_Char + str;
}
}
return newStr;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.LoadCSVLibrary
{
public class StorePostionBase
{
/// <summary>
/// 位置
/// </summary>
[CSVAttribute("位置")]
public string PositionNum { get; set; }
/// <summary>
/// 优先级
/// </summary>
[CSVAttribute("优先级")]
public int Priority { get; set; }
/// <summary>
/// 高
/// </summary>
[CSVAttribute("高度")]
public int BagHigh { get; set; }
/// <summary>
/// 宽
/// </summary>
[CSVAttribute("宽度")]
public int BagWidth { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.LoadCSVLibrary
{
public class CSVConfigReader : CSVReaderBase
{
private static Dictionary<Type, Dictionary<string, string>> allItemProTitleMap = null;
/// <summary>
/// 获取一个类所有的《字段,AttributeName列名》集合
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
private static Dictionary<string, string> GetProMapByType(Type type)
{
if (allItemProTitleMap == null)
{
allItemProTitleMap = new Dictionary<Type, Dictionary<string, string>>();
}
if (!allItemProTitleMap.ContainsKey(type))
{
allItemProTitleMap.Add(type, getProAttributeMap(type));
}
return allItemProTitleMap[type];
}
public static List<ConfigBase> ReadConfig(string filePath)
{
List<ConfigBase> configList = new List<ConfigBase>();
string[] lines = ReadCSVFile(filePath);
int index = 0;
Dictionary<string, int> allTitleIndex = new Dictionary<string, int>();
int typeIndex = -1;
foreach (var line in lines)
{
if (index == 0)
{
//根据配置表来读取数据
allTitleIndex = GetAllTitleIndex(line);
//必须有列【类型】
if (allTitleIndex.Count < 0 || !allTitleIndex.ContainsKey("类型"))
{
LOGGER.Error("未找到必须列:类型,加载数据失败!");
throw new CVSFieldNotMatchingExection("未找到必须列:类型,加载数据失败!");
}
typeIndex = allTitleIndex["类型"];
}
else
{
var array = line.Split(',');
//每一列必须有类型字段
string typeValue = array[typeIndex];
if (typeValue.Equals(""))
{
continue;
}
Type type = typeof(ConfigBase);
if (typeValue.Equals(ConfigItemType.DI) || typeValue.Equals(ConfigItemType.DO))
{
type = typeof(ConfigIO);
}
else if (typeValue.Equals(ConfigItemType.AXIS))
{
type = typeof(ConfigMoveAxis);
}
Dictionary<string, string> proTitleMap = getProAttributeMap(type);
ConfigBase bllIns = (ConfigBase)type.Assembly.CreateInstance(type.FullName);
//取得属性集合
PropertyInfo[] props = type.GetProperties();
int listIndex = 0;
List<string> proNameList = new List<string>(proTitleMap.Keys);
List<string> cvsTitleList = new List<string>(proTitleMap.Values);
List<string> checkFiledList = new List<string>(proNameList);
Dictionary<string, int> proIndexMap = new Dictionary<string, int>();
for (int i = 0; i<cvsTitleList.Count; i++)
{
proIndexMap.Add(cvsTitleList[i], i);
}
foreach (string key in cvsTitleList)
{
try
{
if (allTitleIndex.ContainsKey(key))
{
try
{
int titIndex = allTitleIndex[key];
string value = array[titIndex];
//string proName = proNameList[listIndex];
string proName = proNameList[proIndexMap[key]];
checkFiledList.Remove(proName);
PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性
if (prop != null && !value.Equals(""))
{
if (value.Equals("") && prop.PropertyType.Name.ToLower().Contains("int"))
{
prop.SetValue(bllIns, Convert.ChangeType(-1, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
else if (value.Equals("") && prop.PropertyType.Name.ToLower().Contains("byte"))
{
prop.SetValue(bllIns, Convert.ChangeType(0, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
else
{
prop.SetValue(bllIns, Convert.ChangeType(value, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
}
}
catch (Exception ex)
{
LOGGER.Error("filepath=" + filePath + ",index=" + index + ",key=" + key + "出错:" + ex.ToString());
}
listIndex++;
}
}
catch (Exception ex)
{
LOGGER.Error("filepath=" + filePath + ",index=" + index + ",key=" + key + "出错:" + ex.ToString());
}
}
bllIns.CheckField();
configList.Add(bllIns);
}
index++;
}
return configList;
}
public static StoreConfig LoadConfig(int storeId, string cid, string storeType, string filePath)
{
StoreConfig config = null;
if (storeType.Equals(StoreType.RC_PLC_SM))
{
config = new BOX_Config(storeId, cid, storeType, filePath);
}
else
{
LOGGER.Error("配置的料仓类型=" + storeType + "未找到处理方法!");
}
return LoadConfig(config);
}
public static StoreConfig LoadConfig(StoreConfig config)
{
LOGGER.Info("开始读取文件:" + config.ConfigFilePath);
if (config == null || config.ConfigFilePath.Equals(""))
{
return null;
}
List<ConfigBase> configList = ReadConfig(config.ConfigFilePath);
config.LoadConfig(configList);
return config;
}
public static bool SaveBoxPosition<T>(string filePath, T newConfig)
{
Type type = typeof(T);
//取得属性集合
PropertyInfo[] props = type.GetProperties();
string[] lines = ReadCSVFile(filePath);
int index = 0;
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
string[] newLines = new string[lines.Length] ;
// 获取一个类所有的《字段,AttributeName列名》集合
Dictionary<string, string> proMap = GetProMapByType(typeof(ConfigBase));
List<string> proNameList = new List<string>(proMap.Keys);
List<string> csvNameList = new List<string>(proMap.Values);
Dictionary<string, int> allTitleIndex = new Dictionary<string, int>();
foreach (var line in lines)
{
newLines[index] = line;
var array = line.Split(',');
if (index == 0)
{
allTitleIndex = GetAllTitleIndex(line);
newLines[index] = line;
}
else
{
if (array.Length > 0 && array[0].ToString().Equals(ConfigItemType.PRO))
{
string[] newArray = array;
string proName = array[2];
string proValue = array[3];
try
{
PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性
if (prop != null)
{
string newValue = prop.GetValue(newConfig).ToString();
newArray[3] = newValue;
}
}
catch (Exception e) {
LOGGER.Error("出错:" + e.ToString());
}
string newLine = "";
foreach (string s in newArray)
{
newLine = newLine + s + ",";
}
newLines[index] = newLine;
}
}
index++;
}
return WriteCSVFile(filePath, newLines);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.LoadCSVLibrary
{
//这里利用AttributeUsage 来设置我们的自定义属性的应用范围,这里定义的可以用于类,结构和方法的声明
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public class ConfigProAttribute : Attribute
{
public ConfigProAttribute(string fieldName)
{
FieldName = fieldName;
IsMust = true;
}
public ConfigProAttribute(string fieldName,bool ismust)
{
FieldName = fieldName;
IsMust = ismust;
}
private string fieldName;
public string FieldName
{
get { return fieldName; }
set { fieldName = value; }
}
/// <summary>
/// 是否必须的
/// </summary>
public bool IsMust { get; set; }
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.LoadCSVLibrary
{
/// <summary>
/// 手动料仓配置
/// </summary>
public class BOX_Config : StoreConfig
{
public BOX_Config()
: base()
{
}
public BOX_Config(int id, string cid, string type, string filepath)
: base(id, cid, type, filepath)
{
}
/// <summary>
/// 端口号
/// </summary>
[ConfigProAttribute("Door_PortName")]
public string Door_PortName { get; set; }
/// <summary>
/// PRO,IOIP,AIO_IP,192.168.200.11
/// </summary>
[ConfigProAttribute("AIO_IP")]
public string AIO_IP { get; set; }
/// <summary>
/// PRO 使用哪种IP模块 UseAIOBOX 1
/// </summary>
[ConfigProAttribute("UseAIOBOX")]
public int UseAIOBOX { get; set; }
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.LoadCSVLibrary
{
public class StoreConfig
{
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// ID
/// </summary>
public int Id { get; set; }
/// <summary>
/// 编号,与服务器通信的唯一标识
/// </summary>
public string CID { get; set; }
/// <summary>
/// 料层类型
/// </summary>
public string StoreType { get; set; }
/// <summary>
/// 配置文件路径
/// </summary>
public string ConfigFilePath { get; set; }
/// <summary>
/// 输入IO配置
/// 手动料仓输入Io列表,key=对应的坐标位置的positionNum
/// </summary>
public Dictionary<String, ConfigIO> StoreDIList { get; set; }
/// <summary>
/// 输出IO配置
/// 手动料仓输出Io列表,key=对应的坐标位置的positionNum
/// </summary>
public Dictionary<String, ConfigIO> StoreDOList { get; set; }
/// <summary>
/// 料仓所有用到的IO卡名称
/// </summary>
public List<string> DIODeviceNameList { get; set; }
/// <summary>
/// 料仓所有用到的运动卡名称
/// </summary>
public List<string> SMCDeviceNameList { get; set; }
/// <summary>
/// 必须拥有的DI列表
/// </summary>
protected List<string> MustHaveDIList { get; set; }
/// <summary>
/// 必须拥有的DO列表
/// </summary>
protected List<string> MustHaveDOList { get; set; }
protected virtual void initMustHavePro()
{
MustHaveDIList = new List<string>();
MustHaveDOList = new List<string>();
}
public StoreConfig()
{
initMustHavePro();
}
public StoreConfig(int id, string cid, string type, string filepath)
{
initMustHavePro();
MustHaveDIList = new List<string>();
MustHaveDOList = new List<string>();
this.Id = id;
this.CID = cid;
this.StoreType = type;
this.ConfigFilePath = filepath;
}
public virtual void LoadConfig(List<ConfigBase> configList)
{
StoreDIList = new Dictionary<string, ConfigIO>();
StoreDOList = new Dictionary<string, ConfigIO>();
DIODeviceNameList = new List<string>();
SMCDeviceNameList = new List<string>();
//取得属性集合
PropertyInfo[] props = GetType().GetProperties();
Dictionary<string, string> proMap = CSVReaderBase.getConfigProAttributeMap(GetType());
List<string> checkProList = new List<string>(proMap.Keys);//用来检测attribute属性都应该要配置值
foreach (ConfigBase con in configList)
{
if (con.ProType == ConfigItemType.AXIS || con.ProType == ConfigItemType.PRO)
{
if (proMap.ContainsKey(con.ProName))
{
string proName = proMap[con.ProName];
checkProList.Remove(con.ProName);
PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性
if (prop != null)
{
if (con.ProType == ConfigItemType.AXIS)
{
//如果属性存在
prop.SetValue(this, Convert.ChangeType(con, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
ConfigMoveAxis axis = (ConfigMoveAxis)con;
if (!SMCDeviceNameList.Contains(axis.DeviceName) && axis.GetAxisValue() >= 0)
{
SMCDeviceNameList.Add(axis.DeviceName);
}
}
else if (con.ProType == ConfigItemType.PRO)
{
prop.SetValue(this, Convert.ChangeType(con.ProVale, prop.PropertyType), null);//赋值
}
}
}
else
{
LOGGER.Error("配置文件:" + this.ConfigFilePath + ",属性名=" + con.ProName + "的属性未找到匹配字段!");
}
}
else if (con.ProType == ConfigItemType.DI)
{
if (Store_IO_Type.GetTypeList().Contains(con.ProName))
{
ConfigIO io = (ConfigIO)con;
if (!DIODeviceNameList.Contains(io.DeviceName) && (io.GetIOValue() >= 0 || io.GetIOAddr() >= 0))
{
DIODeviceNameList.Add(io.DeviceName);
}
this.StoreDIList.Add(con.ProName, io);
}
else
{
LOGGER.Error("配置文件:" + this.ConfigFilePath + ",属性名=" + con.ProName + "的属性未找到匹配字段!");
}
}
else if (con.ProType == ConfigItemType.DO)
{
if (Store_IO_Type.GetTypeList().Contains(con.ProName))
{
ConfigIO io = (ConfigIO)con;
if (!DIODeviceNameList.Contains(io.DeviceName) && io.GetIOValue() >= 0)
{
DIODeviceNameList.Add(io.DeviceName);
}
this.StoreDOList.Add(con.ProName, io);
}
else
{
LOGGER.Error("配置文件:" + this.ConfigFilePath + ",属性名=" + con.ProName + "的属性未找到匹配字段!");
}
}
}
if (checkProList.Count >= 0)
{
//常规属性检测
foreach (string str in checkProList)
{
PropertyInfo prop = props.First(c => c.Name == str);//获取同名属性
//判断是否必须要配置
ConfigProAttribute att = (ConfigProAttribute)prop.GetCustomAttribute(typeof(ConfigProAttribute), false);
if (att != null)
{
if (att.IsMust)
{
throw new CVSFieldNotMatchingExection(this.ToString() + "的属性" + str + "必须配置值!");
}
else
{
if (prop.PropertyType.Equals(typeof(int)))
{
prop.SetValue(this, Convert.ChangeType(0, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
else
{
prop.SetValue(this, Convert.ChangeType("", prop.PropertyType), null);//赋值****在这里需要考虑类型问题
}
}
}
}
//DI检测
foreach (string di in MustHaveDIList)
{
if (!StoreDIList.ContainsKey(di))
{
throw new CVSFieldNotMatchingExection(this.ToString() + "的DI属性" + di + "必须配置值!");
}
}
//DO检测
foreach (string io in MustHaveDOList)
{
if (!this.StoreDOList.ContainsKey(io))
{
throw new CVSFieldNotMatchingExection(this.ToString() + "的DO属性" + io + "必须配置值!");
}
}
}
}
public ConfigIO getWaitIO(string ioType)
{
if (StoreDIList.ContainsKey(ioType))
{
return StoreDIList[ioType];
}
else if (StoreDOList.ContainsKey(ioType))
{
return StoreDOList[ioType];
}
return null;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SmartShelf.LoadCSVLibrary
{
public class StoreType
{
/// <summary>
/// 双层在线料仓(电钢,康泰克板子,康奈德IO模块)料仓总配置
/// </summary>
public static string RC_DB_LINE = "RC_DB_LINE";
/// <summary>
/// 双层在线料仓(电钢,康泰克板子,康奈德IO模块)单个料仓配置
/// </summary>
public static string RC_DB_LA = "RC_DB_LA";
/// <summary>
/// 单台自动料仓 锁孔板PLC
/// </summary>
public static string RC_PLC_SM = "RC_PLC_SM";
/// <summary>
/// 康泰克流水线料仓_子料仓
/// </summary>
public static string RC_KTK_LA = "RC_KTK_LA";
/// <summary>
/// 康泰克流水线料仓_流水线
/// </summary>
public static string RC_KTK_LINE = "RC_KTK_LINE";
/// <summary>
/// 康泰克单台料仓
/// </summary>
public static string RC_KTK_SA = "RC_KTK_SA";
/// <summary>
/// 松下伺服485通信单台料仓
/// </summary>
public static string RC_AC_SA = "RC_AC_SA";
}
}

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.572
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{43CDD09E-FCF3-4960-A01D-3BBFE9933122}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceLibrary", "DeviceLibrary\DeviceLibrary.csproj", "{513BC1C9-800D-43A6-9499-3700BAEC3554}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadCSVLibrary", "LoadCVSLibrary\LoadCSVLibrary.csproj", "{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserFromControl", "UserFromControl\UserFromControl.csproj", "{F018462A-D9BC-4365-97F2-F6D71751641E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SingleLedShelf", "SmartShelf\SingleLedShelf.csproj", "{287A1E7D-F5A9-4D78-A407-0E4AE5DC29AF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SingleLedShelfClient", "SmartShelfClient\SingleLedShelfClient.csproj", "{B76CF298-C22C-415F-96EA-CD8C72AF47A1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{43CDD09E-FCF3-4960-A01D-3BBFE9933122}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43CDD09E-FCF3-4960-A01D-3BBFE9933122}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43CDD09E-FCF3-4960-A01D-3BBFE9933122}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43CDD09E-FCF3-4960-A01D-3BBFE9933122}.Release|Any CPU.Build.0 = Release|Any CPU
{513BC1C9-800D-43A6-9499-3700BAEC3554}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{513BC1C9-800D-43A6-9499-3700BAEC3554}.Debug|Any CPU.Build.0 = Debug|Any CPU
{513BC1C9-800D-43A6-9499-3700BAEC3554}.Release|Any CPU.ActiveCfg = Release|Any CPU
{513BC1C9-800D-43A6-9499-3700BAEC3554}.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
{287A1E7D-F5A9-4D78-A407-0E4AE5DC29AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{287A1E7D-F5A9-4D78-A407-0E4AE5DC29AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{287A1E7D-F5A9-4D78-A407-0E4AE5DC29AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{287A1E7D-F5A9-4D78-A407-0E4AE5DC29AF}.Release|Any CPU.Build.0 = Release|Any CPU
{B76CF298-C22C-415F-96EA-CD8C72AF47A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B76CF298-C22C-415F-96EA-CD8C72AF47A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B76CF298-C22C-415F-96EA-CD8C72AF47A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B76CF298-C22C-415F-96EA-CD8C72AF47A1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C406B809-5482-4234-9AA6-D2F89EEE184F}
EndGlobalSection
EndGlobal
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<appSettings>
<!--是否开机自动启动料仓-->
<add key="App_AutoRun" value="0"/>
<add key="App_Title" value="料架"/>
<!--服务器地址-->
<add key="http.server" value="http://192.168.200.22:8080/" />
<!--料架灯类型,0=单色灯料架,1=三色灯料架-->
<add key="DeviceLedType" value="0" />
<!--一下为一个料仓的默认配置 开始-->
<add key="Store_Position_Config" value="\Config\XBYConfig\linePositions.csv"/>
<add key="Store_ConfigPath" value="\Config\StoreConfig.csv" />
<add key="Store_CID" value="SmartShelf3" />
<add key ="DIMS" value="300"/>
<add key ="DOMS" value ="300"/>
<add key ="BoxCount" value ="2"/>
</appSettings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs/SmartShelf.log" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="INFO" />
<levelMax value="ERROR" />
</filter>
</appender>
<appender name="AIOBOXLog" type="log4net.Appender.RollingFileAppender">
<file value="logs/aio/AIOBOX1.log" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t] %m%n" />
</layout>
</appender>
<logger name="RollingLogFileAppender">
<level value="Info" />
<appender-ref ref="RollingLogFileAppender" />
</logger>
<logger name="AIOBOXLog">
<level value="Debug" />
<appender-ref ref="AIOBOXLog" />
</logger>
<root>
<level value="INFO" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
此文件类型无法预览
namespace SmartShelf
{
partial class FrmSmartShelf
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmSmartShelf));
this.tabControl1 = new System.Windows.Forms.TabControl();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.启动手动料仓ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.关闭手动料仓ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.退出程序ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.清理日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.chbAuto = new System.Windows.Forms.CheckBox();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
this.tabControl1.Location = new System.Drawing.Point(11, 31);
this.tabControl1.Multiline = true;
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(779, 532);
this.tabControl1.TabIndex = 1;
this.tabControl1.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.tabControl1_DrawItem);
//
// menuStrip1
//
this.menuStrip1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.启动手动料仓ToolStripMenuItem,
this.关闭手动料仓ToolStripMenuItem,
this.退出程序ToolStripMenuItem,
this.清理日志ToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1216, 28);
this.menuStrip1.TabIndex = 2;
this.menuStrip1.Text = "menuStrip1";
//
// 启动手动料仓ToolStripMenuItem
//
this.启动手动料仓ToolStripMenuItem.Name = "启动手动料仓ToolStripMenuItem";
this.启动手动料仓ToolStripMenuItem.Size = new System.Drawing.Size(77, 24);
this.启动手动料仓ToolStripMenuItem.Text = "启动料架";
this.启动手动料仓ToolStripMenuItem.Click += new System.EventHandler(this.启动手动料仓ToolStripMenuItem_Click);
//
// 关闭手动料仓ToolStripMenuItem
//
this.关闭手动料仓ToolStripMenuItem.Name = "关闭手动料仓ToolStripMenuItem";
this.关闭手动料仓ToolStripMenuItem.Size = new System.Drawing.Size(77, 24);
this.关闭手动料仓ToolStripMenuItem.Text = "关闭料架";
this.关闭手动料仓ToolStripMenuItem.Click += new System.EventHandler(this.关闭手动料仓ToolStripMenuItem_Click);
//
// 退出程序ToolStripMenuItem
//
this.退出程序ToolStripMenuItem.Name = "退出程序ToolStripMenuItem";
this.退出程序ToolStripMenuItem.Size = new System.Drawing.Size(77, 24);
this.退出程序ToolStripMenuItem.Text = "退出程序";
this.退出程序ToolStripMenuItem.Click += new System.EventHandler(this.退出程序ToolStripMenuItem_Click);
//
// 清理日志ToolStripMenuItem
//
this.清理日志ToolStripMenuItem.Name = "清理日志ToolStripMenuItem";
this.清理日志ToolStripMenuItem.Size = new System.Drawing.Size(77, 24);
this.清理日志ToolStripMenuItem.Text = "清理日志";
this.清理日志ToolStripMenuItem.Click += new System.EventHandler(this.清理日志ToolStripMenuItem_Click);
//
// contextMenuStrip1
//
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
//
// richTextBox1
//
this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.richTextBox1.Location = new System.Drawing.Point(802, 62);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(402, 500);
this.richTextBox1.TabIndex = 4;
this.richTextBox1.Text = "";
//
// chbAuto
//
this.chbAuto.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chbAuto.AutoSize = true;
this.chbAuto.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbAuto.Location = new System.Drawing.Point(802, 31);
this.chbAuto.Name = "chbAuto";
this.chbAuto.Size = new System.Drawing.Size(125, 25);
this.chbAuto.TabIndex = 271;
this.chbAuto.Text = "开机自动启动";
this.chbAuto.UseVisualStyleBackColor = true;
this.chbAuto.Visible = false;
this.chbAuto.CheckedChanged += new System.EventHandler(this.chbAuto_CheckedChanged);
//
// FrmSmartShelf
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1216, 574);
this.Controls.Add(this.chbAuto);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1;
this.Name = "FrmSmartShelf";
this.Text = "料架";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmSmartShelf_FormClosing);
this.Load += new System.EventHandler(this.FrmSmartShelf_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem 启动手动料仓ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 关闭手动料仓ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 退出程序ToolStripMenuItem;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem 清理日志ToolStripMenuItem;
public System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.CheckBox chbAuto;
}
}
\ No newline at end of file
using SmartShelf.Common;
using SmartShelf.DeviceLibrary;
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 SmartShelf
{
public partial class FrmSmartShelf : Form
{
public FrmSmartShelf()
{
InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false;
LogUtil.logBox = this.richTextBox1;
}
private bool LoadOk = false;
private List<TabPage> tabPageList = new List<TabPage>();
private void FrmSmartShelf_Load(object sender, EventArgs e)
{
chbAuto.Checked = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun).Equals(1);
LogUtil.showCount = 200;
string title = ConfigAppSettings.GetValue(Setting_Init.App_Title);
this.Text = title;
bool result = BOXManager.StartInit();
if (!result)
{
LogUtil.error("未加载到完整的配置");
Application.Exit();
}
LoadStoreData();
LoadOk = true;
}
private void LoadStoreData()
{
FrmSMStore test = new FrmSMStore(" 料架信息 ", BOXManager.PositionMap);
TabPage tabPage = new TabPage(" 料架信息 ");
tabPage.Text = BOXManager.BoxName;
tabPage.ToolTipText = BOXManager.BoxName;
tabPage.BackColor = Color.White;
test.TopLevel = false;
test.Parent = tabPage;
test.Dock = DockStyle.Fill;
test.Show();
tabPageList.Add(tabPage);
tabControl1.Controls.Add(tabPage);
}
private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
{
Font fntTab;
Brush bshBack;
Brush bshFore;
if (e.Index == this.tabControl1.SelectedIndex)
{
fntTab = new Font(e.Font, FontStyle.Bold);
bshBack = new SolidBrush(Color.Blue);
bshFore = Brushes.Black;
}
else
{
fntTab = e.Font;
bshBack = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, SystemColors.Control, SystemColors.Control, System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal);
bshFore = new SolidBrush(Color.Black);
}
string tabName = this.tabControl1.TabPages[e.Index].Text;
StringFormat sftTab = new StringFormat();
e.Graphics.FillRectangle(bshBack, e.Bounds);
Rectangle recTab = e.Bounds;
recTab = new Rectangle(recTab.X, recTab.Y + 4, recTab.Width, recTab.Height - 4);
e.Graphics.DrawString(tabName, fntTab, bshFore, recTab, sftTab);
}
private void 启动手动料仓ToolStripMenuItem_Click(object sender, EventArgs e)
{
if( BOXManager.StartRun()){
启动手动料仓ToolStripMenuItem.Enabled = false;
}
}
private void 关闭手动料仓ToolStripMenuItem_Click(object sender, EventArgs e)
{
BOXManager.StopRun();
启动手动料仓ToolStripMenuItem.Enabled = true;
}
private void 退出程序ToolStripMenuItem_Click(object sender, EventArgs e)
{
BOXManager.StopRun();
this.Close();
}
private void 清理日志ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Text = "";
}
private void FrmSmartShelf_FormClosing(object sender, FormClosingEventArgs e)
{
if (BOXManager.IsRun)
{
BOXManager.StopRun();
}
}
private void chbAuto_CheckedChanged(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
if (chbAuto.Checked)
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 1);
ManagerUtil.AutoRun(Application.ExecutablePath, true);
}
else
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 0);
ManagerUtil.AutoRun(Application.ExecutablePath, false);
}
}
}
}
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件类型无法预览
此文件类型无法预览
此文件的差异被折叠, 点击展开。
此文件的差异被折叠, 点击展开。
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!