FANUC模拟器Tag对齐:删除Tag11(操作模式),新增Tag24(切削时间)/Tag25(循环时间)/Tag26(加工状态),Tag数从10个增至12个

main
haoliang 1 month ago
parent fa1adc826a
commit 121434ec2a

@ -358,9 +358,11 @@ namespace CncSimulator.Core
new { id = "Tag7", desc = "当前加工程序内容", value = "" }, new { id = "Tag7", desc = "当前加工程序内容", value = "" },
new { id = "Tag8", desc = "当前加工零件数", value = "0.00000" }, new { id = "Tag8", desc = "当前加工零件数", value = "0.00000" },
new { id = "Tag9", desc = "运行状态", value = "0.00000" }, new { id = "Tag9", desc = "运行状态", value = "0.00000" },
new { id = "Tag11", desc = "操作模式", value = "0.00000" },
new { id = "Tag22", desc = "开机时间", value = "0.00000" }, new { id = "Tag22", desc = "开机时间", value = "0.00000" },
new { id = "Tag23", desc = "运行时间", value = "0.00000" } new { id = "Tag23", desc = "运行时间", value = "0.00000" },
new { id = "Tag24", desc = "切削时间", value = "0.00000" },
new { id = "Tag25", desc = "循环时间", value = "0.00000" },
new { id = "Tag26", desc = "加工状态", value = "" }
}; };
foreach (var t in offlineTags) foreach (var t in offlineTags)

@ -37,6 +37,8 @@ namespace CncSimulator.Device
OperateMode = 10, OperateMode = 10,
PowerOnTime = _rng.Next(20000000, 24000000), PowerOnTime = _rng.Next(20000000, 24000000),
RunTime = _rng.Next(15000, 20000), RunTime = _rng.Next(15000, 20000),
CuttingTime = _rng.Next(5000, 12000),
CycleTime = _rng.Next(3000, 8000),
ProgramContent = "", ProgramContent = "",
CurrentScenario = "idle", CurrentScenario = "idle",
ScenarioTick = 0, ScenarioTick = 0,
@ -133,6 +135,8 @@ namespace CncSimulator.Device
_state.OperateMode = 1; _state.OperateMode = 1;
_state.RunTime += interval; _state.RunTime += interval;
_state.PowerOnTime += interval; _state.PowerOnTime += interval;
_state.CuttingTime += interval;
_state.CycleTime += interval;
_state.ProgramContent = "<" + _state.ProgramName + ">\nG40G49G80\n( SIMULATOR )"; _state.ProgramContent = "<" + _state.ProgramName + ">\nG40G49G80\n( SIMULATOR )";
break; break;

@ -44,6 +44,12 @@ namespace CncSimulator.Device
/// <summary>运行累计时间(秒)</summary> /// <summary>运行累计时间(秒)</summary>
public decimal RunTime { get; set; } = 0; public decimal RunTime { get; set; } = 0;
/// <summary>切削累计时间(秒)</summary>
public decimal CuttingTime { get; set; } = 0;
/// <summary>循环累计时间(秒)</summary>
public decimal CycleTime { get; set; } = 0;
/// <summary>加工程序内容片段</summary> /// <summary>加工程序内容片段</summary>
public string ProgramContent { get; set; } = ""; public string ProgramContent { get; set; } = "";

@ -6,7 +6,7 @@ namespace CncSimulator.Generator
{ {
/// <summary> /// <summary>
/// FANUC品牌JSON数据生成器。 /// FANUC品牌JSON数据生成器。
/// 根据设备状态生成10个Tag的FANUC格式JSON与实际FANUC采集数据结构一致。 /// 根据设备状态生成12个Tag的FANUC格式JSON与实际FANUC采集数据结构一致。
/// </summary> /// </summary>
public class FanucDataGenerator : IBrandGenerator public class FanucDataGenerator : IBrandGenerator
{ {
@ -27,7 +27,7 @@ namespace CncSimulator.Generator
return device; return device;
} }
/// <summary>生成10个Tag的JArray</summary> /// <summary>生成12个Tag的JArray</summary>
private JArray GenerateTags(DeviceState state) private JArray GenerateTags(DeviceState state)
{ {
var tags = new JArray(); var tags = new JArray();
@ -68,7 +68,7 @@ namespace CncSimulator.Generator
}); });
} }
// 严格按实际FANUC采集数据的10个Tag生成 // 严格按实际FANUC采集数据的12个Tag生成
AddNumericTag("_io_status", "设备状态", state.DeviceStatus); AddNumericTag("_io_status", "设备状态", state.DeviceStatus);
AddNumericTag("Tag1", "加工零件总数", state.TotalPartCount); AddNumericTag("Tag1", "加工零件总数", state.TotalPartCount);
AddStringTag("Tag5", "执行的NC主程序名", state.ProgramName); AddStringTag("Tag5", "执行的NC主程序名", state.ProgramName);
@ -79,11 +79,20 @@ namespace CncSimulator.Generator
: state.ProgramContent); : state.ProgramContent);
AddNumericTag("Tag8", "当前加工零件数", state.PartCount); AddNumericTag("Tag8", "当前加工零件数", state.PartCount);
AddNumericTag("Tag9", "运行状态", state.RunStatus); AddNumericTag("Tag9", "运行状态", state.RunStatus);
AddNumericTag("Tag11", "操作模式", state.OperateMode);
AddNumericTag("Tag22", "开机时间", state.PowerOnTime); AddNumericTag("Tag22", "开机时间", state.PowerOnTime);
AddNumericTag("Tag23", "运行时间", state.RunTime); AddNumericTag("Tag23", "运行时间", state.RunTime);
AddNumericTag("Tag24", "切削时间", state.CuttingTime);
AddNumericTag("Tag25", "循环时间", state.CycleTime);
AddStringTag("Tag26", "加工状态", GetRandomMachiningStatus());
return tags; return tags;
} }
/// <summary>随机返回加工状态: G01/G02/G03</summary>
private string GetRandomMachiningStatus()
{
string[] statuses = { "G01", "G02", "G03" };
return statuses[_rng.Next(statuses.Length)];
}
} }
} }

Loading…
Cancel
Save