Commit 92c43c5a 张东亮

init

1 个父辈 82f8c8fa
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
...@@ -39,18 +39,15 @@ ...@@ -39,18 +39,15 @@
<Reference Include="Asa.IOModule.AIOBOX"> <Reference Include="Asa.IOModule.AIOBOX">
<HintPath>..\..\dll\Asa.IOModule.AIOBOX.dll</HintPath> <HintPath>..\..\dll\Asa.IOModule.AIOBOX.dll</HintPath>
</Reference> </Reference>
<Reference Include="Asa.RFID"> <Reference Include="Asa.RFID.HiStation">
<HintPath>..\..\dll\Asa.RFID.dll</HintPath> <HintPath>..\..\dll\Asa.RFID.HiStation.dll</HintPath>
</Reference>
<Reference Include="Asa.RFID.IReadAll">
<HintPath>..\..\dll\Asa.RFID.IReadAll.dll</HintPath>
</Reference> </Reference>
<Reference Include="Client"> <Reference Include="Client">
<HintPath>..\..\dll\Client.dll</HintPath> <HintPath>..\..\dll\Client.dll</HintPath>
</Reference> </Reference>
<Reference Include="CodeLibrary">
<HintPath>..\..\..\RC32-SZBOSCH-ACSingleStore\dll\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="halcondotnet">
<HintPath>..\..\..\RC32-SZBOSCH-ACSingleStore\dll\halcondotnet.dll</HintPath>
</Reference>
<Reference Include="HFReader9CSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64"> <Reference Include="HFReader9CSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\RFID\HFReader9CSharp.dll</HintPath> <HintPath>..\..\dll\RFID\HFReader9CSharp.dll</HintPath>
......
...@@ -5,16 +5,23 @@ using System.Collections.Concurrent; ...@@ -5,16 +5,23 @@ using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary namespace OnlineStore.DeviceLibrary
{ {
public class RFIDManager public class RFIDManager
{ {
private static ReadAll readAll =new ReadAll ("TheRFID"); private static Asa.RFID.ReadAll read;
private static bool IsOpen = false; private static bool IsOpen = false;
// private static ConcurrentDictionary<string, string> LastRfidMap = new ConcurrentDictionary<string, string>(); public static bool IsAuto = false;
public static void Open(string[] iparray) /// <summary>
/// 是否连接
/// </summary>
public static bool IsConnected { get; set; } = false;
private static Dictionary<string, string> LastRfidMap = new Dictionary<string, string>();
public static void Open(string[] ip)
{ {
if (IsOpen) if (IsOpen)
{ {
...@@ -22,15 +29,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -22,15 +29,9 @@ namespace OnlineStore.DeviceLibrary
} }
try try
{ {
int port = ConfigAppSettings.GetIntValue(Setting_Init.RfidServer_Port); read = new ReadAll("TheRFID");
if (port <= 0) read.Received += Read_Received;
{ read.Start(13001);
port = 13001;
}
// readAll.Received += ReadAll_Received;
// readAll.Log += ReadAll_Log;
LogUtil.info("RFID Server Open,port=" + port);
readAll.Start(port);
IsOpen = true; IsOpen = true;
} }
catch (Exception ex) catch (Exception ex)
...@@ -39,7 +40,27 @@ namespace OnlineStore.DeviceLibrary ...@@ -39,7 +40,27 @@ namespace OnlineStore.DeviceLibrary
} }
} }
private static string lastStr = ""; private static string lastStr = "";
private static void Read_Received(string ip, string id)
{
try
{
if(LastRfidMap.ContainsKey(ip))
{
LastRfidMap[ip] = id;
}
else
{
LastRfidMap.Add(ip,id);
}
}
catch (ObjectDisposedException ex)
{
//程序刚退出,又回传数据
}
}
private static void ReadAll_Log(string ip, string log) private static void ReadAll_Log(string ip, string log)
{ {
string str = "RFID : [" + ip + "] " + log; string str = "RFID : [" + ip + "] " + log;
...@@ -51,20 +72,21 @@ namespace OnlineStore.DeviceLibrary ...@@ -51,20 +72,21 @@ namespace OnlineStore.DeviceLibrary
lastStr = str; lastStr = str;
} }
public static RFIDData ReadRFID(string ip, bool isClear = false) public static RFIDData ReadRFID(string ip,bool isClear= true)
{ {
try try
{ {
if (String.IsNullOrEmpty(ip).Equals(false)) if (String.IsNullOrEmpty(ip).Equals(false) && read!=null)
{ {
string outValue = readAll.Read(ip);
if (isClear) if (isClear)
{ {
readAll.Clear(ip); read.Clear(ip);
} }
Thread.Sleep(100);
string outValue = read.Read(ip);
RFIDData data = new RFIDData(outValue); RFIDData data = new RFIDData(outValue);
return data; return data;
} }
} }
...@@ -80,10 +102,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -80,10 +102,15 @@ namespace OnlineStore.DeviceLibrary
{ {
try try
{ {
readAll.Stop(); if(IsOpen)
{
read.Stop();
IsOpen = false;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
IsOpen = false;
LogUtil.error("关闭RFID出错:" + ex.ToString()); LogUtil.error("关闭RFID出错:" + ex.ToString());
} }
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<add key="App_AutoRun" value="1" /> <add key="App_AutoRun" value="1" />
<add key="App_Title" value="VMI总仓进出料架缓存线" /> <add key="App_Title" value="VMI总仓进出料架缓存线" />
<!--Server address--> <!--Server address-->
<add key="http.server" value="http://10.85.160.25/myproject/" /> <add key="http.server" value="http://10.85.162.124/myproject/" />
<!--storeType--> <!--storeType-->
<add key="store_count" value="1" /> <add key="store_count" value="1" />
<!--start one store config--> <!--start one store config-->
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<add key="DIMS" value="60" /> <add key="DIMS" value="60" />
<add key="DOMS" value="300" /> <add key="DOMS" value="300" />
<!--AGV调度服务器地址--> <!--AGV调度服务器地址-->
<add key="AgvServerIp" value="192.168.103.12" /> <add key="AgvServerIp" value="10.85.162.40" />
<!--是否调试状态--> <!--是否调试状态-->
<add key="IsInDebug" value="1" /> <add key="IsInDebug" value="1" />
<add key ="Agv_Log_Open" value ="1"/> <add key ="Agv_Log_Open" value ="1"/>
...@@ -29,8 +29,11 @@ ...@@ -29,8 +29,11 @@
<file type="log4net.Util.PatternString" value="logs/vmiLine.log" /> <file type="log4net.Util.PatternString" value="logs/vmiLine.log" />
<param name="Encoding" value="UTF-8" /> <param name="Encoding" value="UTF-8" />
<appendToFile value="true" /> <appendToFile value="true" />
<rollingStyle value="Date" /> <param name="MaxSizeRollBackups" value="10"/>
<datePattern value="yyyy-MM-dd" /> <!-- 切割最多文件数 -->
<param name="MaximumFileSize" value="100MB"/>
<!-- 每个文件的大小 -->
<param name="RollingStyle" value="Size"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" /> <conversionPattern value="[%date][%t]%-5p %m%n" />
</layout> </layout>
...@@ -39,8 +42,11 @@ ...@@ -39,8 +42,11 @@
<file value="logs/TheRFID-vmi.log"/> <file value="logs/TheRFID-vmi.log"/>
<param name="Encoding" value="UTF-8" /> <param name="Encoding" value="UTF-8" />
<appendToFile value="true"/> <appendToFile value="true"/>
<rollingStyle value="Date"/> <param name="MaxSizeRollBackups" value="10"/>
<datePattern value="yyyy-MM-dd"/> <!-- 切割最多文件数 -->
<param name="MaximumFileSize" value="100MB"/>
<!-- 每个文件的大小 -->
<param name="RollingStyle" value="Size"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" /> <conversionPattern value="[%date][%t]%-5p %m%n" />
</layout> </layout>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!