Beispiel #1
0
 private void CfgChanged(Topic sender, TopicChanged arg) {
   DVar<string> dv=sender as DVar<string>;
   if(dv==null || sender==_verbose) {
     return;
   }
   if(arg.Art==TopicChanged.ChangeArt.Remove) {
     foreach(var i in _items.Where(z => z.name==dv.name).ToArray()) {
       i.Dispose();
       _items.Remove(i);
     }
   } else if(!string.IsNullOrWhiteSpace(dv.value)) {
     Uri u;
     try {
       u=new Uri(dv.value);
     }
     catch(UriFormatException ex) {
       Log.Warning("{0}=\"{1}\" - {2}", dv.path, dv.value, ex.Message);
       return;
     }
     if(string.IsNullOrEmpty(u.AbsolutePath)) {
       return;
     }
     WsSyncItem it=_items.FirstOrDefault(z => z.name==dv.name);
     if(it==null) {
       it=new WsSyncItem(dv.name, u);
       _items.Add(it);
     } else {
       it.ChangeUri(u);
     }
   }
 }
Beispiel #2
0
    private static void DeclarerChanged(Topic sender, TopicChanged param) {
      DVar<string> dec=sender as DVar<string>;
      Topic infoT;
      DVar<string> infoD;
      if(dec==null) {
        return;
      }

      StatementDescription stR=null;

      if(param.Art==TopicChanged.ChangeArt.Remove) {
        stR=_statements.FirstOrDefault(z => z.name==dec.name);
        if(stR!=null) {
          _statements.Remove(stR);
        }
      } else {
        if(param.Art==TopicChanged.ChangeArt.Value) {
          stR=_statements.FirstOrDefault(z => z.name==dec.name);
        }
        if(stR==null) {
          stR=new StatementDescription() { name=dec.name };
          _statements.Add(stR);
        }
        stR.image=dec.value;
        if(dec.Exist("_description", out infoT) && (infoD=(infoT as DVar<string>))!=null && !string.IsNullOrEmpty(infoD.value)) {
          stR.sortKey=infoD.value.Substring(0, 2);
          stR.info=infoD.value.Substring(2);
        }
      }
    }
Beispiel #3
0
 private void TopicBox_Click(object sender, EventArgs e)
 {
     ParentForm.ActiveControl = null;
     (var info, var str)      = TopicForm.Show(Topic, Text);
     if (info == DialogResult.OK)
     {
         Text = str;
         TopicChanged?.Invoke(this, EventArgs.Empty);
     }
 }
Beispiel #4
0
 static LogramView() {
   _settings=Topic.root.Get("/etc/CC/Logram");
   _statements=new List<StatementDescription>();
   Topic decls=Topic.root.Get("/etc/declarers/func");
   //decls.Subscribe("+", DeclarerChanged);
   TopicChanged p=new TopicChanged(TopicChanged.ChangeArt.Add);
   foreach(Topic d in decls.children) {
     DeclarerChanged(d, p);
   }
 }
Beispiel #5
0
 public void Go(Topic topic)
 {
     lock (_locker)
     {
         if (_topic != topic)
         {
             _topic = topic;
             TopicChanged?.Invoke(this, topic);
         }
     }
 }
Beispiel #6
0
 private void via_changed(Topic sender, TopicChanged arg) {
   DVar<string> via;
   if(arg.Art!=TopicChanged.ChangeArt.Value || sender.name!="_via" || (via=sender as DVar<string>)==null || via.parent==null) {
     return;
   }
   if(string.Compare(via.value, _id.value)==0) {
     via.parent.Subscribe("#", L_dummy);
   } else {
     via.parent.Unsubscribe("#", L_dummy);
   }
   if(string.IsNullOrEmpty(via.value) && PiLogram._isDefault) {
     via.saved=true;
     via.value=_id.value;
   }
 }
