大屏页面与接口开发v4

dev-0829
ccongli 1 year ago
parent 5aa767e3d5
commit 4a5629bc4e

@ -70,8 +70,8 @@ namespace VOL.Core.Utils
temp[i] = src[i + start]; temp[i] = src[i + start];
} }
byte[] bytesTemp = Ushorts2Bytes(temp,false); byte[] bytesTemp = Ushorts2Bytes(temp,false);
//Array.Reverse(bytesTemp); // BitConverter默认是小端转换如果是大端顺序数组接收需要先反序字节顺序
// BitConverter默认是小端转换如果是大端字节顺序存放需要先反序字节顺序 Array.Reverse(bytesTemp);
float res = BitConverter.ToSingle(bytesTemp, 0); float res = BitConverter.ToSingle(bytesTemp, 0);
return res; return res;
} catch (Exception e) } catch (Exception e)
@ -147,6 +147,7 @@ namespace VOL.Core.Utils
ushort[] temp = new ushort[2]; ushort[] temp = new ushort[2];
temp[0] = src[start]; temp[0] = src[start];
temp[1] = src[start + 1]; // 0 100 temp[1] = src[start + 1]; // 0 100
Array.Reverse(temp);
byte[] bytesTemp = Ushorts2Bytes(temp); byte[] bytesTemp = Ushorts2Bytes(temp);
int res = BitConverter.ToInt32(bytesTemp, 0); int res = BitConverter.ToInt32(bytesTemp, 0);
return res; return res;
@ -172,6 +173,7 @@ namespace VOL.Core.Utils
temp[1] = src[start + 1]; temp[1] = src[start + 1];
temp[2] = src[start + 2]; temp[2] = src[start + 2];
temp[3] = src[start + 3]; temp[3] = src[start + 3];
Array.Reverse(temp);
byte[] bytesTemp = Ushorts2Bytes(temp); byte[] bytesTemp = Ushorts2Bytes(temp);
long res = BitConverter.ToInt64(bytesTemp, 0); long res = BitConverter.ToInt64(bytesTemp, 0);
return res; return res;
@ -197,8 +199,8 @@ namespace VOL.Core.Utils
for (int i = start; i < start + num; i++) for (int i = start; i < start + num; i++)
{ {
temp[i] = src[i + start]; temp[i] = src[i + start];
} // 0 1 0 1 0 0 0 0 默认小端模式 }
//Array.Reverse(temp); // 0 0 0 0 1 0 1 0 Array.Reverse(temp); // 反序,小端读取
byte[] bytes = Ushorts2Bytes(temp); byte[] bytes = Ushorts2Bytes(temp);
bool[] res = Bytes2Bools(bytes); bool[] res = Bytes2Bools(bytes);
return res; return res;

@ -23,20 +23,21 @@ namespace VOL.Data.Services.modbus
// 生产数据 // 生产数据
Dictionary<string, object> map1 = new Dictionary<string, object> Dictionary<string, object> map1 = new Dictionary<string, object>
{ {
{ "com_status", modbus.readData(1, 6430, "int16") }, // 通讯状态 5通讯正常 15通讯断线 { "config_id", 1},
{ "run_time", modbus.readData(1, 6435, "int16") }, // 运行时长 分钟 { "com_status",modbus.readData(1, 6430, "int16") }, // 通讯状态 5通讯正常 15通讯断线
{ "turnout_1", modbus.readData(1, 6436, "int16") }, // 工单1产量 件 { "run_time", (int)modbus.readData(1, 6435, "int16") }, // 运行时长 分钟
{ "turnout_2", modbus.readData(1, 6437, "int16") }, // 工单2产量 件 { "turnout_1",(int)modbus.readData(1, 6436, "int16") }, // 工单1产量 件
{ "turnout_3", modbus.readData(1, 6438, "int16") }, // 工单3产量 件 { "turnout_2", (int)modbus.readData(1, 6437, "int16") }, // 工单2产量 件
{ "turnout_all", modbus.readData(1, 6439, "int16") }, // 当班产量 件 { "turnout_3", (int)modbus.readData(1, 6438, "int16") }, // 工单3产量 件
{ "turnout_all", (int)modbus.readData(1, 6439, "int16") }, // 当班产量 件
{ "status", modbus.readData(1, 6440, "int16") }, // 运行状态 0:待机 1运行 2故障 { "status", modbus.readData(1, 6440, "int16") }, // 运行状态 0:待机 1运行 2故障
{ "schedule_1", modbus.readData(1, 1315, "single") }, // 工单1任务进度 % { "schedule_1", (decimal)modbus.readData(1, 1315, "single") }, // 工单1任务进度 %
{ "schedule_2", modbus.readData(1, 1317, "single") }, // 工单2任务进度 % { "schedule_2",(decimal) modbus.readData(1, 1317, "single") }, // 工单2任务进度 %
{ "schedule_3", modbus.readData(1, 1319, "single") }, // 工单3任务进度 % { "schedule_3", (decimal)modbus.readData(1, 1319, "single") }, // 工单3任务进度 %
{ "yield_1", modbus.readData(1, 1321, "single") }, // 工单1良品率 % 真实值 *= 100 { "yield_1", (decimal)modbus.readData(1, 1321, "single") }, // 工单1良品率 % 真实值 *= 100
{ "yield_2", modbus.readData(1, 1323, "single") }, // 工单2良品率 % 真实值 *= 100 { "yield_2", (decimal)modbus.readData(1, 1323, "single") }, // 工单2良品率 % 真实值 *= 100
{ "yield_3", modbus.readData(1, 1325, "single") }, // 工单3良品率 % 真实值 *= 100 { "yield_3", (decimal)modbus.readData(1, 1325, "single") }, // 工单3良品率 % 真实值 *= 100
{ "oee", modbus.readData(1, 1339, "single") }, // 设备综合效率 % 真实值 *= 100 { "oee", (decimal)modbus.readData(1, 1339, "single") }, // 设备综合效率 % 真实值 *= 100
}; };
// 机床数据 // 机床数据
@ -44,17 +45,18 @@ namespace VOL.Data.Services.modbus
{ {
// 操作模式 0:JOG 1:AUTO 2:AUTO + TEACHIN 3:JOG + REPOIN 4:JOG + REPOS // 操作模式 0:JOG 1:AUTO 2:AUTO + TEACHIN 3:JOG + REPOIN 4:JOG + REPOS
// 5:MDA 6:MDA + REPOS 7:MDA + REPOS + TEAHIN8:MDA + TEACHIN // 5:MDA 6:MDA + REPOS 7:MDA + REPOS + TEAHIN8:MDA + TEACHIN
{ "config_id", 1},
{ "com_status", modbus.readData(1, 6430, "int16") }, // 通讯状态 5通讯正常 15通讯断线 { "com_status", modbus.readData(1, 6430, "int16") }, // 通讯状态 5通讯正常 15通讯断线
{ "smode", modbus.readData(1, 6099, "int16") }, { "smode", modbus.readData(1, 6099, "int16") },
{ "state", modbus.readData(1, 6429, "int16") }, // 运行状态 0:待机 1:故障 2:运行 3:暂停 { "state", modbus.readData(1, 6429, "int16") }, // 运行状态 0:待机 1:故障 2:运行 3:暂停
{ "temperature", modbus.readData(1, 1201, "single")}, // 电机温度 ℃ { "temperature", (decimal)modbus.readData(1, 1201, "single")}, // 电机温度 ℃
{ "potential", modbus.readData(1, 1203, "single")}, // 母线电压 V { "potential", (decimal)modbus.readData(1, 1203, "single")}, // 母线电压 V
{ "current", modbus.readData(1, 1205, "single")}, // 实际电流 A { "current", (decimal)modbus.readData(1, 1205, "single")}, // 实际电流 A
{ "quantity", modbus.readData(1, 1215, "single")}, // 加工数 次 { "quantity", (long)modbus.readData(1, 1215, "single")}, // 加工数 次
{ "cut_rate", modbus.readData(1, 1225, "single")}, // 切削倍率 { "cut_rate", (decimal)modbus.readData(1, 1225, "single")}, // 切削倍率
{ "main_rate", modbus.readData(1, 1231, "single")}, // 主轴倍率 { "main_rate", (decimal)modbus.readData(1, 1231, "single")}, // 主轴倍率
{ "run_program_no", modbus.readData(1, 6689, "string", 26)}, // 加工程序号 length = 52 { "run_program_no", modbus.readData(1, 6689, "string", 26)}, // 加工程序号 length = 52
{ "run_time_total", modbus.readData(1, 6435, "int16")}, // 累计运行时长 分钟 { "run_time_total", (long)modbus.readData(1, 6435, "int16")}, // 累计运行时长 分钟
}; };
// 组装Map返回 // 组装Map返回
@ -70,37 +72,39 @@ namespace VOL.Data.Services.modbus
// 生产数据 // 生产数据
Dictionary<string, object> map1 = new Dictionary<string, object> Dictionary<string, object> map1 = new Dictionary<string, object>
{ {
{ "program_no", modbus.readData(1, 6429, "int16") }, // 程序编号 { "config_id", 2}, // 枚举todo
{ "program_no", (int)modbus.readData(1, 6429, "int16") }, // 程序编号
{ "com_status", modbus.readData(1, 6430, "int16") }, // 通讯状态 5通讯正常 15通讯断线 { "com_status", modbus.readData(1, 6430, "int16") }, // 通讯状态 5通讯正常 15通讯断线
{ "run_time", modbus.readData(1, 6435, "int16") }, // 运行时长 分钟 { "run_time", (int)modbus.readData(1, 6435, "int16") }, // 运行时长 分钟
{ "turnout_1", modbus.readData(1, 6436, "int16") }, // 工单1产量 件 { "turnout_1", (int)modbus.readData(1, 6436, "int16") }, // 工单1产量 件
{ "turnout_2", modbus.readData(1, 6437, "int16") }, // 工单2产量 件 { "turnout_2", (int)modbus.readData(1, 6437, "int16") }, // 工单2产量 件
{ "turnout_3", modbus.readData(1, 6438, "int16") }, // 工单3产量 件 { "turnout_3", (int)modbus.readData(1, 6438, "int16") }, // 工单3产量 件
{ "turnout_all", modbus.readData(1, 6439, "int16") }, // 当班产量 件 { "turnout_all",(int)modbus.readData(1, 6439, "int16") }, // 当班产量 件
{ "status", modbus.readData(1, 6435, "int16") }, // 运行状态 0:待机 1运行 2故障 { "status", modbus.readData(1, 6440, "int16") }, // 运行状态 0:待机 1运行 2故障
{ "schedule_1", modbus.readData(1, 1315, "single") }, // 工单1任务进度 % { "schedule_1", (decimal)modbus.readData(1, 1315, "single") }, // 工单1任务进度 %
{ "schedule_2", modbus.readData(1, 1317, "single") }, // 工单2任务进度 % { "schedule_2", (decimal)modbus.readData(1, 1317, "single") }, // 工单2任务进度 %
{ "schedule_3", modbus.readData(1, 1319, "single") }, // 工单3任务进度 % { "schedule_3", (decimal)modbus.readData(1, 1319, "single") }, // 工单3任务进度 %
{ "yield_1", modbus.readData(1, 1321, "single") }, // 工单1良品率 % 真实值 *= 100 { "yield_1", (decimal)modbus.readData(1, 1321, "single") }, // 工单1良品率 % 真实值 *= 100
{ "yield_2", modbus.readData(1, 1323, "single") }, // 工单2良品率 % 真实值 *= 100 { "yield_2", (decimal)modbus.readData(1, 1323, "single") }, // 工单2良品率 % 真实值 *= 100
{ "yield_3", modbus.readData(1, 1325, "single") }, // 工单3良品率 % 真实值 *= 100 { "yield_3", (decimal)modbus.readData(1, 1325, "single") }, // 工单3良品率 % 真实值 *= 100
{ "oee", modbus.readData(1, 1331, "single") }, // 设备综合效率 % 真实值 *= 100 { "oee", (decimal)modbus.readData(1, 1331, "single") }, // 设备综合效率 % 真实值 *= 100
}; };
// 机床数据 // 机床数据
Dictionary<string, object> map2 = new Dictionary<string, object> Dictionary<string, object> map2 = new Dictionary<string, object>
{ {
{ "config_id", 2},
{ "com_status", modbus.readData(1, 6430, "int16") }, // 通讯状态 5通讯正常 15通讯断线 { "com_status", modbus.readData(1, 6430, "int16") }, // 通讯状态 5通讯正常 15通讯断线
{ "gmode", modbus.readData(1, 6099, "int16") }, // 工作方式 0:编辑 1:自动 2:MDI 3:DNC 4:手动 5:手轮 6:回参考点 { "gmode", modbus.readData(1, 6099, "int16") }, // 工作方式 0:编辑 1:自动 2:MDI 3:DNC 4:手动 5:手轮 6:回参考点
{ "state", modbus.readData(1, 6099, "int16") }, // 运行状态 0:复位 1:停止 2:运行 3:暂停 { "state", modbus.readData(1, 6100, "int16") }, // 运行状态 0:复位 1:停止 2:运行 3:暂停
{ "quantity", modbus.readData(1, 1199, "int32")}, // 加工数量 次 { "quantity", (long)modbus.readData(1, 1199, "int32")}, // 加工数量 次
{ "on_time", modbus.readData(1, 1201, "int32")}, // 开机时间 秒 { "on_time", (long)modbus.readData(1, 1201, "int32")}, // 开机时间 秒
{ "run_time", modbus.readData(1, 1203, "int32")}, // 运行时间 秒 { "run_time", (long)modbus.readData(1, 1203, "int32")}, // 运行时间 秒
{ "feed_rate", modbus.readData(1, 1241, "single")}, // 进给倍率 { "feed_rate", (decimal)modbus.readData(1, 1242, "single")}, // 进给倍率
{ "main_rate", modbus.readData(1, 1247, "single")}, // 主轴倍率 { "main_rate", (decimal)modbus.readData(1, 1248, "single")}, // 主轴倍率
{ "run_program_no", modbus.readData(1, 6299, "string", 4)}, // 运行程序编号 length = 8 { "run_program_no", modbus.readData(1, 6299, "string", 4)}, // 运行程序编号 length = 8
{ "run_time_total", modbus.readData(1, 4115, "int32")}, // 累计运行时长 分钟 { "run_time_total", (long)modbus.readData(1, 4115, "int32")}, // 累计运行时长 分钟
{ "quantity_total", modbus.readData(1, 4117, "int32")} // 累计加工数 次 { "quantity_total", (long)modbus.readData(1, 4117, "int32")} // 累计加工数 次
}; };
// 组装Map返回 // 组装Map返回
@ -121,18 +125,18 @@ namespace VOL.Data.Services.modbus
{ "gmode", machine.gmode ?? 1 }, { "gmode", machine.gmode ?? 1 },
{ "smode", machine.smode ?? 1 }, { "smode", machine.smode ?? 1 },
{ "run_program_no", machine.run_program_no ?? "12345"}, { "run_program_no", machine.run_program_no ?? "12345"},
{ "state", machine.state ?? 2 }, { "state", machine.state ?? 0 },
{ "temperature", machine.temperature ?? 33M }, { "temperature", machine.temperature ?? 0M },
{ "potential", machine.potential ?? 220M}, { "potential", machine.potential ?? 0M},
{ "current", machine.current ?? 36M}, { "current", machine.current ?? 0M},
{ "quantity", machine.current ?? 1008}, { "quantity", machine.quantity ?? 0},
{ "on_time", machine.on_time ?? 1694683609}, { "on_time", machine.on_time ?? 0},
{ "run_time", machine.run_time ?? 1694683629}, { "run_time", machine.run_time ?? 0},
{ "feed_rate",machine.cut_rate ?? 62.00M}, { "feed_rate",machine.feed_rate ?? 0M},
{ "cut_rate", machine.cut_rate ?? 68.00M}, { "cut_rate", machine.cut_rate ?? 0M},
{ "main_rate", machine.cut_rate ?? 65.00M}, { "main_rate", machine.main_rate ?? 0M},
{ "run_time_total", machine.run_time_total ?? 10080}, { "run_time_total", machine.run_time_total ?? 0},
{ "quantity_total", machine.quantity_total ?? 10086} { "quantity_total", machine.quantity_total ?? 0}
}; };
model.MainData = mapData; model.MainData = mapData;
try { try {
@ -162,21 +166,21 @@ namespace VOL.Data.Services.modbus
Dictionary<string, object> mapData = new() Dictionary<string, object> mapData = new()
{ {
{ "config_id", produce.config_id}, { "config_id", produce.config_id},
{ "program_no", produce.program_no ?? 56789 }, { "program_no", produce.program_no ?? 12345 },
{ "com_status", produce.com_status ?? 15 }, { "com_status", produce.com_status ?? 15 },
{ "run_time", produce.run_time ?? 34695 }, { "run_time", produce.run_time ?? 0 },
{ "status", produce.status ?? 1 }, { "status", produce.status ?? 0 },
{ "turnout_all", produce.turnout_all ?? 1640 }, { "turnout_all", produce.turnout_all ?? 0 },
{ "turnout_1", produce.turnout_1 ?? 450 }, { "turnout_1", produce.turnout_1 ?? 0 },
{ "turnout_2", produce.turnout_2 ?? 630 }, { "turnout_2", produce.turnout_2 ?? 0 },
{ "turnout_3", produce.turnout_3 ?? 560 }, { "turnout_3", produce.turnout_3 ?? 0 },
{ "schedule_1", produce.schedule_1 ?? 0.92M }, { "schedule_1", produce.schedule_1 ?? 0M },
{ "schedule_2", produce.schedule_2 ?? 0.88M }, { "schedule_2", produce.schedule_2 ?? 0M },
{ "schedule_3", produce.schedule_3 ?? 0.78M }, { "schedule_3", produce.schedule_3 ?? 0M },
{ "yield_1", produce.yield_1 ?? 0.97M }, { "yield_1", produce.yield_1 ?? 1M },
{ "yield_2", produce.yield_2 ?? 0.88M }, { "yield_2", produce.yield_2 ?? 0M },
{ "yield_3", produce.yield_3 ?? 0.92M }, { "yield_3", produce.yield_3 ?? 0M },
{ "oee", produce.oee ?? 0.99M } { "oee", produce.oee ?? 0.95M } // 默认95%
}; };
model.MainData = mapData; model.MainData = mapData;
try try

@ -47,9 +47,9 @@ namespace VOL.Entity.DomainModels
///通讯状态 ///通讯状态
/// </summary> /// </summary>
[Display(Name ="通讯状态")] [Display(Name ="通讯状态")]
[Column(TypeName="int")] [Column(TypeName="short")]
[Editable(true)] [Editable(true)]
public int? com_status { get; set; } public short? com_status { get; set; }
/// <summary> /// <summary>
///运行时长 ///运行时长
@ -63,9 +63,9 @@ namespace VOL.Entity.DomainModels
///运行状态 ///运行状态
/// </summary> /// </summary>
[Display(Name ="运行状态")] [Display(Name ="运行状态")]
[Column(TypeName="sbyte")] [Column(TypeName="short")]
[Editable(true)] [Editable(true)]
public sbyte? status { get; set; } public short? status { get; set; }
/// <summary> /// <summary>
///当班产量 ///当班产量

@ -70,8 +70,8 @@ namespace VOL.WebApi.Utils
temp[i] = src[i + start]; temp[i] = src[i + start];
} }
byte[] bytesTemp = Ushorts2Bytes(temp,false); byte[] bytesTemp = Ushorts2Bytes(temp,false);
//Array.Reverse(bytesTemp); Array.Reverse(bytesTemp);
// BitConverter默认是小端转换如果是大端字节顺序存放,需要先反序字节顺序 // BitConverter默认是小端转换如果是大端字节顺序数组接收,需要先反序字节顺序
float res = BitConverter.ToSingle(bytesTemp, 0); float res = BitConverter.ToSingle(bytesTemp, 0);
return res; return res;
} catch (Exception e) } catch (Exception e)
@ -147,7 +147,7 @@ namespace VOL.WebApi.Utils
ushort[] temp = new ushort[2]; ushort[] temp = new ushort[2];
temp[0] = src[start]; temp[0] = src[start];
temp[1] = src[start + 1]; // 0 100 temp[1] = src[start + 1]; // 0 100
Array.Reverse(temp); // 100 0 Array.Reverse(temp); // 100 0 地址低位存储低字节数据(小端)
byte[] bytesTemp = Ushorts2Bytes(temp); byte[] bytesTemp = Ushorts2Bytes(temp);
int res = BitConverter.ToInt32(bytesTemp, 0); int res = BitConverter.ToInt32(bytesTemp, 0);
return res; return res;
@ -173,7 +173,7 @@ namespace VOL.WebApi.Utils
temp[1] = src[start + 1]; temp[1] = src[start + 1];
temp[2] = src[start + 2]; temp[2] = src[start + 2];
temp[3] = src[start + 3]; // 0 0 0 100 temp[3] = src[start + 3]; // 0 0 0 100
//Array.Reverse(temp); // 100 0 0 0 Array.Reverse(temp); // 100 0 0 0
byte[] bytesTemp = Ushorts2Bytes(temp); byte[] bytesTemp = Ushorts2Bytes(temp);
long res = BitConverter.ToInt64(bytesTemp, 0); long res = BitConverter.ToInt64(bytesTemp, 0);
return res; return res;

