Ejemplo n.º 1
0
 private Action <GarageAssignment> GetProcess(GarageMediator context)
 {
     return((assignment) =>
     {
         context.MicroCommunication.ClearIncoming();
         context.MicroCommunication.Write(START_INSTRUCTION);
         VehicleInstructionsStarted();
         while (context.MicroCommunication.Read() != CONTINUE_INSTRUCTION)
         {
             Thread.Sleep(0);
         }
         context.MicroCommunication.Write(assignment.Cell);
         while (context.MicroCommunication.Read() != CONTINUE_INSTRUCTION)
         {
             Thread.Sleep(0);
         }
         context.MicroCommunication.Write(assignment.Stored ? OUTGOING : INCOMING);
         while (context.MicroCommunication.Read() != CONTINUE_INSTRUCTION)
         {
             Thread.Sleep(0);
         }
         context.MicroCommunication.Write(STOP_INSTRUCTION);
         VehicleProcessingStarted();
         while (context.MicroCommunication.Read() != INSTRUCTIONS_COMPLETED)
         {
             Thread.Sleep(0);
         }
         context.DatabaseCommunication.MoveVehicle(assignment.ID, !assignment.Stored);
         VehicleProcessed();
     });
 }
Ejemplo n.º 2
0
 private Action GetWorkerAction(GarageMediator context)
 {
     return () =>
     {
         while (_isRunning)
         {
             ScanID(context.RFIDCommunication.CurrentID);
             Thread.Sleep(0);
         }
     };
 }
Ejemplo n.º 3
0
 private Action GetWorkerAction(GarageMediator context)
 {
     return(() =>
     {
         while (_isRunning)
         {
             ScanID(context.RFIDCommunication.CurrentID);
             Thread.Sleep(0);
         }
     });
 }
Ejemplo n.º 4
0
 private Action<GarageAssignment> GetProcess(GarageMediator context)
 {
     return (assignment) =>
     {
         context.MicroCommunication.ClearIncoming();
         context.MicroCommunication.Write(START_INSTRUCTION);
         VehicleInstructionsStarted();
         while (context.MicroCommunication.Read() != CONTINUE_INSTRUCTION)
             Thread.Sleep(0);
         context.MicroCommunication.Write(assignment.Cell);
         while (context.MicroCommunication.Read() != CONTINUE_INSTRUCTION)
             Thread.Sleep(0);
         context.MicroCommunication.Write(assignment.Stored ? OUTGOING : INCOMING);
         while (context.MicroCommunication.Read() != CONTINUE_INSTRUCTION)
             Thread.Sleep(0);
         context.MicroCommunication.Write(STOP_INSTRUCTION);
         VehicleProcessingStarted();
         while (context.MicroCommunication.Read() != INSTRUCTIONS_COMPLETED)
             Thread.Sleep(0);
         context.DatabaseCommunication.MoveVehicle(assignment.ID, !assignment.Stored);
         VehicleProcessed();
     };
 }
Ejemplo n.º 5
0
        private Action <GarageAssignment> GetProcess(GarageMediator context)
        {
            return((assignment) =>
            {
                context.MicroCommunication.Write(START_INSTRUCTION);
                VehicleInstructionsStarted();

                byte cont = 0;
                while (cont != CONTINUE_INSTRUCTION)
                {
                    cont = context.MicroCommunication.Read();
                    System.Diagnostics.Debug.WriteLine(cont);
                    Thread.Sleep(0);
                }

                //while (context.MicroCommunication.Read() != CONTINUE_INSTRUCTION)
                //    Thread.Sleep(0);
                context.MicroCommunication.Write(assignment.Cell);
                while (context.MicroCommunication.Read() != CONTINUE_INSTRUCTION)
                {
                    Thread.Sleep(0);
                }
                context.MicroCommunication.Write(assignment.Stored ? OUTGOING : INCOMING);
                while (context.MicroCommunication.Read() != CONTINUE_INSTRUCTION)
                {
                    Thread.Sleep(0);
                }
                context.MicroCommunication.Write(STOP_INSTRUCTION);
                VehicleProcessingStarted();
                while (context.MicroCommunication.Read() != INSTRUCTIONS_COMPLETED)
                {
                    Thread.Sleep(0);
                }
                context.DatabaseCommunication.MoveVehicle(assignment.ID, !assignment.Stored);
                VehicleProcessed();
            });
        }
Ejemplo n.º 6
0
 public abstract void Change(GarageMediator context);
Ejemplo n.º 7
0
 public virtual void Kill(GarageMediator context)
 {
     context.MicroCommunication.StopServer();
     context.RFIDCommunication.StopServer();
     context.State = new MediatorKilledState();
 }
Ejemplo n.º 8
0
 public override void Change(GarageMediator context)
 {
     _instructor?.Wait();
     context.State = new MediatorListeningState(context);
 }
Ejemplo n.º 9
0
 public override void Change(GarageMediator context)
 {
     _isRunning = false;
     _worker.Wait();
     context.State = new MediatorProcessingState(context);
 }
 public override void Change(GarageMediator context)
 {
     context.RFIDCommunication.OnIDScan -= RFIDCommunication_OnIDScan;
     context.State = new MediatorProcessingState(context);
 }
Ejemplo n.º 11
0
 public override void Kill(GarageMediator context)
 {
     _instructor?.Wait();
     base.Kill(context);
 }
Ejemplo n.º 12
0
 // constructor - sets up _worker task using context
 public MediatorListeningState(GarageMediator context)
 {
     _isRunning = true;
     CurrentID = string.Empty;
     _worker = Task.Run(GetWorkerAction(context));
 }
Ejemplo n.º 13
0
 public override void Kill(GarageMediator context)
 {
     _instructor?.Wait();
     base.Kill(context);
 }
Ejemplo n.º 14
0
 public override void Change(GarageMediator context)
 {
     _isRunning = false;
     _worker.Wait();
     context.State = new MediatorProcessingState(context);
 }
Ejemplo n.º 15
0
 public override void Kill(GarageMediator context)
 {
     base.Kill(context);
 }
Ejemplo n.º 16
0
 // constructor - sets up _worker task using context
 public MediatorListeningState(GarageMediator context)
 {
     _isRunning = true;
     CurrentID  = string.Empty;
     _worker    = Task.Run(GetWorkerAction(context));
 }
Ejemplo n.º 17
0
 public override void Kill(GarageMediator context)
 {
     _isRunning = false;
     _worker.Wait();
     base.Kill(context);
 }
Ejemplo n.º 18
0
 public override void Change(GarageMediator context)
 {
     _instructor?.Wait();
     context.State = new MediatorListeningState(context);
 }
Ejemplo n.º 19
0
 public MediatorProcessingState(GarageMediator context)
 {
     _Process = GetProcess(context);
 }
 // constructor - sets up _worker task using context
 public MediatorListeningState(GarageMediator context)
 {
     context.RFIDCommunication.OnIDScan += RFIDCommunication_OnIDScan;
 }
Ejemplo n.º 21
0
 public override void Kill(GarageMediator context)
 {
     _isRunning = false;
     _worker.Wait();
     base.Kill(context);
 }
Ejemplo n.º 22
0
 public MediatorProcessingState(GarageMediator context)
 {
     _Process = GetProcess(context);
 }
Ejemplo n.º 23
0
 public override void Change(GarageMediator context)
 {
     context.State = new MediatorListeningState(context);
 }
Ejemplo n.º 24
0
 public override void Change(GarageMediator context)
 {
     context.State = new MediatorReadyState();
 }