|
| 1 | +API for Python interface. |
| 2 | + |
| 3 | +1. Key data structures, not accessed directly, but important for concepts: |
| 4 | + - Element: Managers for objects. This includes data, messaging, |
| 5 | + field info and class info. All Elements can be arrays. |
| 6 | + - Finfo: Field information specifiers, used to build up the MOOSE |
| 7 | + interface to the underlying C++ class. Similar to the old MOOSE. |
| 8 | + Major Subclasses: |
| 9 | + - DestFinfo: used for functions of the Object. Can be called |
| 10 | + either using SetGet::set or by messages. |
| 11 | + - SrcFinfo: Used to call messages. |
| 12 | + - ValueFinfo: Used to define fields. The ReadOnly kind has |
| 13 | + just the 'get' function, whereas the normal kind |
| 14 | + also has a 'set' function. Both 'get' and 'set' are |
| 15 | + implemented as DestFinfos. |
| 16 | + - Cinfo: Class information specifier, used to specify class name, |
| 17 | + inheritance, and manage the array of Finfos. |
| 18 | + - Msg: Messages. Many subclasses. Handle communication between Elements. |
| 19 | + All Msgs are between precisely two Elements. So the Elements are nodes |
| 20 | + and the Msgs are edges. Msg have a lot of variety in how they control |
| 21 | + data transfer between individual array entries within the source and |
| 22 | + destination Element. Data transfer can be bidirectional. |
| 23 | + All Msgs provide a handle to an Element called a MsgManager, which |
| 24 | + allows you to inspect the Msg fields and in some cases modify them. |
| 25 | + But you cannot modify the source and destination Elements. |
| 26 | + |
| 27 | +2. Key data structures that you will access. |
| 28 | + |
| 29 | +Id: Handle to Elements. |
| 30 | +DataId: Handle to objects on Elements. Has a data part and a field part. |
| 31 | + The data part is the parent object, and is used for any array Element. |
| 32 | + The field part is for array fields within individual data entries, |
| 33 | + in cases where the array fields themselves are accessed like Elements. |
| 34 | + For example, in an IntFire neuron, you could have an |
| 35 | + array of a million IntFire neurons on Element A, and each IntFire |
| 36 | + neuron might have a random individual number, say, 10000, 15000, 8000, |
| 37 | + etc Synapses. To index Synapse 234 on IntFire 999999 you would use a |
| 38 | + DataId( 999999, 234). |
| 39 | + |
| 40 | +ObjId: Composite of Id and DataId. Allows you to uniquely identify any entity |
| 41 | + in the simulation. |
| 42 | + |
| 43 | + |
| 44 | +3. Field assignments and function calls: |
| 45 | + File: SetGet.h |
| 46 | + This has a series of templates for different argument cases. |
| 47 | + 1. If you want to call a function foo( int A, double B ) on |
| 48 | + ObjId oid, you would do: |
| 49 | + |
| 50 | + SetGet2< int, double >::set( oid, "foo", A, B ); |
| 51 | + |
| 52 | + 2. To call a function bar( int A, double B, string C ) on oid: |
| 53 | + SetGet3< int, double, string >::set( oid, "bar", A, B, C ); |
| 54 | + |
| 55 | + 3. To assign a field value "short abc" on object oid: |
| 56 | + Field< short >::set( oid, "abc", 123 ); |
| 57 | + |
| 58 | + 4. To get a field value "double pqr" on object obj: |
| 59 | + double x = Field< short >::get( oid, "pqr" ); |
| 60 | + |
| 61 | + 5. To assign the double 'xcoord' field on all the objects on |
| 62 | + element Id id, which has an array of the objects: |
| 63 | + vector< double > newXcoord; |
| 64 | + // Fill up the vector here. |
| 65 | + Field< double >::setVec( id, "xcoord", newXcoord ); |
| 66 | + Note that the dimensions of newXcoord should match those of |
| 67 | + the target element. |
| 68 | + |
| 69 | + You can also use a similar call if it is just a function on id: |
| 70 | + SetGet1< double >::setVec( id, "xcoord_func", newXcoord ); |
| 71 | + |
| 72 | + 6. To extract the double vector 'ycoord' field from all the |
| 73 | + objects on id: |
| 74 | + vector< double > oldYcoord; // Do not need to allocate. |
| 75 | + Field< double >::getVec( id, "ycoord", oldYcoord ); |
| 76 | + |
| 77 | + 7. To set/get LookupFields, that is fields which have an index |
| 78 | + to lookup: |
| 79 | + double x = LookupField< unsigned int, double >::get( objId, field, index ); |
| 80 | + LookupField< unsigned int, double >::set( objId, field, index, value ); |
| 81 | + |
| 82 | + There are lots of other variants here. |
| 83 | + |
| 84 | +4. Shell commands to use: the ones that start with 'do'. |
| 85 | + |
| 86 | +Id doCreate( string type, Id parent, string name, |
| 87 | + vector< unsigned int > dimensions ); |
| 88 | + |
| 89 | +bool doDelete( Id id ) |
| 90 | + |
| 91 | +MsgId doAddMsg( const string& msgType, |
| 92 | + ObjId src, const string& srcField, |
| 93 | + ObjId dest, const string& destField); |
| 94 | + |
| 95 | +void doQuit(); |
| 96 | + |
| 97 | +void doStart( double runtime ); |
| 98 | + |
| 99 | +void doNonBlockingStart( double runtime ); |
| 100 | + |
| 101 | +void doReinit(); |
| 102 | + |
| 103 | +void doStop(); |
| 104 | + |
| 105 | +void doTerminate(); |
| 106 | + |
| 107 | +void doMove( Id orig, Id newParent ); |
| 108 | + |
| 109 | +Id doCopyId orig, Id newParent, string newName, |
| 110 | + unsigned int n, bool copyExtMsgs); |
| 111 | + |
| 112 | +Id doFind( const string& path ) const |
| 113 | + |
| 114 | +void doSetClock( unsigned int tickNum, double dt ) |
| 115 | + |
| 116 | +void doUseClock( string path, string field, unsigned int tick ); |
| 117 | + |
| 118 | +Id doLoadModel( const string& fname, const string& modelpath ); |
| 119 | + |
| 120 | +void doSyncDataHandler( Id elm, const string& sizeField, Id tgt ); |
| 121 | + |
| 122 | + |
| 123 | +5. Important fields of important objects. |
| 124 | + |
| 125 | +5.1. Shell object. This is the root object, '/' or '/root'. |
| 126 | +This has the following fields of note: |
| 127 | + - bool isRunning: ReadOnlyValue |
| 128 | + - Id cwe: Regular value. |
| 129 | + |
| 130 | +5.2 Neutral. These fields are shared by all objects. |
| 131 | + string name |
| 132 | + ObjId parent // Parent ObjId. Note this is fully |
| 133 | + // specified, including index. |
| 134 | + vector< Id > children // All child elements. |
| 135 | + string path // Full path |
| 136 | + string className |
| 137 | + unsigned int linearSize // Product of all dimensions |
| 138 | + // Currently not working. |
| 139 | + vector< unsigned int> Dimensions |
| 140 | + unsigned int fieldDimension // Size of field dimension. |
| 141 | + vector< ObjId > msgOut // MsgManagers of all outgoing msgs |
| 142 | + vector< ObjId > msgIn // MsgManagers of all incoming msgs |
| 143 | + vector< Id > msgSrc( string field ) // Ids of source msgs into field |
| 144 | + vector< Id > msgDest( string field ) // Ids of dest msgs into field |
| 145 | + |
| 146 | +5.3 Class Info objects. These are located in /classes/<classname> |
| 147 | + string docs // currently not implemented |
| 148 | + string baseClass // Name of base class |
| 149 | + |
| 150 | +5.4 Field Info objects. These are children of the respective ClassInfo and |
| 151 | + are located in /classes/<classname>/<Field category> |
| 152 | + There are 5 field categories: |
| 153 | + srcFinfo |
| 154 | + destFinfo |
| 155 | + valueFinfo |
| 156 | + lookupFinfo |
| 157 | + sharedFinfo |
| 158 | + Each of these is an array, indexed as DataId( 0, <index> ) |
| 159 | + since they are FieldElements. |
| 160 | + You can query the # of entries in each category using |
| 161 | + Id classId( "/classes/<classname>" ); |
| 162 | + numValueFinfos = |
| 163 | + Field< unsigned int >::get( classId, "num_valueFinfo" ); |
| 164 | + |
| 165 | + Finally each of the field categories has the following fields: |
| 166 | + string name |
| 167 | + string docs // This is implemented |
| 168 | + string type // String with argument types separated by |
| 169 | + // commas. Can handle basic types, Ids, |
| 170 | + // ObjIds, DataIds, strings, and vectors of |
| 171 | + // any of the above. |
| 172 | + vector< string > src // vector of subsidiary srcFinfos, which |
| 173 | + // happens in SharedFinfos. |
| 174 | + vector< string > dest // vector of subsidiary destFinfos, which |
| 175 | + // happens in SharedFinfos and ValueFinfos. |
| 176 | + |
| 177 | + |
| 178 | + |
| 179 | +6. Message traversal, C++ level: |
| 180 | +General approach: |
| 181 | + - If you just want src/dest Id, use the Neutral or Element functions |
| 182 | + to find list of source or target Ids as per spec. |
| 183 | + - Netural::msgSrc( string field ); |
| 184 | + - Netural::msgDest( string field ); |
| 185 | + - Element::getOutputs( vector< Id >& ret, const SrcFinfo* finfo) |
| 186 | + - Element::getInputs( vector< Id >& ret, const DestFinfo* finfo) |
| 187 | + |
| 188 | + - If you want to iterate through specific array and/or field |
| 189 | + entries in src/dest Id, then you will have to look up the |
| 190 | + MsgIds themselves. |
| 191 | + - vector< ObjId > Neutral::msgOut(): |
| 192 | + Not very specific, just the ObjIds of the MsgManagers |
| 193 | + of all outgoing Msgs. |
| 194 | + - vector< ObjId > Neutral::msgIn(): |
| 195 | + All ObjIds of MsgManagers of incoming Msgs. |
| 196 | + - MsgId Element::findCaller( FuncId fid ) const: |
| 197 | + Looks up the first Msg that calls the specified Fid |
| 198 | + - Element::getInputMsgs( vector< MsgId >& caller, FuncId fid) |
| 199 | + Fills up vector of MsgIds that call the specified fid |
| 200 | + |
| 201 | + - To convert between MsgIds, Msgs, and the manager ObjId: |
| 202 | + - MsgId Msg::mid(): returns the MsgId of the Msg. |
| 203 | + - Msg::manager(): returns the manager Eref of a Msg. |
| 204 | + - Msg::manager().objId(): returns the manager ObjId of a Msg. |
| 205 | + - static const Msg* Msg::getMsg( MsgId mid ) |
| 206 | + Returns the Msg ptr given a MsgId. |
| 207 | + |
| 208 | + - To iterate through Msg targets: |
| 209 | + unsigned int Msg::srcToDestPairs( |
| 210 | + vector< DataId >& src, vector< DataId >& dest) const |
| 211 | + This function gives matching vectors of src and dest |
| 212 | + pairs for the Msg. This should be node-independent, |
| 213 | + but the SparseMsg currently doesn't handle it right, |
| 214 | + and works only on 1 node. |
| 215 | + |
0 commit comments