Ejemplo n.º 1
0
        private void SDPlayFileThread(object obj)
        {
            ThreadParam ap = (ThreadParam)obj;

            Delegate h = new DelegateShowProcess(ShowProgress);

            uint ret = DeviceInterfaceDll.SR_PutFile(ap.id, ap.filename, ap.volume);

            if (ret == DeviceInterfaceDll.RC_OK)
            {
                try
                {
                    while (true)
                    {
                        ret = DeviceInterfaceDll.SR_PutFileStatus(ap.id, out uint nProcess);
                        if (ret == DeviceInterfaceDll.RC_OK)
                        {
                            int process = (int)nProcess;
                            this.Invoke(h, process);
                        }
                        else
                        {
                            break;
                        }
                        Thread.Sleep(1000);
                    }
                    //this.Invoke(h, 101);
                }
                catch (ThreadAbortException e)
                {
                    DeviceInterfaceDll.SR_PutFileClose(ap.id);
                }
                finally
                {
                    this.Invoke(h, 101);
                    dataThread = null;
                }
            }
        }
Ejemplo n.º 2
0
        private void SDCardUploadFileThread(object obj)
        {
            ThreadParam ap = (ThreadParam)obj;
            Delegate    h  = new DelegateShowProcess(ShowProgress);

            uint ret = DeviceInterfaceDll.SR_UploadFile(out uint handle, ap.id, ap.filename, true);

            if (ret == DeviceInterfaceDll.RC_OK)
            {
                try
                {
                    long       count = 0;
                    byte[]     bdata = new byte[1024];
                    FileStream fs    = File.OpenRead(ap.filename);
                    if (fs != null)
                    {
                        int rlen;
                        do
                        {
                            rlen = fs.Read(bdata, 0, bdata.Length);
                            if (rlen > 0)
                            {
                                count += rlen;
                                DeviceInterfaceDll.SR_UploadFileData(handle, bdata, rlen);
                                this.Invoke(h, (int)(100 * count / fs.Length));
                            }
                        }while (rlen >= bdata.Length);
                    }
                }
                catch (ThreadAbortException e)
                { }
                finally
                {
                    DeviceInterfaceDll.SR_UploadClose(handle);
                    this.Invoke(h, 101);
                }
            }
        }
Ejemplo n.º 3
0
        private void UpdateThread(object obj)
        {
            //ThreadParam ap = (ThreadParam)obj;
            Delegate h = new DelegateShowProcess(ShowProcess);

            try
            {
                uint ret;
                if ((bin_filename != null) && (File.Exists(bin_filename)))
                {
                    ret = DeviceInterfaceDll.SR_Update(out uint bin_handle, id, 0, bin_filename);
                    if (ret == DeviceInterfaceDll.RC_OK)
                    {
                        try
                        {
                            int        count = 0;
                            byte[]     bdata = new byte[1024];
                            FileStream fs    = File.OpenRead(bin_filename);
                            if (fs != null)
                            {
                                int rlen;
                                do
                                {
                                    rlen = fs.Read(bdata, 0, bdata.Length);
                                    if (rlen > 0)
                                    {
                                        count += rlen;
                                        DeviceInterfaceDll.SR_UpdateData(bin_handle, bdata, rlen);
                                        this.Invoke(h, bin_filename, (int)(100 * count / fs.Length));
                                    }
                                    //System.Windows.Forms.Application.DoEvents();
                                }while (rlen >= bdata.Length);
                            }
                            fs.Close();
                        }
                        finally
                        {
                            DeviceInterfaceDll.SR_UpdateClose(bin_handle);
                        }
                    }
                }

                Thread.Sleep(500);

                if ((pak_filename != null) && (File.Exists(pak_filename)))
                {
                    ret = DeviceInterfaceDll.SR_Update(out uint pak_handle, id, 1, pak_filename);
                    if (ret == DeviceInterfaceDll.RC_OK)
                    {
                        try
                        {
                            int        count = 0;
                            byte[]     bdata = new byte[1024];
                            FileStream fs    = File.OpenRead(pak_filename);
                            if (fs != null)
                            {
                                int rlen;
                                do
                                {
                                    rlen = fs.Read(bdata, 0, bdata.Length);
                                    if (rlen > 0)
                                    {
                                        count += rlen;
                                        DeviceInterfaceDll.SR_UpdateData(pak_handle, bdata, rlen);
                                        this.Invoke(h, pak_filename, (int)(100 * count / fs.Length));
                                    }
                                }while (rlen >= bdata.Length);

                                //wait update 200
                            }
                            //else
                            //{
                            //    Thread.Sleep(0);
                            //}
                            fs.Close();
                        }
                        finally
                        {
                            DeviceInterfaceDll.SR_UpdateClose(pak_handle);
                        }
                    }
                }

                DeviceInterfaceDll.SR_Apply(id);
            }
            finally
            {
                this.Invoke(h, "", 101);
            }
        }
Ejemplo n.º 4
0
        private void UpdateThread(object obj)
        {
            ThreadParam ap = (ThreadParam)obj;
            Delegate    h  = new DelegateShowProcess(ShowProgress);

            try
            {
                uint ret;
                uint handle;
                ret = DeviceInterfaceDll.SR_Update(out handle, ap.id, 0, ap.bin_filename);
                if (ret == DeviceInterfaceDll.RC_OK)
                {
                    try
                    {
                        int        count = 0;
                        byte[]     bdata = new byte[1024];
                        FileStream fs    = File.OpenRead(ap.bin_filename);
                        if (fs != null)
                        {
                            int rlen;
                            do
                            {
                                rlen = fs.Read(bdata, 0, bdata.Length);
                                if (rlen > 0)
                                {
                                    count += rlen;
                                    DeviceInterfaceDll.SR_UpdateData(handle, bdata, rlen);
                                    this.Invoke(h, ap.bin_filename, (int)(100 * count / fs.Length));
                                }
                            }while (rlen >= bdata.Length);
                        }
                    }
                    finally
                    {
                        DeviceInterfaceDll.SR_UpdateClose(handle);
                        //this.Invoke(h, "", 101);
                    }
                }

                ret = DeviceInterfaceDll.SR_Update(out uint pak_handle, ap.id, 1, ap.pak_filename);
                if (ret == DeviceInterfaceDll.RC_OK)
                {
                    try
                    {
                        int        count = 0;
                        byte[]     bdata = new byte[1024];
                        FileStream fs    = File.OpenRead(ap.pak_filename);
                        if (fs != null)
                        {
                            int rlen;
                            do
                            {
                                rlen = fs.Read(bdata, 0, bdata.Length);
                                if (rlen > 0)
                                {
                                    count += rlen;
                                    DeviceInterfaceDll.SR_UpdateData(pak_handle, bdata, rlen);
                                    this.Invoke(h, ap.pak_filename, (int)(100 * count / fs.Length));
                                }
                            }while (rlen >= bdata.Length);
                        }
                    }
                    finally
                    {
                        DeviceInterfaceDll.SR_UpdateClose(handle);
                    }
                }
            }
            finally
            {
                this.Invoke(h, "", 101);
            }
        }