示例#1
0
        void Notify_NewStatusMessage(object sender, FMStatusEventArgs e)
        {
            IFM2Device device;
            Dictionary <string, string> Lastdata1 = new Dictionary <string, string>();

            Devices = ((cFM2Notify)sender).Devices;
            if (e.StatusChangeNotification == StatusChangeNotifications.MeterAdded)
            {
                FMCounter           = FMCounter + 1;
                device              = (IFM2Device)Devices.Item(((cFM2Notify)sender).DeviceIndex.ToString());
                device.DeviceEvents = Notify;
                Lastdata.Add(device.SerialNumber, "");
                metterArray.Add(device.DeviceIndex.ToString(), device.SerialNumber);
                //MessageBox.Show(metterArray[device.DeviceIndex.ToString()]);
                if (FMCounter >= 1)
                {
                    ScanData.CheckTimer(Devices);
                }
            }
            if (e.StatusChangeNotification == StatusChangeNotifications.MeterRemoved)
            {
                metterArray.Remove(((cFM2Notify)sender).DeviceIndex.ToString());
                Lastdata.Remove(((cFM2Notify)sender).SerialNumber);
                FMCounter = FMCounter - 1;
                if (FMCounter >= 1)
                {
                    ScanData.CheckTimer(Devices);
                }
            }
        }
示例#2
0
        public void EngineFM2DeviceStatusNotifier(IFM2DeviceEvents CallbackData, cFM2Devices DevicesList)
        {
            m_DevicesList = DevicesList;
            switch (CallbackData.CallbackEvent)
            {
            case "MeterAdded":
                m_lastDeviceStatusConnection = "MeterAdded";
                string s = CallbackData.DeviceIndex.ToString();
                m_DevicesList.Item(ref s).DeviceEvents = NotifyMe;
                ScanForData.CheckTimer(ref m_DevicesList);
                m_stringDeviceList.Add(new deviceStringInfo(s, m_DevicesList.Item(ref s).SerialNumber));
                Console.WriteLine("MeterAdded " + m_DevicesList.Item(ref s).SerialNumber);
                if (EventNotifyMeterAdded != null)
                {
                    EventNotifyMeterAdded(m_DevicesList.Item(ref s).SerialNumber, s);
                }
                break;

            case "MeterRemoved":
                m_lastDeviceStatusConnection = "MeterRemoved";
                ScanForData.CheckTimer(ref m_DevicesList);
                m_stringDeviceList.Clear();
                Console.WriteLine("MeterRemoved");
                foreach (IFM2Device d in m_DevicesList)
                {
                    m_stringDeviceList.Add(new deviceStringInfo(d.DeviceIndex.ToString(), d.SerialNumber));
                }
                if (EventNotifyMeterRemoved != null)
                {
                    EventNotifyMeterRemoved(CallbackData.SerialNumber, CallbackData.DeviceIndex.ToString());
                }
                break;

            default:
                m_lastDeviceStatusConnection = "NoMeterAdded";
                break;
            }
        }
示例#3
0
        public SimpleFM()
        {
            Zeroed       = false;
            FMCounter    = 0;
            PowerOn      = false;
            ProbePresent = false;
            //auto connecting to dll server when class init;
            cListener = new cFM2Listener();
            iListener = (IFM2Listener)cListener;
            ScanData  = new cFM2ScanForData();
            ScanUSB   = new cFM2ScanUSBForChange();
            Notify    = new cFM2Notify();
            Devices   = new cFM2Devices();

            cListener.DeviceEvents = Notify;
            ScanUSB.CheckTimer(iListener);
            Notify.NewStatusMessage += Notify_NewStatusMessage;
            Notify.NewMessage       += Notify_NewMessage;
            FMCounter    = 0;
            PowerOn      = false;
            ProbePresent = false;
            System.Diagnostics.Debug.Write("SimpleFM constructor!\r");
            //double pwr = Power;
        }
示例#4
0
 public void NotifyDeviceStatus(IFM2DeviceEvents CallbackData, cFM2Devices DevicesList) //метод, обрабатывающий событие изменения статуса устройства
 {
     //form.NotifyDeviceStatus(CallbackData, DevicesList);
     notifyDeviceStatusEvent(CallbackData, DevicesList);
 }
示例#5
0
 public void NotifyDeviceStatus(FieldMax2DLLServer.IFM2DeviceEvents CallbackData, FieldMax2DLLServer.cFM2Devices DeviceList)
 {
     this.Devices = DeviceList;
     NewStatusMessage(this, new FMStatusEventArgs((StatusChangeNotifications)System.Enum.Parse(typeof(StatusChangeNotifications), CallbackData.CallbackEvent, true)));
 }