public double GetTotalVolume(Hose hose) { int fPumpID = 0, fHoseID = 0; GetForecourtHoseID(hose.ID, ref fPumpID, ref fHoseID); var status = string.Empty; var result = _wayneIO.SendAndReceive(WayneCommands.GetTotalVolume, fPumpID.ToString().PadLeft(2, '0'), ref status); return double.Parse(result.Substring(13 + (17 * (fHoseID - 1)), 12)) / 100; }
public void SetPrice(Hose hose, double price) { int fPumpID = 0, fHoseID = 0; GetForecourtHoseID(hose.ID, ref fPumpID, ref fHoseID); var data = fPumpID.ToString().PadLeft(2, '0') + fHoseID.ToString() + string.Format("{0:0.000}", price).Replace(",", string.Empty); var status = string.Empty; _wayneIO.SendAndReceive(WayneCommands.SetPrice, data, ref status); }
public FormForecourts() { InitializeComponent(); comboBoxCompanySerialPorts.DataSource = Enum.GetValues(typeof(SerialPort)); _deliveryList = new List<Delivery>(); _pumpList = new List<Pump>(); _pumpList.Add(new Pump(1)); _pumpList.Add(new Pump(2)); _pumpList.Add(new Pump(3)); _pumpList.Add(new Pump(4)); _pumpList.Add(new Pump(5)); _pumpList.Add(new Pump(6)); _pumpList.Add(new Pump(7)); _pumpList.Add(new Pump(8)); _pumpList.Add(new Pump(9)); _pumpList.Add(new Pump(10)); _pumpList.Add(new Pump(11)); _pumpList.Add(new Pump(12)); _pumpList.Add(new Pump(13)); _pumpList.Add(new Pump(14)); _pumpList.Add(new Pump(15)); _pumpList.Add(new Pump(16)); _pumpList.Add(new Pump(17)); _pumpList.Add(new Pump(18)); _pumpList.Add(new Pump(19)); _pumpList.Add(new Pump(20)); _pumpList.Add(new Pump(21)); _pumpList.Add(new Pump(22)); _pumpList.Add(new Pump(23)); _pumpList.Add(new Pump(24)); _pumpList.Add(new Pump(25)); _pumpList.Add(new Pump(26)); _pumpList.Add(new Pump(27)); _pumpList.Add(new Pump(28)); _pumpList.Add(new Pump(29)); _pumpList.Add(new Pump(30)); _pumpList.Add(new Pump(31)); _pumpList.Add(new Pump(32)); _hoseList = new List<Hose>(); int hoseID = 1; foreach (var pump in _pumpList) { for (int i = 0; i < 4; i++) { var hose = new Hose(hoseID++); _hoseList.Add(hose); pump.Hoses.Add(hose); } } dataGridViewPumps.DataSource = typeof(List<Pump>); dataGridViewPumps.DataSource = _pumpList; }
public double GetPrice(Hose hose) { short hDurationType = 0, hPriceType = 0; double hPrice1 = 0, hPrice2 = 0; var result = _eztechIO.GetHosePrices(hose.ID, ref hDurationType, ref hPriceType, ref hPrice1, ref hPrice2); return hPrice1; }
public double GetTotalVolume(Hose hose) { int hNumber = 0, hPumpID = 0, hTankID = 0, hPhysicalNumber = 0; double hMtrTheoValue = 0, hMtrTheoVolume = 0, hMtrElecValue = 0, hMtrElecVolume = 0; _eztechIO.GetHoseProperties(hose.ID, ref hNumber, ref hPumpID, ref hTankID, ref hPhysicalNumber, ref hMtrTheoValue, ref hMtrTheoVolume, ref hMtrElecValue, ref hMtrElecVolume); return Math.Round(hMtrElecVolume, 2); }
public void GetDeliveringVolume_HoseList_ReturnsDeliveringVolumeForEachHose() { var forecourt = new EZTech(new EZTechMockIO()); var hose1 = new Hose(1); var hose2 = new Hose(2); var hoseList = new List<Hose>() { hose1, hose2 }; var dic = forecourt.GetDeliveringVolume(hoseList); forecourt.Dispose(); dic[hose1].Should().Be(243.943d); dic[hose2].Should().Be(20.752d); }
public void Block(Hose hose) { int hNumber = 0, hPumpID = 0, hTankID = 0, hPhysicalNumber = 0; double hMtrTheoValue = 0, hMtrTheoVolume = 0, hMtrElecValue = 0, hMtrElecVolume = 0; _eztechIO.GetHoseProperties(hose.ID, ref hNumber, ref hPumpID, ref hTankID, ref hPhysicalNumber, ref hMtrTheoValue, ref hMtrTheoVolume, ref hMtrElecValue, ref hMtrElecVolume); short pPhysicalNumber = 0, pSide = 0, pAddress = 0, pPriceLevel1 = 0, pPriceLevel2 = 0, pPriceDspFormat = 0, pVolumeDspFormat = 0, pValueDspFormat = 0, pAuthMode = 0, pStackMode = 0, pPrepayAllowed = 0, pPreauthAllowed = 0; int pType = 0, pPortID = 0, pAttendantID = 0, pNumber = 0; string pName = string.Empty; _eztechIO.GetPumpProperties(hPumpID, ref pNumber, ref pName, ref pPhysicalNumber, ref pSide, ref pAddress, ref pPriceLevel1, ref pPriceLevel2, ref pPriceDspFormat, ref pVolumeDspFormat, ref pValueDspFormat, ref pType, ref pPortID, ref pAttendantID, ref pAuthMode, ref pStackMode, ref pPrepayAllowed, ref pPreauthAllowed); pAuthMode = 2; _eztechIO.SetPumpProperties(hPumpID, pNumber, pName, pPhysicalNumber, pSide, pAddress, pPriceLevel1, pPriceLevel2, pPriceDspFormat, pVolumeDspFormat, pValueDspFormat, pType, pPortID, pAttendantID, pAuthMode, pStackMode, pPrepayAllowed, pPreauthAllowed); }
public void GetDeliveringVolume_HoseList_ReturnsDeliveringVolumeForEachHose() { _mockIO.Setup(c => c.SendAndReceive(CompanyCommands.GetHosesDeliveringVolume)).Returns("(0412439444002075)"); var forecourt = new Company(_mockIO.Object); var hose1 = new Hose(1); var hose2 = new Hose(2); var hoseList = new List<Hose>() { hose1, hose2 }; var dic = forecourt.GetDeliveringVolume(hoseList); forecourt.Dispose(); dic[hose1].Should().Be(1243.94d); dic[hose2].Should().Be(20.75d); }
public void GetDeliveringVolume_HoseList_ReturnsDeliveringVolumeForEachHose() { var status = string.Empty; var callCount = 0; var returnValues = new string[] { "024394300000000000001", "002075200000000000002" }; _mockIO.Setup(c => c.SendAndReceive(WayneCommands.GetDeliveringVolume, "01", ref status)) .Returns(() => returnValues[callCount]) .Callback(() => { status = "00"; callCount++; }); var forecourt = new Wayne(_mockIO.Object); var hose1 = new Hose(1); var hose2 = new Hose(2); var hoseList = new List<Hose>() { hose1, hose2 }; var dic = forecourt.GetDeliveringVolume(hoseList); forecourt.Dispose(); status.Should().Be("00"); dic[hose1].Should().Be(243.943d); dic[hose2].Should().Be(20.752d); }
public void PresetByValue(Hose hose, double value) { _companyIO.SendAndReceive(CompanyCommands.PresetHoseByValue, GetHexadecimalHoseID(hose.ID), value.ToString("0000.00").Replace(",", string.Empty)); }
public double GetDeliveringVolume(Hose hose) { int hNumber = 0, hPumpID = 0, hTankID = 0, hPhysicalNumber = 0; double hMtrTheoValue = 0, hMtrTheoVolume = 0, hMtrElecValue = 0, hMtrElecVolume = 0; _eztechIO.GetHoseProperties(hose.ID, ref hNumber, ref hPumpID, ref hTankID, ref hPhysicalNumber, ref hMtrTheoValue, ref hMtrTheoVolume, ref hMtrElecValue, ref hMtrElecVolume); var dictionary = new Dictionary<Pump, PumpState>(); short pStatus = 0, pReservedFor = 0, pHoseNumber = 0, pPriceLevel = 0, pStackSize = 0; int pReservedBy = 0, pHoseID = 0, pGradeID = 0; string pGradeName = string.Empty, pShortGradeName = string.Empty; double pPrice = 0, pVolume = 0, pValue = 0; _eztechIO.GetPumpStatus(hPumpID, ref pStatus, ref pReservedFor, ref pReservedBy, ref pHoseID, ref pHoseNumber, ref pGradeID, ref pGradeName, ref pShortGradeName, ref pPriceLevel, ref pPrice, ref pVolume, ref pValue, ref pStackSize); return pVolume; }
private void InitializeHosesAndPumps() { _pumpList = new List<Pump>(); _hoseList = new List<Hose>(); for (int i = 1; i <= 32; i++) { var status = string.Empty; var result = _wayneIO.SendAndReceive(WayneCommands.GetPumpConfiguration, i.ToString().PadLeft(2, '0'), ref status); if (status == "00") { var hoseCount = int.Parse(result.Substring(5, 1)); var pump = new Pump(i); for (int j = 1; j <= hoseCount; j++) { var hose = new Hose(GetHoseID(i, j)); _hoseList.Add(hose); pump.Hoses.Add(hose); } if (hoseCount > 0) _pumpList.Add(pump); } } }
public void PresetByVolume(Hose hose, double volume) { int fPumpID = 0, fHoseID = 0; GetForecourtHoseID(hose.ID, ref fPumpID, ref fHoseID); var status = string.Empty; _wayneIO.SendAndReceive(WayneCommands.PresetByVolume, fPumpID.ToString().PadLeft(2, '0') + Convert.ToInt32(volume).ToString().PadLeft(4, '0') + fHoseID.ToString(), ref status); }
public void PresetByVolume(Hose hose, double volume) { throw new NotImplementedException(); }
public void SetPrice(Hose hose, double price) { var result = _eztechIO.SetHosePrices(hose.ID, 2, 1, price, price); }
private void ReadEvents() { Int16 eventType = 0; while (!_tasksCancellation.IsCancellationRequested) { Thread.Sleep(300); // TODO: verificar tempo correto _eztechIO.ProcessEvents(); var result = _eztechIO.GetNextEventType(ref eventType); // TODO: adicionar validação do retorno do comando switch (eventType) { case 2: // 2 == Delivery Event { Int32 DeliveryID = -1; Int32 PumpID = -1; Int16 PumpNumber = 0; Int32 HoseID = -1; Int16 HoseNumber = 0; Int32 GradeID = -1; string GradeName = string.Empty; string ShortGradeName = string.Empty; Int16 PriceLevel = 1; Double Price = 0; Double Volume = 0; Double Value = 0; Int16 DeliveryState = 0; Int16 DeliveryType = 0; Int32 LockedBy = -1; Int32 ReservedBy = -1; Int32 Age = 0; DateTime CompletedDT = System.DateTime.Now; Int32 AttendantID = -1; Double OldVolumeETot = 0; Double OldVolume2ETot = 0; Double OldValueETot = 0; Double NewVolumeETot = 0; Double NewVolume2ETot = 0; Double NewValueETot = 0; Int64 Tag = 0; Int32 Duration = 0; _eztechIO.GetNextDeliveryEventEx2(ref DeliveryID, ref PumpID, ref PumpNumber, ref HoseID, ref HoseNumber, ref GradeID, ref GradeName, ref ShortGradeName, ref PriceLevel, ref Price, ref Volume, ref Value, ref DeliveryState, ref DeliveryType, ref LockedBy, ref ReservedBy, ref Age, ref CompletedDT, ref AttendantID, ref OldVolumeETot, ref OldVolume2ETot, ref OldValueETot, ref NewVolumeETot, ref NewVolume2ETot, ref NewValueETot, ref Tag, ref Duration); // TODO: adicionar validação do retorno do comando if (DeliveryID != -1 && LockedBy == -1 && OnDeliveryFinalized != null) { _eztechIO.LockAndClearDelivery(DeliveryID, DeliveryType); // Removes the delivery from the forecourt var delivery = new Delivery(); delivery.Date = CompletedDT; delivery.Hose = new Hose(HoseID); delivery.TotalValue = Value; delivery.UnitPrice = Price; delivery.Volume = Volume; _progressDeliveryFinalized.Report(new DeliveryProgressInfo(delivery)); } break; } case 1: // 1 == Pump Event { Int32 PumpID = -1; Int16 PumpNumber = 0; Int16 State = 0; Int16 ReservedFor = 0; Int32 ReservedBy = -1; Int32 HoseID = -1; Int16 HoseNumber = 0; Int32 GradeID = -1; string GradeName = string.Empty; string ShortGradeName = string.Empty; Int16 PriceLevel = 1; Double Price = 0; Double Volume = 0; Double Value = 0; Int16 StackSize = 0; string PumpName = string.Empty; Int16 PhysicalNumber = 0; Int16 Side = 0; Int16 Address = 0; Int16 PriceLevel1 = 0; Int16 PriceLevel2 = 0; Int16 Type = 0; Int32 PortID = -1; Int16 AuthMode = 0; Int16 StackMode = 0; Int16 PrepayAllowed = 0; Int16 PreauthAllowed = 0; Int16 PriceFormat = 0; Int16 ValueFormat = 0; Int16 VolumeFormat = 0; _eztechIO.GetNextPumpEventEx(ref PumpID, ref PumpNumber, ref State, ref ReservedFor, ref ReservedBy, ref HoseID, ref HoseNumber, ref GradeID, ref GradeName, ref ShortGradeName, ref PriceLevel, ref Price, ref Volume, ref Value, ref StackSize, ref PumpName, ref PhysicalNumber, ref Side, ref Address, ref PriceLevel1, ref PriceLevel2, ref Type, ref PortID, ref AuthMode, ref StackMode, ref PrepayAllowed, ref PreauthAllowed, ref PriceFormat, ref ValueFormat, ref VolumeFormat); if (OnPumpStateChanged != null && HoseID == -1) { var pump = new Pump(PumpID, ToPumpState(State)); _progressPumpStateChanged.Report(new PumpProgressInfo(pump)); } if (OnHoseCurrentVolumeChanged != null && HoseID != -1) { var hose = new Hose(HoseID); hose.CurrentVolume = Volume; _progressHoseCurrentVolumeChanged.Report(new HoseProgressInfo(hose)); } break; } default: _eztechIO.DiscardNextEvent(); break; } } }
public HoseProgressInfo(Hose hose) { Hose = hose; }
public double GetDeliveringVolume(Hose hose) { var result = _companyIO.SendAndReceive(CompanyCommands.GetHosesDeliveringVolume); var pattern = GetHexadecimalHoseID(hose.ID) + "[0-9]{6}"; var volume = 0d; if (result != "(0)") { for (int i = 1; result[i] != ')' && volume == 0; i = i + 8) { if (Regex.IsMatch(result.Substring(i, 8), pattern, RegexOptions.IgnoreCase)) { var match = Regex.Match(result.Substring(i, 8), pattern, RegexOptions.IgnoreCase).Value; volume = Convert.ToDouble(match.Substring(2, 6)) / 100; } } } return volume; }
public HoseEventArgs(Hose hose) { this.Hose = hose; }
private void InitializeHosesAndPumps() { _pumpList = new List<Pump>(); _hoseList = new List<Hose>(); var report = _companyIO.SendAndReceive(CompanyCommands.GetPumpsAndHosesConfiguration); var pattern = "C[0-9]{2}[^ \t\r\n\v\f]{3}[0-9]{6}"; var nextID = 1; var hoseCount = 0; var channel = 0; var pump = 0; foreach (Match match in Regex.Matches(report, pattern)) { channel = Convert.ToInt32(match.Value.Substring(1, 2)); pump = Convert.ToInt32(match.Value.Substring(6, 2)) - 1; hoseCount = Convert.ToInt32(match.Value.Substring(8, 2)); if (hoseCount > 0) { var newPump = new Pump(nextID, PumpState.Free); for (int i = 0; i < hoseCount; i++) { var hose = new Hose(GetHoseID(channel, pump, i)); newPump.Hoses.Add(hose); _hoseList.Add(hose); } _pumpList.Add(newPump); } nextID++; } }
public void PresetByValue(Hose hose, double value) { int fPumpID = 0, fHoseID = 0; GetForecourtHoseID(hose.ID, ref fPumpID, ref fHoseID); var status = string.Empty; _wayneIO.SendAndReceive(WayneCommands.PresetByValue, fPumpID.ToString().PadLeft(2, '0') + string.Format("{0:000000.00}", value).Replace(",", string.Empty) + fHoseID.ToString(), ref status); }
public void SetPrice(Hose hose, double price) { _companyIO.SendAndReceive(CompanyCommands.SetPrice, GetHexadecimalHoseID(hose.ID), price.ToString("0.000").Replace(",", string.Empty)); }
public double GetDeliveringVolume(Hose hose) { int fPumpID = 0, fHoseID = 0; GetForecourtHoseID(hose.ID, ref fPumpID, ref fHoseID); var status = string.Empty; var result = _wayneIO.SendAndReceive(WayneCommands.GetDeliveringVolume, fPumpID.ToString().PadLeft(2, '0'), ref status); var hoseID = Convert.ToInt32(result.Substring(20, 1).ToString()); if (fHoseID == hoseID) return Convert.ToDouble(result.Substring(1, 6)) / 1000; else return 0; }
public double GetPrice(Hose hose) { var result = _companyIO.SendAndReceive(CompanyCommands.GetPrice, GetHexadecimalHoseID(hose.ID)); return Convert.ToDouble(result.Substring(9, 4)) / 1000; }
public void Block(Hose hose) { _companyIO.SendAndReceive(CompanyCommands.BlockHose, GetHexadecimalHoseID(hose.ID)); }
public void Authorise(Hose hose) { _companyIO.SendAndReceive(CompanyCommands.AuthoriseHose, GetHexadecimalHoseID(hose.ID)); }
public void Block(Hose hose) { int fPumpID = 0, fHoseID = 0; GetForecourtHoseID(hose.ID, ref fPumpID, ref fHoseID); var status = string.Empty; _wayneIO.SendAndReceive(WayneCommands.BlockHose, fPumpID.ToString().PadLeft(2, '0') + "2", ref status); }
public void PresetByVolume(Hose hose, double volume) { int hNumber = 0, hPumpID = 0, hTankID = 0, hPhysicalNumber = 0; double hMtrTheoValue = 0, hMtrTheoVolume = 0, hMtrElecValue = 0, hMtrElecVolume = 0; _eztechIO.GetHoseProperties(hose.ID, ref hNumber, ref hPumpID, ref hTankID, ref hPhysicalNumber, ref hMtrTheoValue, ref hMtrTheoVolume, ref hMtrElecValue, ref hMtrElecVolume); var result = _eztechIO.LoadPreset(hPumpID, 3, volume, (short)(Math.Pow(2, hose.ID - 1)), 1); }