public override async Task EnableVariableHistoryChangedEvents(params ObjectRef[] idsOfEnabledTreeRoots) { JObject request = MakeSessionRequest(); request["idsOfEnabledTreeRoots"] = new JRaw(StdJson.ValueToString(idsOfEnabledTreeRoots)); await PostJObject("EnableVariableHistoryChangedEvents", request); }
public override async Task <VTQ[]> ReadVariablesSync(VariableRef[] variables, Duration?timeout = null) { if (variables == null) { throw new ArgumentNullException(nameof(variables)); } JObject request = MakeSessionRequest(); request["variables"] = new JRaw(StdJson.ObjectToString(variables)); if (timeout.HasValue) { request["timeout"] = new JRaw(StdJson.ValueToString(timeout.Value)); } Task <VTQ[]> task = Post <VTQ[]>("ReadVariablesSync", request); if (timeout.HasValue) { if (task == await Task.WhenAny(task, Task.Delay(timeout.Value.ToTimeSpan()))) { return(await task); } else { throw new Exception("Timeout"); } } else { return(await task); } }
public override async Task EnableAlarmsAndEvents(Severity minSeverity = Severity.Info) { JObject request = MakeSessionRequest(); request["minSeverity"] = new JRaw(StdJson.ValueToString(minSeverity)); await PostJObject("EnableAlarmsAndEvents", request); }
public override async Task <ObjectInfo> GetRootObject(string moduleID) { JObject request = MakeSessionRequest(); request["moduleID"] = new JRaw(StdJson.ValueToString(moduleID)); return(await Post <ObjectInfo>("GetRootObject", 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 <ObjectValue> GetParentOfObject(ObjectRef objectID) { JObject request = MakeSessionRequest(); request["objectID"] = new JRaw(StdJson.ValueToString(objectID)); return(await Post <ObjectValue>("GetParentOfObject", request)); }
public override async Task <ObjectValue[]> GetObjectValuesByID(params ObjectRef[] objectIDs) { JObject request = MakeSessionRequest(); request["objectIDs"] = new JRaw(StdJson.ValueToString(objectIDs)); return(await Post <ObjectValue[]>("GetObjectValuesByID", request)); }
public override async Task EnableConfigChangedEvents(params ObjectRef[] objects) { JObject request = MakeSessionRequest(); request["objects"] = new JRaw(StdJson.ValueToString(objects)); await PostJObject("EnableConfigChangedEvents", request); }
public override async Task <VariableValue[]> ReadAllVariablesOfObjectTree(ObjectRef objectID) { JObject request = MakeSessionRequest(); request["objectID"] = new JRaw(StdJson.ValueToString(objectID)); return(await Post <VariableValue[]>("ReadAllVariablesOfObjectTree", request)); }
public override async Task <WriteResult> WriteVariablesSync(VariableValue[] values, Duration?timeout = null) { JObject request = MakeSessionRequest(); request["values"] = new JRaw(StdJson.ObjectToString(values)); if (timeout.HasValue) { request["timeout"] = new JRaw(StdJson.ValueToString(timeout.Value)); } Task <WriteResult> task = Post <WriteResult>("WriteVariablesSync", request); if (timeout.HasValue) { if (task == await Task.WhenAny(task, Task.Delay(timeout.Value.ToTimeSpan()))) { return(await task); } else { throw new Exception("Timeout"); } } else { return(await task); } }
public override async Task <ObjectInfo[]> GetAllObjectsOfType(string moduleID, string className) { JObject request = MakeSessionRequest(); request["moduleID"] = new JRaw(StdJson.ValueToString(moduleID)); request["className"] = new JRaw(StdJson.ValueToString(className)); return(await Post <ObjectInfo[]>("GetAllObjectsOfType", request)); }
public override async Task <ObjectInfo[]> GetAllObjectsWithVariablesOfType(string moduleID, params DataType[] types) { JObject request = MakeSessionRequest(); request["moduleID"] = new JRaw(StdJson.ValueToString(moduleID)); request["types"] = new JRaw(StdJson.ValueToString(types.Cast <Enum>().ToArray())); return(await Post <ObjectInfo[]>("GetAllObjectsWithVariablesOfType", request)); }
public override async Task HistorianModify(VariableRef variable, ModifyMode mode, params VTQ[] data) { JObject request = MakeSessionRequest(); request["variable"] = new JRaw(StdJson.ObjectToString(variable)); request["data"] = new JRaw(StdJson.ObjectToString(data)); request["mode"] = new JRaw(StdJson.ValueToString(mode)); await PostJObject("HistorianModify", request); }
public override async Task <long> HistorianDeleteInterval(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive) { JObject request = MakeSessionRequest(); request["variable"] = new JRaw(StdJson.ObjectToString(variable)); request["startInclusive"] = new JRaw(StdJson.ValueToString(startInclusive)); request["endInclusive"] = new JRaw(StdJson.ValueToString(endInclusive)); return(await Post <long>("HistorianDeleteInterval", request)); }
public override async Task <VTTQ?> HistorianGetLatestTimestampDB(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive) { JObject request = MakeSessionRequest(); request["variable"] = new JRaw(StdJson.ObjectToString(variable)); request["startInclusive"] = new JRaw(StdJson.ValueToString(startInclusive)); request["endInclusive"] = new JRaw(StdJson.ValueToString(endInclusive)); return(await Post <VTTQ?>("HistorianGetLatestTimestampDB", request)); }
public override Task <BrowseResult> BrowseObjectMemberValues(MemberRef member, int?continueID = null) { JObject request = MakeSessionRequest(); request["member"] = new JRaw(StdJson.ObjectToString(member)); if (continueID.HasValue) { request["continueID"] = new JRaw(StdJson.ValueToString(continueID.Value)); } return(Post <BrowseResult>("BrowseObjectMemberValues", request)); }
public override async Task <MetaInfos> GetMetaInfos(string moduleID) { if (moduleID == null) { throw new ArgumentNullException(nameof(moduleID)); } JObject request = MakeSessionRequest(); request["moduleID"] = new JRaw(StdJson.ValueToString(moduleID)); return(await Post <MetaInfos>("GetMetaInfos", request)); }
public override async Task <VTTQ[]> HistorianReadRaw(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive, int maxValues, BoundingMethod bounding) { JObject request = MakeSessionRequest(); request["variable"] = new JRaw(StdJson.ObjectToString(variable)); request["startInclusive"] = new JRaw(StdJson.ValueToString(startInclusive)); request["endInclusive"] = new JRaw(StdJson.ValueToString(endInclusive)); request["maxValues"] = new JRaw(StdJson.ValueToString(maxValues)); request["bounding"] = new JRaw(StdJson.ValueToString(bounding)); return(await Post <VTTQ[]>("HistorianReadRaw", request)); }
protected async Task DoConnectAndLogin(string login, string password, bool isModule, string[] roles, EventListener listener) { var request = new JObject(); if (isModule) { request["moduleID"] = login; } else { request["login"] = login; request["roles"] = new JRaw(StdJson.ValueToString(roles)); } JObject json = await PostJObject("Login", request); string session = (string)json["session"]; string challenge = (string)json["challenge"]; if (string.IsNullOrEmpty(session) || string.IsNullOrEmpty(challenge)) { throw new ConnectivityException("Invalid response"); } long hash = Util.ClientDefs.strHash(password + challenge + password + session); request = new JObject(); request["session"] = session; request["hash"] = hash; json = await PostJObject("Authenticate", request); this.session = (string)json["session"]; if (listener != null) { eventManager = new EventManager(listener); await eventManager.StartWebSocket(this.session, wsUri, OnConnectionBroken); } }
public static DataValue FromDecimalArray(decimal[] v) => new DataValue(StdJson.ValueToString(v));
public static DataValue FromDoubleArray(double[] v) => new DataValue(StdJson.ValueToString(v));
public static DataValue FromFloatArray(float[] v) => new DataValue(StdJson.ValueToString(v));
public static DataValue FromUShortArray(ushort[] v) => new DataValue(StdJson.ValueToString(v));
public static DataValue FromShort(short v) => new DataValue(StdJson.ValueToString(v));
public static DataValue FromInt(int v) => new DataValue(StdJson.ValueToString(v));
public static DataValue FromLong(long v) => new DataValue(StdJson.ValueToString(v));
public static DataValue FromULongArray(ulong[] v) => new DataValue(StdJson.ValueToString(v));
public static DataValue FromByte(byte v) => new DataValue(StdJson.ValueToString(v));
public static DataValue FromUIntArray(uint[] v) => new DataValue(StdJson.ValueToString(v));
public static DataValue FromSByteArray(sbyte[] v) => new DataValue(StdJson.ValueToString(v));