05-17-2018 04:40 AM
according to a suggestion by Mr Unangst (see here) i've tried to use the same technique to upload robot programs into PS.
private void button5_Click(object sender, EventArgs e)
{
int s = cmb_robots.SelectedIndex;
TxRobot selectedRobot = (TxRobot)allRobots[s];
TxOlpControllerUtilities txOlpControllerUtilities = new TxOlpControllerUtilities();
string path = @"C:\Temp\uploadtest\FF_BC1.tid";
ITxRoboticProgramUploader uploader = txOlpControllerUtilities.GetInterfaceImplementationFromController(selectedRobot.Controller.Name,
typeof(ITxRoboticProgramUploader),
typeof(TxControllerAttribute),
selectedRobot.Controller.Name) as ITxRoboticProgramUploader;
uploader.Upload(path, selectedRobot);
}
unfourtunately the uploader Object stay's null, since i have no clue what to pass into
GetInterfaceImplementationFromController parameters to get a ItxRoboticProgramUploader.
Did anyone get an upload method running?
Solved! Go to Solution.
05-17-2018 11:38 AM
Hello @Titaniser
Code below works for me. Although, I can't actually remember why I'm also checking if uploader is not "null", maybe some configuration in robot controller needs to be done correctly before trying to upload. Or maybe some controller I was testing had no upload capability.
You can also test for last "ControllerName" string, if changing that can help you to get the object correctly
TxOlpControllerUtilities newUtilities = new TxOlpControllerUtilities(); if (robot != null) { ITxRoboticProgramUploader uploader = newUtilities.GetInterfaceImplementationFromController(robot.Controller.Name, typeof(ITxRoboticProgramUploader), typeof(TxRoboticProgramUploaderAttribute), "ControllerName") as ITxRoboticProgramUploader; if (uploader != null) uploader.Upload(newPath, robot); }
Regards!
05-18-2018 09:03 AM
That seems to work at first sight, but unfourtunately no locations where uploaded.
The build in uploader works fine with locations.
Do i have to create locations (including parameters) by my self?
05-18-2018 11:43 AM
The uploader shall do the complete job for you.
Maybe you can try to check if the robot was correctly selected. The builtin application automatically filter the nc file extension for specific robots (in your case ".tid"), but your application is not checking that, so maybe you're trying to upload a nc file with incorrect robot (which I don't know if throws an exception or if can result in an empty uploaded file, like happened in your case).
Regards!
05-21-2018 12:58 AM
Hi,
it should be like this:
public ITxRoboticProgramUploader CreateUploader(TxRobot robot) 29 { 30 string controllerName = robot.Controller.Name; 31 ITxRoboticProgramUploader uploader = null; 32 if( controllerName != null) 33 { 34 TxOlpControllerUtilities controllerUtilities = new TxOlpControllerUtilities(); 35 uploader = (ITxRoboticProgramUploader)controllerUtilities.GetInterfaceImplementationFromController(controllerName, typeof(ITxRoboticProgramUploader), typeof(TxRoboticProgramUploaderAttribute), "ControllerName"); 36 } 37 38 return uploader; 39 }
Regards,
Moshe
06-04-2018 08:54 AM
my fault,
instead of uploading the datafile, i've tried it with the program file. That works.
Thanks guys or girls
08-19-2018 08:30 AM
Hy,
does anyone knows or has figure it out. If you upload more than one Program using PS Upload function, it puts you all Programs being uploaded under one Compound Operation like on the picture.
When I´m uploading using foreach, it uploaded each program under his own Compound Operation.
So how to upload files into one Compound Operation?
08-21-2018 01:14 AM
Hi,
Can you please share your code?
Regards,
Moshe
08-23-2018 02:10 AM
Hi,
here is my code.
foreach (string file in OpenFile.FileNames)
{
......
Upload(SelectedFile, Robot);
}
public void Upload(string file, TxRobot robot)
{
TxOlpControllerUtilities newUtilities = new TxOlpControllerUtilities();
if (robot != null)
{
ITxRoboticProgramUploader uploader = newUtilities.GetInterfaceImplementationFromController(robot.Controller.Name,
typeof(ITxRoboticProgramUploader), typeof(TxRoboticProgramUploaderAttribute),"ControllerName") as ITxRoboticProgramUploader;
if (uploader != null) uploader.Upload(file, robot);
}
}
09-03-2018 04:25 AM
Hi,
you create a new uploader for each file, instead of creating only once and using it for all files. So the loop over files should be below.
Regards,
Moshe
Watch Replays of Previous Topics