示例#1
0
        public override async Task EnableVariableHistoryChangedEvents(params ObjectRef[] idsOfEnabledTreeRoots)
        {
            JObject request = MakeSessionRequest();

            request["idsOfEnabledTreeRoots"] = new JRaw(StdJson.ValueToString(idsOfEnabledTreeRoots));
            await PostJObject("EnableVariableHistoryChangedEvents", request);
        }
示例#2
0
        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);
            }
        }
示例#3
0
        public override async Task EnableAlarmsAndEvents(Severity minSeverity = Severity.Info)
        {
            JObject request = MakeSessionRequest();

            request["minSeverity"] = new JRaw(StdJson.ValueToString(minSeverity));
            await PostJObject("EnableAlarmsAndEvents", request);
        }
示例#4
0
        public override async Task <ObjectInfo> GetRootObject(string moduleID)
        {
            JObject request = MakeSessionRequest();

            request["moduleID"] = new JRaw(StdJson.ValueToString(moduleID));
            return(await Post <ObjectInfo>("GetRootObject", request));
        }
示例#5
0
        public override async Task HistorianDeleteAllVariablesOfObjectTree(ObjectRef objectID)
        {
            JObject request = MakeSessionRequest();

            request["objectID"] = new JRaw(StdJson.ValueToString(objectID));
            await PostJObject("HistorianDeleteAllVariablesOfObjectTree", request);
        }
示例#6
0
        public override async Task <ObjectValue> GetParentOfObject(ObjectRef objectID)
        {
            JObject request = MakeSessionRequest();

            request["objectID"] = new JRaw(StdJson.ValueToString(objectID));
            return(await Post <ObjectValue>("GetParentOfObject", request));
        }
示例#7
0
        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));
        }
示例#8
0
        public override async Task EnableConfigChangedEvents(params ObjectRef[] objects)
        {
            JObject request = MakeSessionRequest();

            request["objects"] = new JRaw(StdJson.ValueToString(objects));
            await PostJObject("EnableConfigChangedEvents", request);
        }
示例#9
0
        public override async Task <VariableValue[]> ReadAllVariablesOfObjectTree(ObjectRef objectID)
        {
            JObject request = MakeSessionRequest();

            request["objectID"] = new JRaw(StdJson.ValueToString(objectID));
            return(await Post <VariableValue[]>("ReadAllVariablesOfObjectTree", request));
        }
示例#10
0
        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);
            }
        }
示例#11
0
        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));
        }
示例#12
0
        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));
        }
示例#13
0
        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);
        }
示例#14
0
        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));
        }
示例#15
0
        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));
        }
示例#16
0
        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));
        }
示例#17
0
        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));
        }
示例#18
0
        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));
        }
示例#19
0
        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);
            }
        }
示例#20
0
 public static DataValue FromDecimalArray(decimal[] v) => new DataValue(StdJson.ValueToString(v));
示例#21
0
 public static DataValue FromDoubleArray(double[] v) => new DataValue(StdJson.ValueToString(v));
示例#22
0
 public static DataValue FromFloatArray(float[] v) => new DataValue(StdJson.ValueToString(v));
示例#23
0
 public static DataValue FromUShortArray(ushort[] v) => new DataValue(StdJson.ValueToString(v));
示例#24
0
 public static DataValue FromShort(short v) => new DataValue(StdJson.ValueToString(v));
示例#25
0
 public static DataValue FromInt(int v) => new DataValue(StdJson.ValueToString(v));
示例#26
0
 public static DataValue FromLong(long v) => new DataValue(StdJson.ValueToString(v));
示例#27
0
 public static DataValue FromULongArray(ulong[] v) => new DataValue(StdJson.ValueToString(v));
示例#28
0
 public static DataValue FromByte(byte v) => new DataValue(StdJson.ValueToString(v));
示例#29
0
 public static DataValue FromUIntArray(uint[] v) => new DataValue(StdJson.ValueToString(v));
示例#30
0
 public static DataValue FromSByteArray(sbyte[] v) => new DataValue(StdJson.ValueToString(v));