public void destroyCommunicationPath() { DevMgmtS_tgl.T_GW_CURR_LINKID CurrLinkId= new DevMgmtS_tgl.T_GW_CURR_LINKID(); CurrLinkId.LinkId=0; try { commInterface.WriteRecord((int)DevMgmtS_dcte.E_DGLB_SIMPLE_PREDEFINED_IDX.DGLB_SIMPL_GW_CURR_LINKID_IDX, CurrLinkId); } catch (CommunicationException e) { log.Error(e.Message, e); if (! (e.InnerException is AmbigousDeviceException) ) { throw new CommunicationDestructionException(this, "Cannot destruct communication path!", e); } } }
/// <summary> /// Constructs communication path from bottom up. /// /// This is necessary, since devices can reset at any time, and we don't have any /// advantage if we read gw first, so we just write. /// </summary> /// <param name="children"></param> /// <returns> /// Result of contruction. /// If construction was unsucesfull we must delete device for which construction was unsucesfull /// and we have to update device tree. /// </returns> public void constructCommunicationPath() { try { if (this.isRoot) { destroyCommunicationPath(); return; } } catch (CommunicationDestructionException e) { log.Error(e.Message, e); return; //throw new CommunicationConstructionException(this, "Cannot construct communication path for root device", e); } if (parentDevice != null) { try { ((BPDevice)parentDevice).constructCommunicationPath(); } catch (CommunicationConstructionException e) { throw; } } //This should occur only on leaf node if (!this.parentDevice.isGwCapable) return; //From here on we must preform reconstruction of path! //We must do that for every record. //Change parent gw to us DevMgmtS_tgl.T_GW_CURR_LINKID CurrLinkId = new DevMgmtS_tgl.T_GW_CURR_LINKID(); CurrLinkId.LinkId = this.LinkId; try { commInterface.WriteRecord((int)DevMgmtS_dcte.E_DGLB_SIMPLE_PREDEFINED_IDX.DGLB_SIMPL_GW_CURR_LINKID_IDX, CurrLinkId); } catch (CommunicationException e) { log.Error(e.Message, e); throw new CommunicationConstructionException(this, String.Format("Cannot construct communication path! Eroor on device {0}!", this),e); } }