/// <summary>
        /// Method for showing meter window
        /// </summary>
        /// <param name="meter"></param>
        public void ShowPacWindow(ModbusMeterBase meter)
        {
            PACWindow window = new PACWindow();

            window.Init(meter);
            window.Show();
        }
        public void Init(ModbusMeterBase device)
        {
            this.Meter = device;

            MeterUserControl      = this.Meter.GetUserControl();
            this.mainBorder.Child = MeterUserControl;

            this.DataContext = this.Meter;
        }
        /// <summary>
        /// Method for removing meter
        /// </summary>
        /// <param name="device">
        /// Meter to remove
        /// </param>
        public void RemoveDevice(ModbusMeterBase device)
        {
            //Stopping meter if started
            if (device.IsRunning)
            {
                device.Stop();
            }

            AllMBDevices.Remove(device);
            device.MBDeviceSettingsChanged -= OnDeviceSettingsChanged;
            SaveToXMLFile();
        }
        /// <summary>
        /// Method for setting simulator according to XML content
        /// </summary>
        /// <param name="mainElement">XML element</param>
        public void SetFromXML(XElement mainElement)
        {
            if (mainElement.Name != "PACSimulator")
            {
                throw new Exception("Invalid name of XML file");
            }

            //Clearing all possible selections and seleted elements
            this.AllMBDevices.Clear();
            this.CurrentDevice = null;

            foreach (var element in mainElement.Elements())
            {
                if (element.Name == PAC3200.TypeString)
                {
                    var newPAC3200 = new PAC3200(this, element);

                    AddDevice(newPAC3200);
                }
                else if (element.Name == PAC4200.TypeString)
                {
                    var newPAC4200 = new PAC4200(this, element);

                    AddDevice(newPAC4200);
                }
                else if (element.Name == PAC3220.TypeString)
                {
                    var newPAC3220 = new PAC3220(this, element);

                    AddDevice(newPAC3220);
                }
                else if (element.Name == PAC3100.TypeString)
                {
                    var newPAC3100 = new PAC3100(this, element);

                    AddDevice(newPAC3100);
                }
                else if (element.Name == PAC3120.TypeString)
                {
                    var newPAC3120 = new PAC3120(this, element);

                    AddDevice(newPAC3120);
                }
            }
        }
 /// <summary>
 /// Method for stopping meter
 /// </summary>
 /// <param name="meter"></param>
 public void StopMeter(ModbusMeterBase meter)
 {
     meter.Stop();
 }
 /// <summary>
 /// Method for starting meter
 /// </summary>
 /// <param name="meter">
 /// Meter to start
 /// </param>
 public void StartMeter(ModbusMeterBase meter)
 {
     meter.Start();
 }
 /// <summary>
 /// Method for adding new meter to AllMeters
 /// </summary>
 /// <param name="device">new meter to be added</param>
 public void AddDevice(ModbusMeterBase device)
 {
     AllMBDevices.Add(device);
     device.MBDeviceSettingsChanged += OnDeviceSettingsChanged;
     SaveToXMLFile();
 }
Exemplo n.º 8
0
 /// <summary>
 /// Sampler for generating tick events for meters
 /// </summary>
 /// <param name="meter">Meter connected to sampler</param>
 /// <param name="samplingTime">Sample time</param>
 public Sampler(ModbusMeterBase meter, Double samplingTime = 1000)
 {
     this.MBDevice           = meter;
     this.TickTimer          = new Timer(samplingTime);
     this.TickTimer.Elapsed += TickTimer_Elapsed;
 }