public bool SendStringMessage(string message, MyTransmitTarget target = MyTransmitTarget.Default) { if (type == antennaType.radioAntenna) { return(radioAntenna.TransmitMessage(message, target)); } else { if (laserAntenna.Status == MyLaserAntennaStatus.Connected) { return(laserAntenna.TransmitMessage(message)); } } return(false); }
private void IndividualSend() { if (isLaser) { if (lAntenna.TransmitMessage(msgQueue[0])) { msgQueue.RemoveAt(0); } } else { if (antenna.TransmitMessage(msgQueue[0], TRANSMITTARGET)) { msgQueue.RemoveAt(0); } } }
public void Main(string arg) { RController = GridTerminalSystem.GetBlockWithName(RC) as IMyShipController; if (RController == null) { Echo(RCFailedMSG); RCFailed = true; Status = "Failed"; return; } RControllers = GridTerminalSystem.GetBlockWithName(RC) as IMyRemoteControl; if (RControllers == null) { Echo(RCFailedMSG); RCFailed = true; Status = "Failed"; return; } var CCruise = GridTerminalSystem.GetBlockWithName(CC) as IMyProgrammableBlock; if (CCruise == null) { Echo(CCFailedMSG); CCFailed = true; Status = "Failed"; return; } RGyro = GridTerminalSystem.GetBlockWithName(Gyro) as IMyGyro; if (RGyro == null) { Echo(GyroFailedMSG); GyroFailed = true; Status = "Failed"; return; } RGyros = GridTerminalSystem.GetBlockWithName(Gyro) as IMyFunctionalBlock; if (RGyros == null) { Echo(GyroFailedMSG); GyroFailed = true; Status = "Failed"; return; } RCon = GridTerminalSystem.GetBlockWithName(Cargo) as IMyCargoContainer; if (RCon == null) { Echo(RConFailedMSG); RConFailed = true; Status = "Failed"; return; } LAntenna = GridTerminalSystem.GetBlockWithName(LA) as IMyLaserAntenna; if (LAntenna == null) { Echo(LAFailedMSG); LAFailed = true; Status = "Failed"; return; } LGear = GridTerminalSystem.GetBlockWithName(LG) as IMyTimerBlock; if (LGear == null) { Echo(LGFailedMSG); LGFailed = true; Status = "Failed"; return; } CCUp = GridTerminalSystem.GetBlockWithName(CCU) as IMyTimerBlock; if (CCUp == null) { Echo(CCTsFailedMSG); CCTsFailed = true; Status = "Failed"; return; } CCOff = GridTerminalSystem.GetBlockWithName(CCO) as IMyTimerBlock; if (CCOff == null) { Echo(CCTsFailedMSG); CCTsFailed = true; Status = "Failed"; return; } CCDown = GridTerminalSystem.GetBlockWithName(CCD) as IMyTimerBlock; if (CCDown == null) { Echo(CCTsFailedMSG); CCTsFailed = true; Status = "Failed"; return; } GridTerminalSystem.GetBlocksOfType(thrustersUP, x => x.WorldMatrix.Forward == RControllers.WorldMatrix.Up); if (thrustersUP.Count == 0) { Echo($"Error: No lift-off thrusters were found!"); } GridTerminalSystem.GetBlocksOfType(thrustersDOWN, x => x.WorldMatrix.Forward == RControllers.WorldMatrix.Down); if (thrustersDOWN.Count == 0) { Echo($"Error: No lift-off thrusters were found!"); } var shipMass = RController.CalculateShipMass(); TotalMass = shipMass.TotalMass; AutoEnable = RControllers.IsAutoPilotEnabled; RController.TryGetPlanetElevation(MyPlanetElevation.Sealevel, out Elev); velo = RController.GetShipSpeed(); Position = RController.GetPosition(); Gravity = (RController.GetNaturalGravity().Length()); GravityG = (RController.GetNaturalGravity().Length() / 9.81); thrustSumUP = 0; thrustSumDOWN = 0; foreach (var block in thrustersUP) { thrustSumUP += block.MaxEffectiveThrust; } foreach (var block in thrustersDOWN) { thrustSumDOWN += block.MaxEffectiveThrust; } if (Status == "Launched") { TargetGravity = (PlanetGravity * (Math.Pow((MaxR / (TargetAltitude + MinR)), 7))); Accel = ((thrustSumUP / TotalMass) + TargetGravity); //Stopping force AccelTime = ((0 - velo) / -Accel); //Seconds to stop stopDistance = ((velo * AccelTime) + ((-Accel * (AccelTime * AccelTime)) / 2)); } if (Status == "Return") { Accel = ((thrustSumDOWN / TotalMass) - PlanetGravity); //Stopping force AccelTime = ((0 - velo) / -Accel); //Seconds to stop stopDistance = ((velo * AccelTime) + ((-Accel * (AccelTime * AccelTime)) / 2)); } Echo(Ship + " Control Pro"); Echo("Status: " + Status); Echo("Altitude: " + Math.Round(Elev, 2) + "/" + TargetAltitude); Echo("Speed: " + Math.Round(velo, 2)); Echo("Total Weight: " + TotalMass); Echo("Gravity: " + Math.Round(GravityG, 2) + "G"); string msg = ("Ship" + ":" + Ship + "," + "Status" + ":" + Status + "," + "Elevation" + ":" + Elev + "," + "Position" + ":" + Position + "," + "Speed" + ":" + velo + "," + "Target" + ":" + TargetAltitude + ","); LAntenna.TransmitMessage(msg); var keyValuePairs = arg.Split(',').Select(x => x.Split(':')).Where(x => x.Length == 2).ToDictionary(x => x.First(), x => x.Last()); //Echo(thrustSumDOWN.ToString()); //Echo(thrustersDOWN.Count.ToString()); //Echo(thrustSumUP.ToString()); //Echo(thrustersUP.Count.ToString()); if (Status == "Failed") { if (RCFailed == true) { Echo(RCFailedMSG); return; } if (CCFailed == true) { Echo(CCFailedMSG); return; } if (GyroFailed == true) { Echo(GyroFailedMSG); return; } if (LAFailed == true) { Echo(LAFailedMSG); return; } if (LGFailed == true) { Echo(LGFailedMSG); return; } if (RConFailed == true) { Echo(RConFailedMSG); return; } if (CCTsFailed == true) { Echo(CCTsFailedMSG); return; } Status = "Failed"; return; } if (arg.Contains("Target")) { TargetAltitudeSetter = keyValuePairs["Target"]; TargetAltitude = int.Parse(TargetAltitudeSetter); NotReady(); } if (!Init) { Status = "Initalizing..."; NotReady(); } if (arg == "Reset") { Status = "Not Ready"; NotReady(); } if (arg == "Ready") { Status = "Ready"; Ready(); } if (arg == "Launch") { Status = "Launching"; Launch(); } if (arg == "Launched") { Status = "Launched"; Climb(); } if (arg == "Seperate") { Status = "Seperation"; Seperation(); } if (arg == "Return") { Status = "Return"; Return(); } if (arg == "Approach") { Status = "Approaching"; Approach(); } if (arg == "Land") { Status = "Landing"; Land(); } if (arg == "Landed") { Status = "Landed"; } if (Status == "Launching") { Launch(); } if (Status == "Launched") { Climb(); } if (Status == "Seperation") { Seperation(); } if (Status == "Return") { Return(); } if (Status == "Approaching") { Approach(); } if (Status == "Landing") { Land(); } if (Status == "Landed") { Status = "Landed"; } }