Added cooling translation

This commit is contained in:
Lucio Maranta
2018-08-20 17:26:01 +02:00
parent c9ab2062bb
commit 8856ff1390
7 changed files with 574 additions and 384 deletions
+2 -2
View File
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<serverConfig>
<ncConfig>
<ncVendor>DEMO</ncVendor> <!-- NO_NC/DEMO/FANUC/SIEMENS/OSAI -->
<ncVendor>OSAI</ncVendor> <!-- NO_NC/DEMO/FANUC/SIEMENS/OSAI -->
<showNcHMI>true</showNcHMI>
<ncIpAddress>localhost</ncIpAddress>
<ncIpAddress>192.168.157.2</ncIpAddress>
<ncPort>8080</ncPort>
<machineModel>Ares 37 OF</machineModel>
</ncConfig>
+51 -15
View File
@@ -1,16 +1,52 @@
<?xml version="1.0" encoding="utf-8" ?>
<toolManagerConfig>
<familyOpt>true</familyOpt>
<shankOpt>true</shankOpt>
<magPositionOpt>true</magPositionOpt>
<offsetOpt>true</offsetOpt>
<reviveOpt>true</reviveOpt>
<gammaOpt>true</gammaOpt>
<lifeOpt>true</lifeOpt>
<tcpOpt>true</tcpOpt>
<coolingOpt>true</coolingOpt>
<multidimensionalShankOpt>true</multidimensionalShankOpt>
<selfAdaptivePathOpt>true</selfAdaptivePathOpt>
<dynamicCompensationOpt>true</dynamicCompensationOpt>
<ballufOpt>true</ballufOpt>
</toolManagerConfig>
<root>
<toolManagerConfig>
<familyOpt>true</familyOpt>
<shankOpt>true</shankOpt>
<magPositionOpt>true</magPositionOpt>
<offsetOpt>true</offsetOpt>
<reviveOpt>true</reviveOpt>
<gammaOpt>true</gammaOpt>
<lifeOpt>true</lifeOpt>
<tcpOpt>true</tcpOpt>
<coolingOpt>true</coolingOpt>
<multidimensionalShankOpt>true</multidimensionalShankOpt>
<selfAdaptivePathOpt>true</selfAdaptivePathOpt>
<dynamicCompensationOpt>true</dynamicCompensationOpt>
<ballufOpt>true</ballufOpt>
</toolManagerConfig>
<coolingLocalizedNames>
<cooling>
<lang langKey="en">Test</lang>
<lang langKey="it">Ita</lang>
</cooling>
<cooling1>
<lang langKey="en">Test</lang>
<lang langKey="it">Ita</lang>
</cooling1>
<cooling2>
<lang langKey="en">Test</lang>
<lang langKey="it">Ita</lang>
</cooling2>
<cooling3>
<lang langKey="en">Test</lang>
<lang langKey="it">Ita</lang>
</cooling3>
<cooling4>
<lang langKey="en">Test</lang>
<lang langKey="it">Ita</lang>
</cooling4>
<cooling5>
<lang langKey="en">Test</lang>
<lang langKey="it">Ita</lang>
</cooling5>
<cooling6>
<lang langKey="en">Test</lang>
<lang langKey="it">Ita</lang>
</cooling6>
<cooling7>
<lang langKey="en">Test</lang>
<lang langKey="it">Ita</lang>
</cooling7>
</coolingLocalizedNames>
</root>
+112 -16
View File
@@ -1,22 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="toolManagerConfig">
<xs:complexType>
<xs:element name="root">
<xs:complexType>
<xs:all>
<xs:element name="toolManagerConfig">
<xs:complexType>
<xs:all>
<xs:element name="familyOpt" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
<xs:element name="shankOpt" type="xs:boolean" minOccurs="1" maxOccurs="1"/>
<xs:element name="magPositionOpt" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
<xs:element name="offsetOpt" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
<xs:element name="reviveOpt" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
<xs:element name="gammaOpt" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
<xs:element name="lifeOpt" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
<xs:element name="tcpOpt" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
<xs:element name="coolingOpt" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
<xs:element name="multidimensionalShankOpt" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
<xs:element name="selfAdaptivePathOpt" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
<xs:element name="dynamicCompensationOpt" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
<xs:element name="ballufOpt" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
<xs:element name="familyOpt" type="xs:boolean" minOccurs='1' maxOccurs='1' />
<xs:element name="shankOpt" type="xs:boolean" minOccurs="1" maxOccurs="1" />
<xs:element name="magPositionOpt" type="xs:boolean" minOccurs='1' maxOccurs='1' />
<xs:element name="offsetOpt" type="xs:boolean" minOccurs='1' maxOccurs='1' />
<xs:element name="reviveOpt" type="xs:boolean" minOccurs='1' maxOccurs='1' />
<xs:element name="gammaOpt" type="xs:boolean" minOccurs='1' maxOccurs='1' />
<xs:element name="lifeOpt" type="xs:boolean" minOccurs='1' maxOccurs='1' />
<xs:element name="tcpOpt" type="xs:boolean" minOccurs='1' maxOccurs='1' />
<xs:element name="coolingOpt" type="xs:boolean" minOccurs='1' maxOccurs='1' />
<xs:element name="multidimensionalShankOpt" type="xs:boolean" minOccurs='1' maxOccurs='1' />
<xs:element name="selfAdaptivePathOpt" type="xs:boolean" minOccurs='1' maxOccurs='1' />
<xs:element name="dynamicCompensationOpt" type="xs:boolean" minOccurs='1' maxOccurs='1' />
<xs:element name="ballufOpt" type="xs:boolean" minOccurs='1' maxOccurs='1' />
</xs:all>
</xs:complexType>
</xs:element>
</xs:element>
<xs:element name="coolingLocalizedNames">
<xs:complexType>
<xs:all>
<xs:element name="cooling">
<xs:complexType>
<xs:sequence>
<xs:element name="lang" type="langType" minOccurs="0" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="cooling1">
<xs:complexType>
<xs:sequence>
<xs:element name="lang" type="langType" minOccurs="0" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="cooling2">
<xs:complexType>
<xs:sequence>
<xs:element name="lang" type="langType" minOccurs="0" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="cooling3">
<xs:complexType>
<xs:sequence>
<xs:element name="lang" type="langType" minOccurs="0" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="cooling4">
<xs:complexType>
<xs:sequence>
<xs:element name="lang" type="langType" minOccurs="0" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="cooling5">
<xs:complexType>
<xs:sequence>
<xs:element name="lang" type="langType" minOccurs="0" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="cooling6">
<xs:complexType>
<xs:sequence>
<xs:element name="lang" type="langType" minOccurs="0" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="cooling7">
<xs:complexType>
<xs:sequence>
<xs:element name="lang" type="langType" minOccurs="0" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<!-- Language Type -->
<xs:complexType name="langType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="langKey" use="required" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
+373 -338
View File
@@ -1,53 +1,53 @@
using Step.Model.ConfigModels;
using Step.Utils;
using System;
using System.Globalization;
using Step.Model.ConfigModels;
using Step.Utils;
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq;
using System.Reflection;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;
using static Step.Config.ServerConfig;
using static Step.Model.Constants;
using static Step.Utils.SupportFunctions;
namespace Step.Config
{
public static class ServerConfigController
{
public static void ReadStartupConfig()
{
try
{
ReadServerConfig();
ReadAreaConfig();
ReadMaintenancesConfig();
ReadNcSoftKeys();
ReadUserSoftKeysConfig();
ReadAlarmsConfig();
ReadHeadsConfig();
ReadToolManagerConfig();
}
catch (System.Xml.XmlException ex)
{
ExceptionManager.Manage(ERROR_LEVEL.FATAL,
"Error while reading file: " + ex.SourceUri +
"\n Error: " + ex.Message
);
}
catch (Exception ex)
{
ExceptionManager.Manage(ERROR_LEVEL.FATAL, ex.Message);
}
}
private static XDocument GetXmlHandlerWithValidator(string configSchemaFilePath, string configFilePath)
{
// Create new instance
XmlSchemaSet readerSettings = new XmlSchemaSet();
// Add Schema from Assembly
using System.Xml.Linq;
using System.Xml.Schema;
using static Step.Config.ServerConfig;
using static Step.Model.Constants;
using static Step.Utils.SupportFunctions;
namespace Step.Config
{
public static class ServerConfigController
{
public static void ReadStartupConfig()
{
try
{
ReadServerConfig();
ReadAreaConfig();
ReadMaintenancesConfig();
ReadNcSoftKeys();
ReadUserSoftKeysConfig();
ReadAlarmsConfig();
ReadHeadsConfig();
ReadToolManagerConfig();
}
catch (System.Xml.XmlException ex)
{
ExceptionManager.Manage(ERROR_LEVEL.FATAL,
"Error while reading file: " + ex.SourceUri +
"\n Error: " + ex.Message
);
}
catch (Exception ex)
{
ExceptionManager.Manage(ERROR_LEVEL.FATAL, ex.Message);
}
}
private static XDocument GetXmlHandlerWithValidator(string configSchemaFilePath, string configFilePath)
{
// Create new instance
XmlSchemaSet readerSettings = new XmlSchemaSet();
// Add Schema from Assembly
Assembly myAssembly = Assembly.GetExecutingAssembly();
using (Stream schemaStream = myAssembly.GetManifestResourceStream(configSchemaFilePath))
{
@@ -55,299 +55,334 @@ namespace Step.Config
{
readerSettings.Add(null, schemaReader);
}
}
// Open file reader
XDocument xmlConfigFile = XDocument.Load(BASE_PATH + "\\" + configFilePath);
// Validate file
xmlConfigFile.Validate(readerSettings, ValidationHandler);
return xmlConfigFile;
}
private static void SetAreaValueByName(XElement element)
{
// Choose which area to be set
switch (element.Name.ToString())
{
case AREAS.PRODUCTION_KEY:
SetAreaValue(ref ProductionConfig, element);
break;
case AREAS.TOOLING_KEY:
SetAreaValue(ref ToolingConfig, element);
break;
case AREAS.REPORT_KEY:
SetAreaValue(ref ReportConfig, element);
break;
case AREAS.ALARMS_KEY:
SetAreaValue(ref AlarmsConfig, element);
break;
case AREAS.MAINTENANCE_KEY:
SetAreaValue(ref MaintenanceConfig, element);
break;
case AREAS.UTILITIES_KEY:
SetAreaValue(ref UtilitiesConfig, element);
break;
case AREAS.SCADA_KEY:
SetAreaValue(ref ScadaConfig, element);
break;
}
}
private static void SetAreaValue(ref AreasConfigModel areasConfig, XElement element)
{
// Set area model with xml data
areasConfig = new AreasConfigModel()
{
Name = element.Name.ToString(),
Enabled = Convert.ToBoolean(element.Element("enabled").Value),
AllowExternalBrowser = Convert.ToBoolean(element.Element("allowExternalBrowser").Value),
NcNeeded = Convert.ToBoolean(element.Element("ncNeeded").Value)
};
}
private static void ValidationHandler(object sender, ValidationEventArgs e)
{
if (e.Severity == XmlSeverityType.Warning)
{
ExceptionManager.Manage(ERROR_LEVEL.WARNING, e.Message);
}
else if (e.Severity == XmlSeverityType.Error)
{
ExceptionManager.Manage(ERROR_LEVEL.FATAL, e.Message);
}
}
public static bool CheckAreaStatus(string areaName)
{ // Get Area status ( enabled field) by name
switch (areaName)
{
case AREAS.PRODUCTION_KEY:
return ProductionConfig.Enabled;
case AREAS.TOOLING_KEY:
return ToolingConfig.Enabled;
case AREAS.REPORT_KEY:
return ProductionConfig.Enabled;
case AREAS.ALARMS_KEY:
return AlarmsConfig.Enabled;
case AREAS.MAINTENANCE_KEY:
return MaintenanceConfig.Enabled;
case AREAS.UTILITIES_KEY:
return UtilitiesConfig.Enabled;
case AREAS.SCADA_KEY:
return ScadaConfig.Enabled;
case AREAS.GENERAL_KEY:
case AREAS.UNDER_HOOD:
return true;
default:
return false;
}
}
#region Read config from file from configuration
public static void ReadServerConfig()
{
// Get server file handler
XDocument xmlConfigFile = GetXmlHandlerWithValidator(SERVER_CONFIG_SCHEMA_PATH, SERVER_CONFIG_PATH);
// Read nc Config with LINQ
NcConfig = xmlConfigFile
.Root
.Descendants(NC_CONFIG_KEY)
.Select(x => new NcConfigModel()
{
NcVendor = x.Element("ncVendor").Value,
showNcHMI = Convert.ToBoolean(x.Element("showNcHMI").Value),
NcIpAddress = x.Element("ncIpAddress").Value,
NcPort = Convert.ToUInt16(x.Element("ncPort").Value),
NcName = x.Element("machineModel").Value
}).FirstOrDefault();
// Read server config with LINQ and save into static config
ServerStartupConfig = xmlConfigFile
.Root
.Descendants(SERVER_CONFIG_KEY)
.Select(x => new ServerConfigModel()
{ // Set server config model data
Language = CultureInfo.CreateSpecificCulture(x.Element("language").Value),
ServerAddress = x.Element("serverAddress").Value,
ServerPort = Convert.ToInt32(x.Element("serverPort").Value),
EnableDirectoryBrowsing = Convert.ToBoolean(x.Element("enableDirectoryBrowsing").Value),
DatabaseAddress = x.Element("databaseAddress").Value
}).FirstOrDefault();
}
private static void ReadAreaConfig()
{
// Get Areas file handler
XDocument xmlConfigFile = GetXmlHandlerWithValidator(AREAS_CONFIG_SCHEMA_PATH, AREAS_CONFIG_PATH);
// Read areas config with LINQ
xmlConfigFile
.Root // Get areas config node
.Elements()
.ToList()
.ForEach(x => SetAreaValueByName(x)); // Loop through elements
}
public static void ReadMaintenancesConfig()
{
// Get Maintenances file handler
XDocument xmlConfigFile = GetXmlHandlerWithValidator(MAINTENANCES_CONFIG_SCHEMA_PATH, MAINTENANCES_CONFIG_PATH);
MaintenancesConfig = xmlConfigFile
.Root
.Elements()
.ToList()
.Select(x =>
new MaintenanceConfigModel()
{
Id = Convert.ToInt32(x.Element("id").Value),
LocalizedName = x.Element("localizedName").Elements().ToDictionary( // Read localized names
y => y.Attribute("langKey").Value, y => y.Value
),
Intervall = TimeSpan.FromMinutes(Convert.ToDouble(x.Element("interval").Value)),
Deadline = DateTime.Parse(x.Element("deadline").Value),
Type = x.Element("type").Value,
CouterId = Convert.ToInt32(x.Element("counterId").Value),
LocalizedDescription = x.Element("localizedDescription").Elements().ToDictionary( // Read localization of description
y => y.Attribute("langKey").Value, y => y.Value
),
UnitOfMeasure = x.Element("unitOfMeasure").Value
})
.ToList();
}
private static void ReadNcSoftKeys()
{
XDocument xmlConfigFile = GetXmlHandlerWithValidator(NC_SOFTKEYS_CONFIG_SCHEMA_PATH, NC_SOFTKEYS_CONFIG_PATH);
// Read Nc softkey configuration from XML
NcSoftKeysConfig = xmlConfigFile
.Root
.Elements()
.Where(x => Convert.ToBoolean(x.Element("enabled").Value) == true) // Filter for active softkey
.Select(x => new NcSoftKeysModel()
{
Id = GetPlcIdFromNcSoftKey(x.Name.ToString()),
Name = x.Name.ToString(),
VisualizedName = x.Element("visualizedName").Value,
IsActive = Convert.ToBoolean(x.Element("enabled").Value),
IsReadOnly = Convert.ToBoolean(x.Element("readOnly").Value)
})
.ToList();
}
private static void ReadUserSoftKeysConfig()
{
// Get softkey file content
XDocument xmlConfigFile = GetXmlHandlerWithValidator(USER_SOFTKEYS_CONFIG_SCHEMA_PATH, USER_SOFTKEYS_CONFIG_PATH);
int id = 1;
// Read softkey configuration from XML with LINQ
SoftKeysConfig = xmlConfigFile
.Root
.Elements()
.Where(x => Convert.ToBoolean(x.Element("active").Value) == true) // Filter for active softkey
.Select(x => new UserSoftKeyConfigModel()
{
Id = id++, // autoincrement Id
PlcId = Convert.ToInt32(x.Element("plcId")?.Value), // If exists
IsActive = Convert.ToBoolean(x.Element("active").Value),
Category = Convert.ToInt32(x.Element("category").Value),
LocalizedNames = x.Element("localizedNames").Elements().ToDictionary( // Read localized names and convert into a dictionary
y => y.Attribute("langKey").Value, y => y.Value
),
SubKeys = x.Element("subKeys")?.Elements().Select(y => new SubKeysModel() // Populate subkeys if exist
{
Id = id++,
PlcId = Convert.ToInt32(y.Attribute("plcId").Value),
Text = y.Value
}).ToList(),
Type = GetSoftKeyType(x.Name.ToString()),
OperatorConfirmationNeeded = Convert.ToBoolean(x.Element("operatorConfirmationNeeded").Value)
})
.ToList();
}
private static void ReadAlarmsConfig()
{
XDocument xmlConfigFile = GetXmlHandlerWithValidator(ALARMS_CONFIG_SCHEMA_PATH, ALARMS_CONFIG_PATH);
// Read alarms config from XML file
InitialAlarmsConfig = xmlConfigFile
.Root
.Elements()
.Select(x => new AlarmsConfigModel()
{
AlarmId = Convert.ToInt32(x.Element("alarmId").Value),
PlcId = Convert.ToInt32(x.Element("plcId").Value),
RestoreIsActive = Convert.ToBoolean(x.Element("restoreIsActive").Value)
})
.ToList();
}
private static void ReadHeadsConfig()
{
XDocument xmlConfigFile = GetXmlHandlerWithValidator(HEADS_CONFIG_SCHEMA_PATH, HEADS_CONFIG_PATH);
int i = 1;
// Read head config from XML file
HeadsConfig = xmlConfigFile
.Root
.Elements()
.Select(x => new HeadsConfigModel()
{
Id = i++, // Autoincrement Id
Type = GetHeadType(x.Element("type").Value),
WarningLimit = Convert.ToInt16(x.Element("warningLimit").Value),
}
// Open file reader
XDocument xmlConfigFile = XDocument.Load(BASE_PATH + "\\" + configFilePath);
// Validate file
xmlConfigFile.Validate(readerSettings, ValidationHandler);
return xmlConfigFile;
}
private static void SetAreaValueByName(XElement element)
{
// Choose which area to be set
switch (element.Name.ToString())
{
case AREAS.PRODUCTION_KEY:
SetAreaValue(ref ProductionConfig, element);
break;
case AREAS.TOOLING_KEY:
SetAreaValue(ref ToolingConfig, element);
break;
case AREAS.REPORT_KEY:
SetAreaValue(ref ReportConfig, element);
break;
case AREAS.ALARMS_KEY:
SetAreaValue(ref AlarmsConfig, element);
break;
case AREAS.MAINTENANCE_KEY:
SetAreaValue(ref MaintenanceConfig, element);
break;
case AREAS.UTILITIES_KEY:
SetAreaValue(ref UtilitiesConfig, element);
break;
case AREAS.SCADA_KEY:
SetAreaValue(ref ScadaConfig, element);
break;
}
}
private static void SetAreaValue(ref AreasConfigModel areasConfig, XElement element)
{
// Set area model with xml data
areasConfig = new AreasConfigModel()
{
Name = element.Name.ToString(),
Enabled = Convert.ToBoolean(element.Element("enabled").Value),
AllowExternalBrowser = Convert.ToBoolean(element.Element("allowExternalBrowser").Value),
NcNeeded = Convert.ToBoolean(element.Element("ncNeeded").Value)
};
}
private static void ValidationHandler(object sender, ValidationEventArgs e)
{
if (e.Severity == XmlSeverityType.Warning)
{
ExceptionManager.Manage(ERROR_LEVEL.WARNING, e.Message);
}
else if (e.Severity == XmlSeverityType.Error)
{
ExceptionManager.Manage(ERROR_LEVEL.FATAL, e.Message);
}
}
public static bool CheckAreaStatus(string areaName)
{ // Get Area status ( enabled field) by name
switch (areaName)
{
case AREAS.PRODUCTION_KEY:
return ProductionConfig.Enabled;
case AREAS.TOOLING_KEY:
return ToolingConfig.Enabled;
case AREAS.REPORT_KEY:
return ProductionConfig.Enabled;
case AREAS.ALARMS_KEY:
return AlarmsConfig.Enabled;
case AREAS.MAINTENANCE_KEY:
return MaintenanceConfig.Enabled;
case AREAS.UTILITIES_KEY:
return UtilitiesConfig.Enabled;
case AREAS.SCADA_KEY:
return ScadaConfig.Enabled;
case AREAS.GENERAL_KEY:
case AREAS.UNDER_HOOD:
return true;
default:
return false;
}
}
#region Read config from file from configuration
public static void ReadServerConfig()
{
// Get server file handler
XDocument xmlConfigFile = GetXmlHandlerWithValidator(SERVER_CONFIG_SCHEMA_PATH, SERVER_CONFIG_PATH);
// Read nc Config with LINQ
NcConfig = xmlConfigFile
.Root
.Descendants(NC_CONFIG_KEY)
.Select(x => new NcConfigModel()
{
NcVendor = x.Element("ncVendor").Value,
showNcHMI = Convert.ToBoolean(x.Element("showNcHMI").Value),
NcIpAddress = x.Element("ncIpAddress").Value,
NcPort = Convert.ToUInt16(x.Element("ncPort").Value),
NcName = x.Element("machineModel").Value
}).FirstOrDefault();
// Read server config with LINQ and save into static config
ServerStartupConfig = xmlConfigFile
.Root
.Descendants(SERVER_CONFIG_KEY)
.Select(x => new ServerConfigModel()
{ // Set server config model data
Language = CultureInfo.CreateSpecificCulture(x.Element("language").Value),
ServerAddress = x.Element("serverAddress").Value,
ServerPort = Convert.ToInt32(x.Element("serverPort").Value),
EnableDirectoryBrowsing = Convert.ToBoolean(x.Element("enableDirectoryBrowsing").Value),
DatabaseAddress = x.Element("databaseAddress").Value
}).FirstOrDefault();
}
private static void ReadAreaConfig()
{
// Get Areas file handler
XDocument xmlConfigFile = GetXmlHandlerWithValidator(AREAS_CONFIG_SCHEMA_PATH, AREAS_CONFIG_PATH);
// Read areas config with LINQ
xmlConfigFile
.Root // Get areas config node
.Elements()
.ToList()
.ForEach(x => SetAreaValueByName(x)); // Loop through elements
}
public static void ReadMaintenancesConfig()
{
// Get Maintenances file handler
XDocument xmlConfigFile = GetXmlHandlerWithValidator(MAINTENANCES_CONFIG_SCHEMA_PATH, MAINTENANCES_CONFIG_PATH);
MaintenancesConfig = xmlConfigFile
.Root
.Elements()
.ToList()
.Select(x =>
new MaintenanceConfigModel()
{
Id = Convert.ToInt32(x.Element("id").Value),
LocalizedName = x.Element("localizedName").Elements().ToDictionary( // Read localized names
y => y.Attribute("langKey").Value, y => y.Value
),
Intervall = TimeSpan.FromMinutes(Convert.ToDouble(x.Element("interval").Value)),
Deadline = DateTime.Parse(x.Element("deadline").Value),
Type = x.Element("type").Value,
CouterId = Convert.ToInt32(x.Element("counterId").Value),
LocalizedDescription = x.Element("localizedDescription").Elements().ToDictionary( // Read localization of description
y => y.Attribute("langKey").Value, y => y.Value
),
UnitOfMeasure = x.Element("unitOfMeasure").Value
})
.ToList();
}
private static void ReadNcSoftKeys()
{
XDocument xmlConfigFile = GetXmlHandlerWithValidator(NC_SOFTKEYS_CONFIG_SCHEMA_PATH, NC_SOFTKEYS_CONFIG_PATH);
// Read Nc softkey configuration from XML
NcSoftKeysConfig = xmlConfigFile
.Root
.Elements()
.Where(x => Convert.ToBoolean(x.Element("enabled").Value) == true) // Filter for active softkey
.Select(x => new NcSoftKeysModel()
{
Id = GetPlcIdFromNcSoftKey(x.Name.ToString()),
Name = x.Name.ToString(),
VisualizedName = x.Element("visualizedName").Value,
IsActive = Convert.ToBoolean(x.Element("enabled").Value),
IsReadOnly = Convert.ToBoolean(x.Element("readOnly").Value)
})
.ToList();
}
private static void ReadUserSoftKeysConfig()
{
// Get softkey file content
XDocument xmlConfigFile = GetXmlHandlerWithValidator(USER_SOFTKEYS_CONFIG_SCHEMA_PATH, USER_SOFTKEYS_CONFIG_PATH);
int id = 1;
// Read softkey configuration from XML with LINQ
SoftKeysConfig = xmlConfigFile
.Root
.Elements()
.Where(x => Convert.ToBoolean(x.Element("active").Value) == true) // Filter for active softkey
.Select(x => new UserSoftKeyConfigModel()
{
Id = id++, // autoincrement Id
PlcId = Convert.ToInt32(x.Element("plcId")?.Value), // If exists
IsActive = Convert.ToBoolean(x.Element("active").Value),
Category = Convert.ToInt32(x.Element("category").Value),
LocalizedNames = x.Element("localizedNames").Elements().ToDictionary( // Read localized names and convert into a dictionary
y => y.Attribute("langKey").Value, y => y.Value
),
SubKeys = x.Element("subKeys")?.Elements().Select(y => new SubKeysModel() // Populate subkeys if exist
{
Id = id++,
PlcId = Convert.ToInt32(y.Attribute("plcId").Value),
Text = y.Value
}).ToList(),
Type = GetSoftKeyType(x.Name.ToString()),
OperatorConfirmationNeeded = Convert.ToBoolean(x.Element("operatorConfirmationNeeded").Value)
})
.ToList();
}
private static void ReadAlarmsConfig()
{
XDocument xmlConfigFile = GetXmlHandlerWithValidator(ALARMS_CONFIG_SCHEMA_PATH, ALARMS_CONFIG_PATH);
// Read alarms config from XML file
InitialAlarmsConfig = xmlConfigFile
.Root
.Elements()
.Select(x => new AlarmsConfigModel()
{
AlarmId = Convert.ToInt32(x.Element("alarmId").Value),
PlcId = Convert.ToInt32(x.Element("plcId").Value),
RestoreIsActive = Convert.ToBoolean(x.Element("restoreIsActive").Value)
})
.ToList();
}
private static void ReadHeadsConfig()
{
XDocument xmlConfigFile = GetXmlHandlerWithValidator(HEADS_CONFIG_SCHEMA_PATH, HEADS_CONFIG_PATH);
int i = 1;
// Read head config from XML file
HeadsConfig = xmlConfigFile
.Root
.Elements()
.Select(x => new HeadsConfigModel()
{
Id = i++, // Autoincrement Id
Type = GetHeadType(x.Element("type").Value),
WarningLimit = Convert.ToInt16(x.Element("warningLimit").Value),
AlarmLimit = Convert.ToInt16(x.Element("alarmLimit").Value),
LocalizedNames = x.Element("localizedNames").Elements().ToDictionary( // Read localized names and convert into a dictionary
y => y.Attribute("langKey").Value, y => y.Value
),
})
.ToList();
}
private static void ReadToolManagerConfig()
{
LocalizedNames = x.Element("localizedNames").Elements().ToDictionary( // Read localized names and convert into a dictionary
y => y.Attribute("langKey").Value, y => y.Value
),
})
.ToList();
}
private static void ReadToolManagerConfig()
{
XDocument xmlConfigFile = GetXmlHandlerWithValidator(TOOL_MANAGER_CONFIG_SCHEMA_PATH, TOOL_MANAGER_CONFIG_PATH);
// Read config from XML file
ToolManagerConfig = xmlConfigFile
.Elements()
.Select(x => new ToolManagerConfigModel()
{
FamilyOpt = Convert.ToBoolean(x.Element("familyOpt").Value),
ShankOpt = Convert.ToBoolean(x.Element("shankOpt").Value),
MagPosTypeOpt = Convert.ToBoolean(x.Element("magPositionOpt").Value),
OffsetOpt = Convert.ToBoolean(x.Element("offsetOpt").Value),
ReviveOpt = Convert.ToBoolean(x.Element("reviveOpt").Value),
GammaOpt = Convert.ToBoolean(x.Element("gammaOpt").Value),
LifeOpt = Convert.ToBoolean(x.Element("lifeOpt").Value),
TcpOpt = Convert.ToBoolean(x.Element("tcpOpt").Value),
CoolingOpt = Convert.ToBoolean(x.Element("coolingOpt").Value),
MultidimensionalShankOpt = Convert.ToBoolean(x.Element("multidimensionalShankOpt").Value),
SelfAdaptivePathOpt = Convert.ToBoolean(x.Element("selfAdaptivePathOpt").Value),
DynamicCompensationOpt = Convert.ToBoolean(x.Element("dynamicCompensationOpt").Value),
BallufOpt = Convert.ToBoolean(x.Element("ballufOpt").Value)
})
.FirstOrDefault();
}
#endregion Read config from file from configuration
}
ToolManagerConfig = xmlConfigFile
.Root
.Descendants("toolManagerConfig")
.Select(x => new ToolManagerConfigModel()
{
FamilyOpt = Convert.ToBoolean(x.Element("familyOpt").Value),
ShankOpt = Convert.ToBoolean(x.Element("shankOpt").Value),
MagPosTypeOpt = Convert.ToBoolean(x.Element("magPositionOpt").Value),
OffsetOpt = Convert.ToBoolean(x.Element("offsetOpt").Value),
ReviveOpt = Convert.ToBoolean(x.Element("reviveOpt").Value),
GammaOpt = Convert.ToBoolean(x.Element("gammaOpt").Value),
LifeOpt = Convert.ToBoolean(x.Element("lifeOpt").Value),
TcpOpt = Convert.ToBoolean(x.Element("tcpOpt").Value),
CoolingOpt = Convert.ToBoolean(x.Element("coolingOpt").Value),
MultidimensionalShankOpt = Convert.ToBoolean(x.Element("multidimensionalShankOpt").Value),
SelfAdaptivePathOpt = Convert.ToBoolean(x.Element("selfAdaptivePathOpt").Value),
DynamicCompensationOpt = Convert.ToBoolean(x.Element("dynamicCompensationOpt").Value),
BallufOpt = Convert.ToBoolean(x.Element("ballufOpt").Value)
})
.FirstOrDefault();
ToolManagerConfig.CooligsTranslations = xmlConfigFile
.Root
.Descendants("coolingLocalizedNames")
.Select(x => new CooligTranslations()
{
Cooling = x.Element("cooling").Elements().ToDictionary( // Read localized names of cooling and convert into a dictionary
y => y.Attribute("langKey").Value, y => y.Value
),
Cooling1 = x.Element("cooling1").Elements().ToDictionary(
y => y.Attribute("langKey").Value, y => y.Value
),
Cooling2 = x.Element("cooling2").Elements().ToDictionary(
y => y.Attribute("langKey").Value, y => y.Value
),
Cooling3 = x.Element("cooling3").Elements().ToDictionary(
y => y.Attribute("langKey").Value, y => y.Value
),
Cooling4LocalizedNames = x.Element("cooling4").Elements().ToDictionary(
y => y.Attribute("langKey").Value, y => y.Value
),
Cooling5LocalizedNames = x.Element("cooling5").Elements().ToDictionary(
y => y.Attribute("langKey").Value, y => y.Value
),
Cooling6LocalizedNames = x.Element("cooling6").Elements().ToDictionary(
y => y.Attribute("langKey").Value, y => y.Value
),
Cooling7LocalizedNames = x.Element("cooling7").Elements().ToDictionary(
y => y.Attribute("langKey").Value, y => y.Value
)
})
.FirstOrDefault();
}
#endregion Read config from file from configuration
}
}
@@ -21,5 +21,20 @@ namespace Step.Model.ConfigModels
public bool SelfAdaptivePathOpt { get; set; }
public bool DynamicCompensationOpt { get; set; }
public bool BallufOpt { get; set; }
public CooligTranslations CooligsTranslations { get; set; }
}
public class CooligTranslations
{
public Dictionary<string, string> Cooling { get; set; }
public Dictionary<string, string> Cooling1 { get; set; }
public Dictionary<string, string> Cooling2 { get; set; }
public Dictionary<string, string> Cooling3 { get; set; }
public Dictionary<string, string> Cooling4 { get; set; }
public Dictionary<string, string> Cooling5 { get; set; }
public Dictionary<string, string> Cooling6 { get; set; }
public Dictionary<string, string> Cooling7 { get; set; }
}
}
+12 -13
View File
@@ -3,7 +3,6 @@ using CMS_CORE.Demo;
using CMS_CORE.Fanuc;
using CMS_CORE.Osai;
using CMS_CORE.Siemens;
using CMS_CORE_Library;
using Step.Database.Controllers;
using Step.Model.DatabaseModels;
using Step.Model.DTOModels;
@@ -100,7 +99,7 @@ namespace Step.NC
return cmsError;
}
public CmsError SetActiveProgramInfo(string path, out DTOActiveProgramDataModel dtoData)
{
dtoData = new DTOActiveProgramDataModel();
@@ -145,7 +144,9 @@ namespace Step.NC
return cmsError;
}
#endregion
#endregion File manager
#region Read Data
@@ -326,7 +327,7 @@ namespace Step.NC
if (cmsError.IsError())
return cmsError;
if(selectedProcess > 0)
if (selectedProcess > 0)
cmsError = GetAxesPositionsByProcess(selectedProcess, out axes);
return cmsError;
@@ -832,7 +833,7 @@ namespace Step.NC
Override = head.Override,
IsActive = head.IsActive,
IsSelected = head.IsSelected,
AbrasiveIsActive = head.AbrasiveIsActive
AbrasiveIsActive = head.AbrasiveIsActive
});
}
break;
@@ -913,7 +914,7 @@ namespace Step.NC
config = new ToolTableConfiguration();
CmsError cmsError = numericalControl.TOOLS_RConfiguration(ref config);
if(NcConfig.NcVendor != NC_VENDOR.SIEMENS)
if (NcConfig.NcVendor != NC_VENDOR.SIEMENS)
{
List<string> categories = new List<string>();
@@ -926,7 +927,7 @@ namespace Step.NC
if (ToolManagerConfig.OffsetOpt)
categories.Add("offset");
if (ToolManagerConfig.TcpOpt)
if (ToolManagerConfig.TcpOpt)
categories.Add("tcp");
if (ToolManagerConfig.CoolingOpt)
@@ -996,7 +997,6 @@ namespace Step.NC
return cmsError;
}
#endregion Read Data
#region Write data
@@ -1057,6 +1057,7 @@ namespace Step.NC
// Set to true power on data by id
return numericalControl.PLC_WPowerOnData(id, true);
}
#endregion Write data
#region Siemens Tools
@@ -1170,8 +1171,6 @@ namespace Step.NC
#region Osai/Fanuc Tools
// OSAI FANUC TOOL MANAGER
public CmsError GetToolsData(out List<DTONcToolModel> dtoTools)
{
dtoTools = new List<DTONcToolModel>();
@@ -1321,7 +1320,7 @@ namespace Step.NC
{
return numericalControl.TOOLS_WOffset(offsetId, offsetData);
}
public CmsError DeleteNcTool(DbNcToolModel tool)
{
using (NcToolManagerController toolsManager = new NcToolManagerController())
@@ -1493,7 +1492,7 @@ namespace Step.NC
return cmsError;
toolsManager.DeleteFamily(family);
// Update Nc families
// Update Nc families
cmsError = UpdateNcFamily(toolsManager);
ManageErrorAndTransaction(cmsError, dbContextTransaction, true);
@@ -1528,7 +1527,7 @@ namespace Step.NC
// Update nc families
return numericalControl.TOOLS_WUpdateFamilies(families);
}
public CmsError UpdateMagazinePosition(DbNcMagazinePositionModel dbPos, DTONcMagazinePositionModel dtoPos, out DTONcMagazinePositionModel magPos)
{
magPos = new DTONcMagazinePositionModel();
@@ -139,5 +139,14 @@ namespace Step.Controllers.WebApi
return returnValue;
}
}
private static Dictionary<string, string> GetCoolingTranslations(string language)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
var key = ToolManagerConfig.CooligsTranslations.Cooling.Where(x => x.Key == language).FirstOrDefault();
dictionary.Add("cooling", key.Value);
}
}
}