/// <summary> /// Called by other modules or clients to invoke a module specific method using <see cref="Connection.CallMethod(string, string, NamedValue[])"/>. /// Use the Result<DataValue> return value to indicate failure or return the result of the method call, if any. /// Any exception is considered an error and leads to module restart. /// </summary> /// <param name="origin">Information about the originator/initiator of this method call</param> /// <param name="methodName">The name of the method call</param> /// <param name="parameters">The parameters for method call</param> public virtual Task <Result <DataValue> > OnMethodCall(Origin origin, string methodName, NamedValue[] parameters) { return(Task.FromResult(Result <DataValue> .Failure("Method not implemented: " + methodName))); }
/// <summary> /// Called by other modules or clients to change the module configuration. /// For deleting an object or (optional) member, Value.IsEmpty will be true. /// To indicate an attempt for an invalid configuration change, use the Result return value. /// Any exception is considered an error and leads to module restart. /// </summary> /// <param name="origin">Information about the originator/initiator of this update</param> /// <param name="updateOrDeleteObjects">The objects to change or delete</param> /// <param name="updateOrDeleteMembers">The members to change or delete</param> /// <param name="addArrayElements">The new elements to add to an array member</param> public virtual Task <Result> UpdateConfig(Origin origin, ObjectValue[]?updateOrDeleteObjects, MemberValue[]?updateOrDeleteMembers, AddArrayElement[]?addArrayElements) { return(Task.FromResult(Result.Failure("UpdateConfig not implemented by module"))); }
/// <summary> /// Called by <see cref="Connection.WriteVariables"/> and <see cref="Connection.WriteVariablesSync"/> to update the /// value of specific variables. If variables can not be written successfully, use the WriteResult return value /// to indicate which variable writes failed. /// Any exception is considered an error and leads to module restart. /// </summary> /// <param name="origin">Information about the originator/initiator of this write request</param> /// <param name="values">The variable values to write</param> /// <param name="timeout">Optional timeout</param> public virtual Task <WriteResult> WriteVariables(Origin origin, VariableValue[] values, Duration?timeout) { var errs = values.Select(v => new VariableError(v.Variable, "WriteVariables not implemented by module")).ToArray(); return(Task.FromResult(WriteResult.Failure(errs))); }