Example #1
0
 public void Display(ZACommons commons)
 {
     if (Active)
     {
         commons.Echo("Cruise control active");
         commons.Echo(string.Format("Set Speed: {0:F1} m/s", TargetSpeed));
         commons.Echo(string.Format("Actual Speed: {0:F1} m/s", CurrentSpeed));
     }
 }
 public void Display(ZACommons commons)
 {
     if (Active)
     {
         commons.Echo(string.Format("Solar Max Power: {0}", PrintUtils.FormatPower(TotalPower)));
     }
     else
     {
         commons.Echo("Solar Max Power: Paused");
     }
 }
 public void Display(ZACommons commons)
 {
     if (!Active)
     {
         commons.Echo("Solar Max Power: Paused");
     }
     else
     {
         commons.Echo(string.Format("Solar Max Power: {0}", ZACommons.FormatPower(CurrentMaxPower)));
     }
 }
 public void Display(ZACommons commons)
 {
     if (PRODUCTION_MANAGER_SETUP)
     {
         commons.Echo("Setup complete. Set PRODUCTION_MANAGER_SETUP to false to enable ProductionManager");
     }
     else
     {
         commons.Echo("Production Manager: " +
                      (CurrentState == STATE_INACTIVE ? "Paused" : "Active"));
     }
 }
    public void Display(ZACommons commons, EventDriver eventDriver)
    {
        switch (Mode)
        {
        case Modes.Idle:
            commons.Echo("Fire Control: Off");
            break;

        case Modes.Armed:
            commons.Echo("Fire Control: Enabled");
            break;

        case Modes.Snapshot:
            commons.Echo("Fire Control: Searching");
            break;

        case Modes.Locked:
            commons.Echo("Fire Control: Locked");
            commons.Echo(string.Format("Last Update: {0:F1} s", (eventDriver.TimeSinceStart - LastTargetUpdate).TotalSeconds));
            break;
        }
        commons.Echo(string.Format("Shell Speed: {0:F1} m/s", ShellSpeed));
        commons.Echo(string.Format("Shell Offset: {0:F2} m", ShellOffset));
        commons.Echo(string.Format("Fire Delay: {0:F2} s", ShellFireDelay));
    }
Example #6
0
 public void Display(ZACommons commons)
 {
     if (Indexes.Count > 0)
     {
         commons.Echo("Sequencer active: " + string.Join(", ", Indexes.Keys));
     }
 }
Example #7
0
 public void Display(ZACommons commons)
 {
     if (Mode != IDLE)
     {
         commons.Echo("Damage Control: Active");
     }
 }
Example #8
0
 public void Display(ZACommons commons)
 {
     if (Indexes.Count > 0)
     {
         commons.Echo("Sequencer active: " + string.Join(", ", Indexes.Keys));
     }
 }
    public void Run(ZACommons commons, EventDriver eventDriver)
    {
        if (!Active)
        {
            return;
        }

        TotalPower = 0.0f;
        var solarGroups = commons.GetBlockGroupsWithPrefix(MAX_POWER_GROUP_PREFIX);

        foreach (var group in solarGroups)
        {
            var rotor = GetRotor(group);
            if (rotor == null)
            {
                commons.Echo(string.Format("Group {0} ignored; needs exactly 1 rotor", group.Name));
                continue;
            }
            else if (rotor.CubeGrid != commons.Me.CubeGrid)
            {
                // Skip if rotor is on a different grid than this programmable block
                continue;
            }

            var solarPanelDetails = new SolarPanelDetails(group);
            var currentMaxPower   = solarPanelDetails.MaxPowerOutput;

            float maxPower;
            if (!MaxPowers.TryGetValue(group.Name, out maxPower))
            {
                maxPower = -100.0f;
            }

            var minError = solarPanelDetails.DefinedPowerOutput * SOLAR_ROTOR_MIN_ERROR;
            var delta    = currentMaxPower - maxPower;
            MaxPowers[group.Name] = currentMaxPower;

            if (delta > minError || currentMaxPower < minError /* failsafe */)
            {
                // Keep going
                rotor.Enabled = true;
            }
            else if (delta < -minError)
            {
                // Back up
                rotor.Enabled = true;
                rotor.ApplyAction("Reverse");
            }
            else
            {
                // Hold still for a moment
                rotor.Enabled = false;
            }

            TotalPower += currentMaxPower;
        }

        eventDriver.Schedule(RunDelay, Run);
    }
