e8e8d8928b
Added Tools Data Api
718 lines
28 KiB
C#
718 lines
28 KiB
C#
using CMS_CORE;
|
|
using CMS_CORE.Demo;
|
|
using CMS_CORE.Fanuc;
|
|
using CMS_CORE.Osai;
|
|
using CMS_CORE.Siemens;
|
|
using Step.Database.Controllers;
|
|
using Step.Model.DatabaseModels;
|
|
using Step.Model.DTOModels;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using static CMS_CORE_Library.DataStructures;
|
|
using static Step.Config.ServerConfig;
|
|
using static Step.Model.Constants;
|
|
|
|
namespace Step.NC
|
|
{
|
|
public class NcHandler : IDisposable
|
|
{
|
|
public Nc numericalControl;
|
|
|
|
public NcHandler()
|
|
{
|
|
// Choose NC
|
|
numericalControl = SetNumericalControl();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
numericalControl.NC_Disconnect();
|
|
}
|
|
|
|
public CmsError Connect()
|
|
{
|
|
// Connect NC
|
|
if (!numericalControl.NC_IsConnected())
|
|
return numericalControl.NC_Connect();
|
|
|
|
return null;
|
|
}
|
|
|
|
public Nc SetNumericalControl()
|
|
{
|
|
// Return new Numerical control instance choosed from the configuration
|
|
switch (NcConfig.NcVendor)
|
|
{
|
|
case NC_VENDOR.DEMO:
|
|
return new Nc_Demo(NcConfig.NcIpAddress, NcConfig.NcPort);
|
|
|
|
case NC_VENDOR.FANUC:
|
|
return new Nc_Fanuc(NcConfig.NcIpAddress, NcConfig.NcPort, 2000);
|
|
|
|
case NC_VENDOR.SIEMENS:
|
|
return new Nc_Siemens(2000);
|
|
|
|
case NC_VENDOR.OSAI:
|
|
return new Nc_Osai(NcConfig.NcIpAddress, NcConfig.NcPort, 2000);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
#region Read Data
|
|
|
|
public CmsError GetNcGenericData(out DTONcGenericDataModel genericData)
|
|
{
|
|
genericData = new DTONcGenericDataModel(MachineConfig.Model);
|
|
|
|
// Get date time
|
|
DateTime dateTime = new DateTime();
|
|
CmsError cmsError = numericalControl.NC_RDateTime(ref dateTime);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
genericData.DateTime = dateTime;
|
|
|
|
// Get language
|
|
CultureInfo lang = new CultureInfo("en");
|
|
cmsError = numericalControl.NC_RLanguage(ref lang);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
genericData.Language = lang.TwoLetterISOLanguageName;
|
|
|
|
string tmpInfo = "";
|
|
// Get serial number
|
|
cmsError = numericalControl.NC_RSerialNumber(ref tmpInfo);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
genericData.SerialNumber = tmpInfo;
|
|
|
|
// Get software version
|
|
numericalControl.NC_RSoftwareVersion(ref tmpInfo);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
genericData.NcSoftwareVersion = tmpInfo;
|
|
|
|
// Get model name
|
|
numericalControl.NC_RModelName(ref tmpInfo);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
genericData.NcModel = tmpInfo;
|
|
|
|
// Get machine number
|
|
numericalControl.NC_RMachineNumber(ref tmpInfo);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
genericData.CmsMachineIdNumber = tmpInfo;
|
|
|
|
// Get max process number
|
|
ushort procNum = 0;
|
|
numericalControl.NC_RProcessesNum(ref procNum);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
// Max process number
|
|
genericData.ProcessNumber = procNum;
|
|
// Get Installation Date
|
|
genericData.InstallationDate = DateTime.Now;
|
|
// Get PLC version
|
|
genericData.PlcVersion = "1.0.0";
|
|
// Get PLC version
|
|
genericData.UnitOfMeasurement = "mm";
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError GetNcAlarms(out DTOAlarmsModel alarms)
|
|
{
|
|
alarms = new DTOAlarmsModel();
|
|
List<AlarmModel> tmpAlarms = new List<AlarmModel>();
|
|
|
|
// Read NC active alarms
|
|
CmsError cmsError = numericalControl.NC_RActiveAlarms(ref tmpAlarms);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
// Create response list from NC data
|
|
foreach (AlarmModel ncAlarm in tmpAlarms)
|
|
{
|
|
alarms.NcAlarms.Add(new GenericAlarmModel()
|
|
{
|
|
Id = ncAlarm.Id,
|
|
Message = ncAlarm.Message,
|
|
DateTime = DateTime.Now,
|
|
RestorationIsEnabled = false
|
|
});
|
|
}
|
|
|
|
// Get NC max process number
|
|
ushort maxProcNumber = 0;
|
|
cmsError = numericalControl.NC_RProcessesNum(ref maxProcNumber);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
// For each process
|
|
for (ushort i = 1; i <= maxProcNumber; i++)
|
|
{
|
|
// Get process active alarms
|
|
numericalControl.PROC_RActiveAlarms(i, ref tmpAlarms);
|
|
// Create response list from NC data
|
|
foreach (AlarmModel processAlarm in tmpAlarms)
|
|
{
|
|
alarms.ProcessAlarms.Add(new ProcessAlarmModel()
|
|
{
|
|
Id = processAlarm.Id,
|
|
Message = processAlarm.Message,
|
|
Process = processAlarm.Process,
|
|
DateTime = DateTime.Now,
|
|
RestorationIsEnabled = false
|
|
});
|
|
}
|
|
}
|
|
|
|
List<PlcAlarmModel> plcAlarms = new List<PlcAlarmModel>();
|
|
// Read PLC Active Messages
|
|
cmsError = numericalControl.PLC_RActiveMessages(ref plcAlarms);
|
|
bool restorationIsEnabled = false;
|
|
foreach (PlcAlarmModel plcAlarm in plcAlarms)
|
|
{
|
|
var configuredAlarm = InitialAlarmsConfig.Where(x => x.PlcId == plcAlarm.Id).FirstOrDefault();
|
|
if (configuredAlarm == null)
|
|
restorationIsEnabled = false;
|
|
else
|
|
restorationIsEnabled = configuredAlarm.RestoreIsActive;
|
|
|
|
// Create response list from plc data
|
|
alarms.PlcAlarms.Add(new DTOPlcAlarmModel()
|
|
{
|
|
Id = plcAlarm.Id,
|
|
IsWarning = plcAlarm.IsWarning,
|
|
Process = plcAlarm.Process,
|
|
RestorationIsActive = plcAlarm.RestorationIsActive,
|
|
DateTime = DateTime.Now,
|
|
RestorationIsEnabled = restorationIsEnabled
|
|
});
|
|
}
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError GetAxesPositions(out List<DTOAxesModel> axes)
|
|
{
|
|
axes = new List<DTOAxesModel>();
|
|
|
|
// Get NC max process number
|
|
ushort maxProcNumber = 0;
|
|
CmsError cmsError = numericalControl.NC_RProcessesNum(ref maxProcNumber);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
// For each process
|
|
for (ushort i = 1; i <= maxProcNumber; i++)
|
|
{
|
|
cmsError = GetAxesPositionsByProcess(i, out DTOAxesModel axis);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
axes.Add(axis);
|
|
}
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError GetAxesPositionsByProcess(ushort processNum, out DTOAxesModel axes)
|
|
{
|
|
axes = new DTOAxesModel();
|
|
|
|
CmsError cmsError = numericalControl.AXES_RInterpPosition(processNum, ref axes.interpolated);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
numericalControl.AXES_RMachinePosition(processNum, ref axes.machine);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
numericalControl.AXES_RProgrPosition(processNum, ref axes.programmePos);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
numericalControl.AXES_RDistanceToGo(processNum, ref axes.toGo);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
//numericalControl.AXES_RFollowingError(1, ref axes.followingErr);
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError GetPowerOnData(out DTOPowerOnDataModel resultPowerOnData)
|
|
{
|
|
resultPowerOnData = new DTOPowerOnDataModel();
|
|
|
|
// Init object
|
|
PreAndPostPowerOnModel prePostPowerOn = new PreAndPostPowerOnModel
|
|
{
|
|
PostPowerOn = new PostPowerOnModel(),
|
|
PrePowerOn = new PrePowerOnModel()
|
|
};
|
|
|
|
// Read pre and post power on data
|
|
CmsError cmsError = numericalControl.PLC_RPowerOnData(ref prePostPowerOn);
|
|
if (cmsError.IsError())
|
|
return cmsError;
|
|
|
|
// Set return object
|
|
resultPowerOnData.PrePowerOn = prePostPowerOn.PrePowerOn;
|
|
resultPowerOnData.PostPowerOn = prePostPowerOn.PostPowerOn;
|
|
|
|
// Read axes procedure data from
|
|
cmsError = numericalControl.PLC_RAxesResetData(ref resultPowerOnData.AxisReset);
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError GetProcessesData(out DTOProcessesDataModel processesData)
|
|
{
|
|
processesData = new DTOProcessesDataModel();
|
|
|
|
// Get NC max process number
|
|
ushort maxProcNumber = 0;
|
|
CmsError cmsError = numericalControl.NC_RProcessesNum(ref maxProcNumber);
|
|
if (cmsError.errorCode != 0)
|
|
return cmsError;
|
|
|
|
PROC_STATUS status = PROC_STATUS.IDLE;
|
|
// For each process get info
|
|
for (ushort i = 1; i <= maxProcNumber; i++)
|
|
{
|
|
ProcessDataModel tmpProcPP = new ProcessDataModel();
|
|
// Get process status
|
|
cmsError = numericalControl.PROC_RStatusAndData(i, ref tmpProcPP);
|
|
// if at least one process is in run, NC is running
|
|
// Add to list
|
|
processesData.processes.Add(new ProcessModel()
|
|
{
|
|
Id = tmpProcPP.Id,
|
|
IsInAlarm = tmpProcPP.IsInAlarm,
|
|
PartProgramName = tmpProcPP.PartProgramName,
|
|
Reps = tmpProcPP.Reps,
|
|
Status = tmpProcPP.Status,
|
|
Type = tmpProcPP.Type,
|
|
Visible = tmpProcPP.Visible
|
|
});
|
|
|
|
if (tmpProcPP.IsSelected && processesData.selectedProcess == 0) // TODO remove with multi-process
|
|
processesData.selectedProcess = (ushort)tmpProcPP.Id;
|
|
|
|
// Check if there are running process
|
|
if (!processesData.isRunning)
|
|
{
|
|
// Get process status
|
|
cmsError = numericalControl.PROC_RStatus(i, ref status);
|
|
if (status == PROC_STATUS.RUN || status == PROC_STATUS.HOLD)
|
|
processesData.isRunning = true;
|
|
else
|
|
status = PROC_STATUS.IDLE;
|
|
}
|
|
}
|
|
// Read selected axes
|
|
cmsError = numericalControl.AXES_RSelectedAxis(ref processesData.selectedAxis);
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError GetFunctionsMappedWithNC(out List<DTORuntimeFunctionalityModel> functionsAccessList)
|
|
{
|
|
functionsAccessList = new List<DTORuntimeFunctionalityModel>();
|
|
// Read plc functionality
|
|
List<FunctionalityModel> functionalityList = null;
|
|
CmsError cmsError = numericalControl.PLC_RFunctionAccess(ref functionalityList);
|
|
|
|
// If empty return
|
|
if (functionalityList == null || functionalityList.Count == 0)
|
|
return cmsError;
|
|
|
|
using (FunctionsAccessController functionsAccessController = new FunctionsAccessController())
|
|
{
|
|
// Map plc and database data
|
|
functionsAccessList = functionsAccessController.GetFunctionsMappedWithPlc(functionalityList);
|
|
}
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError GetExpiredMaintenances(out List<DTOExpiredMaintenanceModel> expiredMaintenance)
|
|
{
|
|
// Return value
|
|
expiredMaintenance = new List<DTOExpiredMaintenanceModel>();
|
|
|
|
// List of PLC counters
|
|
List<CounterModel> counters = new List<CounterModel>();
|
|
// Get counters values from PLC
|
|
CmsError cmsError = numericalControl.PLC_RMachineCounters(ref counters);
|
|
if (cmsError.IsError())
|
|
return cmsError;
|
|
|
|
using (MaintenancesController maintenancesController = new MaintenancesController())
|
|
{
|
|
// Get the last performed maintenance for each maintenance
|
|
List<PerformedMaintenanceModel> performedMaintenance = maintenancesController.FindLastMaintenance();
|
|
|
|
// Get all the active maintenances
|
|
List<MaintenanceModel> maintenances = maintenancesController.FindAll(); // TODO db or config file?
|
|
|
|
foreach (var currMaintenance in maintenances)
|
|
{
|
|
// Get matching last performed maintenance for current maintenance
|
|
var performed = performedMaintenance.Find(x => x.MaintenanceId == currMaintenance.MaintenanceId);
|
|
|
|
switch (currMaintenance.Type)
|
|
{
|
|
case MAINT_MACHINE_INTERVAL_TYPE:
|
|
{
|
|
// Get matching counter for the current maintenance
|
|
var counter = counters.Find(x => x.Id == currMaintenance.CounterId);
|
|
|
|
int perfVal = 0;
|
|
if (performed != null)
|
|
perfVal = performed.CounterValue;
|
|
|
|
// MAINTENANCE_INTERVAL <= PLC - LASTPERFORMED
|
|
if (currMaintenance.Interval <= counter.Value - perfVal)
|
|
{
|
|
// Update last expiration date if null
|
|
if (currMaintenance.LastExpirationDate == null)
|
|
{
|
|
maintenancesController.UpdateLastExpirationDate(currMaintenance.MaintenanceId, DateTime.Now);
|
|
currMaintenance.LastExpirationDate = DateTime.Now;
|
|
}
|
|
|
|
// Add item to return list
|
|
expiredMaintenance.Add(new DTOExpiredMaintenanceModel()
|
|
{
|
|
Id = currMaintenance.MaintenanceId,
|
|
ExpirationDate = (DateTime)currMaintenance.LastExpirationDate
|
|
});
|
|
}
|
|
}
|
|
break;
|
|
|
|
case MAINT_EXPIRATION_DATE_TYPE:
|
|
{
|
|
// Already performed
|
|
if (performed != null)
|
|
break;
|
|
// DEADLINE <= NOW
|
|
if (currMaintenance.Deadline <= DateTime.Now)
|
|
// Add item to return list
|
|
expiredMaintenance.Add(new DTOExpiredMaintenanceModel()
|
|
{
|
|
Id = currMaintenance.MaintenanceId,
|
|
ExpirationDate = currMaintenance.Deadline
|
|
});
|
|
}
|
|
break;
|
|
|
|
case MAINT_TIME_INTERVAL_TYPE:
|
|
{
|
|
// Get last performed, default value is maintenance creation date
|
|
DateTime perfDate = currMaintenance.CreationDate;
|
|
if (performed != null)
|
|
perfDate = performed.Date;
|
|
|
|
// Now - last performed = elapsed interval since last maintenance
|
|
TimeSpan timePassedFromLastMaint = DateTime.Now.Subtract(perfDate);
|
|
// Convert in minutes
|
|
double minutesPassedFromLastMaint = timePassedFromLastMaint.TotalMinutes;
|
|
|
|
// Interval - passed minutes since last maintenance
|
|
if (currMaintenance.Interval <= minutesPassedFromLastMaint)
|
|
{
|
|
// Update last expiration date
|
|
if (currMaintenance.LastExpirationDate == null)
|
|
{
|
|
// Exp date = now - ( expiration intervall)
|
|
DateTime expirationDate = DateTime.Now.Subtract(TimeSpan.FromMinutes(minutesPassedFromLastMaint - currMaintenance.Interval));
|
|
|
|
maintenancesController.UpdateLastExpirationDate(currMaintenance.MaintenanceId, expirationDate);
|
|
currMaintenance.LastExpirationDate = expirationDate;
|
|
}
|
|
|
|
// Add item to return list
|
|
expiredMaintenance.Add(new DTOExpiredMaintenanceModel()
|
|
{
|
|
Id = currMaintenance.MaintenanceId,
|
|
ExpirationDate = (DateTime)currMaintenance.LastExpirationDate
|
|
});
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError GetUserSoftKeys(out List<DTOUserSoftKeyModel> softKeys)
|
|
{
|
|
softKeys = new List<DTOUserSoftKeyModel>();
|
|
List<SoftKeysModel> plcSoftKeys = new List<SoftKeysModel>();
|
|
|
|
// Get softkeys data from PLC
|
|
CmsError cmsError = numericalControl.PLC_RUserSoftKeys(ref plcSoftKeys);
|
|
if (cmsError.IsError() || plcSoftKeys.Count == 0)
|
|
return cmsError;
|
|
|
|
foreach (var softKey in SoftKeysConfig)
|
|
{
|
|
// Check type of the selected softkey
|
|
if (softKey.Type == SOFTKEY_TYPE.GROUP)
|
|
{
|
|
// Foreach subkey create a softkey
|
|
foreach (var subkey in softKey.SubKeys)
|
|
{
|
|
// Find the plc matching data
|
|
var plcSoftKey = plcSoftKeys.Find(x => x.Id == subkey.PlcId);
|
|
// Create and add new user softkey model
|
|
softKeys.Add(new DTOUserSoftKeyModel()
|
|
{
|
|
Id = subkey.Id,
|
|
Active = plcSoftKey.Active,
|
|
Category = softKey.Category,
|
|
Value = plcSoftKey.Value
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Find the plc matching data
|
|
var plcSoftKey = plcSoftKeys.Find(x => x.Id == softKey.PlcId);
|
|
softKeys.Add(new DTOUserSoftKeyModel()
|
|
{
|
|
Id = softKey.Id,
|
|
Active = plcSoftKey.Active,
|
|
Category = softKey.Category,
|
|
Value = plcSoftKey.Value
|
|
});
|
|
}
|
|
}
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError GetNcSoftKeys(out List<DTONcSoftKeyModel> ncSoftKeys)
|
|
{
|
|
ncSoftKeys = new List<DTONcSoftKeyModel>();
|
|
List<SoftKeysModel> plcSoftKeys = new List<SoftKeysModel>();
|
|
|
|
// Get Nc softkeys data from PLC
|
|
CmsError cmsError = numericalControl.PLC_RNcSoftKeys(ref plcSoftKeys);
|
|
if (cmsError.IsError() || plcSoftKeys.Count == 0)
|
|
return cmsError;
|
|
|
|
foreach (var softKey in NcSoftKeysConfig)
|
|
{
|
|
// Find the plc matching data
|
|
var plcSoftKey = plcSoftKeys.Find(x => x.Id == softKey.Id);
|
|
|
|
// Create and add Nc softkey model
|
|
ncSoftKeys.Add(new DTONcSoftKeyModel()
|
|
{
|
|
Id = softKey.Id,
|
|
Active = plcSoftKey.Active,
|
|
Value = plcSoftKey.Value
|
|
});
|
|
}
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError GetHeadsData(out List<DTOHeadModel> heads)
|
|
{
|
|
// Returned value
|
|
heads = new List<DTOHeadModel>();
|
|
// Number of configured heads
|
|
int headsNumber = HeadsConfig.Count;
|
|
|
|
List<HeadDataModel> plcHeads = new List<HeadDataModel>();
|
|
// Read value from PLC
|
|
CmsError cmsError = numericalControl.PLC_RHeadsData(plcHeads, headsNumber);
|
|
if (cmsError.IsError())
|
|
return cmsError;
|
|
|
|
foreach (var head in plcHeads)
|
|
{
|
|
// Get current head config
|
|
var configuredHead = HeadsConfig.Find(x => x.Id == head.Id);
|
|
// Create different model according on type
|
|
switch (configuredHead.Type)
|
|
{
|
|
case HEAD_TYPE.SPINDLE:
|
|
{
|
|
heads.Add(new DTOSpindleModel()
|
|
{
|
|
Id = head.Id,
|
|
Process = head.Process,
|
|
Type = configuredHead.Type.ToString(),
|
|
inWarning = head.Load_Abrasive >= configuredHead.WarningLimit,
|
|
inAlarm = head.Load_Abrasive >= configuredHead.AlarmLimit,
|
|
OverrideEditable = head.OverrideEditable,
|
|
ActualSpeed = head.ActualSpeed_Pressure,
|
|
Load = head.Load_Abrasive,
|
|
MountedTool = (ushort)head.MountedTool_Vacum,
|
|
Override = head.Override,
|
|
IsActive = head.IsActive,
|
|
IsSelected = head.IsSelected
|
|
});
|
|
}
|
|
break;
|
|
|
|
case HEAD_TYPE.AWJ:
|
|
{
|
|
float vacumValue = (float)head.MountedTool_Vacum / 100;
|
|
heads.Add(new DTOAbrasiveWaterJet()
|
|
{
|
|
Id = head.Id,
|
|
Process = head.Process,
|
|
Type = configuredHead.Type.ToString(),
|
|
inWarning = vacumValue >= configuredHead.WarningLimit,
|
|
inAlarm = vacumValue >= configuredHead.AlarmLimit,
|
|
OverrideEditable = head.OverrideEditable,
|
|
ActualPressure = head.ActualSpeed_Pressure,
|
|
Abrasive = head.Load_Abrasive,
|
|
Vacum = vacumValue,
|
|
Override = head.Override,
|
|
IsActive = head.IsActive,
|
|
IsSelected = head.IsSelected
|
|
});
|
|
}
|
|
break;
|
|
|
|
case HEAD_TYPE.WJ:
|
|
{
|
|
heads.Add(new DTOWaterJet()
|
|
{
|
|
Id = head.Id,
|
|
Process = head.Process,
|
|
Type = configuredHead.Type.ToString(),
|
|
inAlarm = false,
|
|
inWarning = false,
|
|
ActualPressure = head.ActualSpeed_Pressure,
|
|
OverrideEditable = head.OverrideEditable,
|
|
Override = head.Override,
|
|
IsActive = head.IsActive,
|
|
IsSelected = head.IsSelected
|
|
});
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError ReadAxisData(out List<DTOAxisNameModel> axesNames)
|
|
{
|
|
axesNames = new List<DTOAxisNameModel>();
|
|
List<AxisModel> plcAxes = new List<AxisModel>();
|
|
// Read selected process
|
|
ushort selectedProcess = 0;
|
|
CmsError cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess);
|
|
if (cmsError.IsError())
|
|
return cmsError;
|
|
// Read axes names
|
|
cmsError = numericalControl.AXES_RAxesNames(selectedProcess, ref plcAxes);
|
|
|
|
axesNames = plcAxes.Select(x => new DTOAxisNameModel()
|
|
{
|
|
Id = x.Id,
|
|
Name = x.Name
|
|
}).ToList();
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError GetToolTableConfiguration(out ToolTableConfiguration config)
|
|
{
|
|
config = new ToolTableConfiguration();
|
|
return numericalControl.TOOLS_RConfiguration(ref config);
|
|
}
|
|
|
|
public CmsError GetToolTableData(out List<SiemensToolModel> config)
|
|
{
|
|
config = new List<SiemensToolModel>();
|
|
return numericalControl.TOOLS_RToolTable(ref config);
|
|
}
|
|
|
|
#endregion Read Data
|
|
|
|
#region Write data
|
|
|
|
public CmsError PutNcSoftKeyClick(uint id)
|
|
{
|
|
// Write Nc softkey press to plc
|
|
CmsError cmsError = numericalControl.PLC_WNcSoftKey(id);
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError PutUserSoftKeyClick(uint id)
|
|
{
|
|
// Write user softkey press to plc
|
|
return numericalControl.PLC_WUserSoftKey(id);
|
|
}
|
|
|
|
public CmsError RefreshAlarm(uint id)
|
|
{
|
|
// Write in memory the request to refresh the alarm
|
|
return numericalControl.PLC_WRefreshMessage(id);
|
|
}
|
|
|
|
public CmsError RestoreAlarm(uint id)
|
|
{
|
|
// Write in memory the request to restore the alarm
|
|
return numericalControl.PLC_WRestoreMessage(id);
|
|
}
|
|
|
|
public CmsError RefreshAllAlarms()
|
|
{
|
|
return numericalControl.PLC_WRefreshAllMessages();
|
|
}
|
|
|
|
public CmsError PutSelectProcess(ushort procNumber)
|
|
{
|
|
return numericalControl.PROC_WSelectProcess(procNumber);
|
|
}
|
|
|
|
public CmsError PutSelectAxis(byte axisId)
|
|
{
|
|
return numericalControl.AXES_WSelectAxis(axisId);
|
|
}
|
|
|
|
public CmsError PutOverride(uint id, string action)
|
|
{
|
|
HEAD_OVERRIDE_SIGN sign = HEAD_OVERRIDE_SIGN.MINUS;
|
|
if (action == "plus")
|
|
sign = HEAD_OVERRIDE_SIGN.PLUS;
|
|
|
|
CmsError cmsError = numericalControl.PLC_WHeadOverride(id, sign);
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError PutPowerOnData(uint id)
|
|
{
|
|
// Set to true power on data by id
|
|
return numericalControl.PLC_WPowerOnData(id, true);
|
|
}
|
|
|
|
#endregion Write data
|
|
}
|
|
} |