public Network(int x, int y, int _base, int buffer, int genLimit, float maxLoadRatio, bool djekstra) { this.xDim = x; this.yDim = y; this.msgList = new MessageList(); this.vertexList = new VertexList(x * y); this.edgeList = new EdgeList((x-1)*y + (y-1)*x); if ( djekstra ) { this.vrtConfig = new VertexConfig( buffer, _base,genLimit, maxLoadRatio, this.findRouteD ); this.initVertexList(); this.initEdgeList(); // initializing the incidency matrix variable with dimensions edges x vertices this.incidencyMatrix = new AsociatedMatrix<sbyte>( this.vertexList.TheList, this.edgeList.TheList ); } else { this.vrtConfig = new VertexConfig( buffer, _base,genLimit, maxLoadRatio, this.findRouteC ); this.initVrtListCoord( x, y ); this.initEdgeListCoord(); } }
public Network(NetworkConfig netcfg, VertexConfig vrtcfg/*, bool djekstra*/) { this.netConf = netcfg; int x = netConf.HNodes; int y = netConf.VNodes; this.msgList = new MessageList(); this.vertexList = new VertexList(x * y); this.edgeList = new EdgeList((x-1)*y + (y-1)*x); // if !djekstra vrtcfg.RouteFunc = this.findRouteC; this.vrtConfig = vrtcfg; this.initVrtListCoord(x, y); this.initEdgeListCoord(); }
public void Iterate( MessageList msgList ) { Message tmpMsg; // processing recieved messages from the previous iteration while ( this.currentRecieveQ > 0) { msgList.Find( this.recieveMemory.Dequeue() ).CurrentStatus = MsgStat.Recieved; this.currentRecieveQ--; } // adding freshly created messages to the main queue // if there is no space left, add them back to the gen queue while (this.currentGenerateQ > 0 ) { tmpMsg = msgList.Find( this.genMemory.Dequeue() ); if ( this.IsFull() ) { this.genMemory.Enqueue( tmpMsg.Handler ); } else { this.memory.Enqueue( tmpMsg.Handler ); tmpMsg.CurrentStatus = MsgStat.OnTheWay; } this.currentGenerateQ--; } // sending messages in the base while ( this.currentProcQ > 0 ) { tmpMsg = msgList.Find( this.memory.Dequeue() ); // if the message has reached its final destination if ( this.Handler == tmpMsg.Destination ) { tmpMsg.CurrentStatus = MsgStat.JustRecieved; this.recieveMemory.Enqueue( tmpMsg.Handler ); } // if the message has been successfully sent remove it from the memory, // put it in the end of the queue, otherwise. else if ( this.sendMsg( tmpMsg ) == false ) { this.memory.Enqueue( tmpMsg.Handler ); } this.currentProcQ--; } this.statusSum += this.Status(); }
public void SetMsgList( MessageList list ) { if ( list != null ) { this.messageList = list; } }