public void ReadWashingTagStatus() { bool carWashReady = false; bool carWashCarPresent = false; bool carWashFinish = false; bool carWashFinishTriggered = false; if (objCarWashControllerService == null) { objCarWashControllerService = new CarWashControllerImp(); } int washQId = 0; try { using (OpcOperationsService opcd = new OpcOperationsImp(OpcConnection.GetOPCServerConnection())) { carWashReady = opcd.ReadTag <bool>("CH003", "VLC_Drive_03", "CarWash_Ready"); carWashCarPresent = opcd.ReadTag <bool>("CH003", "VLC_Drive_03", "CarWash_Car_Present"); carWashFinish = opcd.ReadTag <bool>("CH003", "VLC_Drive_03", "CW_Fin"); objCarWashControllerService.UpdateIsWashReady(carWashReady); if (carWashReady && !carWashCarPresent) { carWashReader.Stop(); objCarWashControllerService.UpdateCarWashFinishTrigger(0); washQId = objCarWashControllerService.InsertQueueForWashing(1); if (washQId != 0) { //CancellationTokenSource tokenSource = new CancellationTokenSource(); //GlobalValues.threadsDictionary.Add(washQId, tokenSource); //Task.Factory.StartNew(() => objCarWashControllerService.ProcessWashPath(washQId), GlobalValues.threadsDictionary[washQId].Token); } } else if (carWashFinish && carWashCarPresent) { //update car finish flag as 1. carWashReader.Stop(); //carWashFinishTriggered = objCarWashControllerService.IsCarWashFinishTriggeredByUser(); //if (carWashFinishTriggered) //{ //} objCarWashControllerService.UpdateCarWashFinishTrigger(1); } else if (carWashCarPresent && objCarWashControllerService.IsCarWashFinishTriggeredByUser()) { objCarWashControllerService.UpdateCarWashFinishTrigger(0); washQId = objCarWashControllerService.InsertQueueForWashing(-1); if (washQId != 0) { //CancellationTokenSource tokenSource = new CancellationTokenSource(); //GlobalValues.threadsDictionary.Add(washQId, tokenSource); //Task.Factory.StartNew(() => objCarWashControllerService.ProcessWashPath(washQId), GlobalValues.threadsDictionary[washQId].Token); } } } } catch (Exception errMsg) { //Console.WriteLine("StartWashingScan, Error = " + errMsg.Message); } finally { carWashReader.Interval = 3000; carWashReader.Start(); } }
public void ReadQueueEntryData() { if (objQueueDaoService == null) { objQueueDaoService = new QueueDaoImp(); } if (objParkingControllerService == null) { objParkingControllerService = new ParkingControllerImp(); } if (objClickTransferService == null) { objClickTransferService = new ClickTransferImp(); } if (objCarWashControllerService == null) { objCarWashControllerService = new CarWashControllerImp(); } int queueId = 0; try { queueEntryReader.Stop(); queueId = objQueueDaoService.GetPendingQueueDataForProcessing(); if (queueId != 0) { Model.QueueData objQueueData = new Model.QueueData(); objQueueData = objQueueDaoService.GetQueueData(queueId); CancellationTokenSource tokenSource = new CancellationTokenSource(); if (objQueueData.requestType == 1) { Task.Factory.StartNew(() => objParkingControllerService.EntryCarProcessing(objQueueData), tokenSource.Token); } else if (objQueueData.requestType == 0) { Task.Factory.StartNew(() => objParkingControllerService.ExitCarProcessing(objQueueData), tokenSource.Token); } else if (objQueueData.requestType == 3 || objQueueData.requestType == 4 || objQueueData.requestType == 5 || objQueueData.requestType == 6 || objQueueData.requestType == 7 || objQueueData.requestType == 8) { objParkingControllerService.AddRequestIntoQueue(objQueueData); } objQueueDaoService.SetQueueStatus(queueId, 2); } } catch (Exception errMsg) { Logger.WriteLogger(GlobalValues.PARKING_LOG, ":--Exception 'ReadQueueEntryData ':: " + errMsg.Message); } finally { removeFinishedThread(); queueEntryReader.Interval = 3000; queueEntryReader.Start(); } }