コード例 #1
0
      private void UpdatePumpMotor(ElmoWhistleMotor motor, double setPoint, ref ElmoWhistleMotor.Modes requestedMode, ref double requestedSetPoint)
      {
         if (null == motor.FaultReason)
         {
            bool modeChange = false;
            ElmoWhistleMotor.Modes neededMode = ElmoWhistleMotor.Modes.undefined;
            double neededValue = 0;

            if (0 == setPoint)
            {
               if (0 == requestedSetPoint)
               {
                  neededMode = ElmoWhistleMotor.Modes.off;
                  neededValue = 0;
               }
               else
               {
                  neededMode = ElmoWhistleMotor.Modes.velocity;
                  neededValue = 0;
               }
            }
            else
            {
               neededMode = ElmoWhistleMotor.Modes.velocity;
               neededValue = setPoint;
            }

            if (neededMode != requestedMode)
            {
               motor.SetMode(neededMode);
               requestedMode = neededMode;
               modeChange = true;
               Tracer.WriteMedium(TraceGroup.TBUS, null, "{0} {1}", motor.Name, requestedMode.ToString());
            }

            if (ElmoWhistleMotor.Modes.velocity == requestedMode)
            {
               if ((neededValue != requestedSetPoint) || (false != modeChange))
               {
                  motor.SetVelocity((int)neededValue);
                  requestedSetPoint = neededValue;
                  Tracer.WriteMedium(TraceGroup.TBUS, null, "{0} velocity {1} {2}", motor.Name, neededValue, requestedSetPoint);
               }
            }
         }           
      }
コード例 #2
0
      private void UpdateGuideMotor(ElmoWhistleMotor motor, GuideMotorStatus status)
      {
         if (null == motor.FaultReason)
         {
            double neededValue = 0;

            if (GuideDirections.retract == status.direction)
            {
               if (status.RetractionLimit == false)
               {
                  neededValue = ParameterAccessor.Instance.GuideRetractionSpeed.OperationalValue;
               }
               else
               {
                  status.direction = GuideDirections.off;
                  neededValue = 0;
               }
            }
            else if (GuideDirections.extend == status.direction)
            {
               if (status.ExtensionLimit == false)
               {
                  neededValue = ParameterAccessor.Instance.GuideExtensionSpeed.OperationalValue * -1;
               }
               else
               {
                  status.direction = GuideDirections.off;
                  neededValue = 0;
               }
            }
            else
            {
               neededValue = 0;
            }

            if (status.requestedVelocity != neededValue)
            {
               int velocityRpm = (int)(neededValue);
               motor.SetVelocity(velocityRpm);
               status.requestedVelocity = neededValue;
               Tracer.WriteMedium(TraceGroup.TBUS, null, "{0} velocity {1}", motor.Name, neededValue);
            }
         }
      }