Esempio n. 1
0
        private void LogOff_Gsk(short rowinput, string ipinput)
        {
            GskApi.GSKRM_CloseInstance(CGlbFunc.gsktock[rowinput]);//关闭一个实例,没有返回值
            CGlbFunc.LoginFlag[rowinput] = Constants.LOGOFFLAG;
            CGlbFunc.gsktock[rowinput]   = IntPtr.Zero;
            CGlbFunc.ip_info[rowinput]   = ipinput;
            //连接成功存储相关信息到GLOBLE变量
#if (MARCO_DB)
            LogIn_Enqueue(rowinput);
#endif
        }
        private void UpdateTheText_gsk()
        {
            Byte[] aCNCtype = new Byte[20];
            IntPtr retptr   = new IntPtr();
            Int32  ret      = GskApi.GSKRM_GetConnectState(gskTocket);

            if (ret == 1)
            {
                GskApi.GSKRM_GetCncTypeName(gskTocket, aCNCtype);  //型号读取接口会报错
                retptr = InfoApi.GSKRM_GetVersionInfo(gskTocket);
                try
                {
                    VERS_INFO structure = new VERS_INFO();
                    //int size = Marshal.SizeOf(typeof(VERS_INFO));
                    //IntPtr allocIntPtr = Marshal.AllocHGlobal(size);          //分配内存,返回一个指针
                    structure                 = (VERS_INFO)Marshal.PtrToStructure(retptr, typeof(VERS_INFO));
                    newnc.strNC_ID            = structure.softWareNumber;
                    this.txtid.Text           = newnc.strNC_ID;
                    newnc.strNC_Version_Num_1 = structure.armVersion;
                    this.txtver1.Text         = newnc.strNC_Version_Num_1;
                    newnc.strNC_Version_Num_2 = structure.dspVersion;
                    this.txtver2.Text         = newnc.strNC_Version_Num_2;
                    newnc.strNC_Version_Num_3 = structure.FPGAVersion;
                    this.txtver3.Text         = newnc.strNC_Version_Num_3;
                    newnc.strNC_Version_Num_4 = structure.hardVersion;
                    this.txtver4.Text         = newnc.strNC_Version_Num_4;
                    newnc.strNC_Version_Num_5 = structure.sysVersion;
                    this.txtver5.Text         = newnc.strNC_Version_Num_5;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
                finally
                {
                    GskApi.GSKRM_CloseInstance(gskTocket);
                }
                this.txtxinhao.Text = System.Text.Encoding.Default.GetString(aCNCtype);
                newnc.tDatatime     = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss.ffff");
                this.txtdt.Text     = newnc.tDatatime;
                newnc.strNC_Num     = this.txtxinhao.Text;
                newnc.strNC_factr   = this.txtFac.Text;
                newnc.strIP         = ip;
                newnc.strPort       = port;
                newnc.strNC_state   = "未登录";
            }
            else
            {
                MessageBox.Show("连接断开");
            }
        }