Beispiel #7
0
 private void GpioChanged(Topic t, TopicChanged a) {
   if(t==null || t.parent!=_gpio || a.Visited(_gpio, true)) {
     return;
   }
   DVar<bool> tb=t as DVar<bool>;
   if(tb!=null) {
     Pin pin=GetPin(t.name);
     if(pin==null) {
       t.Remove();
       return;
     }
     if(a.Art==TopicChanged.ChangeArt.Remove) {
       _pins.Remove(pin.idx);
       pin.Dispose();
     } else if(a.Art==TopicChanged.ChangeArt.Value && pin.dir) {
       pin.value=tb.value;
     }
   }
 }
Beispiel #8
0
 private void SubChanged(Topic t, TopicChanged a) {
   if(t.path.StartsWith("/local") || a.Visited(_ses.owner, true) || !MQTT.MqBroker.CheckAcl(_ses.userName, t, TopicAcl.Subscribe)) {
     if(_verbose.value) {
       X13.Log.Warning("ws.snd({0}) - subscribe:access denied", t.path);
     }
     return;
   }
   if(a.Art==TopicChanged.ChangeArt.Remove) {
     Send(string.Concat("P\t", t.path, "\tnull"));
     if(_verbose.value) {
       X13.Log.Debug("ws.snd({0}) - remove", t.path);
     }
   } else if(a.Art==TopicChanged.ChangeArt.Value) {
     Send(string.Concat("P\t", t.path, "\t", t.ToJson()));
     if(_verbose.value) {
       X13.Log.Debug("ws.snd({0}, {1})", t.path, t.ToJson());
     }
   } else {
     return;
   }
 }
Beispiel #9
0
 protected override void Because()
 {
     result = (TopicChanged)sut.MakeFrom(ExampleMessages.TopicChanged);
 }
Beispiel #10
0
 private void _owner_changed(Topic sender, TopicChanged param) {
   DVar<Topic> p = param.Source as DVar<Topic>;
   if (p != null && p.parent == _owner && p.value != null) {
     if (p.name == "A") {
       Change_A(p.value);
     } else if (p.name == "B") {
       Change_B(p.value);
     }
   } else if (sender.name == "direction" && sender.valueType == typeof(long)) {
     _dir = (byte)((sender as DVar<long>).value);
   }
   if (exec && _a != null && _b != null) {
     Topic a = _a.valueType == typeof(Topic) ? (_a as DVar<Topic>).value : _a;
     Topic b = _b.valueType == typeof(Topic) ? (_b as DVar<Topic>).value : _b;
     if (a != null && b != null) {
       if (Direction == 0 || Direction == 1) {
         b.SetValue(a.GetValue(), new TopicChanged(TopicChanged.ChangeArt.Value, _owner));
       } else {
         a.SetValue(b.GetValue(), new TopicChanged(TopicChanged.ChangeArt.Value, _owner));
       }
     }
   }
 }
Beispiel #11
0
 private void MQTT_Main_changed(Topic sender, TopicChanged param) {
   if(sender.path.StartsWith("/var/log") || sender.path.StartsWith("/var/now")) {
     return;
   }
   var ir=param.Initiator;
   switch(param.Art) {
   case TopicChanged.ChangeArt.Add:
     if(ir==null) {
       Log.Debug("+ {0}[{1}]", param.Source.path, param.Source.valueType);
     } else {
       Log.Debug("+ {0}[{1}] : {2}", param.Source.path, param.Source.valueType, ir.name);
     }
     break;
   case TopicChanged.ChangeArt.Value:
     if(ir==null) {
       Log.Debug("! {0}={1}", param.Source.path, param.Source.GetValue());
     } else {
       Log.Debug("! {0}={1} : {2}", param.Source.path, param.Source.GetValue(), ir.name);
     }
     break;
   case TopicChanged.ChangeArt.Remove:
     if(ir==null) {
       Log.Debug("- {0}", param.Source.path, param.Initiator);
     } else {
       Log.Debug("- {0} : {1}", param.Source.path, ir.name);
     }
     break;
   }
 }
