Fanuc active program
Added refresh all
This commit is contained in:
@@ -142,12 +142,17 @@ namespace CMS_CORE_Application
|
||||
List<PreviewFileModel> p = new List<PreviewFileModel>();
|
||||
cmsError = N.FILES_RGetFileList("", ref p);
|
||||
|
||||
OffsetModel offset = new OffsetModel();
|
||||
N.TOOLS_ROffset(1, ref offset);
|
||||
N.TOOLS_WOffset(2, offset);
|
||||
|
||||
ActiveProgramDataModel prg = new ActiveProgramDataModel();
|
||||
|
||||
|
||||
cmsError = N.FILES_WSetActiveProgram(1, "//CNC_MEM/USER/PATH1/Nuovo", ref prg);
|
||||
cmsError = N.FILES_RActiveProgramData(1, ref prg);
|
||||
|
||||
Console.WriteLine("ICON" + sw.ElapsedMilliseconds);
|
||||
sw.Stop();
|
||||
|
||||
|
||||
if (!this.IsDisposed && this.InvokeRequired)
|
||||
{
|
||||
this.Invoke((ThreadStart)delegate ()
|
||||
|
||||
@@ -1635,6 +1635,11 @@ namespace CMS_CORE_Library.Fanuc
|
||||
// Write a Int-Value-List inside the NC. In writing-mode the field "Number" is not required
|
||||
public override CmsError MEM_RWIntegerList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int Number, ref List<int> Value)
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
{
|
||||
//The maximum number of variables read/writed at the same time is 5
|
||||
@@ -1653,12 +1658,7 @@ namespace CMS_CORE_Library.Fanuc
|
||||
int ActualEndIndex;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
|
||||
//Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
|
||||
//Check if the Memory area is corrected
|
||||
cmsError = CheckMemoryArea(MemType.ToString());
|
||||
if (cmsError.IsError())
|
||||
@@ -2000,6 +2000,12 @@ namespace CMS_CORE_Library.Fanuc
|
||||
|
||||
public override CmsError FILES_RGetFileList(string path, ref List<PreviewFileModel> files)
|
||||
{
|
||||
|
||||
// Check if the NC is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
{
|
||||
ODBPDFDRV baseDir = new ODBPDFDRV();
|
||||
@@ -2017,13 +2023,14 @@ namespace CMS_CORE_Library.Fanuc
|
||||
|
||||
short maxDir = 1;
|
||||
|
||||
// Read directories names
|
||||
// Check if there are directories
|
||||
if (dataNum.dir_num > 0)
|
||||
{
|
||||
// Setup input data
|
||||
currDirInput.dummy = 0;
|
||||
currDirInput.path = path;
|
||||
for(short i = 0; i < dataNum.dir_num; i++)
|
||||
|
||||
for (short i = 0; i < dataNum.dir_num; i++)
|
||||
{
|
||||
// Update index
|
||||
currDirInput.req_num = i;
|
||||
@@ -2042,7 +2049,8 @@ namespace CMS_CORE_Library.Fanuc
|
||||
});
|
||||
}
|
||||
}
|
||||
// Read files names
|
||||
|
||||
// Check if there are files
|
||||
if(dataNum.file_num > 0)
|
||||
{
|
||||
IDBPDFADIR funcInput = new IDBPDFADIR();
|
||||
@@ -2075,7 +2083,7 @@ namespace CMS_CORE_Library.Fanuc
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
return ManageException(ex);
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
@@ -2083,16 +2091,68 @@ namespace CMS_CORE_Library.Fanuc
|
||||
|
||||
public override CmsError FILES_RGetFileInfo(string path, ref InfoFile fileInfo)
|
||||
{
|
||||
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
public override CmsError FILES_WSetActiveProgram(int processId, string filePath, ref ActiveProgramDataModel data)
|
||||
{
|
||||
// Check if the NC is connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
{
|
||||
// Select main data
|
||||
short nReturn = Focas1.cnc_pdf_slctmain(nLibHandle[processId - 1], filePath);
|
||||
if (nReturn != 0)
|
||||
return GetNcError(nReturn);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ManageException(ex);
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
public override CmsError FILES_RActiveProgramData(int processId, ref ActiveProgramDataModel data)
|
||||
{
|
||||
// Check if the NC is connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
try
|
||||
{
|
||||
char[] filePath = new char[242];
|
||||
// Read main program data
|
||||
short nReturn = Focas1.cnc_pdf_rdmain(nLibHandle[processId - 1], filePath);
|
||||
if (nReturn != 0)
|
||||
return GetNcError(nReturn);
|
||||
|
||||
string path = new string(filePath).TrimEnd('\0');
|
||||
|
||||
ushort length = 200;
|
||||
char[] text = new char[201];
|
||||
nReturn = Focas1.cnc_rdexecprog(nLibHandle[processId - 1], ref length, out short block, text);
|
||||
|
||||
string lines = new string(text.Take(length).ToArray());
|
||||
|
||||
data = new ActiveProgramDataModel()
|
||||
{
|
||||
Path = path,
|
||||
IsoLines = lines.Split('\n').ToList(),
|
||||
TimeLeft = new DateTime()
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ManageException(ex);
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -1640,6 +1640,7 @@ namespace CMS_CORE_Library
|
||||
|
||||
#region CONSTANTS (Struct and Enum are Static for definition)
|
||||
|
||||
public const int REFRESH_ALL_ALARMS_SFKEY_INDEX = 29;
|
||||
// Read Write type
|
||||
/** <summary>Write action</summary> */
|
||||
public const bool W = true;
|
||||
|
||||
@@ -491,7 +491,7 @@ namespace CMS_CORE_Library.Osai
|
||||
|
||||
public override CmsError PLC_WRefreshAllMessages()
|
||||
{
|
||||
return NO_ERROR;
|
||||
return PLC_WNcSoftKey(REFRESH_ALL_ALARMS_SFKEY_INDEX);
|
||||
}
|
||||
|
||||
public override CmsError PLC_RPowerOnData(ref PreAndPostPowerOnModel powerOnModel)
|
||||
|
||||
@@ -609,14 +609,13 @@ namespace CMS_CORE_Library.Siemens
|
||||
|
||||
public override CmsError PLC_WRefreshAllMessages()
|
||||
{
|
||||
int numberOfInteger = (ALARMS_NUMBER / 8) / 4; // Number of integers to write 1024 / 8 = byte number
|
||||
List<uint> defaultValue = Enumerable.Repeat(uint.MaxValue, numberOfInteger).ToList();
|
||||
//int numberOfInteger = (ALARMS_NUMBER / 8) / 4; // Number of integers to write 1024 / 8 = byte number
|
||||
//List<uint> defaultValue = Enumerable.Repeat(uint.MaxValue, numberOfInteger).ToList();
|
||||
|
||||
CmsError cmsError = MEM_RWDWordList(W, 0, ALARM_REFRESH_STROBE.MemType, ALARM_REFRESH_STROBE.Address, ALARM_REFRESH_STROBE.SubAddress, numberOfInteger, ref defaultValue);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
return NO_ERROR;
|
||||
//CmsError cmsError = MEM_RWDWordList(W, 0, ALARM_REFRESH_STROBE.MemType, ALARM_REFRESH_STROBE.Address, ALARM_REFRESH_STROBE.SubAddress, numberOfInteger, ref defaultValue);
|
||||
//if (cmsError.IsError())
|
||||
// return cmsError;
|
||||
return PLC_WNcSoftKey(REFRESH_ALL_ALARMS_SFKEY_INDEX);
|
||||
}
|
||||
|
||||
public override CmsError PLC_RPowerOnData(ref PreAndPostPowerOnModel powerOnModel)
|
||||
|
||||
Reference in New Issue
Block a user