 |
Author |
Message |
andg
SOT-223 - Salvaje
Joined: Thu Apr 18, 2013 3:21 am Posts: 144 Location: Portland OREGON
|
at this point external event handlers can be attached that log json data of any request. Code: :before_transition :park => do moving? transition[neutral] end Optimizing state machine to do simplest, most critical validation just before the transition. Code: :event park_brake transition[park] end
Code: def moving? db.sensors.find({"speed" : {$exists:true}}, {speed:1}).sort({_id:-1}).limit(1) end
find documents with a speed key and return the most recent one. Code: { "_id" : ObjectId("517f3fbb6e46043d8781257f"), "speed" : 2 }
_________________Code: {url: andrewgauger.com, skype: andrgaug, email: andg@andrewgauger.com, car: 25, fb: facebook.com/DonatoArrighi, github: andg.github.io, assets:https://s3.amazonaws.com/3400}
Last edited by andg on Tue Apr 30, 2013 8:35 pm, edited 7 times in total.
|
Sat Apr 27, 2013 6:11 am |
|
 |
andg
SOT-223 - Salvaje
Joined: Thu Apr 18, 2013 3:21 am Posts: 144 Location: Portland OREGON
|
Code: def avg_speed if ( m = db.sensor.count(speed: {$exists:true}) ) < 1 raise "we don't know if we're moving!" db.sensors.aggregate( [ { $group: { _id: null, count: { $sum: 1 } } }] ) / m end
aggregation provides powerful framework to do anything outside of the simple sum succintly But what we are looking to do is at the database be able to implement high level OOP into the database layer which is where we need functions added to our playground. a mapreduce might look like this: Code: res = db.<mycollection>.mapReduce(map, red);
which can create a temporary collect to abstract data in different ways
_________________Code: {url: andrewgauger.com, skype: andrgaug, email: andg@andrewgauger.com, car: 25, fb: facebook.com/DonatoArrighi, github: andg.github.io, assets:https://s3.amazonaws.com/3400}
Last edited by andg on Tue Apr 30, 2013 8:37 pm, edited 6 times in total.
|
Sat Apr 27, 2013 6:11 am |
|
 |
andg
SOT-223 - Salvaje
Joined: Thu Apr 18, 2013 3:21 am Posts: 144 Location: Portland OREGON
|
Code: map = function() { var res = 0; for (i = 0; i < this.marks.length; i++) { res = res + this.marks[i]; } var median = res/this.marks.length; emit(this._id,{marks:this.marks,median:median}); }
reduce = function (k, values) { values.forEach(function(value) { result = value; }); return result; }
Code: group({ initial: {count: 0, running_average: 0}, reduce: function(doc, out) {out.count++; out.running_average+=doc.v; },finalize: function(out) { out.average = out.running_average / out.count;}}); Used formatting more like node js here. If you want to learn the power of mongoDB you need to learn the Javascript engine that runs it.
_________________Code: {url: andrewgauger.com, skype: andrgaug, email: andg@andrewgauger.com, car: 25, fb: facebook.com/DonatoArrighi, github: andg.github.io, assets:https://s3.amazonaws.com/3400}
Last edited by andg on Tue Apr 30, 2013 7:04 pm, edited 5 times in total.
|
Sat Apr 27, 2013 6:13 am |
|
 |
andg
SOT-223 - Salvaje
Joined: Thu Apr 18, 2013 3:21 am Posts: 144 Location: Portland OREGON
|
production runs through manufacturing. In 24 hrs product had velocity of 26 units/sec and we need a way to expose business intelligence through an api so that adjunct systems can communicate. Code: {)id: BSON, product: "Cascade", invent_trans_id: 3445},
{)id: BSON, product: "Cascade", invent_trans_id: 3446},
{)id: BSON, product: "Cascade", invent_trans_id: 3447}
_________________Code: {url: andrewgauger.com, skype: andrgaug, email: andg@andrewgauger.com, car: 25, fb: facebook.com/DonatoArrighi, github: andg.github.io, assets:https://s3.amazonaws.com/3400}
Last edited by andg on Sat Apr 27, 2013 5:16 pm, edited 1 time in total.
|
Sat Apr 27, 2013 6:16 am |
|
 |
andg
SOT-223 - Salvaje
Joined: Thu Apr 18, 2013 3:21 am Posts: 144 Location: Portland OREGON
|
JSON is adjunct XML in terms of data exposure. mongo data can be exposed in an xml format from incredibly low level processes. all the way up through c and ruby comes along Code: <nodes> <node><id>BSON</id> <product>Cascade</product>, <invent_trans_id> 3445<</invent_trans_id> </node> <node><id>BSON</id> <product>Cascade</product>, <invent_trans_id> 3446<</invent_trans_id> </node> <node><id>BSON</id> <product>Cascade</product>, <invent_trans_id> 3447<</invent_trans_id> </node> </nodes>
_________________Code: {url: andrewgauger.com, skype: andrgaug, email: andg@andrewgauger.com, car: 25, fb: facebook.com/DonatoArrighi, github: andg.github.io, assets:https://s3.amazonaws.com/3400}
Last edited by andg on Tue Apr 30, 2013 5:32 am, edited 3 times in total.
|
Sat Apr 27, 2013 6:17 am |
|
 |
andg
SOT-223 - Salvaje
Joined: Thu Apr 18, 2013 3:21 am Posts: 144 Location: Portland OREGON
|
CAN is a network aware protocol using as few as 4 wires although all implementations use 9 which when you are dealing with shielded signals is a major pain in the arse. this leads to a various sample size for an event handler which shares the data model. As more signals are sent through the network each cpu has to keep up with the message size so each sensor gets tuned from a networking perspective Networks can be taped. They can be injected. If an external controller detects on the network something is missing it can inject a calculated signal, detect if it sent a signal in error and stop doing that for a while and externally log the sensor before it tells you you should look into something on the car. 4 wires are TX and RX signals CAN interface is impractical in its implementation if you output tap the RX and validate against your local code to know when to fire. remote attached networked sensors that only alert the event handlers which run on two bluetooth attached iPads that elect which one is in charge. The two iPads are running native app or broken if necissary. They display EMS Studio as the dash and ensure all of the necessary signals are present even if the remote sensor isn't present. engine at predefined rpm shifts from 24x signal to 3x signal for performance reasons and that signal takes too long to process normally. This remote sensor can be queried by sending a request signal across the network to provide signal for a duration. local validation code on the output device uses CAN decipering signals across those 4 wires. GM DIS is first example on car already using the technology by pre processing the7x signal and converign it to 3x off board what better place to put input signals like slap shifters that say lets upshift and we want it to happen asap. event logger is waiting for any signal of the slap shift telling the `car` to do something unique like any good event handler deals with Transmission control happens externally with a harness to the transmission which signals the network of a query interface to find the neutral safety switch status lets say we want our event handler to detect throttle platee at 0 since this is a major event for the system we need to bypass air since thats how I sit in trtaffic mostly on the brake. Idle air control through the existing valve is valuable. MAP, TPS, and TACH can be interpreted that we're idling but there is no reason to send these signals everywhere at every chance so we tune the network, and data logging usage by allowing for small documents to transmit. need to add event handler for throttle plate position by time interval and time interval acceration This type of logic lives at a higher level than the firmware. The entire design is to be able to tune event handlers for known conditions. I currently have an evap leak that I ought to fix, but a check engine light is a bit extreme for this. normal cpu not utilized determining based off existing tables or at the oscellation. Event handlers become the slimed down versions of code. gemsets or versions of the modules become available to each external controller.
_________________Code: {url: andrewgauger.com, skype: andrgaug, email: andg@andrewgauger.com, car: 25, fb: facebook.com/DonatoArrighi, github: andg.github.io, assets:https://s3.amazonaws.com/3400}
Last edited by andg on Tue Apr 30, 2013 9:01 pm, edited 10 times in total.
|
Sat Apr 27, 2013 6:28 am |
|
 |
andg
SOT-223 - Salvaje
Joined: Thu Apr 18, 2013 3:21 am Posts: 144 Location: Portland OREGON
|
Code: CREATE TRIGGER ON INVENTORY FOR INSERT AS UPDATE INVENTORY SET VELOCITY=calculation Not implemented in mongodb. Implement at a higher level or consider tailable cursors on the oplog oplog used in replication
_________________Code: {url: andrewgauger.com, skype: andrgaug, email: andg@andrewgauger.com, car: 25, fb: facebook.com/DonatoArrighi, github: andg.github.io, assets:https://s3.amazonaws.com/3400}
Last edited by andg on Tue Apr 30, 2013 8:52 pm, edited 3 times in total.
|
Sat Apr 27, 2013 6:29 am |
|
 |
andg
SOT-223 - Salvaje
Joined: Thu Apr 18, 2013 3:21 am Posts: 144 Location: Portland OREGON
|
Code: show dbs sensors 0.203125GB local 0.314223GB In this example there is a replicated collection that multiple members add their sensor data to a document Code: rs.status() db.runCommand( { replSetGetStatus: 1 } ) get status of replication Oplog equivalent to transaction log. Used for replication. Capped collection on primary member
_________________Code: {url: andrewgauger.com, skype: andrgaug, email: andg@andrewgauger.com, car: 25, fb: facebook.com/DonatoArrighi, github: andg.github.io, assets:https://s3.amazonaws.com/3400}
Last edited by andg on Fri May 03, 2013 1:59 am, edited 5 times in total.
|
Sat Apr 27, 2013 6:29 am |
|
 |
andg
SOT-223 - Salvaje
Joined: Thu Apr 18, 2013 3:21 am Posts: 144 Location: Portland OREGON
|
so lets let the sequential fuel injection go for a moment by profiding a tach signal over the same networked interfeace. they determine when the right time the ought to fire and be able to switch back and forth between different bodes my overwriting oop driven classes.
_________________Code: {url: andrewgauger.com, skype: andrgaug, email: andg@andrewgauger.com, car: 25, fb: facebook.com/DonatoArrighi, github: andg.github.io, assets:https://s3.amazonaws.com/3400}
|
Sat Apr 27, 2013 7:21 am |
|
 |
Fred
Moderator
Joined: Tue Jan 15, 2008 2:31 pm Posts: 15342 Location: Home sweet home!
|
You were just trying to up your package type to BGA-208, weren't you!!?? I did you a favour and customised it for you :-) http://stuff.fredcooke.com/AndyGHalfPos ... rnight.png
_________________DIYEFI.org - where Open Source means Open Source, and Free means Freedom FreeEMS.org - the open source engine management system FreeEMS dev diary and its comments thread and my turbo truck!n00bs, do NOT PM or email tech questions! Use the forum! The ever growing list of FreeEMS success stories!
|
Sat Apr 27, 2013 10:25 am |
|
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|
 |