コード例 #1
0
 //This runs on the main Thread
 public ProductionAreaManager(ref ProductionAreaServer serverRef)
 {
     //An instance of the local server must exist in order for this to work, since the server is the only input source.
     Conveyor.Subscribe(machineA);
     Conveyor.Subscribe(machineB);
     Conveyor.Subscribe(machineC);
     Conveyor.Subscribe(machineD);
     machineA.subscribe(Conveyor);
     machineB.subscribe(Conveyor);
     machineC.subscribe(Conveyor);
     machineD.subscribe(Conveyor);
     Conveyor.Subscribe(this);
     Subscribe(Conveyor);
     Subscribe(ref serverRef);
     serverRef.Subscribe(this);
 }
コード例 #2
0
        private static void Main(string[] args)
        {
            var port = 8083;

            Console.Title  = "Production Area";
            path           = AppDomain.CurrentDomain.BaseDirectory;
            folder         = Path.Combine(path, "3_ProductionArea");
            backupFilePath = Path.Combine(folder, "Backup.json");
            if (!File.Exists(backupFilePath))
            {
                File.Create(backupFilePath);
            }
            Console.WriteLine(folder);
            try
            {
                backupManager = new BackupManager(backupFilePath);                 //runs on its own thread
            }
            catch (Exception e)
            {
                AbortInit();
                Console.WriteLine("Something went wrong initializing the BackupManager. We must abort the mission.");
                Console.WriteLine(e.Message);
            }

            try
            {
                server = new ProductionAreaServer(folder, port);
                Console.WriteLine("HELLO! PRODUCTION AREA SERVER RUNNING ON 127.0.0.1:{0}", port.ToString());
            }
            catch (Exception e)
            {
                AbortInit();
                Console.WriteLine("HELLO! SERVER STOPPED ON 127.0.0.1:{0}", port.ToString());
                Console.WriteLine(e.Message);
            }

            try
            {
                prodManager =
                    new ProductionAreaManager(
                        ref server);                         //This runs on the main thread... should it though? like. everything else has its own thread so...
                Console.WriteLine("HELLO! PRODUCTION AREA MANAGER UP AND RUNNING.");
            }
            catch (Exception e)
            {
                Console.WriteLine(
                    "Something went wrong initializing and/or running the Production Area Manager. We must abort the mission.");
                Console.WriteLine(e.Message);
                AbortInit();
            }

            try
            {
                prodManager.Start();
            }
            catch (Exception e)
            {
                Console.WriteLine(
                    "Something went wrong while running the Production Area Manager. We must abort the mission.");
                Console.WriteLine(e.Message);
                AbortInit();
            }
        }
コード例 #3
0
 private void Subscribe(ref ProductionAreaServer serverRef)
 {
     Console.WriteLine("Manager subscribed to Server");
     serverRef.Events += OnProductionAreaServerEvent;
 }