diff --git a/Client.Utils/Constants.cs b/Client.Utils/Constants.cs index debddba9..1067761f 100644 --- a/Client.Utils/Constants.cs +++ b/Client.Utils/Constants.cs @@ -20,9 +20,8 @@ namespace Client.Utils public static String CEF_LOCALES_PATH = BASE_PATH + "CEF\\Resources\\locales"; public static String CEF_EXCEPTIONLOG_PATH = BASE_PATH + "ExceptionLog"; public static String errorPageFile = BASE_PATH + "error.pg"; - public static String JOB_OPENING_PATH = BASE_PATH + "TempJob\\"; - - + public static String JOB_OPENING_PATH = "C:\\CMS\\STEP\\TMP\\clientTmpJob\\"; + //Config Names public const string CONFIG_KEY = "Config"; public const string CLIENT_CONFIG_KEY = "Client"; @@ -74,12 +73,11 @@ namespace Client.Utils public const string KEYB_PROC_NAME = "OSK"; public const string StartingPage = "index.html"; - public const string Uploadpage = "/api/file_manager/upload"; + public const string UPLOAD_PAGE = "/api/file_manager/upload"; public const string UPLOAD_ADD_QUEUE = "/api/file_manager/queue/add"; public const string ConfigPage = "api/configuration/client"; - public const string errorPageUrl = @"error://error/"; - - - + public const string errorPageUrl = @"error://error/"; + + public static string[] JOB_EXTENSIONS = { ".job", ".zip" }; } } diff --git a/Client/Browser_Tools/BrowserJSObject.cs b/Client/Browser_Tools/BrowserJSObject.cs index d26859e5..9d290353 100644 --- a/Client/Browser_Tools/BrowserJSObject.cs +++ b/Client/Browser_Tools/BrowserJSObject.cs @@ -27,7 +27,7 @@ namespace CMS_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", ".ini", ".mpf", ".spf" }; + private static readonly string[] _validExtensions = { "", ".txt", ".cnc", ".ini", ".mpf", ".spf", ".job", ".zip" }; private static readonly string[] _validImages = { ".jpg", ".jpeg", ".png" }; private static string jobPath = ""; @@ -66,11 +66,14 @@ namespace CMS_Client.Browser_Tools AddFunction("openJob").Execute += openJob; AddFunction("saveJob").Execute += saveJob; AddFunction("newJob").Execute += newJob; + AddFunction("closeJob").Execute += closeJob; AddFunction("saveJobNewPath").Execute += saveJobNewPath; AddFunction("addImageToJob").Execute += addImageToJob; AddFunction("delImageFromJob").Execute += delImageFromJob; AddFunction("addPPToJob").Execute += addPPToJob; AddFunction("delPPFromJob").Execute += delPPFromJob; + AddFunction("readJobMetadata").Execute += readJobMetadata; + AddFunction("updateJobMetadata").Execute += updateJobMetadata; } #endregion CONSTRUCTOR_METHOD @@ -325,7 +328,7 @@ namespace CMS_Client.Browser_Tools { if (_validExtensions.Contains(Path.GetExtension(item).ToLower())) { - bool isJob = Path.GetExtension(item) == "job"; + bool isJob = JOB_EXTENSIONS.Contains(Path.GetExtension(item)); filelist.Add(new Models.File { Name = Path.GetFileName(item), @@ -357,7 +360,7 @@ namespace CMS_Client.Browser_Tools //Check the arguments numbers if (e.Arguments.Length < 1 || e.Arguments[0] == null) { - e.SetReturnValue(Constants.Uploadpage + "INVALID_ARGUMENTS"); + e.SetReturnValue(UPLOAD_PAGE + "INVALID_ARGUMENTS"); return; } @@ -365,7 +368,7 @@ namespace CMS_Client.Browser_Tools fileToUpload = e.Arguments[0].StringValue; if (!System.IO.File.Exists(fileToUpload)) { - e.SetReturnValue(Constants.Uploadpage + ";FILE_NOT_FOUND"); + e.SetReturnValue(UPLOAD_PAGE + ";FILE_NOT_FOUND"); return; } @@ -390,22 +393,23 @@ namespace CMS_Client.Browser_Tools using (HttpClient httpClient = new HttpClient()) { //Create the new FORM - MultipartFormDataContent form = new MultipartFormDataContent(); - - //Add the content to the form - form.Add(new ByteArrayContent(filecontent), "file", fileName); + MultipartFormDataContent form = new MultipartFormDataContent + { + //Add the content to the form + { new ByteArrayContent(filecontent), "file", fileName } + }; if (imagecontent != null) form.Add(new ByteArrayContent(imagecontent), "image", imageName); //Send them HttpResponseMessage response = httpClient.PostAsync( - "http://" + Config.ConnectionConfig.ServerUrl + ":" + Config.ConnectionConfig.ServerPort + "/" + Constants.Uploadpage, + "http://" + Config.ConnectionConfig.ServerUrl + ":" + Config.ConnectionConfig.ServerPort + "/" + Constants.UPLOAD_PAGE, form).Result; //Wait the answer if (response.StatusCode == System.Net.HttpStatusCode.BadRequest) - e.SetReturnValue(Constants.Uploadpage + ";" + await response.Content.ReadAsStringAsync()); + e.SetReturnValue(UPLOAD_PAGE + ";" + await response.Content.ReadAsStringAsync()); else if (response.StatusCode != System.Net.HttpStatusCode.OK) - e.SetReturnValue(Constants.Uploadpage + ";" + response.ReasonPhrase); + e.SetReturnValue(UPLOAD_PAGE + ";" + response.ReasonPhrase); else e.SetReturnValue(""); } @@ -425,7 +429,7 @@ namespace CMS_Client.Browser_Tools //Check the arguments numbers if (e.Arguments.Length < 1 || e.Arguments[0] == null) { - e.SetReturnValue(Constants.UPLOAD_ADD_QUEUE + "INVALID_ARGUMENTS"); + e.SetReturnValue(UPLOAD_ADD_QUEUE + "INVALID_ARGUMENTS"); return; } @@ -435,7 +439,7 @@ namespace CMS_Client.Browser_Tools if (!System.IO.File.Exists(fileToUpload)) { - e.SetReturnValue(Constants.UPLOAD_ADD_QUEUE + ";FILE_NOT_FOUND"); + e.SetReturnValue(UPLOAD_ADD_QUEUE + ";FILE_NOT_FOUND"); return; } @@ -471,14 +475,14 @@ namespace CMS_Client.Browser_Tools //Send them HttpResponseMessage response = httpClient - .PostAsync("http://" + Config.ConnectionConfig.ServerUrl + ":" + Config.ConnectionConfig.ServerPort + "/" + Constants.UPLOAD_ADD_QUEUE, + .PostAsync("http://" + Config.ConnectionConfig.ServerUrl + ":" + Config.ConnectionConfig.ServerPort + "/" + UPLOAD_ADD_QUEUE, form) .Result; //Wait the answer if (response.StatusCode == System.Net.HttpStatusCode.BadRequest) - e.SetReturnValue(Constants.UPLOAD_ADD_QUEUE + ";" + await response.Content.ReadAsStringAsync()); + e.SetReturnValue(UPLOAD_ADD_QUEUE + ";" + await response.Content.ReadAsStringAsync()); else if (response.StatusCode != System.Net.HttpStatusCode.OK) - e.SetReturnValue(Constants.UPLOAD_ADD_QUEUE + ";" + response.ReasonPhrase); + e.SetReturnValue(UPLOAD_ADD_QUEUE + ";" + response.ReasonPhrase); else e.SetReturnValue(""); } @@ -573,7 +577,7 @@ namespace CMS_Client.Browser_Tools #region JOB_METHODS - // Read job data + // Read all the job data public void openJob(object sender, CfrV8HandlerExecuteEventArgs e) { JobToStep job = new JobToStep(); @@ -585,6 +589,14 @@ namespace CMS_Client.Browser_Tools if (jobOpenFileDialog.ShowDialog() == DialogResult.OK) { + // Check if zip is valid + var zipIsValid = ValidateZip(jobOpenFileDialog.FileName); + if (zipIsValid != null) + { + e.SetReturnValue(JsonConvert.SerializeObject(zipIsValid)); + return; + } + if (!Directory.Exists(JOB_OPENING_PATH)) Directory.CreateDirectory(JOB_OPENING_PATH); @@ -632,15 +644,15 @@ namespace CMS_Client.Browser_Tools metasFromFile = JsonConvert.DeserializeObject(reader.ReadToEnd()); if (metasFromFile == null) { - e.SetReturnValue(null); + e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("error_corrupted_model"))); return; } else { - job.metadata.generics.Description = metasFromFile.Description; - job.metadata.generics.ExecutionTime = metasFromFile.ExecutionTime; - job.metadata.tools = metasFromFile.Tools; - job.metadata.customs = metasFromFile.Customs; + job.metadata.generics.description = metasFromFile.description; + job.metadata.generics.executionTime = metasFromFile.executionTime; + job.metadata.tools = metasFromFile.tools; + job.metadata.customs = metasFromFile.customs; } } } @@ -648,10 +660,11 @@ namespace CMS_Client.Browser_Tools else { entry.ExtractToFile(JOB_OPENING_PATH + entry.Name, true); + job.partPrograms.Add(new PPContainer(Path.GetFileName(entry.Name))); } } } - jobPath = Path.GetFileName(jobOpenFileDialog.FileName); + jobPath = jobOpenFileDialog.FileName; e.SetReturnValue(JsonConvert.SerializeObject(job)); return; } @@ -662,7 +675,116 @@ namespace CMS_Client.Browser_Tools } } - // create job data + public void readJobMetadata(object sender, CfrV8HandlerExecuteEventArgs e) + { + // Get file path + string filePath = e.Arguments[0].StringValue; + + // Check if zip is valid + var zipIsValid = ValidateZip(filePath); + if (zipIsValid != null) + { + e.SetReturnValue(JsonConvert.SerializeObject(zipIsValid)); + return; + } + + // Open zip archive + using (ZipArchive zipArchive = ZipFile.OpenRead(filePath)) + { + // Setup main Fields + JobToStep jobData = new JobToStep() + { + name = Path.GetFileName(filePath), + lastEditTimestamp = new FileInfo(filePath).LastAccessTime + }; + + foreach (ZipArchiveEntry entry in zipArchive.Entries) + { + // Get images content without extract files + if (_validImages.Contains(Path.GetExtension(entry.Name).ToLower())) + { + using (var memoryReader = new MemoryStream()) + { + entry.Open().CopyTo(memoryReader); + jobData.metadata.generics.images.Add(new ImageParam() + { + name = Path.GetFileName(entry.Name), + base64 = "data:image/" + Path.GetExtension(entry.Name).ToLower().TrimStart('.') + ";base64," + Convert.ToBase64String(memoryReader.ToArray()) + }); + } + } + // Metadata + else if (entry.Name.Equals(JOB_METADATA_FILENAME, StringComparison.OrdinalIgnoreCase)) + { + MetadataToFile metasFromFile = new MetadataToFile(); + + using (var reader = new StreamReader(entry.Open())) + { + metasFromFile = JsonConvert.DeserializeObject(reader.ReadToEnd()); + if (metasFromFile == null) + { + e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("error_corrupted_model"))); + return; + } + else + { + jobData.metadata.generics.description = metasFromFile.description; + jobData.metadata.generics.executionTime = metasFromFile.executionTime; + jobData.metadata.tools = metasFromFile.tools; + jobData.metadata.customs = metasFromFile.customs; + } + } + } + } + + e.SetReturnValue(JsonConvert.SerializeObject(jobData)); + + return; + } + } + + public void updateJobMetadata(object sender, CfrV8HandlerExecuteEventArgs e) + { + MetadataToFile metafile = new MetadataToFile(); + + // Deserialize job + JobToStep job = JsonConvert.DeserializeObject(e.Arguments[1].StringValue); + if (job == null) + { + e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("error_corrupted_model"))); + return; + } + + // Set meta data + metafile.description = job.metadata.generics.description; + metafile.executionTime = job.metadata.generics.executionTime; + metafile.tools = job.metadata.tools; + metafile.customs = job.metadata.customs; + + // Open zipArchive in update mode + using (ZipArchive zipArchive = ZipFile.Open(e.Arguments[0].StringValue, ZipArchiveMode.Update)) + { + // Find metadata.json file + var file = zipArchive.Entries.Where(x => x.FullName == JOB_METADATA_FILENAME).FirstOrDefault(); + if(file == null) + { + e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("error_corrupted_model"))); + return; + } + // Update metadata file + using (StreamWriter streamWriter = new StreamWriter(file.Open())) + { + JsonSerializer serializer = new JsonSerializer + { + Formatting = Formatting.Indented + }; + // Write + serializer.Serialize(streamWriter, metafile); + } + } + } + + // Create job data public void newJob(object sender, CfrV8HandlerExecuteEventArgs e) { JobToStep job = new JobToStep(); @@ -671,15 +793,26 @@ namespace CMS_Client.Browser_Tools Directory.CreateDirectory(JOB_OPENING_PATH); ClearTempPath(); - + job.name = "newjob_" + DateTime.Now.ToFileTime() + ".job"; jobPath = ""; e.SetReturnValue(JsonConvert.SerializeObject(job)); return; - } - + + // close job + public void closeJob(object sender, CfrV8HandlerExecuteEventArgs e) + { + if (!Directory.Exists(JOB_OPENING_PATH)) + Directory.CreateDirectory(JOB_OPENING_PATH); + + ClearTempPath(); + jobPath = ""; + + e.SetReturnValue(null); + return; + } // Save all job public void saveJobNewPath(object sender, CfrV8HandlerExecuteEventArgs e) @@ -699,15 +832,16 @@ namespace CMS_Client.Browser_Tools JobToStep job = JsonConvert.DeserializeObject(e.Arguments[0].StringValue); if (job == null) { - e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("corrupted_model"))); + e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("error_corrupted_model"))); return; } //Metadata - metafile.Description = job.metadata.generics.Description; - metafile.ExecutionTime = job.metadata.generics.ExecutionTime; - metafile.Tools = job.metadata.tools; - metafile.Customs = job.metadata.customs; + metafile.description = job.metadata.generics.description; + metafile.executionTime = job.metadata.generics.executionTime; + metafile.tools = job.metadata.tools; + metafile.customs = job.metadata.customs; + using (StreamWriter file = System.IO.File.CreateText(JOB_OPENING_PATH + JOB_METADATA_FILENAME)) { JsonSerializer serializer = new JsonSerializer @@ -727,16 +861,16 @@ namespace CMS_Client.Browser_Tools //Create Zip File ZipFile.CreateFromDirectory(JOB_OPENING_PATH, jobSaveFileDialog.FileName); - jobPath = Path.GetFileName(jobSaveFileDialog.FileName); + jobPath = jobSaveFileDialog.FileName; job.name = jobPath; e.SetReturnValue(JsonConvert.SerializeObject(job)); return; } + e.SetReturnValue(null); return; } - // Save all job public void saveJob(object sender, CfrV8HandlerExecuteEventArgs e) { @@ -744,16 +878,14 @@ namespace CMS_Client.Browser_Tools SaveFileDialog jobSaveFileDialog = new SaveFileDialog(); jobSaveFileDialog.Filter = "CMS Job Files(*.JOB)|*.job|Zip Files(*.ZIP)|*.zip"; - // Job deserialize JobToStep job = JsonConvert.DeserializeObject(e.Arguments[0].StringValue); if (job == null) { - e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("corrupted_model"))); + e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("error_corrupted_model"))); return; } - //check the arguments if (e.Arguments.Count() == 0) return; @@ -770,16 +902,15 @@ namespace CMS_Client.Browser_Tools e.SetReturnValue(null); return; } - } - + if (!String.IsNullOrEmpty(jobPath)) { //Metadata - metafile.Description = job.metadata.generics.Description; - metafile.ExecutionTime = job.metadata.generics.ExecutionTime; - metafile.Tools = job.metadata.tools; - metafile.Customs = job.metadata.customs; + metafile.description = job.metadata.generics.description; + metafile.executionTime = job.metadata.generics.executionTime; + metafile.tools = job.metadata.tools; + metafile.customs = job.metadata.customs; using (StreamWriter file = System.IO.File.CreateText(JOB_OPENING_PATH + JOB_METADATA_FILENAME)) { JsonSerializer serializer = new JsonSerializer @@ -797,16 +928,24 @@ namespace CMS_Client.Browser_Tools System.IO.File.Delete(jobPath); //Create Zip File - ZipFile.CreateFromDirectory(JOB_OPENING_PATH, jobPath); + try + { + ZipFile.CreateFromDirectory(JOB_OPENING_PATH, jobPath); + } + catch(Exception ex) + { + e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("error_save_file"))); + return; + } e.SetReturnValue(JsonConvert.SerializeObject(job)); return; } + e.SetReturnValue(null); return; } - // Add an image public void addImageToJob(object sender, CfrV8HandlerExecuteEventArgs e) { @@ -873,7 +1012,7 @@ namespace CMS_Client.Browser_Tools //Check the extension if (!_validExtensions.Contains(Path.GetExtension(PPOpenFileDialog.FileName).ToLower())) { - e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("extension_not_available"))); + e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("ext_not_available"))); return; } @@ -944,6 +1083,33 @@ namespace CMS_Client.Browser_Tools return base64img.Substring(base64img.IndexOf(";base64,") + ";base64,".Length); } + + private static ErrorContainer ValidateZip(string filePath) + { + ErrorContainer result = null; + if (!System.IO.File.Exists(filePath)) + return new ErrorContainer("error_file_not_found"); + + try + { + using (var archive = ZipFile.OpenRead(filePath)) + { + List files = archive.Entries.Where(x => x.FullName == JOB_MAIN_FILENAME || x.FullName == JOB_METADATA_FILENAME).ToList(); + + if (files.Count() < 2) + return new ErrorContainer("error_job_not_valid"); + else + result = null; + } + } + catch (Exception) + { + result = new ErrorContainer("error_job_not_valid"); + } + + return result; + } + #endregion JOB_METHODS } } \ No newline at end of file diff --git a/Client/Browser_Tools/Models/JobToStep.cs b/Client/Browser_Tools/Models/JobToStep.cs index 7118f1f9..48a835a0 100644 --- a/Client/Browser_Tools/Models/JobToStep.cs +++ b/Client/Browser_Tools/Models/JobToStep.cs @@ -12,11 +12,13 @@ namespace CMS_Client.Browser_Tools.Models public string name; public DateTime lastEditTimestamp; public string isoMainProgram; - public Metas metadata; + public Metas metadata; + public List partPrograms; public JobToStep() { metadata = new Metas(); + partPrograms = new List(); } } } diff --git a/Client/Browser_Tools/Models/Metadata/CustomParam.cs b/Client/Browser_Tools/Models/Metadata/CustomParam.cs index 13774abc..efe1dd16 100644 --- a/Client/Browser_Tools/Models/Metadata/CustomParam.cs +++ b/Client/Browser_Tools/Models/Metadata/CustomParam.cs @@ -8,10 +8,10 @@ namespace CMS_Client.Browser_Tools.Models.Metadata { public class CustomParam { - public string Name; - public string Type; + public string name; + public string type; public List selectionList; - public int Value; + public int value; public CustomParam() { diff --git a/Client/Browser_Tools/Models/Metadata/GenericsParam.cs b/Client/Browser_Tools/Models/Metadata/GenericsParam.cs index d18ba2ae..a4262461 100644 --- a/Client/Browser_Tools/Models/Metadata/GenericsParam.cs +++ b/Client/Browser_Tools/Models/Metadata/GenericsParam.cs @@ -9,8 +9,8 @@ namespace CMS_Client.Browser_Tools.Models.Metadata public class GenericsParam { public List images; - public string Description; - public TimeSpan ExecutionTime; + public string description; + public TimeSpan executionTime; public GenericsParam() { diff --git a/Client/Browser_Tools/Models/MetadataToFile.cs b/Client/Browser_Tools/Models/MetadataToFile.cs index d17d5706..673460c9 100644 --- a/Client/Browser_Tools/Models/MetadataToFile.cs +++ b/Client/Browser_Tools/Models/MetadataToFile.cs @@ -9,15 +9,15 @@ namespace CMS_Client.Browser_Tools.Models { public class MetadataToFile { - public string Description; - public TimeSpan ExecutionTime; - public List Tools; - public List Customs; + public string description; + public TimeSpan executionTime; + public List tools; + public List customs; public MetadataToFile() { - Tools = new List(); - Customs = new List(); + tools = new List(); + customs = new List(); } } } diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index 3f9c1e98..a9172a69 100644 Binary files a/Libs/CMS_CORE_Library.dll and b/Libs/CMS_CORE_Library.dll differ diff --git a/Step.Config/Config/maintenancesConfig.xml b/Step.Config/Config/maintenancesConfig.xml index 959d0e61..12697b84 100644 --- a/Step.Config/Config/maintenancesConfig.xml +++ b/Step.Config/Config/maintenancesConfig.xml @@ -1,35 +1,173 @@  - - 1 - - Manutenzione scaduta - Manutenzione scaduta - - 10 - 15/06/2018 13:00 - EXP_DATE - - Test 2 - Ita 2 - - D - 2 - - - 2 - - Test 2 - Ita 2 - - 1000 - 15/07/2018 13:00 - MACHINE_INTERVAL - - Test 2 - Ita 2 - - mm - 1 - + + 1 + + 5-Axis operating-unit management + Gestione gruppo operatore 5 assi + + 2000 + 15/07/2018 13:00 + MACHINE_INTERVAL + + Replace air/liquid seals of rotary axis joint + Sostituire tenute aria/liquido giunto assi rotanti + + mm + 1 + + + + 2 + + Transmission member check + Gestione Organi di trasmissione + + 2000 + 15/07/2018 13:00 + MACHINE_INTERVAL + + Transmission members check + Necessary control of all transmission system + + mm + 1 + + + + 3 + + Mechanical/electrical safety systems + Sistemi di sicurezza meccanici/elettrici + + 2000 + 15/07/2018 13:00 + MACHINE_INTERVAL + + Necessary control of mechanical/electrical safety systems + Necessario controllo di tutti i sistemi di sicurezza meccanici/elettrici presenti in macchina + + mm + 1 + + + + 4 + + Check of axis geometry + Controllo geometria assi + + 2000 + 15/07/2018 13:00 + MACHINE_INTERVAL + + Necessary control of axis geometry + Necessario controllo della corretta geometria assi + + mm + 1 + + + + 5 + + Machine System check + Controllo impianti macchina necessario + + 2000 + 15/07/2018 13:00 + MACHINE_INTERVAL + + Necessary control Electric / Mechanical / Pneumatic Systems + Necessario controllo impianti Elettrico / Meccanico / Pneumatico + + mm + 1 + + + + 6 + + Tool holder clamps management + Gestione manine portautensili + + 4000 + 15/07/2018 13:00 + MACHINE_INTERVAL + + Replace composite material tool holder clamps + Sostituire manine portautensili in materiale composito + + mm + 1 + + + + 7 + + Balancing cylinders management + Gestione cilindri di bilanciamento + + 4000 + 15/07/2018 13:00 + MACHINE_INTERVAL + + Replace seals on balancing cylinders + Sostituire tenute su cilindri di bilanciamento + + mm + 1 + + + + 8 + + Lower-grinder servicing necessary + Revisione mola inferiore necessaria + + 4000 + 15/07/2018 13:00 + MACHINE_INTERVAL + + Execute spindle service of Lower-grinder + Eseguire revisione al mandrino della mola inferiore + + mm + 2 + + + + 9 + + Upper-grinder servicing necessary + Revisione mola superiore necessaria + + 4000 + 15/07/2018 13:00 + MACHINE_INTERVAL + + Execute spindle service of Upper-grinder + Eseguire revisione al mandrino della mola superiore + + mm + 3 + + + + 10 + + Drill servicing necessary + Revisione foratore necessario + + 4000 + 15/07/2018 13:00 + MACHINE_INTERVAL + + Execute spindle service of the driller + Eseguire revisione al mandrino del foratore + + mm + 4 + + \ No newline at end of file diff --git a/Step.Core/ThreadsFunctions.cs b/Step.Core/ThreadsFunctions.cs index 5866733c..2a9be059 100644 --- a/Step.Core/ThreadsFunctions.cs +++ b/Step.Core/ThreadsFunctions.cs @@ -1,4 +1,5 @@ -using Step.Core; +using CMS_CORE_Library.Models; +using Step.Core; using Step.Model.DTOModels; using Step.Model.DTOModels.ToolModels; using Step.NC; @@ -6,7 +7,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Threading; using TeamDev.SDK.MVVM; -using static CMS_CORE_Library.DataStructures; using static Step.Model.Constants; using static Step.Utils.ExceptionManager; diff --git a/Step.Database/Controllers/FunctionsAccessController.cs b/Step.Database/Controllers/FunctionsAccessController.cs index 5f19b197..8afbb200 100644 --- a/Step.Database/Controllers/FunctionsAccessController.cs +++ b/Step.Database/Controllers/FunctionsAccessController.cs @@ -3,7 +3,7 @@ using Step.Model.DTOModels; using System; using System.Collections.Generic; using System.Linq; -using static CMS_CORE_Library.DataStructures; +using static CMS_CORE_Library.Models.DataStructures; using static Step.Config.ServerConfig; namespace Step.Database.Controllers diff --git a/Step.Model/Constants.cs b/Step.Model/Constants.cs index 12d19947..2873795d 100644 --- a/Step.Model/Constants.cs +++ b/Step.Model/Constants.cs @@ -6,17 +6,6 @@ namespace Step.Model { public static class Constants { - public static readonly string[] VALID_FILE_EXTENSIONS = { "", ".txt", ".cnc", ".ini", ".mpf", ".spf" }; - public static readonly string[] VALID_IMAGE_EXTENSIONS = { ".jpg", ".jpeg", ".png" }; - public const double EPSILON = 0.001; - public static string QUEUE_FILE_NAME = "pp"; - public const string JOB_MAIN_FILENAME = "main.cnc"; - public const string JOB_METADATA_FILENAME = "metadata.json"; - - public static String JOB_OPENING_PATH = BASE_PATH + "TempJob\\"; - - - public enum ROLE_IDS { CMS_SERVICE_ONLY = 1, @@ -213,10 +202,19 @@ namespace Step.Model } // File paths - public const string MAINTENANCE_ATTACHMENT_PATH = "C:\\CMS\\STEP\\attachment\\"; - public const string TEMP_FILE = @"C:\CMS\STEP\tmp\pp\"; - public const string JOB_TMP_DIRECTORY = @"C:\CMS\STEP\tmp\pp\job\"; - public const string QUEUE_TMP_FILE = @"C:\CMS\STEP\tmp\pp\queue\"; - public const string PART_PRG_IMAGES = @"C:\CMS\STEP\pp_img/"; + public const string MAINTENANCE_ATTACHMENT_PATH = @"C:\CMS\STEP\attachment\"; + public const string TEMP_FOLDER = @"C:\CMS\STEP\TMP\"; + public const string TEMP_PP_FOLDER = TEMP_FOLDER + @"pp\"; + public const string JOB_TMP_DIRECTORY = TEMP_PP_FOLDER + @"job\"; + public const string QUEUE_TMP_FOLDER = TEMP_PP_FOLDER + @"queue\"; + public const string PART_PRG_IMAGES = @"C:\CMS\STEP\pp_img\"; + + public static readonly string[] VALID_FILE_EXTENSIONS = { "", ".txt", ".cnc", ".ini", ".mpf", ".spf" }; + public static readonly string[] VALID_IMAGE_EXTENSIONS = { ".jpg", ".jpeg", ".png" }; + public const double EPSILON = 0.001; + public static string QUEUE_FILE_NAME = "pp"; + public const string JOB_MAIN_FILENAME = "main.cnc"; + public const string JOB_METADATA_FILENAME = "metadata.json"; + public static string[] JOB_EXTENSIONS = { ".job", ".zip" }; } } diff --git a/Step.Model/DTOModels/DTOActiveProgramInfoModel.cs b/Step.Model/DTOModels/DTOActiveProgramInfoModel.cs index cf8cdc03..6a1d07d2 100644 --- a/Step.Model/DTOModels/DTOActiveProgramInfoModel.cs +++ b/Step.Model/DTOModels/DTOActiveProgramInfoModel.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static CMS_CORE_Library.DataStructures; +using System.Linq; +using static CMS_CORE_Library.Models.DataStructures; namespace Step.Model.DTOModels { @@ -17,7 +13,7 @@ namespace Step.Model.DTOModels if (Path != item.Path) return false; - if(IsoLines != null && item.IsoLines != null) + if (IsoLines != null && item.IsoLines != null) if (!IsoLines.SequenceEqual(item.IsoLines)) return false; @@ -27,4 +23,4 @@ namespace Step.Model.DTOModels return true; } } -} +} \ No newline at end of file diff --git a/Step.Model/DTOModels/DTOAlarmsModel.cs b/Step.Model/DTOModels/DTOAlarmsModel.cs index faabb08b..2c914f23 100644 --- a/Step.Model/DTOModels/DTOAlarmsModel.cs +++ b/Step.Model/DTOModels/DTOAlarmsModel.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using static CMS_CORE_Library.DataStructures; +using static CMS_CORE_Library.Models.DataStructures; namespace Step.Model.DTOModels { diff --git a/Step.Model/DTOModels/DTOAxisNameModel.cs b/Step.Model/DTOModels/DTOAxisNameModel.cs index 4df395f4..3e896fc6 100644 --- a/Step.Model/DTOModels/DTOAxisNameModel.cs +++ b/Step.Model/DTOModels/DTOAxisNameModel.cs @@ -1,4 +1,4 @@ -using static CMS_CORE_Library.DataStructures; +using static CMS_CORE_Library.Models.DataStructures; namespace Step.Model.DTOModels { diff --git a/Step.Model/DTOModels/DTOPowerOnDataModel.cs b/Step.Model/DTOModels/DTOPowerOnDataModel.cs index 94ffb6fe..3e746a7b 100644 --- a/Step.Model/DTOModels/DTOPowerOnDataModel.cs +++ b/Step.Model/DTOModels/DTOPowerOnDataModel.cs @@ -1,4 +1,5 @@ -using static CMS_CORE_Library.DataStructures; +using CMS_CORE_Library.Models; +using static CMS_CORE_Library.Models.DataStructures; namespace Step.Model.DTOModels { diff --git a/Step.Model/DTOModels/DTOProcessDataModel.cs b/Step.Model/DTOModels/DTOProcessDataModel.cs index 739fcffe..592ce9fa 100644 --- a/Step.Model/DTOModels/DTOProcessDataModel.cs +++ b/Step.Model/DTOModels/DTOProcessDataModel.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Linq; -using static CMS_CORE_Library.DataStructures; +using static CMS_CORE_Library.Models.DataStructures; namespace Step.Model.DTOModels { diff --git a/Step.Model/DTOModels/DTOQueueModel.cs b/Step.Model/DTOModels/DTOQueueModel.cs index 4b0586b3..30aa3887 100644 --- a/Step.Model/DTOModels/DTOQueueModel.cs +++ b/Step.Model/DTOModels/DTOQueueModel.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static CMS_CORE_Library.DataStructures; -using static Step.Model.Constants; +using static Step.Model.Constants; namespace Step.Model.DTOModels { @@ -14,7 +8,7 @@ namespace Step.Model.DTOModels public string PartProgramName { get; set; } - public int Reps { get; set; } + public int Reps { get; set; } public int RemainingReps { get; set; } @@ -36,7 +30,7 @@ namespace Step.Model.DTOModels if (Reps != item.Reps) return false; - + if (RemainingReps != item.RemainingReps) return false; @@ -46,4 +40,4 @@ namespace Step.Model.DTOModels return true; } } -} +} \ No newline at end of file diff --git a/Step.Model/DTOModels/JobModels/DTOGenericParamModel.cs b/Step.Model/DTOModels/JobModels/DTOGenericParamModel.cs index 7bc3f4ec..5b889381 100644 --- a/Step.Model/DTOModels/JobModels/DTOGenericParamModel.cs +++ b/Step.Model/DTOModels/JobModels/DTOGenericParamModel.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Step.Model.DTOModels.JobModels { @@ -17,4 +14,4 @@ namespace Step.Model.DTOModels.JobModels Images = new List(); } } -} +} \ No newline at end of file diff --git a/Step.Model/DTOModels/JobModels/DTOImageParamModel.cs b/Step.Model/DTOModels/JobModels/DTOImageParamModel.cs index 25524b03..c01d8eb0 100644 --- a/Step.Model/DTOModels/JobModels/DTOImageParamModel.cs +++ b/Step.Model/DTOModels/JobModels/DTOImageParamModel.cs @@ -1,14 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Step.Model.DTOModels.JobModels +namespace Step.Model.DTOModels.JobModels { public class DTOImageParamModel { public string Name; public string Base64; } -} +} \ No newline at end of file diff --git a/Step.Model/DTOModels/JobModels/DTOJobCustomParamModel.cs b/Step.Model/DTOModels/JobModels/DTOJobCustomParamModel.cs index e6ba277f..797f55a4 100644 --- a/Step.Model/DTOModels/JobModels/DTOJobCustomParamModel.cs +++ b/Step.Model/DTOModels/JobModels/DTOJobCustomParamModel.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Step.Model.DTOModels.JobModels { @@ -18,4 +14,4 @@ namespace Step.Model.DTOModels.JobModels SelectionList = new List(); } } -} +} \ No newline at end of file diff --git a/Step.Model/DTOModels/JobModels/DTOJobModel.cs b/Step.Model/DTOModels/JobModels/DTOJobModel.cs index c885fb21..03e0d3d5 100644 --- a/Step.Model/DTOModels/JobModels/DTOJobModel.cs +++ b/Step.Model/DTOModels/JobModels/DTOJobModel.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Step.Model.DTOModels.JobModels { @@ -12,10 +9,12 @@ namespace Step.Model.DTOModels.JobModels public DateTime LastEditTimestamp; public string IsoMainProgram; public DTOMetadataModel Metadata; + public List PartPrograms; public DTOJobModel() { Metadata = new DTOMetadataModel(); + PartPrograms = new List(); } } -} +} \ No newline at end of file diff --git a/Step.Model/DTOModels/JobModels/DTOMetadataFieldsModel.cs b/Step.Model/DTOModels/JobModels/DTOMetadataFieldsModel.cs index 248b3ffc..c7d94987 100644 --- a/Step.Model/DTOModels/JobModels/DTOMetadataFieldsModel.cs +++ b/Step.Model/DTOModels/JobModels/DTOMetadataFieldsModel.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Step.Model.DTOModels.JobModels { @@ -19,4 +16,4 @@ namespace Step.Model.DTOModels.JobModels Customs = new List(); } } -} +} \ No newline at end of file diff --git a/Step.Model/DTOModels/JobModels/DTOMetadataModel.cs b/Step.Model/DTOModels/JobModels/DTOMetadataModel.cs index 7a0db8a7..c44563a1 100644 --- a/Step.Model/DTOModels/JobModels/DTOMetadataModel.cs +++ b/Step.Model/DTOModels/JobModels/DTOMetadataModel.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Step.Model.DTOModels.JobModels { @@ -19,4 +15,4 @@ namespace Step.Model.DTOModels.JobModels Customs = new List(); } } -} +} \ No newline at end of file diff --git a/Step.Model/DTOModels/ToolModels/DTOEdgeModel.cs b/Step.Model/DTOModels/ToolModels/DTOEdgeModel.cs index 0baae4d0..10c26698 100644 --- a/Step.Model/DTOModels/ToolModels/DTOEdgeModel.cs +++ b/Step.Model/DTOModels/ToolModels/DTOEdgeModel.cs @@ -1,6 +1,6 @@ -using System.Collections.Generic; +using CMS_CORE_Library.Models; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using static CMS_CORE_Library.DataStructures; namespace Step.Model.DTOModels.ToolModels { diff --git a/Step.Model/DTOModels/ToolModels/DTOMagazineStatusModel.cs b/Step.Model/DTOModels/ToolModels/DTOMagazineStatusModel.cs index fc3e8a69..585dc9c0 100644 --- a/Step.Model/DTOModels/ToolModels/DTOMagazineStatusModel.cs +++ b/Step.Model/DTOModels/ToolModels/DTOMagazineStatusModel.cs @@ -1,4 +1,5 @@ -using static CMS_CORE_Library.DataStructures; +using CMS_CORE_Library.Models; +using static CMS_CORE_Library.Models.DataStructures; namespace Step.Model.DTOModels.ToolModels { diff --git a/Step.Model/DTOModels/ToolModels/DTONcShankModel.cs b/Step.Model/DTOModels/ToolModels/DTONcShankModel.cs index 5bcf91c3..019c771d 100644 --- a/Step.Model/DTOModels/ToolModels/DTONcShankModel.cs +++ b/Step.Model/DTOModels/ToolModels/DTONcShankModel.cs @@ -1,10 +1,6 @@ using Step.Model.DatabaseModels; -using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Step.Model.DTOModels.ToolModels { @@ -80,4 +76,4 @@ namespace Step.Model.DTOModels.ToolModels }; } } -} +} \ No newline at end of file diff --git a/Step.Model/DTOModels/ToolModels/DTONcToolModel.cs b/Step.Model/DTOModels/ToolModels/DTONcToolModel.cs index 2094e45e..442ee711 100644 --- a/Step.Model/DTOModels/ToolModels/DTONcToolModel.cs +++ b/Step.Model/DTOModels/ToolModels/DTONcToolModel.cs @@ -1,8 +1,7 @@ -using Step.Model.DatabaseModels; -using System; +using CMS_CORE_Library.Models; +using Step.Model.DatabaseModels; using System.Collections; using System.ComponentModel.DataAnnotations; -using static CMS_CORE_Library.DataStructures; namespace Step.Model.DTOModels.ToolModels { diff --git a/Step.Model/DTOModels/ToolModels/DTOShankModel.cs b/Step.Model/DTOModels/ToolModels/DTOShankModel.cs index 2c12f73c..3dc7e1b0 100644 --- a/Step.Model/DTOModels/ToolModels/DTOShankModel.cs +++ b/Step.Model/DTOModels/ToolModels/DTOShankModel.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; +using CMS_CORE_Library.Models; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; -using static CMS_CORE_Library.DataStructures; namespace Step.Model.DTOModels.ToolModels { diff --git a/Step.Model/DTOModels/ToolModels/DTOSiemensToolModel.cs b/Step.Model/DTOModels/ToolModels/DTOSiemensToolModel.cs index cec33a4d..3ffe525d 100644 --- a/Step.Model/DTOModels/ToolModels/DTOSiemensToolModel.cs +++ b/Step.Model/DTOModels/ToolModels/DTOSiemensToolModel.cs @@ -1,5 +1,6 @@ -using System.ComponentModel.DataAnnotations; -using static CMS_CORE_Library.DataStructures; +using CMS_CORE_Library.Models; +using System.ComponentModel.DataAnnotations; +using static CMS_CORE_Library.Models.DataStructures; namespace Step.Model.DTOModels.ToolModels { diff --git a/Step.Model/DatabaseModels/NcFamilyModel.cs b/Step.Model/DatabaseModels/NcFamilyModel.cs index 9519649d..68cb7f7d 100644 --- a/Step.Model/DatabaseModels/NcFamilyModel.cs +++ b/Step.Model/DatabaseModels/NcFamilyModel.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; +using CMS_CORE_Library.Models; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using static CMS_CORE_Library.DataStructures; namespace Step.Model.DatabaseModels { diff --git a/Step.Model/DatabaseModels/NcMagazinePositionModel.cs b/Step.Model/DatabaseModels/NcMagazinePositionModel.cs index f020eeb4..1f651fb0 100644 --- a/Step.Model/DatabaseModels/NcMagazinePositionModel.cs +++ b/Step.Model/DatabaseModels/NcMagazinePositionModel.cs @@ -1,6 +1,8 @@ -using System.ComponentModel.DataAnnotations; +using System; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using static CMS_CORE_Library.DataStructures; +using CMS_CORE_Library.Models; +using static CMS_CORE_Library.Models.NcMagazinePositionModel; namespace Step.Model.DatabaseModels { diff --git a/Step.Model/DatabaseModels/NcShankModel.cs b/Step.Model/DatabaseModels/NcShankModel.cs index fac661fe..184f8cb4 100644 --- a/Step.Model/DatabaseModels/NcShankModel.cs +++ b/Step.Model/DatabaseModels/NcShankModel.cs @@ -1,7 +1,8 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using static CMS_CORE_Library.DataStructures; +using CMS_CORE_Library.Models; namespace Step.Model.DatabaseModels { diff --git a/Step.Model/DatabaseModels/NcToolModel.cs b/Step.Model/DatabaseModels/NcToolModel.cs index ded54d50..7b52ca22 100644 --- a/Step.Model/DatabaseModels/NcToolModel.cs +++ b/Step.Model/DatabaseModels/NcToolModel.cs @@ -1,6 +1,6 @@ -using System.ComponentModel.DataAnnotations; +using CMS_CORE_Library.Models; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using static CMS_CORE_Library.DataStructures; namespace Step.Model.DatabaseModels { diff --git a/Step.NC/NcHandler.cs b/Step.NC/NcHandler.cs index cf1ee157..a7ae52cf 100644 --- a/Step.NC/NcHandler.cs +++ b/Step.NC/NcHandler.cs @@ -1,11 +1,13 @@ -using CMS_CORE; -using CMS_CORE.Demo; -using CMS_CORE.Fanuc; -using CMS_CORE.Osai; -using CMS_CORE.Siemens; +using CMS_CORE_Library; +using CMS_CORE_Library.Demo; +using CMS_CORE_Library.Fanuc; +using CMS_CORE_Library.Models; +using CMS_CORE_Library.Osai; +using CMS_CORE_Library.Siemens; using Step.Database.Controllers; using Step.Model.DatabaseModels; using Step.Model.DTOModels; +using Step.Model.DTOModels.JobModels; using Step.Model.DTOModels.MaintenanceModels; using Step.Model.DTOModels.ToolModels; using Step.Utils; @@ -15,17 +17,17 @@ using System.Data.Entity; using System.Globalization; using System.IO; using System.Linq; -using static CMS_CORE_Library.DataStructures; +using static CMS_CORE_Library.Models.DataStructures; using static Step.Config.ServerConfig; -using static Step.Model.Constants; using static Step.Database.Controllers.QueueController; +using static Step.Model.Constants; namespace Step.NC { public class NcHandler : IDisposable { public Nc numericalControl; - + public NcHandler() { // Choose NC @@ -85,13 +87,57 @@ namespace Step.NC return numericalControl.FILES_RGetFileInfo(path, ref fileInfo); } + public CmsError GetActiveFileInfo(string path, out InfoFile fileInfo) + { + fileInfo = new InfoFile(); + + PROGRAM_TYPE_ENUM program = PROGRAM_TYPE_ENUM.NONE; + CmsError cmsError = numericalControl.FILES_RGetProgramType(ref program); + if (cmsError.IsError()) + return cmsError; + + // If the program is a job + if (program == PROGRAM_TYPE_ENUM.JOB) + { + ushort selectedProcess = 0; + cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); + if (cmsError.IsError()) + return cmsError; + + + string jobFolderPath = JOB_TMP_DIRECTORY + "\\" + selectedProcess + "\\"; + + DTOJobModel model = SupportFunctions.ReadExtractedJobMetadata(selectedProcess); + if (model == null) + return FILE_NOT_FOUND_ERROR; + + string base64Img = model.Metadata.Generics.Images.Count() > 0 ? model.Metadata.Generics.Images[0].Base64 : ""; + + fileInfo = new InfoFile() + { + AbsolutePath = path, + Content = model.IsoMainProgram.Split('\n').ToList(), + PreviewBase64 = base64Img + }; + + return NO_ERROR; + } + else + { + if (File.Exists(path)) + return GetQueueFileInfo(path, out fileInfo); + else + return numericalControl.FILES_RGetFileInfo(path, ref fileInfo); + } + } + public CmsError GetQueueFileInfo(string path, out InfoFile fileInfo) { FileInfo fileData = new FileInfo(path); StreamReader fileRead = new StreamReader(path); int count = 0; string line = ""; - + fileInfo = new InfoFile() { Name = fileData.Name, @@ -205,25 +251,34 @@ namespace Step.NC { programData = new ActiveProgramDataModel(); - // Upload to NC - CmsError cmsError = UploadPartProgram(localPath, fileName, out string newFilePath); - if (cmsError.IsError()) - return cmsError; - // Get selectedProcess id ushort selectedProcess = 0; - cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); + CmsError cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); if (cmsError.IsError()) return cmsError; - // Activate updated program - return numericalControl.FILES_WSetActiveProgram(selectedProcess, newFilePath, ref programData); - } + if (!JOB_EXTENSIONS.Contains(Path.GetExtension(fileName))) + { + // Upload to NC + cmsError = UploadPartProgram(localPath, fileName, out string newFilePath); + if (cmsError.IsError()) + return cmsError; + + // Activate updated program + return numericalControl.FILES_WSetActiveProgram(selectedProcess, newFilePath, ref programData); + } + else + { + DTOJobModel job = SupportFunctions.UnpackJobAndReadMetadata(localPath + fileName, selectedProcess); + return numericalControl.FILES_WUploadJobFilesAndActivate(selectedProcess, JOB_TMP_DIRECTORY, JOB_MAIN_FILENAME); + } + } + public CmsError UploadPartProgramAndAddToQueue(string localPath, string fileName, int reps, out DTOQueueModel queueItem) { queueItem = new DTOQueueModel(); - + // Get selectedProcess id ushort selectedProcess = 0; CmsError cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); @@ -248,7 +303,6 @@ namespace Step.NC // Add new process to PartProgramQueue[selectedProcess].Add(queueItem); - using (QueueController queueController = new QueueController()) { queueController.UpdateQueue(); @@ -259,12 +313,12 @@ namespace Step.NC public CmsError UpdateQueue() { - // Get selectedProcess id + // Get queue data List queueData = new List(); CmsError cmsError = numericalControl.FILES_RQueueData(ref queueData); - foreach(var item in queueData) + foreach (var item in queueData) { if (!QueueRunningIndexes.ContainsKey(item.ProcessId)) QueueRunningIndexes.Add(item.ProcessId, 0); @@ -286,16 +340,31 @@ namespace Step.NC // Set as finished actualItem.RemainingReps = 0; actualItem.Status = QUEUE_ITEM_STATUS.FINISHED; + + //while(PartProgramQueue[item.ProcessId].ElementAtOrDefault(QueueRunningIndexes[item.ProcessId] + 1) != null && !File.Exists(PartProgramQueue[item.ProcessId][QueueRunningIndexes[item.ProcessId]].AbsolutePath)) + //{ + // QueueRunningIndexes[item.ProcessId] += 1; + //} + if (PartProgramQueue[item.ProcessId].ElementAtOrDefault(QueueRunningIndexes[item.ProcessId] + 1) != null) // if next part program exists, set next pp as current pp QueueRunningIndexes[item.ProcessId] += 1; - // Change part program - cmsError = numericalControl - .FILES_WLoadNextPartProgram( - PartProgramQueue[item.ProcessId][QueueRunningIndexes[item.ProcessId]].AbsolutePath, - QUEUE_FILE_NAME - ); + // Check if file is a valid job + if (SupportFunctions.IsValidJob(PartProgramQueue[item.ProcessId][QueueRunningIndexes[item.ProcessId]].AbsolutePath)) + { + // Unpack job + DTOJobModel job = SupportFunctions.UnpackJobAndReadMetadata(PartProgramQueue[item.ProcessId][QueueRunningIndexes[item.ProcessId]].AbsolutePath, item.ProcessId); + // Load JOB to NC + return numericalControl.FILES_WUploadJobFilesAndActivate(item.ProcessId, JOB_TMP_DIRECTORY + "\\" + item.ProcessId + "\\", JOB_MAIN_FILENAME); + } + else + // Upload & activate new part program + cmsError = numericalControl + .FILES_WLoadNextPartProgram( + PartProgramQueue[item.ProcessId][QueueRunningIndexes[item.ProcessId]].AbsolutePath, + QUEUE_FILE_NAME + ); if (cmsError.IsError()) return cmsError; @@ -303,8 +372,8 @@ namespace Step.NC } } } - - // Check if queue exists for the process + + // Check if queue exists for the process if (PartProgramQueue.ContainsKey(item.ProcessId) && PartProgramQueue[item.ProcessId].ElementAtOrDefault(QueueRunningIndexes[item.ProcessId]) != null) { // Set status based on queue status @@ -317,16 +386,11 @@ namespace Step.NC if (item.Status == QUEUE_STATUS.WAITING_OPERATOR) PartProgramQueue[item.ProcessId][QueueRunningIndexes[item.ProcessId]].Status = QUEUE_ITEM_STATUS.WAITING_OPERATOR; } - } - // Update data - //using (QueueController queueController = new QueueController()) - //{ - // queueController.UpdateQueue(); - //} + } return NO_ERROR; } - + public CmsError GetSelectedProcessQueue(out List queueList) { queueList = new List(); @@ -396,15 +460,15 @@ namespace Step.NC return INCORRECT_PARAMETERS_ERROR; var item = PartProgramQueue[processId][itemId]; - // Remove item in the old positions + // Remove item in the old positions PartProgramQueue[processId].RemoveAt(itemId); // Add in the new position PartProgramQueue[processId].Insert(newIndex, item); - + // Fix new ids for (int i = 0; i < PartProgramQueue[processId].Count(); i++) PartProgramQueue[processId][i].Id = i + 1; - + using (QueueController queueController = new QueueController()) queueController.UpdateQueueIdsAndSave(processId); @@ -451,12 +515,14 @@ namespace Step.NC if (tmpQueueItem != null) PartProgramQueue[processId].Remove(tmpQueueItem); + + if (File.Exists(tmpQueueItem.AbsolutePath)) + File.Delete(tmpQueueItem.AbsolutePath); } // Update database data using (QueueController queueController = new QueueController()) queueController.UpdateQueueIdsAndSave(processId); - return NO_ERROR; } @@ -466,11 +532,16 @@ namespace Step.NC // Check if there is a queue if (PartProgramQueue.ContainsKey(processId)) PartProgramQueue[processId] = new List(); - + // Update db using (QueueController queueController = new QueueController()) queueController.UpdateQueue(); + // Clean directory + SupportFunctions.EmptyFolder(JOB_TMP_DIRECTORY); + + QueueRunningIndexes[processId] = 0; + return NO_ERROR; } @@ -1292,7 +1363,7 @@ namespace Step.NC config.ToolsConfiguration = config.ToolsConfiguration.Concat(config.FamiliesConfiguration.FamilyReadOnlyConfiguration).ToList(); } - if(!ToolManagerConfig.OffsetOpt) + if (!ToolManagerConfig.OffsetOpt) config.OffsetOptionActive = false; if (!ToolManagerConfig.OffsetOpt) @@ -1443,7 +1514,7 @@ namespace Step.NC public CmsError SetActiveScreen(short screen) { // Set to true power on data by id - return numericalControl.NC_SetScreenVisible((Nc.SCREEN_PAGE) screen); + return numericalControl.NC_SetScreenVisible((Nc.SCREEN_PAGE)screen); } #endregion Write data @@ -1628,7 +1699,6 @@ namespace Step.NC { DbNcToolModel ncTool = toolsManager.AddTool(tool, toolId); - if (!ToolManagerConfig.OffsetOpt) { CmsError cmsError = UpdateToolOffsetId(ncTool.ToolId, 1, ncTool.ToolId, out DTONcToolModel toolWithOffset); @@ -1640,7 +1710,6 @@ namespace Step.NC GetToolData(ncTool, ref dtoTool); - return NO_ERROR; } } diff --git a/Step.Utils/languages/IT.xml b/Step.Utils/languages/IT.xml index 652eba68..bc1799c1 100644 --- a/Step.Utils/languages/IT.xml +++ b/Step.Utils/languages/IT.xml @@ -115,7 +115,7 @@ Msg - Tool Manager + Gestore Utensili Magazzino Mandrino Utensili @@ -496,6 +496,7 @@ Modifica Manutenzione + Gestore della produzione CMS CNC Softkey Preferite diff --git a/Step.Utils/languages/en.xml b/Step.Utils/languages/en.xml index 701502bb..d091f150 100644 --- a/Step.Utils/languages/en.xml +++ b/Step.Utils/languages/en.xml @@ -495,6 +495,7 @@ Edit Maintenance + Production manager CMS CNC Favorite Softkey diff --git a/Step.Utils/supportFunctions.cs b/Step.Utils/supportFunctions.cs index 0710a897..5897bb3d 100644 --- a/Step.Utils/supportFunctions.cs +++ b/Step.Utils/supportFunctions.cs @@ -129,37 +129,41 @@ namespace Step.Utils return 1; } - public static DTOJobModel UnpackJobAndReadMetadata(string path) + public static DTOJobModel UnpackJobAndReadMetadata(string filePath, int processId) { DTOJobModel job = new DTOJobModel(); + string jobFolderPath = JOB_TMP_DIRECTORY + "\\" + processId + "\\"; + if (!Directory.Exists(jobFolderPath)) + Directory.CreateDirectory(jobFolderPath); + // Check if job exists - if (!File.Exists(path)) + if (!File.Exists(filePath)) return null; - EmptyFolder(path); - - string fileName = Path.GetFileName(path); - - using (ZipArchive zipExtractor = ZipFile.OpenRead(fileName)) + EmptyFolder(jobFolderPath); + + using (ZipArchive zipExtractor = ZipFile.OpenRead(filePath)) { // Setup main job fields - job.Name = Path.GetFileName(fileName); - job.LastEditTimestamp = new FileInfo(fileName).LastAccessTime; + job.Name = Path.GetFileName(filePath); + job.LastEditTimestamp = new FileInfo(filePath).LastAccessTime; foreach (ZipArchiveEntry entry in zipExtractor.Entries) { + // Extract file + entry.ExtractToFile(jobFolderPath + entry.Name, true); + // Get main program content if (entry.Name.Equals(JOB_MAIN_FILENAME, StringComparison.OrdinalIgnoreCase)) { using (var reader = new StreamReader(entry.Open())) job.IsoMainProgram = (reader.ReadToEnd()); } - // Read images else if (VALID_IMAGE_EXTENSIONS.Contains(Path.GetExtension(entry.Name).ToLower())) { var bytes = default(byte[]); - entry.ExtractToFile(JOB_OPENING_PATH + entry.Name, true); + // Populate metadata using (var memstream = new MemoryStream()) { entry.Open().CopyTo(memstream); @@ -194,7 +198,9 @@ namespace Step.Utils } // Consider other file as part program else - entry.ExtractToFile(JOB_OPENING_PATH + entry.Name, true); + { + job.PartPrograms.Add(jobFolderPath + entry.Name); + } } return job; @@ -209,5 +215,87 @@ namespace Step.Utils foreach (DirectoryInfo dir in di.GetDirectories()) dir.Delete(true); } + + public static bool IsValidJob(string filePath) + { + if (!File.Exists(filePath)) + return false; + + try + { + using (var archive = ZipFile.OpenRead(filePath)) + { + // Find key files + List files = archive + .Entries + .Where(x => x.FullName == JOB_MAIN_FILENAME || x.FullName == JOB_METADATA_FILENAME) + .ToList(); + // if there aren't both + if (files.Count() < 2) + return false; + else + return true; + } + } + catch (Exception) + { + return false; + } + } + + public static DTOJobModel ReadExtractedJobMetadata(int processId) + { + string filePath = JOB_TMP_DIRECTORY + "\\" + processId + "\\"; + if (!Directory.Exists(filePath)) + return null; + + // Setup main Fields + DTOJobModel jobData = new DTOJobModel() + { + Name = Path.GetFileName(filePath), + LastEditTimestamp = new FileInfo(filePath).LastAccessTime + }; + + DirectoryInfo di = new DirectoryInfo(filePath); + foreach (FileInfo file in di.GetFiles()) + { + // Get main program content + if (file.Name.Equals(JOB_MAIN_FILENAME, StringComparison.OrdinalIgnoreCase)) + { + jobData.IsoMainProgram = (File.ReadAllText(file.FullName)); + } + // Get images content without extract files + else if (VALID_IMAGE_EXTENSIONS.Contains(Path.GetExtension(file.Name).ToLower())) + { + byte[] bytes = File.ReadAllBytes(file.FullName); + jobData.Metadata.Generics.Images.Add(new DTOImageParamModel() + { + Name = file.Name, + Base64 = "data:image/" + Path.GetExtension(file.Name).ToLower().TrimStart('.') + ";base64," + Convert.ToBase64String(bytes) + }); + } + // Metadata + else if (file.Name.Equals(JOB_METADATA_FILENAME, StringComparison.OrdinalIgnoreCase)) + { + DTOMetadataFieldsModel metasFromFile = new DTOMetadataFieldsModel(); + + metasFromFile = JsonConvert + .DeserializeObject + (File.ReadAllText(file.FullName)); + + if (metasFromFile == null) + return null; + else + { + jobData.Metadata.Generics.Description = metasFromFile.Description; + jobData.Metadata.Generics.ExecutionTime = metasFromFile.ExecutionTime; + jobData.Metadata.Tools = metasFromFile.Tools; + jobData.Metadata.Customs = metasFromFile.Customs; + } + } + } + + return jobData; + } } } \ No newline at end of file diff --git a/Step/App_Start/Startup.cs b/Step/App_Start/Startup.cs index b3f6053b..c899b894 100644 --- a/Step/App_Start/Startup.cs +++ b/Step/App_Start/Startup.cs @@ -144,8 +144,8 @@ namespace Step.App_Start if (!Directory.Exists(MAINTENANCE_ATTACHMENT_PATH)) Directory.CreateDirectory(MAINTENANCE_ATTACHMENT_PATH); - if (!Directory.Exists(TEMP_FILE)) - Directory.CreateDirectory(TEMP_FILE); + if (!Directory.Exists(TEMP_PP_FOLDER)) + Directory.CreateDirectory(TEMP_PP_FOLDER); if (!Directory.Exists(PART_PRG_IMAGES)) Directory.CreateDirectory(PART_PRG_IMAGES); @@ -153,8 +153,8 @@ namespace Step.App_Start if (!Directory.Exists(JOB_TMP_DIRECTORY)) Directory.CreateDirectory(JOB_TMP_DIRECTORY); - if (!Directory.Exists(QUEUE_TMP_FILE)) - Directory.CreateDirectory(QUEUE_TMP_FILE); + if (!Directory.Exists(QUEUE_TMP_FOLDER)) + Directory.CreateDirectory(QUEUE_TMP_FOLDER); } } } diff --git a/Step/Controllers/SignalR/NcHub.cs b/Step/Controllers/SignalR/NcHub.cs index 6f8d3cd4..9a573766 100644 --- a/Step/Controllers/SignalR/NcHub.cs +++ b/Step/Controllers/SignalR/NcHub.cs @@ -1,10 +1,10 @@ -using Microsoft.AspNet.SignalR; +using CMS_CORE_Library.Models; +using Microsoft.AspNet.SignalR; using Step.Attributes; using Step.NC; using System.Collections.Generic; using System.Threading.Tasks; using TeamDev.SDK.MVVM; -using static CMS_CORE_Library.DataStructures; using static Step.Config.ServerConfig; using static Step.Model.Constants; using static Step.Model.Constants.FUNCTIONALITY_NAMES; diff --git a/Step/Controllers/WebApi/ConfigurationController.cs b/Step/Controllers/WebApi/ConfigurationController.cs index 0605e877..5cd2d144 100644 --- a/Step/Controllers/WebApi/ConfigurationController.cs +++ b/Step/Controllers/WebApi/ConfigurationController.cs @@ -1,12 +1,11 @@ -using Step.Database.Controllers; +using CMS_CORE_Library.Models; +using Step.Database.Controllers; using Step.Model.DTOModels; using Step.NC; using System.Collections.Generic; using System.Linq; using System.Web.Http; -using static CMS_CORE_Library.DataStructures; using static Step.Config.ServerConfig; -using static Step.Model.Constants; namespace Step.Controllers.WebApi { diff --git a/Step/Controllers/WebApi/LanguageController.cs b/Step/Controllers/WebApi/LanguageController.cs index ecc41de6..8c43ae29 100644 --- a/Step/Controllers/WebApi/LanguageController.cs +++ b/Step/Controllers/WebApi/LanguageController.cs @@ -1,9 +1,10 @@ -using Step.Model.DTOModels; +using CMS_CORE_Library.Models; +using Step.Model.DTOModels; using Step.NC; using System.Collections.Generic; using System.Linq; using System.Web.Http; -using static CMS_CORE_Library.DataStructures; +using static CMS_CORE_Library.Models.DataStructures; using static Step.Config.ServerConfig; using static Step.Model.Constants; using static Step.Utils.LanguageController; diff --git a/Step/Controllers/WebApi/MaintenanceController.cs b/Step/Controllers/WebApi/MaintenanceController.cs index 3c3074cb..13c33a84 100644 --- a/Step/Controllers/WebApi/MaintenanceController.cs +++ b/Step/Controllers/WebApi/MaintenanceController.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using CMS_CORE_Library.Models; +using Newtonsoft.Json; using Step.Database.Controllers; using Step.Model.DatabaseModels; using Step.Model.DTOModels.MaintenanceModels; @@ -16,7 +17,6 @@ using System.Threading; using System.Threading.Tasks; using System.Web; using System.Web.Http; -using static CMS_CORE_Library.DataStructures; using static Step.Config.ServerConfig; using static Step.Model.Constants; diff --git a/Step/Controllers/WebApi/NcApiController.cs b/Step/Controllers/WebApi/NcApiController.cs index 35d8f189..26b5d266 100644 --- a/Step/Controllers/WebApi/NcApiController.cs +++ b/Step/Controllers/WebApi/NcApiController.cs @@ -1,8 +1,8 @@ -using Step.Model.DTOModels; +using CMS_CORE_Library.Models; +using Step.Model.DTOModels; using Step.NC; using System.Globalization; using System.Web.Http; -using static CMS_CORE_Library.DataStructures; using static Step.Model.Constants; namespace Step.Controllers.WebApi diff --git a/Step/Controllers/WebApi/NcFileController.cs b/Step/Controllers/WebApi/NcFileController.cs index 9f56d018..b66f9e18 100644 --- a/Step/Controllers/WebApi/NcFileController.cs +++ b/Step/Controllers/WebApi/NcFileController.cs @@ -10,10 +10,11 @@ using static Step.Model.Constants; using System.Text; using System.Threading.Tasks; using System.Web.Http; -using static CMS_CORE_Library.DataStructures; using System.Linq; using static Step.Config.ServerConfig; using System.ComponentModel.DataAnnotations; +using CMS_CORE_Library.Models; +using static CMS_CORE_Library.Models.DataStructures; namespace Step.Controllers.WebApi { @@ -50,6 +51,21 @@ namespace Step.Controllers.WebApi } } + [Route("file/active/info"), HttpGet] + public IHttpActionResult GetActiveFileInfo([FromUri]string filePath) + { + using (NcHandler ncHandler = new NcHandler()) + { + ncHandler.Connect(); + + CmsError cmsError = ncHandler.GetActiveFileInfo(filePath, out InfoFile fileInfo); + if (cmsError.IsError()) + return BadRequest(cmsError.localizationKey); + + return Ok(fileInfo); + } + } + [Route("file/active"), HttpPut] public IHttpActionResult SetActiveProgram([FromUri]string filePath) { @@ -100,9 +116,9 @@ namespace Step.Controllers.WebApi { ncHandler.Connect(); - File.WriteAllBytes(TEMP_FILE + item.FileName, item.Data); + File.WriteAllBytes(TEMP_PP_FOLDER + item.FileName, item.Data); - CmsError cmsError = ncHandler.UploadPartProgramAndActivate(TEMP_FILE, item.FileName, out ActiveProgramDataModel programData); + CmsError cmsError = ncHandler.UploadPartProgramAndActivate(TEMP_PP_FOLDER, item.FileName, out ActiveProgramDataModel programData); if (cmsError.IsError()) return BadRequest(cmsError.localizationKey); } @@ -181,7 +197,7 @@ namespace Step.Controllers.WebApi { ncHandler.Connect(); - File.WriteAllBytes(QUEUE_TMP_FILE + item.FileName, item.Data); + File.WriteAllBytes(QUEUE_TMP_FOLDER + item.FileName, item.Data); // Get reps var repsParam = formItems.Where(x => x.ParameterName == "reps").FirstOrDefault(); @@ -189,7 +205,7 @@ namespace Step.Controllers.WebApi if (repsParam == null || !Int32.TryParse(repsParam.Value, out int reps)) return BadRequest(); - CmsError cmsError = ncHandler.UploadPartProgramAndAddToQueue(QUEUE_TMP_FILE, item.FileName, reps, out queueItem); + CmsError cmsError = ncHandler.UploadPartProgramAndAddToQueue(QUEUE_TMP_FOLDER, item.FileName, reps, out queueItem); if (cmsError.IsError()) return BadRequest(cmsError.localizationKey); } diff --git a/Step/Controllers/WebApi/NcToolManagerController.cs b/Step/Controllers/WebApi/NcToolManagerController.cs index 7cbbc7d1..035783d7 100644 --- a/Step/Controllers/WebApi/NcToolManagerController.cs +++ b/Step/Controllers/WebApi/NcToolManagerController.cs @@ -1,4 +1,5 @@ -using Step.Database.Controllers; +using CMS_CORE_Library.Models; +using Step.Database.Controllers; using Step.Model.DatabaseModels; using Step.Model.DTOModels.ToolModels; using Step.NC; @@ -7,7 +8,6 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web.Http; -using static CMS_CORE_Library.DataStructures; using static Step.Config.ServerConfig; using static Step.Model.Constants; @@ -551,6 +551,8 @@ namespace Step.Controllers.WebApi if (shankId.ShankId == 0) return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS); + DTONcShankModel dtoShank = new DTONcShankModel(); + // Check data DbNcShankModel shank; using (NcToolManagerController toolsManager = new NcToolManagerController()) @@ -586,6 +588,9 @@ namespace Step.Controllers.WebApi if (cmsError.IsError()) return BadRequest(cmsError.localizationKey); + + + dtoShank = toolsManager.GetShank(shank.ShankId); } // Update shank data @@ -593,7 +598,10 @@ namespace Step.Controllers.WebApi // Set shankId magazinePos.ShankId = shank.ShankId; - return Ok(magazinePos); + dtoShank.MagazineId = magazineId; + dtoShank.PositionId = positionId; + + return Ok(dtoShank); } } diff --git a/Step/Controllers/WebApi/SiemensToolManagerController.cs b/Step/Controllers/WebApi/SiemensToolManagerController.cs index 723c2664..172293c9 100644 --- a/Step/Controllers/WebApi/SiemensToolManagerController.cs +++ b/Step/Controllers/WebApi/SiemensToolManagerController.cs @@ -1,4 +1,5 @@ -using Step.Model.DatabaseModels; +using CMS_CORE_Library.Models; +using Step.Model.DatabaseModels; using Step.Model.DTOModels.ToolModels; using Step.NC; using System; @@ -6,7 +7,6 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web.Http; -using static CMS_CORE_Library.DataStructures; namespace Step.Controllers.WebApi { diff --git a/Step/wwwroot/assets/styles/base/buttons.less b/Step/wwwroot/assets/styles/base/buttons.less index e5a38233..53b9aab0 100644 --- a/Step/wwwroot/assets/styles/base/buttons.less +++ b/Step/wwwroot/assets/styles/base/buttons.less @@ -17,9 +17,12 @@ button { button[disabled] { cursor: not-allowed !important; + *{ + cursor: not-allowed !important; + } } -button.btn[disabled] { +button.btn[disabled]{ border-radius: 2px; border-radius: 2px; background-color: #dddddd; @@ -50,7 +53,7 @@ button.btn { border: none; background-image: linear-gradient(to bottom, @color-white2, @color-silver); color: @color-darkish-blue; - &:active { + &:active:not([disabled]){ background-image: linear-gradient(to bottom, @color-silver, @color-white2); border: none !important; box-shadow: inset @button-shadow !important; diff --git a/Step/wwwroot/assets/styles/base/job-editor.less b/Step/wwwroot/assets/styles/base/job-editor.less index 28be9dd2..cd6b1057 100644 --- a/Step/wwwroot/assets/styles/base/job-editor.less +++ b/Step/wwwroot/assets/styles/base/job-editor.less @@ -7,6 +7,7 @@ display: flex; justify-content: center; padding-top: 104px; + .job-editor-box{ width: 1808px; height: 872px; @@ -41,10 +42,28 @@ // border-radius: 2px; // font-size: 20px; // } + .job-name-box{ + font-size: 18px; + line-height: 1.11; + color: #4b4b4b; + padding: 0 5px; + box-sizing: border-box; + width: 300px; + + } + .btn{ + width: 70px; + } + + .fa{ + font-size: 24px; + cursor: pointer; + } + span{ display: flex; align-items: center; - width: 288px; + // width: 288px; text-align: center; color: @color-darkish-blue; height: 48px; @@ -200,38 +219,43 @@ line-height: 1.43; color: @color-greyish-brown; } - .filename{ - display: flex; - height: 64px; - align-items: center; - cursor: pointer; - i{ - margin: 0 20px 0 15px; - } - span{ - width: 100%; - font-size: 14px; - line-height: 1.43; - color: @color-greyish-brown; - } - .right{ - width: 100%; + .box-image{ + max-height: 192px; + overflow: auto; + .filename{ display: flex; - justify-content: flex-end; - button.btn-hidden{ - visibility: hidden; - i{ - font-size: 26px; - visibility: visible; - margin: 0 12px; - cursor: pointer; + height: 64px; + align-items: center; + cursor: pointer; + i{ + margin: 0 20px 0 15px; + } + span{ + width: 100%; + font-size: 14px; + line-height: 1.43; + color: @color-greyish-brown; + } + .right{ + width: 100%; + display: flex; + justify-content: flex-end; + button.btn-hidden{ + visibility: hidden; + i{ + font-size: 26px; + visibility: visible; + margin: 0 12px; + cursor: pointer; + } } } } - } - .filename.selected{ - background-color: rgba(255, 255, 255, 0.8); - } + .filename.selected{ + background-color: rgba(255, 255, 255, 0.8); + } + } + .all-message-box{ max-height: 310px; .message-box{ @@ -486,9 +510,40 @@ background-color: @color-clear-blue-30; } } + .job-editor-button{ + display: flex; + width: 100%; + justify-content: flex-end; + margin-top: 16px; + margin-bottom: 16px; + } .job-editor-tools.scrollable{ - height: 519px; + height: 439px; margin-top: 14px; + .tool{ + cursor: pointer; + img{ + background-color: #DDD; + } + } + .tool.selected{ + background-color: rgba(23, 145, 255, 0.75); + color: white !important; + img{ + background-color: #FFF; + } + } + .notfound{ + color: @color-scarlet; + .selected img{ + background-color: @color-scarlet !important; + } + } + .notfound.selected{ + img{ + background-color: @color-scarlet !important; + } + } } .job-editor-tools-footer{ display: flex; @@ -517,6 +572,7 @@ height: 80px; box-shadow: 0 1px 2px 0 @color-black-40; margin: 8px 2px; + cursor: pointer; .title{ display: flex; align-items: center; @@ -542,6 +598,13 @@ .togglebutton label input[type=checkbox]{ display: flex; } + .input-box.selected{ + background-color: rgba(23, 145, 255, 0.75); + color: white; + .title{ + color: white; + } + } } .job-editor-parameters-footer{ display: flex; diff --git a/Step/wwwroot/assets/styles/base/modals.less b/Step/wwwroot/assets/styles/base/modals.less index de5b2987..1b25a6d7 100644 --- a/Step/wwwroot/assets/styles/base/modals.less +++ b/Step/wwwroot/assets/styles/base/modals.less @@ -798,6 +798,50 @@ } } +.@{modal}.modal-image { + width: @modal-iframe-width; + height: @modal-iframe-height; + border-radius: 2px; + background-color: @color-background-white; + top: calc(~"50%" - @modal-iframe-height / 2); + left: calc(~"50%" - @modal-iframe-width / 2); + header { + font-size: 20px; + color: @color-cyan-blue; + padding-left: 23px; + button.close { + position: absolute; + width: 28px; + height: 28px; + border-radius: 50%; + border: none; + background-color: @color-darkish-blue; + color: #fff; + top: calc(50% - 20px); + right: 14px; + font-size: 16px; + cursor: pointer; + } + button.close:active { + background-color: @color-clear-blue; + color: #fff; + } + } + .body{ + height: calc(~"100%" - 64px); + overflow: hidden; + align-items: center; + justify-content: center; + display: flex; + background-color: #cccccc; + } + #imagecontainer{ + position: relative; + max-width: 100%; + max-height: 100%; + } +} + .@{modal}.modal-load-program, .@{modal}.modal-add-element-queue { width: @modal-load-program-width; height: @modal-load-program-height; @@ -1235,51 +1279,67 @@ } .items-list { width: 475px; - min-height: 191px; + max-height: 248px; display: flex; flex-flow: column; - .group-item { + .title{ + height: 20px; + font-size: 18px; + line-height: 1.11; + margin: 0 10px; + color: @color-greyish-brown; + } + .items{ width: 100%; - min-height: 128px; + max-height: 185px; + min-height: 185px; display: flex; flex-flow: column; - .item { + overflow: auto; + .group-item { width: 100%; - height: 48px; + min-height: 60px; display: flex; - flex-flow: row; - align-items: center; - .number { - font-size: 18px; - line-height: 1.11; - color: @color-greyish-brown; - margin-right: 16px; - } - .input-text-box { - margin-right: 8px; - input { - width: 304px; - height: 48px; - border-radius: 2px; - box-shadow: inset 0 1px 3px 0 @color-black-50; - border: solid 1px @color-silver; + flex-flow: column; + .item { + width: 100%; + height: 48px; + display: flex; + flex-flow: row; + align-items: center; + .number { + font-size: 18px; + line-height: 1.11; + color: @color-greyish-brown; + margin-right: 16px; } - } - .group-button { - button.btn { - padding: 0 12px; - .fa { - font-size: 24px; + .input-text-box { + margin-right: 8px; + input { + width: 304px; + height: 48px; + border-radius: 2px; + box-shadow: inset 0 1px 3px 0 @color-black-50; + border: solid 1px @color-silver; + } + } + .group-button { + button.btn { + padding: 0 12px; + .fa { + font-size: 24px; + } } } } - } - .item:first-child { - margin-top: 12px; + .item:first-child { + margin-top: 12px; + } } } .add-item { width: 100%; + margin-top: 10px; display: flex; } } @@ -1746,6 +1806,12 @@ } .box-missing-tools{ margin-top: 26px; + .missing-tool{ + cursor: pointer; + } + .missing-tool.selected{ + background-color: @color-clear-blue; + } } } } diff --git a/Step/wwwroot/assets/styles/base/production.less b/Step/wwwroot/assets/styles/base/production.less index 912981ee..b87383b2 100644 --- a/Step/wwwroot/assets/styles/base/production.less +++ b/Step/wwwroot/assets/styles/base/production.less @@ -52,6 +52,14 @@ flex-flow: row; justify-content: center; align-items: center; + position: relative; + .title-header-label{ + position: absolute; + left: 0; + top: 22px; + font-size: 20px; + color: #002680; + } button.btn{ margin: 0; } diff --git a/Step/wwwroot/assets/styles/style.css b/Step/wwwroot/assets/styles/style.css index 5bdab1ee..5814a1c5 100644 --- a/Step/wwwroot/assets/styles/style.css +++ b/Step/wwwroot/assets/styles/style.css @@ -733,6 +733,49 @@ width: 100%; border: none; } +.modal.modal-image { + width: 1800px; + height: 800px; + border-radius: 2px; + background-color: #fff; + top: calc(50% - 400px); + left: calc(50% - 900px); +} +.modal.modal-image header { + font-size: 20px; + color: #002e6e; + padding-left: 23px; +} +.modal.modal-image header button.close { + position: absolute; + width: 28px; + height: 28px; + border-radius: 50%; + border: none; + background-color: #002680; + color: #fff; + top: calc(30%); + right: 14px; + font-size: 16px; + cursor: pointer; +} +.modal.modal-image header button.close:active { + background-color: #1791ff; + color: #fff; +} +.modal.modal-image .body { + height: calc(100% - 64px); + overflow: hidden; + align-items: center; + justify-content: center; + display: flex; + background-color: #cccccc; +} +.modal.modal-image #imagecontainer { + position: relative; + max-width: 100%; + max-height: 100%; +} .modal.modal-load-program, .modal.modal-add-element-queue { width: 1808px; @@ -1307,50 +1350,66 @@ } .modal.modal-job-add-parameter .job-add-parameter-body .items-list { width: 475px; - min-height: 191px; + max-height: 248px; display: flex; flex-flow: column; } -.modal.modal-job-add-parameter .job-add-parameter-body .items-list .group-item { +.modal.modal-job-add-parameter .job-add-parameter-body .items-list .title { + height: 20px; + font-size: 18px; + line-height: 1.11; + margin: 0 10px; + color: #4b4b4b; +} +.modal.modal-job-add-parameter .job-add-parameter-body .items-list .items { width: 100%; - min-height: 128px; + max-height: 185px; + min-height: 185px; + display: flex; + flex-flow: column; + overflow: auto; +} +.modal.modal-job-add-parameter .job-add-parameter-body .items-list .items .group-item { + width: 100%; + min-height: 60px; display: flex; flex-flow: column; } -.modal.modal-job-add-parameter .job-add-parameter-body .items-list .group-item .item { +.modal.modal-job-add-parameter .job-add-parameter-body .items-list .items .group-item .item { width: 100%; height: 48px; display: flex; flex-flow: row; align-items: center; } -.modal.modal-job-add-parameter .job-add-parameter-body .items-list .group-item .item .number { +.modal.modal-job-add-parameter .job-add-parameter-body .items-list .items .group-item .item .number { font-size: 18px; line-height: 1.11; color: #4b4b4b; margin-right: 16px; } -.modal.modal-job-add-parameter .job-add-parameter-body .items-list .group-item .item .input-text-box { +.modal.modal-job-add-parameter .job-add-parameter-body .items-list .items .group-item .item .input-text-box { margin-right: 8px; } -.modal.modal-job-add-parameter .job-add-parameter-body .items-list .group-item .item .input-text-box input { +.modal.modal-job-add-parameter .job-add-parameter-body .items-list .items .group-item .item .input-text-box input { width: 304px; height: 48px; border-radius: 2px; box-shadow: inset 0 1px 3px 0 rgba(0, 0, 0, 0.5); border: solid 1px #bbbcbc; } -.modal.modal-job-add-parameter .job-add-parameter-body .items-list .group-item .item .group-button button.btn { +.modal.modal-job-add-parameter .job-add-parameter-body .items-list .items .group-item .item .group-button button.btn { padding: 0 12px; } -.modal.modal-job-add-parameter .job-add-parameter-body .items-list .group-item .item .group-button button.btn .fa { +.modal.modal-job-add-parameter .job-add-parameter-body .items-list .items .group-item .item .group-button button.btn .fa { font-size: 24px; } -.modal.modal-job-add-parameter .job-add-parameter-body .items-list .group-item .item:first-child { +.modal.modal-job-add-parameter .job-add-parameter-body .items-list .items .group-item .item:first-child { margin-top: 12px; } .modal.modal-job-add-parameter .job-add-parameter-body .items-list .add-item { width: 100%; + margin-top: 10px; display: flex; } .modal.modal-job-add-parameter .job-add-parameter-footer { @@ -1779,6 +1838,12 @@ .modal.modal-missing-tools .modal-missing-tools-body.scrollable .modal-missing-tools-box .box-missing-tools { margin-top: 26px; } +.modal.modal-missing-tools .modal-missing-tools-body.scrollable .modal-missing-tools-box .box-missing-tools .missing-tool { + cursor: pointer; +} +.modal.modal-missing-tools .modal-missing-tools-body.scrollable .modal-missing-tools-box .box-missing-tools .missing-tool.selected { + background-color: #1791ff; +} .modal.modal-missing-tools .modal-missing-tools-footer { height: 79px; width: 100%; @@ -2012,6 +2077,9 @@ button { button[disabled] { cursor: not-allowed !important; } +button[disabled] * { + cursor: not-allowed !important; +} button.btn[disabled] { border-radius: 2px; background-color: #dddddd; @@ -2041,7 +2109,7 @@ button.btn { background-image: linear-gradient(to bottom, #f1f1f1, #bbbcbc); color: #002680; } -button.btn:active { +button.btn:active:not([disabled]) { background-image: linear-gradient(to bottom, #bbbcbc, #f1f1f1); border: none !important; box-shadow: inset 0 1px 2px 0 rgba(0, 0, 0, 0.4) !important; @@ -12266,6 +12334,14 @@ footer .container button.big:before { flex-flow: row; justify-content: center; align-items: center; + position: relative; +} +.production-container .production-box .production-left-box .box-left .box-left-video .box-header .title-header-label { + position: absolute; + left: 0; + top: 22px; + font-size: 20px; + color: #002680; } .production-container .production-box .production-left-box .box-left .box-left-video .box-header button.btn { margin: 0; @@ -12834,10 +12910,24 @@ footer .container button.big:before { flex-flow: row; margin-left: 24px; } +.job-editor-container .job-editor-box .job-editor-header .search-job .job-name-box { + font-size: 18px; + line-height: 1.11; + color: #4b4b4b; + padding: 0 5px; + box-sizing: border-box; + width: 300px; +} +.job-editor-container .job-editor-box .job-editor-header .search-job .btn { + width: 70px; +} +.job-editor-container .job-editor-box .job-editor-header .search-job .fa { + font-size: 24px; + cursor: pointer; +} .job-editor-container .job-editor-box .job-editor-header .search-job span { display: flex; align-items: center; - width: 288px; text-align: center; color: #002680; height: 48px; @@ -12997,36 +13087,40 @@ footer .container button.big:before { line-height: 1.43; color: #4b4b4b; } -.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .filename { +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .box-image { + max-height: 192px; + overflow: auto; +} +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .box-image .filename { display: flex; height: 64px; align-items: center; cursor: pointer; } -.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .filename i { +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .box-image .filename i { margin: 0 20px 0 15px; } -.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .filename span { +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .box-image .filename span { width: 100%; font-size: 14px; line-height: 1.43; color: #4b4b4b; } -.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .filename .right { +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .box-image .filename .right { width: 100%; display: flex; justify-content: flex-end; } -.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .filename .right button.btn-hidden { +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .box-image .filename .right button.btn-hidden { visibility: hidden; } -.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .filename .right button.btn-hidden i { +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .box-image .filename .right button.btn-hidden i { font-size: 26px; visibility: visible; margin: 0 12px; cursor: pointer; } -.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .filename.selected { +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .box-image .filename.selected { background-color: rgba(255, 255, 255, 0.8); } .job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .all-message-box { @@ -13279,10 +13373,39 @@ footer .container button.big:before { .job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .historical tr:nth-child(odd) { background-color: rgba(23, 145, 255, 0.3); } +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-button { + display: flex; + width: 100%; + justify-content: flex-end; + margin-top: 16px; + margin-bottom: 16px; +} .job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-tools.scrollable { - height: 519px; + height: 439px; margin-top: 14px; } +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-tools.scrollable .tool { + cursor: pointer; +} +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-tools.scrollable .tool img { + background-color: #DDD; +} +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-tools.scrollable .tool.selected { + background-color: rgba(23, 145, 255, 0.75); + color: white !important; +} +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-tools.scrollable .tool.selected img { + background-color: #FFF; +} +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-tools.scrollable .notfound { + color: #d0021b; +} +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-tools.scrollable .notfound .selected img { + background-color: #d0021b !important; +} +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-tools.scrollable .notfound.selected img { + background-color: #d0021b !important; +} .job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-tools-footer { display: flex; height: 62px; @@ -13311,6 +13434,7 @@ footer .container button.big:before { height: 80px; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.4); margin: 8px 2px; + cursor: pointer; } .job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-parameters.scrollable .input-box .title { display: flex; @@ -13334,6 +13458,13 @@ footer .container button.big:before { .job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-parameters.scrollable .togglebutton label input[type=checkbox] { display: flex; } +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-parameters.scrollable .input-box.selected { + background-color: rgba(23, 145, 255, 0.75); + color: white; +} +.job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-parameters.scrollable .input-box.selected .title { + color: white; +} .job-editor-container .job-editor-box .job-editor-body .job-editor-body-box .job-editor-body-box-right .box-right-body .box-right-body-container .job-editor-parameters-footer { display: flex; height: 62px; diff --git a/Step/wwwroot/src/_base/gestures.js b/Step/wwwroot/src/_base/gestures.js index 0e6be68d..59e70dc5 100644 --- a/Step/wwwroot/src/_base/gestures.js +++ b/Step/wwwroot/src/_base/gestures.js @@ -3,89 +3,87 @@ import Vue from "vue"; // credit: http://www.javascriptkit.com/javatutors/touchevents2.shtml function swipedetect(el, callback, onmovecallback, onstart, onstop) { - var touchsurface = el, - swipedir, - startX, - startY, - lastXswipe, - lastYswipe, - distX, - distY, - threshold = 10, //required min distance traveled to be considered swipe - restraint = 1000, // maximum distance allowed at the same time in perpendicular direction - allowedTime = 300, // maximum time allowed to travel that distance - elapsedTime, - handleswipe = callback || function(swipedir) {} + var touchsurface = el, + swipedir, + startX, + startY, + lastXswipe, + lastYswipe, + distX, + distY, + threshold = 10, //required min distance traveled to be considered swipe + restraint = 1000, // maximum distance allowed at the same time in perpendicular direction + allowedTime = 300, // maximum time allowed to travel that distance + elapsedTime, + handleswipe = callback || function (swipedir) { } - touchsurface.addEventListener('touchstart', function(e) { - var touchobj = e.changedTouches[0] - swipedir = 'none' - distX = 0 - distY = 0 - startX = touchobj.pageX - startY = touchobj.pageY - lastXswipe = touchobj.pageX - lastYswipe = touchobj.pageY - e.preventDefault() + touchsurface.addEventListener('touchstart', function (e) { + var touchobj = e.changedTouches[0] + swipedir = 'none' + distX = 0 + distY = 0 + startX = touchobj.pageX + startY = touchobj.pageY + lastXswipe = touchobj.pageX + lastYswipe = touchobj.pageY + e.preventDefault() - if (onstart) onstart(e); + if (onstart) onstart(e); - }, false) + }, false) - touchsurface.addEventListener('touchmove', function(e) { - e.preventDefault() // prevent scrolling when inside DIV + touchsurface.addEventListener('touchmove', function (e) { + e.preventDefault() // prevent scrolling when inside DIV - var touchobj = e.changedTouches[0]; - distX = touchobj.pageX - lastXswipe; - distY = touchobj.pageY - lastYswipe; + var touchobj = e.changedTouches[0]; + distX = touchobj.pageX - lastXswipe; + distY = touchobj.pageY - lastYswipe; - if (Math.abs(distY) >= threshold && Math.abs(distX) < restraint && swipedir != 'left' && swipedir != 'right') { - swipedir = (distY < 0) ? 'up' : 'down' - } - if (Math.abs(distX) >= threshold && Math.abs(distY) < restraint && swipedir != 'up' && swipedir != 'down') { - swipedir = (distX < 0) ? 'left' : 'right' - } + if (Math.abs(distY) >= threshold && Math.abs(distX) < restraint && swipedir != 'left' && swipedir != 'right') { + swipedir = (distY < 0) ? 'up' : 'down' + } + if (Math.abs(distX) >= threshold && Math.abs(distY) < restraint && swipedir != 'up' && swipedir != 'down') { + swipedir = (distX < 0) ? 'left' : 'right' + } - lastXswipe = touchobj.pageX - lastYswipe = touchobj.pageY + lastXswipe = touchobj.pageX + lastYswipe = touchobj.pageY - if (onmovecallback) - onmovecallback(e) + if (onmovecallback) + onmovecallback(e) - }, false) + }, false) - touchsurface.addEventListener('touchend', function(e) { - var touchobj = e.changedTouches[0]; - if (onstop) onstop(e); + touchsurface.addEventListener('touchend', function (e) { + var touchobj = e.changedTouches[0]; + if (onstop) onstop(e); - handleswipe(swipedir) - e.preventDefault() - }, false) + handleswipe(swipedir) + e.preventDefault() + }, false) } Vue.component('vue-gesture', { - template: '', - props: { + template: '', + props: { - call: { type: Function }, - onmove: { type: Function }, - onstart: { type: Function }, - onstop: { type: Function } - }, - mounted: function() { - var self = this; + call: { type: Function }, + onmove: { type: Function }, + onstart: { type: Function }, + onstop: { type: Function } + }, + mounted: function () { + var self = this; - if (typeof this.call !== 'function') { - console.log(this.call); - return console.error('The expression of directive "v-gesture call" must be a function!'); - } - - if (this.onmove && typeof this.onmove !== 'function') { - console.log(this.call); - return console.error('The expression of directive "v-gesture onmove" must be a function!'); - } - - if (this.$el) - swipedetect(this.$el, this.call, this.onmove, this.onstart, this.onstop); + if (typeof this.call !== 'function') { + return console.error('The expression of directive "v-gesture call" must be a function!'); } -}); \ No newline at end of file + + if (this.onmove && typeof this.onmove !== 'function') { + return console.error('The expression of directive "v-gesture onmove" must be a function!'); + } + + if (this.$el) + swipedetect(this.$el, this.call, this.onmove, this.onstart, this.onstop); + } +}); diff --git a/Step/wwwroot/src/app.modules.js b/Step/wwwroot/src/app.modules.js index ada14ecb..f4c32a9b 100644 --- a/Step/wwwroot/src/app.modules.js +++ b/Step/wwwroot/src/app.modules.js @@ -43,7 +43,10 @@ export const SummaryDepot = () => export const ModalIframe = () => import ("./modules/base-components/modal-iframe.vue"); +export const ModalImage = () => + import ("./modules/base-components/modal-image.vue"); + export const ToolingEquipment = () => import ("./components/tooling/tooling-equipment.vue"); export const InfoEquipment = () => diff --git a/Step/wwwroot/src/components/alarm-history.vue b/Step/wwwroot/src/components/alarm-history.vue index 6b43d54b..2f60aefc 100644 --- a/Step/wwwroot/src/components/alarm-history.vue +++ b/Step/wwwroot/src/components/alarm-history.vue @@ -10,31 +10,31 @@
- +
- +
- +
- +
- +
@@ -77,7 +77,7 @@
- #### La macchina non è tarata + #### {{'alarm_history_box_right_info_description_machine_not_calibrated' | localize("La macchina non è tarata")}}La macchina non è tarata
@@ -88,12 +88,12 @@
- Lorem ipsum dolor sit amet, consectetur - adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna. + {{'alarm_history_box_right_info_first_description' | localize("Lorem ipsum dolor sit amet, consectetur")}} + {{'alarm_history_box_right_info_second_description' | localize("adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.")}}
@@ -110,9 +110,9 @@
- - - + + +
@@ -128,11 +128,11 @@
- Aggiungi un allegato + {{'alarm_history_allattach_strong_label_add_attach' | localize("Aggiungi un allegato")}}
@@ -150,11 +150,11 @@
- Aggiungi una nota + {{'alarm_history_allnote_strong_label_add_note' | localize("Aggiungi una nota")}}
diff --git a/Step/wwwroot/src/components/create-queue.vue b/Step/wwwroot/src/components/create-queue.vue index 56cf7374..68eea79d 100644 --- a/Step/wwwroot/src/components/create-queue.vue +++ b/Step/wwwroot/src/components/create-queue.vue @@ -4,15 +4,15 @@
- Selezione programma da aggiungere in coda + {{'create_queue_title' | localize("Selezione programma da aggiungere in coda")}}
- +
@@ -71,18 +71,18 @@
- +
- +
diff --git a/Step/wwwroot/src/components/job-editor-detail.ts b/Step/wwwroot/src/components/job-editor-detail.ts index 87b8c67d..fd642015 100644 --- a/Step/wwwroot/src/components/job-editor-detail.ts +++ b/Step/wwwroot/src/components/job-editor-detail.ts @@ -61,7 +61,7 @@ export default class JobEditorDetail extends Vue { commandsChanged(n, o) { if (n && this.interactive) { var result = ""; - + this.commands.forEach(c => { result += pf.vsprintf(c.definition.command, [c.value || "", c.value2 || ""]) + "\n"; }); @@ -97,7 +97,7 @@ export default class JobEditorDetail extends Vue { } dropNewCommand(event) { - console.log("drop", event) + const { removedIndex, addedIndex, payload, element } = event; this.commands.splice(addedIndex, 0, { definition: payload, diff --git a/Step/wwwroot/src/components/job-editor-detail.vue b/Step/wwwroot/src/components/job-editor-detail.vue index c9e1dea5..62318f9d 100644 --- a/Step/wwwroot/src/components/job-editor-detail.vue +++ b/Step/wwwroot/src/components/job-editor-detail.vue @@ -2,10 +2,10 @@
@@ -18,7 +18,7 @@
- +
diff --git a/Step/wwwroot/src/components/job-editor.ts b/Step/wwwroot/src/components/job-editor.ts index 3ebe51ad..2f0399e9 100644 --- a/Step/wwwroot/src/components/job-editor.ts +++ b/Step/wwwroot/src/components/job-editor.ts @@ -5,90 +5,268 @@ import { objectsJob } from "src/modules/base-components/cards"; import { tool } from "src/modules/base-components/cards"; import { inputBox } from "src/modules/base-components/cards"; import jobEditorDetail from "./job-editor-detail.vue"; -import { jobEditorActions } from "../store/jobEditor.store"; import { store, AppModel } from "../store"; import { ToolingService } from "../services/toolingService"; +import { ModalHelper, ModalMissingTools, ModalJobAddParameter } from "../modules/base-components"; +import * as iziToast from "izitoast"; +import { awaiter } from "src/_base"; +import { ModalImage} from "src/modules/base-components/index"; +import { Watch } from "vue-property-decorator"; + declare let $: any; declare let cmsClient: any; @Component({ components: { objectsJob, tool, inputBox, Container, Draggable, jobEditorDetail } }) export default class JobEditor extends Vue { - public get job(): server.Job { - return (this.$store.state as AppModel).jobEditor.job; - } - - public get ncTools(): server.ToolNc[] { return (this.$store.state as AppModel).tooling.ncTools; } - - toolsJob: Array = []; - programName: string = null; editing: boolean = false; currentJob: server.Job = null; - imagesOfTheJob: Array = []; + limitationList: number = 3; + selectedParam = null; + selectedTool = null; // occorre uno switch per la scelta del linguaggio in base al CN jobitems = siemensJobItems; - public selectedTab: string = "ParBase"; + selectedTab: string = "ParBase"; - public selectTab(value) { + get ncTools(): server.ToolNc[] { return (this.$store.state as AppModel).tooling.ncTools; } + get ncFamilies(): server.FamiliesNc[] { return (this.$store.state as AppModel).tooling.ncFamilies; } + + get jobTools() { + var $this = this; + return this.currentJob.metadata.tools.map(t => + { + var tool = $this.ncTools.find(i => i.id == t); + if(tool) + return tool + else + return t + }); + } + + public get familyOptionActive(): boolean { + return (this.$store.state as AppModel).tooling.familyOptionActive; + } + + get jobGenerics() { + return this.currentJob ? this.currentJob.metadata.generics : null; + } + + async mounted(){ + awaiter (Promise.all([ + await new ToolingService().GetNcTools(), + await new ToolingService().GetNcFamilies(), + await new ToolingService().GetToolsConfiguration() + ])); + } + + selectTab(value) { this.selectedTab = value; } getChildPayload(index) { - // console.log("childPayload", index, this.jobitems[index - 1]) return this.jobitems[index - 1]; } - addImageToJob(){ + addImageToJob() { var res = JSON.parse(cmsClient.addImageToJob()); - if(this.currentJob){ + if (this.currentJob) { this.currentJob.metadata.generics.images.push(res); } } - deleteImageFromJob(){ - var res = JSON.parse(cmsClient.deleteImageFromJob()); - console.log(res); - } - - addPPToJob(){ - var res = JSON.parse(cmsClient.addPPToJob()); - console.log(res); - } - - delPPFromJob(){ - var res = JSON.parse(cmsClient.delPPFromJob()); - console.log(res); - } - - async openJob(){ - var toolsJ, tJ; - this.currentJob = JSON.parse(cmsClient.openJob()); - jobEditorActions.updateJob(store,this.currentJob); - await new ToolingService().GetNcTools(); - toolsJ = this.ncTools; - console.log(this.currentJob); - if(this.currentJob.metadata.tools.length > 0){ - this.currentJob.metadata.tools.forEach(function(value){ - toolsJ.forEach(function(tools){ - if(tools.id == value){ - tJ.push(tools); + deleteImageFromJob(image) { + ModalHelper.AskConfirm(this.$options.filters.localize("modal_delete_image_job", "Richiesta di conferma"), + this.$options.filters.localize("modal_delete_image_job_confirm", "Sei sicuro di voler eliminare l'immagine?"), + () => { + var res = cmsClient.delImageFromJob(image.name); + if (this.currentJob) { + var images = this.currentJob.metadata.generics.images; + images.splice(images.indexOf(image), 1); } - }); - }) - } - this.toolsJob = tJ; + }, null); + + } + openImage(image){ + ModalHelper.modalImage.content = image.base64; + ModalHelper.modalImage.title = image.name; + ModalHelper.ShowModal(ModalImage); } - saveJob(){ - if(this.currentJob){ - var res = JSON.parse(cmsClient.saveJob(this.currentJob)); - console.log(res); + newJob() { + if (this.currentJob) + ModalHelper.AskConfirm(this.$options.filters.localize("modal_open_job", "Richiesta di conferma"), + this.$options.filters.localize("modal_open_job_body", "Sei sicuro di aver salvato il Job?"), + () => { + var res = cmsClient.newJob(); + if(res){ + var obj = JSON.parse(res); + if(obj.error) + this.showError(obj.error); + else + this.currentJob = obj; + } + + }, null); + else + this.currentJob = JSON.parse(cmsClient.newJob()); + + } + + updateLimitation() { + if (this.limitationList == this.currentJob.metadata.generics.images.length) { + this.limitationList = 3; + } else { + this.limitationList = this.currentJob.metadata.generics.images.length; + } + } + + async openJob() { + if (this.currentJob) + ModalHelper.AskConfirm(this.$options.filters.localize("modal_open_job", "Richiesta di conferma"), + this.$options.filters.localize("modal_open_job_body", "Sei sicuro di aver salvato il Job?"), + this.loadJob, null); + else + this.loadJob(); + } + + async loadJob() { + var res = cmsClient.openJob(); + if(res){ + var obj = JSON.parse(res); + if(obj.error) + this.showError(obj.error); + else{ + this.currentJob = obj; + } + } + } + + saveJobNewPath() { + if (this.currentJob) { + var res = cmsClient.saveJobNewPath(JSON.stringify(this.currentJob)); + if(res){ + var obj = JSON.parse(res); + if(obj.error) + this.showError(obj.error); + else + this.currentJob.name = obj.name; + } + } + } + + saveJob() { + if (this.currentJob) { + var res = cmsClient.saveJob(JSON.stringify(this.currentJob)); + if(res){ + var obj = JSON.parse(res); + if(obj.error) + this.showError(obj.error); + else + this.currentJob.name = obj.name; + } + } + } + + closeJob() { + if (this.currentJob) { + + ModalHelper.AskConfirm(this.$options.filters.localize("modal_open_job", "Richiesta di conferma"), + this.$options.filters.localize("modal_open_job_body", "Sei sicuro di aver salvato il Job?"), + () => { + var res = cmsClient.closeJob(); + if(res){ + var obj = JSON.parse(res); + if(obj.error) + this.showError(obj.error); + } + else + this.currentJob = null; + }, null); } } + selectParam(param) { + this.selectedParam = param; + } + + selectTool(tool) { + this.selectedTool = tool; + } + + async openModalAddToolToJob() { + ModalHelper.avaiableTools = this.ncTools.filter(t => this.currentJob.metadata.tools.indexOf(t.id) < 0); + ModalHelper.job = this.currentJob; + var newTool = await ModalHelper.ShowModalAsync(ModalMissingTools); + + if (newTool) { + this.currentJob.metadata.tools.push(newTool.id); + } + } + + removeTool(tool) { + var idx = this.currentJob.metadata.tools.indexOf(tool.id); + if (idx >= 0) + this.currentJob.metadata.tools.splice(idx, 1); + } + + removeParam(parameter) { + var idx = this.currentJob.metadata.customs.indexOf(parameter); + if (idx >= 0) + this.currentJob.metadata.customs.splice(idx, 1); + } + + async editParam(parameter) { + var result = await ModalHelper.ShowModalAsync(ModalJobAddParameter, parameter); + if (result) + Object.assign(parameter, result); + } + + async openModalJobAddParameter() { + + var result = await ModalHelper.ShowModalAsync(ModalJobAddParameter, null); + if (result) + this.currentJob.metadata.customs.push(result); + } + + + showError(error) { + + (iziToast as any).error({ + title: "Error", + message: error, + theme: "dark", + timeout: 10000, + class: "t-error", + transitionOut: "fadeOut", + }) + } + + familyNameFromId(id): any{ + var found = this.ncFamilies.find(k => k.id == id); + if(found) + return found.name; + return ''; + } + + calcFamilyName(id): any{ + if(this.familyOptionActive) + return this.$options.filters.localize("tooling_family_abbreviation", 'F%d',id) + ' - ' + this.familyNameFromId(id); + else + return this.familyNameFromId(id); + } + + getToolIcon = function (id) { + if (id == 9999) + return "../assets/iicons/Tools/Undefined.png" + else if (id == 151 || id == 700) + return "../assets/icons/Tools/Saw.png" + else + return "../assets/icons/Tools/Tools.png" + } + } diff --git a/Step/wwwroot/src/components/job-editor.vue b/Step/wwwroot/src/components/job-editor.vue index 7c439935..62fbb011 100644 --- a/Step/wwwroot/src/components/job-editor.vue +++ b/Step/wwwroot/src/components/job-editor.vue @@ -3,22 +3,21 @@
- +
- - {{currentJob.name}} - - -
-
- - + + + + + + +
-
+
{{'drag_job_items_to_compose_job' | localize('Trascina nella parte centrale della pagina gli oggetti che desideri aggiungere al job')}} @@ -32,112 +31,90 @@
-
+
- +
- Immagini + {{'job_editor_box_right_images' | localize('Immagini')}}
-
- - {{image.name}} - +
+
+ + {{image.name}} +
+ + +
+
-
-
- -
+
- +
- +
- +
- - {{currentJob.metadata.generics.ExecutionTime}} -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
{{'modal_edit_job_table_date' | localize("Data")}}{{'modal_edit_job_table_start_time' | localize("Ora inizio")}}{{'modal_edit_job_table_medium_override' | localize("Override medio")}}{{'modal_edit_job_table_total_time' | localize("T totale")}}
+ + {{jobGenerics.ExecutionTime}}
+
+
+ +
- + +
- - + +
- -
@@ -145,11 +122,11 @@
diff --git a/Step/wwwroot/src/components/production.ts b/Step/wwwroot/src/components/production.ts new file mode 100644 index 00000000..77a8840d --- /dev/null +++ b/Step/wwwroot/src/components/production.ts @@ -0,0 +1,181 @@ +import Vue from "vue"; +import softkeysPrefered from "../modules/base-components/cards/softkeys-prefered.vue" +import headProduction from "../modules/heads/head-production.vue" +import cardAxesProduction from "../modules/base-components/cards/card-axes-production.vue" +import processSelectionMaintenance from "../modules/base-components/cards/process-selection-maintenance.vue"; +import cardProductionCms from "../modules/base-components/cards/card-production-cms.vue"; +import { Hub } from "src/services/hub"; +import { Factory, MessageService, awaiter } from "src/_base"; +import { appModelActions, alarmsModelActions, store } from "src/store"; +import { ModalHelper } from "src/modules/base-components"; +import { DataService } from '../services/dataService'; +import Component from "vue-class-component"; +import { Watch } from "vue-property-decorator"; + +@Component({ + components: { + softkeysPrefered, headProduction, cardAxesProduction, processSelectionMaintenance, cardProductionCms + } +}) +export default class Production extends Vue { + + isCnReady: Function; + + activeCms = true; + activeCnc = false; + headsR = []; + selectedHead = null; + selectedPositionTop = 0; + userSubkeysMenuOpened = false; + waitingForSftkConfirm = false; + confirmationDelegate = null; + + async created() { + await awaiter(new DataService().GetUserSoftkeyFavorite()); + } + async mounted() { + this.confirmationDelegate = null; + ModalHelper.HideModal("modal2"); + } + + get machineInfo() { + return this.$store.state.machineInfo; + } + get heads() { + return this.$store.state.machineInfo.heads; + } + softkeyFavorite() { + function compare(a, b) { + if (a.id < b.id) { + return -1; + } + if (a.id > b.id) { + return 1; + } + return 0; + } + + var array = this.$store.state.machineInfo.softkeysFavorites; + return array.sort(compare); + } + + @Watch("activeCnc") + activeCncChanged() { + if (this.activeCnc) { + Factory.Get(MessageService).publishToChannel("HMI-production-show"); + Factory.Get(MessageService).publishToChannel("HMI-production-show-state"); + } + else { + Factory.Get(MessageService).publishToChannel("HMI-production-hide"); + Factory.Get(MessageService).publishToChannel("HMI-production-hide-state"); + } + } + + beforeDestroy() { + Factory.Get(MessageService).publishToChannel("HMI-production-hide"); + Factory.Get(MessageService).publishToChannel("HMI-production-hide-state"); + } + + closeAlarmsRibbon() { + alarmsModelActions.toggleOpened(this.$store, false); + alarmsModelActions.toggleServiceOpened(this.$store, false); + } + selectHead(h) { + this.selectedHead = h; + } + getHeadsProperty(id) { + var r = this.$store.getters.getHeadsProperty(id); + return r || {}; + } + clickCms() { + this.activeCms = true; + this.activeCnc = false; + } + clickCnc() { + this.activeCnc = true; + this.activeCms = false; + } + ncClick(id) { + Hub.Current.ncSoftKeyClick(id); + } + isReadOnly(id) { + let r = this.$store.getters.getNcSoftKeyInfo(id); + if (r) return r.isReadOnly; + return false; + } + isKeyActive(id) { + let r = this.$store.getters.getNcSoftKeyStatus(id); + if (r) return r.active; + return false; + } + name(id) { + let r = this.$store.getters.getNcSoftKeyInfo(id); + if (r) return r.visualizedName; + return null; + } + isKeySelected(id) { + let r = this.$store.getters.getNcSoftKeyStatus(id); + if (r) return r.value; + return false; + } + overrideMinus(id) { + Hub.Current.headOverrideMinus(id); + } + overridePlus(id) { + Hub.Current.headOverridePlus(id); + } + positionBox(arg1, arg2) { + this.selectedPositionTop = (arg1.offsetTop - (this.$refs.scrollable as any).scrollTop - (this.$refs.scrollable as any).offsetHeight + 155); + this.userSubkeysMenuOpened = arg2; + } + toggleMainView() { + Factory.Get(MessageService).publishToChannel("enable-selected-softkeys-prefered", true); + appModelActions.MainViewToggle(this.$store); + } + getSubKeysActive(keys) { + let result = {}; + for (const key in keys) { + result[key] = this.getSoftKeyActive(key); + } + return result; + } + getSoftKeyActive(id) { + if (!this.isCnReady()) return false; + var sk = this.$store.getters.getSoftKeyStatus(id); + if (sk) + return sk.active; + return false; + } + softKeyChanged(id, confirm) { + if (!confirm) + Hub.Current.sendUserSoftKey(id); + else { + this.confirmationDelegate = () => { + Hub.Current.sendUserSoftKey(id); + }; + this.waitingForSftkConfirm = true; + } + } + sendKeyCancel() { + this.confirmationDelegate = null; + } + sendKeyConfirm() { + if (this.confirmationDelegate) + this.confirmationDelegate(); + this.confirmationDelegate = null; + } + getSubKeysStatus(keys) { + let result = {}; + for (const key in keys) { + result[key] = this.getSoftKeyStatus(key); + } + return result; + } + getSoftKeyStatus(id) { + if (!this.isCnReady()) return false; + var sk = this.$store.getters.getSoftKeyStatus(id); + if (sk) + return sk.value; + return false; + } +}; diff --git a/Step/wwwroot/src/components/production.vue b/Step/wwwroot/src/components/production.vue index 1b98818b..b30065ad 100644 --- a/Step/wwwroot/src/components/production.vue +++ b/Step/wwwroot/src/components/production.vue @@ -8,10 +8,13 @@
+
+ {{'production_header_title' | localize("Gestore della produzione")}} +
-
+
@@ -32,7 +35,7 @@ - + @@ -99,185 +102,6 @@
- \ No newline at end of file + diff --git a/Step/wwwroot/src/components/scada.vue b/Step/wwwroot/src/components/scada.vue index d5aea568..68a149c4 100644 --- a/Step/wwwroot/src/components/scada.vue +++ b/Step/wwwroot/src/components/scada.vue @@ -4,10 +4,10 @@
diff --git a/Step/wwwroot/src/components/summary-depot.vue b/Step/wwwroot/src/components/summary-depot.vue index c70a98a9..9fc91b2e 100644 --- a/Step/wwwroot/src/components/summary-depot.vue +++ b/Step/wwwroot/src/components/summary-depot.vue @@ -12,10 +12,10 @@
- Magazzino 1 - Lineare + {{'summary_depot_header_linear' | localize("Magazzino 1 - Lineare")}}
-
Utensili caricati
+
{{'summary_depot_list_vertical_loaded_tools' | localize("Utensili caricati")}}
@@ -24,7 +24,7 @@
-
Utensili scaricati
+
{{'summary_depot_list_vertical_download_tools' | localize("Utensili scaricati")}}
diff --git a/Step/wwwroot/src/components/tooling/assisted-tooling.vue b/Step/wwwroot/src/components/tooling/assisted-tooling.vue index 8398772e..4427482a 100644 --- a/Step/wwwroot/src/components/tooling/assisted-tooling.vue +++ b/Step/wwwroot/src/components/tooling/assisted-tooling.vue @@ -3,7 +3,7 @@
-
Attrezzaggio assistito - Magazzino 1
+
{{'assisted_tooling_label_header' | localize('Attrezzaggio assistito - Magazzino 1')}}
diff --git a/Step/wwwroot/src/components/tooling/assisted-toolingfive.vue b/Step/wwwroot/src/components/tooling/assisted-toolingfive.vue index 9730b859..5b39bc40 100644 --- a/Step/wwwroot/src/components/tooling/assisted-toolingfive.vue +++ b/Step/wwwroot/src/components/tooling/assisted-toolingfive.vue @@ -3,10 +3,10 @@
-
Attrezzaggio assistito - Magazzino 1
+
{{'assisted_toolingfive_header_label' | localize("Attrezzaggio assistito - Magazzino 1")}}
- Procedura di attrezzaggio assistito completata con successo! + {{'assisted_toolingfive_body' | localize("Procedura di attrezzaggio assistito completata con successo!")}}