Beispiel #12
0
 private void STVarChanged(Topic snd, TopicChanged p) {
   if(p.Visited(_owner, true)) {
     return;
   }
   for(int i=_drivers.Count-1; i>=0; i--) {
     if(_drivers[i].VarChanged(snd, p.Art==TopicChanged.ChangeArt.Remove)) {
       if(p.Art==TopicChanged.ChangeArt.Remove) {
         lock(_drivers) {
           _drivers.RemoveAt(i);
         }
       }
       return;
     }
   }
   if(p.Art==TopicChanged.ChangeArt.Remove) {
     return;
   }
   TWICommon drv=null;
   switch(snd.name) {
   case "LM75_T0":
   case "LM75_T1":
   case "LM75_T2":
   case "LM75_T3":
     drv=new LM75(snd);
     break;
   case "CC2D_T":
   case "CC2D_H":
     drv=new CC2D(snd);
     break;
   case "HIH61_T":
   case "HIH61_H":
     drv=new HIH61xx(snd);
     break;
   case "SI7020_T":
   case "SI7020_H":
     drv=new SI7020(snd);
     break;
   case "BMP180_T":
   case "BMP180_P":
     drv=new BMP180(snd);
     break;
   case "BME280_T":
   case "BME280_P":
   case "BME280_H":
     drv=new BME280(snd);
     break;
   case "BLINKM_8":
   case "BLINKM_9":
   case "BLINKM_10":
     drv=new Blinky(snd);
     break;
   case "BH1750_0":
   case "BH1750_1":
     drv=new BH1750(snd);
     break;
   case "EXP_0":
   case "EXP_1":
   case "EXP_2":
   case "EXP_3":
   case "EXP_4":
   case "EXP_5":
   case "EXP_6":
   case "EXP_7":
     drv=new Expander(snd);
     break;
   //case "SI1143":
   //  drv=new SI1143(snd);
   //  break;
   default:
     if(snd.name.Length>2 && snd.name.Length<6 && (snd.name.StartsWith("Sa") || snd.name.StartsWith("Ra"))) {
       drv=new RawDevice(snd);
     }
     break;
   }
   if(drv!=null) {
     lock(_drivers) {
       for(int i=_drivers.Count-1; i>=0; i--) {
         if(_drivers[i].VarChanged(snd, false)) {
           drv=null;
           break;
         }
       }
       if(drv!=null) {
         _drivers.Add(drv);
       }
     }
   }
 }
Beispiel #13
0
 private void OwnerChanged(Topic sender, TopicChanged param) {
   if(!_connected || sender.parent==null || sender.path.StartsWith("/local") || sender.path.StartsWith("/var/now") || sender.path.StartsWith("/var/log") || param.Visited(_mq, false) || param.Visited(_owner, false)) {
     return;
   }
   switch(param.Art) {
   case TopicChanged.ChangeArt.Add: {
       MqPublish pm=new MqPublish(sender);
       if(sender.valueType!=null && sender.valueType!=typeof(string) && !sender.valueType.IsEnum && !sender.valueType.IsPrimitive) {
         pm.Payload=(new Newtonsoft.Json.Linq.JObject(new Newtonsoft.Json.Linq.JProperty("+", WOUM.ExConverter.Type2Name(sender.valueType)))).ToString();
       }
       this.Send(pm);
     }
     break;
   case TopicChanged.ChangeArt.Value: {
       MqPublish pm=new MqPublish(sender);
       this.Send(pm);
     }
     break;
   case TopicChanged.ChangeArt.Remove: {
       MqPublish pm=new MqPublish(sender);
       pm.Payload=string.Empty;
       this.Send(pm);
     }
     break;
   }
 }
Beispiel #14
0
 private void val_changed(Topic snd, TopicChanged p) {
   if(p.Art==TopicChanged.ChangeArt.Remove && _owner!=null) {
     _owner.Remove();
   }
 }
Beispiel #15
0
 private void ModelChanged(Topic sender, TopicChanged param) {
   if(sender!=null && sender.parent==model) {
     Dispatcher.BeginInvoke(new Action<Topic, TopicChanged.ChangeArt>(ModelItemChanged), System.Windows.Threading.DispatcherPriority.DataBind, sender, param.Art);
   }
 }
