diff --git a/Client/Browser_Tools/BrowserJSObject.cs b/Client/Browser_Tools/BrowserJSObject.cs index 6b4f1b11..d8e9b3c7 100644 --- a/Client/Browser_Tools/BrowserJSObject.cs +++ b/Client/Browser_Tools/BrowserJSObject.cs @@ -28,7 +28,7 @@ namespace Active_Client.Browser_Tools // The first letter of All PUBLIC Variables and Methods must be Lower-Case (CEF Settings) private MainForm mainForm; - private static readonly string[] _validExtensions = { "", ".txt", ".cnc", ".cn", ".cno", ".ini", ".mpf", ".spf", /*".job", ".zip"*/ }; + private static readonly string[] _validExtensions = { "", ".txt", ".cnc", ".cn", ".cno", ".ini", ".mpf", ".spf", ".iso" /*".job", ".zip"*/ }; private static readonly string[] _validImages = { ".jpg", ".jpeg", ".png" }; private static string jobPath = ""; diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index a80fe4a8..4a79b8de 100644 Binary files a/Libs/CMS_CORE_Library.dll and b/Libs/CMS_CORE_Library.dll differ diff --git a/Step.Config/Config/customMainProgram.txt b/Step.Config/Config/customMainProgram.txt new file mode 100644 index 00000000..7b587894 --- /dev/null +++ b/Step.Config/Config/customMainProgram.txt @@ -0,0 +1,4 @@ +% + +M30; +% \ No newline at end of file diff --git a/Step.Config/Config/scadaValidator.xsd b/Step.Config/Config/scadaValidator.xsd index 7075a92a..cdf6b389 100644 --- a/Step.Config/Config/scadaValidator.xsd +++ b/Step.Config/Config/scadaValidator.xsd @@ -58,11 +58,7 @@ - - - - - + diff --git a/Step.Config/ServerConfig.cs b/Step.Config/ServerConfig.cs index a8bb037c..b7336c29 100644 --- a/Step.Config/ServerConfig.cs +++ b/Step.Config/ServerConfig.cs @@ -34,13 +34,14 @@ namespace Step.Config public static AreasConfigModel ScadaConfig; public static AreasConfigModel JobEditorConfig; public static AreasConfigModel UsersConfig; - - + public static List ProductionScadaSchema = new List(); public static List ConfiguredScadaSchema = new List(); public static List SubscribedScada = new List(); public static List MacrosConfig; + + public static string CMSMainProgramContent; } } \ No newline at end of file diff --git a/Step.Config/ServerConfigController.cs b/Step.Config/ServerConfigController.cs index ec9ed26f..a1d3de12 100644 --- a/Step.Config/ServerConfigController.cs +++ b/Step.Config/ServerConfigController.cs @@ -35,6 +35,7 @@ namespace Step.Config ReadToolManagerConfig(); ReadMacros(); ReadScadaFile(); + ReadMainProgram(); } catch (XmlException ex) { @@ -78,7 +79,6 @@ namespace Step.Config return xmlConfigFile; } - private static void validateScada(string configSchemaFilePath, string configFilePath) { // Create new instance @@ -142,8 +142,6 @@ namespace Step.Config case AREAS.USERS_KEY: SetAreaValue(ref UsersConfig, element); break; - - } } @@ -562,6 +560,15 @@ namespace Step.Config .ToList(); } + + public static void ReadMainProgram() + { + if (File.Exists(MAIN_PROGRAM_CONFIG_PATH)) + { + CMSMainProgramContent = File.ReadAllText(MAIN_PROGRAM_CONFIG_PATH); + } + } + #endregion Read config from file from configuration } } \ No newline at end of file diff --git a/Step.Config/Step.Config.csproj b/Step.Config/Step.Config.csproj index 281f49dc..60932e76 100644 --- a/Step.Config/Step.Config.csproj +++ b/Step.Config/Step.Config.csproj @@ -63,6 +63,9 @@ + + Always + PreserveNewest diff --git a/Step.Model/Constants.cs b/Step.Model/Constants.cs index 89db1c60..d4ddfc20 100644 --- a/Step.Model/Constants.cs +++ b/Step.Model/Constants.cs @@ -162,12 +162,12 @@ namespace Step.Model public const string AREAS_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "areasConfigValidator.xsd"; public const string AREAS_CONFIG_PATH = CONFIG_DIRECTORY + "areasConfig.xml"; - public const string MAINTENANCES_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "maintenancesConfigValidator.xsd"; + public const string MAINTENANCES_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "maintenancesConfigValidator.xsd"; public const string MAINTENANCES_CONFIG_PATH = CONFIG_DIRECTORY + "maintenancesConfig.xml"; - + public const string USER_SOFTKEYS_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "userSoftKeyConfigValidator.xsd"; public const string USER_SOFTKEYS_CONFIG_PATH = CONFIG_DIRECTORY + "userSoftKeyConfig.xml"; - + public const string ALARMS_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "alarmsConfigValidator.xsd"; public const string ALARMS_CONFIG_PATH = CONFIG_DIRECTORY + "alarmsConfig.xml"; @@ -181,7 +181,9 @@ namespace Step.Model public const string TOOL_MANAGER_CONFIG_PATH = CONFIG_DIRECTORY + "toolManagerConfig.xml"; public const string MACROS_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "macrosConfigValidator.xsd"; - public const string MACROS_CONFIG_PATH = CONFIG_DIRECTORY + "macrosConfig.xml"; + public const string MACROS_CONFIG_PATH = CONFIG_DIRECTORY + "macrosConfig.xml"; + + public const string MAIN_PROGRAM_CONFIG_PATH = CONFIG_DIRECTORY + "customMainProgram.txt"; public static string LANGUAGE_PACK_DIRECTORY = BASE_PATH + "\\languages\\"; public static string LANGUAGE_SCHEMA_PATH = BASE_PATH + "\\LanguageValidator.xsd"; diff --git a/Step.NC/NcFileHandler.cs b/Step.NC/NcFileHandler.cs index c7eb6c00..87a131e4 100644 --- a/Step.NC/NcFileHandler.cs +++ b/Step.NC/NcFileHandler.cs @@ -256,8 +256,15 @@ namespace Step.NC if (cmsError.IsError()) return cmsError; - // Activate updated program - return numericalControl.FILES_WSetActiveProgram(selectedProcess, newFilePath, ref programData); + if(String.IsNullOrEmpty(CMSMainProgramContent)) + // Activate directly program + return numericalControl.FILES_WSetActiveProgram(selectedProcess, newFilePath, ref programData); + else + { + string path = ""; + // Activate updated program with custom main program + return numericalControl.FILES_WUploadCustomMainProgramAndActivate(selectedProcess, CMSMainProgramContent, ref programData); + } } else { diff --git a/Step.NC/NcHandler.cs b/Step.NC/NcHandler.cs index 3867f860..a6107ca7 100644 --- a/Step.NC/NcHandler.cs +++ b/Step.NC/NcHandler.cs @@ -1006,7 +1006,7 @@ namespace Step.NC if (cmsError.IsError()) return cmsError; // Populate & add new object into scada model - scadaValue.Buttons.Add(new DTOScadaButtonModel() + scadaValue.Buttons.Add(new DTOScadaButtonModel() { Id = layer.Buttons[i].Id, Enabled = Convert.ToBoolean(val) diff --git a/Step/Controllers/WebApi/NcFileController.cs b/Step/Controllers/WebApi/NcFileController.cs index d67df01f..2b2a6eb8 100644 --- a/Step/Controllers/WebApi/NcFileController.cs +++ b/Step/Controllers/WebApi/NcFileController.cs @@ -116,18 +116,18 @@ namespace Step.Controllers.WebApi if (cmsError.IsError() && cmsError.errorCode != CMS_ERROR_CODES.FILE_NOT_FOUND) return BadRequest(cmsError.localizationKey); } - + ActiveProgramDataModel programData = new ActiveProgramDataModel(); foreach (FormItem item in formItems) { if (item.IsAFile) { - if (item.ParameterName == "main") + if (item.ParameterName == "main") { File.WriteAllBytes(TEMP_PP_FOLDER + item.FileName, item.Data); mainPPName = item.FileName; // Upload main program - CmsError cmsError = ncFileHandler.UploadPartProgramAndActivate(TEMP_PP_FOLDER, item.FileName, out ActiveProgramDataModel programData); + CmsError cmsError = ncFileHandler.UploadPartProgramAndActivate(TEMP_PP_FOLDER, item.FileName, out programData); if (cmsError.IsError()) return BadRequest(cmsError.localizationKey); } @@ -142,7 +142,7 @@ namespace Step.Controllers.WebApi else if (item.ParameterName == "image") { // Upload image - File.WriteAllBytes(PART_PRG_IMAGES + item.FileName, item.Data); + File.WriteAllBytes(PART_PRG_IMAGES + Path.GetFileNameWithoutExtension(programData.Path) + Path.GetExtension(item.FileName), item.Data); imageUploaded = true; } } diff --git a/Step/Step.csproj b/Step/Step.csproj index 1c9cfd40..3f2b7250 100644 --- a/Step/Step.csproj +++ b/Step/Step.csproj @@ -40,7 +40,7 @@ true full - true + false bin\ DEBUG;TRACE prompt