Beispiel #1
0
        async private void GPIOConnector_ChangeGPIOs(object sender, IPropertySet propertys)
        {
            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
            { // your code should be here
                m_GPIOEnvironmentConnectors.ProcessPropertysFromGPIOConnector(propertys);

                var con = m_GPIOEnvironmentConnectors.getGPIOOConnectorByOutputPropertySet(propertys);

                if (con == null)
                {
                    return;
                }


                GPIOOBank inputbank = con.ActiveInputs;
                for (int i = 0; i < m_ConfigProcessItems.ProcessItems.Count; i++)
                {
                    ConfigProcessItem item = m_ConfigProcessItems.ProcessItems[i];
                    for (int j = 0; j < item.GPIOInputProcessItems.Count; j++)
                    {
                        GPIOOProcessItem pItem = item.GPIOInputProcessItems[j];

                        GPIOObject obj = inputbank.getGPIOByName(pItem.GPIOName);
                        if (obj != null)
                        {
                            if (obj.PinValue != obj.InitValue)
                            {
                                ProcessFingerEvent ev = new ProcessFingerEvent();
                                GPIOObjectProcess OutObjectProcess = new GPIOObjectProcess();
                                GPIOObjectProcess InObjectProcess  = new GPIOObjectProcess();


                                //item.GPIOOutputProcessItems
                                OutObjectProcess.GPIOEnvironmentConnector = m_GPIOEnvironmentConnectors.getGPIOOConnectorByHostName(pItem.ConnectorName);
                                OutObjectProcess.GPIOObject = obj;

                                InObjectProcess.GPIOEnvironmentConnector = con;
                                InObjectProcess.GPIOObject = obj;

                                ev.GPIOOutputs.Add(OutObjectProcess);
                                ev.GPIOInputs.Add(InObjectProcess);
                                ev.AccessRights = 0x1;

                                m_EventQueue.Enqueue(ev);
                            }
                        }
                    }
                }
            });
        }
        async private void GPIOConnector_ChangeGPIOs(object sender, IPropertySet propertys)
        {
            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
            { // your code should be here
                m_GPIOEnvironmentConnectors.ProcessPropertysFromGPIOConnector(propertys);

                var con = m_GPIOEnvironmentConnectors.getGPIOOConnectorByOutputPropertySet(propertys);

                if (con == null)
                {
                    return;
                }

                if (m_ProcessGPIOEvents == null)
                {
                    return;
                }

                for (int i = 0; i < m_ProcessGPIOEvents.Count; i++)
                {
                    ProcessGPIOEvents item = m_ProcessGPIOEvents[i];
                    if (item.InputActiv())
                    {
                        removeOldEvents(); // ältere löschen, welche nach 5 sec. nicht beantwortet waren

                        if ((item.AccessRights > 0) && m_Environment.ConnectorSEN0188Enable)
                        {
                            if (m_Environment.SensorConnecorInitialized)
                            {
                                ProcessGPIOEvents Processitem = new ProcessGPIOEvents(item);
                                m_EventQueue.Enqueue(Processitem);
                                SensorCMDs.VerifyFingerId(m_Environment.SensorInputServiceConnectorConfig);
                            }
                            else
                            {
                                string cmdState               = "Fingerprint Connector not initialized!";
                                int state                     = -1;
                                FingerEvent eventSet          = createSensorEvent("John", "Doe", -1, -1, item.Ident, state, cmdState);
                                System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
                                eventSet.SensorId             = enc.GetBytes(m_SensorID);
                                bool insert                   = m_FingertEventDatabase.InsertFingerEvent(eventSet);
                                NotifyEvent?.Invoke(this, eventSet);
                            }
                        }
                        else
                        {
                            item.UpdateState(0);
                            item.ProcessOutput();
                            item.UpdateState(1);
                            int state                     = -1;
                            string cmdState               = "no FingerSensor used";
                            FingerEvent eventSet          = createSensorEvent("John", "Doe", -1, -1, item.Ident, state, cmdState);
                            System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
                            eventSet.SensorId             = enc.GetBytes(m_SensorID);
                            bool insert                   = m_FingertEventDatabase.InsertFingerEvent(eventSet);
                            NotifyEvent?.Invoke(this, eventSet);
                        }
                    }
                }
            });
        }