public void UpdateOutputPropertySets(GPIOObject GPIOObj)
        {
            string keyPinValue = GPIOObj.PinName;
            double dblValue    = 0;
            Object Obj         = null;

            if (this.GPIOOutPutServiceConnectorConfig.TryGetValue(keyPinValue, out Obj))
            {
                if (Obj != null)
                {
                    dblValue = (double)Obj;
                    if (GPIOObj.PinValue != dblValue)
                    {
                        if (GPIOObj.GPIOtyp == GPIOObject.GPIOTyp.output)
                        {
                            if (GPIOObj.SetValue != dblValue)
                            {
                                GPIOObj.SetValue = dblValue;
                                double PulseTime = GPIOObj.PulseTime; // save pulseTime
                                GPIOObj.PulseTime = 0;                // pulsetime set to 0
                                UpdateInputPropertySets(GPIOObj);
                                GPIOObj.PulseTime = PulseTime;        // store back PulseTime
                            }
                        }
                        GPIOObj.PinValue = dblValue;
                    }
                }
            }
        }
 public void readImages()
 {
     for (int i = 0; i < m_GPIOs.Count; i++)
     {
         GPIOObject obj = m_GPIOs[i];
         obj.readImages();
     }
 }
 public void createPropertySet(IPropertySet property)
 {
     for (int i = 0; i < m_GPIOs.Count; i++)
     {
         GPIOObject obj = m_GPIOs[i];
         if (obj.IsEnabled)
         {
             obj.createPropertySet(property);
         }
     }
 }
 public GPIOObject getGPIOByName(string name)
 {
     for (int i = 0; i < m_GPIOs.Count; i++)
     {
         GPIOObject obj = m_GPIOs[i];
         if (obj.PinName == name)
         {
             return(obj);
         }
     }
     return(null);
 }
        public int getInitFlank()
        {
            // oder verknüfung
            int ret = 0;

            foreach (var GPIOInput in m_GPIOInputs)
            {
                bool       activ = false;
                GPIOObject obj   = GPIOInput.GPIOObject;
                if (obj.PinValue != obj.InitValue)
                {
                    if ((obj.InitValue == 0) && (obj.PinValue == 1))
                    {
                        activ = true;
                    }
                    else if ((obj.InitValue == 1) && (obj.PinValue == 0))
                    {
                        activ = true;
                    }
                }

                if (activ && !obj.IsFlankActive)
                {
                    long     aktTicks = DateTime.Now.Ticks;
                    long     span     = aktTicks - m_FlankTicks;
                    TimeSpan duration = new TimeSpan(span);
                    //             if (span >= 300) // msec
                    if (duration.TotalMilliseconds >= 300) // msec
                    {
                        m_FlankTicks      = aktTicks;
                        obj.IsFlankActive = true;
                        //   m_LookFor = obj;
                        ret = 1;
                    }
                    //else
                    //{
                    //    bool d = true;
                    //}
                }
                else if (obj.IsFlankActive)
                {
                    if ((obj.InitValue == 0) && (obj.PinValue == 0))
                    {
                        obj.IsFlankActive = false;
                    }
                    else if ((obj.InitValue == 1) && (obj.PinValue == 1))
                    {
                        obj.IsFlankActive = false;
                    }
                }
            }
            return(ret);
        }
Beispiel #6
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);
                            }
                        }
                    }
                }
            });
        }
        public GPIOObject getGPIOByName(string name)
        {
            for (int i = 0; i < m_GPIOBanks.Count; i++)
            {
                GPIOObjects obj = m_GPIOBanks[i];

                GPIOObject ret = obj.getGPIOByName(name);
                if (ret != null)
                {
                    return(ret);
                }
            }

            return(null);
        }
        public void UpdateInputPropertySets(GPIOObject GPIOObj)
        {
            //OutPut.readImages();
            //  string keyPinValue = string.Format("GPIO.{0:00}", OutPut.PinNumber);
            string keyPinValue = GPIOObj.PinName;

            Object Valout;

            if (m_GPIOInputServiceConnectorConfig.TryGetValue(keyPinValue, out Valout))
            {
                if (Valout != null)
                {
                    string nwLine = (string)GPIOObj.getPropertyLine();
                    Valout = nwLine;
                    m_GPIOInputServiceConnectorConfig[keyPinValue] = Valout;
                }
            }
        }
Beispiel #9
0
 public GPIOObjectProcess()
 {
     m_GPIOObject = null;
     m_GPIOEnvironmentConnector = null;
 }