Exemple #1
0
        private float DatchikValue(byte value, byte type)
        {
            Datchick d = AvailableDatchiks[type];

            float sh = ((float)(value - d.MinCode) / (float)(d.MaxCode - d.MinCode));

            return(d.MinValue + sh * (d.MaxValue - d.MinValue));
        }
Exemple #2
0
        private void InitializeDatchiks(string fileName)
        {
            string path = AppDomain.CurrentDomain.BaseDirectory + "\\" + fileName;

            StreamReader file =
                new StreamReader(path, Encoding.GetEncoding(1251));

            for (int count = 0; count < File.ReadAllLines(path).Count() / 7; count++)
            {
                Datchick datchick = new Datchick();
                datchick.Name     = file.ReadLine();
                datchick.Unit     = file.ReadLine();
                datchick.Number   = int.Parse(file.ReadLine());
                datchick.MinValue = float.Parse(file.ReadLine().Replace(".", ","));
                datchick.MaxValue = float.Parse(file.ReadLine().Replace(".", ","));
                datchick.MinCode  = byte.Parse(file.ReadLine());
                datchick.MaxCode  = byte.Parse(file.ReadLine());
                AvailableDatchiks.Add(datchick);
            }
        }