private void LoadFormWithBatteryFromComboBox(string serial) { try { // TODO - refactor to use one function GetSelectedData, N/A for Tools BatteryModel batteryModel = ApiHelpers.ApiConnectorHelper.GetSelectedJobData <BatteryModel>(serial, pathBatterySelected).First(); battery_id = batteryModel.Id; editBatteryBoxNumberText.Text = batteryModel.BoxNumber; editBatteryConditionText.Text = batteryModel.BatteryCondition; editBatterySerialOneText.Text = batteryModel.SerialOne; editBatterySerialTwoText.Text = batteryModel.SerialTwo; editBatterySerialThreeText.Text = batteryModel.SerialThr; editBatteryCcdText.Text = batteryModel.CCD; editBatteryInvoiceText.Text = batteryModel.Invoice; editBatteryStatusText.Text = batteryModel.BatteryStatus; editBatteryArrivedText.Text = batteryModel.Arrived; editBatteryContainerText.Text = batteryModel.Container; editBatteryCommentText.Text = batteryModel.Comment; } catch (Exception e) { MessageBox.Show(e.ToString()); } }
public void ConstructorLosiParametri1(string name, double mp, double c, double cc) { Assert.Throws <ArgumentException>(() => { BatteryModel battery = new BatteryModel(name, mp, c, cc); }); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,IsPublic,ChallengeId")] BatteryModel batteryModel) { if (id != batteryModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(batteryModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BatteryModelExists(batteryModel.Id)) { return(NotFound()); } throw; } return(RedirectToAction(nameof(Index), new { challengeId = batteryModel.ChallengeId })); } ViewData["ChallengeId"] = new SelectList(_context.Challenges, "Id", "Id", batteryModel.ChallengeId); return(View(batteryModel)); }
public int AddBattery(BatteryModel model) { var headers = OperationContext.Current.IncomingMessageProperties["httpRequest"]; var token = ((HttpRequestMessageProperty)headers).Headers["Token"]; using (var dbContext = new TokenDbContext()) { ITokenValidator validator = new DatabaseTokenValidator(dbContext); if (validator.IsValid(token) == true) { using (IDbConnection connection = new SqlConnection(GlobalConfig.CnnString("GyrodataTracker"))) { var p = new DynamicParameters(); p.Add("@BoxNumber", model.BoxNumber); p.Add("@BatteryCondition", model.BatteryCondition); p.Add("@SerialOne", model.SerialOne); p.Add("@SerialTwo", model.SerialTwo); p.Add("@SerialThr", model.SerialThr); p.Add("@CCD", model.CCD); p.Add("@Invoice", model.Invoice); p.Add("@BatteryStatus", model.BatteryStatus); p.Add("@Arrived", model.Arrived); p.Add("@Container", model.Container); p.Add("@Comment", model.Comment); p.Add("@Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output); connection.Execute("dbo.spBatteries_Insert", p, commandType: CommandType.StoredProcedure); model.Id = p.Get <int>("@Id"); } } } return(model.Id); }
public void EditBattery(string id, BatteryModel model) { int Id = int.Parse(id); var headers = OperationContext.Current.IncomingMessageProperties["httpRequest"]; var token = ((HttpRequestMessageProperty)headers).Headers["Token"]; using (var dbContext = new TokenDbContext()) { ITokenValidator validator = new DatabaseTokenValidator(dbContext); if (validator.IsValid(token) == true) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString("GyrodataTracker"))) { var p = new DynamicParameters(); p.Add("@Id", Id); p.Add("@BoxNumber", model.BoxNumber); p.Add("@BatteryCondition", model.BatteryCondition); p.Add("@SerialOne", model.SerialOne); p.Add("@SerialTwo", model.SerialTwo); p.Add("@SerialThr", model.SerialThr); p.Add("@CCD", model.CCD); p.Add("@Invoice", model.Invoice); p.Add("@BatteryStatus", model.BatteryStatus); p.Add("@Arrived", model.Arrived); p.Add("@Container", model.Container); p.Add("@Comment", model.Comment); connection.Execute("spBattery_Update", p, commandType: CommandType.StoredProcedure); } } } }
private async Task RunBattery(SolutionModel solution, BatteryModel battery) { // Verificam daca exista deja rezultate pentru bateria si solutia data si daca exista le suprascriem VerifyIfResultExists(solution.Id, battery.Id); var result = new ResultModel { SolutionId = solution.Id, BatteryId = battery.Id }; _context.Results.Add(result); await _context.SaveChangesAsync(); foreach (var test in battery.Tests) { var testResult = CodeRunner.RunCode(solution.Code, test, solution.ProgrammingLanguage.LanguageCode); testResult.ResultId = result.Id; testResult.TestId = test.Id; var expectedOutput = test.ExpectedOutput.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace("\n", "").Replace(" ", ""); var resultedOutput = testResult.ResultedOutput.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace("\t", "").Replace("\n", "").Replace(" ", ""); var pointsGiven = expectedOutput.Equals(resultedOutput) ? test.Points : 0; testResult.PointsGiven = pointsGiven; if (testResult.ExecutionTime <= solution.Challenge.ExecutionTimeLimit && testResult.Memory <= solution.Challenge.MemoryLimit) { // inserare in tabelul de rezultate ale testelor _context.TestResults.Add(testResult); _context.SaveChanges(); } } }
public void ConstructorDobriParametri(string name, double mp, double c, double cc) { BatteryModel battery = new BatteryModel(name, mp, c, cc); Assert.AreEqual(name, battery.Name); Assert.AreEqual(mp, battery.MaxPower); Assert.AreEqual(c, battery.Capacity); Assert.AreEqual(cc, battery.CurrentCapacity); }
public void ConstructorPrazan() { BatteryModel battery = new BatteryModel(); Assert.AreEqual("", battery.Name); Assert.AreEqual(0, battery.MaxPower); Assert.AreEqual(0, battery.Capacity); Assert.AreEqual(0, battery.CurrentCapacity); Assert.AreEqual(SmartHomeEnergySystem.Enums.BatteryEnum.IDLE, battery.State); }
public bool IsTriggeredAlarm(AlarmModel alarm, BatteryModel battery) { if (alarm.AlarmTrigger == battery.Value || alarm.AlarmTrigger >= battery.Value) { return true; } else { return false; } }
public async Task <IActionResult> Create([Bind("Name,IsPublic,ChallengeId")] BatteryModel batteryModel) { if (ModelState.IsValid) { _context.Add(batteryModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { challengeId = batteryModel.ChallengeId })); } return(View(batteryModel)); }
public IActionResult GetBatteryConditionsByBatteryModel(int id) { BatteryModel batteryModel = db.BatteryModels.Include(bb => bb.BatteryBrand) .ToList().Find(bm => bm.BatteryModelId == id); ViewBag.BatteryModel = batteryModel; return(View(db.BatteryConditions.Include(ad => ad.AddressByDates) .ThenInclude(h => h.House) .ThenInclude(s => s.Street) .ToList().FindAll(b => b.BatteryModel == batteryModel) )); }
public void loadBatteries() { Batteries = new ObservableCollection <BatteryModel>(); using (dbSHESEntities entity = new dbSHESEntities()) { List <BatteryTable> bateries = entity.BatteryTables.ToList <BatteryTable>(); foreach (var bat in bateries) { BatteryModel battery = new BatteryModel(bat.Name, (double)bat.MaxPower, (double)bat.Capacity, (double)bat.CurrentCapacity); battery.CapacityMin = (double)bat.CapacityMin; battery.State = (BatteryEnum)Enum.Parse(typeof(BatteryEnum), bat.State); Batteries.Add(battery); } }; }
private void editBatteryButton_Click(object sender, EventArgs e) { BatteryModel model = new BatteryModel( editBatteryBoxNumberText.Text, editBatteryConditionText.Text, editBatterySerialOneText.Text, editBatterySerialTwoText.Text, editBatterySerialThreeText.Text, editBatteryCcdText.Text, editBatteryInvoiceText.Text, editBatteryStatusText.Text, editBatteryArrivedText.Text, editBatteryContainerText.Text, editBatteryCommentText.Text ); //MessageBox.Show(battery_id.ToString()); ApiHelpers.ApiConnectorHelper.EditData <BatteryModel>(battery_id.ToString(), model, pathBatteryEdit); }
public BatteryViewModel() { battery = new BatteryModel() { Level = Battery.ChargeLevel, State = Battery.State, Source = Battery.PowerSource }; Battery.BatteryInfoChanged += (s, e) => { StatusChangeCommand.Execute(e); }; StatusChangeCommand = new Command <BatteryInfoChangedEventArgs>((e) => { Level = e.ChargeLevel; State = e.State; Source = e.PowerSource; }); }
private void addBatteryButton_Click(object sender, EventArgs e) { int result = 0; if (ValidateForm().Keys.First()) { BatteryModel model = new BatteryModel( batteryBoxNumberText.Text, // check length, pattern conditionComboBox.Text, batterySerialOneText.Text, // check length, pattern batterySerialTwoText.Text, // check length, pattern batterySerialThreeText.Text, // check length, pattern batteryCcdText.Text, batteryInvoiceText.Text, // check length, pattern batteryStatusText.Text, // check length batteryArrivedText.Text, // check length batteryContainerText.Text, // check length batteryCommentText.Text // check length ); result = ApiHelpers.ApiConnectorHelper.SaveData <BatteryModel>(model, pathBatteriesAdd); if (result != 0) { MessageBox.Show($"Battery { batterySerialOneText.Text } added"); } else { MessageBox.Show("Smth went wrong"); } } else { ErrorForm errorForm = new ErrorForm(ValidateForm().Values.First()); errorForm.Show(); } }
public Battery(int IdleHours = 0, int TalkHours = 0, BatteryModel modelBattery = BatteryModel.LithiumLon) { this.IdleHours = IdleHours; this.TalkHours = TalkHours; this.batteryModel = modelBattery; }
public static Dictionary <bool, List <string> > ValidateBattery(Dictionary <string, string> batteryFields) { Dictionary <bool, List <string> > result = new Dictionary <bool, List <string> >(); bool output = true; List <string> errorsBattery = new List <string>(); // Box validation string batteryBoxNumber = batteryFields["batteryBoxNumber"]; string batteryBoxPattern = @"^([1-9]+)$"; if (batteryBoxNumber.Length == 0) { output = false; errorsBattery.Add("Box couldn't be empty"); } if (batteryBoxNumber.Length > 2) { output = false; errorsBattery.Add("Box Length should be <= 2"); } if (!UnitValidationRegex.Validate(batteryBoxNumber, batteryBoxPattern)) { output = false; errorsBattery.Add("Wrong Box pattern"); } // SerialOne validation if (batteryFields["serialOne"].Length != 0) { string serialOne = batteryFields["serialOne"]; string serialOnePattern = @"^(S1-[0-9]{4})-([0-9]{4})$"; BatteryModel battery = ApiHelpers.ApiConnectorHelper.GetSelectedJobData <BatteryModel>(serialOne, PathBatterySelected).FirstOrDefault(); if (battery != null) { output = false; errorsBattery.Add($"Battery {serialOne} already exists"); } if (serialOne.Length == 0) { output = false; errorsBattery.Add("Serial 1 couldn't be empty"); } if (serialOne.Length > 12) { output = false; errorsBattery.Add("Serial 1 Length should be = 12"); } if (!UnitValidationRegex.Validate(serialOne, serialOnePattern)) { output = false; errorsBattery.Add("Wrong Serial 1 pattern"); } } // CCD validation if (batteryFields["batteryCCD"].Length != 0) { string batteryCCD = batteryFields["batteryCCD"]; string batteryCcdPattern = @"^([0-9]{8})-([0-9]{6})-([0-9]{7})$"; // 10707090-021017-0013452 if (batteryCCD.Length == 0) { output = false; errorsBattery.Add("CCD couldn't be empty"); } if (batteryCCD.Length > 25) { output = false; errorsBattery.Add("CCD Length should be <= 25"); } if (!UnitValidationRegex.Validate(batteryCCD, batteryCcdPattern)) { output = false; errorsBattery.Add("Wrong CCD pattern"); } } // Invoice validation if (batteryFields["batteryInvoice"].Length != 0) { string batteryInvoice = batteryFields["batteryInvoice"]; string batteryInvoicePattern = @"^([A-Z])\/([0-9]{2})\/([0-9]{2})$"; if (batteryInvoice.Length == 0) { output = false; errorsBattery.Add("Invoice couldn't be empty"); } if (batteryInvoice.Length > 10) { output = false; errorsBattery.Add("Invoice Length should be <= 10"); } if (!UnitValidationRegex.Validate(batteryInvoice, batteryInvoicePattern)) { output = false; errorsBattery.Add("Wrong Invoice pattern"); } } // Arrived Date validation if (batteryFields["batteryArrived"].Length != 0) { string batteryArrived = batteryFields["batteryArrived"]; string batteryArrivedPattern = @"^([0-9]{4})-([0-9]{2}-([0-9]{2}))$"; if (batteryArrived.Length == 0) { output = false; errorsBattery.Add("Arriving date couldn't be empty"); } if (batteryArrived.Length > 10) { output = false; errorsBattery.Add("Arriving date Length should be <= 10"); } if (!UnitValidationRegex.Validate(batteryArrived, batteryArrivedPattern)) { output = false; errorsBattery.Add("Wrong Arriving date pattern"); } } // Container validation if (batteryFields["batteryContainer"].Length != 0) { string batteryContainer = batteryFields["batteryContainer"]; if (batteryContainer.Length > 20) { errorsBattery.Add("Container Length should be <= 20"); } } result.Add(output, errorsBattery); return(result); }
private void ManageBattery(SnackbarPage arg1, BatteryModel batteryModel) { NetworkStatus.Text = $"Battery {batteryModel.State.ToText()} at level {batteryModel.ChargeLevel * 100}%"; }
public Battery(BatteryModel model, uint hoursTalk) : this(model, hoursTalk, null) { }
private void RefreshStatus() { _batteryModel = SetStatusBattery(); }
private bool ExeBusinessBottom(ref string reStr) { List <string> recvBarcodesBuf = barcodeRW.GetBarcodesBuf(); if (recvBarcodesBuf.Contains("START") || recvBarcodesBuf.Contains("start")) { this.currentTaskPhase = 1; logRecorder.AddDebugLog(nodeName, "流程开始"); this.db1ValsToSnd[0] = 2; //开始扫码 } if (this.currentTaskPhase < 1) { //待机状态 this.db1ValsToSnd[0] = 1; return(true); } if (this.currentTaskPhase == 3) { System.Threading.Thread.Sleep(3000); this.db1ValsToSnd[0] = 1; this.currentTaskPhase = 0; } switch (this.currentTaskPhase) { case 1: { //给PLC提示,开始扫码 barcodeRW.ClearBarcodesBuf(); this.workerID = string.Empty; this.modID = string.Empty; this.batteryID = string.Empty; this.currentTaskPhase++; currentTaskDescribe = "开始,等待扫码、模组绑定"; break; } case 2: { recvBarcodesBuf = barcodeRW.GetBarcodesBuf(); for (int i = 0; i < recvBarcodesBuf.Count(); i++) { //Console.WriteLine(nodeName + ",扫码:" + recvBarcodesBuf[i]); if (recvBarcodesBuf[i].Length <= 0) { continue; } if (recvBarcodesBuf[i].Substring(0, 1).ToUpper() == "M" && recvBarcodesBuf[i].Length > 15) { //模组码 if (string.IsNullOrWhiteSpace(modID)) { Console.WriteLine(string.Format("{0},扫到模组:{1}", nodeName, recvBarcodesBuf[i])); } this.modID = recvBarcodesBuf[i]; } else if (recvBarcodesBuf[i].Substring(0, 2).ToUpper() == "NB") { if (string.IsNullOrWhiteSpace(workerID)) { Console.WriteLine(string.Format("{0},扫到员工码:{1}", nodeName, recvBarcodesBuf[i])); } this.workerID = recvBarcodesBuf[i]; } else { //电池条码 if (string.IsNullOrWhiteSpace(batteryID)) { Console.WriteLine(string.Format("{0},扫到电池码:{1}", nodeName, recvBarcodesBuf[i])); } this.batteryID = recvBarcodesBuf[i]; } } if (string.IsNullOrEmpty(this.workerID)) { break; } if (string.IsNullOrEmpty(this.modID)) { break; } if (string.IsNullOrEmpty(this.batteryID)) { break; } //检查模组是否已经存在 if (batModBll.Exists(this.modID)) { currentTaskDescribe = string.Format("已经存在模组{0},绑定完成", this.modID); this.db1ValsToSnd[0] = 3; //绑定完成 this.currentTaskPhase++; break; } else { //1 先检索所有电池 Tb_CheckDataModel tbBatModel = tbBatteryDataBll.GetModel(this.batteryID); if (tbBatModel == null) { Console.WriteLine(string.Format("不存在的电池条码:{0}", this.batteryID)); return(false); } string strWhere = string.Format("tf_Group='{0}'", tbBatModel.tf_Group); List <Tb_CheckDataModel> batterys = tbBatteryDataBll.GetModelList(strWhere); BatteryModuleModel batModule = new BatteryModuleModel(); batModule.batchName = tbBatModel.FileName;//批次 batModule.asmTime = System.DateTime.Now; batModule.batModuleID = this.modID; batModule.curProcessStage = EnumModProcessStage.模组焊接下盖.ToString(); batModule.downcapOPWorkerID = this.workerID; batModule.palletBinded = false; batModBll.Add(batModule); // foreach (Tb_CheckDataModel tbBattery in batterys) { BatteryModel batteryModel = new BatteryModel(); batteryModel.batteryID = tbBattery.BarCode; batteryModel.batModuleID = this.modID; batteryModel.batModuleAsmTime = System.DateTime.Now; batteryBll.Add(batteryModel); } //添加生产过程记录 AddProcessRecord(this.modID, EnumModProcessStage.模组焊接下盖.ToString()); } this.db1ValsToSnd[0] = 3; //绑定完成 currentTaskDescribe = string.Format("模组{0},绑定完成", this.modID); this.currentTaskPhase++; break; } case 3: { barcodeRW.ClearBarcodesBuf(); break; } default: break; } return(true); }
public override bool ExeBusiness(ref string reStr) { if (SysCfgModel.SimMode) { if (this.nodeID != "5001") { return(true); } //test string[] testBatcodes = new string[] { "bat0001", "bat0004" }; string[] testModcodes = new string[] { "MODT0001", "MODT0002" }; string opWorkerID = "W12345"; for (int i = 0; i < 2; i++) { string modBarcode = testModcodes[i]; string batBarcode = testBatcodes[i]; //检查模组是否已经存在 if (batModBll.Exists(modBarcode)) { continue; } //绑定 //1 先检索所有电池 Tb_CheckDataModel tbBatModel = tbBatteryDataBll.GetModel(batBarcode); string strWhere = string.Format("tf_Group='{0}'", tbBatModel.tf_Group); List <Tb_CheckDataModel> batterys = tbBatteryDataBll.GetModelList(strWhere); BatteryModuleModel batModule = new BatteryModuleModel(); batModule.asmTime = System.DateTime.Now; batModule.batModuleID = modBarcode; batModule.curProcessStage = EnumModProcessStage.模组装配下盖.ToString(); batModule.topcapOPWorkerID = opWorkerID; batModule.palletBinded = false; batModBll.Add(batModule); // foreach (Tb_CheckDataModel tbBattery in batterys) { BatteryModel batteryModel = new BatteryModel(); batteryModel.batteryID = tbBattery.BarCode; batteryModel.batModuleID = modBarcode; batteryModel.batModuleAsmTime = System.DateTime.Now; batteryBll.Add(batteryModel); } //添加生产过程记录 AddProcessRecord(modBarcode, EnumModProcessStage.模组装配下盖.ToString()); //ModPsRecordModel modRecord = new ModPsRecordModel(); //modRecord.RecordID = System.Guid.NewGuid().ToString(); //modRecord.processRecord = EnumModProcessStage.模组装配.ToString(); //modRecord.batModuleID = modBarcode; //modRecord.recordTime = System.DateTime.Now; //modPsRecordBll.Add(modRecord); } } else { // string startFlagStr = "START"; return(ExeBusinessBottom(ref reStr)); } return(true); }
public DeleteBatteryCommand(BatteryModel batteryToDelete) { this.batteryToDelete = batteryToDelete; }
public Battery(BatteryModel modelOfBattery, BatteryType typeOfBattery) : this(typeOfBattery) { this.BatteryModel = modelOfBattery; }
private BatteryModel SetStatusBattery() { BatteryModel model = new BatteryModel(); model = _batteryService.GetBatteryInformation(); return model; }
public BatteryAlarmForm() { InitializeComponent(); //Registry Model _regModel = new RegistryModel() { KeyName = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", ValueName = "ARTHA.BatteryAlarm.AutoRun", Value = "C:\\Program Files\\ARTHA.BatteryAlarm\\ARTHA.BatteryAlarm.exe\" -autorun", RegValueKind = RegistryValueKind.String }; //registry Factory Instansiate _regFactory = new RegistryFactory(_regModel); //Checked or not if (_regFactory.IsRegistryExist()) { chkAutorun.Checked = true; } else { chkAutorun.Checked = false; } // general seting for xml model and factory _xmlFactory = new XmlValueFactory(XmlConstant.XmlFileLocation); _xmlModel = new XmlModel() { ElementName = XmlConstant.XmlElementName, AttrKeyName = XmlConstant.XmlKey, AttrValueName = XmlConstant.XmlValue }; this.ShowInTaskbar = false; //sound Player _soundPlayer = new SoundPlayer(); //timer _timer = new Timer(); _timer.Tick += new EventHandler(BatteryTimer_Tick); _timer.Interval = Constant.DefaultIntervalTimer; _timer.Start(); //instansiate service and model _batteryService = new BatteryService(); _alarmService = new AlarmService(); _alarmModel = new AlarmModel(); _batteryModel = new BatteryModel(); //populate Batery Level combobox cmbBateryLevel.DataSource = PopulateComboBox(Constant.MinBateryLevel, Constant.MaxBateryLevel, Constant.MultipleIterationValue); InitializeAlarmTrigger(); //button close Event Handler btnMinimize.Click += new EventHandler(btnMinimize_Click); //button open file event Handler btnOpenFile.Click += new EventHandler(btnOpenFile_Click); //button save setting event handler btnSaveSetting.Click += new EventHandler(btnSaveSetting_Click); //label Warning LabelTitle.Text = Constant.AppName; LabelTitle.AutoSize = Constant.LabelSet.AutoSize; LabelTitle.Font = Constant.LabelSet.Font; //button Stop Sound Event Handler btnStopSound.Click += new EventHandler(btnStopSound_Click); //label prosen label2.Text = Constant.Prosen; }
public Battery(BatteryModel model, uint hoursTalk, string idleTime) { this.Model = model; this.IdleTime = idleTime; this.HoursTalk = hoursTalk; }
public Battery(BatteryModel batteryModel) { this.batteryModel = batteryModel; this.hoursIddle = (decimal)this.batteryModel / 5; this.hoursTalk = (decimal)this.batteryModel / 250; }
public Battery(BatteryModel model, double hoursIdle, double hoursTalk) { this.Model = model; this.HoursIdle = hoursIdle; this.HoursTalk = hoursTalk; }