예제 #1
0
 public PumpBoard(UInt16 Id, FlowrateConfig newconfig)
 {
     id       = Id;
     type     = (int)SensorType.PUMPBOARD;
     online   = false;
     online_t = false;
     port     = -1;
     for (int i = 0; i < 8; i++)
     {
         flowrate[i] = 0;
         if (Id == newconfig.id)
         {
             config[i] = newconfig.config[i];
         }
     }
     newindata = false;
     for (int i = 0; i < 8; i++)
     {
         pumpvalue[i] = 0;
     }
     for (int i = 0; i < 8; i++)
     {
         pumpspeed[i] = 0;
     }
     newoutdata          = false;
     uploadcreatenewfile = true;
 }
예제 #2
0
        private void ReadConfig(string dir, ref ArrayList array,int mode)
        {
            FileStream fs;
            StreamReader sr;
            var fileMode = FileMode.Open;
            fs = new FileStream(dir, fileMode, FileAccess.Read);
            sr = new StreamReader(fs, Encoding.Default);
            if (mode == 1)
            {
                try
                {
                    while (true)
                    {
                        string line = sr.ReadLine();
                        if(line.StartsWith("#"))
                            continue;
                        if(line.Length<3)
                            continue;
                        string[] split1 = line.Split(':');
                        string[] split2 = split1[1].Split(',');
                        TemperatureConfig newconfig = new TemperatureConfig();
                        try
                        {
                            newconfig.id = UInt16.Parse(split1[0]);
                            for (int i = 0; i < 16; i++)
                            {
                                newconfig.config[i] = int.Parse(split2[i]);
                            }
                        }
                        catch
                        {
                        }
                        Temperatureconfig.Add(newconfig);
                    }
                }
                catch
                {
                }
            }
            else if (mode == 2)
            {
                try
                {
                    while (true)
                    {
                        string line = sr.ReadLine();
                        if (line.StartsWith("#"))
                            continue;
                        if (line.Length < 3)
                            continue;
                        string[] split1 = line.Split(':');
                        string[] split2 = split1[1].Split(',');
                        FlowrateConfig newconfig = new FlowrateConfig();
                        try
                        {
                            newconfig.id = UInt16.Parse(split1[0]);
                            for (int i = 0; i < 8; i++)
                            {
                                newconfig.config[i] = int.Parse(split2[i]);
                            }
                        }
                        catch
                        {
                        }
                        Flowrateconfig.Add(newconfig);
                    }
                }
                catch
                {
                }
            }
            else if(mode ==3)
            {
                try
                {
                    while (true)
                    {
                        string line = sr.ReadLine();
                        if (line.StartsWith("#"))
                            continue;
                        if (line.Length < 3)
                            continue;
                        string[] split1 = line.Split(':');
                        TelosbConfig newconfig = new TelosbConfig();
                        try
                        {
                            newconfig.id = UInt16.Parse(split1[0]);
                            newconfig.config = int.Parse(split1[1]);
                        }
                        catch
                        {
                        }
                        Telosbconfig.Add(newconfig);
                    }
                }
                catch
                {
                }
            }
            else if (mode == 4)
            {
                try
                {
                    while (true)
                    {
                        string line = sr.ReadLine();
                        if (line.StartsWith("#"))
                            continue;
                        if (line.Length < 3)
                            continue;
                        string[] split1 = line.Split(':');
                        if (split1.Length == 4)
                        {
                            UInt16 id;
                            try
                            {
                                id = UInt16.Parse(split1[0]);
                            }
                            catch
                            {
                                continue;
                            }

                            int type = -1;
                            if (split1[1] == "TEMPERATURE")
                                type = (int)SensorType.TEMPBOARD;
                            else if (split1[1] == "FLOWRATE" || split1[1] == "PUMP")
                                type = (int)SensorType.PUMPBOARD;
                            else
                                continue;

                            if (Boardconfig.Contains(id) == false)
                            {
                                BoardConfig newconfig = new BoardConfig(id, type);
                                Boardconfig.Add(newconfig);
                            }

                            int i = Boardconfig.IndexOf(id);
                            if(i>=0)
                                ((BoardConfig)Boardconfig[i]).SetConfig(split1);
                        }
                    }
                }
                catch
                {
                }
            }
            else
            {
            }
        }
예제 #3
0
 public PumpBoard(UInt16 Id,FlowrateConfig newconfig)
 {
     id = Id;
     type = (int)SensorType.PUMPBOARD;
     online = false;
     online_t = false;
     port = -1;
     for (int i = 0; i < 8; i++)
     {
         flowrate[i] = 0;
         if (Id == newconfig.id)
             config[i] = newconfig.config[i];
     }
     newindata = false;
     for (int i = 0; i < 8; i++)
         pumpvalue[i] = 0;
     for (int i = 0; i < 8; i++)
         pumpspeed[i] = 0;
     newoutdata = false;
     uploadcreatenewfile = true;
 }