Exemplo n.º 1
0
        void Update_SEN0188_NotifyChangeState(IPropertySet Outputpropertys)
        {
            ProcessFingerEvent ev = m_EventQueue.Dequeue(); // get Event

            Object Valout;
            Int16  state               = -1;
            String cmdState            = "...";
            bool   doactFilledSensorId = false;

            if (Outputpropertys.TryGetValue("FingerPrint.CMDState", out Valout))
            {
                if (Valout != null)
                {
                    state = (Int16)Valout;
                }
            }

            if (Outputpropertys.TryGetValue("FingerPrint.CMDTextState", out Valout))
            {
                String cmd = Valout as String;
                if (cmd != null)
                {
                    cmdState = cmd;
                }
            }


            if (Outputpropertys.TryGetValue("FingerPrint.CMD", out Valout))
            {
                if (Valout != null)
                {
                    Int32 CMD = (Int32)Valout;

                    if (CMD == Connector_SEN0188_CMDs.getFingerPrintCmd("_doFingerSensorInitialize"))
                    {
                        if (state == 0)
                        {
                            //        SensorInitialized = true;
                            doactFilledSensorId = true;
                        }
                    }
                    else if (CMD == Connector_SEN0188_CMDs.getFingerPrintCmd("_doFingerAutoVerifiying"))
                    {
                        if (state == 0)
                        {
                            if (Outputpropertys.TryGetValue("FingerPrint.FingerID", out Valout))
                            {
                                if (Valout != null)
                                {
                                    UInt16 fingerId = (UInt16)Valout;
                                    if (Outputpropertys.TryGetValue("FingerPrint.Search_MatchScore", out Valout))
                                    {
                                        UInt16    MatchScore = (UInt16)Valout;
                                        DBDataSet dataset    = m_SEN0188SQLite.getDatabyId(fingerId);
                                        if (dataset != null)
                                        {
                                            if (dataset.AccessRights_Bit0 || (dataset.AccessRights & ev.AccessRights) != 0) // Master Bit
                                            {
                                                for (int i = 0; i < ev.GPIOOutputs.Count; i++)
                                                {
                                                    //                         ev.GPIOOutputs[i].GPIOEnvironmentConnector.UpdateState(0);
                                                    ev.GPIOOutputs[i].GPIOObject.SetValue = (ev.GPIOOutputs[i].GPIOObject.InitValue > 0) ? 1:0;
                                                    ev.GPIOOutputs[i].GPIOEnvironmentConnector.UpdateInputPropertySets(ev.GPIOOutputs[i].GPIOObject);
                                                }

                                                FingerEvent eventSet = new FingerEvent();
                                                eventSet.FirstName      = dataset.FirstName;
                                                eventSet.SecondName     = dataset.SecondName;
                                                eventSet.MatchScore     = MatchScore;
                                                eventSet.FingerID       = fingerId;
                                                eventSet.EventType      = 0;
                                                eventSet.SensorState    = state;
                                                eventSet.SensorTxtState = cmdState;
                                                System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
                                                eventSet.SensorId = enc.GetBytes(m_SensorID);

                                                bool insert = m_FingertEventDatabase.InsertFingerEvent(eventSet);

                                                ConfigProcessItem outstate = m_ConfigProcessItems.getConfigItemByIdent("State_OK");
                                                if (outstate != null)
                                                {
                                                    for (int i = 0; i < outstate.GPIOOutputProcessItems.Count; i++)
                                                    {
//                                                        outstate.GPIOOutputProcessItems[i].GPIOName
                                                    }
                                                }


                                                //             GetEventData();
                                            }
                                            else
                                            {
                                                ConfigProcessItem outstate = m_ConfigProcessItems.getConfigItemByIdent("State_NoPermiss");
                                                if (outstate != null)
                                                {
                                                    for (int i = 0; i < outstate.GPIOOutputProcessItems.Count; i++)
                                                    {
                                                        //                                                        outstate.GPIOOutputProcessItems[i].GPIOName
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (doactFilledSensorId)
            {
                //   m_SensorId.Clear();
                if (Outputpropertys.TryGetValue("FingerPrint.SensorID", out Valout))
                {
                    if (Valout != null)
                    {
                        byte[] array = Valout as byte[];
                        if (array != null)
                        {
                            m_SensorID = System.Text.Encoding.UTF8.GetString(array, 0, array.Length);
                        }
                    }
                }
            }
        }
        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);
                        }
                    }
                }
            });
        }