Now the Icarus is one chamber down and we’ve been working night after night to get control back of the ship, our tablets allow us to log in to each systems console but it’s going to take some time to regain control of the systems we lost after the explosion. Steve has automated a path for the ship to start following the solar wind that hit us, our plan-b is to keep absorbing any anti-matter that’s left in its trail, allowing us to stay powered while we get all the systems back online, and the ship headed back home at the same pace we got here in, or at the very least continue absorbing enough power to just, stay alive…

Icarus has laser energy cannons on both wings of the ship and directional rockets underneath the chambers, so far it seems only the rocket power regulation system in the last chamber is working at all and we’ll need all of them if we want to keep up with that solar wind trail. I am going through the sixth chambers code and updating it to send power to the rockets in the other chambers as well. I confirmed the ships power grid can handle the distribution but these chambers just aren’t that integrated out of the box, thankfully all the ships components are on a network, so at least they can talk to each other.

THERE IT IS! I think this might be the code I can update to send power to the rockets in the other chambers…

//@info:The power regulation functions must properly control the rockets power to ensure a safe flight.

function RocketPowerRegulationSystem(current_chamber, peer_chambers) {

var self = this;

self.regulate = function () {

var failure = false;

peer_chambers.forEach(function(peer_chamber) {

//@info: DO NOT FIRE CHAMBERS IN DIFFERENT DIRECTIONS!!!

if(peer_chamber.direction!=current_chamber.direction){

failure = true; // catastrophic failure

return true;

}

});

if(failure) {

current_chamber.direction=GEO_SPACIAL_LOCATIONS.HOME;

current_chamber.power = 0;

return false;

}

//@info: if no power issues, continue increasing power.

if(!current_chamber.power_notifications && current_chamber.power < current_chamber.requested_power) {

current_chamber.power++;

} else if(current_chamber.power_notifications || current_chamber.power > current_chamber.requested_power) {

current_chamber.power--;

}

}

}

I opened a communication line with Captain Sterling to let him know we have a chance here.

“Step me the through how the system works, I don’t want to see any changes that could put us in a place colder than what Jack already has us in.”

— Captain Sterling

I told him what I saw… when the power regulation system is created it’s passed control of the current chamber and all connected chambers (the peer_chambers). The code checks the direction of the connected chambers to make sure they don’t start firing in opposite directions, that would cause the chambers to detach and then we’d really be toast. The original programmer added a safety check, so when it occurs the rockets are powered down and the direction is set back towards home instead of actually allowing it to happen. The next lines of code simply increase or decrease the power until it reaches what the controls have requested or power notifications in the chamber start firing off. I’m sure the code embedded on the actual rocket device is much more complicated but I sure am glad this API is usable.

“What’s the patch solider!?”

— Captain Sterling

I took a deep breath as a drop of sweat floated away from my forehead, this wasn’t exactly rocket science but our lives were on the line. The patch I had to write seemed simple enough, this function had to send power to all of the chambers instead of just this one. I decided on using a nested function and some Array hacking to get the job done.

“It doesn’t sound like it’ll blow us up into too many smithereens but don’t get my hopes up too high, let me know when it’s tested and I’ll apply the patch to the ship.”

— Captain Sterling

First things first, let me wrap the power regulation logic in a function so I can use it to regulate the power in the chambers throughout the rest of the ship.

//@info:The power regulation functions must properly control the rockets power to ensure a safe flight.

function RocketPowerRegulationSystem(current_chamber, peer_chambers) {

var self = this;

//@info: nested function to handle any power regulation.

var actually_regulate = function(current_chamber, peer_chambers){

var failure = false;

peer_chambers.forEach(function(peer_chamber) {

//@info: DO NOT FIRE CHAMBERS IN DIFFERENT DIRECTIONS!!!

if(peer_chamber.direction!=current_chamber.direction){

failure = true; // catastrophic failure

return true;

}

});

if(failure) {

current_chamber.direction=GEO_SPACIAL_LOCATIONS.HOME;

current_chamber.power = 0;

return false;

}

//@info: if no power issues, continue increasing power.

if(!current_chamber.power_notifications && current_chamber.power < current_chamber.requested_power) {

current_chamber.power++;

} else if(current_chamber.power_notifications || current_chamber.power > current_chamber.requested_power) {

current_chamber.power--;

}

}; self.regulate = function (current_chamber, peer_chambers) {

actually_regulate(current_chamber, peer_chambers);

};

}