Example #10
0
    public void Display(ZACommons commons, EventDriver eventDriver)
    {
        switch (Mode)
        {
        case Modes.Idle:
            commons.Echo("Tracker: Off");
            break;

        case Modes.Armed:
            commons.Echo("Tracker: Enabled");
            break;

        case Modes.Snapshot:
            commons.Echo("Tracker: Searching");
            commons.Echo(string.Format("Max. Range: {0:F2} m", RaycastRange));
            break;

        case Modes.Painting:
        case Modes.Released:
            commons.Echo(string.Format("Tracker: Painting ({0})", Mode == Modes.Painting ? (GyroLock ? "locked" : "lost") : "released"));
            commons.Echo(string.Format("Max. Range: {0:F2} m", RaycastRange));
            if (LastTargetUpdate != null)
            {
                commons.Echo(string.Format("Last Update: {0:F1} s", (eventDriver.TimeSinceStart - (TimeSpan)LastTargetUpdate).TotalSeconds));
            }
            break;
        }
    }
Example #11
0
    public void Display(ZACommons commons)
    {
        switch (Mode)
        {
        case IDLE:
            break;

        case UNDOCKING:
            commons.Echo("SmartUndock: Undocking");
            break;

        case RETURNING:
            commons.Echo("SmartUndock: Returning");
            break;

        case ORIENTING:
            commons.Echo("SmartUndock: Orienting");
            break;
        }
    }
    public void Run(ZACommons commons, EventDriver eventDriver)
    {
        if (!Active) return;

        TotalPower = 0.0f;
        var solarGroups = commons.GetBlockGroupsWithPrefix(MAX_POWER_GROUP_PREFIX);
        for (var e = solarGroups.GetEnumerator(); e.MoveNext();)
        {
            var group = e.Current;

            var rotor = GetRotor(group);
            if (rotor == null)
            {
                commons.Echo(string.Format("Group {0} ignored; needs exactly 1 rotor", group.Name));
                continue;
            }
            else if (rotor.CubeGrid != commons.Me.CubeGrid)
            {
                // Skip if rotor is on a different grid than this programmable block
                continue;
            }

            var solarPanelDetails = new SolarPanelDetails(group);
            var currentMaxPower = solarPanelDetails.MaxPowerOutput;

            float maxPower;
            if (!MaxPowers.TryGetValue(group.Name, out maxPower)) maxPower = -100.0f;

            var minError = solarPanelDetails.DefinedPowerOutput * SOLAR_ROTOR_MIN_ERROR;
            var delta = currentMaxPower - maxPower;
            MaxPowers[group.Name] = currentMaxPower;

            if (delta > minError || currentMaxPower < minError /* failsafe */)
            {
                // Keep going
                rotor.SetValue<bool>("OnOff", true);
            }
            else if (delta < -minError)
            {
                // Back up
                rotor.SetValue<bool>("OnOff", true);
                rotor.ApplyAction("Reverse");
            }
            else
            {
                // Hold still for a moment
                rotor.SetValue<bool>("OnOff", false);
            }

            TotalPower += currentMaxPower;
        }

        eventDriver.Schedule(RunDelay, Run);
    }
    public void Display(ZACommons commons)
    {
        switch (Mode)
        {
        case Modes.Idle:
            break;

        case Modes.Undocking:
            commons.Echo("SmartUndock: Undocking");
            break;

        case Modes.Returning:
            commons.Echo("SmartUndock: Returning");
            break;

        case Modes.Orienting:
            commons.Echo("SmartUndock: Orienting");
            break;
        }
    }
