Пример #1
0
        public static Pdm Load(IMessageRadio radio, string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }

            if (!File.Exists(path))
            {
                return(null);
            }

            Pdm pdm = null;
            var js  = new JsonSerializer();

            using (var sr = new StreamReader(path))
            {
                using (var jr = new JsonTextReader(sr))
                {
                    pdm = js.Deserialize <Pdm>(jr);
                }
            }

            if (pdm != null)
            {
                pdm.SavePath = path;
                pdm.Radio    = radio;
            }

            return(pdm);
        }
Пример #2
0
        public async static Task <Pdm> InitializePod(IMessageRadio radio, BasalSchedule basalSchedule)
        {
            //TODO:
            //var pod = new Pod(0, 0, 0);
            var pod = new Pod();

            return(new Pdm(radio, pod, basalSchedule));
        }
Пример #3
0
        public static Conversation Start(IMessageRadio radio, Pod pod)
        {
            if (!pod.Address.HasValue)
            {
                throw new ArgumentException("Pod address is unknown");
            }

            //Monitor.Wait(ConversationLock);
            if (!radio.IsInitialized())
            {
                radio.InitializeRadio(pod.Address.Value);
                radio.SetNonceParameters(pod.Lot.Value, pod.Tid.Value, null, null);
            }
            return(new Conversation(radio, pod));
        }
Пример #4
0
 public Pdm(IMessageRadio radio, Pod activePod, BasalSchedule basalSchedule)
 {
     this.Radio         = radio;
     this.Pod           = activePod;
     this.BasalSchedule = basalSchedule;
 }
Пример #5
0
 private Conversation(IMessageRadio radio, Pod pod)
 {
     this.Radio = radio;
     this.Pod   = pod;
 }