本文整理汇总了C#中Topic.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Topic.Get方法的具体用法?C# Topic.Get怎么用?C# Topic.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topic
的用法示例。
在下文中一共展示了Topic.Get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public void Init() {
_sign=Topic.root.Get("/etc/PersistentStorage");
_verbose=_sign.Get("verbose");
_verbose.config=true;
if(!Directory.Exists("../data")) {
Directory.CreateDirectory("../data");
}
_file=new FileStream("../data/persist.xdb", FileMode.OpenOrCreate, FileAccess.ReadWrite);
if(_file.Length<=0x40) {
_file.Write(new byte[0x40], 0, 0x40);
_file.Flush(true);
_nextBak=DateTime.Now.AddHours(1);
} else {
Load();
}
_fileLength=_file.Length;
_work=new AutoResetEvent(false);
_thread=new Thread(new ThreadStart(PrThread));
_thread.Priority=ThreadPriority.BelowNormal;
_now=DateTime.Now;
if(_nextBak<_now) {
Backup();
}
_thread.Start();
Topic.root.all.changed+=MqChanged;
}
示例2: Start
public void Start() {
using(var sr=new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("X13.Periphery.gpio.xst"))) {
Topic.Import(sr, null);
}
_gpio=Topic.root.Get("/dev/Gpio");
_gpio.Get<string>("_declarer", _gpio).value="Gpio";
_gpio.Subscribe("+", GpioChanged);
_poolTimer=new Timer(Pool, null, 500, 50);
}
示例3: MqClient
public MqClient() {
_waitPingResp=false;
_mq=Topic.root.Get("/local/MQ");
ConnInfo=new MqConnect();
ConnInfo.cleanSession=true;
ConnInfo.keepAlive=this.KeepAlive;
_tOut=new Timer(new TimerCallback(TimeOut));
_settings=Topic.root.Get("/local/cfg/Client");
_subs=new List<Topic.Subscription>();
_now=Topic.root.Get<DateTime>("/var/now");
_nowOffset=_settings.Get<long>("TimeOffset");
}
示例4: WsSyncItem
public WsSyncItem(string name, Uri uri) {
this.name = name;
this._uri = uri;
_st=State.Connecting;
_val=_var.Get(name);
_present=_val.Get<bool>("_present");
_present.value=false;
_reconn = new Timer(CheckState);
_rccnt = 1;
Connect();
}
示例5: SetOwner
public void SetOwner(Topic owner) {
if(_owner!=null) {
_owner.Unsubscribe("+", STVarChanged);
}
_owner=owner;
if(_owner!=null) {
addr=int.Parse(owner.name.Substring(2));
if(_owner.parent!=null && _owner.parent.valueType==typeof(MsDevice)) {
_dev=(_owner.parent as DVar<MsDevice>).value;
}
_decl=_owner.Get<string>("_declarer", _owner);
_owner.Subscribe("+", STVarChanged);
if(_state!=0xB0) {
Reset();
}
} else {
_decl=null;
_state=0xB0;
_to.Change(-1, -1);
}
}
示例6: AddTopic
private Topic AddTopic(Topic parent, Record r) {
Topic t=null;
if(parent==null) {
if(r.name=="/") {
t=Topic.root;
}
} else {
t=parent.Get(r.name, true, _sign);
}
if(t!=null) {
r.t=t;
t.saved=r.saved_fl!=0;
t.local=r.local;
if(_verbose.As<bool>()) {
Log.Debug("L [{0:X4}]{1}={2}", r.pos<<4, t.path, r.payload);
}
_tr[t]=r;
int idx;
while((idx=indexPPos(_refitParent, r.pos))>=0 && idx<_refitParent.Count && _refitParent[idx].parent==r.pos) {
Record nextR=_refitParent[idx];
_refitParent.RemoveAt(idx);
AddTopic(t, nextR);
}
if(!string.IsNullOrEmpty(r.payload)) {
t.SetJson(r.payload, _sign);
}
}
return t;
}
示例7: foreach
void ITopicOwned.SetOwner(Topic owner) {
if(Owner!=owner) {
if(Owner!=null) {
if(_subsscriptions!=null) {
foreach(var s in _subsscriptions) {
Owner.Unsubscribe(s.path, s.func);
}
_subsscriptions.Clear();
}
_stateVar=null;
if(_activeTimer!=null) {
_activeTimer.Change(Timeout.Infinite, Timeout.Infinite);
}
}
Owner=owner;
if(Owner!=null) {
_stateVar=Owner.Get<State>(".cfg/_state");
if(Topic.brokerMode) {
Owner.saved=true;
Owner.Get<string>(".cfg/_declarer").value="mqtts_cfg";
var dc=Owner.Get<string>("_declarer", Owner);
dc.saved=true;
dc.value=_declarer;
_present=Owner.Get<bool>("present", Owner);
_present.saved=false;
_present.value=(state==State.Connected || state==State.ASleep || state==State.AWake);
Topic oldT;
if(!string.IsNullOrEmpty(backName) && backName!=Owner.name && Owner.parent.Exist(backName, out oldT) && oldT.valueType==typeof(MsDevice)) { // Device renamed
MsDevice old=(oldT as DVar<MsDevice>).value;
if(old!=null) {
Addr=old.Addr;
old._gate.Send(new MsPublish(null, PredefinedTopics["_sName"], QoS.AtLeastOnce) { Addr=Addr, MessageId=old.NextMsgId(), Data=Encoding.UTF8.GetBytes(Owner.name.Substring(0, Owner.name.Length)) });
this.state=State.Disconnected;
}
}
backName=Owner.name;
}
}
}
}
示例8: Import
private static void Import(XElement xElement, Topic owner) {
if(xElement == null || owner == null || xElement.Attribute("n") == null) {
return;
}
Version ver;
Topic cur;
bool setVersion = false;
if(xElement.Attribute("ver") != null && Version.TryParse(xElement.Attribute("ver").Value, out ver)) {
if(owner.Exist(xElement.Attribute("n").Value, out cur)) {
Topic tVer;
Version oldVer;
if(!cur.Exist("$INF\version", out tVer) || tVer.vType != typeof(string) || !Version.TryParse(tVer.As<string>(), out oldVer) || oldVer < ver) {
setVersion = true;
cur.Remove();
} else {
return; // don't import older version
}
} else {
setVersion = true;
}
} else {
ver = default(Version);
}
cur = owner.Get(xElement.Attribute("n").Value);
foreach(var xNext in xElement.Elements("i")) {
Import(xNext, cur);
}
cur.SetFlagI(0, xElement.Attribute("s") != null && xElement.Attribute("s").Value != bool.FalseString);
if(xElement.Attribute("v") != null) {
try {
cur.SetJson(xElement.Attribute("v").Value);
}
catch(Exception ex) {
Log.Warning("Import({0}) - {1}\n{2}", cur.path, ex.Message, xElement.Attribute("v").Value);
}
}
if(setVersion) {
cur.Get("$INF\version").value = ver.ToString();
}
}
示例9: SetOwner
public void SetOwner(Topic owner) {
if(_owner!=null) {
if(Topic.brokerMode) {
_owner.Unsubscribe("+", STVarChanged);
}
}
if(_dev!=null) {
_dev.Pool+=_dev_Pool;
}
_owner=owner;
if(_owner!=null) {
name=owner.name;
if(Topic.brokerMode) {
if(_owner.parent!=null && _owner.parent.valueType==typeof(MsDevice)) {
_dev=(_owner.parent as DVar<MsDevice>).value;
}
_owner.Get<string>("_declarer", _owner).value="TWI";
_owner.Subscribe("+", STVarChanged);
if(_dev!=null) {
_dev.Pool+=_dev_Pool;
Reset();
}
}
}
}
示例10: SetOwner
public void SetOwner(Topic owner) {
if(!object.ReferenceEquals(owner, _owner)) {
if(_owner!=null) {
_owner.Unsubscribe("#", ChildChaged);
}
_owner=owner;
if(_owner!=null) {
_tPresent=_owner.Get<bool>("_present");
_tPresent.saved=false;
_owner.Get<string>("_declarer", _owner).value=_decl;
PSetOwner();
_owner.Subscribe("#", ChildChaged);
} else if(_gate!=null) {
_gate.DelDevice(this);
var dev=Topic.root.Get("/dev/1Wire").children.Select(z => z.GetValue() as OneWireBase).FirstOrDefault(z => z!=null && z!=this && this.rom.SequenceEqual(z.rom));
if(dev!=null) {
dev.gate=_gate;
}
_gate=null;
}
}
}