master
CaesarBao 3 weeks ago
parent 2a708e8c30
commit 2f2dc00969

@ -8,11 +8,13 @@
</startup>
<appSettings>
<add key="CollectID" value="101" />
<!--<add key="SqlString" value="Persist Security Info=True;Password=123456;User ID=sa;Initial Catalog=Newzhongjianjian;Data Source=127.0.0.1;Connection Timeout=5" />-->
<!--<add key="SqlString" value="Persist Security Info=True;Password=123456;User ID=sa;Initial Catalog=WLDB;Data Source=127.0.0.1;Connection Timeout=5" />-->
<add key="SqlString" value="Persist Security Info=True;Password=haiwei@123;User ID=sa;Initial Catalog=XJMIDDBTOMES;Data Source=119.45.202.115;Connection Timeout=5" />
<add key="UpdateUrl" value="ftp://118.24.158.141" />
<!--定时删除日志时间间隔(单位:月)-->
<add key="DeleteLogIntervel" value="2" />
<!--webapi端口号-->
<add key="ApiPort" value="6001" />
<!--是否启用光电信号回执功能(1:启用0:停用)-->
<add key="IsIOSendData" value="1" />

@ -121,20 +121,20 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="TouchSocket, Version=3.1.0.0, Culture=neutral, PublicKeyToken=5f39d7da98dac6a9, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.3.1.0\lib\net45\TouchSocket.dll</HintPath>
<Reference Include="TouchSocket, Version=3.1.4.0, Culture=neutral, PublicKeyToken=5f39d7da98dac6a9, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.3.1.4\lib\net45\TouchSocket.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.Core, Version=3.1.0.0, Culture=neutral, PublicKeyToken=d6c415a2f58eda72, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Core.3.1.0\lib\net45\TouchSocket.Core.dll</HintPath>
<Reference Include="TouchSocket.Core, Version=3.1.4.0, Culture=neutral, PublicKeyToken=d6c415a2f58eda72, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Core.3.1.4\lib\net45\TouchSocket.Core.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.Http, Version=3.1.0.0, Culture=neutral, PublicKeyToken=ecea290704fb8ddd, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Http.3.1.0\lib\net45\TouchSocket.Http.dll</HintPath>
<Reference Include="TouchSocket.Http, Version=3.1.4.0, Culture=neutral, PublicKeyToken=ecea290704fb8ddd, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Http.3.1.4\lib\net45\TouchSocket.Http.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.Rpc, Version=3.1.0.0, Culture=neutral, PublicKeyToken=15eb0d7aa187fa38, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Rpc.3.1.0\lib\net45\TouchSocket.Rpc.dll</HintPath>
<Reference Include="TouchSocket.Rpc, Version=3.1.4.0, Culture=neutral, PublicKeyToken=15eb0d7aa187fa38, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Rpc.3.1.4\lib\net45\TouchSocket.Rpc.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.WebApi, Version=3.1.0.0, Culture=neutral, PublicKeyToken=004e630594e1cb25, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.WebApi.3.1.0\lib\net45\TouchSocket.WebApi.dll</HintPath>
<Reference Include="TouchSocket.WebApi, Version=3.1.4.0, Culture=neutral, PublicKeyToken=004e630594e1cb25, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.WebApi.3.1.4\lib\net45\TouchSocket.WebApi.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@ -231,9 +231,9 @@
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\TouchSocket.Core.3.1.0\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
<Analyzer Include="..\packages\TouchSocket.Rpc.3.1.0\analyzers\dotnet\cs\TouchSocket.Rpc.SourceGenerator.dll" />
<Analyzer Include="..\packages\TouchSocket.WebApi.3.1.0\analyzers\dotnet\cs\TouchSocket.WebApi.SourceGenerator.dll" />
<Analyzer Include="..\packages\TouchSocket.Core.3.1.4\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
<Analyzer Include="..\packages\TouchSocket.Rpc.3.1.4\analyzers\dotnet\cs\TouchSocket.Rpc.SourceGenerator.dll" />
<Analyzer Include="..\packages\TouchSocket.WebApi.3.1.4\analyzers\dotnet\cs\TouchSocket.WebApi.SourceGenerator.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