Example #14
0
 public void Display(ZACommons commons)
 {
     commons.Echo(Result.ToString());
 }
Example #15
0
 public void Display(ZACommons commons)
 {
     if (Active)
     {
         commons.Echo("Cruise control active");
         commons.Echo(string.Format("Set Speed: {0:F1} m/s", TargetSpeed));
         commons.Echo(string.Format("Actual Speed: {0:F1} m/s", CurrentSpeed));
     }
 }
Example #16
0
 public void Display(ZACommons commons)
 {
     switch (Mode)
     {
         case IDLE:
             break;
         case UNDOCKING:
             commons.Echo("SmartUndock: Undocking");
             break;
         case RETURNING:
             commons.Echo("SmartUndock: Returning");
             break;
         case ORIENTING:
             commons.Echo("SmartUndock: Orienting");
             break;
     }
 }
Example #17
0
    public void Run(ZACommons commons)
    {
        var batteries = GetBatteries(commons);

        if (CurrentState == null)
        {
            // First time run, get to known state and return
            CurrentState = STATE_NORMAL;
            SinceLastStateChange = TimeSpan.FromSeconds(0);
            ZACommons.SetBatteryRecharge(batteries, false);
            return;
        }

        SinceLastStateChange += commons.Program.ElapsedTime;

        var aggregateDetails = new AggregateBatteryDetails(batteries);
        string stateStr = "Unknown";

        switch (CurrentState)
        {
            case STATE_NORMAL:
                if (SinceLastStateChange >= DischargeInterval)
                {
                    // Don't check again until next interval, regardless of whether we
                    // change state
                    SinceLastStateChange = TimeSpan.FromSeconds(0);

                    // Only recharge if there is available power, e.g. the batteries have no load,
                    // and there is need to
                    if (aggregateDetails.CurrentPowerOutput == 0.0f &&
                        aggregateDetails.CurrentStoredPower < aggregateDetails.MaxStoredPower &&
                        Active)
                    {
                        CurrentState = STATE_RECHARGE;
                        ZACommons.SetBatteryRecharge(batteries, true);
                    }
                    else
                    {
                        // Force discharge, just in case
                        ZACommons.SetBatteryRecharge(batteries, false);
                    }
                }
                stateStr = Active ? "Normal" : "Paused";
                break;
            case STATE_RECHARGE:
                // Too bad we don't have access to battery input (w/o parsing DetailInfo)
                // Then we could figure out non-battery load and cancel recharge pre-emptively
                // when needed
                if (SinceLastStateChange >= RechargeInterval)
                {
                    CurrentState = STATE_NORMAL;
                    SinceLastStateChange = TimeSpan.FromSeconds(0);
                    ZACommons.SetBatteryRecharge(batteries, false);
                }
                stateStr = "Recharging";
                break;
            case STATE_DISABLED:
                // Switch back to auto if full
                if (aggregateDetails.CurrentStoredPower >= aggregateDetails.MaxStoredPower)
                {
                    CurrentState = STATE_NORMAL;
                    SinceLastStateChange = TimeSpan.FromSeconds(0);
                    ZACommons.SetBatteryRecharge(batteries, false);
                }
                stateStr = "Disabled";
                break;
        }

        // See if we have a net power loss
        var newDraining = AddDrainData(aggregateDetails.CurrentPowerOutput > 0.0f);
        if (powerDrainHandler != null)
        {
            if (!Draining && newDraining)
            {
                powerDrainHandler.PowerDrainStarted(commons);
            }
            else if (Draining && !newDraining)
            {
                powerDrainHandler.PowerDrainEnded(commons);
            }
        }
            
        Draining = newDraining;

        commons.Echo(string.Format("Battery Manager: {0}", stateStr));
        commons.Echo(string.Format("Total Stored Power: {0}h", ZACommons.FormatPower(aggregateDetails.CurrentStoredPower)));
        commons.Echo(string.Format("Max Stored Power: {0}h", ZACommons.FormatPower(aggregateDetails.MaxStoredPower)));
        if (Draining) commons.Echo("Net power loss!");
    }
 public void Display(ZACommons commons)
 {
     if (PRODUCTION_MANAGER_SETUP)
     {
         commons.Echo("Setup complete. Set PRODUCTION_MANAGER_SETUP to false to enable ProductionManager");
     }
     else
     {
         commons.Echo("Production Manager: " +
                      (CurrentState == STATE_INACTIVE ? "Paused" : "Active"));
     }
 }
