feat(cli): native-alarm-source commands (template add/list/remove + instance set/clear)
This commit is contained in:
@@ -23,6 +23,7 @@ public static class TemplateCommands
|
||||
command.Add(BuildDelete(urlOption, formatOption, usernameOption, passwordOption));
|
||||
command.Add(BuildAttribute(urlOption, formatOption, usernameOption, passwordOption));
|
||||
command.Add(BuildAlarm(urlOption, formatOption, usernameOption, passwordOption));
|
||||
command.Add(BuildNativeAlarmSource(urlOption, formatOption, usernameOption, passwordOption));
|
||||
command.Add(BuildScript(urlOption, formatOption, usernameOption, passwordOption));
|
||||
command.Add(BuildComposition(urlOption, formatOption, usernameOption, passwordOption));
|
||||
|
||||
@@ -293,6 +294,73 @@ public static class TemplateCommands
|
||||
return group;
|
||||
}
|
||||
|
||||
private static Command BuildNativeAlarmSource(Option<string> urlOption, Option<string> formatOption, Option<string> usernameOption, Option<string> passwordOption)
|
||||
{
|
||||
var group = new Command("native-alarm-source")
|
||||
{
|
||||
Description = "Manage template native alarm source bindings (read-only mirror of OPC UA A&C / MxGateway alarms)"
|
||||
};
|
||||
|
||||
// add
|
||||
var templateIdOption = new Option<int>("--template-id") { Description = "Template ID", Required = true };
|
||||
var nameOption = new Option<string>("--name") { Description = "Source binding name", Required = true };
|
||||
var connectionOption = new Option<string>("--connection") { Description = "Alarm-capable data connection name", Required = true };
|
||||
var sourceRefOption = new Option<string>("--source-ref") { Description = "Source reference (OPC UA SourceNode nodeId, or MxAccess object/area)", Required = true };
|
||||
var filterOption = new Option<string?>("--filter") { Description = "Optional condition filter (null = mirror all conditions under the source)" };
|
||||
var descOption = new Option<string?>("--description") { Description = "Description" };
|
||||
var lockedOption = new Option<bool>("--locked") { Description = "Lock status" };
|
||||
lockedOption.DefaultValueFactory = _ => false;
|
||||
|
||||
var addCmd = new Command("add") { Description = "Add a native alarm source binding to a template" };
|
||||
addCmd.Add(templateIdOption);
|
||||
addCmd.Add(nameOption);
|
||||
addCmd.Add(connectionOption);
|
||||
addCmd.Add(sourceRefOption);
|
||||
addCmd.Add(filterOption);
|
||||
addCmd.Add(descOption);
|
||||
addCmd.Add(lockedOption);
|
||||
addCmd.SetAction(async (ParseResult result) =>
|
||||
{
|
||||
return await CommandHelpers.ExecuteCommandAsync(
|
||||
result, urlOption, formatOption, usernameOption, passwordOption,
|
||||
new AddTemplateNativeAlarmSourceCommand(
|
||||
result.GetValue(templateIdOption),
|
||||
result.GetValue(nameOption)!,
|
||||
result.GetValue(connectionOption)!,
|
||||
result.GetValue(sourceRefOption)!,
|
||||
result.GetValue(filterOption),
|
||||
result.GetValue(descOption),
|
||||
result.GetValue(lockedOption)));
|
||||
});
|
||||
group.Add(addCmd);
|
||||
|
||||
// list
|
||||
var listIdOption = new Option<int>("--template-id") { Description = "Template ID", Required = true };
|
||||
var listCmd = new Command("list") { Description = "List native alarm source bindings on a template" };
|
||||
listCmd.Add(listIdOption);
|
||||
listCmd.SetAction(async (ParseResult result) =>
|
||||
{
|
||||
return await CommandHelpers.ExecuteCommandAsync(
|
||||
result, urlOption, formatOption, usernameOption, passwordOption,
|
||||
new ListTemplateNativeAlarmSourcesCommand(result.GetValue(listIdOption)));
|
||||
});
|
||||
group.Add(listCmd);
|
||||
|
||||
// remove
|
||||
var removeIdOption = new Option<int>("--id") { Description = "Native alarm source ID", Required = true };
|
||||
var removeCmd = new Command("remove") { Description = "Remove a native alarm source binding from a template" };
|
||||
removeCmd.Add(removeIdOption);
|
||||
removeCmd.SetAction(async (ParseResult result) =>
|
||||
{
|
||||
return await CommandHelpers.ExecuteCommandAsync(
|
||||
result, urlOption, formatOption, usernameOption, passwordOption,
|
||||
new DeleteTemplateNativeAlarmSourceCommand(result.GetValue(removeIdOption)));
|
||||
});
|
||||
group.Add(removeCmd);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
private static Command BuildScript(Option<string> urlOption, Option<string> formatOption, Option<string> usernameOption, Option<string> passwordOption)
|
||||
{
|
||||
var group = new Command("script") { Description = "Manage template scripts" };
|
||||
|
||||
Reference in New Issue
Block a user