1.初始化项目。保险起见bin目录完整提交 2.基于现场代码为调整过的初始项目(此次提交还未解决代码差异问题)
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
using Nancy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Nancy.ModelBinding;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace HxBusiness
|
||||
{
|
||||
public class APIContainer : NancyModule
|
||||
{
|
||||
public APIContainer()
|
||||
{
|
||||
var tasks = new Dictionary<int, string>();
|
||||
//Get["api/get"] = GetStr;
|
||||
Get("api/get", parameters => GetStr(parameters));
|
||||
//更新任务
|
||||
//Post("api/sendpermission") = UpdateTraffic;
|
||||
Post("api/sendpermission", parameters => UpdateTraffic(parameters));
|
||||
|
||||
}
|
||||
private object GetStr(dynamic o)
|
||||
{
|
||||
try
|
||||
{
|
||||
string str = Request.Query["id"];
|
||||
return "test Api" + str;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.ToString();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新任务
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
/// <returns></returns>
|
||||
private object UpdateTraffic(dynamic o)
|
||||
{
|
||||
ResponseModel resultmodel = new ResponseModel();
|
||||
try
|
||||
{
|
||||
string[] tagPoint = { "280", "282" };
|
||||
SendModel parmmodel = this.Bind<SendModel>();
|
||||
string str = JsonConvert.SerializeObject(parmmodel);
|
||||
WriteTxt.SaveLog1("接收到授权请求!" + str, "api日志");
|
||||
if (parmmodel.interchangePointCode.Equals(tagPoint[0]) || parmmodel.interchangePointCode.Equals(tagPoint[1]))
|
||||
{
|
||||
|
||||
resultmodel.code = 0;
|
||||
resultmodel.msg = "成功";
|
||||
resultmodel.data = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
resultmodel.code = -2;
|
||||
resultmodel.msg = "交汇点地标不存在!";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
resultmodel.code = -1;
|
||||
resultmodel.data = "服务器错误:" + ex.ToString();
|
||||
}
|
||||
return JsonConvert.SerializeObject(resultmodel);
|
||||
}
|
||||
|
||||
public object Root(dynamic o)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace HxBusiness
|
||||
{
|
||||
public class ConfigBiz
|
||||
{
|
||||
private const int TryReadWriteCount = 10;
|
||||
private int readcount = 0;
|
||||
private int writecount = 0;
|
||||
/// <summary>
|
||||
/// 指定程序目录
|
||||
/// </summary>
|
||||
private string xmlPath;
|
||||
//设置读写锁
|
||||
private ReaderWriterLockSlim objlock;
|
||||
public ConfigBiz()
|
||||
{
|
||||
xmlPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "/Config/";
|
||||
objlock = new ReaderWriterLockSlim();
|
||||
}
|
||||
/// <summary>
|
||||
/// 写json到文件
|
||||
/// </summary>
|
||||
/// <typeparam name="T">任意模型,根据模型匹配文件名</typeparam>
|
||||
/// <param name="list">返回指定模型数据</param>
|
||||
/// <returns></returns>
|
||||
public bool WriteDb<T>(object parm)
|
||||
{
|
||||
objlock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
string fileName = typeof(T).Name.ToString() + ".json";
|
||||
//如果没有则创建文件夹
|
||||
if (!Directory.Exists(xmlPath))
|
||||
{
|
||||
Directory.CreateDirectory(xmlPath);
|
||||
}//如果没有则创建文件
|
||||
if (!File.Exists(xmlPath + fileName))
|
||||
{
|
||||
FileStream fs1 = new FileStream(xmlPath + fileName, FileMode.Create, FileAccess.ReadWrite);
|
||||
fs1.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
//保证每次文件的更新
|
||||
FileInfo finfo = new FileInfo(xmlPath + fileName);
|
||||
finfo.Delete();
|
||||
FileStream fs1 = new FileStream(xmlPath + fileName, FileMode.Create, FileAccess.ReadWrite);
|
||||
fs1.Close();
|
||||
}
|
||||
File.WriteAllText(xmlPath + fileName, JsonConvert.SerializeObject(parm, Formatting.Indented));
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("write error!" + ex.ToString());
|
||||
//CreateLog.Log.Error("write error!" + ex.ToString());
|
||||
if (writecount < TryReadWriteCount)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
writecount++;
|
||||
WriteDb<T>(parm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
objlock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 读文件到json
|
||||
/// </summary>
|
||||
/// <typeparam name="T">任意模型,根据模型匹配文件名</typeparam>
|
||||
/// <returns></returns>
|
||||
public string ReadDb<T>()
|
||||
{
|
||||
//using (BaseAccess access = new BaseAccess())
|
||||
//{
|
||||
// List<AgvInfo> lsit = access.Select<AgvInfo>();
|
||||
//}
|
||||
objlock.EnterReadLock();
|
||||
try
|
||||
{
|
||||
string fileName = typeof(T).Name.ToString() + ".json";
|
||||
//如果没有则创建文件夹
|
||||
if (!Directory.Exists(xmlPath))
|
||||
{
|
||||
Directory.CreateDirectory(xmlPath);
|
||||
}//如果没有则创建文件
|
||||
if (!File.Exists(xmlPath + fileName))
|
||||
{
|
||||
FileStream fs1 = new FileStream(xmlPath + fileName, FileMode.Create, FileAccess.ReadWrite);
|
||||
fs1.Close();
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var temp = File.ReadAllText(xmlPath + fileName);
|
||||
return temp;
|
||||
//return JsonConvert.DeserializeObject<List<T>>(temp);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("read error!" + ex.ToString());
|
||||
if (readcount < TryReadWriteCount)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
readcount++;
|
||||
ReadDb<T>();
|
||||
}
|
||||
|
||||
//CreateLog.Log.Error("read error!" + ex.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
objlock.ExitReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Collections.Specialized;
|
||||
using System.Reflection;
|
||||
|
||||
namespace HxBusiness
|
||||
{
|
||||
public class ConnectedManager
|
||||
{
|
||||
public bool isOpen(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Ping p = new Ping();
|
||||
Uri uri = new Uri(url);
|
||||
if (p.Send(uri.Host, 150).Status == IPStatus.Success)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取配置信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetUrl(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
return "-1";
|
||||
}
|
||||
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
|
||||
request.Method = "GET";
|
||||
request.ContentType = "application/json";
|
||||
HttpWebResponse Response2 = request.GetResponse() as HttpWebResponse;
|
||||
StreamReader reader = new StreamReader(Response2.GetResponseStream(), Encoding.UTF8);
|
||||
string jsontmp = reader.ReadToEnd();
|
||||
reader.Close();
|
||||
Response2.Close();
|
||||
return jsontmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
return "-2";
|
||||
}
|
||||
}
|
||||
public string PostForUrl(string url, string postdb)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
return "-1";
|
||||
}
|
||||
byte[] byteArray = Encoding.UTF8.GetBytes(postdb);
|
||||
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
|
||||
//设置请求头
|
||||
SetHeaderValue(request.Headers, "owl-ois-adapter-tag", "HUAXIAO");
|
||||
request.Method = "POST";
|
||||
request.ContentType = "application/json";
|
||||
request.ContentLength = byteArray.Length;
|
||||
Stream newStream = request.GetRequestStream();//创建一个Stream,赋值是写入HttpWebRequest对象提供的一个stream里面
|
||||
newStream.Write(byteArray, 0, byteArray.Length);
|
||||
newStream.Close();
|
||||
HttpWebResponse Response2 = request.GetResponse() as HttpWebResponse;
|
||||
StreamReader reader = new StreamReader(Response2.GetResponseStream(), Encoding.UTF8);
|
||||
string jsontmp = reader.ReadToEnd();
|
||||
reader.Close();
|
||||
Response2.Close();
|
||||
return jsontmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("服务错误:" + ex.ToString() + "提示:" + ex.StackTrace);
|
||||
return "-2";
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetHeaderValue(WebHeaderCollection header, string name, string value)
|
||||
{
|
||||
var property = typeof(WebHeaderCollection).GetProperty("InnerCollection", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
if (property != null)
|
||||
{
|
||||
var collection = property.GetValue(header, null) as NameValueCollection;
|
||||
collection[name] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Nancy;
|
||||
using Nancy.Hosting.Self;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace HxBusiness
|
||||
{
|
||||
public class BusinessManage
|
||||
{
|
||||
#region 属性
|
||||
private ConnectedManager _webClient;
|
||||
private ConnectedManager webClient
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_webClient != null) return _webClient;
|
||||
else
|
||||
{
|
||||
_webClient = new ConnectedManager();
|
||||
return _webClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ApiModel _apiModel;
|
||||
public ApiModel apiModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_apiModel != null) return _apiModel;
|
||||
else
|
||||
{
|
||||
_apiModel = new ApiModel()
|
||||
{
|
||||
requestUrl = "http://192.168.128.1:8080",
|
||||
leaveUrl = "http://192.168.128.1:8080",
|
||||
sendUrl = "http://192.168.128.1:8080"
|
||||
};
|
||||
return _apiModel;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_apiModel = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
public BusinessManage()
|
||||
{
|
||||
try
|
||||
{
|
||||
//启动服务
|
||||
//数据处理
|
||||
string result = new ConfigBiz().ReadDb<ApiModel>();
|
||||
if (string.IsNullOrEmpty(result)) throw new Exception("请配置url");
|
||||
apiModel = JsonConvert.DeserializeObject<ApiModel>(result);
|
||||
//启动api服务
|
||||
//HostConfiguration hostConfigs = new HostConfiguration();
|
||||
//hostConfigs.UrlReservations.CreateAutomatically = true;
|
||||
//Uri uri = new Uri(apiModel.sendUrl);
|
||||
//var host = new NancyHost(hostConfigs, uri);
|
||||
//host.Start();
|
||||
WriteTxt.SaveLog1("启动api!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteTxt.SaveLog1("初始化失败!" + ex.ToString(), "异常日志");
|
||||
}
|
||||
}
|
||||
public void Request(string agvid, string rfid, AgvState state)
|
||||
{
|
||||
if (state == null || !state.agvid.ToString().Equals(agvid)) return;
|
||||
if (state.state == E_State.开始)
|
||||
{
|
||||
int requestCount = 0;
|
||||
bool result = false;
|
||||
ThreadPool.QueueUserWorkItem((o) =>
|
||||
{
|
||||
while (!result)
|
||||
{
|
||||
if (requestCount % 2 == 0)
|
||||
{
|
||||
result = RequestLeaved(agvid, rfid);
|
||||
requestCount++;
|
||||
}
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 请求离开
|
||||
/// </summary>
|
||||
/// <param name="agvid">设备编号</param>
|
||||
/// <param name="rfid">请求时地标</param>
|
||||
/// <returns></returns>
|
||||
public bool RequestLeaved(string agvid, string rfid)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (apiModel == null)
|
||||
{
|
||||
WriteTxt.SaveLog1("路口请求时配置为空!", "异常日志");
|
||||
return false;
|
||||
}
|
||||
if (string.IsNullOrEmpty(agvid) || string.IsNullOrEmpty(rfid))
|
||||
{
|
||||
WriteTxt.SaveLog1("路口请求时请求参数为空!", "异常日志");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
RequestModel model = new RequestModel()
|
||||
{
|
||||
equipmentCode = agvid,
|
||||
requestCode = "AGV" + agvid + "-" + rfid,
|
||||
arriveTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
|
||||
taskPriority = 100,
|
||||
taskDeadLine = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
|
||||
allowedQueueUp = false,
|
||||
interchangePointCode = rfid
|
||||
};
|
||||
string postStr = JsonConvert.SerializeObject(model);
|
||||
string result = webClient.PostForUrl(apiModel.requestUrl, postStr);
|
||||
|
||||
WriteTxt.SaveLog1(string.Format("路口请求url:{0},请求数据:{1},获取回复:{2}!", apiModel.requestUrl, postStr, result));
|
||||
ResponseModel response = JsonConvert.DeserializeObject<ResponseModel>(result);
|
||||
if (response.code == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteTxt.SaveLog1("路口请求离开异常!" + ex.ToString(), "异常日志");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 离开释放
|
||||
/// </summary>
|
||||
/// <param name="agvid">设备编号</param>
|
||||
/// <param name="rfid">离开时地标</param>
|
||||
/// <returns></returns>
|
||||
public bool ByLeaved(string agvid, string rfid, string Cross_Location_Go)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (apiModel == null)
|
||||
{
|
||||
WriteTxt.SaveLog1("离开时请求时配置为空!", "异常日志");
|
||||
return false;
|
||||
}
|
||||
if (string.IsNullOrEmpty(agvid) || string.IsNullOrEmpty(rfid))
|
||||
{
|
||||
WriteTxt.SaveLog1("离开时请求时请求参数为空!", "异常日志");
|
||||
return false;
|
||||
}
|
||||
|
||||
RequestLeavedModel model = new RequestLeavedModel()
|
||||
{
|
||||
adapterCode = "HUAXIAO",
|
||||
equipmentCode = agvid,
|
||||
requestCode = "AGV" + agvid + "-" + Cross_Location_Go,
|
||||
leaveTime = DateTime.Now.ToString("yyyyMMddHHmmssfff")
|
||||
};
|
||||
string postStr = JsonConvert.SerializeObject(model);
|
||||
string result = webClient.PostForUrl(apiModel.leaveUrl, postStr);
|
||||
|
||||
WriteTxt.SaveLog1(string.Format("离开请求url:{0},请求数据:{1},获取回复:{2}!", apiModel.requestUrl, postStr, result));
|
||||
ResponseModel response = JsonConvert.DeserializeObject<ResponseModel>(result);
|
||||
if (response.code == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteTxt.SaveLog1("离开时请求离开异常!" + ex.ToString(), "异常日志");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 被通知启动
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool GetStart()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 被通知停止
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool GetStop()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{183258A1-5B41-44ED-91B4-848CE91DEFB4}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>HxBusiness</RootNamespace>
|
||||
<AssemblyName>HxBusiness</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<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="Nancy, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\AGVSystem Ver2.0\packages\Nancy.2.0.0\lib\net452\Nancy.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Hosting.Self, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\AGVSystem Ver2.0\packages\Nancy.Hosting.Self.2.0.0\lib\net452\Nancy.Hosting.Self.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\AGVSystem Ver2.0\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<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="Api\APIContainer.cs" />
|
||||
<Compile Include="Api\ConfigBiz.cs" />
|
||||
<Compile Include="Api\ConnectedManager.cs" />
|
||||
<Compile Include="BusinessManage.cs" />
|
||||
<Compile Include="Model\AgvState.cs" />
|
||||
<Compile Include="Model\ApiModel.cs" />
|
||||
<Compile Include="Model\RequestModel.cs" />
|
||||
<Compile Include="Model\ResponseModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="WriteTxt.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace HxBusiness
|
||||
{
|
||||
public class AgvState
|
||||
{
|
||||
public int agvid { get; set; }
|
||||
public E_State state { get; set; }
|
||||
}
|
||||
public enum E_State
|
||||
{
|
||||
开始 = 0,
|
||||
请求中 = 1,
|
||||
收到 = 2,
|
||||
结束 = 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace HxBusiness
|
||||
{
|
||||
public class ApiModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 请求url
|
||||
/// </summary>
|
||||
public string requestUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 离开url
|
||||
/// </summary>
|
||||
public string leaveUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 通知url
|
||||
/// </summary>
|
||||
public string sendUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 请求间隔秒数
|
||||
/// </summary>
|
||||
public int requestSecond { get; set; }
|
||||
/// <summary>
|
||||
/// 请求地标列表
|
||||
/// </summary>
|
||||
public string waitRfidList { get; set; }
|
||||
/// <summary>
|
||||
/// 离开归还地标列表
|
||||
/// </summary>
|
||||
public string leavedRfidList { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace HxBusiness
|
||||
{
|
||||
public class RequestModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备编号,必须,长度20
|
||||
/// </summary>
|
||||
public string equipmentCode { get; set; }
|
||||
/// <summary>
|
||||
/// 请求编号 ,长度20
|
||||
/// </summary>
|
||||
public string requestCode { get; set; }
|
||||
/// <summary>
|
||||
/// 请求时间,格式yyyyMMddHHmmssSSS
|
||||
/// </summary>
|
||||
public string arriveTime { get; set; }
|
||||
/// <summary>
|
||||
/// 优先级,越大优先级越高
|
||||
/// </summary>
|
||||
public int taskPriority { get; set; }
|
||||
/// <summary>
|
||||
/// 最晚完成时间,格式yyyyMMddHHmmssSSS
|
||||
/// </summary>
|
||||
public string taskDeadLine { get; set; }
|
||||
/// <summary>
|
||||
/// 是否排除,True.要排队,False.不排队,默认False
|
||||
/// </summary>
|
||||
public bool allowedQueueUp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交汇点编号
|
||||
/// </summary>
|
||||
public string interchangePointCode { get; set; }
|
||||
}
|
||||
public class RequestLeavedModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 适配器编号
|
||||
/// </summary>
|
||||
public string adapterCode { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编号,必须,长度20
|
||||
/// </summary>
|
||||
public string equipmentCode { get; set; }
|
||||
/// <summary>
|
||||
/// 请求编号 ,长度20
|
||||
/// </summary>
|
||||
public string requestCode { get; set; }
|
||||
/// <summary>
|
||||
/// 离开时间,格式yyyyMMddHHmmssSSS
|
||||
/// </summary>
|
||||
public string leaveTime { get; set; }
|
||||
}
|
||||
public class SendModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备编号,必须,长度20
|
||||
/// </summary>
|
||||
public string equipmentCode { get; set; }
|
||||
/// <summary>
|
||||
/// 请求编号 ,长度20
|
||||
/// </summary>
|
||||
public string requestCode { get; set; }
|
||||
/// <summary>
|
||||
/// 离开时间,格式yyyyMMddHHmmssSSS
|
||||
/// </summary>
|
||||
public string issueTime { get; set; }
|
||||
/// <summary>
|
||||
/// 授权结果
|
||||
/// </summary>
|
||||
public int permissionResult { get; set; }
|
||||
/// <summary>
|
||||
/// 交汇区编号
|
||||
/// </summary>
|
||||
public string interchangeRegionCode { get; set; }
|
||||
/// <summary>
|
||||
/// 交汇点编号
|
||||
/// </summary>
|
||||
public string interchangePointCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace HxBusiness
|
||||
{
|
||||
public class ResponseModel
|
||||
{
|
||||
public ResponseModel()
|
||||
{
|
||||
code = -1;
|
||||
msg = "初始化错误!";
|
||||
data = "服务器错误!";
|
||||
}
|
||||
public int code { get; set; }
|
||||
public string msg { get; set; }
|
||||
public object data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("HxBusiness")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("HxBusiness")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("183258a1-5b41-44ed-91b4-848ce91defb4")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,149 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
namespace HxBusiness
|
||||
{
|
||||
public class WriteTxt
|
||||
{
|
||||
|
||||
private static object obj_saveLog1 = new object();
|
||||
/// <summary>
|
||||
/// AGV读取的地标值记录
|
||||
/// </summary>
|
||||
/// <param name="fileMsg">日志文件路径</param>
|
||||
/// <param name="filename">文件名称</param>
|
||||
/// <param name="Assembly_name">线体名称</param>
|
||||
public static void SaveLog1(string fileMsg, string filename="插件日志", string Assembly_name ="插件日志" )
|
||||
{
|
||||
lock (obj_saveLog1)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (FileStream _fStream = new FileStream(GetFilePath1(filename, Assembly_name) , FileMode.Append, FileAccess.Write))
|
||||
{
|
||||
using (StreamWriter _sWrite = new StreamWriter(_fStream))
|
||||
{
|
||||
_sWrite.WriteLine(GetCurrentTimeString() + fileMsg);
|
||||
_sWrite.Close();
|
||||
_fStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
SaveLog1(fileMsg, filename, Assembly_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static object obj_saveLog4 = new object();
|
||||
/// <summary>
|
||||
/// AGV读取的地标值记录
|
||||
/// </summary>
|
||||
/// <param name="fileMsg">日志文件路径</param>
|
||||
/// <param name="filename">文件名称</param>
|
||||
/// <param name="Assembly_name">线体名称</param>
|
||||
public static void SaveLog4(string fileMsg, string filename, string Assembly_name)
|
||||
{
|
||||
lock (obj_saveLog4)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (FileStream _fStream = new FileStream(GetFilePath1(filename, Assembly_name), FileMode.Append, FileAccess.Write))
|
||||
{
|
||||
using (StreamWriter _sWrite = new StreamWriter(_fStream))
|
||||
{
|
||||
_sWrite.WriteLine(GetCurrentTimeString() + fileMsg);
|
||||
_sWrite.Close();
|
||||
_fStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
SaveLog1(fileMsg, filename, Assembly_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetCurrentTimeString()
|
||||
{
|
||||
return "[" + DateTime.Now.ToLongTimeString() + "]:";//+ "." + DateTime.Now.Millisecond.ToString("000")
|
||||
}
|
||||
|
||||
private static string GetFilePath1(string str, string Assembly_Name)
|
||||
{
|
||||
string path = Application.StartupPath + @"\log\" + DateTime.Now.ToString("yyyyMMdd")+@"\"+ Assembly_Name;
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
string pa = Application.StartupPath + @"\log\" + DateTime.Now.ToString("yyyyMMdd") + @"\" + Assembly_Name;
|
||||
if (!Directory.Exists(pa))
|
||||
{
|
||||
Directory.CreateDirectory(pa);
|
||||
}
|
||||
return pa + @"\" + str + "_.log";
|
||||
}
|
||||
|
||||
private static object obj_saveLog2 = new object();
|
||||
public static void SaveLog2(string fileMsg)
|
||||
{
|
||||
lock (obj_saveLog2)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(@"c:\pathlog\"))
|
||||
{
|
||||
Directory.CreateDirectory(@"c:\pathlog\");
|
||||
}
|
||||
using (FileStream _fStream = new FileStream(@"c:\pathlog\" + DateTime.Now.ToString("yyyyMMdd") + "_.log", FileMode.Append, FileAccess.Write))
|
||||
{
|
||||
using (StreamWriter _sWrite = new StreamWriter(_fStream))
|
||||
{
|
||||
_sWrite.WriteLine(GetCurrentTimeString() + fileMsg);
|
||||
_sWrite.Close();
|
||||
_fStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
SaveLog2(fileMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static object obj_saveLog3 = new object();
|
||||
public static void SaveLog3(string fileMsg,string id)
|
||||
{
|
||||
lock (obj_saveLog3)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(@"c:\neclog\" + DateTime.Now.ToString("yyyyMMdd")))
|
||||
{
|
||||
Directory.CreateDirectory(@"c:\neclog\" + DateTime.Now.ToString("yyyyMMdd"));
|
||||
}
|
||||
using (FileStream _fStream = new FileStream(@"c:\neclog\" + DateTime.Now.ToString("yyyyMMdd") +@"\"+id+ "_.log", FileMode.Append, FileAccess.Write))
|
||||
{
|
||||
using (StreamWriter _sWrite = new StreamWriter(_fStream))
|
||||
{
|
||||
_sWrite.WriteLine(GetCurrentTimeString() + fileMsg);
|
||||
_sWrite.Close();
|
||||
_fStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
SaveLog3(fileMsg,id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Nancy" version="2.0.0" targetFramework="net48" />
|
||||
<package id="Nancy.Hosting.Self" version="2.0.0" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user