Example #19
0
 public void Display(ZACommons commons)
 {
     switch (Mode)
     {
         case IDLE:
             break;
         case BURNING:
             commons.Echo("VTVL: Burn phase");
             if (Autodrop) commons.Echo("Auto-drop starting");
             break;
         case GLIDING:
             commons.Echo("VTVL: Glide phase");
             if (Autodrop)
             {
                 commons.Echo(string.Format("Elevation: {0:F2} m", Elevation));
                 commons.Echo(string.Format("Brake Distance: {0:F2} m", Distance));
             }
             break;
         case BRAKING:
             commons.Echo("VTVL: Braking");
             break;
         case APPROACHING:
             commons.Echo("VTVL: Approach phase");
             commons.Echo(string.Format("Elevation: {0:F2} m", Elevation));
             commons.Echo(string.Format("Stop Distance: {0:F2} m", Distance));
             break;
         case LAUNCHING:
             commons.Echo("VTVL: Launching");
             break;
         case ORBITING:
             commons.Echo("VTVL: Orbiting");
             break;
     }
 }
Example #20
0
 public void Display(ZACommons commons)
 {
     if (Mode != IDLE)
     {
         commons.Echo("Damage Control: Active");
     }
 }
 public void Display(ZACommons commons)
 {
     if (!Active)
     {
         commons.Echo("Solar Max Power: Paused");
     }
     else
     {
         commons.Echo(string.Format("Solar Max Power: {0}", ZACommons.FormatPower(CurrentMaxPower)));
     }
 }
Example #22
0
    public void Display(ZACommons commons)
    {
        switch (Mode)
        {
        case Modes.Idle:
            break;

        case Modes.Burning:
            commons.Echo("VTVL: Burn phase");
            if (Autodrop)
            {
                commons.Echo("Auto-drop starting");
            }
            break;

        case Modes.Gliding:
            commons.Echo("VTVL: Glide phase");
            if (Autodrop)
            {
                commons.Echo(string.Format("Elevation: {0:F2} m", Elevation));
                commons.Echo(string.Format("Brake Distance: {0:F2} m", Distance));
            }
            break;

        case Modes.Braking:
            commons.Echo("VTVL: Braking");
            break;

        case Modes.Approaching:
            commons.Echo("VTVL: Approach phase");
            commons.Echo(string.Format("Elevation: {0:F2} m", Elevation));
            commons.Echo(string.Format("Stop Distance: {0:F2} m", Distance));
            break;

        case Modes.Launching:
            commons.Echo("VTVL: Launching");
            break;

        case Modes.Orbiting:
            commons.Echo("VTVL: Orbiting");
            break;
        }
    }
Example #23
0
    public void Display(ZACommons commons)
    {
        switch (Mode)
        {
        case IDLE:
            break;

        case BURNING:
            commons.Echo("VTVL: Burn phase");
            if (Autodrop)
            {
                commons.Echo("Auto-drop starting");
            }
            break;

        case GLIDING:
            commons.Echo("VTVL: Glide phase");
            if (Autodrop)
            {
                commons.Echo(string.Format("Elevation: {0:F2} m", Elevation));
                commons.Echo(string.Format("Brake Distance: {0:F2} m", Distance));
            }
            break;

        case BRAKING:
            commons.Echo("VTVL: Braking");
            break;

        case APPROACHING:
            commons.Echo("VTVL: Approach phase");
            commons.Echo(string.Format("Elevation: {0:F2} m", Elevation));
            commons.Echo(string.Format("Stop Distance: {0:F2} m", Distance));
            break;

        case LAUNCHING:
            commons.Echo("VTVL: Launching");
            break;

        case ORBITING:
            commons.Echo("VTVL: Orbiting");
            break;
        }
    }
