How to fix the problem in filtering the signals in PC SDK application?

vikram6892vikram6892 Weingarten
edited March 25 in Developer Tools
I would like to filter out some set of signals (e.g. Digital Input) from a profinet device using signal Filter enum IOFilterTypes. But I am not getting the correct signal  from the correct unit.



Answers

  • scottMHAscottMHA Luton, United Kingdom
    edited April 12
    SignalCollection Signals = MainController.IOSystem.GetSignals(IOFilterTypes.Digital).Where(o => o.Type == SignalType.DigitalInput) as SignalCollection;
    Should be able to use linq to filter these out. Not sure if it works with a collection, you may have to parse through signals individually. Alternatively use the code below.

    SignalCollection Signals = MainController.IOSystem.GetSignals(IOFilterTypes.All);
    
                foreach(Signal signal in Signals)
                {
                    if (signal.Type == SignalType.DigitalInput)
                    {
                     // Do something here to inputs
                    }
                }

  • MickyMicky Germany ✭✭✭

    Hello,
    I think you have to use a binary OR (|) instead of a binary AND (&) to be able to use several filter settings.

    var Signals = MainController.IOSystem.GetSignals(IOFilterTypes.Digital | IOFilterTypes.Input);

    Best regards
    Micly
Sign In or Register to comment.