This commit is contained in:
Nicola Carminati
2017-11-23 16:34:14 +00:00
parent 5da4f470a4
commit dc5a2e501a
18 changed files with 12716 additions and 148 deletions
+2 -2
View File
@@ -40,8 +40,8 @@ Global
{23131777-64A6-41E7-A6DC-D531ACBA1BE4}.Debug|x64.Build.0 = Debug|Any CPU
{23131777-64A6-41E7-A6DC-D531ACBA1BE4}.Debug|x86.ActiveCfg = Debug|Any CPU
{23131777-64A6-41E7-A6DC-D531ACBA1BE4}.Debug|x86.Build.0 = Debug|Any CPU
{23131777-64A6-41E7-A6DC-D531ACBA1BE4}.Release|x64.ActiveCfg = Release|x64
{23131777-64A6-41E7-A6DC-D531ACBA1BE4}.Release|x64.Build.0 = Release|x64
{23131777-64A6-41E7-A6DC-D531ACBA1BE4}.Release|x64.ActiveCfg = Release|Any CPU
{23131777-64A6-41E7-A6DC-D531ACBA1BE4}.Release|x64.Build.0 = Release|Any CPU
{23131777-64A6-41E7-A6DC-D531ACBA1BE4}.Release|x86.ActiveCfg = Release|Any CPU
{23131777-64A6-41E7-A6DC-D531ACBA1BE4}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
+5 -5
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/></startup>
</configuration>
@@ -8,9 +8,10 @@
<OutputType>WinExe</OutputType>
<RootNamespace>CMS_CORE_Application</RootNamespace>
<AssemblyName>CMS_CORE_Application</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -21,6 +22,7 @@
<DefineConstants>TRACE;DEBUG;FS30D</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -30,11 +32,12 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
@@ -72,9 +75,7 @@
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="SKGL, Version=2.0.5.3, Culture=neutral, PublicKeyToken=c2850a745143a030, processorArchitecture=MSIL">
<HintPath>..\packages\SKGL.2.0.5.3\lib\SKGL.dll</HintPath>
</Reference>
<Reference Include="Siemens.Sinumerik.Operate.Services, Version=4.7.4.0, Culture=neutral, PublicKeyToken=bdd90fa02fd1c4ee" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
@@ -109,10 +110,8 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -124,7 +123,9 @@
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="App.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
+157 -12
View File
@@ -28,35 +28,180 @@
/// </summary>
private void InitializeComponent()
{
this.connectDemo = new System.Windows.Forms.Button();
this.Connect = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.TXTport = new System.Windows.Forms.TextBox();
this.TXTip = new System.Windows.Forms.TextBox();
this.NcCombo = new System.Windows.Forms.ComboBox();
this.TXTPath1 = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.TXTStat1 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// connectDemo
// Connect
//
this.connectDemo.Location = new System.Drawing.Point(69, 118);
this.connectDemo.Name = "connectDemo";
this.connectDemo.Size = new System.Drawing.Size(154, 23);
this.connectDemo.TabIndex = 0;
this.connectDemo.Text = "Connect to demo";
this.connectDemo.UseVisualStyleBackColor = true;
this.connectDemo.Click += new System.EventHandler(this.connectDemo_Click);
this.Connect.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.Connect.Location = new System.Drawing.Point(3, 86);
this.Connect.Name = "Connect";
this.Connect.Size = new System.Drawing.Size(229, 23);
this.Connect.TabIndex = 0;
this.Connect.Text = "Connect";
this.Connect.UseVisualStyleBackColor = true;
this.Connect.Click += new System.EventHandler(this.connectDemo_Click);
//
// panel1
//
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.Controls.Add(this.label3);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.TXTport);
this.panel1.Controls.Add(this.TXTip);
this.panel1.Controls.Add(this.NcCombo);
this.panel1.Controls.Add(this.Connect);
this.panel1.Location = new System.Drawing.Point(12, 12);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(237, 114);
this.panel1.TabIndex = 1;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(49, 59);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(29, 13);
this.label3.TabIndex = 5;
this.label3.Text = "Port:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(34, 33);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(44, 13);
this.label2.TabIndex = 4;
this.label2.Text = "Ip Addr:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(27, 6);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(51, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Nc Type:";
//
// TXTport
//
this.TXTport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.TXTport.Location = new System.Drawing.Point(82, 56);
this.TXTport.Name = "TXTport";
this.TXTport.Size = new System.Drawing.Size(150, 20);
this.TXTport.TabIndex = 3;
this.TXTport.Text = "8080";
//
// TXTip
//
this.TXTip.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.TXTip.Location = new System.Drawing.Point(82, 30);
this.TXTip.Name = "TXTip";
this.TXTip.Size = new System.Drawing.Size(150, 20);
this.TXTip.TabIndex = 2;
this.TXTip.Text = "192.168.157.2";
//
// NcCombo
//
this.NcCombo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.NcCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.NcCombo.FormattingEnabled = true;
this.NcCombo.Items.AddRange(new object[] {
"Demo",
"Fanuc",
"Siemens",
"Osai"});
this.NcCombo.Location = new System.Drawing.Point(82, 3);
this.NcCombo.Name = "NcCombo";
this.NcCombo.Size = new System.Drawing.Size(150, 21);
this.NcCombo.TabIndex = 2;
this.NcCombo.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// TXTPath1
//
this.TXTPath1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.TXTPath1.Location = new System.Drawing.Point(100, 132);
this.TXTPath1.Name = "TXTPath1";
this.TXTPath1.ReadOnly = true;
this.TXTPath1.Size = new System.Drawing.Size(150, 20);
this.TXTPath1.TabIndex = 4;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(57, 135);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(37, 13);
this.label4.TabIndex = 6;
this.label4.Text = "Mode:";
//
// TXTStat1
//
this.TXTStat1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.TXTStat1.Location = new System.Drawing.Point(100, 158);
this.TXTStat1.Name = "TXTStat1";
this.TXTStat1.ReadOnly = true;
this.TXTStat1.Size = new System.Drawing.Size(150, 20);
this.TXTStat1.TabIndex = 7;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(54, 161);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(40, 13);
this.label5.TabIndex = 8;
this.label5.Text = "Status:";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.connectDemo);
this.ClientSize = new System.Drawing.Size(262, 326);
this.Controls.Add(this.label5);
this.Controls.Add(this.TXTStat1);
this.Controls.Add(this.label4);
this.Controls.Add(this.TXTPath1);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button connectDemo;
private System.Windows.Forms.Button Connect;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox TXTport;
private System.Windows.Forms.TextBox TXTip;
private System.Windows.Forms.ComboBox NcCombo;
private System.Windows.Forms.TextBox TXTPath1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox TXTStat1;
private System.Windows.Forms.Label label5;
}
}
+88 -50
View File
@@ -1,91 +1,129 @@
using CMS_CORE;
using CMS_CORE.Exceptions;
using CMS_CORE.Osai;
using CMS_CORE.Demo;
using CMS_CORE.Exceptions;
using CMS_CORE.Fanuc;
using CMS_CORE.Osai;
using CMS_CORE.Siemens;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.ServiceModel;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace CMS_CORE_Application
{
public partial class Form1 : Form
{
static Nc N;
static String NCType;
static String NCIp;
static ushort NCPort;
Thread t;
public Form1()
{
InitializeComponent();
SKGL.SerialKeyConfiguration conf = new SKGL.SerialKeyConfiguration();
conf.Features[0] = true;
SKGL.Generate gg = new SKGL.Generate(conf);
gg.secretPhase = "test";
string ss = gg.doKey(999);
SKGL.Validate vv = new SKGL.Validate(conf);
vv.secretPhase = "test";
vv.Key = ss;
Boolean tt= vv.IsValid;
Nc N = new Nc_Osai("192.168.157.2", 8080, 5);
try
{
N.NC_Connect();
byte byteValue = 0;
N.MEM_RWByte(false, 1, Nc.MEMORY_Type.Osai_MW, 0, 0, ref byteValue);
}
catch(Nc_Exception e)
{
MessageBox.Show(e.Message);
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void connectDemo_Click(object sender, EventArgs e)
{
t = new Thread(new ThreadStart(test));
if (NcCombo.SelectedItem == null)
return;
NCType = NcCombo.SelectedItem.ToString().Trim();
NCIp = TXTip.Text.Trim();
NCPort = ushort.Parse(TXTport.Text.Trim());
if(NCType != "")
t.Start();
}
private void test()
{
Nc.PROC_Mode mode = Nc.PROC_Mode.AUTO;
Nc.PROC_Status status = Nc.PROC_Status.ERROR;
try
{
if (NCType == "Siemens")
N = new Nc_Siemens(300);
if (NCType == "Demo")
N = new Nc_Demo(NCIp, NCPort);
if (NCType == "Osai")
N = new Nc_Osai(NCIp, NCPort,1000);
if (NCType == "Fanuc")
N = new Nc_Fanuc(NCIp, NCPort, 1000);
Nc_Demo nc_Demo = new Nc_Demo("localhost", 8080);
nc_Demo.NC_Connect();
N.NC_Connect();
while (true)
{
DateTime testDateTime = new DateTime();
nc_Demo.NC_RDateTime(ref testDateTime);
N.PROC_RMode(1,ref mode);
N.PROC_RStatus(1, ref status);
if (!this.IsDisposed && this.InvokeRequired)
{
this.Invoke((ThreadStart)delegate ()
{
TXTPath1.Text = mode.ToString();
TXTStat1.Text = status.ToString();
panel1.Enabled = false;
});
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", "test1.txt", true);
nc_Demo.FILES_DeleteProgram("", "test1.txt");
}
Thread.Sleep(200);
}
}
catch (Nc_Exception ex)
{
MessageBox.Show(ex.Message);
if (!this.IsDisposed && this.InvokeRequired)
{
this.Invoke((ThreadStart)delegate ()
{
panel1.Enabled = true;
});
}
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (NcCombo.SelectedItem.ToString().Equals("Siemens"))
{
TXTip.Enabled = false;
TXTport.Enabled = false;
}
else
{
TXTip.Enabled = true;
TXTport.Enabled = true;
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if(t != null)
t.Abort();
}
}
}
-1
View File
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CMS_CORE_Application
+25 -33
View File
@@ -1,69 +1,61 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Codice generato da uno strumento.
// Il codice è stato generato da uno strumento.
// Versione runtime:4.0.30319.42000
//
// Le modifiche apportate a questo file possono causare un comportamento non corretto e andranno perse se
// Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se
// il codice viene rigenerato.
// </auto-generated>
//------------------------------------------------------------------------------
namespace CMS_CORE_Application.Properties
{
namespace CMS_CORE_Application.Properties {
using System;
/// <summary>
/// Classe di risorse fortemente tipizzata per la ricerca di stringhe localizzate e così via.
/// </summary>
// Questa classe è stata generata automaticamente dalla classe StronglyTypedResourceBuilder
// Questa classe è stata generata automaticamente dalla classe StronglyTypedResourceBuilder.
// tramite uno strumento quale ResGen o Visual Studio.
// Per aggiungere o rimuovere un membro, modificare il file .ResX, quindi eseguire di nuovo ResGen
// Per aggiungere o rimuovere un membro, modificare il file con estensione ResX ed eseguire nuovamente ResGen
// con l'opzione /str oppure ricompilare il progetto VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
internal Resources() {
}
/// <summary>
/// Restituisce l'istanza di ResourceManager memorizzata nella cache e usata da questa classe.
/// Restituisce l'istanza di ResourceManager nella cache utilizzata da questa classe.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CMS_CORE_Application.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Esegue l'override della proprietà CurrentUICulture del thread corrente per tutte
/// le ricerche di risorse che utilizzano questa classe di risorse fortemente tipizzata.
/// Esegue l'override della proprietà CurrentUICulture del thread corrente per tutte le
/// ricerche di risorse eseguite utilizzando questa classe di risorse fortemente tipizzata.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set
{
set {
resourceCulture = value;
}
}
+13 -17
View File
@@ -1,28 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// Il codice è stato generato da uno strumento.
// Versione runtime:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se
// il codice viene rigenerato.
// </auto-generated>
//------------------------------------------------------------------------------
namespace CMS_CORE_Application.Properties
{
namespace CMS_CORE_Application.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
public static Settings Default {
get {
return defaultInstance;
}
}
+20 -11
View File
@@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CMS_CORE_Library</RootNamespace>
<AssemblyName>CMS_CORE_Library</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -43,7 +44,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;FS30D</DefineConstants>
<DefineConstants>TRACE;DEBUG;FS30D,WIN32</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
@@ -51,7 +52,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;FS30D</DefineConstants>
<DefineConstants>TRACE;FS30D,WIN32</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
@@ -61,7 +62,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug2|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug2\</OutputPath>
<DefineConstants>TRACE;DEBUG;FS30D</DefineConstants>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile>bin\Debug2\CMS_CORE_Library.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
@@ -71,7 +72,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG;FS30D,WIN64</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
@@ -79,7 +80,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;FS30D</DefineConstants>
<DefineConstants>TRACE;FS30D,WIN64</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
@@ -104,6 +105,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Siemens\MotionControl\siemens\sinumerik\hmi\base\Siemens.Sinumerik.Operate.Services.dll</HintPath>
</Reference>
<Reference Include="Siemens.Sinumerik.Operate.Services.Wrapper, Version=4.7.4.0, Culture=neutral, PublicKeyToken=bdd90fa02fd1c4ee, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Siemens\MotionControl\siemens\sinumerik\hmi\base\Siemens.Sinumerik.Operate.Services.Wrapper.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
@@ -131,21 +136,19 @@
<Compile Include="Demo\Models\NcProcessModel.cs" />
<Compile Include="Demo\Nc_Demo.cs" />
<Compile Include="Exceptions\Nc_Exception.cs" />
<Compile Include="Fanuc\fwlib32.cs" />
<Compile Include="Fanuc\fwlib32_64.cs" />
<Compile Include="Fanuc\Nc_Fanuc.cs" />
<Compile Include="Nc.cs" />
<Compile Include="Osai\Nc_Osai.cs" />
<Compile Include="Osai\OSAIErrMgr.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Siemens\Nc_Siemens.cs" />
<Compile Include="Utils\Nc_Utils.cs" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<ItemGroup>
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="Connected Services\OPENControl\CMS_CORE_Library.OPENControl.AxesRefResponse.datasource">
<DependentUpon>Reference.svcmap</DependentUpon>
</None>
@@ -863,13 +866,19 @@
<Content Include="fwlib30i.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="fwlib30i64.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Fwlib32.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Fwlib64.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="fwlibe1.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Siemens.Sinumerik.Operate.Services.Wrapper.dll">
<Content Include="fwlibe64.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
File diff suppressed because it is too large Load Diff
Binary file not shown.
+16 -5
View File
@@ -856,7 +856,13 @@ namespace CMS_CORE
/** <summary>Osai SC Area</summary> */
Osai_SC = 50,
/** <summary>Osai SYMO Area</summary> */
Osai_SYMO = 102
Osai_SYMO = 102,
///////////////////////////////////////////////////////////////////
//Siemens Memory Type,
/** <summary>Siemens DB</summary> */
Siemens_DB = 0
};
// NC Memory Type Name
@@ -897,21 +903,24 @@ namespace CMS_CORE
{
public readonly MEMORY_Type MemType;
public readonly int Address;
public readonly int SubAddress; //Only for Siemens
public MEMORY_Cell(MEMORY_Type MType, int Addr)
public MEMORY_Cell(MEMORY_Type MType, int Addr, int SubAddr)
{
MemType = MType;
Address = Addr;
SubAddress = SubAddr;
}
}
//Lingua CN
internal MEMORY_Cell PARAM_LING_FANUC = new MEMORY_Cell(MEMORY_Type.Null, 3281);
internal MEMORY_Cell PARAM_LING_FANUC = new MEMORY_Cell(MEMORY_Type.Null, 3281, 0);
//Matricola Macchina
internal MEMORY_Cell MATR_MACCH_OSAI = new MEMORY_Cell(MEMORY_Type.Osai_MW , 3403 );
internal MEMORY_Cell MATR_MACCH_FANUC = new MEMORY_Cell(MEMORY_Type.Fanuc_D , 4018 );
internal MEMORY_Cell MATR_MACCH_OSAI = new MEMORY_Cell(MEMORY_Type.Osai_MW , 3403, 0);
internal MEMORY_Cell MATR_MACCH_FANUC = new MEMORY_Cell(MEMORY_Type.Fanuc_D , 4018, 0);
internal MEMORY_Cell MATR_MACCH_SIEMENS = new MEMORY_Cell(MEMORY_Type.Siemens_DB, 255 , 0);
#endregion
@@ -927,6 +936,8 @@ namespace CMS_CORE
internal const uint BYTE_NOT_IN_RANGE_ERROR = 5;
internal const uint INTERNAL_ERROR = 6;
internal const uint INCORRECT_PARAMETERS_ERROR = 7;
internal const uint SIEMENS_ENVIRONMENT_NOT_FOUND = 8;
internal const uint SIEMENS_HMI_NOT_RUNNING = 9;
#endregion
+626
View File
@@ -0,0 +1,626 @@
using CMS_CORE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using System.IO;
using Siemens.Sinumerik.Operate.Services;
using CMS_CORE.Exceptions;
using System.Diagnostics;
namespace CMS_CORE.Siemens
{
public class Nc_Siemens : Nc
{
// Global Constants
const string OptionHMINotRunning = "P66";
const string NcNotFound = "Missing response";
const string NcNotFound2 = "networking error";
const string NcNotFound3 = "Nc not Connected";
const string SinumerikEnvPath = @"MotionControl\siemens\sinumerik";
// Siemens Path Constants
const string PathMaxChannelNo = "/Nck/Configuration/maxnumChannels";
const string PathConfChannelNo = "/Nck/Configuration/numChannels";
const string PathNcType = "/Nck/Configuration/nckType";
const string PathNcVersion = "/Nck/Configuration/nckVersion";
const string PathLanguage = "/Nck/Configuration/anLanguageOnHmi";
const string PathSerialNumber = "/Nck/State/hwProductSerialNrL";
const string PathNcTime = "/Nck/State/sysTimeBCD";
const string PathGenericNcMode = "/Bag/State/opMode";
const string PathGenericNcState = "/Channel/State/chanStatus";
const string PathIncrJog = "/Channel/GeometricAxis/actIncrVal";
// Global Variables
private DateTime Last_Static_Read;
private ushort TimeoutConn;
private String Cnc_name;
private String Cnc_SftVersion;
private String Cnc_SeriesNum;
private String Cms_MachNumber;
private uint ConfChannelNo;
private uint MaxChannelNo;
private uint SiemensLanguage;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region Contructor & global methods
/**
* <summary>
* Instantiate The NC-Siemens Class
* </summary>
* <param name="ConnectionTimeOut">Send/Recieve timeout connection</param>
* <exception cref="Exceptions.Nc_Exception">Thrown when an internal or a library error occours</exception>
* */
public Nc_Siemens(ushort ConnectionTimeOut)
{
//Set Connected to FALSE and close the session
Connected = false;
//Setup timeout
TimeoutConn = ConnectionTimeOut;
//Check if Siemens Environment is started
CheckSiemensEnv();
}
//Connect Method
public override void NC_Connect()
{
//Try to get information
try
{
//Set Connected to FALSE and close the session
Connected = true;
//Read static Data
ReadStaticNCData();
}
catch (Exception ex)
{
ThrowNCException(ex);
}
}
//Disconnect Method
public override void NC_Disconnect()
{
//Set Connected to FALSE and close the session
Connected = false;
}
#endregion
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region High level methods
//Get the processes-count configurated
public override void NC_RProcessesNum(ref ushort ProcNumber)
{
ReadStaticNCData();
ProcNumber = (ushort)ConfChannelNo;
}
//Get the NC model Name
public override void NC_RModelName(ref string ModelName)
{
ReadStaticNCData();
ModelName = Cnc_name;
}
//Get the NC Software Version
public override void NC_RSoftwareVersion(ref string SWV)
{
ReadStaticNCData();
SWV = Cnc_SftVersion;
}
//Get the NC Language
public override void NC_RLanguage(ref CultureInfo Language)
{
ReadStaticNCData();
Language = ConvertToSTEPLanguage(SiemensLanguage);
}
//Get the NC Serial number
public override void NC_RSerialNumber(ref string SN)
{
ReadStaticNCData();
SN = Cnc_SeriesNum;
}
//Get CMS Machine number
public override void NC_RMachineNumber(ref string MachNumber)
{
ReadStaticNCData();
MachNumber = Cms_MachNumber;
}
//Get the Date-Time of the NC
public override void NC_RDateTime(ref DateTime ActualTime)
{
//Check if the NC is Connected
CheckConnection();
//Setup variables
DataSvc Data = new DataSvc();
Item ReadItem = new Item(PathNcTime);
//Try to get information
try
{
//Read Data
Data.Read(ReadItem);
//Save Data
ActualTime = (DateTime) ReadItem.Value;
}
catch (Exception ex)
{
ThrowNCException(ex);
}
}
//Get the process Mode
public override void PROC_RMode(ushort ProcNumber, ref PROC_Mode Mode)
{
//Check if the NC is Connected
CheckConnection();
//Setup variables
DataSvc Data = new DataSvc();
Item ReadItem = new Item(PathGenericNcMode + "[u"+ ProcNumber + "]");
Item ReadItemIncr = new Item(PathIncrJog + "[u" + ProcNumber + "]");
//Try to get information
try
{
//Read Data
Data.Read(ReadItem);
Data.Read(ReadItemIncr);
//Save Data
Mode = ConvertToSTEPMode((uint)ReadItem.Value, (uint)ReadItemIncr.Value);
}
catch (Exception ex)
{
ThrowNCException(ex);
}
}
//Get the process status
public override void PROC_RStatus(ushort ProcNumber, ref PROC_Status Status)
{
//Check if the NC is Connected
CheckConnection();
//Setup variables
DataSvc Data = new DataSvc();
Item ReadItem = new Item(PathGenericNcState + "[u" + ProcNumber + "]");
//Try to get information
try
{
//Read Data
Data.Read(ReadItem);
//Save Data
Status = ConvertToSTEPStatus((uint)ReadItem.Value);
}
catch (Exception ex)
{
ThrowNCException(ex);
}
}
#endregion
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region Subordinate Private Functions
//Manage the Mode
private PROC_Mode ConvertToSTEPMode(uint mode, uint JogMode)
{
switch (mode)
{
case 0: return (JogMode < 6) ? PROC_Mode.JOGINC : PROC_Mode.JOG;
case 1: return PROC_Mode.MDI;
case 2: return PROC_Mode.AUTO;
}
return PROC_Mode.ERROR;
}
//Manage the Status
private PROC_Status ConvertToSTEPStatus(uint status)
{
switch (status)
{
case 0: return PROC_Status.IDLE;
case 1: return PROC_Status.RUN;
case 2: return PROC_Status.HOLD;
}
return PROC_Status.ERROR;
}
//Check if Memory Area is corrected
private String ConvertMemToPath(MEMORY_Type MemoryType,int Address, int SubAddress, char MemAccess)
{
char[] allowedAccess = { 'X', 'B', 'W', 'D'};
if (!MemoryType.ToString().StartsWith(SIEMENS_MEMTYPE) || !allowedAccess.Contains(MemAccess))
throw new Nc_Exception("Incorrect Parameters error");
else
{
return "DB" + Address + ".DB" + MemAccess + SubAddress;
}
}
//Check if NC is connected
private void CheckConnection()
{
if (!NC_IsConnected())
throw new Nc_Exception("CMS-Core-Error: Nc not Connected");
}
//Check if Siemens Environment is started
private void CheckSiemensEnv()
{
if (!Environment.GetEnvironmentVariable("PATH").Contains(SinumerikEnvPath))
throw new Nc_Exception("CMS-Core-Error: Siemens Environment not found");
}
//Manage the Exception Launch
private void ThrowNCException(Exception ex)
{
//Catch the Siemens exceptions
if (ex is OperateMissingOptionException && ex.Message.Contains(OptionHMINotRunning) )
{
Connected = false;
throw new Nc_Exception("CMS-Core-Error: Siemens HMI is not Running / Ready");
}
else if (ex.Message.Contains(NcNotFound) || ex.Message.Contains(NcNotFound2) || ex.Message.Contains(NcNotFound3))
{
Connected = false;
throw new Nc_Exception("CMS-Core-Error: Nc not Connected");
}
else
throw new Nc_Exception("Siemens-Core-Error: " + ex.Message);
}
//Read Static Data
private void ReadStaticNCData()
{
//Check if the NC is Connected
CheckConnection();
//Read oly one time every X seconds
if (DateTime.Now - Last_Static_Read > new TimeSpan(NC_MIN_SEC_READ_STATIC_DATA * TimeSpan.TicksPerSecond))
{
DataSvc ReadStaticData = new DataSvc();
Item ItemNcType = new Item(PathNcType);
Item ItemNcVersion = new Item(PathNcVersion);
Item ItemMaxChannelNo = new Item(PathMaxChannelNo);
Item ItemConfChannelNo = new Item(PathConfChannelNo);
Item ItemLanguage = new Item(PathLanguage);
Item ItemSerialNumber = new Item(PathSerialNumber);
Item ItemMachineNumber = new Item(ConvertMemToPath(MATR_MACCH_SIEMENS.MemType, MATR_MACCH_SIEMENS.Address, MATR_MACCH_SIEMENS.SubAddress,'W'));
//Try to get information
try
{
//Read All Data
ReadStaticData.Read(ItemNcType);
ReadStaticData.Read(ItemNcVersion);
ReadStaticData.Read(ItemMaxChannelNo);
ReadStaticData.Read(ItemConfChannelNo);
ReadStaticData.Read(ItemLanguage);
ReadStaticData.Read(ItemSerialNumber);
ReadStaticData.Read(ItemMachineNumber);
//Setup variables
Cnc_name = getName((uint)ItemNcType.Value);
Cnc_SftVersion = ((double)ItemNcVersion.Value).ToString();
Cnc_SeriesNum = (String)ItemSerialNumber.Value;
MaxChannelNo = (uint)ItemMaxChannelNo.Value;
ConfChannelNo = (uint)ItemConfChannelNo.Value;
SiemensLanguage = (uint)ItemLanguage.Value;
Cms_MachNumber = ((uint)ItemMachineNumber.Value).ToString();
//Save NOW
Last_Static_Read = DateTime.Now;
}
catch (Exception ex)
{
ThrowNCException(ex);
}
}
}
// Convert the internal Name var in Readable STEP Name
private String getName(uint value)
{
String name = "Siemens ";
switch (value)
{
case 0: name += "840D pl"; break;
case 1000: name += "FM-NC" ; break;
case 2000: name += "810D pl" ; break;
case 3000: name += "802S" ; break;
case 4000: name += "802D pl"; break;
case 5000: name += "840Di pl"; break;
case 6000: name += "SOLUTIONLINE"; break;
case 10700: name += "840D sl"; break;
case 14000: name += "802D sl T/M - N/G - C/U" ; break;
case 15000: name += "840Di sl" ; break;
}
return name;
}
//Convert to Step Language
private CultureInfo ConvertToSTEPLanguage(uint language)
{
switch (language)
{
case 1: return new CultureInfo("de");
case 2: return new CultureInfo("fr");
case 3: return new CultureInfo("en");
case 4: return new CultureInfo("es");
case 6: return new CultureInfo("it");
case 7: return new CultureInfo("nl");
case 8: return new CultureInfo("zh-CHS");
case 9: return new CultureInfo("sv");
case 18: return new CultureInfo("hu");
case 19: return new CultureInfo("fi");
case 26: return new CultureInfo("el");
case 28: return new CultureInfo("cs");
case 50: return new CultureInfo("pt-BR");
case 53: return new CultureInfo("pl");
case 55: return new CultureInfo("da");
case 57: return new CultureInfo("ru");
case 65: return new CultureInfo("hr-HR");
case 68: return new CultureInfo("sk");
case 69: return new CultureInfo("sl");
case 72: return new CultureInfo("ro");
case 75: return new CultureInfo("bg");
case 80: return new CultureInfo("zh-CHT");
case 85: return new CultureInfo("ko");
case 87: return new CultureInfo("ja");
case 89: return new CultureInfo("tr");
case 122: return new CultureInfo("id");
case 212: return new CultureInfo("th");
case 213: return new CultureInfo("vi");
case 230: return new CultureInfo("ms");
default: return new CultureInfo("en");
}
}
#endregion
public override void AXES_RDistanceToGo(ushort ProcNumber, ref Dictionary<string, double> Axes)
{
throw new NotImplementedException();
}
public override void AXES_RFollowingError(ushort ProcNumber, ref Dictionary<string, double> Axes)
{
throw new NotImplementedException();
}
public override void AXES_RInterpPosition(ushort ProcNumber, ref Dictionary<string, double> Axes)
{
throw new NotImplementedException();
}
public override void AXES_RMachinePosition(ushort ProcNumber, ref Dictionary<string, double> Axes)
{
throw new NotImplementedException();
}
public override void AXES_RProgrPosition(ushort ProcNumber, ref Dictionary<string, double> Axes)
{
throw new NotImplementedException();
}
public override void FILES_CopyProgram(string partProgramPath, string newPartProgramPath, bool failIfExist)
{
throw new NotImplementedException();
}
public override void FILES_DeleteProgram(string partProgramPath, string partProgramName)
{
throw new NotImplementedException();
}
public override void FILES_RProgramToFile(string partProgramPath, FileStream localFile)
{
throw new NotImplementedException();
}
public override void FILES_WProgramFromFile(string partProgramPath, FileStream localFile)
{
throw new NotImplementedException();
}
public override void MEM_RWBoolean(bool bWrite, int Process, MEMORY_Type MemType, int MemIndex, int MemBit, ref bool Value)
{
throw new NotImplementedException();
}
public override void MEM_RWByte(bool bWrite, int Process, MEMORY_Type MemType, int MemIndex, int MemByte, ref byte Value)
{
throw new NotImplementedException();
}
public override void MEM_RWByteList(bool bWrite, int Process, MEMORY_Type MemType, int MemIndex, int MemByteStart, int Number, ref List<byte> Value)
{
throw new NotImplementedException();
}
public override void MEM_RWDWord(bool bWrite, int Process, MEMORY_Type MemType, int MemIndex, ref uint Value)
{
throw new NotImplementedException();
}
public override void MEM_RWDWordList(bool bWrite, int Process, MEMORY_Type MemType, int MemIndex, int Number, ref List<uint> Value)
{
throw new NotImplementedException();
}
public override void MEM_RWInteger(bool bWrite, int Process, MEMORY_Type MemType, int MemIndex, ref int Value)
{
throw new NotImplementedException();
}
public override void MEM_RWIntegerList(bool bWrite, int Process, MEMORY_Type MemType, int MemIndex, int Number, ref List<int> Value)
{
throw new NotImplementedException();
}
public override void MEM_RWShort(bool bWrite, int Process, MEMORY_Type MemType, int MemIndex, ref short Value)
{
throw new NotImplementedException();
}
public override void MEM_RWShortList(bool bWrite, int Process, MEMORY_Type MemType, int MemIndex, int Number, ref List<short> Value)
{
throw new NotImplementedException();
}
public override void MEM_RWWord(bool bWrite, int Process, MEMORY_Type MemType, int MemIndex, ref ushort Value)
{
throw new NotImplementedException();
}
public override void MEM_RWWordList(bool bWrite, int Process, MEMORY_Type MemType, int MemIndex, int Number, ref List<ushort> Value)
{
throw new NotImplementedException();
}
public override void NC_RParam(short Index, short Bit, ref bool Value)
{
throw new NotImplementedException();
}
public override void NC_RParam(short Index, ref byte Value)
{
throw new NotImplementedException();
}
public override void NC_RParam(short Index, ref short Value)
{
throw new NotImplementedException();
}
public override void NC_RParam(short Index, ref int Value)
{
throw new NotImplementedException();
}
public override void NC_RParam(short Index, ref double Value)
{
throw new NotImplementedException();
}
public override void PLC_RActiveAlarms(ref List<string> Alarms)
{
throw new NotImplementedException();
}
public override void PROC_RActiveAlarms(ushort ProcNumber, ref List<string> Alarms)
{
throw new NotImplementedException();
}
}
}
Binary file not shown.
Binary file not shown.
@@ -193,8 +193,7 @@ namespace Nc_Demo_Application.Database
id = Convert.ToInt32(row["id"]),
name = row["name"].ToString(),
status = Convert.ToInt32(row["status"]),
mode = Convert.ToInt32(row["mode"]),
enabled = Convert.ToInt32(row["enabled"])
mode = Convert.ToInt32(row["mode"])
};
// Add tmp to return list
processes.Add(tmpProcess);
@@ -12,6 +12,5 @@ namespace Nc_Demo_Application.Database.Models
public string name { get; set; }
public int status;
public int mode;
public int enabled;
}
}