Beispiel #16
0
 private void _local_changed(Topic sender, TopicChanged p) {
   if(_val==null || sender==null || sender==_present || _val==null || p.Initiator==_val || sender.path==null || !sender.path.StartsWith(_val.path) || p.Art==TopicChanged.ChangeArt.Add) {
     return;
   }
   string path;
   if(sender==_val) {
     path=_remoteBase;
   } else {
     path=_remoteBase+sender.path.Substring(_val.path.Length);
   }
   string content;
   if(p.Art==TopicChanged.ChangeArt.Value) {
     content=sender.ToJson();
   } else {
     content="null";
   }
     Send("P\t"+path+"\t"+content);
 }
Beispiel #17
0
 private void PublishTopic(Topic topic, TopicChanged param) {
   if(topic.valueType==null || topic==Owner) {
     return;
   }
   if(param.Art==TopicChanged.ChangeArt.Add) {
     if(topic.valueType==typeof(SmartTwi) || (topic.parent!=null && topic.parent.valueType==typeof(SmartTwi))) {
       return;   // processed from SmartTwi
     }
     GetTopicInfo(topic);
     return;
   }
   if(topic.name=="_via") {
     if(_gate==null) {
       if(string.IsNullOrEmpty(via)) {
         MsGSerial.Rescan();
       }
     }
   }
   if(!(state==State.Connected || state==State.ASleep || state==State.AWake) || param.Visited(Owner, true)) {
     return;
   }
   if(topic.valueType==typeof(SmartTwi) || (topic.parent!=null && topic.parent.valueType==typeof(SmartTwi))) {
     return;   // processed from SmartTwi
   }
   TopicInfo rez=null;
   for(int i=_topics.Count-1; i>=0; i--) {
     if(_topics[i].path==topic.path) {
       rez=_topics[i];
       break;
     }
   }
   if(rez==null && param.Art==TopicChanged.ChangeArt.Value) {
     rez=GetTopicInfo(topic, true);
   }
   if(rez==null || rez.it==TopicIdType.NotUsed || rez.TopicId>=0xFFC0 || !rez.registred) {
     return;
   }
   if(param.Art==TopicChanged.ChangeArt.Value) {
     Send(new MsPublish(rez.topic, rez.TopicId, param.Subscription.qos));
   } else {          // Remove by device
     Send(new MsRegister(0xFFFF, rez.path.StartsWith(Owner.path)?rez.path.Remove(0, Owner.path.Length+1):rez.path));
     _topics.Remove(rez);
   }
 }
 private void MqChanged(Topic sender, TopicChanged param) {
   if(sender==null || sender.path.StartsWith("/local") || sender.path=="/var/log/A0" || param.Visited(_sign, true)) {
     return;
   }
   _ch.Enqueue(sender);
   if(param.Art!=TopicChanged.ChangeArt.Add) {
     _work.Set();
   }
 }
Beispiel #19
0
 private void OwnerChanged(Topic topic, TopicChanged param) {
   if(param.Art==TopicChanged.ChangeArt.Remove) {
     Send(new MsDisconnect());
     state=State.Disconnected;
     return;
   }
 }
