Ejemplo n.º 1
0
        public override void Run(HouseholdKey key, object o)
        {
            var sets = (BridgeDayEntries)o;

            if (sets.Entries.Count == 0)
            {
                Logger.Info("No bridge days were found.");
                return;
            }
            SaveableEntry se = new SaveableEntry(key, ResultTableDefinition);

            se.AddField("BridgeDay", SqliteDataType.DateTime);
            se.AddField("BridgeDayJson", SqliteDataType.Text);

            foreach (var afftagset in sets.Entries)
            {
                se.AddRow(RowBuilder.Start("BridgeDay", afftagset)
                          .Add("BridgeDayJson", JsonConvert.SerializeObject(afftagset, Formatting.Indented)).ToDictionary());
            }
            if (Srls == null)
            {
                throw new LPGException("Data Logger was null.");
            }
            Srls.SaveResultEntry(se);
        }
        public override void Run(HouseholdKey key, object o)
        {
            var objects       = (List <IHouseholdKey>)o;
            var actionEntries = objects.ConvertAll(x => (SingleTimestepActionEntry)x).ToList();
            var rowEntries    = new List <Dictionary <string, object> >();

            foreach (var affordanceEnergyUseEntry in actionEntries)
            {
                rowEntries.Add(RowBuilder.Start("Timestep", affordanceEnergyUseEntry.TimeStep)
                               .Add("Json", JsonConvert.SerializeObject(affordanceEnergyUseEntry, Formatting.Indented)).ToDictionary());
            }

            SaveableEntry se = new SaveableEntry(key, ResultTableDefinition);

            se.AddField("Timestep", SqliteDataType.Text);
            se.AddField("Json", SqliteDataType.Text);

            foreach (Dictionary <string, object> entry in rowEntries)
            {
                se.AddRow(entry);
            }
            if (Srls == null)
            {
                throw new LPGException("Data Logger was null.");
            }
            Srls.SaveResultEntry(se);
        }
Ejemplo n.º 3
0
        public override void Run(HouseholdKey key, object o)
        {
            var           objects = (List <LogMessageEntry>)o;
            SaveableEntry se      = new SaveableEntry(key, ResultTableDefinition);

            se.AddField("Time", SqliteDataType.DateTime);
            se.AddField("RelativeTime", SqliteDataType.DateTime);
            se.AddField("Message", SqliteDataType.Text);
            se.AddField("Severity", SqliteDataType.Text);
            se.AddField("MyStackTrace", SqliteDataType.Text);
            foreach (var lme in objects)
            {
                se.AddRow(RowBuilder.Start("Time", lme.Time)
                          .Add("Message", lme.Message)
                          .Add("RelativeTime", lme.RelativeTime)
                          .Add("Severity", lme.Severity.ToString())
                          .Add("MyStackTrace", lme.MyStackTrace)
                          .ToDictionary());
            }
            if (Srls == null)
            {
                throw new LPGException("Data Logger was null.");
            }
            Srls.SaveResultEntry(se);
        }
Ejemplo n.º 4
0
        public override void Run(HouseholdKey key, object o)
        {
            TemperatureProfile tp = (TemperatureProfile)o;
            var tempProfile       = tp.GetTemperatureArray(_calcParameters.InternalStartTime,
                                                           _calcParameters.OfficialEndTime,
                                                           _calcParameters.InternalStepsize);
            DateStampCreator dsc = new DateStampCreator(_calcParameters);

            if (!_calcParameters.IsSet(CalcOption.TemperatureFile))
            {
                return;
            }

            // var allTemperatures = new List<UsedTemperatures>();
            SaveableEntry se = new SaveableEntry(key, ResultTableDefinition);

            se.AddField("Timestep", SqliteDataType.Integer);
            se.AddField("DateTime", SqliteDataType.Text);
            se.AddField("Temperature", SqliteDataType.Double);
            for (var i = 0; i < _calcParameters.OfficalTimesteps; i++)
            {
                string timestamp = dsc.MakeDateStringFromTimeStep(new TimeStep(i, 0, false));
                se.AddRow(RowBuilder.Start("Timestep", i).Add("DateTime", timestamp).Add("Temperature", tempProfile[i]).ToDictionary());
            }

            _srls.SaveResultEntry(se);
        }
