Osai alignment, magazine_action

This commit is contained in:
Lucio Maranta
2019-01-21 13:36:13 +00:00
parent 44eb32658c
commit 8aedbbf071
2 changed files with 126 additions and 64 deletions
+74 -55
View File
@@ -1478,72 +1478,90 @@ namespace CMS_CORE_Library.Fanuc
return GetNcError(nReturn);
// Parse data
if (numAxesRead >= 1)
axesData.Add(new AxisModel() { Id = 1, Name = sOdbExAxisName.axname1, IsSelectable = true });
axesData.Add(new AxisModel() { Id = 1, Name = sOdbExAxisName.axname1, IsSelectable = false });
if (numAxesRead >= 2)
axesData.Add(new AxisModel() { Id = 2, Name = sOdbExAxisName.axname2, IsSelectable = true });
axesData.Add(new AxisModel() { Id = 2, Name = sOdbExAxisName.axname2, IsSelectable = false });
if (numAxesRead >= 3)
axesData.Add(new AxisModel() { Id = 3, Name = sOdbExAxisName.axname3, IsSelectable = true });
axesData.Add(new AxisModel() { Id = 3, Name = sOdbExAxisName.axname3, IsSelectable = false });
if (numAxesRead >= 4)
axesData.Add(new AxisModel() { Id = 4, Name = sOdbExAxisName.axname4, IsSelectable = true });
axesData.Add(new AxisModel() { Id = 4, Name = sOdbExAxisName.axname4, IsSelectable = false });
if (numAxesRead >= 5)
axesData.Add(new AxisModel() { Id = 5, Name = sOdbExAxisName.axname5, IsSelectable = true });
axesData.Add(new AxisModel() { Id = 5, Name = sOdbExAxisName.axname5, IsSelectable = false });
if (numAxesRead >= 6)
axesData.Add(new AxisModel() { Id = 6, Name = sOdbExAxisName.axname6, IsSelectable = true });
axesData.Add(new AxisModel() { Id = 6, Name = sOdbExAxisName.axname6, IsSelectable = false });
if (numAxesRead >= 7)
axesData.Add(new AxisModel() { Id = 7, Name = sOdbExAxisName.axname7, IsSelectable = true });
axesData.Add(new AxisModel() { Id = 7, Name = sOdbExAxisName.axname7, IsSelectable = false });
if (numAxesRead >= 8)
axesData.Add(new AxisModel() { Id = 8, Name = sOdbExAxisName.axname8, IsSelectable = true });
axesData.Add(new AxisModel() { Id = 8, Name = sOdbExAxisName.axname8, IsSelectable = false });
if (numAxesRead >= 9)
axesData.Add(new AxisModel() { Id = 9, Name = sOdbExAxisName.axname9, IsSelectable = true });
axesData.Add(new AxisModel() { Id = 9, Name = sOdbExAxisName.axname9, IsSelectable = false });
if (numAxesRead >= 10)
axesData.Add(new AxisModel() { Id = 10, Name = sOdbExAxisName.axname10, IsSelectable = true });
if (numAxesRead >= 11)
axesData.Add(new AxisModel() { Id = 11, Name = sOdbExAxisName.axname11, IsSelectable = true });
if (numAxesRead >= 12)
axesData.Add(new AxisModel() { Id = 12, Name = sOdbExAxisName.axname12, IsSelectable = true });
if (numAxesRead >= 13)
axesData.Add(new AxisModel() { Id = 13, Name = sOdbExAxisName.axname13, IsSelectable = true });
if (numAxesRead >= 14)
axesData.Add(new AxisModel() { Id = 14, Name = sOdbExAxisName.axname14, IsSelectable = true });
if (numAxesRead >= 15)
axesData.Add(new AxisModel() { Id = 15, Name = sOdbExAxisName.axname15, IsSelectable = true });
if (numAxesRead >= 16)
axesData.Add(new AxisModel() { Id = 16, Name = sOdbExAxisName.axname16, IsSelectable = true });
if (numAxesRead >= 17)
axesData.Add(new AxisModel() { Id = 17, Name = sOdbExAxisName.axname17, IsSelectable = true });
if (numAxesRead >= 18)
axesData.Add(new AxisModel() { Id = 18, Name = sOdbExAxisName.axname18, IsSelectable = true });
if (numAxesRead >= 19)
axesData.Add(new AxisModel() { Id = 19, Name = sOdbExAxisName.axname19, IsSelectable = true });
if (numAxesRead >= 20)
axesData.Add(new AxisModel() { Id = 20, Name = sOdbExAxisName.axname20, IsSelectable = true });
if (numAxesRead >= 21)
axesData.Add(new AxisModel() { Id = 21, Name = sOdbExAxisName.axname21, IsSelectable = true });
if (numAxesRead >= 22)
axesData.Add(new AxisModel() { Id = 22, Name = sOdbExAxisName.axname22, IsSelectable = true });
if (numAxesRead >= 23)
axesData.Add(new AxisModel() { Id = 23, Name = sOdbExAxisName.axname23, IsSelectable = true });
if (numAxesRead >= 24)
axesData.Add(new AxisModel() { Id = 24, Name = sOdbExAxisName.axname24, IsSelectable = true });
if (numAxesRead >= 25)
axesData.Add(new AxisModel() { Id = 25, Name = sOdbExAxisName.axname25, IsSelectable = true });
if (numAxesRead >= 26)
axesData.Add(new AxisModel() { Id = 26, Name = sOdbExAxisName.axname26, IsSelectable = true });
if (numAxesRead >= 27)
axesData.Add(new AxisModel() { Id = 27, Name = sOdbExAxisName.axname27, IsSelectable = true });
if (numAxesRead >= 28)
axesData.Add(new AxisModel() { Id = 28, Name = sOdbExAxisName.axname28, IsSelectable = true });
if (numAxesRead >= 29)
axesData.Add(new AxisModel() { Id = 29, Name = sOdbExAxisName.axname29, IsSelectable = true });
if (numAxesRead >= 30)
axesData.Add(new AxisModel() { Id = 30, Name = sOdbExAxisName.axname30, IsSelectable = true });
if (numAxesRead >= 31)
axesData.Add(new AxisModel() { Id = 31, Name = sOdbExAxisName.axname31, IsSelectable = true });
if (numAxesRead >= 32)
axesData.Add(new AxisModel() { Id = 32, Name = sOdbExAxisName.axname32, IsSelectable = true });
axesData.Add(new AxisModel() { Id = 10, Name = sOdbExAxisName.axname10, IsSelectable = false });
if (numAxesRead >= 11)
axesData.Add(new AxisModel() { Id = 11, Name = sOdbExAxisName.axname11, IsSelectable = false });
if (numAxesRead >= 12)
axesData.Add(new AxisModel() { Id = 12, Name = sOdbExAxisName.axname12, IsSelectable = false });
if (numAxesRead >= 13)
axesData.Add(new AxisModel() { Id = 13, Name = sOdbExAxisName.axname13, IsSelectable = false });
if (numAxesRead >= 14)
axesData.Add(new AxisModel() { Id = 14, Name = sOdbExAxisName.axname14, IsSelectable = false });
if (numAxesRead >= 15)
axesData.Add(new AxisModel() { Id = 15, Name = sOdbExAxisName.axname15, IsSelectable = false });
if (numAxesRead >= 16)
axesData.Add(new AxisModel() { Id = 16, Name = sOdbExAxisName.axname16, IsSelectable = false });
if (numAxesRead >= 17)
axesData.Add(new AxisModel() { Id = 17, Name = sOdbExAxisName.axname17, IsSelectable = false });
if (numAxesRead >= 18)
axesData.Add(new AxisModel() { Id = 18, Name = sOdbExAxisName.axname18, IsSelectable = false });
if (numAxesRead >= 19)
axesData.Add(new AxisModel() { Id = 19, Name = sOdbExAxisName.axname19, IsSelectable = false });
if (numAxesRead >= 20)
axesData.Add(new AxisModel() { Id = 20, Name = sOdbExAxisName.axname20, IsSelectable = false });
if (numAxesRead >= 21)
axesData.Add(new AxisModel() { Id = 21, Name = sOdbExAxisName.axname21, IsSelectable = false });
if (numAxesRead >= 22)
axesData.Add(new AxisModel() { Id = 22, Name = sOdbExAxisName.axname22, IsSelectable = false });
if (numAxesRead >= 23)
axesData.Add(new AxisModel() { Id = 23, Name = sOdbExAxisName.axname23, IsSelectable = false });
if (numAxesRead >= 24)
axesData.Add(new AxisModel() { Id = 24, Name = sOdbExAxisName.axname24, IsSelectable = false });
if (numAxesRead >= 25)
axesData.Add(new AxisModel() { Id = 25, Name = sOdbExAxisName.axname25, IsSelectable = false });
if (numAxesRead >= 26)
axesData.Add(new AxisModel() { Id = 26, Name = sOdbExAxisName.axname26, IsSelectable = false });
if (numAxesRead >= 27)
axesData.Add(new AxisModel() { Id = 27, Name = sOdbExAxisName.axname27, IsSelectable = false });
if (numAxesRead >= 28)
axesData.Add(new AxisModel() { Id = 28, Name = sOdbExAxisName.axname28, IsSelectable = false });
if (numAxesRead >= 29)
axesData.Add(new AxisModel() { Id = 29, Name = sOdbExAxisName.axname29, IsSelectable = false });
if (numAxesRead >= 30)
axesData.Add(new AxisModel() { Id = 30, Name = sOdbExAxisName.axname30, IsSelectable = false });
if (numAxesRead >= 31)
axesData.Add(new AxisModel() { Id = 31, Name = sOdbExAxisName.axname31, IsSelectable = false });
if (numAxesRead >= 32)
axesData.Add(new AxisModel() { Id = 32, Name = sOdbExAxisName.axname32, IsSelectable = false });
axesData = axesData.Where(x => x.Name != "\f").ToList();
// Get from PLC which axis can be selected
List<byte> ids = new List<byte>();
CmsError cmsError = MEM_RWByteList(R, 0, AXES_BUTTON_VISIBLE.MemType, AXES_BUTTON_VISIBLE.Address, AXES_BUTTON_VISIBLE.SubAddress, 0, AXES_BUTTON_VISIBLE.Size, ref ids);
if (cmsError.IsError())
return cmsError;
// Parse the data readed from PLC
foreach (byte id in ids)
{
if (id != 0)
{
// If axis exists, set it as selectable
var tmpAxis = axesData.Where(x => x.Id == id).FirstOrDefault();
if (tmpAxis != null)
tmpAxis.IsSelectable = true;
}
}
return NO_ERROR;
}
@@ -2796,7 +2814,6 @@ namespace CMS_CORE_Library.Fanuc
}
return NO_ERROR;
}
#endregion Siemens Tools Management
@@ -4140,6 +4157,8 @@ namespace CMS_CORE_Library.Fanuc
internal static MEMORY_CELL M155_INPUT_NEEDED = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 3004, 1);
internal static MEMORY_CELL MTCONNECT_DATA_NEEDED = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 3031, 1);
internal static MEMORY_CELL AXES_BUTTON_VISIBLE = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 3033, 16);
// Tool manager areas
internal static MEMORY_CELL MAGAZINE_ACTION = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 4000, 16);
+52 -9
View File
@@ -657,9 +657,9 @@ namespace CMS_CORE_Library.Osai
softKeys = new List<SoftKeysModel>();
List<int> readValue = new List<int>();
int memorySizeToRead = (softKeyStatusMemory.Size + softKeysClickableMemory.Size);
// Offset between status and clickable data ( + 16 is the empty space created by OSAI ARRAY POINTER)
int offset = (softKeyStatusMemory.Size * 8) + 16;
int memorySizeToRead = (softKeyStatusMemory.Size + softKeysClickableMemory.Size) + 4;
// Offset between status and clickable data ( + 32 is the empty space created by OSAI ARRAY POINTER)
int offset = (softKeyStatusMemory.Size * 8) + 32;
// Read on data from memory
CmsError cmsError = MEM_RWIntegerList(R, 0,
@@ -674,11 +674,11 @@ namespace CMS_CORE_Library.Osai
bool[] bits = IntToBits(readValue.ToArray());
// Convert array into structured data
for (ushort i = 0; i < bits.Count() / 2; i++)
for (ushort i = 0; i < softKeyStatusMemory.Size * 8; i++)
{
softKeys.Add(new SoftKeysModel()
{
Id = (uint)i + 1,
Id = (uint)i + 1,
Value = bits[i],
Active = bits[i + offset]
});
@@ -919,7 +919,7 @@ namespace CMS_CORE_Library.Osai
return cmsError;
// If PLC it's performing another request then return
if (readValue)
if (readValue)
return NO_ERROR;
// Write strobe into memory
@@ -1618,6 +1618,12 @@ namespace CMS_CORE_Library.Osai
// Read axes info from NC
nReturn = OpenNC.GetAxesInfo3(ushort.MaxValue, ref axesNumber, out unsignedshortarray axesProcess, out byte[] axesName, out unsignedshortarray axesType, out unsignedshortarray axesInterface, out uint errorClass, out uint errorNum);
// Get from PLC which axis can be selected
List<byte> ids = new List<byte>();
cmsError = MEM_RWByteList(R, 0, AXES_BUTTON_VISIBLE.MemType, AXES_BUTTON_VISIBLE.Address, AXES_BUTTON_VISIBLE.SubAddress, 0, AXES_BUTTON_VISIBLE.Size, ref ids);
if (cmsError.IsError())
return cmsError;
for (int i = 0; i < axesNumber; i++)
{
var charName = Convert.ToChar(axesName[i]);
@@ -1629,7 +1635,7 @@ namespace CMS_CORE_Library.Osai
{
Id = i + 1,
Name = charName.ToString(),
IsSelectable = true
IsSelectable = ids.Where(x => x == i + 1)?.FirstOrDefault() == null ? false : true
});
}
}
@@ -2635,6 +2641,42 @@ namespace CMS_CORE_Library.Osai
public override CmsError TOOLS_RMagazineAction(ref MagazineActionModel magazineAction)
{
byte actionId = 0;
CmsError cmsError = MEM_RWByte(R, 0, MAGAZINE_ACTION.MemType, MAGAZINE_ACTION.Address, 0, ref actionId);
if (cmsError.IsError())
return cmsError;
if (actionId != 0)
{
// Read action data
List<ushort> wordList = new List<ushort>();
cmsError = MEM_RWWordList(R, 0, MAGAZINE_ACTION.MemType, MAGAZINE_ACTION.Address + 1, 6, ref wordList);
if (cmsError.IsError())
return cmsError;
MagazineActionToolModel tool = new MagazineActionToolModel()
{
Id = wordList[0]
};
MagazineActionToolModel secondTool = new MagazineActionToolModel()
{
Id = wordList[1]
};
// Populate model with new data
magazineAction = new MagazineActionModel()
{
Action = (MAGAZINE_ACTIONS)actionId,
Tool = tool,
SecondTool = secondTool,
OriginMagazine = wordList[2],
OriginPosition = wordList[3],
DestinationMagazine = wordList[4],
DestinationPosition = wordList[5]
};
}
return NO_ERROR;
}
@@ -3895,8 +3937,8 @@ namespace CMS_CORE_Library.Osai
internal static MEMORY_CELL NC_SOFTKEYS_VALUE = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4026, 0, 4);
internal static MEMORY_CELL NC_SOFTKEYS_CLICKABLE = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4030, 0, 4);
internal static MEMORY_CELL NC_SOFT_KEYS_ACK = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4034, 4);
internal static MEMORY_CELL NC_SOFT_KEYS_CLICKED = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4038, 4);
internal static MEMORY_CELL NC_SOFT_KEYS_ACK = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4034, 2);
internal static MEMORY_CELL NC_SOFT_KEYS_CLICKED = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4038, 2);
internal static MEMORY_CELL SELECTED_AXIS = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4040, 0, 1);
internal static MEMORY_CELL SELECT_AXIS = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4040, 1, 1);
@@ -3922,6 +3964,7 @@ namespace CMS_CORE_Library.Osai
internal static MEMORY_CELL M155_STROBE = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4310, 1);
internal static MEMORY_CELL MTCONNECT_DATA_NEEDED = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4312, 1);
internal static MEMORY_CELL AXES_BUTTON_VISIBLE = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4320, 16);
// Tool manager areas
internal static MEMORY_CELL MAGAZINE_ACTION = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4350, 16);