Save, load and delete job files. Also, lists and counts files.
Parameter RS7 must be set to 2 to allow these functions outside of REMOTE mode.
Name | Description |
---|---|
LoadToControllerFromString | Load a job file to the controller from a string. |
LoadToControllerFromPath | Load a job file to the controller from a file path. |
SaveFromControllerToFile | Save a job file from the controller to a file path. |
SaveFromControllerToString | Save a job file from the controller to a string. |
DeleteJobFile | Delete a job file from the controller. |
GetFileCount | Get the number of files on the controller. |
ListFiles | List the files on the controller. |
Load a file to the controller from a string.
Parameter RS7 must be set to 2 to allow this function outside of REMOTE mode.
Load a file to the controller from a file path.
The following file types are writable...
StatusInfo LoadToControllerFromString(const std::string& fileName, const std::string& contentsToLoad)
fileName
[in] The name of the file to load.
contentsToLoad
[in] A string containing the contents for the file.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
std::string jobString = "/JOB\r\n"
"//NAME TEST1\r\n"
"//POS\r\n"
"///NPOS 0,0,0,0,0,0\r\n"
"//INST\r\n"
"///DATE 2023/08/02 04:39\r\n"
"///ATTR SC,RW\r\n"
"///GROUP1 RB1\r\n"
"NOP\r\n"
"END\r\n";
status = c->Files->LoadToControllerFromString("TEST1.JBI", jobString);
YMConnect::CloseConnection(c);
Output
Code (0): OK
Load a file to the controller from a file path.
The following file types are writable...
StatusInfo LoadToControllerFromPath(const std::string& filePath)
filePath
[in] The file path on your system to the file to load.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
status = c->Files->LoadToControllerFromPath("C:\\Users\\Public\\Documents\\TEST1.JBI");
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Save a file from the controller to a file path.
StatusInfo SaveFromControllerToFile(const std::string& fileName, const std::string& destinationFile, bool overwriteFlag = false)
fileName
[in] The name of the file to save.
destinationFile
[in] The file path on your system to save the file to.
overwriteFlag
[in] If true, the file will be overwritten if it already exists.
If false and the file exists, the function will fail.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
status = c->Files->SaveFromControllerToFile("TEST1.JBI", "C:\\Users\\Public\\Documents\\TEST1.JBI", true);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Save a file from the controller to a string.
StatusInfo SaveFromControllerToString(const std::string& fileName, std::string& fileContents)
fileName
[in] The name of the file to save.
fileContents
[out] A string containing the contents of the file.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
std::string fileContents;
status = c->Files->SaveFromControllerToString("TEST1.JBI", fileContents);
std::cout << status << std::endl;
std::cout << fileContents << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
/JOB
//NAME TEST1
//POS
///NPOS 0,0,0,0,0,0
//INST
///DATE 2023/10/18 05:04
///ATTR SC,RW
///GROUP1 RB1
NOP
END
Delete a job file from the controller.
StatusInfo DeleteJobFile(const std::string& fileName)
fileName
[in] The name of the file to delete.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
status = c->Files->DeleteJobFile("TEST1.JBI");
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Get the number of files on the controller cooresponding to a file type.
StatusInfo GetFileCount(FileType fileType, INT32& fileCount)
fileType
[in] The type of file to count. See FileType.
fileCount
[out] The number of files on the controller.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
INT32 fileCount{};
status = c->Files->GetFileCount(FileType::Job_JBI, fileCount);
std::cout << status << std::endl;
std::cout << fileCount << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
6
List the files on the controller cooresponding to a file type.
StatusInfo ListFiles(FileType fileType, std::vector<std::string>& fileNames, bool sorted)
fileType
[in] The type of file to list. See FileType.
fileNames
[out] A vector of strings containing the file names.
sorted
[in] If true, the file names will be sorted alphabetically.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
std::vector<std::string> files{};
status = c->Files->ListFiles(FileType::Job_JBI, files, true);
std::cout << status << std::endl;
for (auto& file : files)
{
std::cout << file << std::endl;
}
YMConnect::CloseConnection(c);
Output
Code (0): OK
MASTER.JBI
TEST1.JBI
TEST2.JBI
TEST3.JBI
TEST4.JBI