Beispiel #20
0
 private void PinChanged(Topic src, TopicChanged tc) {
   DVar<bool> pin=src as DVar<bool>;
   int idx=-1;
   if(pin==null || tc.Initiator==_mnt) {
     return;
   }
   if(tc.Art==TopicChanged.ChangeArt.Remove) {
     for(idx=0; idx<_pins.Length; idx++) {
       if(_pins[idx]==pin) {
         _pins[idx]=null;
         ushort n_ipol=_ipol, n_iodir=_iodir;
         n_iodir&=(ushort)(~(1<<idx));
         _inps&=(ushort)(~(1<<idx));
         if(_iodir!=n_iodir) {
           _iodir=n_iodir;
           _flags|=4;
         }
         n_ipol&=(ushort)(~(1<<idx));
         if(_ipol!=n_ipol) {
           _ipol=n_ipol;
           _flags|=2;
         }
         break;
       }
     }
   } else {
     for(int i=0; i<_pins.Length; i++) {
       if(_pins[i]==pin) {
         idx=i;
         break;
       }
     }
     if(idx==-1) {
       ushort n_ipol=_ipol, n_iodir=_iodir;
       if(pin.name.Length==3 
         && (pin.name[0]=='I' || pin.name[0]=='O') 
         && (pin.name[1]=='p' || pin.name[1]=='n')
         && ((pin.name[2]>='0' && pin.name[2]<='9') || (pin.name[2]>='A' && pin.name[2]<='F'))) {
         idx=pin.name[2]-'0';
         if(idx>9) {
           idx-=7;
         }
         if(pin.name[0]=='I') {
           n_iodir|=(ushort)(1<<idx);
           _inps|=(ushort)(1<<idx);
         } else {
           n_iodir&=(ushort)(~(1<<idx));
         }
         if(_iodir!=n_iodir) {
           _iodir=n_iodir;
           _flags|=4;
         }
         if(pin.name[1]=='p') {
           n_ipol&=(ushort)(~(1<<idx));
         } else {
           n_ipol|=(ushort)(1<<idx);
         }
         if(_ipol!=n_ipol) {
           _ipol=n_ipol;
           _flags|=2;
         }
       } else if(pin.name=="IRQ") {
         if(pin.value && !_busy && _flags==0) {
           _pt=DateTime.Now.AddMilliseconds(1);
         }
         return;
       } else {
         return; // unknown variable
       }
       if(_pins[idx]!=pin) {
         if(_pins[idx]!=null) {
           _pins[idx].Remove(tc.Initiator);
         }
         _pins[idx]=pin;
       }
     }
   }
   if(pin.name[0]=='O') {
     ushort n_gpo=_gpo;
     bool val=((_ipol & (1<<idx))==0)?pin.value:!pin.value;
     if(val) {
       n_gpo|=(ushort)(1<<idx);
     } else {
       n_gpo&=(ushort)(~(1<<idx));
     }
     if(_gpo!=n_gpo) {
       _gpo=n_gpo;
       _flags|=1;
     }
   }
   if(!_busy && _flags!=0) {
     _pt=DateTime.Now.AddMilliseconds(1);
   }
 }
Beispiel #21
0
 private void PinChanged(Topic snd, TopicChanged tc) {
   if(snd==_R || snd==_B || snd==_G) {
     _st|=1;
   } else if(snd==_fade) {
     _st|=2;
   }
 }
Beispiel #22
0
 private void _b_changed(Topic sender, TopicChanged param) {
   if (exec) {
     if (param.Art == TopicChanged.ChangeArt.Value && _a != null && !param.Visited(_a, true) && (Direction == 0 || Direction == 2)) {
       Topic a = _a.valueType == typeof(Topic) ? (_a as DVar<Topic>).value : _a;
       Topic b = _b.valueType == typeof(Topic) ? (_b as DVar<Topic>).value : _b;
       if (a != null && b != null) {
         a.SetValue(b.GetValue(), new TopicChanged(param));
       }
     } else if (_b.disposed) {
       DVar<PiWire> o = System.Threading.Interlocked.Exchange(ref _owner, null);
       if (o != null) {
         Change_A(null);
         Change_B(null);
         o.Remove();
       }
     }
   }
 }
Beispiel #23
0
 private void Dummy(Topic t, TopicChanged a) {
 }
 private void obj_changed(Topic sender, TopicChanged param) {
   if(param.Art==TopicChanged.ChangeArt.Value) {
     if(PropertyChanged!=null) {
       if(sender==obj) {
         PropertyChanged(this, new PropertyChangedEventArgs("value"));
       } else if(sender!=null) {
         PropertyChanged(this, new PropertyChangedEventArgs(ExConverter.String2Name(sender.name)));
       }
     }
   } else {
     PropertyView.Selected=obj;
   }
 }
