Fix demo info
Fix queue item status Added start&stop
This commit is contained in:
Binary file not shown.
@@ -641,7 +641,7 @@ public static class ThreadsFunctions
|
||||
if (ncHandler.numericalControl.NC_IsConnected())
|
||||
{
|
||||
// Read data
|
||||
libraryError = ncHandler.GetSelectedProcessQueue(out List<DTOQueueModel> queue);
|
||||
libraryError = ncHandler.UpdateAndGetPPQueue(out List<DTOQueueModel> queue);
|
||||
if (libraryError.IsError())
|
||||
ManageLibraryError(libraryError);
|
||||
|
||||
|
||||
@@ -60,6 +60,14 @@ namespace Step.Model
|
||||
MACHINE_INTERVAL = 1,
|
||||
TIME_INTERVAL = 2
|
||||
}
|
||||
|
||||
public enum QUEUE_ITEM_STATUS
|
||||
{
|
||||
NOT_ACTIVE = 0,
|
||||
RUNNING = 1,
|
||||
WAITING_OPERATOR = 2,
|
||||
FINISHED = 3
|
||||
}
|
||||
|
||||
public static class NC_VENDOR
|
||||
{
|
||||
@@ -192,7 +200,6 @@ namespace Step.Model
|
||||
public const string OPTION_NOT_ACTIVE = "error_option_not_active";
|
||||
}
|
||||
|
||||
|
||||
// File paths
|
||||
public const string MAINTENANCE_ATTACHMENT_PATH = "C:\\CMS\\STEP\\attachment\\";
|
||||
public const string TEMP_FILE = @"C:/CMS/STEP/tmp/pp/";
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Step.Model.DTOModels
|
||||
|
||||
public string AbsolutePath { get; set; }
|
||||
|
||||
public QUEUE_STATUS Status { get; set; }
|
||||
public QUEUE_ITEM_STATUS Status { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
|
||||
+68
-44
@@ -149,17 +149,14 @@ namespace Step.NC
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
public CmsError UploadPartProgram(string localPath, string fileName, out ActiveProgramDataModel programData)
|
||||
public CmsError UploadPartProgram(string localPath, string fileName, out string newFilePath)
|
||||
{
|
||||
programData = new ActiveProgramDataModel();
|
||||
// Upload to NC
|
||||
string newFilePath = "";
|
||||
newFilePath = "";
|
||||
CmsError cmsError = numericalControl.FILES_UploadPartProgram(localPath, fileName, ref newFilePath);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
programData.Path = newFilePath;
|
||||
|
||||
// Delete local file
|
||||
File.Delete(localPath + "\\" + fileName);
|
||||
|
||||
@@ -169,20 +166,56 @@ namespace Step.NC
|
||||
public CmsError UploadPartProgramAndActivate(string localPath, string fileName, out ActiveProgramDataModel programData)
|
||||
{
|
||||
programData = new ActiveProgramDataModel();
|
||||
|
||||
// Upload to NC
|
||||
string newFilePath = "";
|
||||
CmsError cmsError = UploadPartProgram(localPath, fileName, out programData);
|
||||
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);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// Activate updated program
|
||||
return numericalControl.FILES_WSetActiveProgram(selectedProcess, newFilePath, ref programData);
|
||||
}
|
||||
|
||||
public CmsError GetSelectedProcessQueue(out List<DTOQueueModel> queueList)
|
||||
public CmsError UploadPartProgramAddToQueue(string localPath, string fileName, int reps, out DTOQueueModel queueItem)
|
||||
{
|
||||
queueItem = new DTOQueueModel();
|
||||
// Upload to NC
|
||||
CmsError cmsError = UploadPartProgram(localPath, fileName, out string newFilePath);
|
||||
|
||||
// Get selectedProcess id
|
||||
ushort selectedProcess = 0;
|
||||
cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
queueItem = new DTOQueueModel()
|
||||
{
|
||||
PartProgramName = fileName,
|
||||
Reps = reps,
|
||||
RemainingReps = reps,
|
||||
AbsolutePath = newFilePath,
|
||||
Status = QUEUE_ITEM_STATUS.NOT_ACTIVE
|
||||
};
|
||||
|
||||
// Check if there is already a pp queue
|
||||
if (!PartProgramQueue.ContainsKey(selectedProcess))
|
||||
PartProgramQueue.Add(selectedProcess, new List<DTOQueueModel>());
|
||||
|
||||
queueItem.Id = SupportFunctions.GetNextId(PartProgramQueue[selectedProcess].Select(x => x.Id));
|
||||
|
||||
// Add new process to
|
||||
PartProgramQueue[selectedProcess].Add(queueItem);
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
public CmsError UpdateAndGetPPQueue(out List<DTOQueueModel> queueList)
|
||||
{
|
||||
queueList = new List<DTOQueueModel>();
|
||||
// Get selectedProcess id
|
||||
@@ -211,9 +244,12 @@ namespace Step.NC
|
||||
{
|
||||
// Set as finished
|
||||
actualItem.RemainingReps = 0;
|
||||
actualItem.Status = QUEUE_ITEM_STATUS.FINISHED;
|
||||
if (PartProgramQueue[selectedProcess].ElementAtOrDefault(QueueRunningIndex + 1) != null)
|
||||
// if next exist set next as current pp
|
||||
// if next part program exists, set next pp as current pp
|
||||
QueueRunningIndex += 1;
|
||||
|
||||
// Change part program
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,8 +257,18 @@ namespace Step.NC
|
||||
|
||||
// Set status
|
||||
if (PartProgramQueue.ContainsKey(selectedProcess) && PartProgramQueue[selectedProcess].ElementAtOrDefault(QueueRunningIndex) != null)
|
||||
PartProgramQueue[selectedProcess][QueueRunningIndex].Status = queueData.Status;
|
||||
{
|
||||
if (queueData.Status == QUEUE_STATUS.RUNNING || queueData.Status == QUEUE_STATUS.CLOSING)
|
||||
PartProgramQueue[selectedProcess][QueueRunningIndex].Status = QUEUE_ITEM_STATUS.RUNNING;
|
||||
|
||||
if (queueData.Status == QUEUE_STATUS.NOT_ACTIVE)
|
||||
PartProgramQueue[selectedProcess][QueueRunningIndex].Status = QUEUE_ITEM_STATUS.NOT_ACTIVE;
|
||||
|
||||
if (queueData.Status == QUEUE_STATUS.WAITING_OPERATOR)
|
||||
PartProgramQueue[selectedProcess][QueueRunningIndex].Status = QUEUE_ITEM_STATUS.WAITING_OPERATOR;
|
||||
|
||||
}
|
||||
|
||||
return GetProcessQueue(selectedProcess, out queueList);
|
||||
}
|
||||
|
||||
@@ -239,39 +285,6 @@ namespace Step.NC
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
public CmsError UploadPartProgramAddToQueue(string localPath, string fileName, int reps, out DTOQueueModel queueItem)
|
||||
{
|
||||
queueItem = new DTOQueueModel();
|
||||
// Upload to NC
|
||||
CmsError cmsError = UploadPartProgram(localPath, fileName, out ActiveProgramDataModel programData);
|
||||
|
||||
// Get selectedProcess id
|
||||
ushort selectedProcess = 0;
|
||||
cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
queueItem = new DTOQueueModel()
|
||||
{
|
||||
PartProgramName = fileName,
|
||||
Reps = reps,
|
||||
RemainingReps = reps,
|
||||
AbsolutePath = programData.Path,
|
||||
Status = QUEUE_STATUS.NOT_ACTIVE
|
||||
};
|
||||
|
||||
// Check if there is already a pp queue
|
||||
if (!PartProgramQueue.ContainsKey(selectedProcess))
|
||||
PartProgramQueue.Add(selectedProcess, new List<DTOQueueModel>());
|
||||
|
||||
queueItem.Id = SupportFunctions.GetNextId(PartProgramQueue[selectedProcess].Select(x => x.Id));
|
||||
|
||||
// Add new process to
|
||||
PartProgramQueue[selectedProcess].Add(queueItem);
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
public CmsError SwapQueueItems(int processId, int item1Index, int item2Index)
|
||||
{
|
||||
item1Index = item1Index - 1;
|
||||
@@ -340,7 +353,7 @@ namespace Step.NC
|
||||
if (PartProgramQueue[processId].ElementAtOrDefault(itemIndex) == null)
|
||||
return INCORRECT_PARAMETERS_ERROR;
|
||||
// Check if Program is running
|
||||
if (PartProgramQueue[processId][itemIndex].Status == QUEUE_STATUS.RUNNING)
|
||||
if (PartProgramQueue[processId][itemIndex].Status == QUEUE_ITEM_STATUS.RUNNING)
|
||||
return INCORRECT_PARAMETERS_ERROR;
|
||||
|
||||
PartProgramQueue[processId][itemIndex].Reps = reps;
|
||||
@@ -379,6 +392,17 @@ namespace Step.NC
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
public CmsError StartWorkingQueue(int processId)
|
||||
{
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
public CmsError StopWorkingQueue(int processId)
|
||||
{
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
#endregion File manager
|
||||
|
||||
#region Read Data
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Step.Controllers.WebApi
|
||||
}
|
||||
|
||||
[Route("file/info"), HttpGet]
|
||||
public IHttpActionResult GetFileInfo([FromUri]string filePath)
|
||||
public IHttpActionResult GetFileInfo([FromUri]string filePath)
|
||||
{
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
@@ -259,6 +259,32 @@ namespace Step.Controllers.WebApi
|
||||
}
|
||||
}
|
||||
|
||||
[Route("queue/start")]
|
||||
public IHttpActionResult StartWorkingQueue(int processId)
|
||||
{
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
CmsError cmsError = ncHandler.StartWorkingQueue(processId);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
||||
[Route("queue/stop")]
|
||||
public IHttpActionResult StopWorkingQueue(int processId)
|
||||
{
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
CmsError cmsError = ncHandler.StopWorkingQueue(processId);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
||||
public class MoveItems
|
||||
{
|
||||
public int OldPosition;
|
||||
|
||||
Reference in New Issue
Block a user