public override async Task <VariableValue[]> ReadAllVariablesOfObjectTree(ObjectRef objectID) { JObject request = MakeSessionRequest(); request["objectID"] = new JRaw(StdJson.ValueToString(objectID)); return(await Post <VariableValue[]>("ReadAllVariablesOfObjectTree", request)); }
/// <summary> /// Writes a new value to a variable waiting for the receiving module to complete the write request. /// An exception is thrown when the variable does not exist. Check the return value to verify whether /// the receiving module successfully processed the write request. /// </summary> /// <param name="objectID">The object containing the variable</param> /// <param name="variableName">The name of the variable to write</param> /// <param name="value">The new value</param> /// <param name="timeout">Optional timeout</param> public virtual async Task <Result> WriteVariableSync(ObjectRef objectID, string variableName, VTQ value, Duration?timeout = null) { WriteResult res = await WriteVariablesSync(new VariableValues { VariableValue.Make(objectID, variableName, value) }, timeout); if (res.Failed()) { return(Result.Failure(res.FailedVariables ![0].Error));
public override async Task <ObjectValue> GetParentOfObject(ObjectRef objectID) { JObject request = MakeSessionRequest(); request["objectID"] = new JRaw(StdJson.ValueToString(objectID)); return(await Post <ObjectValue>("GetParentOfObject", request)); }
public override async Task HistorianDeleteAllVariablesOfObjectTree(ObjectRef objectID) { var request = MakeSessionRequest <HistorianDeleteAllVariablesOfObjectTreeReq>(); request.ObjectID = objectID; await PostVoid(request); }
public override async Task <ObjectValue> GetParentOfObject(ObjectRef objectID) { var request = MakeSessionRequest <GetParentOfObjectReq>(); request.ObjectID = objectID; return(await Post <ObjectValue>(request)); }
public override async Task HistorianDeleteAllVariablesOfObjectTree(ObjectRef objectID) { JObject request = MakeSessionRequest(); request["objectID"] = new JRaw(StdJson.ValueToString(objectID)); await PostJObject("HistorianDeleteAllVariablesOfObjectTree", request); }
public override async Task <VariableValues> ReadAllVariablesOfObjectTree(ObjectRef objectID) { var request = MakeSessionRequest <ReadAllVariablesOfObjectTreeReq>(); request.ObjectID = objectID; return(await Post <VariableValues>(request, binaryDeserializer : BinSeri.VariableValue_Serializer.Deserialize)); }
public MemberRef(ObjectRef obj, string memberName) { if (memberName == null) { throw new ArgumentNullException(nameof(memberName), nameof(memberName) + " may not be null"); } Object = obj; Name = memberName; }
public VariableRef(ObjectRef obj, string variableName) { if (variableName == null) { throw new ArgumentNullException(nameof(variableName), nameof(variableName) + " may not be null"); } Object = obj; Name = variableName; }
public ObjectInfo(ObjectRef id, string name, string className, MemberRefIdx?parent = null, Variable[]?variables = null, LocationRef?location = null) { ID = id; Name = name ?? throw new ArgumentNullException(nameof(name), nameof(name) + " may not be null"); ClassName = className ?? throw new ArgumentNullException(nameof(className), nameof(className) + " may not be null"); Variables = variables ?? Array.Empty <Variable>(); Parent = parent; Location = location; }
public override object?ReadJson(JsonReader reader, Type objectType, object?existingValue, JsonSerializer serializer) { string?str = (string?)reader.Value; if (str == null) { return(null); } return(ObjectRef.FromEncodedString(str)); }
internal ObjectRef?GetObjectParent(ObjectRef o) { if (!mapObjects.ContainsKey(o)) { return(null); } ObjectInfo info = mapObjects[o]; if (info.Parent.HasValue) { return(info.Parent.Value.Object); } return(null); }
public void SetAllObjects(ObjectInfo[] allObjs) { allObjects = new List <ObjectInfo>(allObjs); mapObjects.Clear(); objectsWithChildren.Clear(); foreach (ObjectInfo obj in allObjects) { mapObjects[obj.ID] = obj; if (obj.Parent.HasValue) { ObjectRef parent = obj.Parent.Value.Object; objectsWithChildren.Add(parent); } } variables.Sync(allObjects); }
/// <summary> /// Writes a new value to a variable without waiting for the receiving module to complete the write request. /// An exception is thrown when the variable does not exist. /// </summary> /// <param name="objectID">The object containing the variable</param> /// <param name="variableName">The name of the variable to write</param> /// <param name="value">The new value</param> public virtual async Task WriteVariable(ObjectRef objectID, string variableName, VTQ value) { await WriteVariables(new VariableValues { VariableValue.Make(objectID, variableName, value) }); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { string str = (string)reader.Value; return(ObjectRef.FromEncodedString(str)); }
/// <summary> /// Reads the current value of a variable directly from the containing module. /// Throws an exception if the variable does not exist or the timeout expires. /// </summary> /// <param name="objectID">The object containing the variable</param> /// <param name="variableName">The name of the variable to read</param> /// <param name="timeout">Optional timeout</param> public virtual Task <VTQ> ReadVariableSync(ObjectRef objectID, string variableName, Duration?timeout = null) { return(ReadVariableSync(VariableRef.Make(objectID, variableName), timeout)); }
/// <summary> /// Reads the current value of all variables of all objects in the tree of objects defined by the given object reference. /// </summary> /// <param name="objectID">The object defining the root of the object tree</param> public abstract Task <VariableValues> ReadAllVariablesOfObjectTree(ObjectRef objectID);
/// <summary> /// Returns the entire object value of the parent object for a given object id. /// </summary> /// <param name="objectID">The id of the object</param> public abstract Task <ObjectValue> GetParentOfObject(ObjectRef objectID);
/// <summary> /// Reads the current value of a variable from the Mediator cache. /// Throws an exception if the variable does not exist. /// </summary> /// <param name="objectID">The object containing the variable</param> /// <param name="variableName">The name of the variable to read</param> /// <returns></returns> public virtual async Task <VTQ> ReadVariable(ObjectRef objectID, string variableName) { VTQs tmp = await ReadVariables(new VariableRefs { VariableRef.Make(objectID, variableName) }); return(tmp[0]); }
/// <summary> /// Returns an entire object by id. /// </summary> /// <param name="objectID">The id of the object to return</param> public virtual async Task <ObjectValue> GetObjectValueByID(ObjectRef objectID) { ObjectValues res = await GetObjectValuesByID(objectID); return(res[0]); }
/// <summary> /// Returns the value of an object member. /// </summary> /// <param name="objectID">The id of the object</param> /// <param name="memberName">The name of the member to return</param> public virtual async Task <MemberValue> GetMemberValue(ObjectRef objectID, string memberName) { MemberValues values = await GetMemberValues(new MemberRef[] { new MemberRef(objectID, memberName) }); return(values[0]); }
public static MemberValue Make(ObjectRef obj, string memberName, DataValue value) { return(new MemberValue(MemberRef.Make(obj, memberName), value)); }
private void ReadModuleVariables(XmlReader reader) { map.Clear(); if (reader.IsEmptyElement) { return; } ObjectRef currentObj = new ObjectRef(); string var_Name = ""; string var_Time = ""; string var_Quality = ""; bool inVar = false; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: inVar = false; switch (reader.Name) { case "Obj": currentObj = ObjectRef.Make(moduleID, reader.GetAttribute("id")); break; case "Var": var_Name = reader.GetAttribute("name"); var_Time = reader.GetAttribute("time"); var_Quality = reader.GetAttribute("quality"); inVar = true; break; } break; case XmlNodeType.Text: if (inVar) { var t = TimestampFromString(var_Time); var q = QualityFromString(var_Quality); var v = DataValue.FromJSON(reader.Value); var varRef = new VariableRef(currentObj, var_Name); map[varRef] = new VTQ(t, q, v); inVar = false; } break; case XmlNodeType.EndElement: inVar = false; if (reader.Name == "Module") { return; } break; } } }
public static MemberValue Make(string moduleID, string localObjectID, string memberName, DataValue value) { return(new MemberValue(MemberRef.Make(ObjectRef.Make(moduleID, localObjectID), memberName), value)); }
public static AddArrayElement Make(ObjectRef obj, string arrayMemberName, DataValue valueToAdd) { return(new AddArrayElement(MemberRef.Make(obj, arrayMemberName), valueToAdd)); }
public static AddArrayElement Make(string moduleID, string localObjectID, string arrayMemberName, DataValue valueToAdd) { return(new AddArrayElement(MemberRef.Make(ObjectRef.Make(moduleID, localObjectID), arrayMemberName), valueToAdd)); }
/// <summary> /// Returns an object by id (ObjectRef) /// </summary> /// <param name="objectID">The object id</param> public virtual async Task <ObjectInfo> GetObjectByID(ObjectRef objectID) { ObjectInfos objects = await GetObjectsByID(objectID); return(objects[0]); }
public static string ValueToString(ObjectRef value) => JsonConvert.ToString(value.ToEncodedString());
/// <summary> /// Returns all objects that are direct children of a specific object /// </summary> /// <param name="objectID">The id of the parent object</param> public virtual async Task <ObjectInfos> GetChildrenOfObject(ObjectRef objectID) { return(await GetChildrenOfObjects(objectID)); }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { ObjectRef ts = (ObjectRef)value; writer.WriteValue(ts.ToEncodedString()); }