private void filterAndSave(string line) { //split timestamp and value string[] substrings = line.Split(' '); if (substrings.Length > 1) { if (this.starttime != new DateTime(2000, 1, 1) && this.endtime != new DateTime(2000, 1, 1)) //check if time filter is set { filterByTime(this.starttime, this.endtime); //check if timestamp fits between start and endtime } else { fitsTimeFilter = true; } if (this.types != null && fitsTimeFilter) //check if any type filters are set and if time is right { filterByType(); } else { fitsTypeFilter = true; } if (this.application != null && fitsTimeFilter && fitsTypeFilter) //check if any application filters are set and if time and types are right { filterByApplication(); } else { fitsApplicationFilter = true; } if (fitsTimeFilter && fitsTypeFilter && fitsApplicationFilter) //check if data fits all filters { temp = new MeterData(REDDMeter.GetMeterId()); temp.SetTimestamp(substrings[0]); temp.SetPowerP1(Convert.ToDouble(substrings[1], CultureInfo.InvariantCulture)); myDatabase.InsertMeterDataIntoDb(temp); } fitsTimeFilter = false; fitsTypeFilter = false; fitsApplicationFilter = false; } }
protected override void fillDBWithMeters() { CustomerData tempCustomer = new CustomerData(); int customerId = tempCustomer.FillEmptyCustomer(); myDatabase.InsertCustomerData(tempCustomer); MeterManufactorData tempMeterManufactor = new MeterManufactorData(); int meterManufactorId = tempMeterManufactor.FillEmptyMeterManufactor(); myDatabase.InsertMeterManufactorData(tempMeterManufactor); MeterProtocolData tempMeterProtocol = new MeterProtocolData(); int meterProtocolId = tempMeterProtocol.FillEmptyMeterProtocol(); myDatabase.InsertMeterProtocolData(tempMeterProtocol); MeterTypeData tempMeterType = new MeterTypeData(); int meterTypeId = tempMeterType.FillEmptyMeterType(); myDatabase.InsertMeterTypeData(tempMeterType); for (int i = 0; i < 81; i++) { int HomeNbr = i / 9; int ApplicationNbr = i % 9; MeterManagementData GREENDMeter = new MeterManagementData(); GREENDMeter.SetCustomerId(customerId); GREENDMeter.SetManufactorId(meterManufactorId); GREENDMeter.SetProtolId(meterProtocolId); GREENDMeter.SetTypeId(meterTypeId); GREENDMeter.SetDescribtion("GREEND-" + HomeNbr + "-" + ApplicationNbr); GREENDMeter.SetKey("not availiable"); GREENDMeter.SetPeriod(1); GREENDMeter.SetPort("not availiable"); GREENDMeter.SetSerial("not availiable"); GREENDMeter.SetActive(true); myDatabase.InsertMeterManagementData(GREENDMeter); Tuple <int, ApplicationEnum> temp = new Tuple <int, ApplicationEnum>(GREENDMeter.GetMeterId(), this.getEnumFromGREENDEnumId((HomeNbr * 9) + ApplicationNbr)); this.meterList.Add(temp); } }
protected override void fillDBWithMeters() { CustomerData tempCustomer = new CustomerData(); int customerId = tempCustomer.FillEmptyCustomer(); myDatabase.InsertCustomerData(tempCustomer); MeterManufactorData tempMeterManufactor = new MeterManufactorData(); int meterManufactorId = tempMeterManufactor.FillEmptyMeterManufactor(); myDatabase.InsertMeterManufactorData(tempMeterManufactor); MeterProtocolData tempMeterProtocol = new MeterProtocolData(); int meterProtocolId = tempMeterProtocol.FillEmptyMeterProtocol(); myDatabase.InsertMeterProtocolData(tempMeterProtocol); MeterTypeData tempMeterType = new MeterTypeData(); int meterTypeId = tempMeterType.FillEmptyMeterType(); myDatabase.InsertMeterTypeData(tempMeterType); MeterManagementData ADRESMeter = new MeterManagementData(); ADRESMeter.SetCustomerId(customerId); ADRESMeter.SetManufactorId(meterManufactorId); ADRESMeter.SetProtolId(meterProtocolId); ADRESMeter.SetTypeId(meterTypeId); ADRESMeter.SetDescribtion("ADRES-01-01"); ADRESMeter.SetKey("not availiable"); ADRESMeter.SetPeriod(1); ADRESMeter.SetPort("not availiable"); ADRESMeter.SetSerial("not availiable"); ADRESMeter.SetActive(true); myDatabase.InsertMeterManagementData(ADRESMeter); this.ADRESMeterId = ADRESMeter.GetMeterId(); }
protected override void fillDBWithMeters() { CustomerData tempCustomer = new CustomerData(); int customerId = tempCustomer.FillEmptyCustomer(); myDatabase.InsertCustomerData(tempCustomer); MeterManufactorData tempMeterManufactor = new MeterManufactorData(); int meterManufactorId = tempMeterManufactor.FillEmptyMeterManufactor(); myDatabase.InsertMeterManufactorData(tempMeterManufactor); MeterProtocolData tempMeterProtocol = new MeterProtocolData(); int meterProtocolId = tempMeterProtocol.FillEmptyMeterProtocol(); myDatabase.InsertMeterProtocolData(tempMeterProtocol); MeterTypeData tempMeterType = new MeterTypeData(); int meterTypeId = tempMeterType.FillEmptyMeterType(); myDatabase.InsertMeterTypeData(tempMeterType); ///Create whole houses meter for (int i = 0; i < 4; i++) { MeterManagementData UKDALEMeter = new MeterManagementData(); UKDALEMeter.SetCustomerId(customerId); UKDALEMeter.SetManufactorId(meterManufactorId); UKDALEMeter.SetProtolId(meterProtocolId); UKDALEMeter.SetTypeId(meterTypeId); UKDALEMeter.SetDescribtion("UKDALE-" + i + "-ALL"); UKDALEMeter.SetKey("not availiable"); UKDALEMeter.SetPeriod(1); UKDALEMeter.SetPort("not availiable"); UKDALEMeter.SetSerial("not availiable"); UKDALEMeter.SetActive(true); myDatabase.InsertMeterManagementData(UKDALEMeter); int tempMeterId = UKDALEMeter.GetMeterId(); Tuple <int, ApplicationEnum> temp; switch (i) { case 0: { temp = new Tuple <int, ApplicationEnum>(tempMeterId, ApplicationEnum.UKDALEwholeHouse1); break; } case 1: { temp = new Tuple <int, ApplicationEnum>(tempMeterId, ApplicationEnum.UKDALEwholeHouse2); break; } case 2: { temp = new Tuple <int, ApplicationEnum>(tempMeterId, ApplicationEnum.UKDALEwholeHouse3); break; } case 3: { temp = new Tuple <int, ApplicationEnum>(tempMeterId, ApplicationEnum.UKDALEwholeHouse4); break; } case 4: { temp = new Tuple <int, ApplicationEnum>(tempMeterId, ApplicationEnum.UKDALEwholeHouse5); break; } default: { temp = new Tuple <int, ApplicationEnum>(tempMeterId, ApplicationEnum.None); break; } } this.housesList.Add(temp); } String pathToUKDALEAplliances = "UKDaleAppliances\\"; for (int i = 1; i <= 5; i++) { Console.WriteLine("working File: " + i); using (StreamReader file = new StreamReader(pathToUKDALEAplliances + "UKDALEdat_" + i + ".txt")) { if (file != null) { String line = ""; while ((line = file.ReadLine()) != null) { MeterManagementData UKDALEMeter = new MeterManagementData(); UKDALEMeter.SetCustomerId(customerId); UKDALEMeter.SetManufactorId(meterManufactorId); UKDALEMeter.SetProtolId(meterProtocolId); UKDALEMeter.SetTypeId(meterTypeId); String[] applicationParts = line.Split(' '); int applicationNumber = Int32.Parse(applicationParts[0]); ApplicationEnum foundApplicationEnum = this.FindApplicationEnumByString(applicationParts[1]); UKDALEMeter.SetDescribtion("UKDALE-" + (i - 1) + "-" + applicationNumber); UKDALEMeter.SetKey("not availiable"); UKDALEMeter.SetPeriod(1); UKDALEMeter.SetPort("not availiable"); UKDALEMeter.SetSerial("not availiable"); UKDALEMeter.SetActive(true); myDatabase.InsertMeterManagementData(UKDALEMeter); int tempMeterId = UKDALEMeter.GetMeterId(); int[] tempTupel = new int[2]; tempTupel[0] = tempMeterId; tempTupel[1] = applicationNumber; Tuple <int[], ApplicationEnum> temp = new Tuple <int[], ApplicationEnum>(tempTupel, foundApplicationEnum); switch (i) { case 1: { this.house1ApplicationList.Add(temp); break; } case 2: { this.house2ApplicationList.Add(temp); break; } case 3: { this.house3ApplicationList.Add(temp); break; } case 4: { this.house4ApplicationList.Add(temp); break; } case 5: { this.house5ApplicationList.Add(temp); break; } } } } } } }