/// <summary> /// add /// </summary> /// <param name="MeterType"></param> /// <returns></returns> public int Add(MeterType model) { var str = GetInsertStr(model) + " select @@identity"; var dict = GetParameters(model); return(Convert.ToInt32(SqlHelper.Instance.ExecuteScalar(str, dict))); }
public static float CalculateRXMeter(uint thread, uint subrx, MeterType MT) { int channel = id(thread, subrx); double val; switch (MT) { case MeterType.SIGNAL_STRENGTH: val = GetRXAMeter(channel, rxaMeterType.RXA_S_PK); break; case MeterType.AVG_SIGNAL_STRENGTH: val = GetRXAMeter(channel, rxaMeterType.RXA_S_AV); break; case MeterType.ADC_REAL: val = GetRXAMeter(channel, rxaMeterType.RXA_ADC_PK); break; case MeterType.ADC_IMAG: val = GetRXAMeter(channel, rxaMeterType.RXA_ADC_PK); break; case MeterType.AGC_GAIN: val = GetRXAMeter(channel, rxaMeterType.RXA_AGC_GAIN); break; default: val = -400.0; break; } return((float)val); }
public bool Change(int Id, MeterType meterType, Person person, out string Res, bool save = true) { try { if ((from h in cont.StavkaSet where h.Id != Id && h.MeterType.Id == meterType.Id && h.Person.Id == person.Id select h).Any()) { Res = "Уже есть данная ставка у данного человека"; return(false); } var a = Find(Id); if (a == null) { Res = "Нет ставки с данным идентификационным номером"; return(false); } a.MeterType = meterType; a.Person = person; if (save) { cont.SaveChanges(); } Res = "Изменение ставки успешно"; return(true); } catch (Exception e) { Res = e.Message; return(false); } }
public IoMeterBuffer.DurationMeasurement MeterIoRate(string fileName, MeterType type, long size) { var fileIoMetrics = _fileMetrics.GetOrAdd(fileName, fn => new FileIoMetrics(fn, BufferSize, SummaryBufferSize)); IoMeterBuffer buffer; switch (type) { case MeterType.Compression: buffer = fileIoMetrics.Compression; break; case MeterType.JournalWrite: buffer = fileIoMetrics.JournalWrite; break; case MeterType.DataFlush: buffer = fileIoMetrics.DataFlush; break; case MeterType.DataSync: buffer = fileIoMetrics.DataSync; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } void OnFileChange(IoMeterBuffer.MeterItem meterItem) { _ioChanges?.RaiseNotifications(fileName, meterItem); } return(new IoMeterBuffer.DurationMeasurement(buffer, type, size, 0, OnFileChange)); }
public void Update2(MeterType model) { var str = GetUpdateStr2(model); var dict = GetParameters(model); SqlHelper.Instance.ExcuteNon(str, dict); }
public void Add2(MeterType model) { var str = GetInsertStr2(model) + " select @@identity"; var dict = GetParameters(model); SqlHelper.Instance.ExecuteScalar(str, dict); }
internal void GetMeterDetailsForCustomer(int customerId) { using (var context = new TownUtilityBillSystemV2Entities()) { var customerDB = context.CUSTOMERs.Find(customerId); if (customerDB != null) { var customerTypeDB = context.CUSTOMER_TYPEs.Where(mt => mt.ID == customerDB.CUSTOMER_TYPE_ID).FirstOrDefault(); var addressDB = context.ADDRESSes.Where(a => a.ID == customerDB.ADDRESS_ID).FirstOrDefault(); var index = context.INDEXes.Where(i => i.ID == addressDB.INDEX_ID).Select(Index.Get).FirstOrDefault(); var town = context.TOWNs.Where(t => t.ID == addressDB.TOWN_ID).Select(Town.Get).FirstOrDefault(); var street = context.STREETs.Where(s => s.ID == addressDB.STREET_ID).Select(Street.Get).FirstOrDefault(); var building = context.BUILDINGs.Where(b => b.ID == addressDB.BUILDING_ID).Select(Building.GetWithSquareAndImagePath).FirstOrDefault(); var flatPartDB = context.FLAT_PARTs.Where(fp => fp.ID == addressDB.FLAT_PART_ID).FirstOrDefault(); var metersDB = context.METERs.Where(m => m.ADDRESS_ID == addressDB.ID).ToList(); foreach (var m in metersDB) { var meterTypeDB = context.METER_TYPEs.Where(mt => mt.ID == m.METER_TYPE_ID).FirstOrDefault(); var utility = context.UTILITYs.Where(u => u.ID == meterTypeDB.UTILITY_ID).Select(Utility.GetUtilityWithIdAndResourceName).FirstOrDefault(); var meterType = new MeterType() { Id = meterTypeDB.ID, Name = meterTypeDB.NAME, Utility = utility }; Meters.Add(new Meter() { Id = m.ID, SerialNumber = m.SERIAL_NUMBER, ReleaseDate = m.RELEASE_DATE, VarificationDate = m.VARIFICATION_DATE, MeterType = meterType }); } FlatPart flatPart = null; if (flatPartDB != null) { flatPart = FlatPart.Get(flatPartDB); } var customerType = new CustomerType() { Id = customerTypeDB.ID, Name = customerTypeDB.NAME, ResourceName = CustomerType.GetResourceName(customerTypeDB.NAME) }; var account = context.ACCOUNTs.Where(a => a.ID == customerDB.ACCOUNT_ID).Select(Account.Get).FirstOrDefault(); var address = new Address() { Id = addressDB.ID, Index = index, Town = town, Street = street, Building = building, FlatPart = flatPart }; Customer = new Customer() { Id = customerDB.ID, Account = account, Surname = customerDB.SURNAME, Name = customerDB.NAME, Email = customerDB.EMAIL, Phone = customerDB.PHONE, CustomerType = customerType, Address = address }; } else { Customer = null; } } }
public string GetInsertStr2(MeterType metertype) { StringBuilder part1 = new StringBuilder(); StringBuilder part2 = new StringBuilder(); if (metertype.meterTypeNo != null) { part1.Append("meterTypeNo,"); part2.Append("@meterTypeNo,"); } if (metertype.meterTypeName != null) { part1.Append("meterTypeName,"); part2.Append("@meterTypeName,"); } if (metertype.MarkCode != null) { part1.Append("MarkCode,"); part2.Append("@MarkCode,"); } StringBuilder sql = new StringBuilder(); sql.Append("insert into metertype(").Append(part1.ToString().Remove(part1.Length - 1)).Append(") values (").Append(part2.ToString().Remove(part2.Length - 1)).Append(")"); return(sql.ToString()); }
public Meter(string meterId, int primaryAddress, MeterType meterType, string manufacturerId) { MeterId = meterId; PrimaryAddress = primaryAddress; MeterType = meterType; ManufacturerId = manufacturerId; }
public ActionResult EditMeterType(MeterType meterType) { using (var context = new TownUtilityBillSystemEntities()) { if (ModelState.IsValid) { var meterTypeDB = context.METER_TYPE.Find(meterType.Id); meterTypeDB.NAME = meterType.Name; meterTypeDB.UTILITY_ID = meterType.Utility.Id; meterTypeDB.VARIFICATION_PERIOD_YEARS = meterType.VarificationPeriod; context.SaveChanges(); return(RedirectToAction("ShowAllMeterTypes", "Meter")); } var utilitiesDB = context.UTILITY.ToList(); meterType.Utilities = new List <Utility>(); foreach (var u in utilitiesDB) { meterType.Utilities.Add(new Utility() { Id = u.ID, Name = u.NAME }); } return(View()); } }
public CT(MeterType CTMeterType, bool CTIsLadder, JieSuanType CTJieSuanType, int CTLadderNum) { this.CTMeterType = CTMeterType; this.CTIsLadder = CTIsLadder; this.CTJieSuanType = CTJieSuanType; this.CTLadderNum = CTLadderNum; }
public bool Add(MeterType meterType, Person person, out string Res, bool save = true) { try { if ((from a in cont.StavkaSet where a.MeterType.Id == meterType.Id && a.Person.Id == person.Id select a).FirstOrDefault() != null) { Res = "Уже есть данная ставка"; return(false); } Stavka stavka = new Stavka(); stavka.MeterType = meterType; stavka.Person = person; cont.StavkaSet.Add(stavka); if (save) { cont.SaveChanges(); } Res = "Успешное добавление"; return(true); } catch (Exception e) { Res = e.Message; return(false); } }
public bool Change(int Id, string Name, MeterType meterType, out string Res, bool save = true) { try { if ((from h in cont.MeterSet where h.Id != Id && h.Name == Name select h).Any()) { Res = "Уже есть прибор учёта с данным названием"; return(false); } var a = Find(Id); if (a == null) { Res = "Нет прибора учёта с данным идентификационным номером"; return(false); } a.Name = Name; a.MeterType = meterType; if (save) { cont.SaveChanges(); } Res = "Изменение дома успешно"; return(true); } catch (Exception e) { Res = e.Message; return(false); } }
public IoMeterBuffer.DurationMeasurement MeterIoRate(string filename, MeterType type, long size) { var fileIoMetrics = _fileMetrics.GetOrAdd(filename, name => new FileIoMetrics(name, BufferSize, SummaryBufferSize)); IoMeterBuffer buffer; switch (type) { case MeterType.JournalWrite: buffer = fileIoMetrics.JournalWrite; break; case MeterType.DataFlush: buffer = fileIoMetrics.DataFlush; break; case MeterType.DataSync: buffer = fileIoMetrics.DataSync; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } return(new IoMeterBuffer.DurationMeasurement(buffer, type, size)); }
public bool Add(string Name, MeterType meterType, out string Res, bool save = true) { try { if ((from a in cont.MeterSet where a.Name == Name select a).FirstOrDefault() != null) { Res = "Уже есть прибор учёта с данным названием"; return(false); } Meter meter = new Meter(); meter.Name = Name; meter.MeterType = meterType; cont.MeterSet.Add(meter); if (save) { cont.SaveChanges(); } Res = "Успешное добавление"; return(true); } catch (Exception e) { Res = e.Message; return(false); } }
/// <summary> /// Determines the firmware set type from the specified node. /// </summary> /// <param name="Node">The node to check</param> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 09/20/10 SCW 1.00.00 Created // private void DetermineSetType(XmlNode Node) { MeterType DeterminedType = MeterType.Unknown; if (Node.ParentNode != null) { switch (Node.ParentNode.Name) { case XML_HW_3_0: { switch (Node.Name) { case XML_SINGLE: { DeterminedType = MeterType.HW30Single; break; } } break; } } } m_MeterType = DeterminedType; }
/// <summary> /// Create a specific meter. /// </summary> public static Meter CreateMeter(MeterType inMeterType) { switch (inMeterType) { case MeterType.Led: return(new LedMeter()); case MeterType.LedS0: return(new LedS0Meter()); case MeterType.Ferraris: return(new FerrarisMeter()); case MeterType.FerrarisS0: return(new FerrarisS0Meter()); case MeterType.Smart: return(new SmartMeter()); case MeterType.Soladin: return(new Soladin()); case MeterType.SmartS0: return(new SmartS0Meter()); case MeterType.NoMeter: return(new NoMeter()); default: throw new NotImplementedException("Unknown meter type " + inMeterType); } }
public ObjectUnderTestBuilder AddUtilityAccount(MeterType meterType, FuelType fuelType, DateTime activeDate, DateTime?inactiveDate = null) { var servicePoint = new ServicePoint(meterType, fuelType); _objectUnderTest.AddUtilityAccount(servicePoint, activeDate, inactiveDate); return(this); }
private static void AssertUtilityAccount(UtilityAccount utilityAccount, MeterType expectedMeterType, FuelType expectedFuelType, DateTime activeDate, DateTime?inactiveDate) { Assert.NotNull(utilityAccount.ServicePoint, "ServicePoint not created"); Assert.AreEqual(expectedMeterType, utilityAccount.ServicePoint.MeterType, "wrong Fuel Type"); Assert.AreEqual(expectedFuelType, utilityAccount.ServicePoint.FuelType, "wrong Fuel Type"); Assert.AreEqual(activeDate, utilityAccount.ActiveDate, "ActiveDate is wrong"); Assert.AreEqual(inactiveDate, utilityAccount.InactiveDate, "InactiveDate is wrong"); }
public Meter(int size) { this.meter_value = 0F; this.size = size; this.meter_value = 0F; this.meter_type = MeterType.SIGNAL_STRENGTH; this.meter_average_value = 0F; }
public ActionResult EditMeterType(int meterTypeId) { var model = new MeterType(); var meterTypeForEdit = model.GetMeterType(meterTypeId); return(View(meterTypeForEdit)); }
private void AddNewMeter(object param) { MeterType mt = new MeterType() { Name = MeterName, IsDeleted = false, MeterId = Guid.NewGuid(), LastMeasure = LastMeasure, IsApartment = IsApartment, IsBuilding = IsBuilding }; MetersCollection.Add(mt); }
public void DeleteMeterType(MeterType mt) { MeterType metertype = mBMSEntities.MeterTypes.Where(x => x.MeterTypeID == mt.MeterTypeID).SingleOrDefault(); metertype.Active = mt.Active; metertype.DeletedDate = DateTime.Now; metertype.DeletedUserID = mt.DeletedUserID; mBMSEntities.SaveChanges(); }
public ActionResult VehicleType() { int found = 0; int imported = 0; List <string> errors = new List <string> { Environment.NewLine }; using (OldDataManager.Models.OldDataManager context = new OldDataManager.Models.OldDataManager()) { var items = context.VehicleTypes.ToList(); found = items.Count(); foreach (var item in items) { VehicleType existing = DataContext.VehicleTypes.FirstOrDefault(x => x.OriginalId == item.VehicleTypeID); if (existing == null) { int?meterTypeID = null; if (item.MeterTypeID.HasValue) { MeterType type = DataContext.MeterTypes.FirstOrDefault(x => x.OriginalId.Value == item.VehicleTypeID); if (type != null) { meterTypeID = type.MeterTypeId; } } try { DataContext.VehicleTypes.Add(new VehicleType { Active = true, GreaseInterval = item.GreaseInterval, IncludeInDispatch = item.IncludeInDispatch, IncludeInReadyMixDispatch = item.IncludeInReadyMixDispatch, MeterTypeId = meterTypeID, Name = item.VehicleTypeName, NeedsAnnualService = item.NeedsAnnualService, NeedsGrease = item.NeedsGrease, NeedsOil = item.NeedsOil, OilInterval = item.OilInterval, OriginalId = item.VehicleTypeID, ServiceInterval = item.ServiceInterval, }); DataContext.SaveChanges(); imported++; } catch (Exception ex) { errors.Add(item.VehicleTypeID + " error: " + ex.Message); } } } } return(Content("Found " + found + ", imported " + imported + " Vehicle Types.", "text/plain")); }
public BuildingMeterData GetResourceUsageOfBuilding(int buildingID, MeterType meterType, DateTime startDate, DateTime endDate) { if (startDate > endDate) { throw new Exception("startDate must be less than endDate"); } //startDate and endDate need to be in milliseconds since 1970 (Unix Epoch time) double startMillis = Math.Round(ConvertDateTimeToUnixEpochTime(startDate)); double endMillis = Math.Round(ConvertDateTimeToUnixEpochTime(endDate)); string url = "https://apps.uwrf.edu/CampusResourcesAPI/building/" + buildingID + "/meter/" + meterType + "?startTime=" + startMillis + "&endTime=" + endMillis + "&interval=day"; BuildingDataResponse buildingDataResponse = null; HttpWebResponse response = null; try { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.Method = "GET"; response = (HttpWebResponse)request.GetResponse(); StreamReader sr = new StreamReader(response.GetResponseStream()); string responseString = "{\"HistoricalData\":" + sr.ReadToEnd().ToString() + "}"; buildingDataResponse = JsonConvert.DeserializeObject<BuildingDataResponse>(responseString); buildingDataResponse.BuildingID = buildingID; buildingDataResponse.MeterType = meterType ; } catch (WebException e) { if (e.Status == WebExceptionStatus.ProtocolError) { throw new Exception(("Errorcode: " + (int)response.StatusCode)); } else { throw new Exception("Error: " + e.Status); } } finally { if (response != null) { response.Close(); } } return ConvertBuildingDataResponse(buildingDataResponse); }
private void dgvMeterTypeList_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { foreach (DataGridViewRow row in dgvMeterTypeList.Rows) { MeterType meterType = (MeterType)row.DataBoundItem; row.Cells[0].Value = meterType.MeterTypeID; row.Cells[1].Value = meterType.MeterTypeCode; row.Cells[2].Value = meterType.MeterTypeDescription; } }
/// <summary> /// Set the meter to a meter with the specified behaviour. /// </summary> public void SetMeter(MeterType inMeterType, List <UsagePatternSpec> inUsagePatterns) { if (Meter != null) { LogAction("Changing to meter type " + inMeterType); } Meter = Meter.CreateMeter(inMeterType); _usagePatterns = inUsagePatterns; Meter.SetUsagePatterns(inUsagePatterns); }
public MeterSelectForm(MeterType mType) { InitializeComponent(); dataGridView1.AutoGenerateColumns = false; using (DiabetContext dc = new DiabetContext()) { dataGridView1.DataSource = dc.Meters.Where(r => (r.MType == mType)).ToList(); } }
private void btnSave_Click(object sender, EventArgs e) { if (checkValidation()) { if (isEdit) { int editMeterTypeCode = 0; MeterType updateMeterType = (from mt in mbmsEntities.MeterTypes where mt.MeterTypeID == meterTypeID select mt).FirstOrDefault(); if (txtMeterTypeCode.Text != updateMeterType.MeterTypeCode) { editMeterTypeCode = (from mt in mbmsEntities.MeterTypes where mt.MeterTypeCode == txtMeterTypeCode.Text select mt).ToList().Count; } if (editMeterTypeCode > 0) { tooltip.SetToolTip(txtMeterTypeCode, "Error"); tooltip.Show("Meter Type Code is already exist!", txtMeterTypeCode); return; } updateMeterType.MeterTypeCode = txtMeterTypeCode.Text; updateMeterType.MeterTypeDescription = txtMeterTypeDes.Text; updateMeterType.UpdatedUserID = UserID; updateMeterType.UpdatedDate = DateTime.Now; meterTypeController.UpdateMeterType(updateMeterType); MessageBox.Show("Successfully updated Meter Type!", "Update"); isEdit = false; btnSave.Text = "Save"; Clear(); FormRefresh(); } else { MeterType meterType = new MeterType(); int meterTypeCount = 0; meterTypeCount = (from m in mbmsEntities.MeterTypes where m.MeterTypeCode == txtMeterTypeCode.Text && m.Active == true select m).ToList().Count; if (meterTypeCount > 0) { tooltip.SetToolTip(txtMeterTypeCode, "Error"); tooltip.Show("MeterType Code is already exist!", txtMeterTypeCode); return; } meterType.MeterTypeID = Guid.NewGuid().ToString(); meterType.MeterTypeCode = txtMeterTypeCode.Text; meterType.MeterTypeDescription = txtMeterTypeDes.Text; meterType.Active = true; meterType.CreatedUserID = UserID; meterType.CreatedDate = DateTime.Now; meterTypeController.Save(meterType); MessageBox.Show("Successfully registered Meter Type! Please check it in 'Meter Type List'.", "Save Success"); Clear(); FormRefresh(); } } }
public void UpdateMeterType(MeterType mt) { MeterType meterType = mBMSEntities.MeterTypes.Where(x => x.MeterTypeID == mt.MeterTypeID).SingleOrDefault(); meterType.MeterTypeCode = mt.MeterTypeCode; meterType.MeterTypeDescription = mt.MeterTypeDescription; meterType.UpdatedUserID = mt.UpdatedUserID; meterType.UpdatedDate = DateTime.Now; mBMSEntities.MeterTypes.AddOrUpdate(meterType); //requires using System.Data.Entity.Migrations; mBMSEntities.SaveChanges(); }
internal MeterReport(Node node, byte[] payload) : base(node) { if (payload == null) throw new ArgumentNullException(nameof(payload)); if (payload.Length < 3) throw new ReponseFormatException($"The response was not in the expected format. {GetType().Name}: Payload: {BitConverter.ToString(payload)}"); Type = (MeterType)(payload[0] & 0x1F); Value = PayloadConverter.ToFloat(payload.Skip(1).ToArray(), out Scale); Unit = GetUnit(Type, Scale); }
public static string MeterBarLabel(MeterType meterType) { switch (meterType) { case MeterType.EXP: return "Experience meter"; case MeterType.HP: return "Health point meter"; default: return ""; } }
/// <summary> /// Determines the meter type. /// </summary> /// <param name="strDeviceClass">The device class of the meter.</param> /// <param name="fHWVersion">The hardware version</param> /// <param name="bTransDevMeterKey">The meter key bit for transparent devices</param> /// <returns>The meter type.</returns> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 09/20/10 SCW 1.00.00 Created // public static MeterType DetermineMeterType(string strDeviceClass, float fHWVersion, bool bTransDevMeterKey) { MeterType SelectedMeterType = MeterType.Unknown; if (VersionChecker.CompareTo(fHWVersion, HW_VERSION_3_0) > 0) { if (strDeviceClass == ITRA_DEVICE_CLASS) { SelectedMeterType = MeterType.HW30Single; } } return(SelectedMeterType); }
public static string MeterBarInfo(MeterType meterType) { switch (meterType) { case MeterType.EXP: return "This meter shows a character's current amount of experience points and how close you are to levelling up."; case MeterType.HP: return "This meter shows a character's current amount of health points. A full meter means they are at max! ;-)"; default: return ""; } }
public static StatsPanelMeterBar Create(string meterBarHeader, Color color, MeterType type) { GameObject meterBarObject = (GameObject) Instantiate(Resources.Load("GUI/StatsPanel/MeterBar")); StatsPanelMeterBar statsPanelMeterBar = meterBarObject.GetComponent<StatsPanelMeterBar>(); statsPanelMeterBar.header = meterBarHeader; statsPanelMeterBar.label.text = meterBarHeader; statsPanelMeterBar.meterBar.color = color; statsPanelMeterBar.meterType = type; //statsPanelMeterBar.modifierInfoLabel.text = ""; statsPanelMeterBar.Init(); return statsPanelMeterBar; }
public static string GetUnit(MeterType type, byte scale) { var electricityUnits = new[] { "kWh", "kVAh", "W", "pulses", "V", "A", "Power Factor", "" }; var gasUnits = new[] { "cubic meters", "cubic feet", "", "pulses", "", "", "", "" }; var waterUnits = new[] { "cubic meters", "cubic feet", "US gallons", "pulses", "", "", "", ""}; switch (type) { case MeterType.Electric: return electricityUnits[scale]; case MeterType.Gas: return gasUnits[scale]; case MeterType.Water: return waterUnits[scale]; default: return string.Empty; } }
internal MeterSupportedReport(Node node, byte[] payload) : base(node) { if (payload.Length < 2) throw new ReponseFormatException($"The response was not in the expected format. {GetType().Name}: Payload: {BitConverter.ToString(payload)}"); CanReset = (payload[0] & 0x80) != 0; Type = (MeterType)Enum.ToObject(typeof(MeterType), payload[0] & 0x1F); var units = new List<string>(); for (byte i = 0; i < 8; ++i) { if ((payload[1] & (1 << i)) == (1 << i)) { units.Add(MeterReport.GetUnit(Type, i)); } } Units = units.ToArray(); }
public static extern float CalculateRXMeter(uint thread, uint subrx, MeterType MT);
private void sWRToolStripMenuItem_Click(object sender, EventArgs e) { TX_meter_type = MeterType.SWR; }
public async Task ReportFakeUsageForAsync(MeterType meterType) { var data = new PostRequest { HubId = DeviceRegistration.Current.DeviceIdentifier.ToString(), Value = 1, SensorId = _fakeSensorIdentifiers[meterType].ToString(), Timestamp = DateTime.UtcNow }; var messageString = JsonConvert.SerializeObject(data); var message = new Message(Encoding.ASCII.GetBytes(messageString)); await _iotHubClient.SendEventAsync(message); }
public BuildingDataResponse(MeterType meterType, int buildingID) { this.MeterType = meterType; this.BuildingID = buildingID; HistoricalData = new List<HistoricalData>(); }
public static extern float CalculateTXMeter(uint thread,MeterType MT);