private OpcVariableValue WriteMatlabVariableValueCallback(OpcWriteVariableValueContext context, OpcVariableValue value) { try { string variableName = context.Node.Name.SymbolicName; string variableValueAsString = value.Value.ToString(); double n; bool isNumeric = double.TryParse(variableValueAsString, out n); if (isNumeric) { _matlabService.Matlab.Execute(string.Format("{0} = {1}", variableName, variableValueAsString)); } else { _matlabService.Matlab.Execute(string.Format("{0} = '{1}'", variableName, variableValueAsString)); } UpdateVariables(); } catch (Exception ex) { Console.WriteLine("Something went wrong while modifying variable:{0}{1}{0}{2}", Environment.NewLine, ex.Message, ex.StackTrace); } return(value); }
protected override OpcVariableValue <object> WriteVariableValueCore( OpcWriteVariableValueContext context, OpcVariableValue <object> value) { if (!this.manager.CanWrite(this, context.Identity)) { throw new OpcException(OpcStatusCode.BadNotWritable); } return(base.WriteVariableValueCore(context, value)); }
private static OpcVariableValue <object> WriteDataProcessed( OpcWriteVariableValueContext context, OpcVariableValue <object> value) { if (value.Value is bool condition && condition) { dataProcessed.Release(); } // Reset DataProcessed return(new OpcVariableValue <object>(false)); }
private OpcVariableValue <object> HandleWriteVariableValue( OpcWriteVariableValueContext context, OpcVariableValue <object> value) { if (context.Identity != null) { Console.WriteLine( "\t[{0} (SID='{1}')] Write: {2}.Value = '{3}'", context.Identity?.DisplayName, context.SessionId?.Value, context.Node.Name, value.Value); } return(value); }
private OpcVariableValue <object> HandleWriteVariableValue( OpcWriteVariableValueContext context, OpcVariableValue <object> value) { // A client may not pass a timestamp associated with a new value or may use the same // timestamp as already used by the variable node. // // Upon we want to enforce that every value written to the node uses its own timestamp // we update the variable value with the current time to assure that every write // results into a new entry in the history of the node. if (value.Timestamp == null || value.Timestamp == context.Node.Timestamp) { value = new OpcVariableValue <object>(value.Value, DateTime.UtcNow, value.Status); } return(value); }
private OpcVariableValue WriteVariableValueCallback(OpcWriteVariableValueContext context, OpcVariableValue value) { UpdateVariables(); return(value); }