private ServiceResult OnStart(ISystemContext context, MethodState method, IList <object> inputArguments, IList <object> outputArguments) { // all arguments must be provided. if (inputArguments.Count < 2) { return(StatusCodes.BadArgumentsMissing); } // check the data type of the input arguments. uint?initialState = inputArguments[0] as uint?; uint?finalState = inputArguments[1] as uint?; if (initialState == null || finalState == null) { return(StatusCodes.BadTypeMismatch); } lock (_processLock) { // check if the process is running. if (_processTimer != null) { _processTimer.Dispose(); _processTimer = null; } // start the process. _state = initialState.Value; _finalState = finalState.Value; _processTimer = new Timer(OnUpdateProcess, null, 1000, 1000); // the calling function sets default values for all output arguments. // only need to update them here. outputArguments[0] = _state; outputArguments[1] = _finalState; } // signal update to state node. lock (ApplicationNodeManager.Lock) { _stateNode.Value = _state; _stateNode.ClearChangeMasks(ApplicationNodeManager.SystemContext, true); } TranslationInfo info = new TranslationInfo( "OnStart", "en-US", "The Confirm method was called."); AuditUpdateMethodEventState auditUpdateMethodEventState = new AuditUpdateMethodEventState(method); auditUpdateMethodEventState.Initialize( context, method, EventSeverity.Low, new LocalizedText(info), ServiceResult.IsGood(StatusCodes.Good), DateTime.UtcNow); auditUpdateMethodEventState.SourceName.Value = "Attribute/Call"; auditUpdateMethodEventState.MethodId = new PropertyState <NodeId>(method) { Value = method.NodeId }; auditUpdateMethodEventState.InputArguments = new PropertyState <object[]>(method) { Value = new object[] { inputArguments } }; auditUpdateMethodEventState.SetChildValue(context, BrowseNames.InputArguments, inputArguments.ToArray(), true); bool valid = auditUpdateMethodEventState.Validate(context); if (valid) { ApplicationNodeManager.Server.ReportEvent(auditUpdateMethodEventState); } return(ServiceResult.Good); }
private ServiceResult AddApplication(ISystemContext context, MethodState method, IList <object> inputArguments, IList <object> outputArguments) { if (inputArguments.Count != 1) { return(StatusCodes.BadArgumentsMissing); } // check the data type of the input arguments. string value = inputArguments[0] as string; if (value == null) { return(StatusCodes.BadTypeMismatch); } if (_applications == null) { _applications = new List <string>(); } _applications.Add(value); if (_processor == null) { _processor = new Processor(); _processor.Name = "Turbo"; _processor.MinSpeed = 0; _processor.MaxSpeed = 0; } _processor.MinSpeed = 1; _processor.MaxSpeed += 1; //Could not encode outgoing outputArguments[0] = _applications.ToArray(); outputArguments[1] = _processor; //Report TranslationInfo info = new TranslationInfo( "AddApplication", "en-US", "The Confirm method was called."); AuditUpdateMethodEventState auditUpdateMethodEventState = new AuditUpdateMethodEventState(method); auditUpdateMethodEventState.Initialize( context, method, EventSeverity.Low, new LocalizedText(info), ServiceResult.IsGood(StatusCodes.Good), DateTime.UtcNow); auditUpdateMethodEventState.SourceName.Value = "Attribute/Call"; auditUpdateMethodEventState.MethodId = new PropertyState <NodeId>(method) { Value = method.NodeId }; auditUpdateMethodEventState.InputArguments = new PropertyState <object[]>(method) { Value = new object[] { inputArguments } }; auditUpdateMethodEventState.SetChildValue(context, BrowseNames.InputArguments, inputArguments.ToArray(), true); bool valid = auditUpdateMethodEventState.Validate(context); if (valid) { ApplicationNodeManager.Server.ReportEvent(auditUpdateMethodEventState); } return(ServiceResult.Good); }