/// <summary> /// Read value 3 retourne un DataObserver /// </summary> /// <param name="completeVariable"></param> /// <param name="dateTime"></param> /// <returns></returns> private DataObserver readValue3(DataObserver oldDataObs) { DataObserver dObs = oldDataObs; string completeVariable = oldDataObs.PathName; int importOk = vc.importVariable(completeVariable); int typeVS = -1; long oldTimeStamp = oldDataObs.Timestamp; long timeStamp = 0; string value = "-10"; vc = Vs.getVariableController(); vc.getType(completeVariable, out typeVS); Console.WriteLine("readValue : " + completeVariable + " TYPE " + typeVS + " VC " + importOk); if (importOk != 0 && !oldDataObs.IsChanging) { switch (typeVS) { ///================================================================================================= /// Si le type est égal à 1 alors c'est un entier ///================================================================================================= case 1: dObs.Type = VS_Type.INTEGER; IntegerReader intr = vc.createIntegerReader(completeVariable); int valVarInt; if (intr != null) { intr.setBlocking(1 * 200); VariableState t = intr.waitForConnection(); if (t == VariableState.Ok) { intr.get(out valVarInt, out timeStamp); value = valVarInt.ToString(); } } break; ///================================================================================================= ///================================================================================================= /// Si le type est égal à 2 alors c'est un double ///================================================================================================= case 2: dObs.Type = VS_Type.DOUBLE; DoubleReader dblr = vc.createDoubleReader(completeVariable); double valVarDbl; if (dblr != null) { dblr.setBlocking(1 * 200); VariableState t = dblr.waitForConnection(); if (t == VariableState.Ok) { dblr.get(out valVarDbl, out timeStamp); value = valVarDbl.ToString(); } } break; ///================================================================================================= default: dObs.Type = VS_Type.INVALID; value = "Undefined"; break; } if (!oldDataObs.ValueObs.Equals(value)) { dObs.ValueObs = value; dObs.ValueHasChanged = true; } else { dObs.ValueHasChanged = false; } dObs.Timestamp = timeStamp; } return dObs; }
private void BroadcastDataObserver(DataObserver dObs) { Clients.All.updateDataObserver(dObs); }