1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Wayne.ForecourtControl.Fusion.ReadDeviceStatus;
- using Wayne.Lib;
- namespace Wayne.ForecourtControl.Fusion
- {
- public static class ConfigurationSetExtensions
- {
- /// <summary>
- /// Returns a list of pump numbers from the given configuration set
- /// </summary>
- /// <param name="configurationSet"></param>
- /// <returns></returns>
- public static int[] PumpNumbers(this ConfigurationSet configurationSet)
- {
- return configurationSet.DspConfiguration.FDCdata.
- WhereNotNull()
- .SelectMany(x => x.DeviceClass.WhereNotNull())
- .Select(x => Strings.ParseInt(x.DeviceID))
- .Where(x => x.HasValue)
- .Select(x => x.Value)
- .ToArray();
- }
- /// <summary>
- /// Returns an array of strings the denormalized nozzle information
- /// containing pumpnumber|nozzlenumber|productnumber|Tank1|Tank2 from the given configurationset.
- /// </summary>
- /// <param name="configurationSet"></param>
- /// <returns></returns>
- public static IEnumerable<string> NozzleSetup(this ConfigurationSet configurationSet)
- {
- foreach (var deviceClassDsp in configurationSet.DspConfiguration.FDCdata
- .WhereNotNull()
- .SelectMany(x => x.DeviceClass.WhereNotNull()))
- {
- foreach (var deviceClassFp in deviceClassDsp.DeviceClass.WhereNotNull())
- {
- foreach (var nozzle in deviceClassFp.FPNozzle.WhereNotNull())
- {
- foreach (var product in nozzle.FPProductId)
- {
- yield return string.Join("|",
- new []{deviceClassDsp.DeviceID,
- nozzle.FPNozzleNo,
- product.PIFPProductNo,
- product.PIFPTankNo1,
- product.PIFPTankNo2});
- }
- }
- }
- }
- }
- /// <summary>
- /// Returns an enumerable of the product numbers in the supplied configuration set.
- /// </summary>
- /// <param name="configurationSet"></param>
- /// <returns></returns>
- public static IEnumerable<int> ProductNumbers(this ConfigurationSet configurationSet)
- {
- return configurationSet.ProductTable.FDCdata
- .WhereNotNull()
- .SelectMany(x => x.FuelProducts.WhereNotNull())
- .SelectMany(x => x.Product.WhereNotNull())
- .Select(x => Strings.ParseInt(x.ProductNo))
- .Where(x => x.HasValue)
- .Select(x => x.Value)
- .ToArray();
- }
- }
- }
|