コード例 #1
0
ファイル: Connection.cs プロジェクト: nsuchold/Mediator.Net
 public HistoryChange(VariableRef variable, Timestamp start, Timestamp end, HistoryChangeType changeType)
 {
     Variable    = variable;
     ChangeStart = start;
     ChangeEnd   = end;
     ChangeType  = changeType;
 }
コード例 #2
0
 public WI_GetLatestTimestampDb(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive, TaskCompletionSource <VTTQ?> promise)
 {
     Variable       = variable;
     StartInclusive = startInclusive;
     EndInclusive   = endInclusive;
     Promise        = promise;
 }
コード例 #3
0
        public void Sync(IList <ObjectInfo> allObjects)
        {
            var validVarRefs = new HashSet <VariableRef>();
            var tEmpty       = Timestamp.Empty;

            foreach (ObjectInfo obj in allObjects)
            {
                if (obj.Variables == null || obj.Variables.Length == 0)
                {
                    continue;
                }
                foreach (Variable v in obj.Variables)
                {
                    VariableRef vref = new VariableRef(obj.ID, v.Name);
                    validVarRefs.Add(vref);
                    if (!map.ContainsKey(vref))
                    {
                        map[vref] = new VTQ(tEmpty, Quality.Bad, v.DefaultValue);
                    }
                }
            }

            foreach (var entry in map)
            {
                VariableRef vref = entry.Key;
                if (!validVarRefs.Contains(vref))
                {
                    validVarRefs.Remove(vref);
                }
            }

            this.allObjects = allObjects;
        }
コード例 #4
0
 public WI_DeleteInterval(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive, TaskCompletionSource <long> promise)
 {
     Variable       = variable;
     StartInclusive = startInclusive;
     EndInclusive   = endInclusive;
     Promise        = promise;
 }
コード例 #5
0
 public WI_Modify(VariableRef variable, Variable varDesc, VTQ[] data, ModifyMode mode, TaskCompletionSource <bool> promise)
 {
     Variable = variable;
     VarDesc  = varDesc;
     Data     = data;
     Mode     = mode;
     Promise  = promise;
 }
コード例 #6
0
 public WI_Count(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive, QualityFilter filter, TaskCompletionSource <long> promise)
 {
     Variable       = variable;
     StartInclusive = startInclusive;
     EndInclusive   = endInclusive;
     Filter         = filter;
     Promise        = promise;
 }
コード例 #7
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);
        }
コード例 #8
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));
        }
コード例 #9
0
 public VTQ GetVarValue(VariableRef varRef)
 {
     try {
         return(map[varRef]);
     }
     catch (Exception) {
         throw new Exception($"No value found for variable reference '{varRef}'.");
     }
 }
コード例 #10
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));
        }
コード例 #11
0
        public override async Task <VTTQ?> HistorianGetLatestTimestampDB(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive)
        {
            var request = MakeSessionRequest <HistorianGetLatestTimestampDBReq>();

            request.Variable       = variable;
            request.StartInclusive = startInclusive;
            request.EndInclusive   = endInclusive;
            return(await Post <VTTQ?>(request));
        }
コード例 #12
0
 private Channel?GetChannelOrNull(VariableRef v)
 {
     try {
         return(GetChannelOrThrow(v));
     }
     catch (Exception) {
         return(null);
     }
 }
コード例 #13
0
        public override async Task <long> HistorianDeleteInterval(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive)
        {
            var request = MakeSessionRequest <HistorianDeleteIntervalReq>();

            request.Variable       = variable;
            request.StartInclusive = startInclusive;
            request.EndInclusive   = endInclusive;
            return(await Post <long>(request));
        }
コード例 #14
0
        public Task <long> DeleteInterval(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive)
        {
            var promise = new TaskCompletionSource <long>();

            if (CheckPrecondition(promise))
            {
                queue.Post(new WI_DeleteInterval(variable, startInclusive, endInclusive, promise));
            }
            return(promise.Task);
        }
コード例 #15
0
        public Task <long> Count(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive, QualityFilter filter)
        {
            var promise = new TaskCompletionSource <long>();

            if (CheckPrecondition(promise))
            {
                queue.Post(new WI_Count(variable, startInclusive, endInclusive, filter, promise));
            }
            return(promise.Task);
        }
コード例 #16
0
 public WI_ReadRaw(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive, int maxValues, BoundingMethod bounding, QualityFilter filter, TaskCompletionSource <List <VTTQ> > promise)
 {
     Variable       = variable;
     StartInclusive = startInclusive;
     EndInclusive   = endInclusive;
     MaxValues      = maxValues;
     Bounding       = bounding;
     Filter         = filter;
     Promise        = promise;
 }
コード例 #17
0
        public Task <List <VTTQ> > ReadRaw(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive, int maxValues, BoundingMethod bounding, QualityFilter filter)
        {
            var promise = new TaskCompletionSource <List <VTTQ> >();

            if (CheckPrecondition(promise))
            {
                queue.Post(new WI_ReadRaw(variable, startInclusive, endInclusive, maxValues, bounding, filter, promise));
            }
            return(promise.Task);
        }
