This commit is contained in:
@@ -62,7 +62,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
//Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -85,7 +85,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
//Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -106,7 +106,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
//Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -125,7 +125,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
//Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -145,7 +145,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
//Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -165,7 +165,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
//Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -184,7 +184,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
//Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -218,15 +218,16 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
{
|
||||
Alarms.Clear();
|
||||
|
||||
List<NcAlarmModel> demoAlarms;
|
||||
// Get Alarms from server
|
||||
serverService.GetProcessesAlarms(out demoAlarms);
|
||||
|
||||
// Parse response
|
||||
foreach (NcAlarmModel demoAlarm in demoAlarms)
|
||||
{
|
||||
@@ -250,7 +251,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -272,7 +273,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -294,11 +295,12 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
{
|
||||
Alarms.Clear();
|
||||
serverService.GetProcessAlarms(ProcNumber.ToString(), out List<NcAlarmModel> demoAlarms);
|
||||
|
||||
foreach (NcAlarmModel demoAlarm in demoAlarms)
|
||||
@@ -328,7 +330,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -354,7 +356,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -379,7 +381,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
try
|
||||
{
|
||||
@@ -404,7 +406,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -429,7 +431,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -458,11 +460,11 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
cmsError = CheckBitRange(MemBit);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -490,7 +492,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -520,7 +522,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -549,7 +551,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -578,7 +580,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -607,7 +609,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -700,7 +702,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -729,7 +731,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -758,7 +760,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -787,7 +789,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -816,7 +818,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -879,7 +881,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -899,7 +901,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -923,7 +925,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -948,7 +950,7 @@ namespace CMS_CORE.Demo
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -997,7 +999,7 @@ namespace CMS_CORE.Demo
|
||||
if (ex is EndpointNotFoundException)
|
||||
return NOT_CONNECTED_ERROR;
|
||||
else
|
||||
return new CmsError(INTERNAL_ERROR, ex.Message);
|
||||
return CmsError.InternalError(ex.Message);
|
||||
}
|
||||
|
||||
//Check Bit In Range
|
||||
@@ -1015,9 +1017,9 @@ namespace CMS_CORE.Demo
|
||||
}
|
||||
|
||||
// Create and return CmsError object
|
||||
private CmsError GetError(uint CMSError, string message)
|
||||
private CmsError GetNcError(string message)
|
||||
{
|
||||
return new CmsError(CMSError, message);
|
||||
return CmsError.NcError(message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -67,14 +67,14 @@ namespace CMS_CORE.Fanuc
|
||||
//Try to connect to The NC
|
||||
nReturn = Focas1.cnc_allclibhndl3(Ip, Port, TimeOut, out TempLibHandle);
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
else
|
||||
nLibHandle.Add(TempLibHandle);
|
||||
|
||||
//Read the Actual Paths
|
||||
nReturn = Focas1.cnc_getpath(nLibHandle[0], out ActivePath, out Cnc_NumPath);
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
//Setup all Paths
|
||||
for (i = 0; i < Cnc_NumPath; i++)
|
||||
@@ -83,14 +83,14 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
nReturn = Focas1.cnc_allclibhndl3(Ip, Port, TimeOut, out TempLibHandle);
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
else
|
||||
nLibHandle.Add(TempLibHandle);
|
||||
}
|
||||
|
||||
nReturn = Focas1.cnc_setpath(nLibHandle[i], (short)(i + 1));
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
// Read static data
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Language = ConvertToSTEPLanguage(FanucLanguage);
|
||||
@@ -149,7 +149,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
// Read static data
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
SN = Cnc_SeriesNum;
|
||||
@@ -164,7 +164,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
// Read static data
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
SWV = Cnc_SftVersion;
|
||||
@@ -179,7 +179,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
// Read static data
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
ModelName = Cnc_name;
|
||||
@@ -194,7 +194,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Read static data
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
ProcNumber = (ushort)Cnc_NumPath;
|
||||
@@ -209,7 +209,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
|
||||
@@ -226,14 +226,14 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
//Execute the method
|
||||
nReturn = Focas1.cnc_gettimer(nLibHandle[0], TimerTime);
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
//Setup the out value
|
||||
ActualTime = new DateTime(TimerDate.date.year, TimerDate.date.month, TimerDate.date.date, TimerTime.time.hour, TimerTime.time.minute, TimerTime.time.second);
|
||||
@@ -250,7 +250,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
// Read word
|
||||
CmsError cmsError = MEM_RWWord(R, UNDEF_PROC, MATR_MACCH_FANUC.MemType, MATR_MACCH_FANUC.Address, ref Value);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
MachNumber = Value.ToString();
|
||||
@@ -268,7 +268,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// Get path index
|
||||
@@ -281,7 +281,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
Status = ConverToSTEPStatus(StatInfo);
|
||||
|
||||
@@ -298,7 +298,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// Get path index
|
||||
@@ -311,7 +311,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
Mode = ConverToSTEPMode(StatInfo);
|
||||
|
||||
@@ -325,9 +325,11 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Alarms.Clear();
|
||||
|
||||
Focas1.ODBALMMSG2 Messg = new Focas1.ODBALMMSG2();
|
||||
short nReturn = 0;
|
||||
short count = FANUC_MAXMSGCNC;
|
||||
@@ -342,7 +344,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
//Add Alarm in List
|
||||
Alarms.Clear();
|
||||
@@ -388,7 +390,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
short nReturn = 0;
|
||||
@@ -408,7 +410,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
path = GetHandleIndexFromPath(ProcNumber);
|
||||
if (path < 0)
|
||||
@@ -420,7 +422,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
//Setup the return values
|
||||
Lines.Clear();
|
||||
@@ -438,7 +440,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
short nReturn = 0;
|
||||
@@ -454,7 +456,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
Name = new String(Prg.name).Replace("\0", String.Empty);
|
||||
|
||||
@@ -468,7 +470,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Focas1.OPMSG3 Messg = new Focas1.OPMSG3();
|
||||
@@ -480,7 +482,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
//Add Alarm in List
|
||||
Alarms.Clear();
|
||||
@@ -505,7 +507,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Focas1.ODBPOS axisFan = new Focas1.ODBPOS();
|
||||
@@ -523,7 +525,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
//If an axis goes out from Process Clear the List
|
||||
if (Axes.Count > NumAxes)
|
||||
@@ -581,7 +583,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Focas1.ODBPOS axisFan = new Focas1.ODBPOS();
|
||||
@@ -599,7 +601,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
//If an axis goes out from Process Clear the List
|
||||
if (Axes.Count > NumAxes)
|
||||
@@ -656,7 +658,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Focas1.ODBPOS axisFan = new Focas1.ODBPOS();
|
||||
@@ -674,7 +676,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
//If an axis goes out from Process Clear the List
|
||||
if (Axes.Count > NumAxes)
|
||||
@@ -737,11 +739,11 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Read the positions
|
||||
CmsError cmsError = AXES_RMachinePosition(ProcNumber, ref ActualMach);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
cmsError = AXES_RDistanceToGo(ProcNumber, ref ToGo);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//If it has the same size
|
||||
@@ -763,7 +765,7 @@ namespace CMS_CORE.Fanuc
|
||||
}
|
||||
}
|
||||
else
|
||||
return GetError(INTERNAL_ERROR, 0);
|
||||
return CmsError.InternalError("Impossible to get programmed position");
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
@@ -789,7 +791,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Focas1.IODBPSD_1 outpar = new Focas1.IODBPSD_1();
|
||||
@@ -801,7 +803,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Check if the Bit Number is Correct
|
||||
cmsError = CheckBitRange(Bit);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Execute the method
|
||||
@@ -809,7 +811,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
Value = ((outpar.cdata & mask) == mask) ? true : false;
|
||||
|
||||
@@ -823,7 +825,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Focas1.IODBPSD_1 outpar = new Focas1.IODBPSD_1();
|
||||
@@ -836,7 +838,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
Value = outpar.cdata;
|
||||
|
||||
@@ -850,7 +852,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Focas1.IODBPSD_1 outpar = new Focas1.IODBPSD_1();
|
||||
@@ -863,7 +865,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
Value = outpar.idata;
|
||||
|
||||
@@ -877,7 +879,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Focas1.IODBPSD_1 outpar = new Focas1.IODBPSD_1();
|
||||
@@ -890,7 +892,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
Value = outpar.ldata;
|
||||
|
||||
@@ -904,7 +906,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Focas1.IODBPSD_2 outpar = new Focas1.IODBPSD_2();
|
||||
@@ -918,7 +920,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
Divider = Math.Pow(10, outpar.rdata.dec_val);
|
||||
|
||||
@@ -937,7 +939,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the Bit Number is Correct
|
||||
CmsError cmsError = CheckBitRange(MemBit);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
byte ReadValue = 0;
|
||||
@@ -945,7 +947,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Read the Byte where is the bit
|
||||
cmsError = MEM_RWByte(R, Process, MemType, MemIndex, 0, ref ReadValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
//If i have to read -> Read the Bit
|
||||
if (bWrite == R)
|
||||
@@ -978,7 +980,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWByteList(bWrite, Process, MemType, MemIndex, 0, 1, ref Values);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = Values.First();
|
||||
@@ -993,12 +995,12 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Check if the Memory area is corrected
|
||||
cmsError = CheckMemoryArea(MemType.ToString());
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//The maximum number of variables readed/writed at the same time is 5
|
||||
@@ -1064,7 +1066,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
//Else add the variables in the List (is is a read-statement)
|
||||
else if (!bWrite)
|
||||
@@ -1087,7 +1089,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWIntegerList(bWrite, Process, MemType, MemIndex, 1, ref ListValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = ListValue.First();
|
||||
@@ -1115,12 +1117,12 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Check if the Memory area is corrected
|
||||
cmsError = CheckMemoryArea(MemType.ToString());
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Setup the 'Value' variable
|
||||
@@ -1173,7 +1175,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
//Else add the variables in the List (is is a read-statement)
|
||||
else if (!bWrite)
|
||||
@@ -1195,7 +1197,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWDWordList(bWrite, Process, MemType, MemIndex, 1, ref ListValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = ListValue.First();
|
||||
@@ -1216,7 +1218,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Exetute the function
|
||||
CmsError cmsError = MEM_RWIntegerList(bWrite, Process, MemType, MemIndex, Number, ref WordValues);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//If i have to read, convert the WORD list into INT
|
||||
@@ -1238,7 +1240,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWShortList(bWrite, Process, MemType, MemIndex, 1, ref ListValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = ListValue.First();
|
||||
@@ -1253,12 +1255,12 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Check if the Memory area is corrected
|
||||
cmsError = CheckMemoryArea(MemType.ToString());
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//The maximum number of variables readed/writed at the same time is 5
|
||||
@@ -1325,7 +1327,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
|
||||
//Else add the variables in the List (is is a read-statement)
|
||||
else if (!bWrite)
|
||||
@@ -1347,7 +1349,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWWordList(bWrite, Process, MemType, MemIndex, 1, ref ListValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = ListValue.First();
|
||||
@@ -1368,7 +1370,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Exetute the function
|
||||
CmsError cmsError = MEM_RWShortList(bWrite, Process, MemType, MemIndex, Number, ref WordValues);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//If i have to read, convert the WORD list into INT
|
||||
@@ -1450,7 +1452,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
// Read NC part program content
|
||||
CmsError cmsError = ReadPartProgramContent(partProgramPath, ref partProgramContent);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -1460,7 +1462,7 @@ namespace CMS_CORE.Fanuc
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return GetError(INTERNAL_ERROR, 0);
|
||||
return CmsError.InternalError(ex.Message);
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
@@ -1479,7 +1481,7 @@ namespace CMS_CORE.Fanuc
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return GetError(INTERNAL_ERROR, 0);
|
||||
return CmsError.InternalError(ex.Message);
|
||||
}
|
||||
|
||||
return WritePartProgramContent(partProgramPath, partProgramContent);
|
||||
@@ -1490,14 +1492,14 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
short nReturn;
|
||||
|
||||
// If the 2 path are the same
|
||||
if (partProgramPath == newPartProgramPath)
|
||||
return GetError(NC_PROD_ERROR, 5); // TODO FIX
|
||||
return GetNcError( 5); // TODO FIX
|
||||
|
||||
if (failIfExist)
|
||||
{
|
||||
@@ -1505,7 +1507,7 @@ namespace CMS_CORE.Fanuc
|
||||
nReturn = Focas1.cnc_pdf_copy(nLibHandle[0], partProgramPath, newPartProgramPath);
|
||||
|
||||
//Throw Exception if there's an error
|
||||
ErrorHandler(NC_PROD_ERROR, nReturn);
|
||||
ErrorHandler(nReturn);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1527,12 +1529,12 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
nReturn = Focas1.cnc_pdf_copy(nLibHandle[0], partProgramPath, newPartProgramPath);
|
||||
|
||||
ErrorHandler(NC_PROD_ERROR, nReturn);
|
||||
ErrorHandler(nReturn);
|
||||
}
|
||||
}
|
||||
else if (nReturn != 0)
|
||||
{
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1543,14 +1545,14 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
short nReturn;
|
||||
|
||||
nReturn = Focas1.cnc_pdf_del(nLibHandle[0], partProgramPath + partProgramName);
|
||||
|
||||
ErrorHandler(NC_PROD_ERROR, nReturn);
|
||||
ErrorHandler(nReturn);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
@@ -1559,10 +1561,10 @@ namespace CMS_CORE.Fanuc
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#region Subordinate Private Functions
|
||||
|
||||
private CmsError ErrorHandler(uint errorClass, short exNum)
|
||||
private CmsError ErrorHandler(short exNum)
|
||||
{
|
||||
if (exNum != 0)
|
||||
return GetError(errorClass, exNum);
|
||||
return GetNcError(exNum);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
@@ -1692,7 +1694,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
// Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
short nReturn;
|
||||
@@ -1705,7 +1707,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Read Language from NC PARAM
|
||||
cmsError = NC_RParam((short)PARAM_LING_FANUC.Address, ref FanucLanguage);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Execute the method
|
||||
@@ -1716,7 +1718,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
//Throw Exception if there's an error
|
||||
if (nReturn != 0)
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
else
|
||||
{
|
||||
//Setup the name
|
||||
@@ -1737,7 +1739,7 @@ namespace CMS_CORE.Fanuc
|
||||
|
||||
|
||||
//Manage the Exception Launch
|
||||
private CmsError GetError(uint Owner, short exNum)
|
||||
private CmsError GetNcError(short exNum)
|
||||
{
|
||||
if (exNum == (short)Focas1.focas_ret.EW_SOCKET)
|
||||
{
|
||||
@@ -1745,7 +1747,7 @@ namespace CMS_CORE.Fanuc
|
||||
return NOT_CONNECTED_ERROR;
|
||||
}
|
||||
|
||||
return new CmsError(Owner, GetErrorMessage(Owner, exNum));
|
||||
return CmsError.NcError(GetErrorMessage(exNum));
|
||||
}
|
||||
|
||||
|
||||
@@ -1810,7 +1812,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
short nReturn;
|
||||
@@ -1819,7 +1821,7 @@ namespace CMS_CORE.Fanuc
|
||||
nReturn = Focas1.cnc_dwnstart4(nLibHandle[0], 0, partProgramPath);
|
||||
|
||||
//Throw Exception if there's an error
|
||||
ErrorHandler(NC_PROD_ERROR, nReturn);
|
||||
ErrorHandler(nReturn);
|
||||
|
||||
//int lenghtMax = fileData.Length;
|
||||
Thread.Sleep(1000);
|
||||
@@ -1828,12 +1830,12 @@ namespace CMS_CORE.Fanuc
|
||||
nReturn = Focas1.cnc_download4(nLibHandle[0], ref lenght, partProgramContent);
|
||||
|
||||
//Throw Exception if there's an error
|
||||
ErrorHandler(NC_PROD_ERROR, nReturn);
|
||||
ErrorHandler(nReturn);
|
||||
|
||||
nReturn = Focas1.cnc_dwnend4(nLibHandle[0]);
|
||||
|
||||
//Throw Exception if there's an error
|
||||
ErrorHandler(NC_PROD_ERROR, nReturn);
|
||||
ErrorHandler(nReturn);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
@@ -1845,7 +1847,7 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
bool fileEnded = false;
|
||||
@@ -1856,7 +1858,7 @@ namespace CMS_CORE.Fanuc
|
||||
nReturn = Focas1.cnc_upstart4(nLibHandle[0], 0, partProgramPath);
|
||||
|
||||
//Throw Exception if there's an error
|
||||
ErrorHandler(NC_PROD_ERROR, nReturn);
|
||||
ErrorHandler(nReturn);
|
||||
|
||||
do
|
||||
{
|
||||
@@ -1887,7 +1889,7 @@ namespace CMS_CORE.Fanuc
|
||||
break;
|
||||
default:
|
||||
{
|
||||
return GetError(NC_PROD_ERROR, nReturn);
|
||||
return GetNcError(nReturn);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1896,7 +1898,7 @@ namespace CMS_CORE.Fanuc
|
||||
// End read
|
||||
nReturn = Focas1.cnc_upend4(nLibHandle[0]);
|
||||
|
||||
ErrorHandler(NC_PROD_ERROR, nReturn);
|
||||
ErrorHandler(nReturn);
|
||||
|
||||
partProgramContent = partProgramContent.Replace("\0", String.Empty);
|
||||
|
||||
@@ -1908,11 +1910,11 @@ namespace CMS_CORE.Fanuc
|
||||
{
|
||||
Connected = false;
|
||||
|
||||
return new CmsError(INTERNAL_ERROR, ex.Message);
|
||||
return CmsError.InternalError(ex.Message);
|
||||
}
|
||||
|
||||
// Convert the internal error in a readable-String error
|
||||
private String GetErrorMessage(uint CMSError, short Value)
|
||||
private String GetErrorMessage(short Value)
|
||||
{
|
||||
String ErrororOwner = "";
|
||||
ErrororOwner = "Fanuc-Core-Error: ";
|
||||
|
||||
+54
-39
@@ -11,14 +11,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CMS_CORE
|
||||
{
|
||||
public abstract partial class Nc
|
||||
public abstract partial class Nc
|
||||
{
|
||||
//Private Global Variables
|
||||
internal Boolean Connected;
|
||||
internal String Ip;
|
||||
internal ushort Port;
|
||||
internal Boolean UseProxy;
|
||||
internal String LibName = "CMS_CORE_Library.dll";
|
||||
internal String LibName = "CMS_CORE_Library.dll";
|
||||
|
||||
//Osai Variable
|
||||
internal string OSAI_PlcMessagesPath = @"C:\CMS\OSAI\";
|
||||
@@ -975,7 +975,7 @@ namespace CMS_CORE
|
||||
* <param name="partProgramName">Name of the Part Program file</param>
|
||||
* */
|
||||
public abstract CmsError FILES_DeleteProgram(string partProgramPath, string partProgramName);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -988,7 +988,7 @@ namespace CMS_CORE
|
||||
public const Boolean R = false;
|
||||
/** <summary>Not-Defined Process</summary> */
|
||||
public const ushort UNDEF_PROC = 0;
|
||||
|
||||
|
||||
|
||||
/** <summary>Process-Status</summary> */
|
||||
public enum PROC_Status : ushort
|
||||
@@ -1163,9 +1163,9 @@ namespace CMS_CORE
|
||||
public readonly MEMORY_Type MemType;
|
||||
public readonly int Address;
|
||||
public readonly int SubAddress; //Only for Siemens
|
||||
public readonly int Size;
|
||||
public readonly int Size;
|
||||
|
||||
public MEMORY_Cell(MEMORY_Type MType, int Addr, int SubAddr,int Sz)
|
||||
public MEMORY_Cell(MEMORY_Type MType, int Addr, int SubAddr, int Sz)
|
||||
{
|
||||
MemType = MType;
|
||||
Address = Addr;
|
||||
@@ -1179,9 +1179,9 @@ namespace CMS_CORE
|
||||
internal MEMORY_Cell PARAM_LING_FANUC = new MEMORY_Cell(MEMORY_Type.Null, 3281, 0, 1);
|
||||
|
||||
//Matricola Macchina
|
||||
internal MEMORY_Cell MATR_MACCH_OSAI = new MEMORY_Cell(MEMORY_Type.Osai_MW , 3403, 0, 1);
|
||||
internal MEMORY_Cell MATR_MACCH_FANUC = new MEMORY_Cell(MEMORY_Type.Fanuc_D , 4018, 0, 1);
|
||||
internal MEMORY_Cell MATR_MACCH_SIEMENS = new MEMORY_Cell(MEMORY_Type.Siemens_DB, 255 , 0, 1);
|
||||
internal MEMORY_Cell MATR_MACCH_OSAI = new MEMORY_Cell(MEMORY_Type.Osai_MW, 3403, 0, 1);
|
||||
internal MEMORY_Cell MATR_MACCH_FANUC = new MEMORY_Cell(MEMORY_Type.Fanuc_D, 4018, 0, 1);
|
||||
internal MEMORY_Cell MATR_MACCH_SIEMENS = new MEMORY_Cell(MEMORY_Type.Siemens_DB, 255, 0, 1);
|
||||
|
||||
//Messaggi PLC
|
||||
internal MEMORY_Cell PLC_MESS_OSAI = new MEMORY_Cell(MEMORY_Type.Osai_MW, 12000, 0, 64);
|
||||
@@ -1192,48 +1192,63 @@ namespace CMS_CORE
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#region Cms Errors Codes
|
||||
|
||||
public const uint OK = 0;
|
||||
public const uint NC_PROD_ERROR = 1;
|
||||
public const uint NOT_CONNECTED = 2;
|
||||
public const uint PROC_NOT_FOUND = 3;
|
||||
public const uint FUNCTION_NOT_ALLOWED = 4;
|
||||
public const uint BIT_NOT_IN_RANGE = 5;
|
||||
public const uint BYTE_NOT_IN_RANGE = 6;
|
||||
public const uint INTERNAL_ERROR = 7;
|
||||
public const uint INCORRECT_PARAMETERS = 8;
|
||||
public const uint NC_LANGUAGE_ERROR = 9;
|
||||
public const uint SIEMENS_ENVIRONMENT_NOT_FOUND = 10;
|
||||
public const uint SIEMENS_HMI_NOT_RUNNING = 11;
|
||||
public enum CMS_ERROR_CODES : uint
|
||||
{
|
||||
OK = 0,
|
||||
NC_PROD_ERROR = 1,
|
||||
NOT_CONNECTED = 2,
|
||||
PROC_NOT_FOUND = 3,
|
||||
FUNCTION_NOT_ALLOWED = 4,
|
||||
BIT_NOT_IN_RANGE = 5,
|
||||
BYTE_NOT_IN_RANGE = 6,
|
||||
INTERNAL_ERROR = 7,
|
||||
INCORRECT_PARAMETERS = 8,
|
||||
NC_LANGUAGE_ERROR = 9,
|
||||
SIEMENS_ENVIRONMENT_NOT_FOUND = 10,
|
||||
SIEMENS_HMI_NOT_RUNNING = 11
|
||||
}
|
||||
|
||||
|
||||
public class CmsError
|
||||
{
|
||||
public uint errorCode;
|
||||
public CMS_ERROR_CODES errorCode;
|
||||
public string message;
|
||||
|
||||
public CmsError(uint errorCode, string message)
|
||||
public CmsError(CMS_ERROR_CODES errorCode, string message)
|
||||
{
|
||||
this.errorCode = errorCode;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public bool IsError()
|
||||
{
|
||||
if (errorCode == CMS_ERROR_CODES.OK)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
public static CmsError InternalError(string message)
|
||||
{
|
||||
return new CmsError(CMS_ERROR_CODES.INTERNAL_ERROR, message);
|
||||
}
|
||||
|
||||
public static CmsError NcError(string message)
|
||||
{
|
||||
return new CmsError(CMS_ERROR_CODES.NC_PROD_ERROR, message);
|
||||
}
|
||||
}
|
||||
|
||||
internal static CmsError NO_ERROR = new CmsError(OK, "");
|
||||
internal static CmsError NOT_CONNECTED_ERROR = new CmsError(NOT_CONNECTED, "CMS-Core-Error: Nc not Connected");
|
||||
internal static CmsError PROC_NOT_FOUND_ERROR = new CmsError(FUNCTION_NOT_ALLOWED, "CMS-Core-Error: Function not allowed for this type of NC");
|
||||
internal static CmsError FUNCTION_NOT_ALLOWED_ERROR = new CmsError(FUNCTION_NOT_ALLOWED, "CMS-Core-Error: Function not allowed for this type of NC");
|
||||
internal static CmsError BIT_NOT_IN_RANGE_ERROR = new CmsError(BIT_NOT_IN_RANGE, "CMS-Core-Error: Bit - number must be between 0 and 7");
|
||||
internal static CmsError BYTE_NOT_IN_RANGE_ERROR = new CmsError(BIT_NOT_IN_RANGE, "CMS-Core-Error: Byte - number must be between 0 and 1");
|
||||
internal static CmsError INCORRECT_PARAMETERS_ERROR = new CmsError(BIT_NOT_IN_RANGE, "CMS-Core-Error: Incorrect Parameters error");
|
||||
internal static CmsError LANGUAGE_ERROR = new CmsError(BIT_NOT_IN_RANGE, "CMS-Core-Error: Incorrect Language");
|
||||
internal static CmsError SIEMENS_ENVIRONMENT_NOT_FOUND_ERROR = new CmsError(BIT_NOT_IN_RANGE, "CMS-Core-Error: Siemens Environment not found");
|
||||
internal static CmsError SIEMENS_HMI_NOT_RUNNING_ERROR = new CmsError(BIT_NOT_IN_RANGE, "CMS-Core-Error: Siemens HMI is not Running / Ready");
|
||||
|
||||
|
||||
|
||||
|
||||
internal static CmsError NO_ERROR = new CmsError(CMS_ERROR_CODES.OK, "");
|
||||
internal static CmsError NOT_CONNECTED_ERROR = new CmsError(CMS_ERROR_CODES.NOT_CONNECTED, "CMS-Core-Error: Nc not Connected");
|
||||
internal static CmsError PROC_NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.FUNCTION_NOT_ALLOWED, "CMS-Core-Error: Function not allowed for this type of NC");
|
||||
internal static CmsError FUNCTION_NOT_ALLOWED_ERROR = new CmsError(CMS_ERROR_CODES.FUNCTION_NOT_ALLOWED, "CMS-Core-Error: Function not allowed for this type of NC");
|
||||
internal static CmsError BIT_NOT_IN_RANGE_ERROR = new CmsError(CMS_ERROR_CODES.BIT_NOT_IN_RANGE, "CMS-Core-Error: Bit - number must be between 0 and 7");
|
||||
internal static CmsError BYTE_NOT_IN_RANGE_ERROR = new CmsError(CMS_ERROR_CODES.BYTE_NOT_IN_RANGE, "CMS-Core-Error: Byte - number must be between 0 and 1");
|
||||
internal static CmsError INCORRECT_PARAMETERS_ERROR = new CmsError(CMS_ERROR_CODES.INCORRECT_PARAMETERS, "CMS-Core-Error: Incorrect Parameters error");
|
||||
internal static CmsError LANGUAGE_ERROR = new CmsError(CMS_ERROR_CODES.NC_LANGUAGE_ERROR, "CMS-Core-Error: Incorrect Language");
|
||||
internal static CmsError SIEMENS_ENVIRONMENT_NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND, "CMS-Core-Error: Siemens Environment not found");
|
||||
internal static CmsError SIEMENS_HMI_NOT_RUNNING_ERROR = new CmsError(CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING, "CMS-Core-Error: Siemens HMI is not Running / Ready");
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
//Find if the NC is in Phase 4
|
||||
if (CNCPhase == 4)
|
||||
@@ -137,7 +137,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Language = ConverToSTEPLanguage(OsaiLanguages);
|
||||
@@ -152,7 +152,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
// Read static NC data
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
SN = Cnc_SeriesNum;
|
||||
@@ -167,7 +167,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
// Read static NC data
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
SWV = Cnc_SftVersion;
|
||||
@@ -180,7 +180,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
// Read static NC data
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
ModelName = Cnc_name;
|
||||
@@ -195,7 +195,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -210,7 +210,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
//Setup the out value
|
||||
ActualTime = new DateTime(Year, Month, Day, Hour, Minute, Second);
|
||||
@@ -233,7 +233,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//Exetute the function
|
||||
CmsError cmsError = MEM_RWWord(R, UNDEF_PROC, MATR_MACCH_OSAI.MemType, MATR_MACCH_OSAI.Address, ref mac);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
MachNumber = mac.ToString();
|
||||
@@ -253,7 +253,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//Execute the method
|
||||
CmsError cmsError = MEM_RWWordList(R, 0, PLC_MESS_OSAI.MemType, PLC_MESS_OSAI.Address, PLC_MESS_OSAI.Size, ref list);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Elaborates the Messages
|
||||
@@ -283,7 +283,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -306,7 +306,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
else if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
//Else update the counter
|
||||
else
|
||||
@@ -332,7 +332,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -350,7 +350,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
//If there's an error
|
||||
if (errEmgy.CodeErr != 0)
|
||||
@@ -380,7 +380,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
|
||||
@@ -398,7 +398,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -415,7 +415,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -432,7 +432,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -449,7 +449,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -467,7 +467,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
//If there's an error
|
||||
if (err.CodeErr != 0)
|
||||
@@ -499,7 +499,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -521,7 +521,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
//Clear All Values
|
||||
Lines.Clear();
|
||||
@@ -552,7 +552,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -569,7 +569,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
//Build the new String
|
||||
Name = MainName;
|
||||
@@ -590,7 +590,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -607,7 +607,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
//If an axis goes out from Process Clear the List
|
||||
if (Axes.Count > Pos.Count)
|
||||
@@ -646,7 +646,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -663,7 +663,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
//If an axis goes out from Process Clear the List
|
||||
if (Axes.Count > Pos.Count)
|
||||
@@ -701,7 +701,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -718,7 +718,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
//If an axis goes out from Process Clear the List
|
||||
if (Axes.Count > Pos.Count)
|
||||
@@ -756,7 +756,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -773,7 +773,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
//If an axis goes out from Process Clear the List
|
||||
if (Axes.Count > Pos.Count)
|
||||
@@ -811,7 +811,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -828,7 +828,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
//If an axis goes out from Process Clear the List
|
||||
if (Axes.Count > Pos.Count)
|
||||
@@ -877,7 +877,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//Read the Byte where is the bit
|
||||
CmsError cmsError = MEM_RWWord(R, Process, MemType, MemIndex, ref WordValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//If i have to read -> Read the Bit
|
||||
@@ -894,7 +894,7 @@ namespace CMS_CORE.Osai
|
||||
WordValue = (byte)(WordValue & ~(1 << MemBit));
|
||||
|
||||
cmsError = MEM_RWWord(W, Process, MemType, MemIndex, ref WordValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
@@ -914,7 +914,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//Read the Byte where is the bit
|
||||
CmsError cmsError = MEM_RWWord(R, Process, MemType, MemIndex, ref WordValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//If i have to read -> Read the Bit
|
||||
@@ -943,7 +943,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//Write to the NC
|
||||
cmsError = MEM_RWWord(W, Process, MemType, MemIndex, ref WordToWrite);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
@@ -975,7 +975,7 @@ namespace CMS_CORE.Osai
|
||||
TempVal = Values[i];
|
||||
|
||||
cmsError = MEM_RWByte(W, Process, MemType, MemIndexTemp, index, ref TempVal);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
if (index == 1)
|
||||
@@ -995,7 +995,7 @@ namespace CMS_CORE.Osai
|
||||
for (int i = 0; i < Number; i++)
|
||||
{
|
||||
cmsError = MEM_RWByte(W, Process, MemType, MemIndexTemp, index, ref TempVal);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Values.Add(TempVal);
|
||||
@@ -1023,7 +1023,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWWordList(bWrite, Process, MemType, MemIndex, 1, ref ListValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = ListValue.First();
|
||||
@@ -1037,12 +1037,12 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Check if the Memory area is corrected
|
||||
cmsError = CheckMemoryArea(MemType.ToString());
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -1064,7 +1064,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
}
|
||||
else
|
||||
@@ -1074,7 +1074,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
// Create the array with the Values
|
||||
Values = values.ToList<ushort>();
|
||||
@@ -1100,7 +1100,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWShortList(bWrite, Process, MemType, MemIndex, 1, ref ListValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = ListValue.First();
|
||||
@@ -1113,7 +1113,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
List<ushort> ShortValue = Value.ConvertAll(x => (ushort)x);
|
||||
CmsError cmsError = MEM_RWWordList(bWrite, Process, MemType, MemIndex, 1, ref ShortValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
return NO_ERROR;
|
||||
@@ -1132,7 +1132,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWDWordList(bWrite, Process, MemType, MemIndex, 1, ref ListValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = ListValue.First();
|
||||
@@ -1152,7 +1152,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//Exetute the function
|
||||
CmsError cmsError = MEM_RWWordList(bWrite, Process, MemType, MemIndex, (Number * 2), ref WordValues);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//If i have to read convert the (2x) WORD list into UINT
|
||||
@@ -1176,7 +1176,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWIntegerList(bWrite, Process, MemType, MemIndex, 1, ref ListValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = ListValue.First();
|
||||
@@ -1196,7 +1196,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//Exetute the function
|
||||
CmsError cmsError = MEM_RWWordList(bWrite, Process, MemType, MemIndex, (Number * 2), ref WordValues);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//If i have to read convert the (2x) WORD list into INT
|
||||
@@ -1308,7 +1308,7 @@ namespace CMS_CORE.Osai
|
||||
string partProgramContent = "";
|
||||
// Read NC part program content
|
||||
CmsError cmsError = FILES_RProgram(partProgramPath, ref partProgramContent);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -1328,7 +1328,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
ushort nReturn;
|
||||
@@ -1344,7 +1344,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1375,7 +1375,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
ushort nReturn;
|
||||
@@ -1388,7 +1388,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1402,7 +1402,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -1418,7 +1418,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1433,7 +1433,7 @@ namespace CMS_CORE.Osai
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
uint errorClass, errorNum;
|
||||
@@ -1446,7 +1446,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1527,7 +1527,7 @@ namespace CMS_CORE.Osai
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
return GetError(NC_PROD_ERROR, errorClass, errorNum);
|
||||
return GetNCError(errorClass, errorNum);
|
||||
|
||||
//Setup the CNC Name
|
||||
Cnc_name = "OSAI - Open Control";
|
||||
@@ -1743,16 +1743,16 @@ namespace CMS_CORE.Osai
|
||||
if (ex is EndpointNotFoundException)
|
||||
return NOT_CONNECTED_ERROR;
|
||||
else
|
||||
return new CmsError(INTERNAL_ERROR, ex.Message);
|
||||
return CmsError.InternalError(ex.Message);
|
||||
}
|
||||
|
||||
private CmsError GetError(uint CMSError, uint errorClass, uint errorNum)
|
||||
private CmsError GetNCError(uint errorClass, uint errorNum)
|
||||
{
|
||||
return new CmsError(CMSError, GetNCErrorMessage(CMSError, errorClass, errorNum));
|
||||
return CmsError.NcError(GetNCErrorMessage(errorClass, errorNum));
|
||||
}
|
||||
|
||||
// Convert the internal error in a readable-String error
|
||||
private string GetNCErrorMessage(uint CMSError, uint Class, uint Num)
|
||||
private string GetNCErrorMessage(uint Class, uint Num)
|
||||
{
|
||||
string szErrorClassDesc = "", szErrorDesc = "", ErrorOwner = "";
|
||||
|
||||
@@ -1927,9 +1927,6 @@ namespace CMS_CORE.Osai
|
||||
default: return ErrorOwner + " Generic Osai Error - Class: " + Class + " Num: " + Num;
|
||||
|
||||
}
|
||||
return ErrorOwner + "Generic Error On Function";
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if Siemens Environment is started
|
||||
CmsError cmsError = CheckSiemensEnv();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Set Connected to FALSE and close the session
|
||||
@@ -97,7 +97,7 @@ namespace CMS_CORE.Siemens
|
||||
|
||||
//Read static Data
|
||||
cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Setup the alarms (Only managed in this way (Siemens Thread)
|
||||
@@ -137,7 +137,7 @@ namespace CMS_CORE.Siemens
|
||||
public override CmsError NC_RProcessesNum(ref ushort ProcNumber)
|
||||
{
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
ProcNumber = (ushort)ConfChannelNo;
|
||||
@@ -151,7 +151,7 @@ namespace CMS_CORE.Siemens
|
||||
public override CmsError NC_RModelName(ref string ModelName)
|
||||
{
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
ModelName = Cnc_name;
|
||||
@@ -166,7 +166,7 @@ namespace CMS_CORE.Siemens
|
||||
public override CmsError NC_RSoftwareVersion(ref string SWV)
|
||||
{
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
SWV = Cnc_SftVersion;
|
||||
@@ -180,7 +180,7 @@ namespace CMS_CORE.Siemens
|
||||
public override CmsError NC_RLanguage(ref CultureInfo Language)
|
||||
{
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Language = ConvertToSTEPLanguage(SiemensLanguage);
|
||||
@@ -194,7 +194,7 @@ namespace CMS_CORE.Siemens
|
||||
public override CmsError NC_RSerialNumber(ref string SN)
|
||||
{
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
SN = Cnc_SeriesNum;
|
||||
@@ -208,7 +208,7 @@ namespace CMS_CORE.Siemens
|
||||
public override CmsError NC_RMachineNumber(ref string MachNumber)
|
||||
{
|
||||
CmsError cmsError = ReadStaticNCData();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
MachNumber = Cms_MachNumber;
|
||||
@@ -223,7 +223,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Try to get information
|
||||
@@ -256,7 +256,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Try to get information
|
||||
@@ -294,7 +294,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Try to get information
|
||||
@@ -328,7 +328,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
String[] newLines;
|
||||
@@ -371,7 +371,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
String RetString;
|
||||
@@ -493,12 +493,12 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Check if the Bit Number is Correct
|
||||
cmsError = CheckBitRange(MemBit);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Try to get information
|
||||
@@ -543,7 +543,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Try to get/set information
|
||||
@@ -591,7 +591,7 @@ namespace CMS_CORE.Siemens
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWByteList(bWrite, Process, MemType, MemTable, MemIndex, MemByte, 1, ref ListValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = ListValue.First();
|
||||
@@ -610,7 +610,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Try to get/set information
|
||||
@@ -657,7 +657,7 @@ namespace CMS_CORE.Siemens
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWWordList(bWrite, Process, MemType, MemTable, MemIndex, 1, ref ListValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = ListValue.First();
|
||||
@@ -674,7 +674,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Try to get/set information
|
||||
@@ -720,7 +720,7 @@ namespace CMS_CORE.Siemens
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWShortList(bWrite, Process, MemType, MemTable, MemIndex, 1, ref ListValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = ListValue.First();
|
||||
@@ -738,7 +738,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Try to get/set information
|
||||
@@ -785,7 +785,7 @@ namespace CMS_CORE.Siemens
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWDWordList(bWrite, Process, MemType, MemTable, MemIndex, 1, ref ListValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = ListValue.First();
|
||||
@@ -803,7 +803,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Try to get/set information
|
||||
@@ -849,7 +849,7 @@ namespace CMS_CORE.Siemens
|
||||
|
||||
//uses the List method with one-element list
|
||||
CmsError cmsError = MEM_RWIntegerList(bWrite, Process, MemType, MemTable, MemIndex, 1, ref ListValue);
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
Value = ListValue.First();
|
||||
@@ -949,7 +949,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
try
|
||||
{
|
||||
@@ -975,7 +975,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -1001,7 +1001,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -1036,7 +1036,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
@@ -1176,13 +1176,13 @@ namespace CMS_CORE.Siemens
|
||||
return NOT_CONNECTED_ERROR;
|
||||
}
|
||||
else
|
||||
return GetError(INTERNAL_ERROR, ex.Message);
|
||||
return CmsError.InternalError(ex.Message);
|
||||
}
|
||||
|
||||
// Create and return CmsError object
|
||||
private CmsError GetError(uint CMSError, string message)
|
||||
private CmsError GetError(string message)
|
||||
{
|
||||
return new CmsError(CMSError, message);
|
||||
return CmsError.NcError(message);
|
||||
}
|
||||
|
||||
//Read Static Data
|
||||
@@ -1190,7 +1190,7 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.errorCode != OK)
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
//Read oly one time every X seconds
|
||||
|
||||
Reference in New Issue
Block a user