diff --git a/Step.Config/Config/scadaValidator.xsd b/Step.Config/Config/scadaValidator.xsd
new file mode 100644
index 00000000..de4fdc48
--- /dev/null
+++ b/Step.Config/Config/scadaValidator.xsd
@@ -0,0 +1,201 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Step.Config/ServerConfigController.cs b/Step.Config/ServerConfigController.cs
index d5569629..d1c77d33 100644
--- a/Step.Config/ServerConfigController.cs
+++ b/Step.Config/ServerConfigController.cs
@@ -19,6 +19,8 @@ namespace Step.Config
{
public static class ServerConfigController
{
+ private static string actualFileName;
+
public static void ReadStartupConfig()
{
try
@@ -64,6 +66,8 @@ namespace Step.Config
readerSettings.Add(null, schemaReader);
}
}
+
+ actualFileName = configFilePath;
// Open file reader
XDocument xmlConfigFile = XDocument.Load(BASE_PATH + "\\" + configFilePath);
@@ -73,6 +77,30 @@ namespace Step.Config
return xmlConfigFile;
}
+
+ private static void validateScada(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))
+ {
+ using (XmlReader schemaReader = XmlReader.Create(schemaStream))
+ {
+ readerSettings.Add(null, schemaReader);
+ }
+ }
+
+ actualFileName = Path.GetFileName(configFilePath);
+
+ // Open file reader
+ XDocument xmlConfigFile = XDocument.Load(configFilePath);
+ // Validate file
+ xmlConfigFile.Validate(readerSettings, ValidationHandler);
+ }
+
private static void SetAreaValueByName(XElement element)
{
// Choose which area to be set
@@ -140,7 +168,7 @@ namespace Step.Config
{
ExceptionManager.Manage(ERROR_LEVEL.FATAL,
// "Error while reading file: " + e.Exception.SourceUri +
- "Error while reading configuration file: " + e.Message,
+ "Error while reading XML file \"" + actualFileName + "\" \n\n" + e.Message,
true
);
}
@@ -192,9 +220,13 @@ namespace Step.Config
// Cycle inside xml files
foreach (var file in files)
{
+ validateScada(SCADA_PAGES_SCHEMA_PATH, SCADA_DIRECTORY + file.Name);
+
StreamReader sr = new StreamReader(SCADA_DIRECTORY + file.Name);
XmlSerializer xmlSerializer = new XmlSerializer(typeof(ScadaSchemaModel));
ScadaSchemaModel schema = xmlSerializer.Deserialize(sr) as ScadaSchemaModel;
+
+
// Setup incremental ids
schema.Id = i++;
diff --git a/Step.Config/Step.Config.csproj b/Step.Config/Step.Config.csproj
index 5bb37d5c..281f49dc 100644
--- a/Step.Config/Step.Config.csproj
+++ b/Step.Config/Step.Config.csproj
@@ -136,5 +136,10 @@
Designer
+
+
+ Designer
+
+
\ No newline at end of file
diff --git a/Step.Model/Constants.cs b/Step.Model/Constants.cs
index 66061f4f..03e7462c 100644
--- a/Step.Model/Constants.cs
+++ b/Step.Model/Constants.cs
@@ -184,7 +184,10 @@ namespace Step.Model
public const string MACROS_CONFIG_PATH = CONFIG_DIRECTORY + "macrosConfig.xml";
public static string LANGUAGE_PACK_DIRECTORY = BASE_PATH + "\\languages\\";
- public static string LANGUAGE_SCHEMA_PATH = BASE_PATH + "\\LanguageValidator.xsd";
+ public static string LANGUAGE_SCHEMA_PATH = BASE_PATH + "\\LanguageValidator.xsd";
+
+
+ public const string SCADA_PAGES_SCHEMA_PATH = RESOURCE_DIRECTORY + "scadaValidator.xsd";
public static string CANDY_DUMMYFILE_PATH = BASE_PATH + "\\dll.dll";
// MVVM Messages to server UI
diff --git a/Step.NC/NcHandler.cs b/Step.NC/NcHandler.cs
index 7a30af32..2d9afa9e 100644
--- a/Step.NC/NcHandler.cs
+++ b/Step.NC/NcHandler.cs
@@ -1037,7 +1037,7 @@ namespace Step.NC
});
}
- if (layer.Inputs.ElementAtOrDefault(i) != null && layer.Inputs[i].Status.Action == "read")
+ if (layer.Inputs.ElementAtOrDefault(i) != null && layer.Inputs[i].Status.Action.ToLower() == "read")
{
// Read isVisible from PLC
//cmsError = numericalControl.PLC_RScadaValue(layer.Inputs[i].Status.MemEnabledIndex, SCADA_MEM_TYPE.BOOL, ref val);
diff --git a/Step/program.cs b/Step/program.cs
index 923471aa..7900efbe 100644
--- a/Step/program.cs
+++ b/Step/program.cs
@@ -36,8 +36,6 @@ namespace Step
return;
}
- // Start WinForm
- ServerControlWindow.Start();
// Create unhandled exception handler
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandler);
@@ -45,6 +43,9 @@ namespace Step
// Read config
ServerConfigController.ReadStartupConfig();
+ // Start WinForm
+ ServerControlWindow.Start();
+
DatabaseContext.SetUpDbConnectionAndDbConfig();
// Register listener to "close application" messages