@ -80,7 +80,7 @@ namespace HighWayAssemble
MesHttpClient.init();
var service = new HttpService();
await service.SetupAsync(new TouchSocketConfig()
.SetListenIPHosts(6001)
.SetListenIPHosts(int.Parse(System.Configuration.ConfigurationManager.AppSettings["ApiPort"]))
.ConfigureContainer(a =>
{
a.AddConsoleLogger();

@ -2,6 +2,7 @@
using Highway.Assemble.common;
using Highway.Assemble.Common;
using Highway.Assemble.EquipClient;
using Highway.Assemble.Sql;
using log4net;
using Mesnac.DeviceAdapter;
using System;
@ -18,10 +19,11 @@ namespace HighWayAssemble.Protocol
public class ApiServer : SingletonRpcServer
{
IEquipClient m_EquipClient = null;
ISql Sql = null;
public ApiServer()
{
m_EquipClient = App.Make<IEquipClient>();
Sql = App.Make<ISql>(System.Configuration.ConfigurationManager.AppSettings["SqlString"]);
}
[WebApi(Method = HttpMethodType.Post)]
@ -35,6 +37,18 @@ namespace HighWayAssemble.Protocol
Msg = "sucess",
};
}
[WebApi(Method = HttpMethodType.Post)]
public async Task<RFIDDeviceApiResponse<RFIDDeviceInfo>> basedata(string Requesttime)
{
List<RFIDDeviceInfo> rFIDDeviceInfos = Sql.GetRFIDEquipList();
return new RFIDDeviceApiResponse<RFIDDeviceInfo>
{
Code = 200,
Data = rFIDDeviceInfos,
Msg = "sucess",
};
}
/// <summary>
/// MES主动请求读取标签
/// </summary>
@ -81,7 +95,7 @@ namespace HighWayAssemble.Protocol
/// <returns></returns>
[WebApi(Method = HttpMethodType.Post)]
public async Task<ApiResponse<MesParaData>> revresult(MesAlarmLightPara mesAlarmLightPara)
{
{
FrmDisplayView.LogInfo.InfoFormat("接收MES控制报警灯指令{0},{1}", mesAlarmLightPara.EQUID, mesAlarmLightPara.Sendtime);
m_EquipClient.WriteAlarmLight(Int32.Parse(mesAlarmLightPara.EQUID), mesAlarmLightPara.Code);

@ -10,9 +10,9 @@
<package id="System.Text.Json" version="8.0.5" targetFramework="net461" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net452" requireReinstallation="true" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net452" requireReinstallation="true" />
<package id="TouchSocket" version="3.1.0" targetFramework="net452" />
<package id="TouchSocket.Core" version="3.1.0" targetFramework="net452" />
<package id="TouchSocket.Http" version="3.1.0" targetFramework="net452" />
<package id="TouchSocket.Rpc" version="3.1.0" targetFramework="net452" />
<package id="TouchSocket.WebApi" version="3.1.0" targetFramework="net452" />
<package id="TouchSocket" version="3.1.4" targetFramework="net461" />
<package id="TouchSocket.Core" version="3.1.4" targetFramework="net461" />
<package id="TouchSocket.Http" version="3.1.4" targetFramework="net461" />
<package id="TouchSocket.Rpc" version="3.1.4" targetFramework="net461" />
<package id="TouchSocket.WebApi" version="3.1.4" targetFramework="net461" />
</packages>

@ -21,7 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@ -52,12 +52,14 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Adapter.cs" />
<Compile Include="RFIDDeviceApiResponse.cs" />
<Compile Include="ApiResponse.cs" />
<Compile Include="Collect.cs" />
<Compile Include="DeviceState.cs" />
<Compile Include="Equip.cs" />
<Compile Include="IBOXDB.cs" />
<Compile Include="MesAlarmLightPara.cs" />
<Compile Include="RFIDDeviceInfo.cs" />
<Compile Include="MesReadRespon.cs" />
<Compile Include="MesReadPara.cs" />
<Compile Include="MesParaData.cs" />

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Highway.Assemble.Common
{
public class RFIDDeviceApiResponse<T>
{
/// <summary>
/// 状态码(如 200 成功400 失败500 错误)
/// </summary>
public int Code { get; set; }
/// <summary>
/// 消息(如 "操作成功"、"参数错误"
/// </summary>
public string Msg { get; set; }
/// <summary>
/// 返回数据
/// </summary>
public List<T> Data { get; set; }
}
}

@ -0,0 +1,10 @@
namespace Highway.Assemble.common
{
public class RFIDDeviceInfo
{
public string IPAddress { get; set; }
public string EQUID { get; set; }
public string position { get; set; }
}
}

@ -973,7 +973,7 @@ namespace Highway.Assemble.EquipClient
//sensor = GetSensorInfoByCombineId(Convert.ToUInt32(num));
if (deviceInfo.m_IDeviceAdapter != null)
{
flag = deviceInfo.m_IDeviceAdapter.Device_WriteAlarmLight(int.Parse(code), 2000);
flag = deviceInfo.m_IDeviceAdapter.Device_WriteAlarmLight(int.Parse(code), 10000);
//Thread.Sleep(3000);
//flag = deviceInfo.m_IDeviceAdapter.Device_WriteAlarmLight(2,2000);

@ -408,5 +408,54 @@ namespace Highway.Assemble.Sql
return 0;
}
}
public List<RFIDDeviceInfo> GetRFIDEquipList()
{
List<RFIDDeviceInfo> mesList = new List<RFIDDeviceInfo>();
if (dbHelper == null)
{
return mesList;
}
try
{
dbHelper.ClearParameter();
dbHelper.CommandType = CommandType.Text;//adapterid ="+mesID+"
dbHelper.CommandText = "";
string sql = "select t1.connectstr, t2.sensorid,t1.addr from base_device_info t1 left join [dbo].[base_sensor_info] t2 on t1.deviceid = t2.deviceid where t1.deleteflag != 1";
dbHelper.CommandText = sql;
DataTable dt = dbHelper.ToDataTable();
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
RFIDDeviceInfo mes = new RFIDDeviceInfo();
mes.EQUID = dt.Rows[i]["sensorid"].ToString();
mes.IPAddress = dt.Rows[i]["connectstr"].ToString();
mes.position = dt.Rows[i]["addr"].ToString();
mesList.Add(mes);
}
//
return mesList;
}
else
{
return null;
}
}
catch (Exception ex)
{
LogInfo.Fatal("获取服务器Ip错误" + ex.ToString());
return null;
}
finally
{
//dbHelper.CloseConnection();
}
}
}
}

