public DsmrParserService(IMeasurementStorageService storageService, ParserSettings settings, ILog logger)
 {
     this.m_logger         = logger;
     this.m_parserClient   = new ParserServiceClient(EndpointConfigName);
     this.m_storageService = storageService;
     this.m_settings       = settings;
 }
        private Telegram ParseTelegram(string sensorId, TextTelegram textTelegram)
        {
            Telegram telegram = null;

            try {
                this.m_logger.Info($"Origin sensor: {sensorId}.");

                telegram           = this.m_parserClient.Parse(textTelegram.Telegram);
                telegram.SensorId  = sensorId;
                telegram.Timestamp = textTelegram.Timestamp;

                if (textTelegram.Longitude > 0D && textTelegram.Latitude > 0D)
                {
                    telegram.Latitude  = textTelegram.Latitude;
                    telegram.Longitude = textTelegram.Longitude;
                }
            } catch (ServerTooBusyException ex) {
                this.m_logger.Error("DSMR parser timeout. Is the remote up?", ex);
                this.m_logger.Error($"Telegram text: {textTelegram.Telegram}");
            } catch (FaultException ex) {
                this.m_logger.Error("Error in the DSMR parser service.", ex);
                this.m_logger.Error($"Telegram text: {textTelegram.Telegram}");
            } catch (CommunicationException ex) {
                this.m_logger.Error("Unknown DSMR parsing exception.", ex);
                this.m_logger.Error($"Telegram text: {textTelegram.Telegram}");

                if (this.m_parserClient.State == CommunicationState.Faulted)
                {
                    this.m_parserClient = new ParserServiceClient(EndpointConfigName);
                }
            }

            return(telegram);
        }
Пример #3
0
 public ICollection <Liquid> Get()
 {
     using (var serviсe = new ParserServiceClient())
     {
         return(serviсe.GetLiquids().Select(x => new Liquid()
         {
             Id = x.Id,
             Name = x.Name,
             Article = x.Article,
             Link = x.Link,
             Price = x.Price,
             Availability = x.Availability,
             StrengthIndicated = x.StrengthIndicated,
             Strength = new List <double>(x.Strength),
             AmountIndicated = x.AmountIndicated,
             Amount = new List <int>(x.Amount)
         }).ToArray());
     }
 }
Пример #4
0
        public MainWindow()
        {
            this.InitializeComponent();
            userVariables = new List<VariableInfo>();

            try {
                service = new ParserServiceClient();

                // Get the lists with the built-in functions and constants.
                FunctionInfo[] functions = service.GetAvailableFunctions();
                FunctionsListView.ItemsSource = functions;

                VariableInfo[] variables = service.GetAvailableVariables();
                AvailableVariablesListView.ItemsSource = variables;
            }
            catch(Exception ex) {
                MessageBox.Show("Service not started! Click OK to close the application.");
                Application.Current.Shutdown();
            }
        }