[chronojump/michrolab] Selected device on discover is usable in any compatible mode



commit e22bb39ba6d4595fe8bea4e8713e40ddb243b194
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sat Jun 25 18:02:42 2022 +0200

    Selected device on discover is usable in any compatible mode

 src/chronopicRegister.cs | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/src/chronopicRegister.cs b/src/chronopicRegister.cs
index b1c3c4c91..d9838d835 100644
--- a/src/chronopicRegister.cs
+++ b/src/chronopicRegister.cs
@@ -343,10 +343,27 @@ public abstract class ChronopicRegister
                if (selectedForMode_l == null)
                        return new ChronopicRegisterPort ("");
 
+               //first search strict to that mode, so if there is a chronopic for jumps and another for 
races, will select the appropriate
                foreach (selectedForMode sfm in selectedForMode_l)
                        if (sfm.mode == mode)
                                return sfm.crp;
 
+               //if not found for that mode, find for equivalent mode, so a chronopic for jumps can be 
suitable for races
+               foreach (selectedForMode sfm in selectedForMode_l)
+               {
+                       if (
+                                       (mode == Constants.Modes.JUMPSSIMPLE || mode == 
Constants.Modes.JUMPSREACTIVE ||
+                                        mode == Constants.Modes.RUNSSIMPLE || mode == 
Constants.Modes.RUNSINTERVALLIC)
+                                       &&
+                                       (sfm.mode == Constants.Modes.JUMPSSIMPLE || sfm.mode == 
Constants.Modes.JUMPSREACTIVE ||
+                                        sfm.mode == Constants.Modes.RUNSSIMPLE || sfm.mode == 
Constants.Modes.RUNSINTERVALLIC) )
+                               return sfm.crp;
+                       else if (Constants.ModeIsFORCESENSOR (mode) && Constants.ModeIsFORCESENSOR (sfm.mode))
+                               return sfm.crp;
+                       else if (Constants.ModeIsENCODER (mode) && Constants.ModeIsENCODER (sfm.mode))
+                               return sfm.crp;
+               }
+
                return new ChronopicRegisterPort ("");
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]