コード例 #18
0
        public Task Modify(VariableRef variable, Variable varDesc, VTQ[] data, ModifyMode mode)
        {
            var promise = new TaskCompletionSource <bool>();

            if (CheckPrecondition(promise))
            {
                queue.Post(new WI_Modify(variable, varDesc, data, mode, promise));
            }
            return(promise.Task);
        }
コード例 #19
0
        public Task <VTTQ?> GetLatestTimestampDb(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive)
        {
            var promise = new TaskCompletionSource <VTTQ?>();

            if (CheckPrecondition(promise))
            {
                queue.Post(new WI_GetLatestTimestampDb(variable, startInclusive, endInclusive, promise));
            }
            return(promise.Task);
        }
コード例 #20
0
        private Variable CheckExistingVariable(VariableRef variable)
        {
            Variable?varDesc = fVarResolver(variable);

            if (varDesc != null)
            {
                return(varDesc);
            }
            throw new Exception("Undefined variable: " + variable.ToString());
        }
コード例 #21
0
        public override async Task <long> HistorianCount(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive, QualityFilter filter = QualityFilter.ExcludeNone)
        {
            var request = MakeSessionRequest <HistorianCountReq>();

            request.Variable       = variable;
            request.StartInclusive = startInclusive;
            request.EndInclusive   = endInclusive;
            request.Filter         = filter;
            return(await Post <long>(request));
        }
コード例 #22
0
        public Task Delete(VariableRef variable)
        {
            var promise = new TaskCompletionSource <bool>();

            if (CheckPrecondition(promise))
            {
                queue.Post(new WI_Delete(variable, promise));
            }
            return(promise.Task);
        }
コード例 #23
0
        private Variable?GetVariableDescription(VariableRef varRef)
        {
            string      moduleID = varRef.Object.ModuleID;
            ModuleState module   = modules.FirstOrDefault(m => m.ID == moduleID);

            if (module == null)
            {
                return(null);
            }
            return(module.GetVarDescription(varRef));
        }
コード例 #24
0
        public async Task <long> HistorianCount(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive, QualityFilter filter)
        {
            HistoryDBWorker?worker = WorkerByVarRef(variable);

            if (worker == null)
            {
                throw new Exception("Failed to find DB worker for variable " + variable);
            }
            CheckExistingVariable(variable);
            return(await worker.Count(variable, startInclusive, endInclusive, filter));
        }
コード例 #25
0
        public async Task <List <VTTQ> > HistorianReadRaw(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive, int maxValues, BoundingMethod bounding, QualityFilter filter)
        {
            HistoryDBWorker?worker = WorkerByVarRef(variable);

            if (worker == null)
            {
                throw new Exception("Failed to find DB worker for variable " + variable);
            }
            CheckExistingVariable(variable);
            return(await worker.ReadRaw(variable, startInclusive, endInclusive, maxValues, bounding, filter));
        }
コード例 #26
0
 public void ValidateVariableValuesOrThrow(IList <VariableValue> values)
 {
     foreach (VariableValue value in values)
     {
         VariableRef varRef = value.Variable;
         if (!map.ContainsKey(varRef))
         {
             throw new Exception("Invalid variable reference: " + varRef.ToString());
         }
     }
 }
コード例 #27
0
 public Variable?GetVarDescription(VariableRef varRef)
 {
     try {
         string     varName = varRef.Name;
         ObjectInfo objInfo = mapObjects[varRef.Object];
         return(objInfo.Variables.First(v => v.Name == varName));
     }
     catch (Exception) {
         return(null);
     }
 }
コード例 #28
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));
        }
コード例 #29
0
        private Channel GetOrCreateChannelOrThrow(VariableRef v, Variable varDesc)
        {
            if (db.ExistsChannel(v.Object.LocalObjectID, v.Name))
            {
                return(GetChannelOrThrow(v));
            }

            Channel res = db.CreateChannel(new ChannelInfo(v.Object.LocalObjectID, v.Name, varDesc.Type));

            mapChannels[v] = res;
            return(res);
        }
コード例 #30
0
        public override async Task <VTTQs> HistorianReadRaw(VariableRef variable, Timestamp startInclusive, Timestamp endInclusive, int maxValues, BoundingMethod bounding, QualityFilter filter = QualityFilter.ExcludeNone)
        {
            var request = MakeSessionRequest <HistorianReadRawReq>();

            request.Variable       = variable;
            request.StartInclusive = startInclusive;
            request.EndInclusive   = endInclusive;
            request.MaxValues      = maxValues;
            request.Bounding       = bounding;
            request.Filter         = filter;
            return(await Post <VTTQs>(request, binaryDeserializer : BinSeri.VTTQ_Serializer.Deserialize));
        }