FIX assisted tooling
Fix maintenances
This commit is contained in:
Binary file not shown.
@@ -37,7 +37,7 @@ namespace Step.Database.Controllers
|
||||
where m1.MaintenanceId == maintenances.MaintenanceId
|
||||
select m1.Date
|
||||
).Max()
|
||||
select maintenances)
|
||||
select maintenances)
|
||||
.Include("Maintainer")
|
||||
.ToList();
|
||||
|
||||
@@ -362,11 +362,11 @@ namespace Step.Database.Controllers
|
||||
public bool CheckPassword(string password, string machineNumber, uint plcCounter, out int cw)
|
||||
{
|
||||
cw = -1;
|
||||
if (String.IsNullOrEmpty(password))
|
||||
|
||||
if (!GetDataFromMaintenancePassword(password, out int pwdMachineNumber, out int pwdHours, out cw))
|
||||
return false;
|
||||
|
||||
GetDataFromMaintenancePassword(password, out int pwdMachineNumber, out int pwdHours, out cw);
|
||||
// Check machine number
|
||||
// Check machine number
|
||||
if(machineNumber == pwdMachineNumber.ToString())
|
||||
{
|
||||
// Convert plcCounter in hours and check if password is expired
|
||||
@@ -379,13 +379,19 @@ namespace Step.Database.Controllers
|
||||
return false; // Invalid Password
|
||||
}
|
||||
|
||||
private void GetDataFromMaintenancePassword(string password, out int number, out int hours, out int cw)
|
||||
private bool GetDataFromMaintenancePassword(string password, out int number, out int hours, out int cw)
|
||||
{
|
||||
number = -1;
|
||||
hours = -1;
|
||||
cw = -1;
|
||||
|
||||
if (String.IsNullOrEmpty(password))
|
||||
return false;
|
||||
|
||||
string tmpPassword1 = "",
|
||||
tmpPassword3 = "",
|
||||
tmpPassword4 = "",
|
||||
tmpPassword5 = "";
|
||||
int controlNumber = 0;
|
||||
|
||||
Hashtable htCifrario = new Hashtable
|
||||
{
|
||||
@@ -411,7 +417,10 @@ namespace Step.Database.Controllers
|
||||
}
|
||||
|
||||
// Get control number
|
||||
controlNumber = Convert.ToInt32(Right(tmpPassword5, 1));
|
||||
var stringCw = Right(tmpPassword5, 1);
|
||||
if (!int.TryParse(stringCw, out int controlNumber))
|
||||
return false;
|
||||
|
||||
tmpPassword4 = tmpPassword5.Remove(tmpPassword5.Length - 1);
|
||||
|
||||
// Create tmpPassoword3
|
||||
@@ -437,6 +446,8 @@ namespace Step.Database.Controllers
|
||||
hours = Convert.ToInt32(tmpPassword1.Substring(0, 5), 16); // Convert from hexadecimal
|
||||
number = Convert.ToInt32(tmpPassword1.Substring(5, 4), 16); // Convert from hexadecimal
|
||||
cw = Convert.ToInt32(tmpPassword1.Substring(9, 2), 16); // Convert from hexadecimal
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string Right(string value, int size)
|
||||
|
||||
+43
-37
@@ -21,7 +21,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using static CMS_CORE_Library.Models.DataStructures;
|
||||
using static Step.Config.ServerConfig;
|
||||
using static Step.Database.Controllers.QueueController;
|
||||
using static Step.Database.Controllers.QueueController;
|
||||
using static Step.Model.Constants;
|
||||
|
||||
namespace Step.NC
|
||||
@@ -32,18 +32,18 @@ namespace Step.NC
|
||||
|
||||
public NcHandler() =>
|
||||
// Choose NC
|
||||
numericalControl = SetNumericalControl();
|
||||
|
||||
numericalControl = SetNumericalControl();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (NcConfig.NcVendor != NC_VENDOR.SIEMENS)
|
||||
numericalControl.NC_Disconnect();
|
||||
}
|
||||
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
numericalControl.NC_Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public CmsError Connect()
|
||||
{
|
||||
@@ -71,7 +71,7 @@ namespace Step.NC
|
||||
case NC_VENDOR.OSAI:
|
||||
return new Nc_Osai(NcConfig.NcIpAddress, NcConfig.NcPort, 2000);
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
#region File manager
|
||||
@@ -439,7 +439,7 @@ namespace Step.NC
|
||||
queueList = new List<DTOQueueModel>();
|
||||
// Check if there is already a pp queue
|
||||
if (PartProgramQueue.ContainsKey(selectedProcess))
|
||||
// return INCORRECT_PARAMETERS_ERROR;
|
||||
// return INCORRECT_PARAMETERS_ERROR;
|
||||
queueList = PartProgramQueue[selectedProcess];
|
||||
|
||||
return NO_ERROR;
|
||||
@@ -671,7 +671,7 @@ namespace Step.NC
|
||||
|
||||
// Get date time
|
||||
DateTime dateTime = new DateTime();
|
||||
CmsError cmsError = numericalControl.NC_RDateTime(ref dateTime);
|
||||
CmsError cmsError = numericalControl.NC_RDateTime(ref dateTime);
|
||||
if (cmsError.errorCode != 0)
|
||||
return cmsError;
|
||||
|
||||
@@ -901,7 +901,6 @@ namespace Step.NC
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
|
||||
//// Get selectedProcessData
|
||||
SelectedProcessData selectedData = new SelectedProcessData();
|
||||
cmsError = numericalControl.PROC_RSelectedProcessData(processesData.SelectedProcess, ref selectedData);
|
||||
@@ -1388,7 +1387,7 @@ namespace Step.NC
|
||||
public CmsError GetM155Data(out List<DTOM155InputModel> data)
|
||||
{
|
||||
data = new List<DTOM155InputModel>();
|
||||
List<M155InputIsNeededModel> ncData = new List<M155InputIsNeededModel>();
|
||||
List<M155InputIsNeededModel> ncData = new List<M155InputIsNeededModel>();
|
||||
CmsError cmsError = numericalControl.PLC_ROperatorInputIsNeeded(ref ncData);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
@@ -1406,10 +1405,10 @@ namespace Step.NC
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
public CmsError GetM154Data(out List<M154DataModel> data, out bool MTCStatus)
|
||||
public CmsError GetM154Data(out List<M154DataModel> data, out bool MTCStatus)
|
||||
{
|
||||
MTCStatus = false;
|
||||
data = new List<M154DataModel>();
|
||||
data = new List<M154DataModel>();
|
||||
|
||||
return numericalControl.PLC_RM154Data(ref data, ref MTCStatus);
|
||||
}
|
||||
@@ -1570,11 +1569,11 @@ namespace Step.NC
|
||||
|
||||
if (!ToolManagerConfig.BallufOpt)
|
||||
categories.Add("balluf");
|
||||
|
||||
|
||||
if (!ToolManagerConfig.ReviveOpt)
|
||||
categories.Add("revive");
|
||||
|
||||
config.ToolsConfiguration = config.ToolsConfiguration.Where(x => !categories.Contains(x.Category)).ToList();
|
||||
config.ToolsConfiguration = config.ToolsConfiguration.Where(x => !categories.Contains(x.Category)).ToList();
|
||||
|
||||
// Remove categories from familyConfig
|
||||
config.FamiliesConfiguration.FamilyConfiguration = config.FamiliesConfiguration.FamilyConfiguration.Where(x => !categories.Contains(x.Category)).ToList();
|
||||
@@ -1827,16 +1826,16 @@ namespace Step.NC
|
||||
CmsError cmsError = NO_ERROR;
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
using (var dbContextTransaction = toolsManager.dbCtx.Database.BeginTransaction())
|
||||
using (var dbContextTransaction = toolsManager.dbCtx.Database.BeginTransaction())
|
||||
{
|
||||
// If option is active
|
||||
if (!ToolManagerConfig.FamilyOpt)
|
||||
{
|
||||
// Copy only family
|
||||
DTONewNcFamilyModel newFamily = new DTONewNcFamilyModel();
|
||||
DTONewNcFamilyModel newFamily = new DTONewNcFamilyModel();
|
||||
SupportFunctions.CopyProperties(dtoToolWithFamily, newFamily);
|
||||
// Update only family data
|
||||
newFamily = (DTONcFamilyModel)toolsManager.UpdateFamily(dtoToolWithFamily.FamilyId, newFamily);
|
||||
newFamily = (DTONcFamilyModel)toolsManager.UpdateFamily(dtoToolWithFamily.FamilyId, newFamily);
|
||||
|
||||
// Update Nc families
|
||||
cmsError = UpdateNcFamily(toolsManager);
|
||||
@@ -1971,7 +1970,7 @@ namespace Step.NC
|
||||
{
|
||||
DbNcFamilyModel fam = toolsManager.FindFamily(tool.FamilyId);
|
||||
// Check if family is connected to other tools
|
||||
if (fam != null && fam.Tools.Count() == 1)
|
||||
if (fam != null && fam.Tools.Count() == 1)
|
||||
{
|
||||
toolsManager.DeleteFamily(fam.FamilyId);
|
||||
}
|
||||
@@ -2010,7 +2009,6 @@ namespace Step.NC
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, startIsActive);
|
||||
|
||||
return cmsError;
|
||||
@@ -2151,13 +2149,13 @@ namespace Step.NC
|
||||
// If the relationship is 1:1 (tool:shank) i have to remove shanks manually
|
||||
// Tools are deleted thanks to foreign keys constraint
|
||||
List<DbNcShankModel> shanks = toolsManager.FindShanksByFamilyId(famId);
|
||||
foreach(var shank in shanks)
|
||||
foreach (var shank in shanks)
|
||||
{
|
||||
if (shank != null)
|
||||
toolsManager.DeleteNcShank(shank.ShankId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
toolsManager.DeleteFamily(famId);
|
||||
|
||||
// Update Nc families
|
||||
@@ -2426,7 +2424,7 @@ namespace Step.NC
|
||||
|
||||
// Get shank occupied space
|
||||
toolsManager.GetShankMaxSpaceOccupied(shankToBeLoaded.ShankId, out int maxRight, out int maxLeft);
|
||||
|
||||
|
||||
// Check if tool can fit in the position considering other tools
|
||||
foreach (var mountedTool in magazineMountedTools)
|
||||
{
|
||||
@@ -2441,7 +2439,7 @@ namespace Step.NC
|
||||
decPosition = decPosition < positionId ? decPosition + magConfig.MaxPositions : decPosition;
|
||||
incPosition = incPosition > positionId ? incPosition - magConfig.MaxPositions : incPosition;
|
||||
}
|
||||
|
||||
|
||||
// Right check
|
||||
if (positionId < decPosition)
|
||||
{
|
||||
@@ -2496,23 +2494,31 @@ namespace Step.NC
|
||||
return cmsError;
|
||||
|
||||
data = new DTOAssistedToolingEndValueModel(tmpData);
|
||||
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
public CmsError TerminateAssistedProcedure(int magazineId)
|
||||
public CmsError TerminateAssistedProcedure(int magazineId, bool writeData)
|
||||
{
|
||||
CmsError cmsError = StartEditTooling(magazineId);
|
||||
if (!cmsError.IsError())
|
||||
if (writeData)
|
||||
{
|
||||
cmsError = StopEditTooling(magazineId);
|
||||
CmsError cmsError = StartEditTooling(magazineId);
|
||||
if (!cmsError.IsError())
|
||||
{
|
||||
return numericalControl.PLC_WTerminateAssistedToolingProcedure();
|
||||
// Write tool table new data
|
||||
cmsError = StopEditTooling(magazineId);
|
||||
if (!cmsError.IsError())
|
||||
{
|
||||
// Close procedure
|
||||
return numericalControl.PLC_WTerminateAssistedToolingProcedure();
|
||||
}
|
||||
}
|
||||
return cmsError;
|
||||
}
|
||||
else
|
||||
{
|
||||
return numericalControl.PLC_WTerminateAssistedToolingProcedure();
|
||||
}
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
#endregion Osai/Fanuc Tools
|
||||
@@ -2540,7 +2546,7 @@ namespace Step.NC
|
||||
alreadyReadScada.Add(schema.Id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
@@ -2576,7 +2582,7 @@ namespace Step.NC
|
||||
Enabled = Convert.ToBoolean(val)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (layer.Images.ElementAtOrDefault(i) != null)
|
||||
{
|
||||
// Read isVisible from PLC
|
||||
@@ -2615,11 +2621,11 @@ namespace Step.NC
|
||||
SCADA_MEM_TYPE type = SupportFunctions.GetMemTypeFromString(layer.Inputs[i].Status.Type);
|
||||
// Read value from PLC
|
||||
cmsError = numericalControl.PLC_RScadaValue(layer.Inputs[i].Status.MemValueIndex, type, ref val2);
|
||||
if (cmsError.IsError())
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// if type is real approximate to configurated decimal digits
|
||||
if(type == SCADA_MEM_TYPE.REAL)
|
||||
if (type == SCADA_MEM_TYPE.REAL)
|
||||
{
|
||||
double tmpVal = Math.Round(Convert.ToDouble(val2), layer.Inputs[i].Status.Round);
|
||||
val2 = tmpVal;
|
||||
@@ -2649,7 +2655,7 @@ namespace Step.NC
|
||||
|
||||
if (layer.Images.Count() > max)
|
||||
max = layer.Images.Count();
|
||||
|
||||
|
||||
if (layer.Inputs.Count() > max)
|
||||
max = layer.Inputs.Count();
|
||||
|
||||
@@ -2658,7 +2664,7 @@ namespace Step.NC
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
//DTOScadaModel scada = new DTOScadaModel
|
||||
//{
|
||||
// Layers = prodScada.Layers.Select(x => new DTOScadaLayerModel()
|
||||
|
||||
@@ -186,12 +186,12 @@ namespace Step.Controllers.WebApi
|
||||
{
|
||||
bool passwordIsValid = maintenancesController.CheckPassword(password.Password, data.CmsMachineIdNumber, maintData.PlcCounter, out controlWord);
|
||||
if (!passwordIsValid)
|
||||
return BadRequest(API_ERROR_KEYS.PASSWORD_IS_INVALID);
|
||||
}
|
||||
return BadRequest(API_ERROR_KEYS.PASSWORD_IS_INVALID);
|
||||
}
|
||||
|
||||
|
||||
// Check if maintenance id
|
||||
PerformedMaintenanceModel performed = maintenancesController.PerformeMaintenance(maintData.PlcCounter, maintenanceId, Convert.ToInt32(userId.Value), controlWord);
|
||||
PerformedMaintenanceModel performed = maintenancesController.PerformeMaintenance(maintData.PlcCounter/60, maintenanceId, Convert.ToInt32(userId.Value), controlWord);
|
||||
if (performed == null)
|
||||
return NotFound();
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using CMS_CORE_Library.Models;
|
||||
using Step.Database.Controllers;
|
||||
using Step.Database.Controllers;
|
||||
using Step.Model.DatabaseModels;
|
||||
using Step.Model.DTOModels;
|
||||
using Step.Model.DTOModels.AlarmModels;
|
||||
@@ -29,7 +28,7 @@ namespace Step.Listeners.Database
|
||||
List<DbNcToolModel> dbTools = controller.FindTools();
|
||||
if (dbTools.Count > 0)
|
||||
{
|
||||
// Loop through new data
|
||||
// Loop through new data
|
||||
foreach (var live in data.UpdatedLives)
|
||||
{
|
||||
// Find tool and update residual life
|
||||
@@ -81,21 +80,26 @@ namespace Step.Listeners.Database
|
||||
{
|
||||
case 1:
|
||||
return (byte)(oldValue | (1 << 0));
|
||||
|
||||
case 2:
|
||||
return (byte)(oldValue | (1 << 1));
|
||||
|
||||
case 3:
|
||||
return (byte)(oldValue | (1 << 2));
|
||||
|
||||
case 9:
|
||||
return (byte)(oldValue & ~(1 << 0));
|
||||
|
||||
case 10:
|
||||
return (byte)(oldValue & ~(1 << 1));
|
||||
|
||||
case 11:
|
||||
return (byte)(oldValue & ~(1 << 2));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public static void UpdateQueue(object queue)
|
||||
{
|
||||
List<DTOQueueModel> newQueue = queue as List<DTOQueueModel>;
|
||||
@@ -118,7 +122,7 @@ namespace Step.Listeners.Database
|
||||
{
|
||||
// Intersect old alarms data with new data
|
||||
DTOAlarmsModel differences = LastAlarms.GetDifferences(alarms);
|
||||
if(!AlmDifferences.Equals(differences))
|
||||
if (!AlmDifferences.Equals(differences))
|
||||
{
|
||||
AlmDifferences = differences;
|
||||
|
||||
@@ -228,12 +232,12 @@ namespace Step.Listeners.Database
|
||||
public static void ManageAssisedToolingProcedure(object assTool)
|
||||
{
|
||||
DTOAssistedToolingEndValueModel assToolingData = assTool as DTOAssistedToolingEndValueModel;
|
||||
if(!LastToolingData.Equals(assToolingData))
|
||||
if (!LastToolingData.Equals(assToolingData))
|
||||
{
|
||||
LastToolingData = assToolingData;
|
||||
if (assToolingData.IsActive)
|
||||
{
|
||||
using(NcToolManagerController toolManager = new NcToolManagerController())
|
||||
using (NcToolManagerController toolManager = new NcToolManagerController())
|
||||
{
|
||||
switch (assToolingData.Action)
|
||||
{
|
||||
@@ -241,13 +245,14 @@ namespace Step.Listeners.Database
|
||||
{
|
||||
// Find shank loaded in the position
|
||||
var shank = toolManager.FindShanksByPositions(assToolingData.MagazineId, assToolingData.PositionId);
|
||||
if(shank != null)
|
||||
if (shank != null)
|
||||
{
|
||||
// Unload Tool from magazine
|
||||
var pos = toolManager.UnloadShankInMagazine((byte)assToolingData.MagazineId, (byte)assToolingData.PositionId, shank);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ASSISTED_TOOLING_ACTION.EXCHANGE:
|
||||
{
|
||||
// Find shank loaded in the position
|
||||
@@ -260,7 +265,7 @@ namespace Step.Listeners.Database
|
||||
|
||||
// Find shank by toolId
|
||||
var shankToLoad = toolManager.FindShankByToolId(assToolingData.ToolId);
|
||||
if(shankToLoad != null)
|
||||
if (shankToLoad != null)
|
||||
{
|
||||
// Load shank in magazine
|
||||
var pos = toolManager.LoadShankInMagazine((byte)assToolingData.MagazineId, (byte)assToolingData.PositionId, shankToLoad);
|
||||
@@ -272,7 +277,10 @@ namespace Step.Listeners.Database
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
ncHandler.TerminateAssistedProcedure(assToolingData.MagazineId);
|
||||
// Close procedure
|
||||
ncHandler.TerminateAssistedProcedure(assToolingData.MagazineId,
|
||||
assToolingData.Action != ASSISTED_TOOLING_ACTION.NONE
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ export default class MaintenanceCard extends Vue {
|
||||
if(m.createdByCms) {
|
||||
// if maintenance is created by cms open password modal
|
||||
ModalHelper.ShowMaintenancePassword(PasswordDialog, m, (data) => {
|
||||
this.RunMaintenance(m)
|
||||
this.RunMaintenance(m, data)
|
||||
})
|
||||
}
|
||||
else {
|
||||
@@ -190,11 +190,13 @@ export default class MaintenanceCard extends Vue {
|
||||
ModalHelper.AskConfirm(this.$options.filters.localize("modal_confirm_title", "Richiesta di conferma"),
|
||||
this.$options.filters.localize("modal_confirm_perform_maintenance", "Sei sicuro di aver eseguito questa manutenzione?"),
|
||||
() =>
|
||||
this.RunMaintenance(m)
|
||||
this.RunMaintenance(m, "")
|
||||
, null);
|
||||
}
|
||||
}
|
||||
async RunMaintenance(m){
|
||||
async RunMaintenance(m, password){
|
||||
m.password = password
|
||||
|
||||
new MaintenanceService().RunMaintenance(m).then((performedMaint) => {
|
||||
if(performedMaint && performedMaint.id){
|
||||
// Delete from Expired List
|
||||
|
||||
@@ -25,7 +25,8 @@ export default class PasswordDialog extends Vue{
|
||||
}
|
||||
confirmPassword() {
|
||||
let onConf = this.onConfirm()
|
||||
onConf.call(this.value)
|
||||
|
||||
onConf.call(this, this.value)
|
||||
|
||||
this.close();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,8 @@ export class ModalHelper {
|
||||
};
|
||||
|
||||
public static MaintenancePasswordData = {
|
||||
maintenance: null
|
||||
maintenance: null,
|
||||
value: ""
|
||||
};
|
||||
|
||||
public static GetModalData() {
|
||||
|
||||
Reference in New Issue
Block a user