@ -47,13 +47,13 @@
{"title":"工单3良品率","field":"yield_3","type":"decimal"}], {"title":"工单3良品率","field":"yield_3","type":"decimal"}],
[{"title":"设备综合效率","field":"oee","type":"decimal"}]]); [{"title":"设备综合效率","field":"oee","type":"decimal"}]]);
const searchFormFields = ref({"config_id":"","program_no":"","com_status":"","status":"","turnout_all":[null,null],"CreateDate":""}); const searchFormFields = ref({"config_id":"","program_no":"","com_status":"","status":"","turnout_all":[null,null],"CreateDate":""});
const searchFormOptions = ref([[{"dataKey":"produce_status","data":[],"title":"运行状态","field":"status","type":"select"},{"title":"程序编号","field":"program_no","type":"number"},{"dataKey":"produce_com_status","data":[],"title":"通讯状态","field":"com_status","type":"number"}],[{"title":"记录时间","field":"CreateDate","type":"datetime"},{"dataKey":"device_name","data":[],"title":"设备信息","field":"config_id","type":"select"},{"title":"当班产量","field":"turnout_all","type":"range"}]]); const searchFormOptions = ref([[{"dataKey":"produce_status","data":[],"title":"运行状态","field":"status","type":"select"},{"title":"程序编号","field":"program_no","type":"number"},{"dataKey":"produce_com_status","data":[],"title":"通讯状态","field":"com_status"}],[{"title":"记录时间","field":"CreateDate","type":"datetime"},{"dataKey":"device_name","data":[],"title":"设备信息","field":"config_id","type":"select"},{"title":"当班产量","field":"turnout_all","type":"range"}]]);
const columns = ref([{field:'id',title:'ID',type:'int',width:110,readonly:true,require:true,align:'left',sort:true}, const columns = ref([{field:'id',title:'ID',type:'int',width:110,readonly:true,require:true,align:'left',sort:true},
{field:'config_id',title:'设备信息',type:'int',bind:{ key:'device_name',data:[]},width:120,readonly:true,require:true,align:'left'}, {field:'config_id',title:'设备信息',type:'int',bind:{ key:'device_name',data:[]},width:120,readonly:true,require:true,align:'left'},
{field:'program_no',title:'程序编号',type:'int',width:150,align:'left'}, {field:'program_no',title:'程序编号',type:'int',width:150,align:'left'},
{field:'com_status',title:'通讯状态',type:'int',bind:{ key:'produce_com_status',data:[]},width:120,align:'left'}, {field:'com_status',title:'通讯状态',type:'short',bind:{ key:'produce_com_status',data:[]},width:120,align:'left'},
{field:'run_time',title:'运行时长',type:'int',width:110,align:'left'}, {field:'run_time',title:'运行时长',type:'int',width:110,align:'left'},
{field:'status',title:'运行状态',type:'sbyte',bind:{ key:'produce_status',data:[]},width:110,align:'left'}, {field:'status',title:'运行状态',type:'short',bind:{ key:'produce_status',data:[]},width:110,align:'left'},
{field:'turnout_all',title:'当班产量',type:'int',sort:true,width:120,align:'left'}, {field:'turnout_all',title:'当班产量',type:'int',sort:true,width:120,align:'left'},
{field:'turnout_1',title:'工单 1 产量',type:'int',width:120,align:'left'}, {field:'turnout_1',title:'工单 1 产量',type:'int',width:120,align:'left'},
{field:'turnout_2',title:'工单 2 产量',type:'int',width:120,align:'left'}, {field:'turnout_2',title:'工单 2 产量',type:'int',width:120,align:'left'},

Loading…
Cancel
Save