* Refactored NC_ERRORS

+ Added client configuration api
* Refactored serverconfig
This commit is contained in:
Lucio Maranta
2018-01-11 15:56:33 +01:00
parent 904db3d09c
commit fec3d00ff9
13 changed files with 70 additions and 51 deletions
Binary file not shown.
+2 -1
View File
@@ -31,7 +31,8 @@ namespace Step.Config
.Descendants(NC_CONFIG_KEY)
.Select(x => new NcConfigModel()
{
NcVendor = Convert.ToUInt16(x.Element("ncVendor").Value),
NcVendor = x.Element("ncVendor").Value,
showNcHMI = Convert.ToBoolean(x.Element("showNcHMI").Value),
NcIpAddress = x.Element("ncIpAddress").Value,
NcPort = Convert.ToUInt16(x.Element("ncPort").Value)
}).FirstOrDefault();
+2 -1
View File
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<ncConfig>
<ncVendor>1</ncVendor>
<ncVendor>FANUC</ncVendor> <!-- NO_NC/DEMO/FANUC/SIEMENS/OSAI -->
<showNcHMI>true</showNcHMI>
<ncIpAddress>10.69.36.33</ncIpAddress>
<ncPort>8193</ncPort>
</ncConfig>
+6 -5
View File
@@ -7,6 +7,7 @@
<xs:complexType>
<xs:all>
<xs:element name="ncVendor" type="NcType" minOccurs='1' maxOccurs='1'/>
<xs:element name="showNcHMI" type="xs:boolean" minOccurs="1" maxOccurs="1"/>
<xs:element name="ncIpAddress" minOccurs='1' maxOccurs='1'/>
<xs:element name="ncPort" type="xs:int" minOccurs='1' maxOccurs='1'/>
</xs:all>
@@ -94,11 +95,11 @@
</xs:element>
<xs:simpleType name="NcType" final="restriction" >
<xs:restriction base="xs:integer">
<xs:enumeration value="0" />
<xs:enumeration value="1" />
<xs:enumeration value="2" />
<xs:enumeration value="3" />
<xs:restriction base="xs:string">
<xs:enumeration value="DEMO" />
<xs:enumeration value="OSAI" />
<xs:enumeration value="FANUC" />
<xs:enumeration value="SIEMENS" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
+6 -5
View File
@@ -6,10 +6,11 @@ using System.Threading.Tasks;
namespace Step.Model.ConfigModels
{
public class ServerConfigModel
public class NcConfigModel
{
public string Language { get; set; }
public int ServerPort { get; set; }
public bool EnableDirectoryBrowsing { get; set; }
public string NcVendor { get; set; }
public bool showNcHMI { get; set; }
public string NcIpAddress { get; set; }
public ushort NcPort { get; set; }
}
}
}
+5 -5
View File
@@ -6,10 +6,10 @@ using System.Threading.Tasks;
namespace Step.Model.ConfigModels
{
public class NcConfigModel
public class ServerConfigModel
{
public ushort NcVendor { get; set; }
public string NcIpAddress { get; set; }
public ushort NcPort { get; set; }
public string Language { get; set; }
public int ServerPort { get; set; }
public bool EnableDirectoryBrowsing { get; set; }
}
}
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Step.Model.DTOModels
{
public class DTOClientConfigurationModel
{
public string NcVendor;
public bool showHMI;
}
}
+3 -2
View File
@@ -57,9 +57,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ConfigModels\NcConfigModel.cs" />
<Compile Include="ConfigModels\AreasConfigModel.cs" />
<Compile Include="ConfigModels\ServerConfigModel.cs" />
<Compile Include="ConfigModels\AreasConfigModel.cs" />
<Compile Include="ConfigModels\NcConfigModel.cs" />
<Compile Include="DatabaseModels\FunctionAccessModel.cs" />
<Compile Include="ConfigModels\MessageModel.cs" />
<Compile Include="DatabaseModels\RoleModel.cs">
@@ -68,6 +68,7 @@
</Compile>
<Compile Include="DTOModels\DTOAlarmsModel.cs" />
<Compile Include="DTOModels\DTOAxesModel.cs" />
<Compile Include="DTOModels\DTOClientConfigurationModel.cs" />
<Compile Include="DTOModels\DTOLanguageModel.cs">
<Generator>DtsGenerator</Generator>
<LastGenOutput>DTOLanguageModel.cs.d.ts</LastGenOutput>
+1 -2
View File
@@ -37,7 +37,7 @@ namespace Step.NC
public Nc SetNumericalControl()
{
// Return new Numerical control instance choosed from the configuration
switch ((NC_VENDOR)NcConfig.NcVendor)
switch (NcConfig.NcVendor)
{
case NC_VENDOR.DEMO:
return new Nc_Demo(NcConfig.NcIpAddress, NcConfig.NcPort);
@@ -48,7 +48,6 @@ namespace Step.NC
case NC_VENDOR.OSAI:
return new Nc_Osai(NcConfig.NcIpAddress, NcConfig.NcPort, 2000);
}
return null;
}
+13 -13
View File
@@ -112,11 +112,11 @@ public static class ThreadsFunctions
{
// Try reconnection
CmsError cmsError = ncHandler.Connect();
if (cmsError.errorCode == SIEMENS_ENVIRONMENT_NOT_FOUND || cmsError.errorCode == SIEMENS_HMI_NOT_RUNNING)
if (cmsError.errorCode == CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND || cmsError.errorCode == CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING)
{
ManageLibraryError(cmsError);
}
else if ( cmsError.errorCode != OK)
else if ( cmsError.errorCode != CMS_ERROR_CODES.OK)
ncHandler.Dispose();
Thread.Sleep(1000);
@@ -149,28 +149,28 @@ public static class ThreadsFunctions
{
switch (cmsError.errorCode)
{
case NC_PROD_ERROR:
case CMS_ERROR_CODES.NC_PROD_ERROR:
TryNcConnection();
break;
case NOT_CONNECTED:
case CMS_ERROR_CODES.NOT_CONNECTED:
TryNcConnection(); // If not connected try reconnection
break;
case PROC_NOT_FOUND:
case CMS_ERROR_CODES.PROC_NOT_FOUND:
break;
case FUNCTION_NOT_ALLOWED:
case CMS_ERROR_CODES.FUNCTION_NOT_ALLOWED:
break;
case BIT_NOT_IN_RANGE:
case CMS_ERROR_CODES.BIT_NOT_IN_RANGE:
break;
case BYTE_NOT_IN_RANGE:
case CMS_ERROR_CODES.BYTE_NOT_IN_RANGE:
break;
case INTERNAL_ERROR:
case CMS_ERROR_CODES.INTERNAL_ERROR:
break;
case INCORRECT_PARAMETERS:
case CMS_ERROR_CODES.INCORRECT_PARAMETERS:
break;
case NC_LANGUAGE_ERROR:
case CMS_ERROR_CODES.NC_LANGUAGE_ERROR:
break;
case SIEMENS_ENVIRONMENT_NOT_FOUND:
case SIEMENS_HMI_NOT_RUNNING:
case CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND:
case CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING:
Manage(ERROR_LEVEL.FATAL, cmsError.message);
break;
}
+1 -12
View File
@@ -190,20 +190,9 @@ namespace Step.UI
{
DTONcGenericDataModel data = (DTONcGenericDataModel)a;
//Nc Type
String NcType = "";
if (NcConfig.NcVendor == 0)
NcType = "Demo";
else if (NcConfig.NcVendor == 1)
NcType = "Fanuc";
else if (NcConfig.NcVendor == 2)
NcType = "Siemens";
else if (NcConfig.NcVendor == 3)
NcType = "Osai";
//Other type
this.Invoke((MethodInvoker)delegate () {
TXTType.Text = NcType;
TXTType.Text = NcConfig.NcVendor;
TXTName.Text = data.Model;
TXTNcSerial.Text = data.SerialNumber;
TXTCMSMach.Text = data.MachineNumber;
+5 -5
View File
@@ -20,12 +20,12 @@ namespace Step.Utils
FATAL = 4
}
public enum NC_VENDOR
public static class NC_VENDOR
{
DEMO = 0,
FANUC = 1,
SIEMENS = 2,
OSAI = 3
public const string DEMO = "DEMO";
public const string FANUC = "FANUC";
public const string SIEMENS = "SIEMENS";
public const string OSAI = "OSAI";
}
// Token fields Keys
@@ -23,5 +23,17 @@ namespace Step.Controllers.WebApi
return Ok(startupConfiguration);
}
[Route("client"), HttpGet]
public IHttpActionResult GetInfoConfiguration()
{
DTOClientConfigurationModel clientConfiguration = new DTOClientConfigurationModel()
{
NcVendor = NcConfig.NcVendor,
showHMI = NcConfig.showNcHMI
};
return Ok(clientConfiguration);
}
}
}