Exemplo n.º 1
0
      private void HardwareOff()
      {
          VerticalPistons.ForEach(b =>
            {
                b.Velocity = 0f;
                b.SetValue <float>("MaxImpulseAxis", PISTON_MIN_FORCE);
                b.SetValue <float>("MaxImpulseNonAxis", PISTON_MIN_FORCE);
                b.Enabled = false;
            });

          HorizontalPistons.ForEach(b =>
            {
                b.Velocity = 0f;
                b.SetValue <float>("MaxImpulseAxis", PISTON_MIN_FORCE);
                b.SetValue <float>("MaxImpulseNonAxis", PISTON_MIN_FORCE);
                b.Enabled = false;
            });

          AzimuthRotor.TargetVelocityRad = 0f;
          AzimuthRotor.RotorLock         = true;
          AzimuthRotor.Torque            = 0f;
          AzimuthRotor.BrakingTorque     = 0f;
          AzimuthRotor.Enabled           = false;

          CurrentProgramm = DrillProgrammEnum.None;
          ProgrammState   = ProgrammStateEnum.None;
      }
Exemplo n.º 2
0
      private void SetRadiusSpeed(float linearSpeed)
      {
          rad_spd = linearSpeed;

          float vel = FadeSpeed(rad_spd, RadiusDeviation()) / HorizontalPistons.Count;

          HorizontalPistons.ForEach(b => b.Velocity = vel);
      }
Exemplo n.º 3
0
      private float CurrentRadius()
      {
          //float R = MIN_RADIUS;
          float R = 0f;

          HorizontalPistons.ForEach(b => R += b.CurrentPosition);
          return(R);
      }
Exemplo n.º 4
0
      private void GotoStartPos()
      {
          DesiredRadius = radius_min;
          DesiredDepth  = 0f; // depth_min;  через верхнюю точку, в конце опустим
          DesiredAngle  = angle_min;

          Drills.ForEach(b => b.Enabled = false);

          SetDepthSpeed(FREE_VELOCITY);
          HorizontalPistons.ForEach(b => b.Velocity = 0f);
          AzimuthRotor.TargetVelocityRad            = 0f;

          CurrentProgramm = DrillProgrammEnum.GotoBegin;
          ProgrammState   = ProgrammStateEnum.MoveVertical;
      }
Exemplo n.º 5
0
      private void GotoHome()
      {
          DesiredRadius = 0f;
          DesiredDepth  = 0f;
          DesiredAngle  = 0f;

          Drills.ForEach(b => b.Enabled = false);

          SetDepthSpeed(FREE_VELOCITY);
          HorizontalPistons.ForEach(b => b.Velocity = 0f);
          AzimuthRotor.TargetVelocityRad            = 0f;

          CurrentProgramm = DrillProgrammEnum.GotoHome;
          ProgrammState   = ProgrammStateEnum.MoveVertical;
      }
Exemplo n.º 6
0
      private bool CheckRadius(bool correctSpeed)
      {
          float d = RadiusDeviation();

          if (d == 0f)
          {
              return(true);
          }

          if (!correctSpeed)
          {
              return(false);
          }

          float vel = FadeSpeed(rad_spd, d) / HorizontalPistons.Count;

          HorizontalPistons.ForEach(b => b.Velocity = vel);

          return(false);
      }
Exemplo n.º 7
0
      private void StartDrill()
      {
          DesiredDepth  = CurrentDepth();
          DesiredRadius = CurrentRadius();

          if (turn_direction)
          {
              DesiredAngle = angle_max;
          }
          else
          {
              DesiredAngle = angle_min;
          }

          Drills.ForEach(b => b.Enabled = true);

          VerticalPistons.ForEach(b => b.Velocity   = 0f);
          HorizontalPistons.ForEach(b => b.Velocity = 0f);

          SetAngleSpeed(DRILL_VELOCITY);

          CurrentProgramm = DrillProgrammEnum.Drill;
          ProgrammState   = ProgrammStateEnum.Turning;
      }
Exemplo n.º 8
0
      private void HardwareOn()
      {
          VerticalPistons.ForEach(b =>
            {
                b.Velocity = 0f;
                b.SetValue <float>("MaxImpulseAxis", PISTON_FORCE);
                b.SetValue <float>("MaxImpulseNonAxis", PISTON_FORCE);
                b.Enabled = true;
            });

          HorizontalPistons.ForEach(b =>
            {
                b.Velocity = 0f;
                b.SetValue <float>("MaxImpulseAxis", PISTON_FORCE);
                b.SetValue <float>("MaxImpulseNonAxis", PISTON_FORCE);
                b.Enabled = true;
            });

          AzimuthRotor.TargetVelocityRad = 0f;
          AzimuthRotor.RotorLock         = false;
          AzimuthRotor.Torque            = ROTOR_FORCE;
          AzimuthRotor.BrakingTorque     = ROTOR_BRAKE_FORCE;
          AzimuthRotor.Enabled           = true;
      }
