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();
     });
 }
Пример #2
0
 private Action GetWorkerAction(GarageMediator context)
 {
     return () =>
     {
         while (_isRunning)
         {
             ScanID(context.RFIDCommunication.CurrentID);
             Thread.Sleep(0);
         }
     };
 }
Пример #3
0
 private Action GetWorkerAction(GarageMediator context)
 {
     return(() =>
     {
         while (_isRunning)
         {
             ScanID(context.RFIDCommunication.CurrentID);
             Thread.Sleep(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();
     };
 }
Пример #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();
            });
        }
Пример #6
0
 public abstract void Change(GarageMediator context);
Пример #7
0
 public virtual void Kill(GarageMediator context)
 {
     context.MicroCommunication.StopServer();
     context.RFIDCommunication.StopServer();
     context.State = new MediatorKilledState();
 }
 public override void Change(GarageMediator context)
 {
     _instructor?.Wait();
     context.State = new MediatorListeningState(context);
 }
Пример #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);
 }
Пример #11
0
 public override void Kill(GarageMediator context)
 {
     _instructor?.Wait();
     base.Kill(context);
 }
Пример #12
0
 // constructor - sets up _worker task using context
 public MediatorListeningState(GarageMediator context)
 {
     _isRunning = true;
     CurrentID = string.Empty;
     _worker = Task.Run(GetWorkerAction(context));
 }
Пример #13
0
 public override void Kill(GarageMediator context)
 {
     _instructor?.Wait();
     base.Kill(context);
 }
Пример #14
0
 public override void Change(GarageMediator context)
 {
     _isRunning = false;
     _worker.Wait();
     context.State = new MediatorProcessingState(context);
 }
Пример #15
0
 public override void Kill(GarageMediator context)
 {
     base.Kill(context);
 }
Пример #16
0
 // constructor - sets up _worker task using context
 public MediatorListeningState(GarageMediator context)
 {
     _isRunning = true;
     CurrentID  = string.Empty;
     _worker    = Task.Run(GetWorkerAction(context));
 }
Пример #17
0
 public override void Kill(GarageMediator context)
 {
     _isRunning = false;
     _worker.Wait();
     base.Kill(context);
 }
Пример #18
0
 public override void Change(GarageMediator context)
 {
     _instructor?.Wait();
     context.State = new MediatorListeningState(context);
 }
Пример #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;
 }
Пример #21
0
 public override void Kill(GarageMediator context)
 {
     _isRunning = false;
     _worker.Wait();
     base.Kill(context);
 }
Пример #22
0
 public MediatorProcessingState(GarageMediator context)
 {
     _Process = GetProcess(context);
 }
Пример #23
0
 public override void Change(GarageMediator context)
 {
     context.State = new MediatorListeningState(context);
 }
Пример #24
0
 public override void Change(GarageMediator context)
 {
     context.State = new MediatorReadyState();
 }