private TopicInfo GetTopicInfo(Topic tp, bool sendRegister=true) {
if(tp==null) {
return null;
}
TopicInfo rez=null;
for(int i=_topics.Count-1; i>=0; i--) {
if(_topics[i].path==tp.path) {
rez=_topics[i];
break;
}
}
string tpc=(tp.path.StartsWith(Owner.path))?tp.path.Remove(0, Owner.path.Length+1):tp.path;
if(rez==null) {
rez=new TopicInfo();
rez.topic=tp;
rez.path=tp.path;
ushort rtId;
if(PredefinedTopics.TryGetValue(tpc, out rtId)) {
rez.TopicId=rtId;
rez.it=TopicIdType.PreDefined;
rez.registred=true;
} else {
Topic tmp=tp.parent;
bool ignory=false;
while(tmp!=null && tmp.valueType!=typeof(MsDevice)) {
if(tmp.valueType==typeof(SmartTwi) || tmp.valueType==typeof(TWIDriver)) {
ignory=true;
break;
}
tmp=tmp.parent;
}
if(ignory) {
rez.TopicId=0xFFFF;
rez.it=TopicIdType.PreDefined;
rez.registred=true;
} else {
rez.TopicId=CalculateTopicId(rez.path);
rez.it=TopicIdType.Normal;
}
}
_topics.Add(rez);
}
if(!rez.registred) {
if(sendRegister) {
Send(new MsRegister(rez.TopicId, tpc));
} else {
rez.registred=true;
}
}
return rez;
}
private ushort CalculateTopicId(string path) {