cancel
Showing results for 
Search instead for 
Did you mean: 

Write new OLP commands using API

Creator
Creator

Hi everyone,

 

I have been looking to on how to add OLP commands to some vialocations in my stud but can find the class that does this. There is a lot of different classes for working with OLP commands. I am totally newbie to this and quite lost at the moment when it comes to OLP commands.

 

In my case basically what i would like to do is to write a message in text (as shown in picture 1) and also on a different location include a WaitSignal that will be going to the PLC.

 

I am not sure if its clear, but please ask me if you need any clarfication.

 

Thanks for your help one more time.

Lucas

8 REPLIES

Re: Write new OLP commands using API

Siemens Legend Siemens Legend
Siemens Legend

Hi,

 

Maybe "TxRoboticCompositeCommandCreationData" is what you are looking for.

 

TxRoboticCompositeCommandCreationData txRoboticCompositeCommandCreationData =
new TxRoboticCompositeCommandCreationData(elements);

WeldOp.CreateCompositeCommand(txRoboticCompositeCommandCreationData);

 

 

Best regards

Patrick

Re: Write new OLP commands using API

Creator
Creator

Hi Patrick!

 

Thanks for your quick answer. i think that what i need, but when you mention "elements" what do you refer to? I've seen that the SDK mention an ArrayList but still i can't manage to make it work. Do i need to define it as a TxCompositeCommandElement and then put it on the "CreationData" (As shown below)

 

TxCompositeCommandElement NewElement = new as TxCompositeCommandElement;
//change the value of "NewElement", dont know how

TxRoboticCompositeCommandCreationData txRoboticCompositeCommandCreationData = new TxRoboticCompositeCommandCreationData(NewElement); WeldOp.CreateCompositeCommand(txRoboticCompositeCommandCreationData);

Could you help me on this?

Re: Write new OLP commands using API

Genius
Genius

Hello Lucas

 

The elements are basically the parameters from your XML customization that you select/input when adding the OLP command. If your OLP depends on two parameters, e.g,  you need to create an ArrayList and add the elements to it. This ArrayList is the input to the CreationData (instead of the element, as you were trying to do)

 

Regards

Re: Write new OLP commands using API

I did this a few years back sucessfully.  But this may only work inserting string based Commands.  For using the XML schema to build a command list you may have to use the Classed meantioned above.  This is just a quick dirty method of populating the download layer in a location.  It had a method before this that cleared the strings from the locations Commands array.

 

//blocks is an arraylist returned from a SQL handling service that returned a logic block for a location

//wp_id is a location object.

 

for (i = 0; i < block.Count; i==)

{

buffer = block[i].ToString();

try

{

if (buffer != null)

{

TxRoboticCommandCreationData ccd = new TxRoboticCommandCreationData(buffer);

TxRoboticCommand testcom = wp_id.CreateCommand(ccd);

wp_id.Commands.Add(testcom);

}

}

catch

{

}

}

 

 

 

Re: Write new OLP commands using API

Creator
Creator

Thanks for your asnwer FredCastro!! I solve my problem by writting the next code:

 

ArrayList ArrList1 = new ArrayList();
TxRoboticCompositeCommandStringElement StringElement1 = new TxRoboticCompositeCommandStringElement(); TxRoboticCompositeCommandCreationData CommandCreationData1 = new TxRoboticCompositeCommandCreationData(); ITxRoboticLocationOperation Command11 = Command[0] as ITxRoboticLocationOperation; string Message1 = "New OLP command";
StringElement1.Value = Message1; ArrList1.Add(StringElement1); CommandCreationData1.Elements = ArrList1; Command11.CreateCompositeCommand(CommandCreationData1); // Also .Commands.Add(Message1); can be used

//OUTCOME
A new command stating "New OLP command" gets generated on the vialocation "Command11"

 

Since until now i have only tried with plain text, i would like to know how to implement the WaitSignals as OLP. Should i just write  asrting that says: WaitSignal "name of the signal"? or is there another way of properly creating that WaitSignal for the OLP Command?

Re: Write new OLP commands using API

Creator
Creator
Thanks for your answer CliffKnasinski

Re: Write new OLP commands using API

You can do it as a string as long as the syntax is correct the simulation will recognize it as a command to wait.

 

The string should follow the syntax of the robot programming language that the controller is set to.  If it is set to default controller then all you have to do is insert a wait signal command into a location, and then look at the simulation layer of it to see the correct syntax needed.

Re: Write new OLP commands using API

Genius
Genius

Hello

 

I believe the best way of doing it is adding a plain text exactly the way it should look like the command. The controller shall automatically convert it to your desired command (at least is what happens when you use the "Free Text" command from the default controller and write the plain text equals to a default controller command, like the wait command, e.g, "# WaitTime 2")

 

I also believe you can do it by adding a TxRoboticCommand with only the text, or a TxRoboticCompositeCommand with the text + an empty ArrayList. 

 

Regards!