Added dressing + presetting Read

This commit is contained in:
Nicola
2021-01-19 16:29:46 +01:00
parent c0422b597d
commit 7c7dd2c1ca
7 changed files with 97 additions and 8 deletions
+1 -1
View File
@@ -3565,7 +3565,7 @@ namespace CMS_CORE_Library.Demo
return NO_ERROR;
}
public override CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives)
public override CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives, ref Dictionary<int, ushort> updatedPresetting, ref Dictionary<int, ushort> updatedDressing)
{
return NO_ERROR;
}
+3 -1
View File
@@ -4201,7 +4201,7 @@ namespace CMS_CORE_Library.Fanuc
return NO_ERROR;
}
public override CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives)
public override CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives, ref Dictionary<int, ushort> updatedPresetting, ref Dictionary<int, ushort> updatedDressing)
{
// Check if the NC is Connected
CmsError cmsError = CheckConnection();
@@ -4210,6 +4210,8 @@ namespace CMS_CORE_Library.Fanuc
updatedStatus = new Dictionary<int, byte>();
updatedLives = new Dictionary<int, uint>();
updatedPresetting = new Dictionary<int, ushort>();
updatedDressing = new Dictionary<int, ushort>();
// Read 20 bit of status, read 20 bit of tool life
List<int> readInt = new List<int>();
+1 -1
View File
@@ -1872,7 +1872,7 @@ namespace CMS_CORE_Library
public abstract CmsError TOOLS_RMagazineConfig(ref List<NcMagazineConfigModel> config);
public abstract CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives);
public abstract CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives, ref Dictionary<int, ushort> updatedPresetting, ref Dictionary<int, ushort> updatedDressing);
public abstract CmsError TOOLS_RStoredData(ref List<NcToolModel> tools, ref List<NcFamilyModel> families, ref List<NcShankModel> shanks);
+1 -1
View File
@@ -1846,7 +1846,7 @@ namespace CMS_CORE_Library
public abstract CmsError TOOLS_RMagazineConfig(ref List<NcMagazineConfigModel> config);
public abstract CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives);
public abstract CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives, ref Dictionary<int, ushort> updatedPresetting, ref Dictionary<int, ushort> updatedDressing);
public abstract CmsError TOOLS_RStoredData(ref List<NcToolModel> tools, ref List<NcFamilyModel> families, ref List<NcShankModel> shanks);
+89 -2
View File
@@ -4123,8 +4123,8 @@ namespace CMS_CORE_Library.Osai
return NO_ERROR;
}
public override CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives)
{
public override CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives, ref Dictionary<int, ushort> updatedPresetting, ref Dictionary<int, ushort> updatedDressing)
{
// Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
@@ -4132,6 +4132,8 @@ namespace CMS_CORE_Library.Osai
updatedStatus = new Dictionary<int, byte>();
updatedLives = new Dictionary<int, uint>();
updatedPresetting = new Dictionary<int, ushort>();
updatedDressing = new Dictionary<int, ushort>();
// Read 20 bit of status, read 20 bit of tool life
List<int> readInt = new List<int>();
@@ -4204,6 +4206,82 @@ namespace CMS_CORE_Library.Osai
}
}
// Read 20 bit of status, read 20 bit of tool life
readInt = new List<int>();
cmsError = MEM_RWIntegerList(R, 0, TOOL_DRESSING_UPDATED_CMD.MemType, TOOL_DRESSING_UPDATED_CMD.Address, 3, ref readInt);
if (cmsError.IsError())
return cmsError;
// Convert int into to true/false array
bits = IntToBits(readInt.ToArray());
toolId = 0;
ushort presetting = 0;
ushort dressing = 0;
strobeByteIndex = 0;
ackByteIndex = 0;
for (int i = 0; i < bits.Length; i++)
{
if ((i < 32 || i > 63) && bits[i])
{
int bitIndex = i;
if (i >= 64) // 32 status bit and 32 lives bit
bitIndex -= 64;
// First tool id + actual head index
int headIndex = (HEADS_DATA.Address + 2) + (bitIndex * 6);
cmsError = MEM_RWWord(R, 0, HEADS_DATA.MemType, headIndex, ref toolId);
if (i < 32)
{
// Read new status value
int dressingIndex = TOOL_DRESSING_UPDATED_DATA.Address + (bitIndex); // Index = starting address + (headIndex * 2) -> because Osai uses 16bit format
cmsError = MEM_RWWord(R, 0, TOOL_DRESSING_UPDATED_DATA.MemType, dressingIndex, ref dressing);
if (cmsError.IsError())
return cmsError;
// Insert into the list
if (!updatedDressing.ContainsKey(toolId))
// Insert into the new lives list
updatedDressing.Add(toolId, dressing);
// Setup ack/strobe indexes
// if i > 15 then index = next word
strobeByteIndex = i > 15 ? TOOL_DRESSING_UPDATED_CMD.Address + 1 : TOOL_DRESSING_UPDATED_CMD.Address;
ackByteIndex = i > 15 ? TOOL_DRESSING_UPDATED_ACK.Address + 1 : TOOL_DRESSING_UPDATED_ACK.Address;
}
else
{
// Read new life value
int presettingIndex = TOOL_PRESETTING_UPDATED_DATA.Address + (bitIndex); // Index = starting address + (headIndex * 2) -> because Osai uses 16bit format
cmsError = MEM_RWWord(R, 0, TOOL_PRESETTING_UPDATED_DATA.MemType, presettingIndex, ref presetting);
if (cmsError.IsError())
return cmsError;
// TODO CHECK
if (!updatedPresetting.ContainsKey(toolId))
// Insert into the new lives list
updatedPresetting.Add(toolId, presetting);
// Setup ack/strobe indexes
// if i > (64) + 15 then index = next word
strobeByteIndex = i > 79 ? TOOL_PRESETTING_UPDATED_CMD.Address + 1 : TOOL_PRESETTING_UPDATED_CMD.Address;
ackByteIndex = i > 79 ? TOOL_PRESETTING_UPDATED_ACK.Address + 1 : TOOL_PRESETTING_UPDATED_ACK.Address;
}
// Manage ack and strobe
bitIndex = bitIndex % 16;
cmsError = PLC_ManageActiveAck(strobeByteIndex, bitIndex, ackByteIndex, bitIndex, MEMORY_TYPE.Osai_MW);
if (cmsError.IsError())
return cmsError;
}
}
return NO_ERROR;
}
@@ -5192,6 +5270,15 @@ namespace CMS_CORE_Library.Osai
internal static MEMORY_CELL TOOL_STATUS_UPDATED_DATA = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4416, 10);
internal static MEMORY_CELL TOOL_LIFE_UPDATED_DATA = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4428, 40);
internal static MEMORY_CELL TOOL_DRESSING_UPDATED_CMD = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4534, 2);
internal static MEMORY_CELL TOOL_DRESSING_UPDATED_ACK = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4542, 2);
internal static MEMORY_CELL TOOL_DRESSING_UPDATED_DATA = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4550, 20);
internal static MEMORY_CELL TOOL_PRESETTING_UPDATED_CMD = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4538, 2);
internal static MEMORY_CELL TOOL_PRESETTING_UPDATED_ACK = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4546, 2);
internal static MEMORY_CELL TOOL_PRESETTING_UPDATED_DATA = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4572, 20);
internal static MEMORY_CELL MAGAZINE_TYPES = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4470, 4);
internal static MEMORY_CELL MAGAZINE_POSITIONS_NUMBER = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4482, 4);
+1 -1
View File
@@ -4828,7 +4828,7 @@ namespace CMS_CORE_Library.S7Net
return FUNCTION_NOT_ALLOWED_ERROR;
}
public override CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives)
public override CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives, ref Dictionary<int, ushort> updatedPresetting, ref Dictionary<int, ushort> updatedDressing)
{
return FUNCTION_NOT_ALLOWED_ERROR;
}
+1 -1
View File
@@ -5194,7 +5194,7 @@ namespace CMS_CORE_Library.Siemens
return FUNCTION_NOT_ALLOWED_ERROR;
}
public override CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives)
public override CmsError TOOLS_RUpdatedToolsData(ref Dictionary<int, byte> updatedStatus, ref Dictionary<int, uint> updatedLives, ref Dictionary<int, ushort> updatedPresetting, ref Dictionary<int, ushort> updatedDressing)
{
return FUNCTION_NOT_ALLOWED_ERROR;
}