Data consistency Siemens

This commit is contained in:
ext_luca.pansa@cms.it
2021-02-26 11:00:48 +01:00
parent 9cec214235
commit 055756d3b7
+65
View File
@@ -4460,6 +4460,8 @@ namespace CMS_CORE_Library.Siemens
public override CmsError TOOLS_WLoadToolInMagazine(int magazineId, NewToolInMagazineModel newMagazineTool, ref MountedToolModel newMountedTool)
{
int ackValue = -1;
ReadOkActionValue(out ackValue);
// Check if magazine is occupied
if (MagazineAction.Action != MAGAZINE_ACTIONS.READY)
return MAGAZINE_BUSY_ERROR;
@@ -4631,6 +4633,10 @@ namespace CMS_CORE_Library.Siemens
if (cmsError.IsError())
return cmsError;
cmsError = CheckDimensionConsistency(ackValue);
if (cmsError.IsError())
return cmsError;
// Mount temporarily till the Siemens notification arrives
MoveToolInMagazineList(newMagazineTool.ToolId, magazineId, newMagazineTool.PositionId);
@@ -4646,6 +4652,8 @@ namespace CMS_CORE_Library.Siemens
return NO_ERROR;
}
#region CONSISTENCY CHECKS
private CmsError CheckToolTableConsistency()
{
Thread.Sleep(100);
@@ -4670,6 +4678,63 @@ namespace CMS_CORE_Library.Siemens
return NO_ERROR;
}
private CmsError ReadOkActionValue(out int value)
{
value = -1;
try
{
DataSvc dataSvc = new DataSvc();
//Read Machine status
Item itemToRead = new Item("/Channel/State/aTcAckC[u1, 1]");
dataSvc.Read(itemToRead);
value = Convert.ToInt32(itemToRead.Value);
}
catch (Exception ex)
{
return ManageException(ex);
}
if(value == -1)
{
return SIEMENS_TOOL_TABLE_ERROR;
}
return NO_ERROR;
}
private CmsError CheckDimensionConsistency(int oldValue )
{
bool check = true;
int attempt = 0;
int actualValue = -1;
try
{
while (check)
{
ReadOkActionValue(out actualValue);
if(actualValue > oldValue)
{
return NO_ERROR;
}
else
{
Thread.Sleep(500);
if (attempt == 9)
{
check = false;
}
attempt++;
}
}
}
catch(Exception ex)
{
return ManageException(ex);
}
return SIEMENS_TOOL_TABLE_ERROR;
}
#endregion
public override CmsError TOOLS_WUnloadToolFromMagazine(int magazineId, int positionId)
{
if (MagazineAction.Action != MAGAZINE_ACTIONS.READY)