//idroutera private void HandleAvaibleSlotsInNode(string[] msg) { string resultstring = XmlSerialization.GetStringToNormal(msg); MessageAvaibleSlotsInNode messageAvaibleSlots = XmlSerialization.DeserializeObject <MessageAvaibleSlotsInNode>(resultstring); int index = FindIndexOfNodeInPath(messageAvaibleSlots.ID); Responses[index] = messageAvaibleSlots.AvaibleSlots; //NewLog2($"CC: Get SNP LinkConnectionRequestResponse from {index+1}", myWindow, "LightSkyBlue"); if (AreAllResponsesReceivevd() && (Responses.Length > 0)) { //NewLog($"Areallresponsereceived", myWindow); //NewLog($"Responses {Responses.Length}", myWindow); List <int> unionOfSlots = Responses[0]; for (int i = 1; i < Responses.Length; i++) { for (int j = 0; j < unionOfSlots.Count;) { if (Responses[i].Contains(unionOfSlots[j])) { j++; } else { unionOfSlots.RemoveAt(j); } } } string unionStr = ""; foreach (int i in unionOfSlots) { unionStr += " " + i; } NewLog($"RC: Found union of available slots {unionStr}", myWindow); Responses = null; SlotWindow slotWindow = new SlotWindow(); if (FindSlotWindow(unionOfSlots, ref slotWindow)) { NewLog($"RC: Found Slot Window: FirstSlot: {slotWindow.FirstSlot} NumberOfSlots: {slotWindow.NumberofSlots}", myWindow); NewLog($"RC: {IPRC} Send RouteTableQueryResponse to CC", myWindow); SentNewRouterRecord(slotWindow); } else { //Zaloguj brak dostępnych slotow NewLog($"No available slots!", myWindow); } } }
//sprawdza dostepnosc okien public void HandleAvaibleSlotsRequest() { //NewLog($"LRM: Get SNP LinkConnectionRequest from CC", this); //NewLog($"{NodeNumber} adres rc response: {networknode.RCIPAddres}", this); //lista dostepnych slotow var listofslots = new System.Collections.Generic.List <int>(); for (int i = 0; i < 10; i++) { listofslots.Add(i); } foreach (RouterMapRecord item in networknode.routerMapRecords) { for (int i = item.slotWindow.FirstSlot; i < (item.slotWindow.FirstSlot + item.slotWindow.NumberofSlots); i++) { listofslots.Remove(i); } } MessageAvaibleSlotsInNode response = new MessageAvaibleSlotsInNode(); response.ID = networknode.ID; response.AvaibleSlots = listofslots; string sloty = ""; foreach (int id in listofslots) { sloty = sloty + " " + id; } string messageContent = MessageNames.HANDLEAVAIBLESLOT_RESPONSE + " "; messageContent += XmlSerialization.SerializeObject(response); //wysylamy wiadomosc do CC SendMessage(networknode.RCIPAddres, messageContent); //NewLog($"LRM: Send SNP LinkConnectionResponse to CC, Available slots: {sloty}", this); }