* File management to Demo application
* File management to Demo Library
This commit is contained in:
Lucio Maranta
2017-11-13 16:24:15 +00:00
parent 726f6ee52d
commit 09aaaeb2ac
45 changed files with 522 additions and 71 deletions
Binary file not shown.
+6
View File
@@ -1,7 +1,13 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
<<<<<<< .mine
VisualStudioVersion = 15.0.27004.2006
||||||| .r6
VisualStudioVersion = 15.0.27004.2005
=======
VisualStudioVersion = 15.0.26730.16
>>>>>>> .r9
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CMS_CORE_Application", "CMS_CORE_Application\CMS_CORE_Application.csproj", "{EEB0C188-6EFA-4ABB-9E6F-4D423006428C}"
ProjectSection(ProjectDependencies) = postProject
+14
View File
@@ -12,6 +12,7 @@ using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace CMS_CORE_Application
{
@@ -67,6 +68,19 @@ namespace CMS_CORE_Application
byte byteValue = 0;
nc_Demo.MEM_RWByte(false, 1, Nc.MEMORY_Type.Null, 0, 0, ref byteValue);
MessageBox.Show("First byte: " + byteValue.ToString() + "\nDateTime: " + testDateTime.ToString());
FileStream a = new FileStream("./test.txt", FileMode.Create, FileAccess.ReadWrite);
nc_Demo.FILES_RProgramToFile("test.txt", a);
a.Close();
a = new FileStream("./test.txt", FileMode.Open, FileAccess.Read);
nc_Demo.FILES_WProgramFromFile("nuovissimo", a);
a.Close();
nc_Demo.FILES_CopyProgram("test.txt", "test.txt", true);
nc_Demo.FILES_DeleteProgram("", "test1.txt");
}
catch (Nc_Exception ex)
{
+1
View File
@@ -67,6 +67,7 @@
</Compile>
<Compile Include="Demo\ILibraryService.cs" />
<Compile Include="Demo\Models\BinaryMemoryModel.cs" />
<Compile Include="Demo\Models\FileModel.cs" />
<Compile Include="Demo\Models\NcAlarmModel.cs" />
<Compile Include="Demo\Models\NcAxisModel.cs" />
<Compile Include="Demo\Models\NcDataModel.cs" />
+16
View File
@@ -126,5 +126,21 @@ namespace Nc_Demo_Application.Server.Service
[WebInvoke(Method = "PUT", UriTemplate = "binary_memory/dword/{index}/list", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
void PutDWordList(string index, BinaryMemoryModel body);
#endregion
#region File Management
[WebGet(UriTemplate = "file/{fileName}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
void GetFile(string fileName, out string fileContent);
[WebInvoke(Method = "POST", UriTemplate = "file", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void PostFile(FileModel file);
[WebInvoke(Method = "PUT", UriTemplate = "file", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void CopyFile(FileModel file);
[WebInvoke(Method = "DELETE", UriTemplate = "file/{fileName}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void DeleteFile(string fileName);
#endregion
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace CMS_CORE.Demo.Models
{
[DataContract]
class FileModel
{
[DataMember]
public string sourceFileName;
[DataMember]
public string destFileName;
[DataMember]
public string fileContent;
[DataMember]
public bool failIfExist;
}
}
+59 -11
View File
@@ -4,15 +4,12 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.Text;
using System.Threading.Tasks;
using CMS_CORE.Demo.Models;
using CMS_CORE.Exceptions;
using CMS_CORE_Library.Demo.Models;
using Nc_Demo_Application.Server.Service;
using CMS_CORE_Library;
using CMS_CORE.Utils;
namespace CMS_CORE.Demo
{
@@ -692,28 +689,79 @@ namespace CMS_CORE.Demo
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region File Management
public override void FILES_RProgramToFile(string partProgramPath, string partProgramLocalName, ref FileStream localFile)
public override void FILES_RProgramToFile(string partProgramPath, FileStream localFile)
{
throw new NotImplementedException();
// Check if the NC Demo is Connected
CheckConnection();
try
{
serverService.GetFile(partProgramPath, out string fileContent);
Nc_Utils.WriteLocalFile(fileContent, ref localFile);
}
catch(Exception ex)
{
ThrowNCException(ex);
}
}
public override void FILES_WProgramFromFile(string partProgramPath, FileStream localFile)
{
throw new NotImplementedException();
// Check if the NC Demo is Connected
CheckConnection();
try
{
FileModel fileData = new FileModel
{
fileContent = Nc_Utils.ReadLocalFile(localFile),
destFileName = partProgramPath
};
serverService.PostFile(fileData);
}
catch (Exception ex)
{
ThrowNCException(ex);
}
}
public override void FILES_CopyProgram(string partProgramPath, string newPartProgramPath, bool failIfExist)
{
throw new NotImplementedException();
// Check if the NC Demo is Connected
CheckConnection();
try
{
FileModel fileData = new FileModel
{
sourceFileName = partProgramPath,
destFileName = newPartProgramPath,
failIfExist = failIfExist
};
serverService.CopyFile(fileData);
}
catch (Exception ex)
{
ThrowNCException(ex);
}
}
public override void FILES_DeleteProgram(string partProgramPath, string partProgramName)
{
throw new NotImplementedException();
// Check if the NC Demo is Connected
CheckConnection();
try
{
serverService.DeleteFile(partProgramName);
}
catch (Exception ex)
{
ThrowNCException(ex);
}
}
#endregion
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region Subordinate Private Functions
+2 -2
View File
@@ -1181,7 +1181,7 @@ namespace CMS_CORE.Fanuc
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region File Management
public override void FILES_RProgramToFile(string partProgramPath, string partProgramLocalName, ref FileStream localFile)
public override void FILES_RProgramToFile(string partProgramPath, FileStream localFile)
{
string partProgramContent = "";
@@ -1190,7 +1190,7 @@ namespace CMS_CORE.Fanuc
try
{
// Write content into local file
Nc_Utils.WriteLocalFile(partProgramLocalName, partProgramContent, ref localFile);
Nc_Utils.WriteLocalFile(partProgramContent, ref localFile);
}
catch (Exception ex)
{
+1 -1
View File
@@ -678,7 +678,7 @@ namespace CMS_CORE
* <param name="partProgramLocalName">Name of the Part Program and name of new local file</param>
* <param name="localFile">Reference to the new local file where the NC Part Program data will be saved</param>
* */
public abstract void FILES_RProgramToFile(string partProgramPath, string partProgramLocalName, ref FileStream localFile);
public abstract void FILES_RProgramToFile(string partProgramPath, FileStream localFile);
/**
* <summary>Write/Overwrite a Part Program by path and name
+6 -6
View File
@@ -1065,16 +1065,16 @@ namespace CMS_CORE.Osai
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region File Management
public override void FILES_RProgramToFile(string partProgramPath, string partProgramLocalName, ref FileStream localFile)
public override void FILES_RProgramToFile(string partProgramPath, FileStream localFile)
{
string partProgramContent = "";
// Read NC part program content
R_NCReadPartProgram(partProgramPath, ref partProgramContent); ;
FILES_RProgram(partProgramPath, ref partProgramContent); ;
try
{
// Write content into local file
Nc_Utils.WriteLocalFile(partProgramLocalName, partProgramContent, ref localFile);
Nc_Utils.WriteLocalFile(partProgramContent, ref localFile);
}
catch (Exception ex)
{
@@ -1082,7 +1082,7 @@ namespace CMS_CORE.Osai
}
}
private void R_NCReadPartProgram(string partProgramPath, ref string partProgramContent)
private void FILES_RProgram(string partProgramPath, ref string partProgramContent)
{
//Check if the NC is Connected
CheckConnection();
@@ -1122,10 +1122,10 @@ namespace CMS_CORE.Osai
ThrowNCException(ex);
}
// Write/Overwrite Nc file
W_NCWritePartProgram(partProgramPath, partProgramContent);
FILES_WProgram(partProgramPath, partProgramContent);
}
private void W_NCWritePartProgram(string partProgramPath, string partProgramContent)
private void FILES_WProgram(string partProgramPath, string partProgramContent)
{
//Check if the NC is Connected
CheckConnection();
+2 -5
View File
@@ -146,14 +146,11 @@ namespace CMS_CORE.Utils
return Uint;
}
public static void WriteLocalFile(string fileName, string fileContent, ref FileStream fileReference)
public static void WriteLocalFile(string fileContent, ref FileStream fileReference)
{
// Create new local Part Program
fileReference = new FileStream(partProgramFolder + fileName, FileMode.OpenOrCreate, FileAccess.Write);
// Write Part Program
StreamWriter writer = new StreamWriter(fileReference);
writer.WriteLine(fileContent);
writer.Write(fileContent);
// Close file Writer
writer.Close();
}
Binary file not shown.
Binary file not shown.
@@ -553,7 +553,7 @@
<param name="Value">List of values to read/Write</param>
</member>
<member name="M:CMS_CORE.Nc.FILES_RProgramToFile(System.String,System.String,System.IO.FileStream@)">
<member name="M:CMS_CORE.Nc.FILES_RProgramToFile(System.String,System.IO.FileStream)">
<summary>Read a Part Program by path and name
<para>
Compatibility: Fanuc | Osai | Demo
Binary file not shown.
@@ -1 +1 @@
9a1c4b88cb1ae7a511e2e79c37db6884ee251c65
7d878ebe32103cd5e6f43f15a703880188ed56f2
Binary file not shown.
Binary file not shown.
@@ -53,6 +53,7 @@
<Reference Include="System.Data.SQLite.Linq, Version=1.0.105.2, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.105.2\lib\net451\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.DirectoryServices" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
@@ -73,10 +74,11 @@
<ItemGroup>
<Compile Include="Constants.cs" />
<Compile Include="Database\DatabaseController.cs" />
<Compile Include="Database\Models\BinaryMemoryModel.cs" />
<Compile Include="Server\Models\BinaryMemoryModel.cs" />
<Compile Include="Database\Models\NcAlarmModel.cs" />
<Compile Include="Database\Models\NcAxisModel.cs" />
<Compile Include="Database\Models\NcProcessModel.cs" />
<Compile Include="Server\Models\FileModel.cs" />
<Compile Include="Views\DemoApplicationForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -26,5 +26,8 @@ namespace Nc_Demo_Application
// CMS Process mode
public enum PROC_MODE : ushort { AUTO = 1, EDIT = 2, MDI = 3, REMOTE = 4, TEACH = 5, REF = 6, JOG = 7, JOGINC = 8, RETPROF = 9, HANDLE = 10, RESTART = 11, ERROR = 12 };
// File
public const string FILE_FOLDER = "./part_program/";
}
}
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace Nc_Demo_Application.Server.Models
{
[DataContract]
class FileModel
{
[DataMember]
public string sourceFileName;
[DataMember]
public string destFileName;
[DataMember]
public string fileContent;
[DataMember]
public bool failIfExist;
}
}
@@ -4,6 +4,7 @@ using System.ServiceModel;
using System.ServiceModel.Web;
using static Nc_Demo_Application.Constants;
using System.Collections.Generic;
using Nc_Demo_Application.Server.Models;
namespace Nc_Demo_Application.Server.Service
{
@@ -129,5 +130,21 @@ namespace Nc_Demo_Application.Server.Service
[WebInvoke(Method = "PUT", UriTemplate = "binary_memory/dword/{index}/list", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
void PutDWordList(string index, BinaryMemoryModel body);
#endregion
#region File Management
[WebGet(UriTemplate = "file/{fileName}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
void GetFile(string fileName, out string fileContent);
[WebInvoke(Method = "POST", UriTemplate = "file", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void PostFile(FileModel file);
[WebInvoke(Method = "PUT", UriTemplate = "file", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void CopyFile(FileModel file);
[WebInvoke(Method = "DELETE", UriTemplate = "file/{fileName}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void DeleteFile(string fileName);
#endregion
}
}
@@ -7,6 +7,8 @@ using static Nc_Demo_Application.Constants;
using System.Linq;
using System.ServiceModel.Web;
using System.Net;
using System.IO;
using Nc_Demo_Application.Server.Models;
namespace Nc_Demo_Application.Server.Service
{
@@ -308,6 +310,81 @@ namespace Nc_Demo_Application.Server.Service
}
#endregion
#region File Management
public void GetFile(string fileName, out string fileContent)
{
// If file not exist
if (!File.Exists(FILE_FOLDER + fileName))
throw new WebFaultException(HttpStatusCode.NotFound);
try
{
// Read file
fileContent = File.ReadAllText(FILE_FOLDER + fileName);
}
catch (Exception)
{
throw new WebFaultException(HttpStatusCode.InternalServerError);
}
}
public void PostFile(FileModel file)
{
try
{
// Write/Overwrite file
File.WriteAllText(FILE_FOLDER + file.destFileName, file.fileContent);
}
catch (Exception ex)
{
throw new WebFaultException(HttpStatusCode.InternalServerError);
}
}
public void CopyFile(FileModel file)
{
string sourcePath = FILE_FOLDER + file.sourceFileName;
string destPath = FILE_FOLDER + file.destFileName;
// Source file not exists
if (!File.Exists(sourcePath))
throw new WebFaultException(HttpStatusCode.NotFound);
// Source and destination file same name
if (file.sourceFileName == file.destFileName)
throw new WebFaultException(HttpStatusCode.BadRequest);
// if failIfExist == true check if dest file exist
if (file.failIfExist && File.Exists(destPath))
throw new WebFaultException(HttpStatusCode.Conflict);
try
{
// Copy file
File.Copy(FILE_FOLDER + file.sourceFileName, FILE_FOLDER + file.destFileName, true);
}
catch (Exception)
{
throw new WebFaultException(HttpStatusCode.InternalServerError);
}
}
public void DeleteFile(string fileName)
{
if (!File.Exists(FILE_FOLDER + fileName))
throw new WebFaultException(HttpStatusCode.NotFound);
try
{
File.Delete(FILE_FOLDER + fileName);
}
catch (Exception)
{
throw new WebFaultException(HttpStatusCode.InternalServerError);
}
}
#endregion
}
}
@@ -90,6 +90,14 @@
this.BinaryMemoryBinaryColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.BinaryMemoryWordColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.BinaryMemoryIntegerColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.partProgramPage = new System.Windows.Forms.TabPage();
this.fileContentTextBox = new System.Windows.Forms.TextBox();
this.toolStrip6 = new System.Windows.Forms.ToolStrip();
this.saveFileButton = new System.Windows.Forms.ToolStripButton();
this.deleteFileButton = new System.Windows.Forms.ToolStripButton();
this.addFileButton = new System.Windows.Forms.ToolStripButton();
this.newFileNameTextBox = new System.Windows.Forms.ToolStripTextBox();
this.fileTreeView = new System.Windows.Forms.TreeView();
this.serverStatusLabel = new System.Windows.Forms.Label();
this.ncAxesSaveButton.SuspendLayout();
this.ncDataPage.SuspendLayout();
@@ -106,6 +114,8 @@
this.byteMemoryPage.SuspendLayout();
this.toolStrip2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.binaryMemoryGridView)).BeginInit();
this.partProgramPage.SuspendLayout();
this.toolStrip6.SuspendLayout();
this.SuspendLayout();
//
// stopServer
@@ -125,6 +135,7 @@
this.ncAxesSaveButton.Controls.Add(this.alarms);
this.ncAxesSaveButton.Controls.Add(this.ncAxesPage);
this.ncAxesSaveButton.Controls.Add(this.byteMemoryPage);
this.ncAxesSaveButton.Controls.Add(this.partProgramPage);
this.ncAxesSaveButton.Location = new System.Drawing.Point(12, 12);
this.ncAxesSaveButton.Name = "ncAxesSaveButton";
this.ncAxesSaveButton.SelectedIndex = 0;
@@ -420,7 +431,7 @@
this.saveNcAlarmsButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.saveNcAlarmsButton.Name = "saveNcAlarmsButton";
this.saveNcAlarmsButton.Size = new System.Drawing.Size(23, 22);
this.saveNcAlarmsButton.Text = "save";
this.saveNcAlarmsButton.Text = "Save";
this.saveNcAlarmsButton.Click += new System.EventHandler(this.SaveNcAlarmsButton_Click);
//
// ncAlarmsGridView
@@ -605,7 +616,7 @@
this.addRowsBinaryMemory.ImageTransparentColor = System.Drawing.Color.Magenta;
this.addRowsBinaryMemory.Name = "addRowsBinaryMemory";
this.addRowsBinaryMemory.Size = new System.Drawing.Size(23, 22);
this.addRowsBinaryMemory.Text = "toolStripButton1";
this.addRowsBinaryMemory.Text = "Add 4 Rows";
this.addRowsBinaryMemory.Click += new System.EventHandler(this.addRowsBinaryMemory_Click);
//
// deleteRowsBinaryMemory
@@ -615,7 +626,7 @@
this.deleteRowsBinaryMemory.ImageTransparentColor = System.Drawing.Color.Magenta;
this.deleteRowsBinaryMemory.Name = "deleteRowsBinaryMemory";
this.deleteRowsBinaryMemory.Size = new System.Drawing.Size(23, 22);
this.deleteRowsBinaryMemory.Text = "toolStripButton1";
this.deleteRowsBinaryMemory.Text = "Remove 4 rows";
this.deleteRowsBinaryMemory.Click += new System.EventHandler(this.deleteRowsBinaryMemory_Click);
//
// binaryMemoryGridView
@@ -669,6 +680,86 @@
this.BinaryMemoryIntegerColumn.HeaderText = "Integer";
this.BinaryMemoryIntegerColumn.Name = "BinaryMemoryIntegerColumn";
//
// partProgramPage
//
this.partProgramPage.Controls.Add(this.fileContentTextBox);
this.partProgramPage.Controls.Add(this.toolStrip6);
this.partProgramPage.Controls.Add(this.fileTreeView);
this.partProgramPage.Location = new System.Drawing.Point(4, 22);
this.partProgramPage.Name = "partProgramPage";
this.partProgramPage.Padding = new System.Windows.Forms.Padding(3);
this.partProgramPage.Size = new System.Drawing.Size(556, 410);
this.partProgramPage.TabIndex = 5;
this.partProgramPage.Text = "Part Program";
this.partProgramPage.UseVisualStyleBackColor = true;
//
// fileContentTextBox
//
this.fileContentTextBox.Enabled = false;
this.fileContentTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.fileContentTextBox.Location = new System.Drawing.Point(130, 31);
this.fileContentTextBox.Multiline = true;
this.fileContentTextBox.Name = "fileContentTextBox";
this.fileContentTextBox.Size = new System.Drawing.Size(423, 373);
this.fileContentTextBox.TabIndex = 2;
//
// toolStrip6
//
this.toolStrip6.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.saveFileButton,
this.deleteFileButton,
this.addFileButton,
this.newFileNameTextBox});
this.toolStrip6.Location = new System.Drawing.Point(3, 3);
this.toolStrip6.Name = "toolStrip6";
this.toolStrip6.Size = new System.Drawing.Size(550, 25);
this.toolStrip6.TabIndex = 1;
this.toolStrip6.Text = "toolStrip6";
//
// saveFileButton
//
this.saveFileButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.saveFileButton.Enabled = false;
this.saveFileButton.Image = ((System.Drawing.Image)(resources.GetObject("saveFileButton.Image")));
this.saveFileButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.saveFileButton.Name = "saveFileButton";
this.saveFileButton.Size = new System.Drawing.Size(23, 22);
this.saveFileButton.Text = "Save file";
this.saveFileButton.Click += new System.EventHandler(this.SaveFileButton_Click);
//
// deleteFileButton
//
this.deleteFileButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.deleteFileButton.Image = ((System.Drawing.Image)(resources.GetObject("deleteFileButton.Image")));
this.deleteFileButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.deleteFileButton.Name = "deleteFileButton";
this.deleteFileButton.Size = new System.Drawing.Size(23, 22);
this.deleteFileButton.Text = "Delete file";
this.deleteFileButton.Click += new System.EventHandler(this.DeleteFile_Click);
//
// addFileButton
//
this.addFileButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.addFileButton.Image = ((System.Drawing.Image)(resources.GetObject("addFileButton.Image")));
this.addFileButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.addFileButton.Name = "addFileButton";
this.addFileButton.Size = new System.Drawing.Size(23, 22);
this.addFileButton.Text = "Add file";
this.addFileButton.Click += new System.EventHandler(this.AddFile_Click);
//
// newFileNameTextBox
//
this.newFileNameTextBox.Name = "newFileNameTextBox";
this.newFileNameTextBox.Size = new System.Drawing.Size(100, 25);
//
// fileTreeView
//
this.fileTreeView.Location = new System.Drawing.Point(3, 31);
this.fileTreeView.Name = "fileTreeView";
this.fileTreeView.Size = new System.Drawing.Size(121, 375);
this.fileTreeView.TabIndex = 0;
this.fileTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.FileTreeView_AfterSelect);
//
// serverStatusLabel
//
this.serverStatusLabel.AutoEllipsis = true;
@@ -689,6 +780,7 @@
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "DemoApplicationForm";
this.Text = "Nc Demo Application";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DemoApplicationForm_FormClosing);
this.Load += new System.EventHandler(this.DemoApplicationForm_Load);
this.ncAxesSaveButton.ResumeLayout(false);
this.ncDataPage.ResumeLayout(false);
@@ -715,6 +807,10 @@
this.toolStrip2.ResumeLayout(false);
this.toolStrip2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.binaryMemoryGridView)).EndInit();
this.partProgramPage.ResumeLayout(false);
this.partProgramPage.PerformLayout();
this.toolStrip6.ResumeLayout(false);
this.toolStrip6.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -783,6 +879,14 @@
private System.Windows.Forms.DataGridViewTextBoxColumn ncAlarmProcessIdColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn ncAlarmTextColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn ncAlarmIdColumn;
private System.Windows.Forms.TabPage partProgramPage;
private System.Windows.Forms.ToolStrip toolStrip6;
private System.Windows.Forms.ToolStripButton addFileButton;
private System.Windows.Forms.TreeView fileTreeView;
private System.Windows.Forms.ToolStripTextBox newFileNameTextBox;
private System.Windows.Forms.ToolStripButton deleteFileButton;
private System.Windows.Forms.TextBox fileContentTextBox;
private System.Windows.Forms.ToolStripButton saveFileButton;
}
}
@@ -7,6 +7,7 @@ using System.Windows.Forms;
using static Nc_Demo_Application.Constants;
using System.Data;
using System.Linq;
using System.IO;
namespace Nc_Demo_Application
{
@@ -33,21 +34,27 @@ namespace Nc_Demo_Application
FillNcAlarmsInput();
FillNAxisInput();
FillBinaryMemoryInput();
ListDirectory("./part_program");
serverStatusLabel.Text = "Server running on: http://localhost:" + SERVER_PORT + API_URL;
}
private void StopServer_Click(object sender, EventArgs e)
{
Close();
}
private void DemoApplicationForm_FormClosing(object sender, FormClosingEventArgs e)
{
CloseServer();
}
private void CloseServer()
{
// Stop Server
ServerController.getInstance().Stop();
// Reset button status
DatabaseController.getInstance().ResetDatabase();
StartupForm startupForm = new StartupForm();
// Close form
Close();
startupForm.Show();
}
private void FillNcDataInput()
@@ -280,5 +287,91 @@ namespace Nc_Demo_Application
}
}
private void ListDirectory(string path)
{
// Clear Tree view
fileTreeView.Nodes.Clear();
var stack = new Stack<TreeNode>();
var rootDirectory = new DirectoryInfo(path);
// Push
var node = new TreeNode(rootDirectory.Name) { Tag = rootDirectory };
stack.Push(node);
while (stack.Count > 0)
{
// Get new node
var currentNode = stack.Pop();
// Add tag to new node
var directoryInfo = (DirectoryInfo)currentNode.Tag;
// Add node to Treeview
foreach (FileInfo file in directoryInfo.GetFiles())
currentNode.Nodes.Add(new TreeNode(file.Name));
}
fileTreeView.Nodes.Add(node);
}
private void AddFile_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(newFileNameTextBox.Text))
{
File.Create(FILE_FOLDER + newFileNameTextBox.Text).Dispose();
fileTreeView.Nodes[0].Nodes.Add(new TreeNode(newFileNameTextBox.Text));
}
else
{
MessageBox.Show("Insert file name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void DeleteFile_Click(object sender, EventArgs e)
{
string selectedFile = fileTreeView.SelectedNode.Text;
try
{
// If file exists
if (File.Exists(FILE_FOLDER + selectedFile))
{
// Delete file and update treeView
File.Delete(FILE_FOLDER + selectedFile);
fileTreeView.SelectedNode.Remove();
}
else
MessageBox.Show("Select a file");
}
catch(Exception ex)
{
Console.WriteLine("File exception: " + ex.Message);
}
}
private void FileTreeView_AfterSelect(object sender, TreeViewEventArgs e)
{
string selectedFile = fileTreeView.SelectedNode.Text;
// On treeview change, update textview if file exists
if (File.Exists(FILE_FOLDER + selectedFile))
{
fileContentTextBox.Text = File.ReadAllText(FILE_FOLDER + selectedFile);
fileContentTextBox.Enabled = true;
saveFileButton.Enabled = true;
}
else
{
fileContentTextBox.Text = "";
fileContentTextBox.Enabled = false;
saveFileButton.Enabled = false;
}
}
private void SaveFileButton_Click(object sender, EventArgs e)
{
string selectedFile = fileTreeView.SelectedNode.Text;
if (File.Exists(FILE_FOLDER + selectedFile))
File.WriteAllText(FILE_FOLDER + selectedFile, fileContentTextBox.Text);
}
}
}
@@ -120,6 +120,21 @@
<metadata name="toolStrip5.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>437, 17</value>
</metadata>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>122, 17</value>
</metadata>
<metadata name="toolStrip3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>227, 17</value>
</metadata>
<metadata name="toolStrip4.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>332, 17</value>
</metadata>
<metadata name="toolStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="toolStrip6.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>542, 17</value>
</metadata>
<metadata name="toolStrip5.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>437, 17</value>
</metadata>
@@ -135,9 +150,6 @@
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>122, 17</value>
</metadata>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>122, 17</value>
</metadata>
<data name="saveNcProcessData.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
@@ -173,9 +185,6 @@
<metadata name="toolStrip3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>227, 17</value>
</metadata>
<metadata name="toolStrip3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>227, 17</value>
</metadata>
<data name="saveNcAlarmsButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
@@ -211,9 +220,6 @@
<metadata name="toolStrip4.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>332, 17</value>
</metadata>
<metadata name="toolStrip4.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>332, 17</value>
</metadata>
<data name="saveNcAxesButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
@@ -273,9 +279,6 @@
<metadata name="toolStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="toolStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="saveBinaryMemoryButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
@@ -316,6 +319,28 @@
<metadata name="BinaryMemoryIntegerColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="saveFileButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABRSURBVDhPY6AK+Pbt239S8NevX+dDtUIASJAheA4cf3j/
EY6RxUB0zIR9mIaQYgAIwwyBaifdABAm2gBkjKyGtgYQg0cNGJQGkIOh2ikBDAwAR/4LjdUkCHIAAAAA
SUVORK5CYII=
</value>
</data>
<data name="deleteFileButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAmSURBVDhPYxgFVADfvn37TwkGG+Dk5EQWHk4GUIKhcTEK
yAcMDABULP5BZjjimQAAAABJRU5ErkJggg==
</value>
</data>
<data name="addFileButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABISURBVDhPY8AGvn379h8bhkoTBiDFFl0mKHg4GwCSwIax
GYANY7WNWDycDMCGsSnGhqFxgQpAEtgMgEoTBsPEAGwYKo0EGBgAMACkrMWZPQwAAAAASUVORK5CYII=
</value>
</data>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAgIAAAAEAIAAoCAEAFgAAACgAAACAAAAAAAEAAAEAIAAAAAAAAAgBAAAAAAAAAAAAAAAAAAAA
@@ -24,8 +24,8 @@ namespace Nc_Demo_Application
SERVER_PORT = serverPort.Text;
Hide();
DemoApplicationForm serverForm = new DemoApplicationForm();
serverForm.Show();
serverForm.Focus();
serverForm.ShowDialog(this);
Show();
}
}
}
@@ -1 +1 @@
1c8a422d4d7efb455dfa5a9d1bb9c8f170cb2c87
ad2ae4727336963bc917a71807a3007832481da7
@@ -18,27 +18,30 @@ C:\Workspace\Nc_Demo_Application\Nc_Demo_Application\obj\Debug\CMS_Core_Nc_Demo_
C:\Workspace\Nc_Demo_Application\Nc_Demo_Application\obj\Debug\CMS_Core_Nc_Demo_Application.csproj.CoreCompileInputs.cache
C:\Workspace\Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.exe
C:\Workspace\Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.pdb
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\Nc_Demo_Application.exe.config
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\Nc_Demo_Application.exe
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\Nc_Demo_Application.pdb
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\EntityFramework.dll
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\EntityFramework.SqlServer.dll
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\System.Data.SQLite.dll
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\System.Data.SQLite.EF6.dll
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\System.Data.SQLite.Linq.dll
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\System.ServiceModel.Primitives.dll
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\EntityFramework.xml
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\EntityFramework.SqlServer.xml
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\System.Data.SQLite.xml
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\System.Data.SQLite.dll.config
<<<<<<< .mine
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\Nc_Demo_Application.exe.config
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\Nc_Demo_Application.exe
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\Nc_Demo_Application.pdb
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\EntityFramework.dll
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\EntityFramework.SqlServer.dll
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\System.Data.SQLite.dll
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\System.Data.SQLite.EF6.dll
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\System.Data.SQLite.Linq.dll
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\System.ServiceModel.Primitives.dll
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\EntityFramework.xml
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\EntityFramework.SqlServer.xml
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\System.Data.SQLite.xml
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\System.Data.SQLite.dll.config
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.DemoApplicationForm.resources
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.Properties.Resources.resources
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.StartupForm.resources
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\CMS_Core_Nc_Demo_Application.csproj.GenerateResource.Cache
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\CMS_Core_Nc_Demo_Application.csproj.CoreCompileInputs.cache
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.exe
C:\Workspace\cms_core_library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.pdb
||||||| .r6
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\CMS_Core_Nc_Demo_Application.csprojResolveAssemblyReference.cache
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.Properties.Resources.resources
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\CMS_Core_Nc_Demo_Application.csproj.GenerateResource.Cache
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\CMS_Core_Nc_Demo_Application.csproj.CoreCompileInputs.cache
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.exe
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.pdb
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.DemoApplicationForm.resources
C:\Workspace\CMS_CORE_LIBRARY\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.StartupForm.resources
=======
C:\Users\carminatini\Documents\Visual Studio 2017\SVN Projects\CMS_CORE_Library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\Nc_Demo_Application.exe.config
C:\Users\carminatini\Documents\Visual Studio 2017\SVN Projects\CMS_CORE_Library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\Nc_Demo_Application.exe
C:\Users\carminatini\Documents\Visual Studio 2017\SVN Projects\CMS_CORE_Library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\bin\Debug\Nc_Demo_Application.pdb
@@ -60,3 +63,4 @@ C:\Users\carminatini\Documents\Visual Studio 2017\SVN Projects\CMS_CORE_Library\
C:\Users\carminatini\Documents\Visual Studio 2017\SVN Projects\CMS_CORE_Library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\CMS_Core_Nc_Demo_Application.csproj.CoreCompileInputs.cache
C:\Users\carminatini\Documents\Visual Studio 2017\SVN Projects\CMS_CORE_Library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.exe
C:\Users\carminatini\Documents\Visual Studio 2017\SVN Projects\CMS_CORE_Library\CMS_CORE_Nc_Demo_Application\Nc_Demo_Application\obj\Debug\Nc_Demo_Application.pdb
>>>>>>> .r9