Пример #1
0
 public static bool SwitchAndWaitForPage(ICDUScreen cdu, string pageName, CDU_KEYS keyForSwitching)
 {
     if (EfisHelper.GetPageName(cdu) != pageName)
     {
         cdu.SendKey(keyForSwitching);
         return(WaitForPage(cdu, pageName));
     }
     return(true);
 }
Пример #2
0
        public void Execute(IApplication app, ISPADEventArgs eventArgs)
        {
            ICDUScreen cdu = EfisHelper.GetCDU(app, CDU_NUMBER.Captain);

            if (cdu == null)
            {
                return;
            }

            if (EfisHelper.GetPageName(cdu) != "EFIS CONTROL")
            {
                if (!EfisHelper.SwitchAndWaitForPage(cdu, "MENU", CDU_KEYS.KEY_MENU))
                {
                    return;
                }
            }
            if (!EfisHelper.SwitchAndWaitForPage(cdu, "EFIS CONTROL", CDU_KEYS.KEY_R2))
            {
                return;
            }

            var oldVal = 0;

            for (int i = 0; i < 6; i++)
            {
                var cell = cdu.GetCell(6, i);
                if (!Char.IsDigit(cell.Symbol))
                {
                    break;
                }
                oldVal = oldVal * 10 + (cell.Symbol - '0');
            }
            oldVal += Convert.ToInt32(eventArgs.NewValue);
            logger.Info($"new Value = {oldVal}");
            while (!cdu.GetCell(13, 0).IsEmpty)
            {
                cdu.SendKey(CDU_KEYS.KEY_CLR);
                Thread.Sleep(100);
            }

            var newVal = oldVal.ToString();

            for (int i = 0; i < newVal.Length; i++)
            {
                cdu.SendKey(CDU_KEYS.KEY_0 + (newVal[i] - '0'));
            }
            Thread.Sleep(100);
            cdu.SendKey(CDU_KEYS.KEY_L3);
        }
Пример #3
0
        public static bool WaitForPage(ICDUScreen cdu, string pageName)
        {
            int tries = 0;

            while ((EfisHelper.GetPageName(cdu) != pageName))
            {
                tries++;
                Thread.Sleep(1000);
                if (tries >= 5)
                {
                    logger.Error($"Cannot switch to page {pageName}");
                    return(false);
                }
            }
            return(true);
        }