Beispiel #25
0
 private void ChildChaged(Topic src, TopicChanged arg) {
   if(src==null) {
     return;
   }
   _prio+=10;
 }
Beispiel #26
0
 private void _via_changed(Topic sender, TopicChanged arg) {
   if(arg.Art!=TopicChanged.ChangeArt.Value) {
     return;
   }
   RefreshStatements();
 }
Beispiel #27
0
 private void STVarChanged(Topic t, TopicChanged a) {
   if(_dev==null || a.Art!=TopicChanged.ChangeArt.Value) {
     return;
   }
   var st=_vars.FirstOrDefault(z => z.ptr==t);
   if(st.ptr!=t || !st.write) {
     return;
   }
   byte[] payload;
   switch(st.dateType) {
   case 'z': {
       payload=new byte[2];
       payload[1]=(byte)((t as DVar<bool>).value?0xFF:0);
     }
     break;
   case 'b': {
       payload=new byte[2];
       payload[1]=(byte)(sbyte)(t as DVar<long>).value;
     }
     break;
   case 'B': {
       payload=new byte[2];
       payload[1]=(byte)(t as DVar<long>).value;
     }
     break;
   case 'w': {
       payload=new byte[3];
       short v=(short)(t as DVar<long>).value;
       payload[1]=(byte)v;
       payload[2]=(byte)(v>>8);
     }
     break;
   case 'W': {
       payload=new byte[3];
       ushort v=(ushort)(t as DVar<long>).value;
       payload[1]=(byte)v;
       payload[2]=(byte)(v>>8);
     }
     break;
   case 'd': {
       payload=new byte[5];
       int v=(int)(t as DVar<long>).value;
       payload[1]=(byte)v;
       payload[2]=(byte)(v>>8);
       payload[3]=(byte)(v>>16);
       payload[4]=(byte)(v>>24);
     }
     break;
   case 'D': {
       payload=new byte[5];
       uint v=(uint)(t as DVar<long>).value;
       payload[1]=(byte)v;
       payload[2]=(byte)(v>>8);
       payload[3]=(byte)(v>>16);
       payload[4]=(byte)(v>>24);
     }
     break;
   case 'q': {
       payload=new byte[9];
       long v=(t as DVar<long>).value;
       payload[1]=(byte)v;
       payload[2]=(byte)(v>>8);
       payload[3]=(byte)(v>>16);
       payload[4]=(byte)(v>>24);
       payload[5]=(byte)(v>>32);
       payload[6]=(byte)(v>>40);
       payload[7]=(byte)(v>>48);
       payload[8]=(byte)(v>>56);
     }
     break;
   case 's': {
       string v=(t as DVar<string>).value;
       if(string.IsNullOrEmpty(v)) {
         payload=new byte[1];
       } else {
         byte[] buf=Encoding.Default.GetBytes(v);
         payload=new byte[buf.Length+1];
         Buffer.BlockCopy(buf, 0, payload, 1, buf.Length);
       }
     }
     break;
   case 'a': {
       PLC.ByteArray v=(t as DVar<PLC.ByteArray>).value;
       if(v!=null) {
         byte[] buf=v.GetBytes();
         payload=new byte[buf.Length+1];
         Buffer.BlockCopy(buf, 0, payload, 1, buf.Length);
       } else {
         payload=new byte[1];
       }
     }
     break;
   default:
     return;
   }
   payload[0]=st.addr;
   _dev.PublishWithPayload(_owner, payload);
 }
Beispiel #28
0
 void Dummy(Topic src, TopicChanged arg) {
 }
