Exemple #1
0
        private void tslRead_Click(object sender, EventArgs e)
        {
            byte bytTag     = Convert.ToByte(((ToolStripButton)sender).Tag.ToString());
            bool blnShowMsg = (CsConst.MyEditMode != 1);

            if (HDLPF.UploadOrReadGoOn(this.Text, bytTag, blnShowMsg))
            {
                Cursor.Current = Cursors.WaitCursor;
                // SetVisableForDownOrUpload(false);
                // ReadDownLoadThread();  //增加线程,使得当前窗体的任何操作不被限制

                CsConst.MyUPload2DownLists = new List <byte[]>();

                string strName  = myDevName.Split('\\')[0].ToString();
                byte   bytSubID = byte.Parse(strName.Split('-')[0]);
                byte   bytDevID = byte.Parse(strName.Split('-')[1]);

                byte[] ArayRelay = new byte[] { bytSubID, bytDevID, (byte)(mywdDeviceType / 256), (byte)(mywdDeviceType % 256),
                                                (byte)MyActivePage, (byte)(myintDIndex / 256), (byte)(myintDIndex % 256) };
                CsConst.MyUPload2DownLists.Add(ArayRelay);
                CsConst.MyUpload2Down = Convert.ToByte(((ToolStripButton)sender).Tag.ToString());
                FrmDownloadShow Frm = new FrmDownloadShow();
                if (CsConst.MyUpload2Down == 0)
                {
                    Frm.FormClosing += new FormClosingEventHandler(UpdateDisplayInformationAccordingly);
                }
                Frm.ShowDialog();
            }
        }
Exemple #2
0
        private void tslRead_Click(byte bytTag)
        {
            bool blnShowMsg = (CsConst.MyEditMode != 1);

            if (HDLPF.UploadOrReadGoOn(this.Text, bytTag, blnShowMsg))
            {
                Cursor.Current = Cursors.WaitCursor;
                UpdateActivePageIndexFromUint();
                CsConst.MyUPload2DownLists = new List <byte[]>();

                string strName  = myDevName.Split('\\')[0].ToString();
                byte   bytSubID = byte.Parse(strName.Split('-')[0]);
                byte   bytDevID = byte.Parse(strName.Split('-')[1]);

                byte[] ArayRelay = new byte[] { bytSubID, bytDevID, (byte)(mywdDeviceType / 256), (byte)(mywdDeviceType % 256),
                                                (byte)MyActivePage, (byte)(myintDIndex / 256), (byte)(myintDIndex % 256) };
                CsConst.MyUPload2DownLists.Add(ArayRelay);
                CsConst.MyUpload2Down = bytTag;
                FrmDownloadShow Frm = new FrmDownloadShow();
                if (bytTag == 0)
                {
                    Frm.FormClosing += new FormClosingEventHandler(UpdateDisplayInformationAccordingly);
                }
                Frm.ShowDialog();
            }
        }
Exemple #3
0
        private void tsbDown_Click(object sender, EventArgs e)
        {
            try
            {
                byte bytTag     = Convert.ToByte(((ToolStripButton)sender).Tag.ToString());
                bool blnShowMsg = (CsConst.MyEditMode != 1);
                if (HDLPF.UploadOrReadGoOn(this.Text, bytTag, blnShowMsg))
                {
                    Cursor.Current = Cursors.WaitCursor;

                    CsConst.MyUPload2DownLists = new List <byte[]>();

                    string strName  = myDevName.Split('\\')[0].ToString();
                    byte   bytSubID = byte.Parse(strName.Split('-')[0]);
                    byte   bytDevID = byte.Parse(strName.Split('-')[1]);

                    byte[] ArayRelay = new byte[] { bytSubID, bytDevID, (byte)(mywdDevicerType / 256), (byte)(mywdDevicerType % 256), (byte)MyActivePage,
                                                    (byte)(mintIDIndex / 256), (byte)(mintIDIndex % 256),
                                                    Convert.ToByte(txtFrm.Text), Convert.ToByte(txtTo.Text) };
                    CsConst.MyUPload2DownLists.Add(ArayRelay);
                    CsConst.MyUpload2Down = Convert.ToByte(((ToolStripButton)sender).Tag.ToString());
                    FrmDownloadShow Frm = new FrmDownloadShow();
                    Frm.FormClosing += new FormClosingEventHandler(UpdateDisplayInformationAccordingly);
                    Frm.ShowDialog();
                }
            }
            catch
            {
            }
        }
