Exemplo n.º 1
0
        public List <VT_hist> get_linha_hist(int id, DateTime ini, DateTime fim)
        {
            int            cont = 0;
            List <VT_hist> hist = new List <VT_hist>();

            while (!linhaDisp)
            {
                if (cont > 100000)
                {
                    return(hist);
                }
            }
            linhaDisp = false;
            try
            {
                string       jon = "";
                StreamReader rd  = new StreamReader(pasta + id + ".data");
                while (!rd.EndOfStream)
                {
                    jon = rd.ReadLine();
                    JavaScriptSerializer ser = new JavaScriptSerializer();
                    VT_hist h = ser.Deserialize <VT_hist>(jon);
                    if (h.time >= ini && h.time <= fim)
                    {
                        hist.Add(h);
                    }
                }
                rd.Close();
            }
            catch { }
            linhaDisp = true;
            return(hist);
        }
Exemplo n.º 2
0
        public bool exec_log(Motor l)
        {
            bool           ret  = false;
            int            cont = 0;
            List <VT_hist> hist = new List <VT_hist>();

            while (!linhaDisp)
            {
                if (cont > 100000)
                {
                    return(ret);
                }
            }
            linhaDisp = false;

            List <string> buffer = new List <string>();

            try
            {
                if (File.Exists(pasta + l.id + ".data"))
                {
                    StreamReader rd = new StreamReader(pasta + l.id + ".data");
                    while (!rd.EndOfStream)
                    {
                        buffer.Add(rd.ReadLine());
                    }
                    rd.Close();
                    rd.Dispose();
                }
                else
                {
                }
            }
            catch { }

            try
            {
                VT_hist h = new VT_hist(l.id, l.V_Rms_Vel_X, l.V_Rms_Vel_Z, l.Temperatura, l.alert_v_Rms_Vel_X, l.alert_v_Rms_Vel_Z, l.alert_tempe, l.Estado);
                buffer.Add(JsonConvert.SerializeObject(h));
                StreamWriter wr = new StreamWriter(pasta + l.id + ".data");
                for (int x = 0; x < buffer.Count; x++)
                {
                    wr.WriteLine(buffer[x]);
                }
                wr.Close();
                wr.Dispose();
                buffer.Clear();
                ret = true;
            }
            catch (Exception ex) { string m = ex.Message; }

            linhaDisp = true;
            return(ret);
        }