提交 e5970666 编写于 作者: cdy816's avatar cdy816

完成历史数据查询接口

上级 f8d9aa03
......@@ -43,6 +43,8 @@ namespace Cdy.Tag
public static byte[] zoreData = new byte[1024 * 10];
private int mSize;
#endregion ...Variables...
#region ... Events ...
......@@ -60,21 +62,21 @@ namespace Cdy.Tag
Init(count);
}
/// <summary>
///
/// </summary>
/// <param name="handle"></param>
/// <param name="count"></param>
public HisQueryResult(IntPtr handle,int count)
{
this.handle = handle;
mCount = count;
mTimeAddr = count * mDataSize;
mQulityAddr = count * (mDataSize + 8);
mLenght = count;
mLimite = count;
mPosition = 0;
}
///// <summary>
/////
///// </summary>
///// <param name="handle"></param>
///// <param name="count"></param>
//public HisQueryResult(IntPtr handle,int count)
//{
// this.handle = handle;
// mCount = count;
// mTimeAddr = count * mDataSize;
// mQulityAddr = count * (mDataSize + 8);
// mLenght = count;
// mLimite = count;
// mPosition = 0;
//}
#endregion ...Constructor...
......@@ -101,6 +103,10 @@ namespace Cdy.Tag
{
return mCount;
}
set
{
mCount = value;
}
}
/// <summary>
......@@ -123,14 +129,41 @@ namespace Cdy.Tag
{
return mPosition;
}
set
{
mPosition = value;
}
}
public int Size
{
get
{
return mSize;
}
}
#endregion ...Properties...
#region ... Methods ...
/// <summary>
///
/// </summary>
/// <returns></returns>
public HisQueryResult<T> Contracts()
{
HisQueryResult<T> re = new HisQueryResult<T>(this.Count);
Buffer.MemoryCopy((void*)this.handle, (void*)re.handle, re.Size, mDataSize * Count);
Buffer.MemoryCopy((void*)(this.handle+ mTimeAddr), (void*)(re.handle+ re.mTimeAddr), re.Size, 8 * Count);
Buffer.MemoryCopy((void*)(this.handle + mQulityAddr), (void*)(re.handle + re.mQulityAddr), re.Size, Count);
re.mCount = this.mCount;
return re;
}
/// <summary>
///
/// </summary>
......@@ -156,6 +189,7 @@ namespace Cdy.Tag
handle = Marshal.AllocHGlobal(csize);
// handle = (void*)System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement(mDataBuffer, 0);
mLimite = count;
mSize = csize;
}
/// <summary>
......
......@@ -33,6 +33,11 @@ namespace Cdy.Tag
/// </summary>
public string Name { get; set; } = "local";
/// <summary>
/// 最后生成时间
/// </summary>
public string UpdateTime { get; set; } = "";
/// <summary>
///
/// </summary>
......
......@@ -74,6 +74,8 @@ namespace Cdy.Tag
RealDatabase db = new RealDatabase();
if (System.IO.File.Exists(path))
{
db.UpdateTime = new System.IO.FileInfo(path).LastWriteTimeUtc.ToString();
XElement xe = XElement.Load(path);
db.Name = xe.Attribute("Name").Value;
......
......@@ -126,8 +126,6 @@ namespace Cdy.Tag
/// </summary>
public async Task Int()
{
string datapath = GetPrimaryHisDataPath();
await Scan(datapath);
if (System.IO.Directory.Exists(datapath))
......
......@@ -180,17 +180,25 @@ namespace Cdy.Tag
/// <param name="result"></param>
public void ReadAllValue<T>(int id, DateTime startTime, DateTime endTime, HisQueryResult<T> result)
{
Tuple<DateTime, DateTime> mLogFileTimes;
var vfiles = GetFileManager().GetDataFiles(startTime, endTime, out mLogFileTimes, id);
vfiles.ForEach(e => {
DateTime sstart = e.StartTime > startTime ? e.StartTime : startTime;
DateTime eend = e.EndTime > endTime ? endTime : endTime;
e.ReadAllValue(id, sstart, eend, result);
});
try
{
Tuple<DateTime, DateTime> mLogFileTimes;
var vfiles = GetFileManager().GetDataFiles(startTime, endTime, out mLogFileTimes, id);
vfiles.ForEach(e =>
{
DateTime sstart = e.StartTime > startTime ? e.StartTime : startTime;
DateTime eend = e.EndTime > endTime ? endTime : endTime;
e.ReadAllValue(id, sstart, eend, result);
});
if (mLogFileTimes.Item1 != DateTime.MinValue)
if (mLogFileTimes.Item1 != DateTime.MinValue)
{
ReadLogFileAllValue(id, mLogFileTimes.Item1, mLogFileTimes.Item2, result);
}
}
catch(Exception ex)
{
ReadLogFileAllValue(id, mLogFileTimes.Item1, mLogFileTimes.Item2, result);
LoggerService.Service.Erro("QueryService", ex.StackTrace);
}
}
......
......@@ -252,13 +252,17 @@ namespace DBRunTime.ServiceApi
mb.WriteString(loginid);
infoRequreEvent.Reset();
Send(mb);
if (infoRequreEvent.WaitOne(timeout))
try
{
return mInfoRequreData.ReadString();
if (infoRequreEvent.WaitOne(timeout))
{
return mInfoRequreData.ReadString();
}
}
finally
{
mInfoRequreData?.ReleaseBuffer();
}
mInfoRequreData?.ReleaseBuffer();
return string.Empty;
}
......@@ -281,12 +285,17 @@ namespace DBRunTime.ServiceApi
mb.WriteInt(maxid);
this.realRequreEvent.Reset();
Send(mb);
if (realRequreEvent.WaitOne(timeout))
try
{
return mRealRequreData.ReadByte() > 0;
if (realRequreEvent.WaitOne(timeout))
{
return mRealRequreData.ReadByte() > 0;
}
}
finally
{
mRealRequreData?.ReleaseBuffer();
}
mRealRequreData?.ReleaseBuffer();
return true;
}
......@@ -303,11 +312,17 @@ namespace DBRunTime.ServiceApi
realRequreEvent.Reset();
Send(mb);
if (realRequreEvent.WaitOne(timeout))
try
{
return mRealRequreData.ReadByte() > 0;
if (realRequreEvent.WaitOne(timeout))
{
return mRealRequreData.ReadByte() > 0;
}
}
finally
{
mRealRequreData?.ReleaseBuffer();
}
mRealRequreData?.ReleaseBuffer();
return true;
}
......@@ -328,11 +343,18 @@ namespace DBRunTime.ServiceApi
realRequreEvent.Reset();
Send(mb);
if (realRequreEvent.WaitOne(timeout))
try
{
return mRealRequreData;
if (realRequreEvent.WaitOne(timeout))
{
return mRealRequreData;
}
}
mRealRequreData?.Release();
finally
{
mRealRequreData?.ReleaseBuffer();
}
return null;
}
......@@ -352,7 +374,7 @@ namespace DBRunTime.ServiceApi
{
return mRealRequreData;
}
mRealRequreData?.Release();
mRealRequreData?.ReleaseBuffer();
return null;
}
......@@ -448,10 +470,16 @@ namespace DBRunTime.ServiceApi
}
realRequreEvent.Reset();
Send(mb);
if (realRequreEvent.WaitOne(timeout))
try
{
return mRealRequreData.ReadByte()>0;
if (realRequreEvent.WaitOne(timeout))
{
return mRealRequreData.ReadByte() > 0;
}
}
finally
{
mRealRequreData?.ReleaseBuffer();
}
return false;
}
......@@ -551,10 +579,16 @@ namespace DBRunTime.ServiceApi
}
realRequreEvent.Reset();
Send(mb);
if (realRequreEvent.WaitOne(timeout))
try
{
return mRealRequreData.ReadByte() > 0;
if (realRequreEvent.WaitOne(timeout))
{
return mRealRequreData.ReadByte() > 0;
}
}
finally
{
mRealRequreData?.ReleaseBuffer();
}
return false;
}
......@@ -582,12 +616,17 @@ namespace DBRunTime.ServiceApi
this.hisRequreEvent.Reset();
Send(mb);
if (hisRequreEvent.WaitOne(timeout) && mHisRequreData.ReadableBytes>1)
try
{
return mHisRequreData;
if (hisRequreEvent.WaitOne(timeout) && mHisRequreData.ReadableBytes > 1)
{
return mHisRequreData;
}
}
finally
{
mHisRequreData?.ReleaseBuffer();
}
mHisRequreData?.ReleaseBuffer();
return null;
}
......@@ -613,12 +652,17 @@ namespace DBRunTime.ServiceApi
this.hisRequreEvent.Reset();
Send(mb);
if (hisRequreEvent.WaitOne(timeout) && mHisRequreData.ReadableBytes > 1)
try
{
return mHisRequreData;
if (hisRequreEvent.WaitOne(timeout) && mHisRequreData.ReadableBytes > 1)
{
return mHisRequreData;
}
}
finally
{
mHisRequreData?.ReleaseBuffer();
}
mHisRequreData?.ReleaseBuffer();
return null;
}
......@@ -643,12 +687,17 @@ namespace DBRunTime.ServiceApi
mb.WriteLong(span.Ticks);
this.hisRequreEvent.Reset();
Send(mb);
if (hisRequreEvent.WaitOne(timeout) && mHisRequreData.ReadableBytes > 1)
try
{
if (hisRequreEvent.WaitOne(timeout) && mHisRequreData.ReadableBytes > 1)
{
return mHisRequreData;
}
}
finally
{
return mHisRequreData;
mHisRequreData?.ReleaseBuffer();
}
mHisRequreData?.ReleaseBuffer();
return null;
}
......
<?xml version="1.0" encoding="utf-8" ?>
<Config Ip="127.0.0.1" Port="14330" LoginUser="Admin" LoginPassword="Admin" >
<Config>
<ProxyClient Ip="127.0.0.1" Port="14330" LoginUser="Admin" LoginPassword="Admin" WorkMode="0" PollCircle="1000" />
</Config>
\ No newline at end of file
......@@ -46,6 +46,10 @@ namespace DBRuntime.Proxy
private bool mIsClosed = false;
private NetTransformWorkMode mWorkMode = NetTransformWorkMode.Poll;
private int mPollCircle = 1000;
#endregion ...Variables...
#region ... Events ...
......@@ -54,6 +58,12 @@ namespace DBRuntime.Proxy
#region ... Constructor...
static DatabaseRunner()
{
//注册日志
ServiceLocator.Locator.Registor<ILog>(new ConsoleLogger());
}
#endregion ...Constructor...
#region ... Properties ...
......@@ -89,6 +99,9 @@ namespace DBRuntime.Proxy
if(System.IO.File.Exists(sfileName))
{
XElement xe = XElement.Load(sfileName);
if (xe.Element("ProxyClient") == null)
return;
xe = xe.Element("ProxyClient");
if(xe.Attribute("Ip")!=null)
{
mIp = xe.Attribute("Ip").Value;
......@@ -108,6 +121,16 @@ namespace DBRuntime.Proxy
{
mPassword = xe.Attribute("LoginPassword").Value;
}
if (xe.Attribute("WorkMode") != null)
{
mWorkMode = (NetTransformWorkMode) int.Parse(xe.Attribute("WorkMode").Value);
}
if (xe.Attribute("PollCircle") != null)
{
mPollCircle = int.Parse(xe.Attribute("PollCircle").Value);
}
}
}
......@@ -174,7 +197,7 @@ namespace DBRuntime.Proxy
string sname = mProxy.GetRunnerDatabase();
if(!string.IsNullOrEmpty(sname))
{
Load(sname);
CheckAndLoadDatabase(sname);
break;
}
}
......@@ -184,11 +207,20 @@ namespace DBRuntime.Proxy
}
}
/// <summary>
///
/// </summary>
private void CheckAndLoadDatabase(string database)
{
string[] sbase = database.Split(new char[] { ',' });
Load(sbase[0], sbase[1] + sbase[2]);
}
/// <summary>
///
/// </summary>
/// <param name="database"></param>
public void Load(string database)
public void Load(string database,string checkKey)
{
if (database == mDatabaseName) return;
......@@ -207,6 +239,14 @@ namespace DBRuntime.Proxy
if (CheckDatabaseExist(mDatabaseName))
{
var mDatabase = new DatabaseSerise().Load(mDatabaseName);
string skey = mDatabase.RealDatabase.Version + mDatabase.RealDatabase.UpdateTime;
if(skey!=checkKey)
{
LoggerService.Service.Warn("Proxy","代理使用的数据库和服务器使用的数据库不一致.");
}
this.mRealDatabase = mDatabase.RealDatabase;
mSecurityRunner = new SecurityRunner() { Document = mDatabase.Security };
}
......@@ -216,7 +256,7 @@ namespace DBRuntime.Proxy
RegistorInterface();
IsReady = true;
mDriver = new NetTransformDriver() { Client = mProxy.NetworkClient };
mDriver = new NetTransformDriver() { Client = mProxy.NetworkClient ,WorkMode=mWorkMode,PollCircle=mPollCircle};
mDriver.Start(realEnginer);
}
......
......@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
......@@ -193,69 +194,281 @@ namespace DBRuntime.Proxy
return dbClient.GetRunnerDatabase(dbClient.LoginId);
}
private unsafe HisQueryResult<T> ProcessHisResult<T>(IByteBuffer data)
//private unsafe Dictionary<DateTime,Tuple<object,byte>> ProcessHisResult<T>(IByteBuffer data, TagType tp)
//{
// Dictionary<DateTime, Tuple<object, byte>> re = new Dictionary<DateTime, Tuple<object, byte>>();
// int count = data.ReadInt();
// DateTime time;
// byte qu = 0;
// switch (tp)
// {
// case Cdy.Tag.TagType.Bool:
// for (int i = 0; i < count; i++)
// {
// var val = data.ReadBoolean();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(val, qu));
// }
// break;
// case Cdy.Tag.TagType.Byte:
// for (int i = 0; i < count; i++)
// {
// var val = data.ReadByte();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(val, qu));
// }
// break;
// case Cdy.Tag.TagType.DateTime:
// for (int i = 0; i < count; i++)
// {
// var val = new DateTime(data.ReadLong());
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(val, qu));
// }
// break;
// case Cdy.Tag.TagType.Double:
// for (int i = 0; i < count; i++)
// {
// var val = data.ReadDouble();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(val, qu));
// }
// break;
// case Cdy.Tag.TagType.Float:
// for (int i = 0; i < count; i++)
// {
// var val = data.ReadFloat();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(val, qu));
// }
// break;
// case Cdy.Tag.TagType.Int:
// for (int i = 0; i < count; i++)
// {
// var val = data.ReadInt();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(val, qu));
// }
// break;
// case Cdy.Tag.TagType.Long:
// for (int i = 0; i < count; i++)
// {
// var val = data.ReadLong();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(val, qu));
// }
// break;
// case Cdy.Tag.TagType.Short:
// for (int i = 0; i < count; i++)
// {
// var val = data.ReadShort();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(val, qu));
// }
// break;
// case Cdy.Tag.TagType.String:
// for (int i = 0; i < count; i++)
// {
// var val = data.ReadString();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(val, qu));
// }
// break;
// case Cdy.Tag.TagType.UInt:
// for (int i = 0; i < count; i++)
// {
// var val = (uint)data.ReadUnsignedInt();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(val, qu));
// }
// break;
// case Cdy.Tag.TagType.ULong:
// for (int i = 0; i < count; i++)
// {
// var val = (ulong)data.ReadLong();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(val, qu));
// }
// break;
// case Cdy.Tag.TagType.UShort:
// for (int i = 0; i < count; i++)
// {
// var val = (ulong)data.ReadUnsignedShort();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(val, qu));
// }
// break;
// case Cdy.Tag.TagType.IntPoint:
// for (int i = 0; i < count; i++)
// {
// var x = data.ReadInt();
// var y = data.ReadInt();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(new IntPointData(x,y), qu));
// }
// break;
// case Cdy.Tag.TagType.UIntPoint:
// for (int i = 0; i < count; i++)
// {
// var x = data.ReadUnsignedInt();
// var y = data.ReadUnsignedInt();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(new UIntPointData(x, y), qu));
// }
// break;
// case Cdy.Tag.TagType.IntPoint3:
// for (int i = 0; i < count; i++)
// {
// var x = data.ReadInt();
// var y = data.ReadInt();
// var z = data.ReadInt();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(new IntPoint3Data(x, y,z), qu));
// }
// break;
// case Cdy.Tag.TagType.UIntPoint3:
// for (int i = 0; i < count; i++)
// {
// var x = data.ReadUnsignedInt();
// var y = data.ReadUnsignedInt();
// var z = data.ReadUnsignedInt();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(new UIntPoint3Data(x, y,z), qu));
// }
// break;
// case Cdy.Tag.TagType.LongPoint:
// for (int i = 0; i < count; i++)
// {
// var x = data.ReadLong();
// var y = data.ReadLong();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(new LongPointData(x, y), qu));
// }
// break;
// case Cdy.Tag.TagType.ULongPoint:
// for (int i = 0; i < count; i++)
// {
// var x = (ulong)data.ReadLong();
// var y = (ulong)data.ReadLong();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(new ULongPointData(x, y), qu));
// }
// break;
// case Cdy.Tag.TagType.LongPoint3:
// for (int i = 0; i < count; i++)
// {
// var x = data.ReadLong();
// var y = data.ReadLong();
// var z = data.ReadLong();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(new LongPoint3Data(x, y,z), qu));
// }
// break;
// case Cdy.Tag.TagType.ULongPoint3:
// for (int i = 0; i < count; i++)
// {
// var x = (ulong)data.ReadLong();
// var y = (ulong)data.ReadLong();
// var z = (ulong)data.ReadLong();
// time = new DateTime(data.ReadLong());
// qu = data.ReadByte();
// re.Add(time, new Tuple<object, byte>(new ULongPoint3Data(x, y, z), qu));
// }
// break;
// }
// return re;
//}
private unsafe HisQueryResult<T> ProcessHisResultByMemory<T>(IByteBuffer data, TagType tp)
{
int size = data.Capacity - data.ReaderIndex;
HisQueryResult<T> re = new HisQueryResult<T>(size);
Buffer.MemoryCopy((void*)(data.AddressOfPinnedMemory() + data.ReaderIndex), (void*)re.Address, size, size);
int count = data.ReadInt();
HisQueryResult<T> re = new HisQueryResult<T>(count);
Marshal.Copy(data.Array, data.ArrayOffset + data.ReaderIndex, re.Address, data.ReadableBytes);
re.Count = count;
return re;
}
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="id"></param>
/// <param name="stime"></param>
/// <param name="etime"></param>
/// <returns></returns>
public HisQueryResult<T> QueryAllHisData<T>(int id,DateTime stime,DateTime etime)
public HisQueryResult<T> QueryAllHisData<T>(int id, DateTime stime, DateTime etime)
{
if(IsConnected)
if (IsConnected)
{
var res = dbClient.QueryAllHisValue(id, stime, etime);
TagType tp = (TagType) res.ReadByte();
if (res == null || res.ReadableBytes == 0) return null;
TagType tp = (TagType)res.ReadByte();
switch (tp)
{
case Cdy.Tag.TagType.Bool:
return ProcessHisResult<bool>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<bool>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Byte:
return ProcessHisResult<byte>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<byte>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.DateTime:
return ProcessHisResult<DateTime>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<DateTime>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Double:
return ProcessHisResult<double>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<double>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Float:
return ProcessHisResult<float>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<float>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Int:
return ProcessHisResult<int>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<int>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Long:
return ProcessHisResult<long>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<long>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Short:
return ProcessHisResult<short>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<short>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.String:
return ProcessHisResult<string>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<string>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.UInt:
return ProcessHisResult<uint>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<uint>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.ULong:
return ProcessHisResult<ulong>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<ulong>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.UShort:
return ProcessHisResult<ushort>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<ushort>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.IntPoint:
return ProcessHisResult<int>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<int>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.UIntPoint:
return ProcessHisResult<uint>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<uint>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.IntPoint3:
return ProcessHisResult<IntPoint3Data>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<IntPoint3Data>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.UIntPoint3:
return ProcessHisResult<UIntPoint3Data>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<UIntPoint3Data>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.LongPoint:
return ProcessHisResult<LongPointData>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<LongPointData>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.ULongPoint:
return ProcessHisResult<ULongPointTag>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<ULongPointTag>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.LongPoint3:
return ProcessHisResult<LongPoint3Data>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<LongPoint3Data>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.ULongPoint3:
return ProcessHisResult<ULongPoint3Data>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<ULongPoint3Data>(res, tp) as HisQueryResult<T>;
}
}
......@@ -272,122 +485,308 @@ namespace DBRuntime.Proxy
/// <param name="span"></param>
/// <param name="type"></param>
/// <returns></returns>
public HisQueryResult<T> QueryHisData<T>(int id, DateTime stime, DateTime etime,TimeSpan span,Cdy.Tag.QueryValueMatchType type)
public HisQueryResult<T> QueryHisData<T>(int id, DateTime stime, DateTime etime, TimeSpan span, Cdy.Tag.QueryValueMatchType type)
{
if (IsConnected)
{
var res = dbClient.QueryHisValueForTimeSpan(id, stime, etime,span,type);
var res = dbClient.QueryHisValueForTimeSpan(id, stime, etime, span, type);
if (res == null) return null;
TagType tp = (TagType)res.ReadByte();
switch (tp)
{
case Cdy.Tag.TagType.Bool:
return ProcessHisResult<bool>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<bool>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Byte:
return ProcessHisResult<byte>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<byte>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.DateTime:
return ProcessHisResult<DateTime>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<DateTime>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Double:
return ProcessHisResult<double>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<double>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Float:
return ProcessHisResult<float>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<float>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Int:
return ProcessHisResult<int>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<int>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Long:
return ProcessHisResult<long>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<long>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Short:
return ProcessHisResult<short>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<short>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.String:
return ProcessHisResult<string>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<string>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.UInt:
return ProcessHisResult<uint>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<uint>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.ULong:
return ProcessHisResult<ulong>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<ulong>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.UShort:
return ProcessHisResult<ushort>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<ushort>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.IntPoint:
return ProcessHisResult<int>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<int>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.UIntPoint:
return ProcessHisResult<uint>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<uint>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.IntPoint3:
return ProcessHisResult<IntPoint3Data>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<IntPoint3Data>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.UIntPoint3:
return ProcessHisResult<UIntPoint3Data>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<UIntPoint3Data>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.LongPoint:
return ProcessHisResult<LongPointData>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<LongPointData>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.ULongPoint:
return ProcessHisResult<ULongPointTag>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<ULongPointTag>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.LongPoint3:
return ProcessHisResult<LongPoint3Data>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<LongPoint3Data>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.ULongPoint3:
return ProcessHisResult<ULongPoint3Data>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<ULongPoint3Data>(res, tp) as HisQueryResult<T>;
}
}
return null;
}
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="id"></param>
/// <param name="times"></param>
/// <param name="type"></param>
/// <returns></returns>
public HisQueryResult<T> QueryHisData<T>(int id, List<DateTime> times, Cdy.Tag.QueryValueMatchType type)
{
if (IsConnected)
{
var res = dbClient.QueryHisValueAtTimes(id, times, type);
if (res == null) return null;
TagType tp = (TagType)res.ReadByte();
switch (tp)
{
case Cdy.Tag.TagType.Bool:
return ProcessHisResult<bool>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<bool>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Byte:
return ProcessHisResult<byte>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<byte>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.DateTime:
return ProcessHisResult<DateTime>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<DateTime>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Double:
return ProcessHisResult<double>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<double>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Float:
return ProcessHisResult<float>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<float>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Int:
return ProcessHisResult<int>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<int>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Long:
return ProcessHisResult<long>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<long>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.Short:
return ProcessHisResult<short>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<short>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.String:
return ProcessHisResult<string>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<string>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.UInt:
return ProcessHisResult<uint>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<uint>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.ULong:
return ProcessHisResult<ulong>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<ulong>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.UShort:
return ProcessHisResult<ushort>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<ushort>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.IntPoint:
return ProcessHisResult<int>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<int>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.UIntPoint:
return ProcessHisResult<uint>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<uint>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.IntPoint3:
return ProcessHisResult<IntPoint3Data>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<IntPoint3Data>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.UIntPoint3:
return ProcessHisResult<UIntPoint3Data>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<UIntPoint3Data>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.LongPoint:
return ProcessHisResult<LongPointData>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<LongPointData>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.ULongPoint:
return ProcessHisResult<ULongPointTag>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<ULongPointTag>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.LongPoint3:
return ProcessHisResult<LongPoint3Data>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<LongPoint3Data>(res, tp) as HisQueryResult<T>;
case Cdy.Tag.TagType.ULongPoint3:
return ProcessHisResult<ULongPoint3Data>(res) as HisQueryResult<T>;
return ProcessHisResultByMemory<ULongPoint3Data>(res, tp) as HisQueryResult<T>;
}
}
return null;
}
#region obslute QueryHisValue
///// <summary>
/////
///// </summary>
///// <param name="id"></param>
///// <param name="stime"></param>
///// <param name="etime"></param>
///// <returns></returns>
//public Dictionary<DateTime, Tuple<object, byte>> QueryAllHisData<T>(int id,DateTime stime,DateTime etime)
//{
// if(IsConnected)
// {
// var res = dbClient.QueryAllHisValue(id, stime, etime);
// if (res == null || res.ReadableBytes==0) return null;
// TagType tp = (TagType) res.ReadByte();
// switch (tp)
// {
// case Cdy.Tag.TagType.Bool:
// return ProcessHisResult<bool>(res,tp);
// case Cdy.Tag.TagType.Byte:
// return ProcessHisResult<byte>(res,tp);
// case Cdy.Tag.TagType.DateTime:
// return ProcessHisResult<DateTime>(res,tp);
// case Cdy.Tag.TagType.Double:
// return ProcessHisResult<double>(res,tp);
// case Cdy.Tag.TagType.Float:
// return ProcessHisResult<float>(res,tp);
// case Cdy.Tag.TagType.Int:
// return ProcessHisResult<int>(res,tp);
// case Cdy.Tag.TagType.Long:
// return ProcessHisResult<long>(res,tp);
// case Cdy.Tag.TagType.Short:
// return ProcessHisResult<short>(res,tp);
// case Cdy.Tag.TagType.String:
// return ProcessHisResult<string>(res,tp);
// case Cdy.Tag.TagType.UInt:
// return ProcessHisResult<uint>(res,tp);
// case Cdy.Tag.TagType.ULong:
// return ProcessHisResult<ulong>(res,tp);
// case Cdy.Tag.TagType.UShort:
// return ProcessHisResult<ushort>(res,tp);
// case Cdy.Tag.TagType.IntPoint:
// return ProcessHisResult<int>(res,tp);
// case Cdy.Tag.TagType.UIntPoint:
// return ProcessHisResult<uint>(res,tp);
// case Cdy.Tag.TagType.IntPoint3:
// return ProcessHisResult<IntPoint3Data>(res,tp);
// case Cdy.Tag.TagType.UIntPoint3:
// return ProcessHisResult<UIntPoint3Data>(res,tp);
// case Cdy.Tag.TagType.LongPoint:
// return ProcessHisResult<LongPointData>(res,tp);
// case Cdy.Tag.TagType.ULongPoint:
// return ProcessHisResult<ULongPointTag>(res,tp);
// case Cdy.Tag.TagType.LongPoint3:
// return ProcessHisResult<LongPoint3Data>(res,tp);
// case Cdy.Tag.TagType.ULongPoint3:
// return ProcessHisResult<ULongPoint3Data>(res,tp);
// }
// }
// return null;
//}
///// <summary>
/////
///// </summary>
///// <typeparam name="T"></typeparam>
///// <param name="id"></param>
///// <param name="stime"></param>
///// <param name="etime"></param>
///// <param name="span"></param>
///// <param name="type"></param>
///// <returns></returns>
//public Dictionary<DateTime, Tuple<object, byte>> QueryHisData<T>(int id, DateTime stime, DateTime etime,TimeSpan span,Cdy.Tag.QueryValueMatchType type)
//{
// if (IsConnected)
// {
// var res = dbClient.QueryHisValueForTimeSpan(id, stime, etime,span,type);
// if (res == null) return null;
// TagType tp = (TagType)res.ReadByte();
// switch (tp)
// {
// case Cdy.Tag.TagType.Bool:
// return ProcessHisResult<bool>(res,tp) ;
// case Cdy.Tag.TagType.Byte:
// return ProcessHisResult<byte>(res,tp) ;
// case Cdy.Tag.TagType.DateTime:
// return ProcessHisResult<DateTime>(res,tp) ;
// case Cdy.Tag.TagType.Double:
// return ProcessHisResult<double>(res,tp) ;
// case Cdy.Tag.TagType.Float:
// return ProcessHisResult<float>(res,tp) ;
// case Cdy.Tag.TagType.Int:
// return ProcessHisResult<int>(res,tp) ;
// case Cdy.Tag.TagType.Long:
// return ProcessHisResult<long>(res,tp) ;
// case Cdy.Tag.TagType.Short:
// return ProcessHisResult<short>(res,tp) ;
// case Cdy.Tag.TagType.String:
// return ProcessHisResult<string>(res,tp) ;
// case Cdy.Tag.TagType.UInt:
// return ProcessHisResult<uint>(res,tp) ;
// case Cdy.Tag.TagType.ULong:
// return ProcessHisResult<ulong>(res,tp) ;
// case Cdy.Tag.TagType.UShort:
// return ProcessHisResult<ushort>(res,tp) ;
// case Cdy.Tag.TagType.IntPoint:
// return ProcessHisResult<int>(res,tp) ;
// case Cdy.Tag.TagType.UIntPoint:
// return ProcessHisResult<uint>(res,tp) ;
// case Cdy.Tag.TagType.IntPoint3:
// return ProcessHisResult<IntPoint3Data>(res,tp) ;
// case Cdy.Tag.TagType.UIntPoint3:
// return ProcessHisResult<UIntPoint3Data>(res,tp) ;
// case Cdy.Tag.TagType.LongPoint:
// return ProcessHisResult<LongPointData>(res,tp) ;
// case Cdy.Tag.TagType.ULongPoint:
// return ProcessHisResult<ULongPointTag>(res,tp) ;
// case Cdy.Tag.TagType.LongPoint3:
// return ProcessHisResult<LongPoint3Data>(res,tp) ;
// case Cdy.Tag.TagType.ULongPoint3:
// return ProcessHisResult<ULongPoint3Data>(res,tp) ;
// }
// }
// return null;
//}
///// <summary>
/////
///// </summary>
///// <typeparam name="T"></typeparam>
///// <param name="id"></param>
///// <param name="times"></param>
///// <param name="type"></param>
///// <returns></returns>
//public Dictionary<DateTime, Tuple<object, byte>> QueryHisData<T>(int id, List<DateTime> times, Cdy.Tag.QueryValueMatchType type)
//{
// if (IsConnected)
// {
// var res = dbClient.QueryHisValueAtTimes(id, times, type);
// if (res == null) return null;
// TagType tp = (TagType)res.ReadByte();
// switch (tp)
// {
// case Cdy.Tag.TagType.Bool:
// return ProcessHisResult<bool>(res,tp) ;
// case Cdy.Tag.TagType.Byte:
// return ProcessHisResult<byte>(res,tp) ;
// case Cdy.Tag.TagType.DateTime:
// return ProcessHisResult<DateTime>(res,tp) ;
// case Cdy.Tag.TagType.Double:
// return ProcessHisResult<double>(res,tp) ;
// case Cdy.Tag.TagType.Float:
// return ProcessHisResult<float>(res,tp) ;
// case Cdy.Tag.TagType.Int:
// return ProcessHisResult<int>(res,tp) ;
// case Cdy.Tag.TagType.Long:
// return ProcessHisResult<long>(res,tp) ;
// case Cdy.Tag.TagType.Short:
// return ProcessHisResult<short>(res,tp) ;
// case Cdy.Tag.TagType.String:
// return ProcessHisResult<string>(res,tp) ;
// case Cdy.Tag.TagType.UInt:
// return ProcessHisResult<uint>(res,tp) ;
// case Cdy.Tag.TagType.ULong:
// return ProcessHisResult<ulong>(res,tp) ;
// case Cdy.Tag.TagType.UShort:
// return ProcessHisResult<ushort>(res,tp) ;
// case Cdy.Tag.TagType.IntPoint:
// return ProcessHisResult<int>(res,tp) ;
// case Cdy.Tag.TagType.UIntPoint:
// return ProcessHisResult<uint>(res,tp) ;
// case Cdy.Tag.TagType.IntPoint3:
// return ProcessHisResult<IntPoint3Data>(res,tp) ;
// case Cdy.Tag.TagType.UIntPoint3:
// return ProcessHisResult<UIntPoint3Data>(res,tp) ;
// case Cdy.Tag.TagType.LongPoint:
// return ProcessHisResult<LongPointData>(res,tp) ;
// case Cdy.Tag.TagType.ULongPoint:
// return ProcessHisResult<ULongPointTag>(res,tp) ;
// case Cdy.Tag.TagType.LongPoint3:
// return ProcessHisResult<LongPoint3Data>(res,tp) ;
// case Cdy.Tag.TagType.ULongPoint3:
// return ProcessHisResult<ULongPoint3Data>(res,tp) ;
// }
// }
// return null;
//}
#endregion
#endregion ...Methods...
#region ... Interfaces ...
......
......@@ -12,6 +12,14 @@ using System.Threading.Tasks;
namespace DBRuntime.Proxy
{
public enum NetTransformWorkMode
{
//主动获取模式
Poll,
//服务器主动推送
Push
}
public class NetTransformDriver : Cdy.Tag.Driver.IProducterDriver
{
......@@ -27,6 +35,8 @@ namespace DBRuntime.Proxy
private Thread mScanThread;
#endregion ...Variables...
#region ... Events ...
......@@ -44,6 +54,17 @@ namespace DBRuntime.Proxy
/// </summary>
public ApiClient Client { get; set; }
/// <summary>
///
/// </summary>
public NetTransformWorkMode WorkMode { get; set; }
/// <summary>
/// 查询周期
/// </summary>
public int PollCircle { get; set; } = 1000;
#endregion ...Properties...
#region ... Methods ...
......@@ -72,12 +93,23 @@ namespace DBRuntime.Proxy
{
while(!mIsClosed)
{
resetEvent.WaitOne();
if (mIsClosed) break;
resetEvent.Reset();
while(mCachDatas.Count>0)
if (WorkMode == NetTransformWorkMode.Push)
{
resetEvent.WaitOne();
if (mIsClosed) break;
resetEvent.Reset();
while (mCachDatas.Count > 0)
{
ProcessSingleBufferData(mCachDatas.Dequeue());
}
}
else
{
ProcessSingleBufferData(mCachDatas.Dequeue());
DateTime stime = DateTime.Now;
ReadAllData();
double span = (DateTime.Now - stime).TotalMilliseconds;
int sleeptime = span > PollCircle ? 1 : (int)(PollCircle - span);
Thread.Sleep(sleeptime);
}
}
}
......@@ -218,7 +250,10 @@ namespace DBRuntime.Proxy
ServiceLocator.Locator.Resolve<IRealDataNotifyForProducter>().SubscribeProducter("NetTransformDriver", ProcessValueChanged,
new Func<List<int>>(() => { return new List<int>() { -1 }; })
);
RegistorTag();
if (WorkMode == NetTransformWorkMode.Push)
RegistorTag();
ReadAllData();
mScanThread = new Thread(RemoteDataudpatePro);
mScanThread.IsBackground = true;
......
......@@ -13,7 +13,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using Cdy.Tag;
using System.Runtime.InteropServices;
namespace DBRuntime.Api
{
......@@ -74,13 +74,13 @@ namespace DBRuntime.Api
switch(cmd)
{
case RequestAllHisData:
ProcessRequestAllHisData(client,data);
ProcessRequestAllHisDataByMemory(client,data);
break;
case RequestHisDatasByTimePoint:
ProcessRequestHisDatasByTimePoint(client, data);
ProcessRequestHisDatasByTimePointByMemory(client, data);
break;
case RequestHisDataByTimeSpan:
ProcessRequestHisDataByTimeSpan(client, data);
ProcessRequestHisDataByTimeSpanByMemory(client, data);
break;
}
}
......@@ -91,20 +91,406 @@ namespace DBRuntime.Api
base.ProcessData(client, data);
}
private unsafe IByteBuffer WriteDataToBuffer<T>(byte id,HisQueryResult<T> resb)
{
var re = BufferManager.Manager.Allocate(FunId,1 + resb.Position);
re.WriteByte(id);
Buffer.MemoryCopy((void*)(re.AddressOfPinnedMemory() + 2), (void*)resb.Address, resb.Position, resb.Position);
re.SetWriterIndex(2 + resb.Position);
return re;
}
#region Serise to IByteBuffer
//private unsafe IByteBuffer WriteDataToBuffer(byte type,HisQueryResult<bool> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId,5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for(int i=0;i<resb.Count;i++)
// {
// var value = resb.GetValue(i, out time,out qu);
// re.WriteBoolean(value);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<byte> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteByte(value);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<short> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteShort(value);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<ushort> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteUnsignedShort(value);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<int> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteInt(value);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<uint> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteInt((int)value);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<long> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteLong((long)value);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<ulong> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteLong((long)value);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<double> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteDouble((double)value);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<float> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteFloat(value);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<DateTime> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteLong(value.Ticks);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<string> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteString(value);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
///// <summary>
/////
///// </summary>
///// <param name="type"></param>
///// <param name="resb"></param>
///// <returns></returns>
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<IntPointData> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteInt(value.X);
// re.WriteInt(value.Y);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<IntPoint3Data> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteInt(value.X);
// re.WriteInt(value.Y);
// re.WriteInt(value.Z);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<UIntPointData> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteInt((int)value.X);
// re.WriteInt((int)value.Y);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<UIntPoint3Data> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteInt((int)value.X);
// re.WriteInt((int)value.Y);
// re.WriteInt((int)value.Z);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
///// <summary>
/////
///// </summary>
///// <param name="type"></param>
///// <param name="resb"></param>
///// <returns></returns>
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<LongPointData> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteLong(value.X);
// re.WriteLong(value.Y);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
///// <summary>
/////
///// </summary>
///// <param name="type"></param>
///// <param name="resb"></param>
///// <returns></returns>
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<ULongPointData> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteLong((long)value.X);
// re.WriteLong((long)value.Y);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<LongPoint3Data> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteLong(value.X);
// re.WriteLong(value.Y);
// re.WriteLong(value.Z);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
//private unsafe IByteBuffer WriteDataToBuffer(byte type, HisQueryResult<ULongPoint3Data> resb)
//{
// var re = BufferManager.Manager.Allocate(FunId, 5 + resb.Position);
// re.WriteByte(type);
// re.WriteInt(resb.Count);
// DateTime time;
// byte qu;
// for (int i = 0; i < resb.Count; i++)
// {
// var value = resb.GetValue(i, out time, out qu);
// re.WriteLong((long)value.X);
// re.WriteLong((long)value.Y);
// re.WriteLong((long)value.Z);
// re.WriteLong(time.Ticks);
// re.WriteByte(qu);
// }
// return re;
//}
#endregion
/// <summary>
///
/// </summary>
/// <param name="data"></param>
private unsafe void ProcessRequestAllHisData(string clientId,IByteBuffer data)
/// <typeparam name="T"></typeparam>
/// <param name="type"></param>
/// <param name="resb"></param>
/// <returns></returns>
private unsafe IByteBuffer WriteDataToBufferByMemory<T>(byte type, HisQueryResult<T> resb)
{
var vdata = resb.Contracts();
var re = BufferManager.Manager.Allocate(FunId, 5 + vdata.Size);
re.WriteByte(type);
re.WriteInt(resb.Count);
Marshal.Copy(vdata.Address, re.Array, re.ArrayOffset+ 6, vdata.Size);
re.SetWriterIndex(re.WriterIndex + vdata.Size);
return re;
}
private unsafe void ProcessRequestAllHisDataByMemory(string clientId, IByteBuffer data)
{
int id = data.ReadInt();
DateTime sTime = new DateTime(data.ReadLong());
......@@ -113,69 +499,69 @@ namespace DBRuntime.Api
IByteBuffer re = null;
if(tags!=null)
if (tags != null)
{
switch (tags.Type)
{
case Cdy.Tag.TagType.Bool:
re = WriteDataToBuffer<bool>((byte)tags.Type, ProcessDataQuery<bool>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<bool>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.Byte:
re = WriteDataToBuffer<byte>((byte)tags.Type, ProcessDataQuery<byte>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<byte>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.DateTime:
re = WriteDataToBuffer<DateTime>((byte)tags.Type, ProcessDataQuery<DateTime>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<DateTime>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.Double:
re = WriteDataToBuffer<double>((byte)tags.Type, ProcessDataQuery<double>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<double>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.Float:
re = WriteDataToBuffer<float>((byte)tags.Type, ProcessDataQuery<float>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<float>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.Int:
re = WriteDataToBuffer<int>((byte)tags.Type, ProcessDataQuery<int>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<int>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.Long:
re = WriteDataToBuffer<long>((byte)tags.Type, ProcessDataQuery<long>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<long>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.Short:
re = WriteDataToBuffer<short>((byte)tags.Type, ProcessDataQuery<short>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<short>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.String:
re = WriteDataToBuffer<string>((byte)tags.Type, ProcessDataQuery<string>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<string>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.UInt:
re = WriteDataToBuffer<bool>((byte)tags.Type, ProcessDataQuery<bool>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<bool>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.ULong:
re = WriteDataToBuffer<ulong>((byte)tags.Type, ProcessDataQuery<ulong>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<ulong>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.UShort:
re = WriteDataToBuffer<ushort>((byte)tags.Type, ProcessDataQuery<ushort>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<ushort>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.IntPoint:
re = WriteDataToBuffer<IntPointData>((byte)tags.Type, ProcessDataQuery<IntPointData>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<IntPointData>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.UIntPoint:
re = WriteDataToBuffer<UIntPointData>((byte)tags.Type, ProcessDataQuery<UIntPointData>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<UIntPointData>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.IntPoint3:
re = WriteDataToBuffer<IntPoint3Data>((byte)tags.Type, ProcessDataQuery<IntPoint3Data>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<IntPoint3Data>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.UIntPoint3:
re = WriteDataToBuffer<UIntPoint3Data>((byte)tags.Type, ProcessDataQuery<UIntPoint3Data>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<UIntPoint3Data>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.LongPoint:
re = WriteDataToBuffer<LongPointData>((byte)tags.Type, ProcessDataQuery<LongPointData>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<LongPointData>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.ULongPoint:
re = WriteDataToBuffer<ULongPointTag>((byte)tags.Type, ProcessDataQuery<ULongPointTag>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<ULongPointData>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.LongPoint3:
re = WriteDataToBuffer<LongPoint3Data>((byte)tags.Type, ProcessDataQuery<LongPoint3Data>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<LongPoint3Data>(id, sTime, eTime));
break;
case Cdy.Tag.TagType.ULongPoint3:
re = WriteDataToBuffer<ULongPoint3Data>((byte)tags.Type, ProcessDataQuery<ULongPoint3Data>(id, sTime, eTime));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<ULongPoint3Data>(id, sTime, eTime));
break;
}
Parent.AsyncCallback(clientId, re);
......@@ -186,29 +572,12 @@ namespace DBRuntime.Api
}
}
private HisQueryResult<T> ProcessDataQuery<T>(int id, DateTime stime, DateTime etime)
{
return ServiceLocator.Locator.Resolve<IHisQuery>().ReadAllValue<T>(id, stime, etime);
}
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="id"></param>
/// <param name="times"></param>
/// <param name="type"></param>
/// <returns></returns>
private HisQueryResult<T> ProcessDataQuery<T>(int id, List<DateTime> times, Cdy.Tag.QueryValueMatchType type)
{
return ServiceLocator.Locator.Resolve<IHisQuery>().ReadValue<T>(id, times, type);
}
/// <summary>
///
/// </summary>
/// <param name="clientId"></param>
/// <param name="data"></param>
private void ProcessRequestHisDatasByTimePoint(string clientId, IByteBuffer data)
private void ProcessRequestHisDatasByTimePointByMemory(string clientId, IByteBuffer data)
{
int id = data.ReadInt();
Cdy.Tag.QueryValueMatchType type = (QueryValueMatchType)data.ReadByte();
......@@ -227,64 +596,64 @@ namespace DBRuntime.Api
switch (tags.Type)
{
case Cdy.Tag.TagType.Bool:
re = WriteDataToBuffer<bool>((byte)tags.Type, ProcessDataQuery<bool>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<bool>(id, times, type));
break;
case Cdy.Tag.TagType.Byte:
re = WriteDataToBuffer<byte>((byte)tags.Type, ProcessDataQuery<byte>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<byte>(id, times, type));
break;
case Cdy.Tag.TagType.DateTime:
re = WriteDataToBuffer<DateTime>((byte)tags.Type, ProcessDataQuery<DateTime>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<DateTime>(id, times, type));
break;
case Cdy.Tag.TagType.Double:
re = WriteDataToBuffer<double>((byte)tags.Type, ProcessDataQuery<double>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<double>(id, times, type));
break;
case Cdy.Tag.TagType.Float:
re = WriteDataToBuffer<float>((byte)tags.Type, ProcessDataQuery<float>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<float>(id, times, type));
break;
case Cdy.Tag.TagType.Int:
re = WriteDataToBuffer<int>((byte)tags.Type, ProcessDataQuery<int>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<int>(id, times, type));
break;
case Cdy.Tag.TagType.Long:
re = WriteDataToBuffer<long>((byte)tags.Type, ProcessDataQuery<long>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<long>(id, times, type));
break;
case Cdy.Tag.TagType.Short:
re = WriteDataToBuffer<short>((byte)tags.Type, ProcessDataQuery<short>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<short>(id, times, type));
break;
case Cdy.Tag.TagType.String:
re = WriteDataToBuffer<string>((byte)tags.Type, ProcessDataQuery<string>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<string>(id, times, type));
break;
case Cdy.Tag.TagType.UInt:
re = WriteDataToBuffer<bool>((byte)tags.Type, ProcessDataQuery<bool>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<bool>(id, times, type));
break;
case Cdy.Tag.TagType.ULong:
re = WriteDataToBuffer<ulong>((byte)tags.Type, ProcessDataQuery<ulong>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<ulong>(id, times, type));
break;
case Cdy.Tag.TagType.UShort:
re = WriteDataToBuffer<ushort>((byte)tags.Type, ProcessDataQuery<ushort>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<ushort>(id, times, type));
break;
case Cdy.Tag.TagType.IntPoint:
re = WriteDataToBuffer<IntPointData>((byte)tags.Type, ProcessDataQuery<IntPointData>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<IntPointData>(id, times, type));
break;
case Cdy.Tag.TagType.UIntPoint:
re = WriteDataToBuffer<UIntPointData>((byte)tags.Type, ProcessDataQuery<UIntPointData>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<UIntPointData>(id, times, type));
break;
case Cdy.Tag.TagType.IntPoint3:
re = WriteDataToBuffer<IntPoint3Data>((byte)tags.Type, ProcessDataQuery<IntPoint3Data>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<IntPoint3Data>(id, times, type));
break;
case Cdy.Tag.TagType.UIntPoint3:
re = WriteDataToBuffer<UIntPoint3Data>((byte)tags.Type, ProcessDataQuery<UIntPoint3Data>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<UIntPoint3Data>(id, times, type));
break;
case Cdy.Tag.TagType.LongPoint:
re = WriteDataToBuffer<LongPointData>((byte)tags.Type, ProcessDataQuery<LongPointData>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<LongPointData>(id, times, type));
break;
case Cdy.Tag.TagType.ULongPoint:
re = WriteDataToBuffer<ULongPointTag>((byte)tags.Type, ProcessDataQuery<ULongPointTag>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<ULongPointData>(id, times, type));
break;
case Cdy.Tag.TagType.LongPoint3:
re = WriteDataToBuffer<LongPoint3Data>((byte)tags.Type, ProcessDataQuery<LongPoint3Data>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<LongPoint3Data>(id, times, type));
break;
case Cdy.Tag.TagType.ULongPoint3:
re = WriteDataToBuffer<ULongPoint3Data>((byte)tags.Type, ProcessDataQuery<ULongPoint3Data>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<ULongPoint3Data>(id, times, type));
break;
}
Parent.AsyncCallback(clientId, re);
......@@ -298,8 +667,9 @@ namespace DBRuntime.Api
/// <summary>
///
/// </summary>
/// <param name="clientId"></param>
/// <param name="data"></param>
private void ProcessRequestHisDataByTimeSpan(string clientId, IByteBuffer data)
private void ProcessRequestHisDataByTimeSpanByMemory(string clientId, IByteBuffer data)
{
int id = data.ReadInt();
Cdy.Tag.QueryValueMatchType type = (QueryValueMatchType)data.ReadByte();
......@@ -308,7 +678,7 @@ namespace DBRuntime.Api
TimeSpan ts = new TimeSpan(data.ReadLong());
List<DateTime> times = new List<DateTime>();
DateTime tmp = stime;
while(tmp<=etime)
while (tmp <= etime)
{
times.Add(tmp);
tmp += ts;
......@@ -322,64 +692,64 @@ namespace DBRuntime.Api
switch (tags.Type)
{
case Cdy.Tag.TagType.Bool:
re = WriteDataToBuffer<bool>((byte)tags.Type, ProcessDataQuery<bool>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<bool>(id, times, type));
break;
case Cdy.Tag.TagType.Byte:
re = WriteDataToBuffer<byte>((byte)tags.Type, ProcessDataQuery<byte>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<byte>(id, times, type));
break;
case Cdy.Tag.TagType.DateTime:
re = WriteDataToBuffer<DateTime>((byte)tags.Type, ProcessDataQuery<DateTime>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<DateTime>(id, times, type));
break;
case Cdy.Tag.TagType.Double:
re = WriteDataToBuffer<double>((byte)tags.Type, ProcessDataQuery<double>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<double>(id, times, type));
break;
case Cdy.Tag.TagType.Float:
re = WriteDataToBuffer<float>((byte)tags.Type, ProcessDataQuery<float>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<float>(id, times, type));
break;
case Cdy.Tag.TagType.Int:
re = WriteDataToBuffer<int>((byte)tags.Type, ProcessDataQuery<int>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<int>(id, times, type));
break;
case Cdy.Tag.TagType.Long:
re = WriteDataToBuffer<long>((byte)tags.Type, ProcessDataQuery<long>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<long>(id, times, type));
break;
case Cdy.Tag.TagType.Short:
re = WriteDataToBuffer<short>((byte)tags.Type, ProcessDataQuery<short>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<short>(id, times, type));
break;
case Cdy.Tag.TagType.String:
re = WriteDataToBuffer<string>((byte)tags.Type, ProcessDataQuery<string>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<string>(id, times, type));
break;
case Cdy.Tag.TagType.UInt:
re = WriteDataToBuffer<bool>((byte)tags.Type, ProcessDataQuery<bool>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<bool>(id, times, type));
break;
case Cdy.Tag.TagType.ULong:
re = WriteDataToBuffer<ulong>((byte)tags.Type, ProcessDataQuery<ulong>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<ulong>(id, times, type));
break;
case Cdy.Tag.TagType.UShort:
re = WriteDataToBuffer<ushort>((byte)tags.Type, ProcessDataQuery<ushort>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<ushort>(id, times, type));
break;
case Cdy.Tag.TagType.IntPoint:
re = WriteDataToBuffer<IntPointData>((byte)tags.Type, ProcessDataQuery<IntPointData>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<IntPointData>(id, times, type));
break;
case Cdy.Tag.TagType.UIntPoint:
re = WriteDataToBuffer<UIntPointData>((byte)tags.Type, ProcessDataQuery<UIntPointData>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<UIntPointData>(id, times, type));
break;
case Cdy.Tag.TagType.IntPoint3:
re = WriteDataToBuffer<IntPoint3Data>((byte)tags.Type, ProcessDataQuery<IntPoint3Data>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<IntPoint3Data>(id, times, type));
break;
case Cdy.Tag.TagType.UIntPoint3:
re = WriteDataToBuffer<UIntPoint3Data>((byte)tags.Type, ProcessDataQuery<UIntPoint3Data>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<UIntPoint3Data>(id, times, type));
break;
case Cdy.Tag.TagType.LongPoint:
re = WriteDataToBuffer<LongPointData>((byte)tags.Type, ProcessDataQuery<LongPointData>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<LongPointData>(id, times, type));
break;
case Cdy.Tag.TagType.ULongPoint:
re = WriteDataToBuffer<ULongPointTag>((byte)tags.Type, ProcessDataQuery<ULongPointTag>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<ULongPointData>(id, times, type));
break;
case Cdy.Tag.TagType.LongPoint3:
re = WriteDataToBuffer<LongPoint3Data>((byte)tags.Type, ProcessDataQuery<LongPoint3Data>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<LongPoint3Data>(id, times, type));
break;
case Cdy.Tag.TagType.ULongPoint3:
re = WriteDataToBuffer<ULongPoint3Data>((byte)tags.Type, ProcessDataQuery<ULongPoint3Data>(id, times, type));
re = WriteDataToBufferByMemory((byte)tags.Type, ProcessDataQuery<ULongPoint3Data>(id, times, type));
break;
}
Parent.AsyncCallback(clientId, re);
......@@ -390,6 +760,298 @@ namespace DBRuntime.Api
}
}
private HisQueryResult<T> ProcessDataQuery<T>(int id, DateTime stime, DateTime etime)
{
return ServiceLocator.Locator.Resolve<IHisQuery>().ReadAllValue<T>(id, stime, etime);
}
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="id"></param>
/// <param name="times"></param>
/// <param name="type"></param>
/// <returns></returns>
private HisQueryResult<T> ProcessDataQuery<T>(int id, List<DateTime> times, Cdy.Tag.QueryValueMatchType type)
{
return ServiceLocator.Locator.Resolve<IHisQuery>().ReadValue<T>(id, times, type);
}
///// <summary>
/////
///// </summary>
///// <param name="data"></param>
//private unsafe void ProcessRequestAllHisData(string clientId, IByteBuffer data)
//{
// int id = data.ReadInt();
// DateTime sTime = new DateTime(data.ReadLong());
// DateTime eTime = new DateTime(data.ReadLong());
// var tags = ServiceLocator.Locator.Resolve<ITagManager>().GetTagById(id);
// IByteBuffer re = null;
// if (tags != null)
// {
// switch (tags.Type)
// {
// case Cdy.Tag.TagType.Bool:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<bool>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.Byte:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<byte>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.DateTime:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<DateTime>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.Double:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<double>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.Float:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<float>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.Int:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<int>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.Long:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<long>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.Short:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<short>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.String:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<string>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.UInt:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<bool>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.ULong:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<ulong>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.UShort:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<ushort>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.IntPoint:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<IntPointData>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.UIntPoint:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<UIntPointData>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.IntPoint3:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<IntPoint3Data>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.UIntPoint3:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<UIntPoint3Data>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.LongPoint:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<LongPointData>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.ULongPoint:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<ULongPointData>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.LongPoint3:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<LongPoint3Data>(id, sTime, eTime));
// break;
// case Cdy.Tag.TagType.ULongPoint3:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<ULongPoint3Data>(id, sTime, eTime));
// break;
// }
// Parent.AsyncCallback(clientId, re);
// }
// else
// {
// Parent.AsyncCallback(clientId, FunId, new byte[1], 0);
// }
//}
///// <summary>
/////
///// </summary>
///// <param name="data"></param>
//private void ProcessRequestHisDatasByTimePoint(string clientId, IByteBuffer data)
//{
// int id = data.ReadInt();
// Cdy.Tag.QueryValueMatchType type = (QueryValueMatchType)data.ReadByte();
// int count = data.ReadInt();
// List<DateTime> times = new List<DateTime>();
// for(int i=0;i<count;i++)
// {
// times.Add(new DateTime(data.ReadLong()));
// }
// var tags = ServiceLocator.Locator.Resolve<ITagManager>().GetTagById(id);
// IByteBuffer re = null;
// if (tags != null)
// {
// switch (tags.Type)
// {
// case Cdy.Tag.TagType.Bool:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<bool>(id, times, type));
// break;
// case Cdy.Tag.TagType.Byte:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<byte>(id, times, type));
// break;
// case Cdy.Tag.TagType.DateTime:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<DateTime>(id, times, type));
// break;
// case Cdy.Tag.TagType.Double:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<double>(id, times, type));
// break;
// case Cdy.Tag.TagType.Float:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<float>(id, times, type));
// break;
// case Cdy.Tag.TagType.Int:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<int>(id, times, type));
// break;
// case Cdy.Tag.TagType.Long:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<long>(id, times, type));
// break;
// case Cdy.Tag.TagType.Short:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<short>(id, times, type));
// break;
// case Cdy.Tag.TagType.String:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<string>(id, times, type));
// break;
// case Cdy.Tag.TagType.UInt:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<bool>(id, times, type));
// break;
// case Cdy.Tag.TagType.ULong:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<ulong>(id, times, type));
// break;
// case Cdy.Tag.TagType.UShort:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<ushort>(id, times, type));
// break;
// case Cdy.Tag.TagType.IntPoint:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<IntPointData>(id, times, type));
// break;
// case Cdy.Tag.TagType.UIntPoint:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<UIntPointData>(id, times, type));
// break;
// case Cdy.Tag.TagType.IntPoint3:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<IntPoint3Data>(id, times, type));
// break;
// case Cdy.Tag.TagType.UIntPoint3:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<UIntPoint3Data>(id, times, type));
// break;
// case Cdy.Tag.TagType.LongPoint:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<LongPointData>(id, times, type));
// break;
// case Cdy.Tag.TagType.ULongPoint:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<ULongPointData>(id, times, type));
// break;
// case Cdy.Tag.TagType.LongPoint3:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<LongPoint3Data>(id, times, type));
// break;
// case Cdy.Tag.TagType.ULongPoint3:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<ULongPoint3Data>(id, times, type));
// break;
// }
// Parent.AsyncCallback(clientId, re);
// }
// else
// {
// Parent.AsyncCallback(clientId, FunId, new byte[1], 0);
// }
//}
///// <summary>
/////
///// </summary>
///// <param name="data"></param>
//private void ProcessRequestHisDataByTimeSpan(string clientId, IByteBuffer data)
//{
// int id = data.ReadInt();
// Cdy.Tag.QueryValueMatchType type = (QueryValueMatchType)data.ReadByte();
// DateTime stime = new DateTime(data.ReadLong());
// DateTime etime = new DateTime(data.ReadLong());
// TimeSpan ts = new TimeSpan(data.ReadLong());
// List<DateTime> times = new List<DateTime>();
// DateTime tmp = stime;
// while(tmp<=etime)
// {
// times.Add(tmp);
// tmp += ts;
// }
// var tags = ServiceLocator.Locator.Resolve<ITagManager>().GetTagById(id);
// IByteBuffer re = null;
// if (tags != null)
// {
// switch (tags.Type)
// {
// case Cdy.Tag.TagType.Bool:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<bool>(id, times, type));
// break;
// case Cdy.Tag.TagType.Byte:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<byte>(id, times, type));
// break;
// case Cdy.Tag.TagType.DateTime:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<DateTime>(id, times, type));
// break;
// case Cdy.Tag.TagType.Double:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<double>(id, times, type));
// break;
// case Cdy.Tag.TagType.Float:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<float>(id, times, type));
// break;
// case Cdy.Tag.TagType.Int:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<int>(id, times, type));
// break;
// case Cdy.Tag.TagType.Long:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<long>(id, times, type));
// break;
// case Cdy.Tag.TagType.Short:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<short>(id, times, type));
// break;
// case Cdy.Tag.TagType.String:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<string>(id, times, type));
// break;
// case Cdy.Tag.TagType.UInt:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<bool>(id, times, type));
// break;
// case Cdy.Tag.TagType.ULong:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<ulong>(id, times, type));
// break;
// case Cdy.Tag.TagType.UShort:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<ushort>(id, times, type));
// break;
// case Cdy.Tag.TagType.IntPoint:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<IntPointData>(id, times, type));
// break;
// case Cdy.Tag.TagType.UIntPoint:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<UIntPointData>(id, times, type));
// break;
// case Cdy.Tag.TagType.IntPoint3:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<IntPoint3Data>(id, times, type));
// break;
// case Cdy.Tag.TagType.UIntPoint3:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<UIntPoint3Data>(id, times, type));
// break;
// case Cdy.Tag.TagType.LongPoint:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<LongPointData>(id, times, type));
// break;
// case Cdy.Tag.TagType.ULongPoint:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<ULongPointData>(id, times, type));
// break;
// case Cdy.Tag.TagType.LongPoint3:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<LongPoint3Data>(id, times, type));
// break;
// case Cdy.Tag.TagType.ULongPoint3:
// re = WriteDataToBuffer((byte)tags.Type, ProcessDataQuery<ULongPoint3Data>(id, times, type));
// break;
// }
// Parent.AsyncCallback(clientId, re);
// }
// else
// {
// Parent.AsyncCallback(clientId, FunId, new byte[1], 0);
// }
//}
#endregion ...Methods...
#region ... Interfaces ...
......
......@@ -103,7 +103,7 @@ namespace DBRuntime.Api
loginId = data.ReadString();
if (Cdy.Tag.ServiceLocator.Locator.Resolve<IRuntimeSecurity>().CheckLogin(loginId))
{
Parent.AsyncCallback(client, ToByteBuffer(ApiFunConst.TagInfoRequest, Runner.mCurrentDatabase));
Parent.AsyncCallback(client, ToByteBuffer(ApiFunConst.TagInfoRequest, Runner.CurrentDatabase+","+Runner.CurrentDatabaseVersion+","+Runner.CurrentDatabaseLastUpdateTime));
}
break;
......
......@@ -21,7 +21,11 @@ namespace Cdy.Tag
#region ... Variables ...
public static string mCurrentDatabase = "";
public static string CurrentDatabase = "";
public static string CurrentDatabaseVersion = "";
public static string CurrentDatabaseLastUpdateTime = "";
/// <summary>
///
......@@ -124,10 +128,12 @@ namespace Cdy.Tag
/// </summary>
private void LoadDatabase()
{
this.mDatabase = new DatabaseSerise().Load(mDatabaseName);
this.mRealDatabase = this.mDatabase.RealDatabase;
this.mHisDatabase = this.mDatabase.HisDatabase;
CurrentDatabaseVersion = this.mRealDatabase.Version;
CurrentDatabase = mRealDatabase.Name;
CurrentDatabaseLastUpdateTime = mRealDatabase.UpdateTime;
}
/// <summary>
......@@ -182,6 +188,8 @@ namespace Cdy.Tag
DriverManager.Manager.Init(realEnginer);
HisQueryManager.Instance.Registor(mDatabaseName);
await task;
return true;
......@@ -253,8 +261,6 @@ namespace Cdy.Tag
hisEnginer.Start();
mSecurityRunner.Start();
DriverManager.Manager.Start();
mCurrentDatabase = database;
mIsStarted = true;
LoggerService.Service.Info("Runner", " 数据库 " + database + " 启动完成");
......
<?xml version="1.0" encoding="utf-8" ?>
<Config Ip="127.0.0.1" Port="14330" LoginUser="Admin" LoginPassword="Admin" >
<Config>
<ProxyClient Ip="127.0.0.1" Port="14330" LoginUser="Admin" LoginPassword="Admin" WorkMode="0" PollCircle="1000" />
</Config>
\ No newline at end of file
......@@ -13,89 +13,142 @@ namespace DbInRunWebApi.Controllers
[Route("[controller]")]
public class HisDataController : ControllerBase
{
private List<HisValue> ProcessResult<T>(HisQueryResult<T> datas)
private HisValue ProcessResult<T>(string tagname, object datas)
{
return null;
HisValue re = new HisValue() { tagName = tagname, Result = true };
List<ValueItem> values = new List<ValueItem>();
var vdata = datas as HisQueryResult<T>;
if (vdata != null)
{
for (int i = 0; i < vdata.Count; i++)
{
byte qu;
DateTime time;
var val = vdata.GetValue(i, out time, out qu);
values.Add(new ValueItem() { Time = time, Quality = qu, Value = val.ToString() });
}
re.Values = values;
}
return re;
}
//private HisValue ProcessResult<T>(string tagname, Dictionary<DateTime, Tuple<object, byte>> datas)
//{
// HisValue re = new HisValue() { tagName = tagname, Result = true };
// List<ValueItem> values = new List<ValueItem>();
// if (datas != null)
// {
// foreach (var vv in datas)
// {
// values.Add(new ValueItem() { Time = vv.Key, Value = vv.Value.Item1.ToString(), Quality = vv.Value.Item2 });
// }
// }
// re.Values = values;
// return re;
//}
private List<DateTime> ConvertToTimes(List<string> time)
{
return time.Select(e => DateTime.Parse(e)).ToList();
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpGet()]
public HisValueQueryResponse Get([FromBody] HisDataRequest request)
public HisValue Get([FromBody] HisDataRequest request)
{
var tag = ServiceLocator.Locator.Resolve<ITagManager>().GetTagByName(request.TagName);
object res;
List<HisValue> revals = new List<HisValue>(request.Times.Count);
HisValue revals=null;
switch (tag.Type)
{
case Cdy.Tag.TagType.Bool:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<bool>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<bool>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<bool>(request.TagName,res);
break;
case Cdy.Tag.TagType.Byte:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<byte>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<byte>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<byte>(request.TagName, res);
break;
case Cdy.Tag.TagType.DateTime:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<DateTime>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<DateTime>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<DateTime>(request.TagName, res);
break;
case Cdy.Tag.TagType.Double:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<double>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<double>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<double>(request.TagName, res);
break;
case Cdy.Tag.TagType.Float:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<float>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<float>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<float>(request.TagName, res);
break;
case Cdy.Tag.TagType.Int:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<int>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<int>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<int>(request.TagName, res);
break;
case Cdy.Tag.TagType.Long:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<long>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<long>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<long>(request.TagName, res);
break;
case Cdy.Tag.TagType.Short:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<short>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<short>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<short>(request.TagName, res);
break;
case Cdy.Tag.TagType.String:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<string>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<string>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<string>(request.TagName, res);
break;
case Cdy.Tag.TagType.UInt:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<uint>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<uint>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<uint>(request.TagName, res);
break;
case Cdy.Tag.TagType.ULong:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<ulong>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<ulong>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<ulong>(request.TagName, res);
break;
case Cdy.Tag.TagType.UShort:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<ushort>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<ushort>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<ushort>(request.TagName, res);
break;
case Cdy.Tag.TagType.IntPoint:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<int>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<int>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<IntPointData>(request.TagName, res);
break;
case Cdy.Tag.TagType.UIntPoint:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<uint>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<uint>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<UIntPointData>(request.TagName, res);
break;
case Cdy.Tag.TagType.IntPoint3:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<IntPoint3Data>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<IntPoint3Data>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<IntPoint3Data>(request.TagName, res);
break;
case Cdy.Tag.TagType.UIntPoint3:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<UIntPoint3Data>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<UIntPoint3Data>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<UIntPoint3Data>(request.TagName, res);
break;
case Cdy.Tag.TagType.LongPoint:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<LongPointData>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<LongPointData>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<LongPointData>(request.TagName, res);
break;
case Cdy.Tag.TagType.ULongPoint:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<ULongPointTag>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<ULongPointTag>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<ULongPointData>(request.TagName, res);
break;
case Cdy.Tag.TagType.LongPoint3:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<LongPoint3Data>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<LongPoint3Data>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<LongPoint3Data>(request.TagName, res);
break;
case Cdy.Tag.TagType.ULongPoint3:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<ULongPoint3Data>(tag.Id,request.Times,request.MatchType);
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<ULongPoint3Data>(tag.Id,ConvertToTimes(request.Times),request.MatchType);
revals = ProcessResult<ULongPoint3Data>(request.TagName, res);
break;
}
return new HisValueQueryResponse() { Result = false };
return revals;
}
......@@ -105,15 +158,202 @@ namespace DbInRunWebApi.Controllers
/// <param name="request"></param>
/// <returns></returns>
[HttpGet("GetByTimeSpan")]
public HisValueQueryResponse GetByTimeSpan([FromBody] HisDataRequest2 request)
public HisValue GetByTimeSpan([FromBody] HisDataRequest2 request)
{
var tag = ServiceLocator.Locator.Resolve<ITagManager>().GetTagByName(request.TagName);
object res;
HisValue revals = null;
switch (tag.Type)
{
case Cdy.Tag.TagType.Bool:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<bool>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<bool>(request.TagName, res);
break;
case Cdy.Tag.TagType.Byte:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<byte>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<byte>(request.TagName, res);
break;
case Cdy.Tag.TagType.DateTime:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<DateTime>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<DateTime>(request.TagName, res);
break;
case Cdy.Tag.TagType.Double:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<double>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<double>(request.TagName, res);
break;
case Cdy.Tag.TagType.Float:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<float>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<float>(request.TagName, res);
break;
case Cdy.Tag.TagType.Int:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<int>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<int>(request.TagName, res);
break;
case Cdy.Tag.TagType.Long:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<long>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<long>(request.TagName, res);
break;
case Cdy.Tag.TagType.Short:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<short>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<short>(request.TagName, res);
break;
case Cdy.Tag.TagType.String:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<string>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<string>(request.TagName, res);
break;
case Cdy.Tag.TagType.UInt:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<uint>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<uint>(request.TagName, res);
break;
case Cdy.Tag.TagType.ULong:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<ulong>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<ulong>(request.TagName, res);
break;
case Cdy.Tag.TagType.UShort:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<ushort>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<ushort>(request.TagName, res);
break;
case Cdy.Tag.TagType.IntPoint:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<int>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<IntPointData>(request.TagName, res);
break;
case Cdy.Tag.TagType.UIntPoint:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<uint>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<UIntPointData>(request.TagName, res);
break;
case Cdy.Tag.TagType.IntPoint3:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<IntPoint3Data>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<IntPoint3Data>(request.TagName, res);
break;
case Cdy.Tag.TagType.UIntPoint3:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<UIntPoint3Data>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<UIntPoint3Data>(request.TagName, res);
break;
case Cdy.Tag.TagType.LongPoint:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<LongPointData>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<LongPointData>(request.TagName, res);
break;
case Cdy.Tag.TagType.ULongPoint:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<ULongPointTag>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<ULongPointData>(request.TagName, res);
break;
case Cdy.Tag.TagType.LongPoint3:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<LongPoint3Data>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<LongPoint3Data>(request.TagName, res);
break;
case Cdy.Tag.TagType.ULongPoint3:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryHisData<ULongPoint3Data>(tag.Id, ConvertToDateTime(request.StartTime),ConvertToDateTime(request.EndTime),ConvertToTimeSpan(request.Duration), request.MatchType);
revals = ProcessResult<ULongPoint3Data>(request.TagName, res);
break;
}
return revals;
}
private DateTime ConvertToDateTime(string time)
{
return new HisValueQueryResponse() { Result = false };
return DateTime.Parse(time);
}
private TimeSpan ConvertToTimeSpan(string time)
{
return TimeSpan.FromSeconds(int.Parse(time));
}
[HttpGet("GetAllValue")]
public HisValueQueryResponse GetAllValue([FromBody] AllHisDataRequest request)
public HisValue GetAllValue([FromBody] AllHisDataRequest request)
{
return new HisValueQueryResponse() { Result = false };
var tag = ServiceLocator.Locator.Resolve<ITagManager>().GetTagByName(request.TagName);
object res;
HisValue revals = null;
switch (tag.Type)
{
case Cdy.Tag.TagType.Bool:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<bool>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<bool>(request.TagName, res);
break;
case Cdy.Tag.TagType.Byte:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<byte>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<byte>(request.TagName, res);
break;
case Cdy.Tag.TagType.DateTime:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<DateTime>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<DateTime>(request.TagName, res);
break;
case Cdy.Tag.TagType.Double:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<double>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<double>(request.TagName, res);
break;
case Cdy.Tag.TagType.Float:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<float>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<float>(request.TagName, res);
break;
case Cdy.Tag.TagType.Int:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<int>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<int>(request.TagName, res);
break;
case Cdy.Tag.TagType.Long:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<long>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<long>(request.TagName, res);
break;
case Cdy.Tag.TagType.Short:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<short>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<short>(request.TagName, res);
break;
case Cdy.Tag.TagType.String:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<string>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<string>(request.TagName, res);
break;
case Cdy.Tag.TagType.UInt:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<uint>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<uint>(request.TagName, res);
break;
case Cdy.Tag.TagType.ULong:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<ulong>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<ulong>(request.TagName, res);
break;
case Cdy.Tag.TagType.UShort:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<ushort>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<ushort>(request.TagName, res);
break;
case Cdy.Tag.TagType.IntPoint:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<int>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<IntPointData>(request.TagName, res);
break;
case Cdy.Tag.TagType.UIntPoint:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<uint>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<UIntPointData>(request.TagName, res);
break;
case Cdy.Tag.TagType.IntPoint3:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<IntPoint3Data>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<IntPoint3Data>(request.TagName, res);
break;
case Cdy.Tag.TagType.UIntPoint3:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<UIntPoint3Data>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<UIntPoint3Data>(request.TagName, res);
break;
case Cdy.Tag.TagType.LongPoint:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<LongPointData>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<LongPointData>(request.TagName, res);
break;
case Cdy.Tag.TagType.ULongPoint:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<ULongPointTag>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<ULongPointData>(request.TagName, res);
break;
case Cdy.Tag.TagType.LongPoint3:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<LongPoint3Data>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<LongPoint3Data>(request.TagName, res);
break;
case Cdy.Tag.TagType.ULongPoint3:
res = DBRuntime.Proxy.DatabaseRunner.Manager.Proxy.QueryAllHisData<ULongPoint3Data>(tag.Id, ConvertToDateTime(request.StartTime), ConvertToDateTime(request.EndTime));
revals = ProcessResult<ULongPoint3Data>(request.TagName, res);
break;
}
return revals;
}
}
......
......@@ -7,17 +7,14 @@ using Microsoft.AspNetCore.Mvc;
namespace DbWebApiProxy.Controllers
{
[Route("[controller]")]
[ApiController]
public class HomeController : ControllerBase
public class HomeController : Controller
{
// GET: api/Home
[HttpGet]
public string Index()
{
return "welcome to mar realtime datase web api.";
return Res.Get("WelcomeMsg");
}
}
}
......@@ -17,6 +17,25 @@
<ProjectReference Include="..\DBRuntime.Proxy\DBRuntime.Proxy.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.zh-CN.resx">
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<Generator>ResXFileCodeGenerator</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="Config\DbWebApiProxy.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
......
......@@ -79,7 +79,7 @@ namespace DbInRunWebApi.Model
/// <summary>
///
/// </summary>
public Dictionary<DateTime,object> Datas { get; set; }
public List<ValueItem> Values { get; set; }
#endregion ...Properties...
#region ... Methods ...
......@@ -91,6 +91,47 @@ namespace DbInRunWebApi.Model
#endregion ...Interfaces...
}
public class ValueItem
{
#region ... Variables ...
#endregion ...Variables...
#region ... Events ...
#endregion ...Events...
#region ... Constructor...
#endregion ...Constructor...
#region ... Properties ...
/// <summary>
///
/// </summary>
public DateTime Time { get; set; }
/// <summary>
///
/// </summary>
public string Value { get; set; }
/// <summary>
///
/// </summary>
public byte Quality { get; set; }
#endregion ...Properties...
#region ... Methods ...
#endregion ...Methods...
#region ... Interfaces ...
#endregion ...Interfaces...
}
/// <summary>
///
......@@ -180,7 +221,7 @@ namespace DbInRunWebApi.Model
/// <summary>
///
/// </summary>
public List<HisValue> Datas { get; set; }
public HisValue Datas { get; set; }
#endregion ...Properties...
#region ... Methods ...
......
......@@ -217,7 +217,7 @@ namespace DbInRunWebApi.Model
/// <summary>
///
/// </summary>
public List<DateTime> Times { get; set; }
public List<string> Times { get; set; }
#endregion ...Properties...
......@@ -263,13 +263,18 @@ namespace DbInRunWebApi.Model
/// <summary>
///
/// </summary>
public DateTime StartTime { get; set; }
public string StartTime { get; set; }
/// <summary>
///
/// </summary>
public DateTime EndTime { get; set; }
public string EndTime { get; set; }
/// <summary>
///
/// </summary>
public string Duration { get; set; }
#endregion ...Properties...
......@@ -308,13 +313,13 @@ namespace DbInRunWebApi.Model
/// <summary>
///
/// </summary>
public DateTime StartTime { get; set; }
public string StartTime { get; set; }
/// <summary>
///
/// </summary>
public DateTime EndTime { get; set; }
public string EndTime { get; set; }
#endregion ...Properties...
......
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace DbWebApiProxy.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DbWebApiProxy.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// 查找类似 Welcome to Web Api of Mars high performance realtime iot database 的本地化字符串。
/// </summary>
internal static string WelcomeMsg {
get {
return ResourceManager.GetString("WelcomeMsg", resourceCulture);
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="WelcomeMsg" xml:space="preserve">
<value>Welcome to Web Api of Mars high performance realtime iot database</value>
</data>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="WelcomeMsg" xml:space="preserve">
<value>欢迎来到Mars高性能实时物联数据库 Web Api</value>
</data>
</root>
\ No newline at end of file
//==============================================================
// Copyright (C) 2020 Inc. All rights reserved.
//
//==============================================================
// Create by 种道洋 at 2020/3/29 11:05:05.
// Version 1.0
// 种道洋
//==============================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace DbWebApiProxy
{
public class Res
{
public static string Get(string name)
{
return Properties.Resources.ResourceManager.GetString(name, Thread.CurrentThread.CurrentCulture);
}
}
}
......@@ -40,8 +40,10 @@ namespace DbInRunWebApi
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapDefaultControllerRoute();
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
DatabaseRunner.Manager.Load();
DatabaseRunner.Manager.Start();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册