Example #24
0
 public void Display(ZACommons commons)
 {
     commons.Echo(AccelResults.ToString());
 }
Example #25
0
    public void Run(ZACommons commons)
    {
        var batteries = GetBatteries(commons);

        if (CurrentState == null)
        {
            // First time run, get to known state and return
            CurrentState         = STATE_NORMAL;
            SinceLastStateChange = TimeSpan.FromSeconds(0);
            ZACommons.SetBatteryRecharge(batteries, false);
            return;
        }

        SinceLastStateChange += commons.Program.ElapsedTime;

        var    aggregateDetails = new AggregateBatteryDetails(batteries);
        string stateStr         = "Unknown";

        switch (CurrentState)
        {
        case STATE_NORMAL:
            if (SinceLastStateChange >= DischargeInterval)
            {
                // Don't check again until next interval, regardless of whether we
                // change state
                SinceLastStateChange = TimeSpan.FromSeconds(0);

                // Only recharge if there is available power, e.g. the batteries have no load,
                // and there is need to
                if (aggregateDetails.CurrentPowerOutput == 0.0f &&
                    aggregateDetails.CurrentStoredPower < aggregateDetails.MaxStoredPower &&
                    Active)
                {
                    CurrentState = STATE_RECHARGE;
                    ZACommons.SetBatteryRecharge(batteries, true);
                }
                else
                {
                    // Force discharge, just in case
                    ZACommons.SetBatteryRecharge(batteries, false);
                }
            }
            stateStr = Active ? "Normal" : "Paused";
            break;

        case STATE_RECHARGE:
            // Too bad we don't have access to battery input (w/o parsing DetailInfo)
            // Then we could figure out non-battery load and cancel recharge pre-emptively
            // when needed
            if (SinceLastStateChange >= RechargeInterval)
            {
                CurrentState         = STATE_NORMAL;
                SinceLastStateChange = TimeSpan.FromSeconds(0);
                ZACommons.SetBatteryRecharge(batteries, false);
            }
            stateStr = "Recharging";
            break;

        case STATE_DISABLED:
            // Switch back to auto if full
            if (aggregateDetails.CurrentStoredPower >= aggregateDetails.MaxStoredPower)
            {
                CurrentState         = STATE_NORMAL;
                SinceLastStateChange = TimeSpan.FromSeconds(0);
                ZACommons.SetBatteryRecharge(batteries, false);
            }
            stateStr = "Disabled";
            break;
        }

        // See if we have a net power loss
        var newDraining = AddDrainData(aggregateDetails.CurrentPowerOutput > 0.0f);

        if (powerDrainHandler != null)
        {
            if (!Draining && newDraining)
            {
                powerDrainHandler.PowerDrainStarted(commons);
            }
            else if (Draining && !newDraining)
            {
                powerDrainHandler.PowerDrainEnded(commons);
            }
        }

        Draining = newDraining;

        commons.Echo(string.Format("Battery Manager: {0}", stateStr));
        commons.Echo(string.Format("Total Stored Power: {0}h", ZACommons.FormatPower(aggregateDetails.CurrentStoredPower)));
        commons.Echo(string.Format("Max Stored Power: {0}h", ZACommons.FormatPower(aggregateDetails.MaxStoredPower)));
        if (Draining)
        {
            commons.Echo("Net power loss!");
        }
    }
Example #26
0
 public void Display(ZACommons commons)
 {
     commons.Echo(Result.ToString());
 }
 public void Display(ZACommons commons)
 {
     commons.Echo(string.Format("Status: {0}", State));
     commons.Echo(string.Format("TargetInfo: {0}", !TargetInfo.IsEmpty()));
 }