@ -38,5 +38,7 @@ namespace Highway.Assemble.Sql
/// <param name="state">设备状态</param>
bool InsertCollectState(string ID, int state);
List<RFIDDeviceInfo> GetRFIDEquipList();
}
}

@ -35,9 +35,6 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference Include="Oracle.ManagedDataAccess">
<HintPath>..\Dll\Oracle.ManagedDataAccess.dll</HintPath>
</Reference>
<Reference Include="SqlSugar">
<HintPath>..\Dll\SqlSugar.dll</HintPath>
</Reference>
@ -59,9 +56,9 @@
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AUCMA.SCADA.Common\AUCMA.SCADA.Common.csproj">
<Project>{880c99cd-15b5-43d0-974c-8e05fb4a68a4}</Project>
<Name>AUCMA.SCADA.Common</Name>
<ProjectReference Include="..\Highway.Assemble.Common\Highway.Assemble.Common.csproj">
<Project>{514b888f-4d0d-4406-9396-5235a7bed7bf}</Project>
<Name>Highway.Assemble.Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

@ -18,8 +18,8 @@ namespace Highway.Assemble.SqlSugar.serviceImpl
{
_dbBase = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = "server = 172.18.29.71; uid = sa; pwd = haiwei@123; database = Newzhongjianjian",
//ConnectionString = "server = .; uid = sa; pwd = 123456; database = Newzhongjianjian",
ConnectionString = "server = 119.45.202.115; uid = sa; pwd = haiwei@123; database = XJMIDDBTOMES",
//ConnectionString = "server = 127.0.0.1; uid = sa; pwd = 123456; database = WLDB",
DbType = DbType.SqlServer,
InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息
IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样我就不多解释了

@ -1,14 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using System.ComponentModel;
using System.Net.Sockets;
using System.Collections;
using System.Threading;
using System.Net;
using Mesnac.Log;
namespace Mesnac.DeviceAdapter.RFly_I160
{

@ -37,9 +37,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\log4net.dll</HintPath>
</Reference>
<Reference Include="Mesnac.Log">
<HintPath>C:\Users\Administrator\Desktop\中间件及动态库设计\Mesnac读写器\动态库\Mesnac.Log.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />

@ -984,7 +984,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
//{
// tag.EPCstring = System.Text.Encoding.ASCII.GetString(tempDataByte);
//}
tag.EPCstring = System.Text.Encoding.ASCII.GetString(tempDataByte);
tag.EPCstring = StringChange.bytesToHexStr(tempDataByte, tempDataByte.Length).Substring(0, 8);
tag.PC = tempPCByte;
tag.Antana = tempDataANT;

Loading…
Cancel
Save