private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (DialogResult.OK.Equals(ofdProjectFile.ShowDialog(this))) { projectFilePath = ofdProjectFile.FileName; projectFolderPath = Path.GetDirectoryName(projectFilePath); ProjectFileReader pfr = new ProjectFileReader(projectFilePath); opcMockProject = pfr.OpcMockProject; opcMockProject.OnProtocolAdded += new OpcMockProject.ProtocolHandler(opcMockProject_OnProtocolAdded); projectFileWriter = new ProjectFileWriter(opcMockProject, projectFolderPath); if (!File.Exists(DataFilePath())) { File.Create(DataFilePath()).Close(); } opcReader = new OpcReaderCsv(DataFilePath()); opcWriter = new OpcWriterCsv(DataFilePath()); FillOpcDataGrid(opcReader.ReadAllTags()); Text = "OPC Mock - " + opcMockProject.Name; EnableButtonsAfterDataFileLoad(); } }
public ProjectFileReader(string projectFilePath) { this.projectFilePath = projectFilePath; this.projectFileContent = File.ReadAllText(projectFilePath); this.opcMockProject = ParseFileContent(); }
public ProjectFileReader(string projectFilePath) { this.projectFilePath = projectFilePath; this.projectFileContent = File.ReadAllText(projectFilePath); this.opcMockProject = ParseFileContent(); }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { CreateProjectDialog cpd = new CreateProjectDialog(); cpd.StartPosition = FormStartPosition.CenterParent; if (DialogResult.OK.Equals(cpd.ShowDialog(this))) { opcMockProject = cpd.Project; opcMockProject.OnProtocolAdded += new OpcMockProject.ProtocolHandler(opcMockProject_OnProtocolAdded); projectFolderPath = cpd.ProjectFolderPath; projectFileWriter = new ProjectFileWriter(opcMockProject, projectFolderPath); projectFileWriter.Save(); if (!File.Exists(DataFilePath())) { File.Create(DataFilePath()).Close(); } opcReader = new OpcReaderCsv(DataFilePath()); opcWriter = new OpcWriterCsv(DataFilePath()); Text = "OPC Mock - " + opcMockProject.Name; EnableButtonsAfterDataFileLoad(); } cpd.Dispose(); }
private void btnCreateProject_Click(object sender, EventArgs e) { opcMockProject = new OpcMockProject(tbProjectName.Text); this.DialogResult = DialogResult.OK; this.Hide(); }
private void btnCreateProject_Click(object sender, EventArgs e) { opcMockProject = new OpcMockProject(tbProjectName.Text); this.DialogResult = DialogResult.OK; this.Hide(); }
public void SaveShould_Write_Protocol_Segment() { OpcMockProject projectWithOneProtocol = new OpcMockProject(PROJECT_NAME); string firstProtocolName = "firstProtocol"; projectWithOneProtocol.AddProtocol(new OpcMockProtocol(firstProtocolName)); projectFileWriter = new ProjectFileWriter(projectWithOneProtocol, TestContext.TestDir); XElement fileContentStartXml = new XElement("project", new XElement("project_name", PROJECT_NAME), new XElement("protocol_list", new XElement("protocol", firstProtocolName))); SaveContentToFileAndCheckResult(fileContentStartXml.ToString()); }
private OpcMockProject ParseFileContent() { OpcMockProject omp; XmlDocument doc = new XmlDocument(); doc.Load(projectFilePath); string projectName = doc.GetElementsByTagName("project_name")[0].InnerText; omp = new OpcMockProject(projectName); List<string> protocolNames = new List<string>(); XmlNodeList protocolTags = doc.GetElementsByTagName("protocol"); foreach (XmlNode protocolTag in protocolTags) { omp.AddProtocol(new OpcMockProtocol(protocolTag.InnerText)); } return omp; }
private OpcMockProject ParseFileContent() { OpcMockProject omp; XmlDocument doc = new XmlDocument(); doc.Load(projectFilePath); string projectName = doc.GetElementsByTagName("project_name")[0].InnerText; omp = new OpcMockProject(projectName); List <string> protocolNames = new List <string>(); XmlNodeList protocolTags = doc.GetElementsByTagName("protocol"); foreach (XmlNode protocolTag in protocolTags) { omp.AddProtocol(new OpcMockProtocol(protocolTag.InnerText)); } return(omp); }
public ProjectFileWriter(OpcMockProject opcMockProject, string projectFolderPath) { this.projectFolderPath = projectFolderPath; this.opcMockProject = opcMockProject; this.content = string.Empty; }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (DialogResult.OK.Equals(ofdProjectFile.ShowDialog(this))) { projectFilePath = ofdProjectFile.FileName; projectFolderPath = Path.GetDirectoryName(projectFilePath); ProjectFileReader pfr = new ProjectFileReader(projectFilePath); opcMockProject = pfr.OpcMockProject; opcMockProject.OnProtocolAdded += new OpcMockProject.ProtocolHandler(opcMockProject_OnProtocolAdded); projectFileWriter = new ProjectFileWriter(opcMockProject, projectFolderPath); if (!File.Exists(DataFilePath())) { File.Create(DataFilePath()).Close(); } opcReader = new OpcReaderCsv(DataFilePath()); opcWriter = new OpcWriterCsv(DataFilePath()); FillOpcDataGrid(opcReader.ReadAllTags()); Text = "OPC Mock - " + opcMockProject.Name; EnableButtonsAfterDataFileLoad(); } }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { CreateProjectDialog cpd = new CreateProjectDialog(); cpd.StartPosition = FormStartPosition.CenterParent; if (DialogResult.OK.Equals(cpd.ShowDialog(this))) { opcMockProject = cpd.Project; opcMockProject.OnProtocolAdded += new OpcMockProject.ProtocolHandler(opcMockProject_OnProtocolAdded); projectFolderPath = cpd.ProjectFolderPath; projectFileWriter = new ProjectFileWriter(opcMockProject, projectFolderPath); projectFileWriter.Save(); if (!File.Exists(DataFilePath())) { File.Create(DataFilePath()).Close(); } opcReader = new OpcReaderCsv(DataFilePath()); opcWriter = new OpcWriterCsv(DataFilePath()); Text = "OPC Mock - " + opcMockProject.Name; EnableButtonsAfterDataFileLoad(); } cpd.Dispose(); }
public ProjectFileWriter(OpcMockProject opcMockProject, string projectFolderPath) { this.projectFolderPath = projectFolderPath; this.opcMockProject = opcMockProject; this.content = string.Empty; }
public void TestInitialize() { opcMockProject = new OpcMockProject(PROJECT_NAME); }