Esempio n. 1
0
 public void ConnectCSP(CSPBus new_bus)
 {
     BusConnections.Add(new_bus);
     new_bus.ConnectModule(this);
     //Log new connection
     Console.WriteLine("Module " + name + " has connected to bus " + new_bus.name);
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            CSPBus CSPBus1 = new CSPBus("CSPBus1");
            Module Module1 = new Module("Module1", 0);
            Module Module2 = new Module("Module2", 1);

            //Temporary loop of 10 steps
            for (int step = 1; step < 11; step++)
            {
                Console.WriteLine("Step: " + step);
                //Example simulation event sequence
                switch (step)
                {
                case 1:
                    Module1.ConnectCSP(CSPBus1);
                    break;

                case 2:
                    Module1.SendCSPPacket(CSPBus1, 1, 0, 0, 0);
                    Module2.SendCSPPacket(CSPBus1, 0, 0, 0, 0);
                    break;

                case 4:
                    Module2.ConnectCSP(CSPBus1);
                    break;

                case 6:
                    Module1.SendCSPPacket(CSPBus1, 1, 0, 0, 0);
                    Module2.SendCSPPacket(CSPBus1, 0, 0, 0, 0);
                    break;

                case 7:
                    Module1.SendCSPPacket(CSPBus1, 2, 0, 0, 0);
                    break;

                default:
                    break;
                }

                CSPBus1.Process(step);
            }

            //Read any input before closing so we can actually read the output
            Console.ReadLine();
        }
Esempio n. 3
0
        public void SendCSPPacket(CSPBus bus, byte destination_addr, byte destination_port, byte source_port, byte priority)
        {
            CSPPacket packet = new CSPPacket(0x00000000);

            packet.Header[CSPPacket.src]       = address;
            packet.Header[CSPPacket.dest]      = destination_addr;
            packet.Header[CSPPacket.src_port]  = source_port;
            packet.Header[CSPPacket.dest_port] = destination_port;
            packet.Header[CSPPacket.priority]  = priority;

            if (BusConnections.Contains(bus))
            {
                bus.EnqueuePacket(packet);
                //Log sending packet
                Console.WriteLine("Module " + name + " sends packet " + packet.ToString() + " to bus " + bus.name);
            }
            else
            {
                //Log failed send
                Console.WriteLine("Module " + name + " failed to send packet " + packet.ToString() + " because it is not connected to bus " + bus.name);
            }
        }