Beispiel #1
0
        static void Main(string[] args)
        {
            var Config = new Settings("conf.json");
            var Start  = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000;

            while (true)
            {
                var Now = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000;
                if (Now - Start < 1000)
                {
                    Thread.Sleep((int)(1000 - Now + Start));
                }
                foreach (var DeviceName in Config.GetSpareDevices())
                {
                    Console.WriteLine($"Try to Start {DeviceName}");
                    Config.Devices[DeviceName].DetectPort();
                    Config.Devices[DeviceName].StartMonitor();
                }
                foreach (var DeviceName in Config.GetLiveDevices())
                {
                    try
                    {
                        Modem.ReceiveSMS(Config.Devices[DeviceName]);
                        Modem.ReceiveStatus(Config.Devices[DeviceName]);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        Config.Devices[DeviceName].StopMonitor();
                    }
                }
                Start = Now;
            }
        }
Beispiel #2
0
 public void DetectPort()
 {
     if (this.IMEI != "")
     {
         Modem.DetectModemByIMEI(this);
         return;
     }
 }
Beispiel #3
0
 public bool StartMonitor()
 {
     if (this.Monitoring == false)
     {
         try
         {
             if (ModemPortName != "")
             {
                 this.ModemPort = new SerialPort(ModemPortName);
                 this.ModemPort.Open();
                 Modem.InitDevice(this);
             }
             if (DiagnosePortName != "")
             {
                 this.DiagnosePort = new SerialPort(DiagnosePortName);
                 this.DiagnosePort.Open();
             }
             if (VoicePortName != "")
             {
                 this.VoicePort = new SerialPort(VoicePortName);
                 this.VoicePort.Open();
             }
             if (ModemPort != null && DiagnosePort != null && VoicePort != null)
             {
                 this.Monitoring = true;
                 Console.WriteLine($"{this.Name} starts being monitoring");
                 return(true);
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
             StopMonitor();
             return(false);
         }
     }
     StopMonitor();
     return(false);
 }