Beispiel #1
0
 public TelosbSensor(UInt16 Id, TelosbConfig newconfig)
 {
     id       = Id;
     type     = (int)SensorType.TELOSB;
     online   = true;
     online_t = false;
     port     = -1;
     for (int i = 0; i < 2; i++)
     {
         telosbdata[i] = 0;
     }
     if (Id == newconfig.id)
     {
         config = newconfig.config;
     }
     temperature         = 0.0;
     humidity            = 0.0;
     newindata           = false;
     uploadcreatenewfile = true;
 }
Beispiel #2
0
 public TelosbSensor(UInt16 Id,TelosbConfig newconfig)
 {
     id = Id;
     type = (int)SensorType.TELOSB;
     online = true;
     online_t = false;
     port = -1;
     for (int i = 0; i < 2; i++)
         telosbdata[i] = 0;
     if (Id == newconfig.id)
         config = newconfig.config;
     temperature = 0.0;
     humidity = 0.0;
     newindata = false;
     uploadcreatenewfile = true;
 }
Beispiel #3
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
            {
            }

            sr.Close();
            fs.Close();
        }
Beispiel #4
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
            {
            }

            sr.Close();
            fs.Close();
        }