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

死区压缩算法Bug修复。压缩参数开发环境不更新Bug修改

上级 c5a6e60e
...@@ -118,71 +118,79 @@ namespace Cdy.Tag ...@@ -118,71 +118,79 @@ namespace Cdy.Tag
/// <param name="port"></param> /// <param name="port"></param>
protected virtual async void StartInner(int port) protected virtual async void StartInner(int port)
{ {
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) try
{ {
GCSettings.LatencyMode = GCLatencyMode.SustainedLowLatency; if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
} {
GCSettings.LatencyMode = GCLatencyMode.SustainedLowLatency;
}
if (UseLibuv) if (UseLibuv)
{ {
var dispatcher = new DispatcherEventLoopGroup(); var dispatcher = new DispatcherEventLoopGroup();
bossGroup = dispatcher; bossGroup = dispatcher;
workGroup = new WorkerEventLoopGroup(dispatcher); workGroup = new WorkerEventLoopGroup(dispatcher);
} }
else else
{ {
bossGroup = new MultithreadEventLoopGroup(1); bossGroup = new MultithreadEventLoopGroup(1);
workGroup = new MultithreadEventLoopGroup(); workGroup = new MultithreadEventLoopGroup();
} }
X509Certificate2 tlsCertificate = null; X509Certificate2 tlsCertificate = null;
if (IsSsl) if (IsSsl)
{ {
// tlsCertificate = new X509Certificate2(Path.Combine(ExampleHelper.ProcessDirectory, "dotnetty.com.pfx"), "password"); // tlsCertificate = new X509Certificate2(Path.Combine(ExampleHelper.ProcessDirectory, "dotnetty.com.pfx"), "password");
} }
var bootstrap = new ServerBootstrap(); var bootstrap = new ServerBootstrap();
bootstrap.Group(bossGroup, workGroup); bootstrap.Group(bossGroup, workGroup);
if (UseLibuv) if (UseLibuv)
{
bootstrap.Channel<TcpServerChannel>();
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
|| RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{ {
bootstrap bootstrap.Channel<TcpServerChannel>();
.Option(ChannelOption.SoReuseport, true) if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
.ChildOption(ChannelOption.SoReuseaddr, true); || RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
bootstrap
.Option(ChannelOption.SoReuseport, true)
.ChildOption(ChannelOption.SoReuseaddr, true);
}
}
else
{
bootstrap.Channel<TcpServerSocketChannel>();
} }
}
else
{
bootstrap.Channel<TcpServerSocketChannel>();
}
bootstrap bootstrap
.Option(ChannelOption.SoBacklog, 8192) .Option(ChannelOption.SoBacklog, 8192)
.ChildHandler(new ActionChannelInitializer<IChannel>(channel => .ChildHandler(new ActionChannelInitializer<IChannel>(channel =>
{
IChannelPipeline pipeline = channel.Pipeline;
if (tlsCertificate != null)
{ {
pipeline.AddLast(TlsHandler.Server(tlsCertificate)); IChannelPipeline pipeline = channel.Pipeline;
} if (tlsCertificate != null)
pipeline.AddLast("framing-enc", new LengthFieldPrepender(4)); {
pipeline.AddLast("framing-dec", new LengthFieldBasedFrameDecoder(Int32.MaxValue, 0, 4, 0, 4)); pipeline.AddLast(TlsHandler.Server(tlsCertificate));
mProcessHandle = new ServerChannelHandler(this); }
mProcessHandle.DataArrived = new ServerChannelHandler.DataArrivedDelegate((context,fun, data) => { return ExecuteCallBack(context,fun,data); }); pipeline.AddLast("framing-enc", new LengthFieldPrepender(4));
pipeline.AddLast(mProcessHandle); pipeline.AddLast("framing-dec", new LengthFieldBasedFrameDecoder(Int32.MaxValue, 0, 4, 0, 4));
})); mProcessHandle = new ServerChannelHandler(this);
mProcessHandle.DataArrived = new ServerChannelHandler.DataArrivedDelegate((context, fun, data) => { return ExecuteCallBack(context, fun, data); });
if (string.IsNullOrEmpty(mIp)) pipeline.AddLast(mProcessHandle);
{ }));
boundChannel = await bootstrap.BindAsync(port);
if (string.IsNullOrEmpty(mIp))
{
boundChannel = await bootstrap.BindAsync(port);
}
else
{
boundChannel = await bootstrap.BindAsync(IPAddress.Parse(mIp), port);
}
} }
else catch(Exception ex)
{ {
boundChannel = await bootstrap.BindAsync(IPAddress.Parse(mIp),port); LoggerService.Service.Erro("SocketServer", ex.Message);
LoggerService.Service.Erro("SocketServer", ex.StackTrace.ToString());
} }
} }
......
...@@ -19,4 +19,8 @@ ...@@ -19,4 +19,8 @@
<ProjectReference Include="..\..\Common\Cdy.Tag\Cdy.Tag.csproj" /> <ProjectReference Include="..\..\Common\Cdy.Tag\Cdy.Tag.csproj" />
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)$(TargetName).XML&quot; copy &quot;$(TargetDir)$(TargetName).XML&quot; &quot;$(SolutionDir)\Output\Xml&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)$(TargetName).pdb&quot; copy &quot;$(TargetDir)$(TargetName).pdb&quot; &quot;$(SolutionDir)\Output&quot; /y" />
</Target>
</Project> </Project>
...@@ -46,7 +46,6 @@ namespace DBInStudio.Desktop.ViewModel ...@@ -46,7 +46,6 @@ namespace DBInStudio.Desktop.ViewModel
} }
} }
#endregion ...Properties... #endregion ...Properties...
#region ... Methods ... #region ... Methods ...
...@@ -64,7 +63,7 @@ namespace DBInStudio.Desktop.ViewModel ...@@ -64,7 +63,7 @@ namespace DBInStudio.Desktop.ViewModel
/// </summary> /// </summary>
public virtual void FillParameters() public virtual void FillParameters()
{ {
} }
#endregion ...Methods... #endregion ...Methods...
...@@ -109,6 +108,7 @@ namespace DBInStudio.Desktop.ViewModel ...@@ -109,6 +108,7 @@ namespace DBInStudio.Desktop.ViewModel
{ {
mDeadValue = value; mDeadValue = value;
FillParameters(); FillParameters();
OnPropertyChanged("DeadValue");
} }
} }
} }
...@@ -180,6 +180,7 @@ namespace DBInStudio.Desktop.ViewModel ...@@ -180,6 +180,7 @@ namespace DBInStudio.Desktop.ViewModel
{ {
Parameters.Add("DeadType", Type); Parameters.Add("DeadType", Type);
} }
base.FillParameters();
} }
#endregion ...Methods... #endregion ...Methods...
...@@ -291,6 +292,7 @@ namespace DBInStudio.Desktop.ViewModel ...@@ -291,6 +292,7 @@ namespace DBInStudio.Desktop.ViewModel
{ {
Parameters.Add("SlopeType", Type); Parameters.Add("SlopeType", Type);
} }
base.FillParameters();
} }
#endregion ...Methods... #endregion ...Methods...
......
...@@ -993,6 +993,10 @@ namespace DBInStudio.Desktop ...@@ -993,6 +993,10 @@ namespace DBInStudio.Desktop
/// </summary> /// </summary>
private void CheckRecordTypeParameterModel() private void CheckRecordTypeParameterModel()
{ {
if(CompressParameterModel!=null)
{
CompressParameterModel.PropertyChanged -= CompressParameterModel_PropertyChanged;
}
if(mHisTagMode==null) if(mHisTagMode==null)
{ {
CompressParameterModel = null; CompressParameterModel = null;
...@@ -1011,7 +1015,19 @@ namespace DBInStudio.Desktop ...@@ -1011,7 +1015,19 @@ namespace DBInStudio.Desktop
CompressParameterModel = new SlopeCompressParameterViewModel() { Parameters = HisTagMode.Parameters }; CompressParameterModel = new SlopeCompressParameterViewModel() { Parameters = HisTagMode.Parameters };
break; break;
} }
if (CompressParameterModel != null)
{
CompressParameterModel.PropertyChanged += CompressParameterModel_PropertyChanged;
}
}
private void CompressParameterModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (mHisTagMode != null)
{
// mHisTagMode.Parameters = (sender as CompressParameterModelBase).Parameters;
IsChanged = true;
}
} }
/// <summary> /// <summary>
......
...@@ -17,6 +17,7 @@ namespace DBInRun ...@@ -17,6 +17,7 @@ namespace DBInRun
{ {
Console.CancelKeyPress += Console_CancelKeyPress; Console.CancelKeyPress += Console_CancelKeyPress;
AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException;
WindowConsolHelper.DisbleQuickEditMode(); WindowConsolHelper.DisbleQuickEditMode();
Runner.RunInstance.Init(); Runner.RunInstance.Init();
...@@ -156,6 +157,12 @@ namespace DBInRun ...@@ -156,6 +157,12 @@ namespace DBInRun
} }
} }
private static void CurrentDomain_FirstChanceException(object sender, System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs e)
{
Console.WriteLine(e.Exception.StackTrace);
e.Exception.HResult = 0;
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
......
...@@ -32,6 +32,10 @@ namespace Cdy.Tag ...@@ -32,6 +32,10 @@ namespace Cdy.Tag
protected ProtoMemory mVarintMemory2; protected ProtoMemory mVarintMemory2;
//Dictionary<int, double> dvals = new Dictionary<int, double>();
//Dictionary<int, int> dtims = new Dictionary<int, int>();
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
...@@ -57,7 +61,7 @@ namespace Cdy.Tag ...@@ -57,7 +61,7 @@ namespace Cdy.Tag
} }
else else
{ {
return Math.Abs((newVal - preVal) / preVal) > deadArea; return preVal > 0 ? Math.Abs((newVal - preVal) / preVal) > deadArea : true;
} }
} }
...@@ -99,7 +103,7 @@ namespace Cdy.Tag ...@@ -99,7 +103,7 @@ namespace Cdy.Tag
{ {
int preids = 0; int preids = 0;
mVarintMemory2.Reset(); mVarintMemory2.Reset();
//dtims.Clear();
bool isFirst = true; bool isFirst = true;
int id = 0; int id = 0;
...@@ -121,6 +125,8 @@ namespace Cdy.Tag ...@@ -121,6 +125,8 @@ namespace Cdy.Tag
{ {
mVarintMemory2.WriteInt32(id - preids); mVarintMemory2.WriteInt32(id - preids);
} }
//dtims.Add(i, id);
preids = id;
} }
else else
{ {
...@@ -431,6 +437,14 @@ namespace Cdy.Tag ...@@ -431,6 +437,14 @@ namespace Cdy.Tag
target.Write(cqus); target.Write(cqus);
rsize += 4; rsize += 4;
rsize += cqus.Length; rsize += cqus.Length;
//StringBuilder sb = new StringBuilder();
//foreach(var vv in dvals)
//{
// sb.Append(dtims[vv.Key] + "," + vv.Value+";");
//}
//System.IO.File.WriteAllText(DateTime.Now.Ticks.ToString() + ".deadarea", sb.ToString());
break; break;
case TagType.Float: case TagType.Float:
FindEmpityIds(source, sourceAddr, (int)count, emptys); FindEmpityIds(source, sourceAddr, (int)count, emptys);
...@@ -947,6 +961,8 @@ namespace Cdy.Tag ...@@ -947,6 +961,8 @@ namespace Cdy.Tag
double dsval = 0; double dsval = 0;
mDCompress.Reset(); mDCompress.Reset();
mDCompress.Precision = this.Precision; mDCompress.Precision = this.Precision;
//dvals.Clear();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
if (i != ig) if (i != ig)
...@@ -957,6 +973,7 @@ namespace Cdy.Tag ...@@ -957,6 +973,7 @@ namespace Cdy.Tag
mDCompress.Append(id); mDCompress.Append(id);
isFirst = false; isFirst = false;
dsval = id; dsval = id;
//dvals.Add(i, id);
} }
else else
{ {
...@@ -965,6 +982,7 @@ namespace Cdy.Tag ...@@ -965,6 +982,7 @@ namespace Cdy.Tag
mDCompress.Append(id); mDCompress.Append(id);
// mMarshalMemory.Write(id); // mMarshalMemory.Write(id);
dsval = id; dsval = id;
//dvals.Add(i, id);
} }
else else
{ {
......
...@@ -96,13 +96,12 @@ namespace Cdy.Tag ...@@ -96,13 +96,12 @@ namespace Cdy.Tag
{ {
isFirst = false; isFirst = false;
mVarintMemory2.WriteInt32(id); mVarintMemory2.WriteInt32(id);
preids = id;
} }
else else
{ {
mVarintMemory2.WriteInt32(id - preids); mVarintMemory2.WriteInt32(id - preids);
preids = id;
} }
preids = id;
ig = usedIndex.ReadIndex < usedIndex.WriteIndex ? usedIndex.IncRead() : -1; ig = usedIndex.ReadIndex < usedIndex.WriteIndex ? usedIndex.IncRead() : -1;
} }
} }
......
...@@ -306,7 +306,7 @@ namespace Cdy.Tag ...@@ -306,7 +306,7 @@ namespace Cdy.Tag
mHisTag = new LongPoint3HisRunTag() { Id = vv.Value.Id, Circle = vv.Value.Circle, Type = vv.Value.Type, TagType = vv.Value.TagType, RealMemoryAddr = realbaseaddr, RealMemoryPtr = realHandle, RealValueAddr = realaddr, CompressType = vv.Value.CompressType, Parameters = vv.Value.Parameters }; mHisTag = new LongPoint3HisRunTag() { Id = vv.Value.Id, Circle = vv.Value.Circle, Type = vv.Value.Type, TagType = vv.Value.TagType, RealMemoryAddr = realbaseaddr, RealMemoryPtr = realHandle, RealValueAddr = realaddr, CompressType = vv.Value.CompressType, Parameters = vv.Value.Parameters };
break; break;
} }
mHisTag.MaxCount = count; mHisTag.MaxCount = count-1;
mHisTags.Add(vv.Key, mHisTag); mHisTags.Add(vv.Key, mHisTag);
if (mHisTag.Type == Cdy.Tag.RecordType.Timer) if (mHisTag.Type == Cdy.Tag.RecordType.Timer)
......
...@@ -298,7 +298,7 @@ namespace Cdy.Tag ...@@ -298,7 +298,7 @@ namespace Cdy.Tag
mHisTag = new LongPoint3HisRunTag() { Id = vv.Value.Id, Circle = vv.Value.Circle, Type = vv.Value.Type, TagType = vv.Value.TagType, RealMemoryAddr = realbaseaddr, RealMemoryPtr = realHandle, RealValueAddr = realaddr, CompressType = vv.Value.CompressType, Parameters = vv.Value.Parameters }; mHisTag = new LongPoint3HisRunTag() { Id = vv.Value.Id, Circle = vv.Value.Circle, Type = vv.Value.Type, TagType = vv.Value.TagType, RealMemoryAddr = realbaseaddr, RealMemoryPtr = realHandle, RealValueAddr = realaddr, CompressType = vv.Value.CompressType, Parameters = vv.Value.Parameters };
break; break;
} }
mHisTag.MaxCount = count; mHisTag.MaxCount = count-1;
mHisTags.Add(vv.Key, mHisTag); mHisTags.Add(vv.Key, mHisTag);
if (mHisTag.Type == Cdy.Tag.RecordType.Timer) if (mHisTag.Type == Cdy.Tag.RecordType.Timer)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册