Example #1
0
        private void runmain()
        {
            Thread.Sleep(100);
            Win32.timeBeginPeriod(1);
            try
            {
                while (this.myapp.upapp.runstate == 1)
                {
                    Touch.Touch_Tpscan();
                    switch (this.myapp.USART.State)
                    {
                    case 0xfd:
                        lock (this.myapp.upapp.Screenbm)
                        {
                            Graphics.FromImage(this.myapp.upapp.Screenbm).Clear(Color.Black);
                        }
                        this.myapp.upapp.ScreenRef(1);
                        Application.DoEvents();
                        Thread.Sleep(100);
                        Hmi.Hmi_OpenInit();
                        Hmi.Hmi_Init();
                        Hmi.Hmi_RefPage(0);
                        this.myapp.USART.State = 0;
                        Commake.Commake_ClearNorComData();
                        break;

                    case 0xff:
                        Commake.Commake_ClearNorComData();
                        this.myapp.USART.State = 0;
                        break;

                    case 0x16:
                        Usart.Usart_SendByte(0xfe);
                        Commake.Commake_SendEnd();
                        this.myapp.USART.State = 0x17;
                        break;

                    case 0:
                        if (this.myapp.runmod > 0)
                        {
                            if (Commake.Commake_ScanComcode() == 0)
                            {
                                Commake.Commake_CheckNorComIdle();
                            }
                            if (this.myapp.upapp.Lcdshouxian == 1)
                            {
                                this.myapp.upapp.ScreenRef(0);
                            }
                            if (this.myapp.runmod == 2)
                            {
                                break;
                            }
                        }
                        if (this.myapp.Hexstrindex != 0xffff)
                        {
                            Hmi.Hmi_ScanHexCode();
                        }
                        else
                        {
                            this.myapp.pagestate = 1;
                            if (this.myapp.upapp.Lcdshouxian == 1)
                            {
                                this.myapp.upapp.ScreenRef(0);
                            }
                            if (this.myapp.tpdownenter == 1)
                            {
                                Hmi.Hmi_Scanrediandown();
                            }
                            else if (this.myapp.tpupenter == 1)
                            {
                                Hmi.Hmi_Scanredianup();
                            }
                            else if (Commake.Commake_ScanComcode() == 0)
                            {
                                Commake.Commake_CheckNorComIdle();
                                Hmi.Hmi_GuiObjectRef();
                                if (this.myapp.Hexstrindex == 0xffff)
                                {
                                    Hmi.Hmi_GetTimerHexbufIndex();
                                }
                            }
                        }
                        break;

                    case 9:
                        Sys.Endcomdata();
                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                if (this.myapp.upapp.runstate == 1)
                {
                    MessageOpen.Show(exception.Message);
                }
            }
        }
Example #2
0
 public unsafe void gui_int(List <guiimagetype> guiimages_, string binpath_, Myapp_inf mapp_, byte bianjistate)
 {
     this.Myapp = mapp_;
     this.myapp.upapp.images     = guiimages_;
     this.binpath                = binpath_;
     this.myapp.upapp.filesr     = new StreamReader(this.binpath);
     this.myapp.upapp.runapptype = bianjistate;
     if (this.merrya == null)
     {
         this.merrya = (byte *)Marshal.AllocHGlobal(0x1f400);
     }
     this.myapp.upapp.pageidchange   = new pageidchange_(this.pageidchange);
     this.myapp.upapp.ScreenRef      = new ScreenRef_(this.Screenref);
     this.myapp.upapp.Sendruncodestr = new Sendruncodestr_(this.Sendruncodestr);
     this.myapp.upapp.Lcd_Set        = new Lcd_Set_(this.Lcd_Set);
     this.myapp.upapp.SendCom        = new SendCom_(this.SendCom_Code);
     Attmake.myapp          = this.myapp;
     CodeRun.myapp          = this.myapp;
     Commake.myapp          = this.myapp;
     GuiCurve.myapp         = this.myapp;
     Showpic.myapp          = this.myapp;
     Showfont.myapp         = this.myapp;
     GuiSlider.myapp        = this.myapp;
     GuiTimer.myapp         = this.myapp;
     Hmi.myapp              = this.myapp;
     Lcd.myapp              = this.myapp;
     Readdata.myapp         = this.myapp;
     Sys.myapp              = this.myapp;
     Sysatt.myapp           = this.myapp;
     Touch.myapp            = this.myapp;
     Usart.myapp            = this.myapp;
     Commake.Comstrbuf      = this.merrya;
     this.myapp.mymerry     = this.merrya + 0x400;
     Hmi.Hexstrbuf          = this.merrya + 0x2400;
     this.myapp.systimerbuf = this.merrya + 0x2c00;
     this.myapp.Mycanshus   = (PosLaction *)(this.merrya + 0x2e00);
     this.myapp.binsuc      = 1;
     if (Readdata.Readdata_ReadBinapp() == 0)
     {
         MessageOpen.Show("错误的资源文件或者资源文件已经受损".Language());
         this.myapp.binsuc = 0;
     }
     Hmi.Hmi_OpenInit();
     Hmi.Hmi_Init();
     Hmi.Hmi_RefPage(0);
     this.myapp.USART.State = 0;
     Commake.Commake_ClearNorComData();
     this.myapp.upapp.runstate = 1;
     if ((this.myapp.upapp.runapptype == runapptype.run) && ((this.mainthread == null) || !this.mainthread.IsAlive))
     {
         Win32.timeBeginPeriod(1);
         DateTime now   = DateTime.Now;
         DateTime time2 = now;
         Rtc.DatetimeSpan = now.AddDays((double)Kuozhan.Getval("datetime_d").Getint()).AddHours((double)Kuozhan.Getval("datetime_h").Getint()).AddMinutes((double)Kuozhan.Getval("datetime_m").Getint()).AddSeconds((double)Kuozhan.Getval("datetime_s").Getint()).Subtract(time2);
         if ((((Rtc.DatetimeSpan.Days == 0) && (Rtc.DatetimeSpan.Hours == 0)) && (Rtc.DatetimeSpan.Minutes == 0)) && (Rtc.DatetimeSpan.Seconds == 0))
         {
             Rtc.DatetimeSpan_val = false;
         }
         else
         {
             Rtc.DatetimeSpan_val = true;
         }
         this.mainthread = new Thread(new ThreadStart(this.runmain));
         this.timerms5   = new Thread(new ThreadStart(this.timerm_5ms));
         Hmi.Hmi_ClearTimer();
         this.timerms5.Start();
         this.mainthread.Start();
     }
 }