Ejemplo n.º 1
0
 protected override int ComputeImpl(int val, ChangerContext cc)
 {
     if (rangeChangers == null || rangeChangers.Length == 0)
     {
         return(val);
     }
     else
     {
         int v = 0;
         foreach (MapRangeChanger mr in rangeChangers)
         {
             v = mr.ComputeValueDirectly(val, cc);
             if (val < mr.mapping.minFrom)
             {
                 // too little, let it be
                 break;
             }
             if (val <= mr.mapping.maxFrom)
             {
                 // got it
                 break;
             }
         }
         return(v);
     }
 }
Ejemplo n.º 2
0
        protected override int ComputeImpl(int val, ChangerContext cc)
        {
            values[index] = val;

            minThrottle = 256;
            maxThrottle = 0;
            foreach (int v in values)
            {
                if (v < minThrottle)
                {
                    minThrottle = v;
                }
                if (v > maxThrottle)
                {
                    maxThrottle = v;
                }
            }

            cc.minThrottleReached = minThrottle;
            cc.maxThrottleReached = maxThrottle;

            index = (index + 1) % NumberOfCycles;

            return(val);
        }
Ejemplo n.º 3
0
 protected override int ComputeImpl(int val, ChangerContext cc)
 {
     if (val < mapping.minFrom)
     {
         val = mapping.minFrom;
     }
     if (val > mapping.maxFrom)
     {
         val = mapping.maxFrom;
     }
     return((int)(Math.Round(mapping.minTo + (Math.Abs(val - mapping.minFrom)) * factor)));
 }
Ejemplo n.º 4
0
 protected override int ComputeImpl(int val, ChangerContext cc)
 {
     if (val < Min)
     {
         val = Min;
     }
     if (val > Max)
     {
         val = Max;
     }
     return(val);
 }
Ejemplo n.º 5
0
        protected override int ComputeImpl(int val, ChangerContext cc)
        {
            int newVal = val;

            switch (state)
            {
            case 0:
                if (prevVal > Threshold && newVal <= Threshold &&
                    cc.maxThrottleReached >= PreviousMotionThreshold)
                {
                    state = 1;
                    cnt   = CntLimit;
                }

                if (prevVal < Threshold && newVal == Threshold &&
                    cc.minThrottleReached <= ReversePreviousMotionThreshold)
                {
                    state = -1;
                    cnt   = CntLimit;
                }

                break;

            case 1:
                cnt--;
                newVal = MIN_VAL;
                if (cnt < 1)
                {
                    newVal = Threshold;
                    state  = 0;
                }
                break;

            case -1:
                cnt--;
                newVal = MAX_VAL;
                if (cnt < 1)
                {
                    cnt = CntLimit / 4;

                    state = 1;
                }
                break;
            }

            prevVal = newVal;

            return(newVal);
        }
Ejemplo n.º 6
0
 protected override int ComputeImpl(int val, ChangerContext cc)
 {
     return(input);
 }