Example #1
0
        public static bool connected(string network, string comms)
        {
            netName = network;

            comm = new GsmCommMain(comms, 9600, 150);

            try
            {
                if (comm.IsConnected())
                {
                    Console.WriteLine(netName + "comm is already open");
                    okay = true;
                    if (!comm2.IsConnected())
                    {
                        comm2 = new GsmCommMain(comms, 9600, 150);

                        comm2.Open();
                        CommNetwork _cm = new CommNetwork()
                        {
                            Names = netName, Comms = comm2
                        };
                        primes.Add(_cm);
                    }
                    else
                    {
                        Console.WriteLine(netName + "all comms are open comm is already open");
                    }
                }
                else
                {
                    comm.Open();
                    CommNetwork _cm = new CommNetwork()
                    {
                        Names = netName, Comms = comm
                    };
                    primes.Add(_cm);
                    Console.WriteLine(netName + "comm has connected");
                    okay = true;
                }
            }
            catch (Exception r)
            {
                Console.WriteLine("comm has failed");
                okay = false;
            }

            return(okay);
        }
Example #2
0
        public static bool connected(string network, string comms)
        {
            netName = network;

            comm = new GsmCommMain(comms, 9600, 150);

            try
            {
                if (comm.IsConnected())
                {

                    Console.WriteLine(netName + "comm is already open");
                    okay = true;
                    if (!comm2.IsConnected())
                    {
                        comm2 = new GsmCommMain(comms, 9600, 150);

                        comm2.Open();
                        CommNetwork _cm = new CommNetwork() { Names = netName, Comms = comm2 };
                        primes.Add(_cm);
                    }
                    else
                    {

                        Console.WriteLine(netName + "all comms are open comm is already open");
                    }

                }
                else
                {
                    comm.Open();
                    CommNetwork _cm = new CommNetwork() { Names = netName, Comms = comm };
                    primes.Add(_cm);
                    Console.WriteLine(netName + "comm has connected");
                    okay = true;


                }

            }
            catch (Exception r)
            {
                Console.WriteLine("comm has failed");
                okay = false;

            }

            return okay;

        }