Beispiel #29
0
 private void _owner_changed(Topic sender, TopicChanged param) {
   if(_initDelay!=null) {
     _initDelay.Change(100, Timeout.Infinite);
   } else if(param.Art==TopicChanged.ChangeArt.Value && param.Initiator!=_owner && _st!=null) {
     if(_st!=null) {
       try {
         _st.Calculate(_owner, param.Source);
       }
       catch(NullReferenceException ex) {
         Log.Debug("{0}.calculate - {1}", _owner.path, ex.Message);
       }
       catch(Exception ex) {
         Log.Warning("{0}.calculate - {1}", _owner.path, ex.Message);
       }
     }
   }
 }
Beispiel #30
0
 private void ModelChanged(Topic sender, TopicChanged param) {
   if(param.Art==TopicChanged.ChangeArt.Add) {   // rename
     Dispatcher.BeginInvoke(new Action(() => { this.Title=model.name; this.Name=ExConverter.String2Name(model.path); }), System.Windows.Threading.DispatcherPriority.Background);
   }
 }
Beispiel #31
0
 public static void L_dummy(Topic sender, TopicChanged arg) {
   return;
 }
Beispiel #32
0
    private void ModelItemChanged(Topic source, TopicChanged.ChangeArt art) {
      if(art==TopicChanged.ChangeArt.Add) {
        return;
      }
      try {
        DrawingVisual cur;

        if(art==TopicChanged.ChangeArt.Value) {
          if(source.name=="_width") {
            var w=model.Get<long>("_width");
            if(w.value==0) {
              w.saved=true;
              w.value=24;
            }
            this.Width=w.value*LogramView.CellSize;
          } else if(source.name=="_height") {
            var h=model.Get<long>("_height");
            if(h.value<=0) {
              h.saved=true;
              h.value=24;
            }
            this.Height=h.value*LogramView.CellSize;
          } else if(source.valueType==typeof(Topic)) {
            if(!_visuals.Where(z => z is uiAlias).Cast<uiAlias>().Any(z => z.model==source)) {
              cur=new uiAlias(source as DVar<Topic>, this);
            }
          } else if(source.valueType==typeof(PiStatement)) {
            if(!_visuals.Where(z => z is uiStatement).Cast<uiStatement>().Any(z => z.model==source)) {
              System.Threading.Thread.Sleep(180);     // filling of the fields executed by the broker
              cur=new uiStatement(source as DVar<PiStatement>, this);
            }

          } else if(source.valueType==typeof(PiWire)) {
            if(!_visuals.Where(z => z is uiWire).Cast<uiWire>().Any(z => z.GetModel()==source)) {
              cur=new uiWire(source as DVar<PiWire>, this);
            }
          } else if(source.valueType==typeof(PiTracer)) {
            if(!_visuals.Where(z => z is uiTracer).Cast<uiTracer>().Any(z => z.GetModel()==source)) {
              cur=new uiTracer(source as DVar<PiTracer>, this);
            }
          }
        }
      }
      catch(Exception ex) {
        Log.Error("Schema.ModelItemChanged({0}, {1}) - {2}", art, source.path, ex.Message);
      }
    }
Beispiel #33
0
 void root_changed(Topic sender, TopicChanged param) {
   if(!_verbose) {
     return;
   }
   var ir=param.Initiator;
   switch(param.Art) {
   case TopicChanged.ChangeArt.Add:
     if(ir==null) {
       Log.Debug("+ {0}[{1}]", sender.path, sender.valueType);
     } else {
       Log.Debug("+ {0}[{1}] : {2}", sender.path, sender.valueType, ir.name);
     }
     break;
   case TopicChanged.ChangeArt.Value:
     if(ir==null) {
       if(!sender.path.StartsWith("/dev/.clock/")) {
         Log.Debug("! {0}={1}", sender.path, sender.GetValue());
       }
     } else if(!ir.path.StartsWith("/dev/.clock/")) {
       Log.Debug("! {0}={1} : {2}", sender.path, sender.GetValue(), ir.name);
     }
     break;
   case TopicChanged.ChangeArt.Remove:
     if(ir==null) {
       Log.Debug("- {0}", sender.path, param.Initiator);
     } else {
       Log.Debug("- {0} : {1}", sender.path, ir.name);
     }
     break;
   }
 }