Exemplo n.º 9
0
 private void StopMotion()
 {
     VerticalPistons.ForEach(b => b.Velocity   = 0f);
     HorizontalPistons.ForEach(b => b.Velocity = 0f);
     AzimuthRotor.TargetVelocityRad            = 0f;
 }
Exemplo n.º 10
0
      private void InitModule()
      {
          StringBuilder sb = new StringBuilder();

          DebugLCD = FindDisplay(DEBUG_LCD_NAME, GridTerminalSystem, Me);
          ToLog("", false, false);

          if (!string.IsNullOrEmpty(LCDName))
          {
              LCD = FindDisplay(LCDName, GridTerminalSystem, Me);
          }
          ProgBlockLCD = Me.GetSurface(0);

          if (LCD == null)
          {
              sb.AppendLine("Дисплей не обнаружен");
          }

          HorizontalPistons = FindAllBlocksOfType <IMyPistonBase>(GridTerminalSystem, Me, HORIZONTAL_PISTONS_TAG);
          VerticalPistons   = FindAllBlocksOfType <IMyPistonBase>(GridTerminalSystem, Me, VERTICAL_PISTONS_TAG);
          AzimuthRotor      = FindBlockOfType <IMyMotorStator>(null, GridTerminalSystem, Me, AZIMUTH_ROTOR_TAG);
          Drills            = FindAllBlocksOfType <IMyShipDrill>(GridTerminalSystem, Me);
          Containers        = FindAllBlocksOfType <IMyCargoContainer>(GridTerminalSystem, Me);

          MAX_PISTONS_RADIUS = 0f;
          HorizontalPistons.ForEach(b => MAX_PISTONS_RADIUS += b.HighestPosition);
          MAX_PISTONS_DEPTH = 0f;
          VerticalPistons.ForEach(b => MAX_PISTONS_DEPTH += b.HighestPosition);

          if (HorizontalPistons.Count == 0)
          {
              init_error = true; sb.AppendLine("Гор. поршни не обнаружены!");
          }
          else
          {
              sb.AppendFormat("Гор. поршней: {0}\n", HorizontalPistons.Count);
          }
          if (VerticalPistons.Count == 0)
          {
              init_error = true; sb.AppendLine("Верт. поршни не обнаружены!");
          }
          else
          {
              sb.AppendFormat("Верт. поршней: {0}\n", VerticalPistons.Count);
          }
          if (AzimuthRotor == null)
          {
              init_error = true; sb.AppendLine("Ротор не обнаружен!");
          }
          else
          {
              sb.AppendLine("Ротор: ОК");
          }
          if (Drills.Count == 0)
          {
              init_error = true; sb.AppendLine("Буры не обнаружены!");
          }
          else
          {
              sb.AppendFormat("Буров: {0}\n", Drills.Count);
          }
          if (Containers.Count == 0)
          {
              init_error = true; sb.AppendLine("Контейнеры не обнаружены!");
          }
          else
          {
              sb.AppendFormat("Контейнеров: {0}\n", Containers.Count);
          }

          init_message = sb.ToString();

          ClearPrgSettings();
          LoadState();

          Echo(init_message);

          Runtime.UpdateFrequency = UpdateFrequency.Update10;

          if (init_error)
          {
              Runtime.UpdateFrequency = UpdateFrequency.None;
              LCD.WriteText(init_message);
          }
      }
Exemplo n.º 11
0
      private bool CheckProgrammState()
      {
          switch (ProgrammState)
          {
          case ProgrammStateEnum.None:
          {
              return(false);
          }

          case ProgrammStateEnum.MoveVertical:
          case ProgrammStateEnum.MoveDown:
          {
              if (CheckDepth(true))
              {
                  VerticalPistons.ForEach(b => b.Velocity = 0f);
                  return(true);
              }
              break;
          }

          case ProgrammStateEnum.MoveHorizontal:
          {
              if (CheckRadius(true))
              {
                  HorizontalPistons.ForEach(b => b.Velocity = 0f);
                  return(true);
              }
              break;
          }

          case ProgrammStateEnum.TurningMoveHorisontal:
          {
              bool flag = true;
              if (CheckRadius(true))
              {
                  HorizontalPistons.ForEach(b => b.Velocity = 0f);
              }
              else
              {
                  flag = false;
              }
              if (CheckAngle(true))
              {
                  AzimuthRotor.TargetVelocityRad = 0f;
              }
              else
              {
                  flag = false;
              }

              return(flag);
          }

          case ProgrammStateEnum.Turning:
          {
              if (CheckAngle(true))
              {
                  AzimuthRotor.TargetVelocityRad = 0f;
                  return(true);
              }
              break;
          }

          default:
              break;
          }
          return(false);
      }