public void DobriParametri() { evcg.SendRegime(plug, rezim); Assert.AreNotEqual(null, evcg); Assert.AreEqual(plug, EVChargerGUI.plugBuffer); Assert.AreEqual(rezim, EVChargerGUI.rezimBuffer); }
private void BtnChange_Click(object sender, RoutedEventArgs e) { //parsirati unos svaki ChannelFactory <ISolarPanelGUI> SolarPanelChannel = new ChannelFactory <ISolarPanelGUI>("ISolarPanelGUI"); ISolarPanelGUI proxySP = SolarPanelChannel.CreateChannel(); ChannelFactory <IEVChargerGUI> EVChargerChannel = new ChannelFactory <IEVChargerGUI>("IEVChargerGUI"); IEVChargerGUI proxyEV = EVChargerChannel.CreateChannel(); ChannelFactory <IConsumerGUI> ConsumerChannel = new ChannelFactory <IConsumerGUI>("IConsumerGUI"); IConsumerGUI proxyConsumer = ConsumerChannel.CreateChannel(); ChannelFactory <IUtilityGUI> UtilityChannel = new ChannelFactory <IUtilityGUI>("IUtilityGUI"); IUtilityGUI proxyUtility = UtilityChannel.CreateChannel(); double sunIntensity = 0; var consumerRezim = Common.Enums.ConsumerRezim.OFF; int consumerID = 0; var ev = Common.Enums.BatteryRezim.PRAZNJENJE; double util = 0; if (txtSun.Text != null && txtSun.Text != "") { if (double.TryParse(txtSun.Text, out sunIntensity) && sunIntensity >= 0 && sunIntensity <= 1) { proxySP.ChangeSunIntensity(sunIntensity); txtSun.Text = ""; } else { throw new ArgumentOutOfRangeException("Intenzitet Sunca mora biti broj u intervalu 0-1!"); } } if (txtConsumerId.Text != null && txtConsumerId.Text != "") { if (Int32.TryParse(txtConsumerId.Text, out consumerID)) { if (cmbBoxConsumer.Text != null && cmbBoxConsumer.Text != "") { switch (cmbBoxConsumer.Text) { case "ON": consumerRezim = Enums.ConsumerRezim.ON; break; default: consumerRezim = Enums.ConsumerRezim.OFF; break; } Trace.TraceInformation("GUI sending: Consumer id-" + consumerID + ", state-" + consumerRezim.ToString()); proxyConsumer.ChangeConsumerState(consumerID, consumerRezim); txtConsumerId.Text = ""; } } else { throw new ArgumentOutOfRangeException("Id potrosaca mora biti nenegativan broj!"); } } if (cmbBoxBatteryRegime.Text != null && cmbBoxBatteryRegime.Text != "") { switch (cmbBoxBatteryRegime.Text) { case "PUNJENJE": ev = Enums.BatteryRezim.PUNJENJE; break; default: ev = Enums.BatteryRezim.PRAZNJENJE; break; } Trace.TraceInformation("GUI to EV: " + Convert.ToBoolean(cmbBoxBatteryOnPlug.Text) + " " + ev.ToString()); proxyEV.SendRegime(Convert.ToBoolean(cmbBoxBatteryOnPlug.Text), ev); } if (txtUtilityPrice.Text != null && txtUtilityPrice.Text != "") { if (double.TryParse(txtUtilityPrice.Text, out util) && util >= 0) { util = double.Parse(txtUtilityPrice.Text); proxyUtility.SendPrice(util); txtUtilityPrice.Text = ""; } else { throw new ArgumentOutOfRangeException("Cena elektrodistribucije mora biti pozitivan broj!"); } } }