This commit is contained in:
Lucio Maranta
2018-08-29 15:35:45 +00:00
parent 6c3f978aa6
commit c8f5fd6bbb
6 changed files with 110 additions and 33 deletions
+26
View File
@@ -16,6 +16,7 @@ using static CMS_CORE.Demo.MEMORY_ADDRESS;
using static CMS_CORE.Nc;
using static CMS_CORE_Library.DataStructures;
using static CMS_CORE_Library.ToolConfigurations;
using static CMS_CORE.Utils.Nc_Utils;
namespace CMS_CORE.Demo
{
@@ -2725,6 +2726,29 @@ namespace CMS_CORE.Demo
return NO_ERROR;
}
public override CmsError TOOLS_RMagazineStatus(ref Dictionary<int, bool> magazineStatus)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
// Read tool manager status
int status = 0;
cmsError = MEM_RWInteger(R, 0, MAGAZINES_ENABLED_CMD.MemType, MAGAZINES_ENABLED_CMD.Address, ref status);
if (cmsError.IsError())
return cmsError;
bool[] bits = IntToBool(status);
for (int i = 0; i < bits.Length; i++)
{
magazineStatus.Add(i + 1, bits[i]);
}
return NO_ERROR;
}
#endregion Nc Tool Manager
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -2853,6 +2877,8 @@ namespace CMS_CORE.Demo
internal static MEMORY_CELL HEADS_ACK = new MEMORY_CELL(MEMORY_TYPE.Demo, 429, 4);
internal static MEMORY_CELL HEADS_STROBE_INCREMENT = new MEMORY_CELL(MEMORY_TYPE.Demo, 432, 4);
internal static MEMORY_CELL HEADS_STROBE_DECREMENT = new MEMORY_CELL(MEMORY_TYPE.Demo, 436, 4);
internal static MEMORY_CELL MAGAZINES_ENABLED_CMD = new MEMORY_CELL(MEMORY_TYPE.Demo, 440, 4);
}
#endregion Memory addresses
+5
View File
@@ -1902,6 +1902,11 @@ namespace CMS_CORE.Fanuc
return NO_ERROR;
}
public override CmsError TOOLS_RMagazineStatus(ref Dictionary<int, bool> magazineStatus)
{
return NO_ERROR;
}
#endregion Nc Tool Manager
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2
View File
@@ -1683,6 +1683,8 @@ namespace CMS_CORE
public abstract CmsError TOOLS_RStoredData();
public abstract CmsError TOOLS_RMagazineStatus(ref Dictionary<int, bool> magazineStatus);
#endregion Nc Tool Manager
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+30 -6
View File
@@ -443,7 +443,7 @@ namespace CMS_CORE.Osai
if (cmsError.IsError())
return cmsError;
// Convert integer array into bit array
bool[] statusBits = new BitArray(readValues.ToArray()).Cast<bool>().ToArray();
bool[] statusBits = IntToBool(readValues.ToArray());
for (int i = 0; i < ALARMS_STATUS.Size * 8; i++)
{
@@ -523,7 +523,7 @@ namespace CMS_CORE.Osai
bool[] bits = new bool[32];
// Convert int into to true/false array
bits = new BitArray(new int[] { readValue }).Cast<bool>().ToArray();
bits = IntToBool(readValue);
// Create adn set pre power on object
PrePowerOnModel prePowerOn = new PrePowerOnModel()
{
@@ -575,7 +575,8 @@ namespace CMS_CORE.Osai
functions = new List<FunctionalityModel>();
// Convert int into to true/false array
bool[] bits = new BitArray(readValues.ToArray()).Cast<bool>().ToArray();
bool[] bits = IntToBool(readValues.ToArray());
// Convert array into structured data
for (int i = 0; i < bits.Count(); i++)
{
@@ -656,7 +657,7 @@ namespace CMS_CORE.Osai
if (cmsError.IsError())
return cmsError;
bool[] bits = new BitArray(readValue.ToArray()).Cast<bool>().ToArray();
bool[] bits = IntToBool(readValue.ToArray());
// Convert array into structured data
for (ushort i = 0; i < bits.Count() / 2; i++)
@@ -2553,7 +2554,7 @@ namespace CMS_CORE.Osai
bool[] bits = new bool[16];
// Convert int into to true/false array
bits = new BitArray(new int[] { status }).Cast<bool>().ToArray();
bits = IntToBool(status);
// 1 = Non-editable tables, 2 = reading in progess
if (bits[1] || bits[2])
return MAGAZINE_BUSY_ERROR;
@@ -2590,6 +2591,29 @@ namespace CMS_CORE.Osai
return NO_ERROR;
}
public override CmsError TOOLS_RMagazineStatus(ref Dictionary<int, bool> magazineStatus)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
// Read tool manager status
int status = 0;
cmsError = MEM_RWInteger(R, 0, MAGAZINES_ENABLED_CMD.MemType, MAGAZINES_ENABLED_CMD.Address, ref status);
if (cmsError.IsError())
return cmsError;
bool[] bits = IntToBool(status);
for(int i = 0; i < bits.Length; i++)
{
magazineStatus.Add(i + 1, bits[i]);
}
return NO_ERROR;
}
public override CmsError TOOLS_WStartEditTooling(int magazineId)
{
//Check if the NC is Connected
@@ -2865,7 +2889,7 @@ namespace CMS_CORE.Osai
return cmsError;
// Convert int into to true/false array
bool[] bits = new BitArray(readInt.ToArray()).Cast<bool>().ToArray();
bool[] bits = IntToBool(readInt.ToArray());
ushort toolId = 0;
byte status = 0;
uint life = 0;
+33 -27
View File
@@ -521,7 +521,7 @@ namespace CMS_CORE.Siemens
if (cmsError.IsError())
return cmsError;
// Convert integer array into bit array
bool[] statusBits = new BitArray(readValues.ToArray()).Cast<bool>().ToArray();
bool[] statusBits = IntToBool(readValues.ToArray());
for (int i = 0; i < ALARMS_STATUS.Size * 8; i++)
{
@@ -609,7 +609,7 @@ namespace CMS_CORE.Siemens
bool[] bits = new bool[32];
// Convert int into to true/false array
bits = new BitArray(new int[] { readValue }).Cast<bool>().ToArray();
bits = IntToBool(readValue);
// Create adn set pre power on object
PrePowerOnModel prePowerOn = new PrePowerOnModel()
{
@@ -662,7 +662,7 @@ namespace CMS_CORE.Siemens
functions = new List<FunctionalityModel>();
// Convert int into to true/false array
bool[] bits = new BitArray(readValues.ToArray()).Cast<bool>().ToArray();
bool[] bits = IntToBool(readValues.ToArray());
// Convert array into structured data
for (int i = 0; i < bits.Count(); i++)
{
@@ -727,7 +727,7 @@ namespace CMS_CORE.Siemens
private CmsError PLC_RSoftKeys(MEMORY_CELL softKeyStatusMemory, MEMORY_CELL softKeysClickableMemory, ref List<SoftKeysModel> softKeys)
{
softKeys = new List<SoftKeysModel>();
List<int> readValue = new List<int>();
List<int> readValues = new List<int>();
int memorySizeToRead = (softKeyStatusMemory.Size + softKeysClickableMemory.Size);
// Offset between status and clickable data
@@ -739,12 +739,12 @@ namespace CMS_CORE.Siemens
softKeyStatusMemory.Address,
softKeyStatusMemory.SubAddress,
memorySizeToRead / 4,
ref readValue);
ref readValues);
if (cmsError.IsError())
return cmsError;
bool[] bits = new BitArray(readValue.ToArray()).Cast<bool>().ToArray();
bool[] bits = IntToBool(readValues.ToArray());
// Convert array into structured data
for (ushort i = 0; i < bits.Count() / 2; i++)
@@ -1931,15 +1931,7 @@ namespace CMS_CORE.Siemens
{
return NO_ERROR;
}
private string FormatPath(ref string path)
{
path = path.TrimStart('\\');
path = path.TrimEnd('\\');
return path.Replace('\\', '/');
}
public override CmsError FILES_RActiveProgramData(int processId, ref ActiveProgramDataModel data)
{
try
@@ -1979,18 +1971,7 @@ namespace CMS_CORE.Siemens
return NO_ERROR;
}
private IEnumerable<string> GetLinesFromString(string text)
{
string line;
using (StringReader reader = new StringReader(text))
{
while ((line = reader.ReadLine()) != null)
{
yield return line;
}
}
}
public override CmsError FILES_UploadPartProgram(string localPath, string name, ref string newFilePath)
{
// Open file
@@ -2110,6 +2091,26 @@ namespace CMS_CORE.Siemens
return NO_ERROR;
}
private IEnumerable<string> GetLinesFromString(string text)
{
string line;
using (StringReader reader = new StringReader(text))
{
while ((line = reader.ReadLine()) != null)
{
yield return line;
}
}
}
private string FormatPath(ref string path)
{
path = path.TrimStart('\\');
path = path.TrimEnd('\\');
return path.Replace('\\', '/');
}
#endregion File Management
@@ -3197,6 +3198,11 @@ namespace CMS_CORE.Siemens
return FUNCTION_NOT_ALLOWED_ERROR;
}
public override CmsError TOOLS_RMagazineStatus(ref Dictionary<int, bool> magazineStatus)
{
return FUNCTION_NOT_ALLOWED_ERROR;
}
#endregion Nc Tool Manager
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+14
View File
@@ -1,6 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static CMS_CORE_Library.DataStructures;
namespace CMS_CORE.Utils
@@ -195,5 +197,17 @@ namespace CMS_CORE.Utils
}
}
}
public static bool[] IntToBool(int val)
{
return IntToBool(new int[] { val });
}
public static bool[] IntToBool(int[] val)
{
return new BitArray(val.ToArray())
.Cast<bool>()
.ToArray();
}
}
}