OOOUCH!!! — The communication piece in my ear squelched in what’s gotta be the best clarity I’ve heard from it yet, it’s the Captain and it sounds like we are in another emergency state all together…

“Looks like more bad space weather headed our way, awall of plasma is headed for impact in five minutes and thirty-two seconds, let’s get those rockets patched!”

— Captain Sterling

I have to get the actually_regulate logic distributed to the other chambers before it’s too late.

The code shows that peer_chambers is an array, so it’s pretty much a list of the connected chambers in the ship. I also know an array has two functions I can use to help me call the actually_regulate function easily, shift & push. Shift will give me an item from the beginning of an array and Push will let me add an item to the end of an array. I should be able to shift a chamber from the bottom of the list, and pass it to actually_regulate function using the array of other chambers as the value for peer_chambers,when that completes I would push the same chamber to the end of the list and shift another chamber from the bottom, continuing to do this all in one loop for all of the other chambers…

This just might be enough to save us, DAMN! Only four minutes -fifty-two seconds left.

//@info:The power regulation functions must properly control the rockets power to ensure a safe flight.

function RocketPowerRegulationSystem(current_chamber, peer_chambers) {

var self = this;

//@info: nested function to handle any power regulation.

var actually_regulate = function(current_chamber, peer_chambers){

var failure = false;

peer_chambers.forEach(function(peer_chamber) {

//@info: DO NOT FIRE CHAMBERS IN DIFFERENT DIRECTIONS!!!

if(peer_chamber.direction!=current_chamber.direction){

failure = true; // catastrophic failure

return true;

}

});

if(failure) {

current_chamber.direction=GEO_SPACIAL_LOCATIONS.HOME;

current_chamber.power = 0;

return false;

}

//@info: if no power issues, continue increasing power.

if(!current_chamber.power_notifications && current_chamber.power < current_chamber.requested_power) {

current_chamber.power++;

} else if(current_chamber.power_notifications || current_chamber.power > current_chamber.requested_power) {

current_chamber.power--;

}

} self.regulate = function (current_chamber, peer_chambers) {

actually_regulate(current_chamber , peer_chambers); //@info: regulate the power for this chamber.

var last_chamber = current_chamber;

//@info: regulate the power for the other chambers also.

for(var i =0; i<peer_chambers.length; i++) {

//@info: add last chamber to the end of the list of peers.

peer_chambers.push(last_chamber);

//@info: get and remove the first chamber in the beginning of the list from the list entirely.

var chamber = peer_chambers.shift();

//@info: regulate the power for the chamber we just removed.

actually_regulate(chamber, peer_chambers);

}

};

}

I’ve let the Captain know that I have a patch ready to go, now the text on the monitors are flashing red… we only have three minutes and eight seconds left until impact with the plasma stream.

“You get a chance to test that Soldier?! Or is there something else we should be praying doesn’t happen?”

— Captain Sterling

My code was sound and I was sure of it, not to mention we don’t have time to write tests that would do as good as proving space still has zero gravity. I have to own up to this kind of decision though, it’s a brave move to go untested but it’s everybody’s life that’s in danger if my code fails.

“Great, was writing it in half the time with twice the number of tests out of the question? Jack get over there and review the code while I apply the patch, better late than never but — I REALLY DON’T LIKE BETTING THE LIVES OF THIS CREW ON STANDARDS THAT LOW SOLDIER!”

— Captain Sterling

I wonder if being a dick is something they teach you in Officers School…

I committed my updates to the system and tossed Jack my console to review the changes. I then went over to the Captain to let him know he could restart the Power Regulation System, staring directly into his eyes while I gave him the okay. I wanted him to be sure of how confident I was about my code, I knew it would get us out of this but ultimately the decision was still up to him. Captain Sterling was the only one with permissions to actually apply any patch that gets committed to the ships code branch.

The Captain looked back at his console and began the restart process,this was the most dangerous part of all, I could hear half the crew hold their breath just as he started. After the solar wind hit us we noticed a few systems behaving especially fragile, a restart could mean none of the rockets coming back online at all, and this was our last chance to escape.