private void Disconnect(ushort duration=0) {
if(duration==0 && !string.IsNullOrEmpty(_willPath)) {
TopicInfo ti = GetTopicInfo(_willPath, false);
SetValue(ti, _wilMsg, false);
}
if(duration>0) {
if(state==State.ASleep) {
state=State.AWake;
}
ResetTimer(3100+duration*1550); // t_wakeup
this.Send(new MsDisconnect());
_tryCounter=0;
state=State.ASleep;
var st=Owner.Get<long>(".cfg/XD_SleepTime", Owner);
st.saved=true;
st.SetValue((short)duration, new TopicChanged(TopicChanged.ChangeArt.Value, Owner) { Source=st });
} else {
_activeTimer.Change(Timeout.Infinite, Timeout.Infinite);
this._gate=null;
if(state!=State.Lost) {
state=State.Disconnected;
if(Owner!=null) {
Log.Info("{0} Disconnected", Owner.path);
}
}
}
_waitAck=false;
}
private void OwnerChanged(Topic topic, TopicChanged param) {