Ejemplo n.º 1
0
        protected override void OnStarted()
        {
            //------------------- falta el folder
            // - Calcular el tick
            // - Calcular nombre del fichero
            Started = true;
            DateTime dateTime    = DateTime.Now;
            int      tickSeconds = (dateTime.Hour * 3600) + (dateTime.Minute * 60) + dateTime.Second;
            string   path        = "LogDay//" + _experiment.Name + "_" + (tickSeconds * 4) + ".bin";

            fileStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite);

            //---------------------------------------------
            _VarsToSave      = _experiment.GetVariables(_systemPriority).Where(x => x.LogValues).ToList();
            _VarsValueToSave = _VarsToSave.ToDictionary(x => x.ID, x => 0D);
            //-------Encabezado------------------------------
            MemoryStream varHeaderStream = new MemoryStream();

            BinarySerializer.Serialize(_VarsToSave, varHeaderStream);

            writer = new BinaryWriter(fileStream);
            writer.Write(varHeaderStream.Length);
            writer.Write(varHeaderStream.ToArray());
            fileStream.Flush();
            //---------------------------------
            _experimentSerializer = new ExperimentSerializer(_VarsToSave);

            //--------------Calcular Tick Timer--------------------------------
            _timer      = TimerCreator.MCD(_VarsToSave.Select(x => x.TicksToSample).ToList());
            _timer.Tick = TimerTickHandler;
            _timer.Start();
        }
Ejemplo n.º 2
0
        public void when_testing_MCD1()
        {
            RealtimeFixedIntervalTimer timer = TimerCreator.MCD(new List <int>()
            {
                8, 4, 2, 12
            });

            timer.Interval.ShouldEqual(2 * 250);
        }