Commit f504e6ba authored by 潘栩锋's avatar 潘栩锋 🚴

1. 测试报警异常

parent 9c836bcf
......@@ -24,9 +24,10 @@ namespace FLY.OBJComponents.Client
#region property
/// <summary>
/// 最后一行数据的ID
/// 最新数据的ID,就是 Buffer.NewestID,
/// 但不直接使用Buffer.NewestID,因为 Buffer.NewestID可能与接收的数据滞后,或超前
/// </summary>
public int RecordLastID { get; private set; } = 0;
public int RecordLastID { get; private set; } = -1;
/// <summary>
/// 窗口最后一行的目标ID
/// </summary>
......@@ -40,7 +41,7 @@ namespace FLY.OBJComponents.Client
/// </summary>
public int TotalPages { get; private set; }
/// <summary>
/// 当前页码
/// 当前页码, 页码从1-TotalPages
/// </summary>
public int CurrentPage { get; private set; }
......@@ -70,7 +71,7 @@ namespace FLY.OBJComponents.Client
Buffer = buffer;
IsKeepNewest = true;
WindowID = Buffer.NewestID;
WindowID = Buffer.NewestID;//显示最新数据!!!
updatePageInfo();
GetWindow();
......@@ -142,13 +143,13 @@ namespace FLY.OBJComponents.Client
{
case NotifyBufferChangedAction.Add:
{
int newEndingIndex = e.StartingIndex - 1 + 1;
int nFirstID = e.StartingIndex;
int nLastID = newEndingIndex;
int newEndingID = e.EndingID;
int nFirstID = e.EndingID;
int nLastID = newEndingID;
if (IsKeepNewest)//保持数据最新
{
WindowID = newEndingIndex;
WindowID = newEndingID;
}
int wLastID = WindowID;
......@@ -164,27 +165,25 @@ namespace FLY.OBJComponents.Client
}
else
{
push(newEndingIndex, (IList<T>)e.Items);
push(newEndingID, (IList<T>)e.Items);
}
}
break;
case NotifyBufferChangedAction.Replace:
{
int newEndingIndex = e.StartingIndex - 1 + 1;
push(newEndingIndex, (IList<T>)e.Items);
push(e.EndingID, (IList<T>)e.Items);
}
break;
case NotifyBufferChangedAction.Remove:
{
int newEndingIndex = e.StartingIndex - 1 + 1;
remove(newEndingIndex, 1);
remove(e.EndingID, 1);
}
break;
case NotifyBufferChangedAction.Reset:
{
//数据清空
Record.Clear();
RecordLastID = 0;
RecordLastID = -1;
WindowID = Size - 1;
}
break;
......@@ -220,8 +219,8 @@ namespace FLY.OBJComponents.Client
int offset = -rFirstID;
firstID += offset;
lastID += offset;
rLastID += offset;
rFirstID = 0;
rLastID += offset;// = Record.Count()-1
rFirstID = 0;// = 0
if (lastID < -1)//新数据在旧数据前面,不能合并
{
......@@ -288,7 +287,7 @@ namespace FLY.OBJComponents.Client
int offset = -rFirstID;
firstID += offset;
lastID += offset;
rLastID += offset;
rLastID += offset;// = Record.Count() - 1;
rFirstID = 0;
if (lastID <= -1)//被删除数据在当前数据前面,什么都不用做
......@@ -299,11 +298,12 @@ namespace FLY.OBJComponents.Client
{
//重新问buffer获取当前数据块
Record.Clear();
RecordLastID = 0;
RecordLastID = -1;
GetWindow();
}
}
}
/// <summary>
/// 把多出window范围的数据删除
/// </summary>
......@@ -366,19 +366,28 @@ namespace FLY.OBJComponents.Client
void updatePageInfo()
{
int firstID = Buffer.NewestID - Buffer.Count + 1;
int firstID = Buffer.NewestID - (Buffer.Count - 1);
int lastID = Buffer.NewestID;
int wLastID = WindowID;
//修正后,firstID,lastID 就是Buffer 内部数据量的排序,lastID=Count-1
int offset = -firstID;
lastID += offset;
wLastID += offset;
firstID = 0;
int page = (int)(Math.Ceiling(1.0 * wLastID / Size));
TotalPages = page + (int)(Math.Ceiling((1.0 * (lastID - wLastID) / Size)));
int page = wLastID / Size;
int page1st_size = wLastID % Size;
int totalpages = (int)(Math.Ceiling((1.0 * (lastID - page1st_size) / Size)));
if (page1st_size != 0)
{
page++;
totalpages++;
}
CurrentPage = page;
TotalPages = totalpages;
if (CurrentPage <=1)
IsFirstPage = true;
else
......
......@@ -17,7 +17,7 @@ namespace FLY.OBJComponents.Client
public class BufferServiceClient<T> : FObj, IBuffer<T>
{
#region property
public int NewestID { get; private set; } = 0;
public int NewestID { get; private set; } = -1;
public int Count { get; private set; } = 0;
/// <summary>
/// 总容量,当总数量 大于等于 总容量的 100%, 前面的10%数据会被删除
......@@ -45,10 +45,11 @@ namespace FLY.OBJComponents.Client
{
if (isIgnore)
return;
Dictionary<string, object> datas = new Dictionary<string, object>();
datas.Add(e.PropertyName, Misc.PropertiesManager.GetValue(sender, e.PropertyName));
Dictionary<string, object> datas = new Dictionary<string, object>
{
{ e.PropertyName, Misc.PropertiesManager.GetValue(sender, e.PropertyName) }
};
string json = JsonConvert.SerializeObject(datas);
CurrObjSys.SetValueEx(mConn, mServerID, ID, BUFFER_OBJ_INTERFACE.SET_PARAMS,
Misc.Converter.StringToBytes(json));
......@@ -91,7 +92,9 @@ namespace FLY.OBJComponents.Client
string json = Misc.Converter.BytesToString(infodata);
Dictionary<string, object> datas = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
//设置属性
//屏蔽属性改变后,设置到服务器
isIgnore = true;
foreach (KeyValuePair<string, object> kv in datas)
......@@ -129,12 +132,6 @@ namespace FLY.OBJComponents.Client
switch (funcid)
{
case BUFFER_OBJ_INTERFACE.CALL_GETRECORD:
{
string json = Misc.Converter.BytesToString(retdata);
GetRecordReponse<T> p = JsonConvert.DeserializeObject<GetRecordReponse<T>>(json);
((AsyncCBHandler)AsyncDelegate)(AsyncState, p);
}
break;
case BUFFER_OBJ_INTERFACE.CALL_GETRECORD_NEWEST:
{
string json = Misc.Converter.BytesToString(retdata);
......@@ -152,7 +149,12 @@ namespace FLY.OBJComponents.Client
public void GetRecord(int last_id, int count, AsyncCBHandler asyncCB, object asyncContext)
{
BUFFER_OBJ_INTERFACE.Pack_GetRecordRequest request = new BUFFER_OBJ_INTERFACE.Pack_GetRecordRequest() { last_id = last_id, count = count };
BUFFER_OBJ_INTERFACE.Pack_GetRecordRequest request = new BUFFER_OBJ_INTERFACE.Pack_GetRecordRequest()
{
last_id = last_id,
count = count
};
string json = JsonConvert.SerializeObject(request);
CurrObjSys.CallFunctionEx(mConn, mServerID, ID, BUFFER_OBJ_INTERFACE.CALL_GETRECORD,
......@@ -162,7 +164,10 @@ namespace FLY.OBJComponents.Client
}
public void GetRecord(int count, AsyncCBHandler asyncCB, object asyncContext)
{
BUFFER_OBJ_INTERFACE.Pack_GetRecordNewestRequest request = new BUFFER_OBJ_INTERFACE.Pack_GetRecordNewestRequest() { count = count };
BUFFER_OBJ_INTERFACE.Pack_GetRecordNewestRequest request = new BUFFER_OBJ_INTERFACE.Pack_GetRecordNewestRequest()
{
count = count
};
string json = JsonConvert.SerializeObject(request);
CurrObjSys.CallFunctionEx(mConn, mServerID, ID, BUFFER_OBJ_INTERFACE.CALL_GETRECORD_NEWEST,
......
......@@ -20,7 +20,7 @@ namespace FLY.OBJComponents.Common
{
public NotifyBufferChangedAction Action { get; set; }
public IList<T> Items { get; set; }
public int StartingIndex { get; set; }
public int EndingID { get; set; }
}
public enum NotifyBufferChangedAction
......
......@@ -36,9 +36,11 @@ namespace FLY.OBJComponents.Server.OBJProxy
private void Buffer_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Dictionary<string, object> p = new Dictionary<string, object>();
p.Add(e.PropertyName, Misc.PropertiesManager.GetValue(buffer, e.PropertyName));
Dictionary<string, object> p = new Dictionary<string, object>
{
{ e.PropertyName, Misc.PropertiesManager.GetValue(sender, e.PropertyName) }
};
string json = JsonConvert.SerializeObject(p);
CurrObjSys.PushObjInfoEx(
this, BUFFER_OBJ_INTERFACE.PUSH_PARAMS,
......@@ -62,9 +64,6 @@ namespace FLY.OBJComponents.Server.OBJProxy
}
}
break;
default:
infodata = null;
break;
}
}
......
......@@ -20,7 +20,7 @@ namespace FLY.OBJComponents.Server
public List<T> list = new List<T>();
#region property
public int NewestID { get; set; }
public int NewestID { get; set; } = -1;
public int Count { get; private set; } = 0;
/// <summary>
......@@ -46,11 +46,14 @@ namespace FLY.OBJComponents.Server
public int GetID(int idx)
{
return NewestID - (list.Count() - 1 - idx);
int offset = (NewestID - (list.Count() - 1));
return offset + idx;
}
public int GetIndex(int id)
{
return list.Count() - 1 - (NewestID - id);
int offset = (NewestID - (list.Count() - 1));
return id - offset;
}
public void Add(T t)
{
......@@ -60,9 +63,8 @@ namespace FLY.OBJComponents.Server
{
list.RemoveRange(0, Capacity / 10);
}
if (list.Count() != 1)
NewestID++;
NewestID++;
Count = list.Count();
......@@ -72,7 +74,7 @@ namespace FLY.OBJComponents.Server
{
Action = NotifyBufferChangedAction.Add,
Items = new T[] { t },
StartingIndex = NewestID
EndingID = NewestID
});
}
public void AddRange(IList<T> array)
......@@ -83,9 +85,8 @@ namespace FLY.OBJComponents.Server
{
list.RemoveRange(0, Capacity / 10);
}
if (list.Count() != 1)
NewestID += array.Count();
NewestID += array.Count();
Count = list.Count();
BufferChanged?.Invoke(this,
......@@ -93,7 +94,7 @@ namespace FLY.OBJComponents.Server
{
Action = NotifyBufferChangedAction.Add,
Items = array,
StartingIndex = NewestID
EndingID = NewestID
});
}
public override string ToString()
......@@ -111,7 +112,7 @@ namespace FLY.OBJComponents.Server
{
Action = NotifyBufferChangedAction.Replace,
Items = new T[] { t },
StartingIndex = id
EndingID = id
});
}
public void Remove(int id)
......@@ -127,14 +128,14 @@ namespace FLY.OBJComponents.Server
new NotifyBufferChangedEventArgs<T>()
{
Action = NotifyBufferChangedAction.Remove,
StartingIndex = id,
EndingID = id,
Items = new T[] { t }
});
}
public void Reset()
{
list.Clear();
NewestID = 0;
NewestID = -1;
Count = 0;
BufferChanged?.Invoke(this,
new NotifyBufferChangedEventArgs<T>()
......
......@@ -52,12 +52,13 @@ namespace FLY.OBJComponents.Server
public void Add(byte errcode, string description, ERR_STATE state)
{
FlyData_WarningHistory reason = new FlyData_WarningHistory();
reason.Time = DateTime.Now;
reason.ErrCode = errcode;
reason.Description = description;
reason.State = state;
FlyData_WarningHistory reason = new FlyData_WarningHistory
{
Time = DateTime.Now,
ErrCode = errcode,
Description = description,
State = state
};
FlyData_WarningHistory error = null;
Buffer<FlyData_WarningHistory> reasonList = ReasonList as Buffer<FlyData_WarningHistory>;
......@@ -77,7 +78,7 @@ namespace FLY.OBJComponents.Server
case ERR_STATE.ON:
if (error == null)
{
((Buffer<FlyData_WarningHistory>)ReasonList).Add(reason.Clone());
reasonList.Add(reason.Clone());
}
else
......@@ -95,7 +96,7 @@ namespace FLY.OBJComponents.Server
else
{
error.State = state;
((Buffer<FlyData_WarningHistory>)ReasonList).Remove(error_id);
reasonList.Remove(error_id);
}
break;
......
......@@ -5,6 +5,7 @@
<Grid>
<Grid x:Name="grid_plc"/>
<Grid x:Name="grid_plcos"/>
<Grid x:Name="grid_WeightSystem"/>
<StackPanel Orientation="Vertical" Margin="5">
<StackPanel Orientation="Horizontal" >
......@@ -26,7 +27,12 @@
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" DataContext="{Binding ElementName=grid_WeightSystem,Path=DataContext}">
<StackPanel Orientation="Vertical">
<CheckBox Content="A层 No.1料斗加料异常" IsChecked="{Binding Items[0].IsErrorOfAdd_1}"/>
<CheckBox Content="B层 No.2料斗加料异常" IsChecked="{Binding Items[1].IsErrorOfAdd_2}"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
......
......@@ -45,6 +45,7 @@ namespace FLY.Weight.UI.Server
mTDGage.mData.PLCos as FLY.OBJComponents.Server.PLCProxySystem;
grid_plcos.DataContext = plsos;
grid_plc.DataContext = plsos.PLCs[0];
grid_WeightSystem.DataContext = mTDGage.mData;
}
}
}
......@@ -73,6 +73,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlyADBase", "Project.FLY.Fl
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TCPManager", "Project.FLY.FObjSys\TCPManager\TCPManager.csproj", "{7D455950-7D7D-4C79-8E9C-4CF53F09559A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Thick-Common", "Thick-Common", "{2488C4FB-3677-405B-BE1B-C9F532708DE3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -434,15 +436,20 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6D4B9BDA-2A66-4583-B244-758BC4213D9F} = {2488C4FB-3677-405B-BE1B-C9F532708DE3}
{88EFEDF8-8228-4EEE-90AF-1EBF747B9FAB} = {4439B7B4-75FB-48D3-8705-BB6C46802F23}
{76C9AC3F-D569-4D2C-BCFD-77421B532BBE} = {4439B7B4-75FB-48D3-8705-BB6C46802F23}
{10C1112E-B7D6-4ACF-B03F-80C2EE58F17D} = {4439B7B4-75FB-48D3-8705-BB6C46802F23}
{97C282A9-F2F0-4B3C-A3B0-B351918D5C4D} = {618447B0-5185-4A52-878E-4C380741E839}
{654515F2-CAAE-450B-A344-547321836E8F} = {618447B0-5185-4A52-878E-4C380741E839}
{F0D844CD-3B55-4D3F-88CA-40EC4CDFE1DD} = {618447B0-5185-4A52-878E-4C380741E839}
{119C3ADC-F8E1-4F72-B89B-006236FF8586} = {2488C4FB-3677-405B-BE1B-C9F532708DE3}
{A539505D-9AC0-426B-A9A0-197DF50598B0} = {2488C4FB-3677-405B-BE1B-C9F532708DE3}
{5EE61AC6-5269-4F0F-B8FA-4334FE4A678F} = {2488C4FB-3677-405B-BE1B-C9F532708DE3}
{A989E480-3730-4B26-809F-DFF94D145D6E} = {086F6EF1-272B-4AFE-89DD-D6EDDF8333E6}
{9A289B5D-24AA-4031-86C7-1300B4FDCB55} = {086F6EF1-272B-4AFE-89DD-D6EDDF8333E6}
{6B762AA7-5C5F-4E1D-AC6A-CAF327056EBE} = {086F6EF1-272B-4AFE-89DD-D6EDDF8333E6}
{ABFE87D4-B692-4AE9-A8C0-1F470B8ACBB8} = {2488C4FB-3677-405B-BE1B-C9F532708DE3}
{CC20ABEB-59F6-492B-A963-51121EB5AE66} = {1262AB40-4503-469A-A00B-50C1AE6A3BA6}
{EC11911F-D868-49EA-BDA4-9F91CA7186AF} = {1262AB40-4503-469A-A00B-50C1AE6A3BA6}
{973DE547-A50D-4FF0-90A4-15FCCE8771BD} = {1262AB40-4503-469A-A00B-50C1AE6A3BA6}
......@@ -453,8 +460,11 @@ Global
{FB1D06A7-081C-48B7-A3D9-136C7162BB9F} = {5D1BC40E-05AA-4682-B637-4F522EEB82E9}
{8E19C40F-CE7F-4982-BD90-4EB4E9E04E34} = {5D1BC40E-05AA-4682-B637-4F522EEB82E9}
{2F88B5EC-85BC-4B5E-B254-06D2F2771F67} = {1262AB40-4503-469A-A00B-50C1AE6A3BA6}
{4DF79671-E814-49BD-864D-8257D6C6E072} = {2488C4FB-3677-405B-BE1B-C9F532708DE3}
{8CAD11B7-BF6E-48BB-92A4-7273FEE9846D} = {1262AB40-4503-469A-A00B-50C1AE6A3BA6}
{9C46D98F-6500-490B-9E56-C89DFFFA05F8} = {2488C4FB-3677-405B-BE1B-C9F532708DE3}
{DD8A6858-1261-49F7-86BE-5AC5C3A0EC34} = {1262AB40-4503-469A-A00B-50C1AE6A3BA6}
{7D455950-7D7D-4C79-8E9C-4CF53F09559A} = {2488C4FB-3677-405B-BE1B-C9F532708DE3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BD78A3E8-6F11-4F24-AB5F-A9F25461F64F}
......
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