示例#1
0
        private void timerOperation_Tick(object sender, EventArgs e)
        {
            int nval = 0;

            if (pbProgress.Value >= pbProgress.Maximum)
            {
                nval = MAX_PROGRESS;
            }
            else
            {
                switch (m_operationType)
                {
                case OperationsType.Read:
                {
                    nval = KB9API.ReadingKB9Progress();
                }
                break;

                case OperationsType.Write:
                {
                    nval = KB9API.WritingKB9Progress();
                }
                break;

                default:
                    break;
                }
            }
#if _DEBUG_ME
            m_val += 15;
            nval   = m_val;
#endif
            set_value(nval);
        }
示例#2
0
 /// <summary>
 /// Sync function, waiting until return
 /// API for cancel current kb9000 operations
 /// </summary>
 /// <returns></returns>
 public bool cancel_kb9000()
 {
     try
     {
         this.KB9Error = KB9API.KB9API_ERROR.FUNC_SUCCESSFUL;
         return(KB9API.Cancel() != KB9API.KB9API_ERROR.FUNC_SUCCESSFUL);
     }
     catch (System.Exception ex)
     {
         return(false);
     }
 }
示例#3
0
        /// <summary>
        /// API for read KB9000.
        /// Usage:
        ///     Call this function from frmMain window
        /// </summary>
        /// <param name="strTemplate">the template data readed from KB9000.</param>
        public KB9API.KB9API_ERROR read_kb9000(ref string strData)
        {
            try
            {
#if _DEBUG_ME
#else
                if (!FindKB9000())
                {
                    return(KB9API.KB9API_ERROR.FUNC_NODEVICE_DRIVER);
                }
#endif
                this.KB9Error = KB9API.KB9API_ERROR.FUNC_SUCCESSFUL;
                //start_operation(_ThreadParam);
                m_operationType = OperationsType.Read;
                m_strData       = "";
                KB9API.StartReadingKB9(KB9API.m_PortType);

                DialogResult result = show_progress("Reading KB9000 ...");  //blocked
#if _DEBUG_ME
                return(KB9API.KB9API_ERROR.FUNC_SUCCESSFUL);
#else
                if (result == DialogResult.Cancel)
                {
                    return(KB9API.KB9API_ERROR.FUNC_UNKOWN_ERROR);
                }
                else
                {
                    if (this.KB9Error != KB9API.KB9API_ERROR.FUNC_SUCCESSFUL)
                    {
                        return(this.KB9Error);
                    }
                    else
                    {
                        KB9API.ReadKB9Data(ref m_strData);
                        strData = m_strData;
                        return(KB9API.KB9API_ERROR.FUNC_SUCCESSFUL);
                    }
                }
#endif
            }
            catch (System.Exception ex)
            {
                return(KB9API.KB9API_ERROR.FUNC_UNHANDLED_EXCEPTION);
            }
        }
示例#4
0
        /// <summary>
        /// API for write template data to KB9000.
        /// Usage:
        ///     Call it in frmMain window
        /// </summary>
        /// <param name="strTemplate">the data structure to write to kb9k</param>
        public KB9API.KB9API_ERROR write_kb9000(string strTemplate)
        {
            try
            {
 #if _DEBUG_ME
#else
                if (!FindKB9000())
                {
                    return(KB9API.KB9API_ERROR.FUNC_NODEVICE_DRIVER);
                }
#endif
                this.KB9Error   = KB9API.KB9API_ERROR.FUNC_SUCCESSFUL;
                m_operationType = OperationsType.Write;
                KB9API.StartWriting(KB9API.m_PortType, strTemplate);

                DialogResult result = show_progress("Writing KB9000 ...");
#if _DEBUG_ME
                return(KB9API.KB9API_ERROR.FUNC_SUCCESSFUL);
#endif
                if (result == DialogResult.Cancel)
                {
                    return(KB9API.KB9API_ERROR.FUNC_UNKOWN_ERROR);
                }
                else
                {
                    if (this.KB9Error != KB9API.KB9API_ERROR.FUNC_SUCCESSFUL)
                    {
                        return(this.KB9Error);
                    }
                    else
                    {
                        //uint nwriten = KB9API.GetWritingResult();
                        //MessageBox.Show("Writen len = " + nwriten.ToString());
                        return(KB9API.KB9API_ERROR.FUNC_SUCCESSFUL);
                    }
                }
            }
            catch (System.Exception ex)
            {
                return(KB9API.KB9API_ERROR.FUNC_UNHANDLED_EXCEPTION);
            }
        }
示例#5
0
        private static bool FindKB9000()
        {
            try
            {
                KB9API.KB9_PORT nPort = KB9API.KB9_PORT.Unknown;

                KB9API.KB9API_ERROR result = KB9API.AutoDetectKB9(ref nPort);

                if (result == KB9API.KB9API_ERROR.FUNC_SUCCESSFUL)
                {
                    KB9API.m_PortType = nPort;
                }
                else
                {
                    KB9API.m_PortType = KB9API.KB9_PORT.Unknown;
                }

                return(KB9API.m_PortType != KB9API.KB9_PORT.Unknown);
            }
            catch (System.Exception ex)
            {
                return(false);
            }
        }