Ejemplo n.º 5
0
        public override void Run(HouseholdKey key, object o)
        {
            CalcStartParameterSet csps = (CalcStartParameterSet)o;
            SaveableEntry         se   = new SaveableEntry(key, ResultTableDefinition);

            se.AddField("Name", SqliteDataType.Text);
            se.AddField("Value", SqliteDataType.Text);
            se.AddRow(RowBuilder.Start("Name", "CsvCharacter").Add("Value", csps.CsvCharacter).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "Temperature Profile").Add("Value", csps.TemperatureProfile.Name).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "AffordanceRepetitionCount").Add("Value", csps.AffordanceRepetitionCount.ToString(CultureInfo.InvariantCulture)).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "CalcOptions").Add("Value", JsonConvert.SerializeObject(csps.CalcOptions, Formatting.Indented)).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "CalcTarget").Add("Value", csps.CalcTarget.Name).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "DeleteDatFiles").Add("Value", csps.DeleteDatFiles.ToString()).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "DeviceSelection").Add("Value", csps.DeviceSelection?.Name ?? "None").ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "EnergyIntensity").Add("Value", csps.EnergyIntensity.ToString()).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "ExternalTimeResolution").Add("Value", csps.ExternalTimeResolution.ToString()).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "GeographicLocation").Add("Value", csps.GeographicLocation.Name).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "InternalTimeResolution").Add("Value", csps.InternalTimeResolution.ToString()).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "LPGVersion").Add("Value", csps.LPGVersion).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "LoadTypePriority").Add("Value", csps.LoadTypePriority.ToString()).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "OfficialSimulationStartTime").Add("Value", csps.OfficialSimulationStartTime.ToString(CultureInfo.InvariantCulture)).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "OfficialSimulationEndTime").Add("Value", csps.OfficialSimulationEndTime.ToString(CultureInfo.InvariantCulture)).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "SelectedRandomSeed").Add("Value", csps.SelectedRandomSeed.ToString(CultureInfo.InvariantCulture)).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "SettlingDays").Add("Value", csps.SettlingDays.ToString(CultureInfo.InvariantCulture)).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "ShowSettlingPeriod").Add("Value", csps.ShowSettlingPeriod.ToString()).ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "TransportationDeviceSet").Add("Value", csps.TransportationDeviceSet?.Name ?? "None").ToDictionary());
            se.AddRow(RowBuilder.Start("Name", "TravelRouteSet").Add("Value", csps.TravelRouteSet?.Name ?? "None").ToDictionary());
            if (Srls == null)
            {
                throw new LPGException("Data Logger was null.");
            }

            Srls.SaveResultEntry(se);
        }
Ejemplo n.º 6
0
        public override void Run(HouseholdKey key, object o)
        {
            DayLightStatus dayLightStatus = (DayLightStatus)o;
            //List<EveryDayLightTimes> daylights = new List<EveryDayLightTimes>();
            var startTimeStep = 0;

            if (!_calcParameters.ShowSettlingPeriodTime)
            {
                startTimeStep = _calcParameters.DummyCalcSteps;
            }
            SaveableEntry se = new SaveableEntry(key, ResultTableDefinition);

            se.AddField("Timestep", SqliteDataType.Integer);
            se.AddField("DateTime", SqliteDataType.Integer);
            se.AddField("Daylight", SqliteDataType.Bit);
            for (var i = startTimeStep; i < dayLightStatus.Status.Count; i++)
            {
                TimeStep ts        = new TimeStep(i, _calcParameters);
                string   timestamp = _dsc.MakeDateStringFromTimeStep(ts);
                se.AddRow(RowBuilder.Start("Timestep", ts.ExternalStep).Add("DateTime", timestamp).Add("Daylight", dayLightStatus.Status[i]).ToDictionary());
                //EveryDayLightTimes edlt = new EveryDayLightTimes(timestamp,timestep, );
                //daylights.Add(edlt);
            }
            _srls.SaveResultEntry(se);
        }
        protected SaveableEntry GetStandardSaveableEntry([NotNull] HouseholdKey key)
        {
            SaveableEntry se = new SaveableEntry(key, ResultTableDefinition);

            se.AddField("Name", SqliteDataType.Text);
            se.AddField("Json", SqliteDataType.Text);
            return(se);
        }
        public override void Run(HouseholdKey key, object o)
        {
            var           objects = (List <IHouseholdKey>)o;
            var           transportationDeviceStateEntries = objects.ConvertAll(x => (TransportationDeviceStateEntry)x).ToList();
            SaveableEntry se = new SaveableEntry(key, ResultTableDefinition);

            se.AddField("Time", SqliteDataType.Integer);
            se.AddField("DateTime", SqliteDataType.Integer);
            se.AddField("DeviceName", SqliteDataType.Text);
            se.AddField("User", SqliteDataType.Text);
            se.AddField("DeviceState", SqliteDataType.Text);
            se.AddField("NumericDeviceState", SqliteDataType.Integer);
            se.AddField("CurrentRange", SqliteDataType.Double);
            se.AddField("CurrentSite", SqliteDataType.Text);
            se.AddField("Json", SqliteDataType.JsonField);
            foreach (var ae in transportationDeviceStateEntries)
            {
                se.AddRow(RowBuilder.Start("Time", ae.TimeStep)
                          .Add("DateTime", ae.DateTime)
                          .Add("DeviceName", ae.TransportationDeviceName)
                          .Add("User", ae.CurrentUser)
                          .Add("DeviceState", ae.TransportationDeviceState)
                          .Add("NumericDeviceState", (int)ae.TransportationDeviceStateEnum)
                          .Add("CurrentRange", ae.CurrentRange)
                          .Add("CurrentSite", ae.CurrentSite)
                          .Add("Json", JsonConvert.SerializeObject(ae, Formatting.Indented)).ToDictionary());
            }
            if (Srls == null)
            {
                throw new LPGException("Data Logger was null.");
            }
            Srls.SaveResultEntry(se);
        }
