Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        public ProjectFileReader(string projectFilePath)
        {
            this.projectFilePath    = projectFilePath;
            this.projectFileContent = File.ReadAllText(projectFilePath);

            this.opcMockProject = ParseFileContent();
        }
Exemplo n.º 3
0
        public ProjectFileReader(string projectFilePath)
        {
            this.projectFilePath = projectFilePath;
            this.projectFileContent = File.ReadAllText(projectFilePath);

            this.opcMockProject = ParseFileContent();
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        private void btnCreateProject_Click(object sender, EventArgs e)
        {
            opcMockProject = new OpcMockProject(tbProjectName.Text);

            this.DialogResult = DialogResult.OK;

            this.Hide();
        }
Exemplo n.º 6
0
        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());
        }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
 public ProjectFileWriter(OpcMockProject opcMockProject, string projectFolderPath)
 {
     this.projectFolderPath = projectFolderPath;
     this.opcMockProject = opcMockProject;
     this.content = string.Empty;
 }
Exemplo n.º 11
0
        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();
            }
        }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 13
0
 public ProjectFileWriter(OpcMockProject opcMockProject, string projectFolderPath)
 {
     this.projectFolderPath = projectFolderPath;
     this.opcMockProject    = opcMockProject;
     this.content           = string.Empty;
 }
Exemplo n.º 14
0
 public void TestInitialize()
 {
     opcMockProject = new OpcMockProject(PROJECT_NAME);
 }