/// <summary>
        /// VLC
        /// </summary>
        /// <returns></returns>


        void objVLC_OnPositionChanged(object sender, EventArgs e)
        {
            VLCData vlc = (VLCData)sender;


            garrageGrid.Dispatcher.BeginInvoke(new InvokeDelegate(SetVLCPosition), vlc.machineCode, vlc.floor);
        }
 public VLCData GetVLCDetails(VLCData objVLCData)
 {
     if (objVLCDaoService == null)
     {
         objVLCDaoService = new VLCDaoImp();
     }
     return(objVLCDaoService.GetVLCDetails(objVLCData));
 }
        public int VLCAtFloor(VLCData objVLCData)
        {
            int vlcFloor = 0;

            using (OpcOperationsService opcd = new OpcOperationsImp(OpcConnection.GetOPCServerConnection()))
            {
                vlcFloor = opcd.ReadTag <Int32>(objVLCData.machineChannel, objVLCData.machineCode, OpcTags.VLC_At_Floor);
            }
            return(vlcFloor);
        }
        public bool SetHighCarBitForCarWash(VLCData objVLCData, bool bit)
        {
            bool success = false;

            using (OpcOperationsService opcd = new OpcOperationsImp(OpcConnection.GetOPCServerConnection()))
            {
                if (opcd.IsMachineHealthy(objVLCData.machineChannel + "." + objVLCData.machineCode + "." + OpcTags.WASH_CarWash_HighCar))
                {
                    success = opcd.WriteTag <bool>(objVLCData.machineChannel, objVLCData.machineCode, OpcTags.WASH_CarWash_HighCar, bit);
                }
            }
            return(success);
        }
        public bool ConfirmReachedAtFloor(VLCData objVLCData)
        {
            Logger.WriteLogger(GlobalValues.PARKING_LOG, "Queue Id:" + objVLCData.queueId + ":--Entering 'ConfirmReachedAtFloor' ");
            if (objVLCDaoService == null)
            {
                objVLCDaoService = new VLCDaoImp();
            }
            VLCData confirmVLCData = new VLCData();
            bool    vlcConfirmed   = false;

            if (objQueueControllerService == null)
            {
                objQueueControllerService = new QueueControllerImp();
            }

            try
            {
                confirmVLCData.machineCode = objVLCData.machineCode;

                confirmVLCData = objVLCDaoService.GetVLCDetails(objVLCData);

                confirmVLCData.destFloor = objVLCData.destFloor;
                confirmVLCData.queueId   = objVLCData.queueId;
                while (VLCAtFloor(confirmVLCData) != confirmVLCData.destFloor)
                {
                    VLCMove(confirmVLCData);
                    /**checking transaction deleted or not****/
                    objQueueControllerService.CancelIfRequested(confirmVLCData.queueId);
                    /******/
                    Thread.Sleep(500);
                }
                vlcConfirmed = true;
            }
            catch (OperationCanceledException errMsg)
            {
                Logger.WriteLogger(GlobalValues.PARKING_LOG, "Queue Id:" + objVLCData.queueId + ": VLC=" + objVLCData.machineCode + " --TaskCanceledException 'ConfirmReachedAtFloor':: " + errMsg.Message);
                throw new OperationCanceledException();
            }
            catch (Exception errMsg)
            {
                Logger.WriteLogger(GlobalValues.PARKING_LOG, "Queue Id:" + objVLCData.queueId + ": VLC=" + objVLCData.machineCode + " --Exception 'ConfirmReachedAtFloor':: " + errMsg.Message);
                if (errMsg is TaskCanceledException)
                {
                    throw new Exception();
                }
            }
            Logger.WriteLogger(GlobalValues.PARKING_LOG, "Queue Id:" + objVLCData.queueId + ":--Exitting 'ConfirmReachedAtFloor' ");
            return(vlcConfirmed);
        }
        public Model.VLCData GetVLCDetails(Int64 queueId)
        {
            Model.VLCData objVLCData = null;
            try
            {
                using (OracleConnection con = new DBConnection().getDBConnection())
                {
                    using (OracleCommand command = con.CreateCommand())
                    {
                        string sql = "SELECT VLC_ID, VLC_NAME,F_ROW,F_AISLE,HOME_FLOOR,MACHINE_CODE,IS_BLOCKED"
                                     + " ,STATUS,IS_AUTOMODE,MACHINE_CHANNEL,VLC_DECK_CODE"
                                     + " FROM L2_VLC_MASTER where BLOCK_Q_ID=" + queueId;


                        command.CommandText = sql;
                        using (OracleDataReader reader = command.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                if (reader.Read())
                                {
                                    objVLCData         = new VLCData();
                                    objVLCData.vlcPkId = Int32.Parse(reader["VLC_ID"].ToString());
                                    objVLCData.vlcName = reader["VLC_NAME"].ToString();
                                    objVLCData.row     = Int32.Parse(reader["F_ROW"].ToString());

                                    objVLCData.aisle       = Int32.Parse(reader["F_AISLE"].ToString());
                                    objVLCData.floor       = Int32.Parse(reader["HOME_FLOOR"].ToString());
                                    objVLCData.machineCode = reader["MACHINE_CODE"].ToString();
                                    objVLCData.isBlocked   = Int32.Parse(reader["IS_BLOCKED"].ToString());

                                    objVLCData.status         = Int32.Parse(reader["STATUS"].ToString());
                                    objVLCData.isAutoMode     = Int32.Parse(reader["IS_AUTOMODE"].ToString()) == 1 ? true : false;
                                    objVLCData.machineChannel = reader["MACHINE_CHANNEL"].ToString();
                                    objVLCData.vlcDeckCode    = reader["VLC_DECK_CODE"].ToString();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception errMsg)
            {
                objVLCData = null;
            }
            return(objVLCData);
        }
        public void DoResumeEngine()
        {
            List <QueueData> processingQList = null;

            if (objQueueDaoService == null)
            {
                objQueueDaoService = new QueueDaoImp();
            }
            if (objCMControllerService == null)
            {
                objCMControllerService = new CMControllerImp();
            }
            if (objVLCControllerService == null)
            {
                objVLCControllerService = new VLCControllerImp();
            }
            if (objEESDaoService == null)
            {
                objEESDaoService = new EESDaoImp();
            }
            //get all request in status 0 or 2
            processingQList = objQueueDaoService.GetAllProcessingQId();

            //take one request
            foreach (QueueData objQueueData in processingQList)
            {
                string carMachine = null;

                //get queue id
                //get all cms blocked by this queue id
                CMData objCMData = objCMControllerService.GetBlockedCMDetails(objQueueData.queuePkId);

                //get all vlcs blocked by this queue id
                VLCData objVLCData = objVLCControllerService.GetVLCDetails(objQueueData.queuePkId);

                EESData objEESData = objEESDaoService.GetBlockedEESDetails(objQueueData.queuePkId);

                if (objCMData != null && objVLCData != null)
                {
                    //check pallet present of blocked machine
                    GlobalValues.palletStatus palletStatus = objCMControllerService.GetPalletOnCMStatus(objCMData);
                    if (palletStatus == GlobalValues.palletStatus.present)
                    {
                        carMachine = objCMData.machineCode;
                    }
                    else
                    {
                        carMachine = objVLCData.machineCode;
                    }
                }
                else if (objCMData != null)
                {
                    carMachine = objCMData.machineCode;
                }
                else if (objCMData != null)
                {
                    carMachine = objVLCData.machineCode;
                }
                else if (objEESData != null)
                {
                    carMachine = objEESData.machineCode;
                }

                //call SetReallocateData with pallet present machine
                if (!string.IsNullOrEmpty(carMachine))
                {
                    SetReallocateData(objQueueData.queuePkId, carMachine, 3);
                }
                else
                {
                    SetReallocateData(objQueueData.queuePkId, "SLOT", 3);// entry or exit which had no initial path
                }
                UpdateAbortedStatus(objQueueData.queuePkId);
            }
        }
        public TriggerData NeedToShowTrigger(VLCData objVLCData)
        {
            bool needToShow = false;

            if (objVLCDaoService == null)
            {
                objVLCDaoService = new VLCDaoImp();
            }

            int         checkCount     = 0;
            int         errorCode      = 0;
            TriggerData objTriggerData = new TriggerData();

            if (objErrorControllerService == null)
            {
                objErrorControllerService = new ErrorControllerImp();
            }
            int max_check_count = 10;


            using (OpcOperationsService opcd = new OpcOperationsImp(OpcConnection.GetOPCServerConnection()))
            {
                do
                {
                    errorCode = objErrorControllerService.GetErrorCode(objVLCData.machineChannel, objVLCData.machineCode, OpcTags.VLC_L2_ErrCode);
                    if (errorCode > 0)
                    {
                        objTriggerData.category  = TriggerData.triggerCategory.ERROR;
                        objTriggerData.ErrorCode = errorCode.ToString();
                        needToShow = true;
                        break;
                    }

                    needToShow = !opcd.ReadTag <bool>(objVLCData.machineChannel, objVLCData.machineCode, OpcTags.VLC_Auto_Ready);
                    if (needToShow)
                    {
                        if (checkCount >= max_check_count)
                        {
                            objTriggerData.category = TriggerData.triggerCategory.MANUAL;
                            break;
                        }
                        checkCount++;
                        Thread.Sleep(1000);
                        continue;
                    }

                    needToShow = objVLCDaoService.IsVLCDisabled(objVLCData.machineCode);
                    if (needToShow)
                    {
                        objTriggerData.category = TriggerData.triggerCategory.DISABLE;
                        break;
                    }
                } while (needToShow && checkCount < max_check_count);
            }
            if (needToShow)
            {
                objTriggerData.MachineCode    = objVLCData.machineCode;
                objTriggerData.TriggerEnabled = true;
                Logger.WriteLogger(GlobalValues.PARKING_LOG, "Queue Id:" + objVLCData.queueId + ": VLC = " + objVLCData.machineCode + "--'NeedToShowTrigger For VLC' = " + needToShow);
            }
            return(objTriggerData);
        }