Ejemplo n.º 9
0
 public void SaveDictionaryCalcParametersTest()
 {
     using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
     {
         wd.ClearDirectory();
         var srl   = new SqlResultLoggingService(wd.WorkingDirectory);
         var hhkey = new HouseholdKey("hh0");
         ResultTableDefinition rtd = new ResultTableDefinition("tbl1", ResultTableID.AffordanceDefinitions, "tabledesc", CalcOption.BasicOverview);
         SaveableEntry         se  = new SaveableEntry(hhkey, rtd);
         se.AddField("Name", SqliteDataType.Text);
         se.AddField("Json", SqliteDataType.Text);
         se.AddRow(RowBuilder.Start("Name", "first").Add("Json", "[]").ToDictionary());
         srl.SaveResultEntry(se);
         wd.CleanUp();
     }
 }
 public override void Run(HouseholdKey key, object o)
 {
     var objects = (List<IHouseholdKey>)o;
     var locationEntries = objects.ConvertAll(x => (TransportationEventEntry)x).ToList();
     SaveableEntry se = new SaveableEntry(key, ResultTableDefinition);
     se.AddField("TimeStep", SqliteDataType.Text);
     se.AddField("PersonName", SqliteDataType.Text);
     se.AddField("Json", SqliteDataType.Text);
     foreach (var locationEntry in locationEntries) {
         se.AddRow(RowBuilder.Start("PersonName", locationEntry.PersonName)
             .Add("TimeStep", locationEntry.Timestep)
             .Add("Json", JsonConvert.SerializeObject(locationEntry, Formatting.Indented)).ToDictionary());
     }
     if (Srls == null)
     {
         throw new LPGException("Data Logger was null.");
     }
     Srls.SaveResultEntry(se);
 }
Ejemplo n.º 11
0
        public override void Run(HouseholdKey key, object o)
        {
            var           objects       = (List <IHouseholdKey>)o;
            var           actionEntries = objects.ConvertAll(x => (TransportationStatus)x).ToList();
            SaveableEntry se            = new SaveableEntry(key, ResultTableDefinition);

            se.AddField("TimeStep", SqliteDataType.Integer);
            se.AddField("Message", SqliteDataType.Text);
            foreach (var actionEntry in actionEntries)
            {
                se.AddRow(RowBuilder.Start("Message", actionEntry.StatusMessage).Add("TimeStep", actionEntry.Timestep).ToDictionary());
            }

            if (Srls == null)
            {
                throw new LPGException("Data Logger was null.");
            }

            Srls.SaveResultEntry(se);
        }
        public override void Run(HouseholdKey key, object o)
        {
            var           objects = (List <IHouseholdKey>)o;
            var           transportationDeviceStateEntries = objects.ConvertAll(x => (ChargingStationState)x).ToList();
            SaveableEntry se = new SaveableEntry(key, ResultTableDefinition);

            se.AddField("Time", SqliteDataType.Integer);
            se.AddField("ChargingStationName", SqliteDataType.Text);
            se.AddField("IsAvailable", SqliteDataType.Bit);
            se.AddField("CarName", SqliteDataType.Text);
            se.AddField("ChargingPower", SqliteDataType.Double);
            se.AddField("Json", SqliteDataType.JsonField);
            foreach (var ae in transportationDeviceStateEntries)
            {
                se.AddRow(RowBuilder.Start("Time", ae.TimeStep)
                          .Add("ChargingStationName", ae.ChargingStationName)
                          .Add("IsAvailable", ae.IsAvailable?1:0)
                          .Add("CarName", ae.ConnectedCarName)
                          .Add("ChargingPower", ae.ChargingPower)
                          .Add("Json", JsonConvert.SerializeObject(ae, Formatting.Indented)).ToDictionary());
            }
            if (Srls == null)
            {
                throw new LPGException("Data Logger was null.");
            }
            Srls.SaveResultEntry(se);
        }
Ejemplo n.º 13
0
        public override void Run(HouseholdKey key, object o)
        {
            var           objects        = (List <IHouseholdKey>)o;
            var           calcVarEntries = objects.ConvertAll(x => (CalcVariableEntry)x).ToList();
            SaveableEntry se             = GetStandardSaveableEntry(key);

            se.AddField("TimeStep", SqliteDataType.Integer);
            foreach (var actionEntry in calcVarEntries)
            {
                se.AddRow(RowBuilder.Start("Name", actionEntry.Name).Add("Timestep", actionEntry.TimeStep)
                          .Add("Json", JsonConvert.SerializeObject(actionEntry, Formatting.Indented)).ToDictionary());
            }
            if (Srls == null)
            {
                throw new LPGException("Data Logger was null.");
            }
            Srls.SaveResultEntry(se);
        }