Exemple #4
0
        private void btnUpdateA_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (dgOnline.RowCount <= 0)
                {
                    return;
                }
                if (CsConst.myOnlines.Count <= 0)
                {
                    return;
                }
                for (int i = 0; i < dgOnline.RowCount; i++)
                {
                    if (dgOnline[0, i].Value.ToString().ToUpper() == "TRUE")
                    {
                        break;
                    }
                }
                string strFileName = HDLPF.SaveFileDialogAccordingly("Project Name", "dat files (*.dat)|*.dat");
                if (strFileName == null)
                {
                    return;
                }
                CsConst.isRestore     = true;
                cl10.Visible          = true;
                this.Enabled          = false;
                CsConst.myBackupLists = new List <HdlDeviceBackupAndRestore>();
                for (int i = 0; i < dgOnline.RowCount; i++)
                {
                    if (dgOnline[0, i].Value.ToString().ToUpper() == "TRUE")
                    {
                        CsConst.isBackUpSucceed = false;

                        dgOnline[10, i].Value = CsConst.WholeTextsList[2577].sDisplayName;
                        int intTag = 0;
                        intTag = Convert.ToInt32(dgOnline[9, i].Value.ToString());
                        for (int j = 0; j < CsConst.myOnlines.Count; j++)
                        {
                            if (intTag == CsConst.myOnlines[j].intDIndex)
                            {
                                intTag = j;
                                break;
                            }
                        }

                        int    wdDeviceType = CsConst.myOnlines[intTag].DeviceType;
                        int    dIndex       = CsConst.myOnlines[intTag].intDIndex;
                        string strName      = CsConst.myOnlines[intTag].DevName;
                        byte   SubNetID     = CsConst.myOnlines[intTag].bytSub;
                        byte   DevID        = CsConst.myOnlines[intTag].bytDev;

                        CsConst.MyUPload2DownLists = new List <byte[]>();
                        byte[] ArayRelay = new byte[] { SubNetID, DevID, (byte)(wdDeviceType / 256), (byte)(wdDeviceType % 256), 0,
                                                        (byte)(dIndex / 256), (byte)(dIndex % 256) };
                        CsConst.MyUPload2DownLists.Add(ArayRelay);
                        CsConst.MyUpload2Down = 0;

                        FrmDownloadShow Frm = new FrmDownloadShow();
                        Frm.ShowDialog();
                        Cursor.Current = Cursors.WaitCursor;
                        if (CsConst.isBackUpSucceed)
                        {
                            dgOnline[10, i].Value = CsConst.WholeTextsList[2576].sDisplayName;
                        }
                        else
                        {
                            dgOnline[10, i].Value = CsConst.WholeTextsList[2578].sDisplayName;
                        }
                        Cursor.Current       = Cursors.Default;
                        dgOnline[0, i].Value = false;
                    }
                }
                if (CsConst.myBackupLists != null && CsConst.myBackupLists.Count != 0)
                {
                    FileStream      fs = new FileStream(strFileName, FileMode.Create);
                    BinaryFormatter bf = new BinaryFormatter();
                    bf.Serialize(fs, CsConst.myBackupLists);
                    fs.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            Cursor.Current    = Cursors.Default;
            this.Enabled      = true;
            CsConst.isRestore = false;
        }