Commit 5b9bd409 by liulongfei

1. 修复数字输入框限制精度的bug

2. 固定buffer处理器添加同步针头校验
3. 模型添加安全更新方式
parent 717b5284
......@@ -193,7 +193,7 @@ namespace VIZ.Framework.Common
}
value = MathHelper.Clip(this.MinValue, this.MaxValue, value);
value = Math.Round(value, MathHelper.GetDigitsPrecision(value));
value = Math.Round(value, MathHelper.GetDigitsPrecision(this.Interval));
this.Text = value.ToString();
this.Value = value;
......@@ -227,7 +227,7 @@ namespace VIZ.Framework.Common
private void PART_Down_Click(object sender, RoutedEventArgs e)
{
double value = this.Value - this.Interval;
value = Math.Round(value, MathHelper.GetDigitsPrecision(value));
value = Math.Round(value, MathHelper.GetDigitsPrecision(this.Interval));
if (value < this.MinValue || value > this.MaxValue)
return;
......@@ -241,7 +241,7 @@ namespace VIZ.Framework.Common
private void PART_Up_Click(object sender, RoutedEventArgs e)
{
double value = this.Value + this.Interval;
value = Math.Round(value, MathHelper.GetDigitsPrecision(value));
value = Math.Round(value, MathHelper.GetDigitsPrecision(this.Interval));
if (value < this.MinValue || value > this.MaxValue)
return;
......
......@@ -40,5 +40,10 @@ namespace VIZ.Framework.Connection
/// 处理器
/// </summary>
public IConnPackageProvider Provider { get; internal set; }
/// <summary>
/// 消息创建时间
/// </summary>
public DateTime DateTime { get; internal set; } = DateTime.Now;
}
}
......@@ -23,11 +23,17 @@ namespace VIZ.Framework.Connection
/// 固定长度Buffer包解析器
/// </summary>
/// <param name="fixedBufferSize">固定Buffer长度</param>
public ConnFixedBufferPackageProvider(int fixedBufferSize)
/// <param name="syncHeader">同步头</param>
public ConnFixedBufferPackageProvider(int fixedBufferSize, IEnumerable<byte> syncHeader)
{
this.FixedBufferSize = fixedBufferSize;
this.buffer_index = 0;
this.buffer_cache = new byte[fixedBufferSize];
if (syncHeader != null)
{
this.SyncHeader.AddRange(SyncHeader);
}
}
/// <summary>
......@@ -36,6 +42,11 @@ namespace VIZ.Framework.Connection
public int FixedBufferSize { get; private set; }
/// <summary>
/// 同步头
/// </summary>
public List<byte> SyncHeader { get; private set; } = new List<byte>();
/// <summary>
/// 数据缓存
/// </summary>
private byte[] buffer_cache;
......@@ -63,6 +74,21 @@ namespace VIZ.Framework.Connection
if (this.buffer_index < this.FixedBufferSize)
continue;
// 同步头
int sync_index = this.getSyncIndex();
if (sync_index < 0)
{
continue;
}
if (sync_index > 0)
{
byte[] buffer_cache_new = new byte[this.FixedBufferSize];
Array.Copy(this.buffer_cache, sync_index, buffer_cache_new, 0, this.FixedBufferSize - sync_index);
this.buffer_index -= sync_index;
continue;
}
// 处理器处理消息
ConnFixedBufferInfo info = new ConnFixedBufferInfo();
info.LocalIP = package.LocalIP;
......@@ -113,5 +139,40 @@ namespace VIZ.Framework.Connection
{
// noting to do.
}
/// <summary>
/// 获取当前同步帧位序
/// </summary>
/// <returns>获取当前同步帧位序</returns>
private int getSyncIndex()
{
if (this.SyncHeader.Count == 0)
return 0;
for (int i = 0; i < this.FixedBufferSize - this.SyncHeader.Count; ++i)
{
if (this.isSameSyncBuffer(i))
return i;
}
// 未找到同步数据
return -1;
}
/// <summary>
/// 是否是相同的同步帧buffer
/// </summary>
/// <param name="index">开始位序</param>
/// <returns>是否是相同的同步帧buffer</returns>
private bool isSameSyncBuffer(int index)
{
for (int i = 0; i < this.SyncHeader.Count; ++i)
{
if (this.buffer_cache[index + i] != this.SyncHeader[i])
return false;
}
return true;
}
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace VIZ.Framework.Core
{
......@@ -32,6 +33,25 @@ namespace VIZ.Framework.Core
}
/// <summary>
/// 触发属性改变前事件(安全方式)
/// </summary>
/// <param name="propertyName">属性名</param>
public void RaisePropertySaveChanging(string propertyName)
{
if (Application.Current.Dispatcher.CheckAccess())
{
this.PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(propertyName));
return;
}
WPFHelper.BeginInvoke(() =>
{
this.PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(propertyName));
});
}
/// <summary>
/// 触发属性改变后事件
/// </summary>
/// <param name="propertyName">属性名</param>
......@@ -39,5 +59,24 @@ namespace VIZ.Framework.Core
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
/// <summary>
/// 触发属性改变后事件(安全方式)
/// </summary>
/// <param name="propertyName">属性名</param>
public void RaisePropertySaveChanged(string propertyName)
{
if (Application.Current.Dispatcher.CheckAccess())
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
return;
}
WPFHelper.BeginInvoke(() =>
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
});
}
}
}
......@@ -209,7 +209,7 @@ namespace VIZ.Framework.ImageContrastTool
{
if (System.IO.Directory.Exists(this.LeftPath))
{
this.ImageFiles = System.IO.Directory.GetFiles(this.LeftPath, "*.jpg").ToList();
this.ImageFiles = System.IO.Directory.GetFiles(this.LeftPath, "*.*").ToList();
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment