00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef NODE_H
00019 #define NODE_H
00020
00021 #include <pthread.h>
00022 #include <amygdala/instance.h>
00023
00024 class MpNetwork;
00025
00031 class Node {
00032 private:
00036 Node();
00038 static void* NetworkThread(void* mpNetwork);
00039 public:
00040 ~Node();
00041
00044 void Run(unsigned int maxRunTime);
00045
00048 MpNetwork* MakeNetwork(int instId);
00049
00058 void ConnectNeurons(AmIdInt preInstId, AmIdInt preNId, AmIdInt postInstId, AmIdInt postNId, float weight, AmTimeInt delay);
00059
00061 static Node* GetNodeRef();
00062
00065 void UdpListener(int port);
00066
00067
00068 unsigned int GetMaxRunTime();
00069
00073 bool NNthreadSleep(unsigned int simTime);
00074
00076 void NNthreadWakeUp();
00077
00082 void Save(string filename);
00086 void ConnectLayers(AmIdInt preInstance, AmIdInt preLayer, AmIdInt postInstance, AmIdInt postLayer, GaussConnectType parms, float pctInhibitory=0.0);
00088 void Load(string filename);
00090 void DeleteInstance(AmIdInt instId);
00093 Network* GetNetwork(AmIdInt instId);
00095 hash_map <AmIdInt, Instance*>::iterator instance_begin();
00097 hash_map <AmIdInt, Instance*>::iterator instance_end();
00099 Instance * GetInstance(AmIdInt instId);
00100
00101
00102 protected:
00104 hash_map<AmIdInt, Instance*> instances;
00106 static Node theNode;
00108 unsigned int maxRunTime;
00109
00114 int sleepers;
00119 int NNthreads;
00120 pthread_mutex_t mut_sleeper;
00121 pthread_cond_t cond_sleeper;
00122 };
00123
00124 #endif