This commit is contained in:
@@ -789,9 +789,10 @@ namespace CMS_CORE.Osai
|
||||
|
||||
private CmsError ResetStrobe(int bit, int strobeByte, int ackByte, MEMORY_TYPE memType)
|
||||
{
|
||||
int n = 720; // 5 minutes
|
||||
int n = 1200; // 30 seconds
|
||||
bool readValue = false;
|
||||
bool writeValue = false;
|
||||
bool ok = false;
|
||||
|
||||
CmsError cmsError;
|
||||
do
|
||||
@@ -810,6 +811,7 @@ namespace CMS_CORE.Osai
|
||||
return cmsError;
|
||||
// Exit from cycle
|
||||
n = 0;
|
||||
ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -820,6 +822,67 @@ namespace CMS_CORE.Osai
|
||||
}
|
||||
} while (n > 0);
|
||||
|
||||
// If loop timeout goes in timeout
|
||||
if(!ok)
|
||||
{
|
||||
// Reset strobe
|
||||
cmsError = MEM_RWBoolean(W, 0, memType, strobeByte, bit, ref writeValue);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
private CmsError ManageAcknowledge(int strobeByte, int strobeBit, int ackByte, int ackBit, MEMORY_TYPE memType)
|
||||
{
|
||||
int n = 1200; // 30 seconds
|
||||
bool readValue = false;
|
||||
bool writeValue = true;
|
||||
bool ok = false;
|
||||
// Set ack to 1
|
||||
CmsError cmsError = MEM_RWBoolean(W, 0, memType, ackByte, ackBit, ref writeValue);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
do
|
||||
{
|
||||
// Check strobe
|
||||
cmsError = MEM_RWBoolean(R, 0, memType, strobeByte, strobeBit, ref readValue);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// If true reset acknowledge
|
||||
if (!readValue)
|
||||
{
|
||||
writeValue = false;
|
||||
// Reset acknowledge
|
||||
cmsError = MEM_RWBoolean(W, 0, memType, ackByte, ackBit, ref writeValue);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
// Exit from cycle
|
||||
n = 0;
|
||||
ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Decrement
|
||||
n--;
|
||||
// Wait befor next cycle
|
||||
Thread.Sleep(25);
|
||||
}
|
||||
} while (n > 0);
|
||||
|
||||
// If loop timeout goes in timeout
|
||||
if (!ok)
|
||||
{
|
||||
// Reset acknowledge
|
||||
writeValue = false;
|
||||
cmsError = MEM_RWBoolean(W, 0, memType, ackByte, ackBit, ref writeValue);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
@@ -2489,6 +2552,9 @@ namespace CMS_CORE.Osai
|
||||
byte status = 0;
|
||||
uint life = 0;
|
||||
|
||||
int strobeByteIndex = 0;
|
||||
int ackByteIndex = 0;
|
||||
|
||||
for(int i = 0; i < bits.Length; i++)
|
||||
{
|
||||
if (bits[i])
|
||||
@@ -2500,30 +2566,43 @@ namespace CMS_CORE.Osai
|
||||
// First tool id + actual head index
|
||||
int headIndex = (HEADS_DATA.Address + 2) + (bitIndex * 5);
|
||||
cmsError = MEM_RWWord(R, 0, HEADS_DATA.MemType, headIndex, ref toolId);
|
||||
|
||||
|
||||
if(i < 32)
|
||||
{
|
||||
// Read new status value
|
||||
int statusBitIndex = i % 2;
|
||||
int statusByteIndex = i % 2;
|
||||
int statusIndex = TOOL_STATUS_UPDATED_DATA.Address + (i / 2);// Index = starting address + (headIndex / 2) -> because Osai uses 16bit format
|
||||
cmsError = MEM_RWByte(R, 0, HEADS_DATA.MemType, statusIndex, statusBitIndex, ref status);
|
||||
cmsError = MEM_RWByte(R, 0, TOOL_STATUS_UPDATED_DATA.MemType, statusIndex, statusByteIndex, ref status);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// Insert into the list
|
||||
updatedStatus.Add(toolId, status);
|
||||
|
||||
// Setup ack/strobe indexes
|
||||
strobeByteIndex = i > 15 ? TOOL_STATUS_UPDATED_CMD.Address + 1 : TOOL_STATUS_UPDATED_CMD.Address;
|
||||
ackByteIndex = i > 15 ? TOOL_STATUS_UPDATED_ACK.Address + 1 : TOOL_STATUS_UPDATED_ACK.Address;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read new life value
|
||||
int lifeIndex = TOOL_LIFE_UPDATED_DATA.Address + ((i - 32) * 2); // Index = starting address + (headIndex * 2) -> because Osai uses 16bit format
|
||||
cmsError = MEM_RWDWord(R, 0, HEADS_DATA.MemType, lifeIndex, ref life);
|
||||
cmsError = MEM_RWDWord(R, 0, TOOL_LIFE_UPDATED_DATA.MemType, lifeIndex, ref life);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// Insert into the new lives list
|
||||
updatedLives.Add(toolId, life);
|
||||
|
||||
// Setup ack/strobe indexes
|
||||
strobeByteIndex = i > 15 ? TOOL_LIFE_UPDATED_CMD.Address + 1 : TOOL_LIFE_UPDATED_CMD.Address;
|
||||
ackByteIndex = i > 15 ? TOOL_LIFE_UPDATED_ACK.Address + 1 : TOOL_LIFE_UPDATED_CMD.Address;
|
||||
}
|
||||
|
||||
// Manage ack and strobe
|
||||
cmsError = ManageAcknowledge(strobeByteIndex, bitIndex, ackByteIndex, bitIndex, MEMORY_TYPE.Osai_MW);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -171,21 +171,26 @@ namespace CMS_CORE_Library
|
||||
|
||||
public const int NC_MAX_TOOL_NUMER = 300;
|
||||
public const int NC_MAX_EDGES_PER_TOOL = 3;
|
||||
public const int NC_MAX_TOOLS_PER_FAMILY = 255;
|
||||
public const int NC_MAX_TOOLS_PER_FAMILY = 300;
|
||||
public const int NC_MAX_MULTITOOLS_NUMBER = 3;
|
||||
public const int NC_MAX_TOOLS_PER_MULTITOOL = 3;
|
||||
|
||||
public static List<FieldsConfiguration> NcToolFieldsConfig = new List<FieldsConfiguration>()
|
||||
{
|
||||
new FieldsConfiguration{ Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0},
|
||||
new FieldsConfiguration{ Name = "familyId", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
new FieldsConfiguration{ Name = "shankId", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
new FieldsConfiguration{ Name = "length", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
new FieldsConfiguration{ Name = "offsetLength", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
new FieldsConfiguration{ Name = "residualLife", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = int.MaxValue},
|
||||
new FieldsConfiguration{ Name = "offset1", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
new FieldsConfiguration{ Name = "offset2", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
new FieldsConfiguration{ Name = "offset3", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
new FieldsConfiguration{ Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0},
|
||||
new FieldsConfiguration{ Name = "familyId", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
new FieldsConfiguration{ Name = "shankId", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
new FieldsConfiguration{ Name = "length", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
new FieldsConfiguration{ Name = "offsetLength", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
new FieldsConfiguration{ Name = "disabled", Type = "bool", SelectValues = null, Category = "status", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue},
|
||||
new FieldsConfiguration{ Name = "broken", Type = "bool", SelectValues = null, Category = "status", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue},
|
||||
new FieldsConfiguration{ Name = "measured", Type = "bool", SelectValues = null, Category = "status", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue},
|
||||
new FieldsConfiguration{ Name = "clockwiseRotation", Type = "bool", SelectValues = null, Category = "status", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue},
|
||||
new FieldsConfiguration{ Name = "counterClockwiseRotation", Type = "bool", SelectValues = null, Category = "status", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue},
|
||||
new FieldsConfiguration{ Name = "residualLife", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue},
|
||||
new FieldsConfiguration{ Name = "offset1", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
new FieldsConfiguration{ Name = "offset2", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
new FieldsConfiguration{ Name = "offset3", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = ushort.MaxValue},
|
||||
};
|
||||
|
||||
public static FamiliesConfiguration NcFamilyFieldsConfig = new FamiliesConfiguration()
|
||||
|
||||
Reference in New Issue
Block a user