public void FifoReadSave(FifoReadWrite innerRead, string deviceName) { XmlDocument document = new XmlDocument(); SaveFileDialogComment comment = new SaveFileDialogComment { Filter = "WDS files (*.swc)|*.swc|All files (*.*)|*.*", FileName = "Read_FIFO" }; if ((comment.ShowDialog() == DialogResult.OK) && (comment.FileName != null)) { XmlTextWriter writer = new XmlTextWriter(comment.FileName, Encoding.UTF8) { Formatting = Formatting.Indented }; writer.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); writer.WriteStartElement("SPITools"); writer.Close(); document.Load(comment.FileName); XmlNode documentElement = document.DocumentElement; DoOnOpenSaveComment.setComment(documentElement, comment.Comment); this.StoreFifoRead(documentElement, innerRead, deviceName); MemoryStream outStream = new MemoryStream(); document.Save(outStream); outStream.Seek(0L, SeekOrigin.Begin); TextReader reader = new StreamReader(outStream); FileStream stream = new FileStream(comment.FileName, FileMode.Create, FileAccess.Write); TextWriter writer2 = new StreamWriter(stream); writer2.Write(Code.EncryptDecrypt(reader.ReadToEnd())); writer2.Flush(); stream.Close(); } }
public FifoReadWrite FifoReadOpen(FifoReadWrite myFRW, string deviceName) { Stream stream; XmlDocument document = new XmlDocument(); OpenFileDialogComment comment = new OpenFileDialogComment { Filter = "WDS files (*.swc)|*.swc|All files (*.*)|*.*" }; if ((comment.ShowDialog() == DialogResult.OK) && ((stream = new FileStream(comment.FileName, FileMode.Open, FileAccess.Read)) != null)) { MemoryStream stream2 = new MemoryStream(); TextWriter writer = new StreamWriter(stream2); TextReader reader = new StreamReader(stream); writer.Write(Code.EncryptDecrypt(reader.ReadToEnd())); writer.Flush(); stream2.Seek(0L, SeekOrigin.Begin); document.Load(stream2); document.PreserveWhitespace = false; XmlNode documentElement = document.DocumentElement; this.RestoreFifoRead(documentElement, myFRW, deviceName); } return myFRW; }
private void cbbMasterDB_SelectedIndexChanged(object sender, EventArgs e) { try { RegisterDGVACC = _myDev; if (dgvRegisterList.Rows.Count > 0) { dgvRegisterList.Rows[0].Selected = true; dgvRegisterList_SelectionChanged(null, null); } bool flag1 = _myDev.Notes == ""; myFifoReadWrite = new FifoReadWrite(_myDev.TxPufferSize, _myDev.RxPufferSize); FifoViewACC = myFifoReadWrite; myBatchCommandList = new BatchCommandList(); BatchViewACC = myBatchCommandList; myFormStatus = FormViewACC; } catch (Exception exception) { MessageBox.Show("Error at Database Selection!\n" + exception.Message); } }
private void btnSaveWrite_Click(object sender, EventArgs e) { try { if (_myDev.TxPufferSize <= 0) { MessageBox.Show("TxPuffer not defined!", "Warning!"); } else { myFifoReadWrite = FifoViewACC; new XMLReaderWriter().FifoWriteSave(myFifoReadWrite, _myDev.Type); } } catch (Exception exception) { MessageBox.Show("Error at Saveing Write Buffer!\n" + exception.Message); } }
private void btnOpenRead_Click(object sender, EventArgs e) { try { if (_myDev.RxPufferSize <= 0) { MessageBox.Show("RxPuffer not defined!", "Warning!"); } else { myFifoReadWrite = new XMLReaderWriter().FifoReadOpen(myFifoReadWrite, _myDev.Type); FifoViewACC = myFifoReadWrite; } } catch (Exception exception) { MessageBox.Show("Error at Opening Read Buffer!\n" + exception.Message); } }
private void cbbMasterDB_SelectedIndexChanged(object sender, EventArgs e) { try { this.RegisterDGVACC = this._myDev; if (this.dgvRegisterList.Rows.Count > 0) { this.dgvRegisterList.Rows[0].Selected = true; this.dgvRegisterList_SelectionChanged(null, null); } this.myFifoReadWrite = new FifoReadWrite(this._myDev.TxPufferSize, this._myDev.RxPufferSize); this.FifoViewACC = this.myFifoReadWrite; this.myBatchCommandList = new BatchCommandList(); this.BatchViewACC = this.myBatchCommandList; this.myFormStatus = this.FormViewACC; if (!this._isDeviceBusy) { this.ButtonLock(false); } } catch (Exception exception) { MessageBox.Show("Error at Database Selection!\n" + exception.Message); } }
private void btnSaveRead_Click(object sender, EventArgs e) { try { if (this._myDev.RxPufferSize <= 0) { MessageBox.Show("RxPuffer not defined!", "Warning!"); } else { this.myFifoReadWrite = this.FifoViewACC; new XMLReaderWriter().FifoReadSave(this.myFifoReadWrite, this._myDev.Type); } } catch (Exception exception) { MessageBox.Show("Error at Saving Read Buffer!\n" + exception.Message); } }
private void btnOpenWrite_Click(object sender, EventArgs e) { try { if (this._myDev.TxPufferSize <= 0) { MessageBox.Show("TxPuffer not defined!", "Warning!"); } else { this.myFifoReadWrite = new XMLReaderWriter().FifoWriteOpen(this.myFifoReadWrite, this._myDev.Type); this.FifoViewACC = this.myFifoReadWrite; } } catch (Exception exception) { MessageBox.Show("Error at Opening Write Buffer!\n" + exception.Message); } }
private void reloadRegisterGrid() { try { this.RegisterDGVACC = this._myDev; if (this.dgvRegisterList.Rows.Count > 0) { this.dgvRegisterList.Rows[0].Selected = true; this.dgvRegisterList_SelectionChanged(null, null); } bool flag1 = this._myDev.Notes == ""; this.myFifoReadWrite = new FifoReadWrite(this._myDev.TxPufferSize, this._myDev.RxPufferSize); this.myBatchCommandList = new BatchCommandList(); this.BatchViewACC = this.myBatchCommandList; this.myFormStatus = this.FormViewACC; } catch (Exception exception) { MessageBox.Show("Error at Database Selection!\n" + exception.Message); } }
public void StoreFifoWrite(XmlNode root, FifoReadWrite data, string deviceName) { XmlDocument ownerDocument = root.OwnerDocument; XmlElement newChild = ownerDocument.CreateElement("TxPuffer"); newChild.SetAttribute("name", deviceName); int length = data.TxArray.GetLength(0); for (int i = 0; i < length; i++) { XmlElement element2 = ownerDocument.CreateElement("Line"); element2.SetAttribute("index", i.ToString()); element2.SetAttribute("h", data.TxArray[i].H); newChild.AppendChild(element2); } root.AppendChild(newChild); }
public void RestoreFifoWrite(XmlNode root, FifoReadWrite data, string deviceName) { XmlDocument ownerDocument = root.OwnerDocument; XmlNodeList list = root.SelectNodes("TxPuffer"); if (list.Count > 0) { if (list[0].Attributes.GetNamedItem("name").Value.ToString() == deviceName) { XmlNode node = list[0]; foreach (XmlNode node2 in node.SelectNodes("Line")) { data.TxArray[Convert.ToInt32(node2.Attributes.GetNamedItem("index").Value.ToString())].H = node2.Attributes.GetNamedItem("h").Value.ToString(); } } else { GlobalServices.ErrMsg("SPI_tool.XMLReaderWriter.RestoreFifoWrite()", "Cannot open xml file of device \"" + list[0].Attributes.GetNamedItem("name").Value.ToString() + "\" to device \"" + deviceName + "\"!"); } } }