FIx fanuc

Added osai unit of measure/fix axes names
This commit is contained in:
Lucio Maranta
2019-02-12 17:03:29 +00:00
parent d9d9309223
commit 7737f0a949
4 changed files with 42 additions and 6 deletions
+1 -1
View File
@@ -604,7 +604,7 @@ namespace CMS_CORE_Library.Fanuc
public override CmsError PLC_WRefreshAllMessages()
{
return NO_ERROR;
return PLC_WNcSoftKey(REFRESH_ALL_ALARMS_SFKEY_INDEX);
}
// Get pre and post power on data
+23 -2
View File
@@ -412,7 +412,25 @@ namespace CMS_CORE_Library.Osai
// Get NC unit of measure
public override CmsError NC_RUnitOfMeasure(ref string unitOfMeasure)
{
unitOfMeasure = "mm";
ushort nReturn = OpenNC.GetNcInfo1(1, out GETINFO1DATA info, out uint errorClass, out uint errorNum);
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
return GetNCError(errorClass, errorNum);
switch (info.feedmisunit)
{
case 0:
unitOfMeasure = "inch";
break;
case 1:
unitOfMeasure = "mm";
break;
case 2:
unitOfMeasure = "inch";
break;
case 3:
unitOfMeasure = "mm";
break;
}
return NO_ERROR;
}
@@ -1729,10 +1747,13 @@ namespace CMS_CORE_Library.Osai
// 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);
List<int> ints = new List<int>();
cmsError = MEM_RWIntegerList(R, 0, AXES_BUTTON_VISIBLE.MemType, AXES_BUTTON_VISIBLE.Address, AXES_BUTTON_VISIBLE.Size / 4, ref ints);
if (cmsError.IsError())
return cmsError;
ids = IntsToBytes(ints);
for (int i = 0; i < axesNumber; i++)
{
var charName = Convert.ToChar(axesName[i]);
+13 -3
View File
@@ -1684,6 +1684,7 @@ namespace CMS_CORE_Library.Siemens
{
try
{
axes = new Dictionary<string, double>();
// Cycle between axes
// The dictionary is written asynchronously so i have to create a copy of the dictionary with .ToList() to avoid exceptions
foreach (var axis in InterpAxesPosition.ToList())
@@ -1703,7 +1704,10 @@ namespace CMS_CORE_Library.Siemens
public override CmsError AXES_RMachinePosition(ushort channel, ref Dictionary<string, double> axes)
{
try
{ // Cycle between axes
{
axes = new Dictionary<string, double>();
// Cycle between axes
// The dictionary is written asynchronously so i have to create a copy of the dictionary with .ToList() to avoid exceptions
foreach (var axis in MachineAxesPosition.ToList())
{
@@ -1722,7 +1726,9 @@ namespace CMS_CORE_Library.Siemens
public override CmsError AXES_RProgrPosition(ushort channel, ref Dictionary<string, double> axes)
{
try
{
{
axes = new Dictionary<string, double>();
// Cycle between axes
// The dictionary is written asynchronously so i have to create a copy of the dictionary with .ToList() to avoid exceptions
foreach (var axis in ProgrammedAxisPosition.ToList())
@@ -1743,6 +1749,8 @@ namespace CMS_CORE_Library.Siemens
{
try
{
axes = new Dictionary<string, double>();
// Cycle between axes
// The dictionary is written asynchronously so i have to create a copy of the dictionary with .ToList() to avoid exceptions
foreach (var axis in InterpAxesPosition.ToList())
@@ -1763,13 +1771,15 @@ namespace CMS_CORE_Library.Siemens
{
try
{
axes = new Dictionary<string, double>();
// Cycle between axes
// The dictionary is written asynchronously so i have to create a copy of the dictionary with .ToList() to avoid exceptions
foreach (var axis in ToGoAxesPosition.ToList())
{
axes.Add(axis.Key, axis.Value);
}
axes = ToGoAxesPosition.ToDictionary(x => x.Key, x => x.Value);
// axes = ToGoAxesPosition.ToDictionary(x => x.Key, x => x.Value);
}
catch (Exception ex)
{
+5
View File
@@ -193,6 +193,11 @@ namespace CMS_CORE_Library.Utils
return BitConverter.GetBytes(Convert.ToInt32(val));
}
internal static List<byte> IntsToBytes(List<int> ints)
{
return ints.SelectMany(BitConverter.GetBytes).ToList();
}
internal static List<T> ListOfByteToListOf<T>(byte[] array, Func<byte[], int, T> bitConverter)
{
var size = Marshal.SizeOf(typeof(T));