public override void ParseDirectory() { //low_freq string low_freq = this.Path + "\\00_original Data\\low_freq"; string[] houseEntries = Directory.GetFileSystemEntries(low_freq); foreach (string house in houseEntries) { Console.WriteLine("House: " + house[house.Length - 1]); string[] fileEntries = Directory.GetFileSystemEntries(house); //read the labels file StreamReader reader = new StreamReader(house + "\\labels.dat"); string labelFile = reader.ReadToEnd().Replace("\r\n", "\n").Replace("\n\r", "\n"); //create a seperate string for each label string[] labels = labelFile.Split(new char[] { '\n' }); for (int i = 0; i < labels.Length; i++) { //split label name and number (tmp[0] = number, tmp[1] = name) string[] tmp = labels[i].Split(); for (int j = 0; j < fileEntries.Length; j++) { //search through the files untill the file that belongs to the label is found if ((fileEntries[j].Replace((house + "\\"), "")).Equals("channel_" + tmp[0] + ".dat")) { REDDMeter = new MeterManagementData(); REDDMeter.SetDescribtion("REDD-0" + house[house.Length - 1]); processFile_LowFreq(tmp[1], fileEntries[j]); } } } } }
private void processFile_LowFreq(string label, string file) { ApplicationEnum application = getApplication(label); if ((int)application < 10) { REDDMeter.SetDescribtion(REDDMeter.GetDescription() + "-0" + (int)application); } else { REDDMeter.SetDescribtion(REDDMeter.GetDescription() + "-" + (int)application); } fillDBWithMeters(); processFile(file); Console.WriteLine("Done"); }
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; } } } } } } }