SM3_Basic.IAxisRef.GetAxisRefPointer not working as expected - codesys

Running "CODESYS V3.5 SP16" here, does anyone have the same problem with the method in the title?
PROGRAM PLC_PRG
VAR
itfAxisRef : SM3_Basic.IAxisRef;
pAxisRefSm3 : POINTER TO SM3_Basic.AXIS_REF_SM3;
END_VAR
pAxisRefSm3 := itfAxisRef.GetAxisRefPointer;
Trying to compile the above throws the following error
C0032: Cannot convert type 'GETAXISREFPOINTER(sm3_basic, 4.10.0.0 (3s - smart software solutions gmbh))' to type 'POINTER TO SM3_Basic.AXIS_REF_SM3'
which has me really confused because I've never seen the type GETAXISREFPOINTER before and the documentation for .GetAxisRefPointer states that it returns POINTER TO AXIS_REF_SM3
https://help.codesys.com/webapp/3dvrBKsuKjYfmeP1KzrJnylfstc%2FGetAxisRefPointer;product=SM3_Basic;version=4.9.0.0
As for why I'm trying to use this method, I'm trying to loop through the array of axes in SM3_Robotics.AXIS_GROUP_REF_SM3 and pass them to SM3_Basic.MC_ReadStatus in order to get their individual SM3_Basic.SMC_AXIS_STATE (not only the SM3_Robotics.SMC_AXIS_GROUP_STATE) for debugging
Is there a better way to achieve the above without using the axes array?

GetAxisRefPointer is a Method, try:
pAxisRefSm3 := itfAxisRef.GetAxisRefPointer();

Related

talend thmap get value of outer loop element

I'm just starting out with thMap.
So far I have successfully mapped an X12 835 message to output structures. That works no problem.
I have also successfully acquired the LoopIndex of the current loop using the LoopIndex() function.
My challenge:
I need to get the value of an element from the enclosing loop.
In the attached image, everything in green is working.
I'm trying to get the value down the red line.
My goal is to do this assignment
gsRecord.parent_id = enclosing loop isaRecord.id
The documentation explains some things but I don't see examples putting it together.
Does anyone have any good examples, videos or suggestions?
Update from 12/9/22
Here is something I have tried. Providing this example in hopes someone recognizes a specific issue to help move me forward. Any input would be appreciated.
Per this screenshot
I am attempting to output in gsRecord.parent_id the loopIndex of the parent loop (isaRecord).
This gives me the following error
"An reference in an LoopIndex/Variable was made to an either an input
map element or an output map element that is not in the context of the
reference. Use an enclosing looping output map element here.(msg #1202)"
Given the reference to 'enclosing looping output map element here' it feels like the gsRecord is not properly defined as a child of the isaRecord.
However the definition of the gsRecord is in reference to the isaRecord as in this screenshot.
It feels like there is some combination of LoopIndex and EnclosedContext that I could use to accomplish this but I'm unable to find any in-depth documentation on the functions.
Any help would be appreciated.

Trouble with poDoNotEncode option in TRESTRequest.AddParameter() method

I'm having trouble using the poDoNotEncode option in the TRESTRequest.AddParameter() method. I need to be able to post a request with a j_token header with a value that includes the '/' characters or else. For this need, I read everywhere that I can simply add poDoNotEncode to the options of the request parameters.
I tried several methods I found on the Internet to add a j_token header to my request:
var
RESTRequest : TRESTRequest;
RESTClient : TRESTClient;
Response : TRESTResponse;
begin
RESTClient := TRESTClient.Create('http://127.0.0.1:5000/')
RESTRequest := TRESTRequest.Create(nil);
try
RESTRequest.Client := RESTClient;
RESTRequest.Method := rmPOST;
RESTRequest.AddParameter('j_token', 'ga/ga', pkHTTPHEADER, poDoNotEncode);
//RESTRequest.Params.AddHeader('j_token', 'ga/ga').Options := poDoNotEncode;
//RESTRequest.Params.AddItem('j_token', 'ga/ga', pkHTTPHEADER, poDoNotEncode);
RESTRequest.Execute;
Response := RESTRequest.Response;
ShowMessage(Response.Content);
finally
RESTClient.Free;
RESTRequest.Free;
end;
end;
In this example, I used my own API to see the content of my request headers (here just j_token). Each and every method I tried (the commented ones) result with this:
Request headers : ga%2Fga
Meaning that the header I'm sending is url-encoded whether or not poDoNotEncode is specified.
Just to clarify, I'm working currently on a program developed by the company I work for. This software should use Delphi 10.3 Rio as its script language.
Maybe it can help, but when I try something like this:
RESTRequest.AddParameter('j_token', 'ga/ga', pkHTTPHEADER, [poDoNotEncode]);
I get this error:
RUNTIME ERROR : Impossible converting variant of type (Array Variant) to type (Integer) when evaluating instruction PushVar($0,$0,$0,$0, 'Result')...
And when I try something like this:
RESTRequest.AddParameter('j_token', 'ga/ga', pkHTTPHEADER, TRESTRequestParameterOptions.poDoNotEncode);
then I get this error:
Unknown identifier or variable is not declared : 'TRESTRequestParameterOptions'
I tried to be as precise as possible, because I'm completely stuck right now. If you need more precision, I'll try to answer as clearly as possible.
I've solved my problem. To provide a context, I have access to the archives of my company with every script they made. To learn delphi it helps a lot, and as I was looking at an example for the TRESTRequest.AddParameter() method i noticed that the 4th parameter for this method was a 0 like this :
RESTRequest.AddParameter('j_token',mytoken,pkHTTPHEADER,0);
So I looked on the internet to find what that 0 meant and i found out it was supposed to be an option for the parameter such as poDoNotEncode. I was still wondering why they replaced that with a 0 but I simply guessed it was to avoid an error if you don't put anything because our compiler wants the RESTRequest.AddParameter() method to have 4 parameters. So in the end i started doing the same until i needed my parameter to not getting encoded. But the poDoNotEncode option wasn't working. I tried to see what it would show inside a ShowMessage(poDoNotEncode); and it showed me a 0. So I decided as a test to put a 1 instead of poDoNotEncode like this :
RESTRequest.AddParameter('j_token',mytoken,pkHTTPHEADER,1);
And finally it worked, I have no idea why our software prefers using Integers instead of the real options names but if ever you stumble upon this problem, there is a high chance that you had the same weird definition of options.
Thank you all for your help !

Trying to use dynamic and action parameters

recently I stumbled upon one of the videos of Benjamin Schumann titled: What are dynamic and action parameters and when should you use them in your AnyLogic model.
I tried to further adjust the functions of dynamic and action based parameters for a problem of mine. Just to give a heads up, I am fairly new to Anylogic (only worked through that one book, and some minor projects and tutorials) and been decent in Java (been a few years since I've been actively working in Java but currentlystarting to get back in [still rusty]).
Regarding my actual problem, in the video Mr. Schumann has an agent with three parameters. One static, one dynamic and one action. In addition to that he has a variable (double) all set in his agent. On his main is a button to increment the value of the variable with the help of the parameters and to trace the lines in the console (= giving out a string if a certain threshold of the variable is passed).
I created a similar setting, however I happen to run into a lot of variable errors during time to time while compiling.
Here some example code snippets:
dynamic parameter p_Station of the type String
v_myFahrt < 222 ? "Wiesbaden Hbf" :
v_myFahrt < 442 ? "Wiesbaden-Biebrich Bahnhof Wiesbaden Ost" :
v_myFahrt < 663 ? "Wiesbaden-Mainz-Kastel Bahnhof" :
"Hochheim (Main) Bahnhof"
therefore my variable is called v_myFahrt, a double with the initial value of 0
action parameter p_durchFahrt with the default action:
v_myFahrt = v_myFahrt + 220;
and my Button on the main:
myAgent.p_durchFahrt();
traceln(myAgent.p_Station());
So basically it is a somewhat similar code as in the reference. I tried to than add another instance of the agent with a different set of "code" for the dynamic parameter (different Strings and values) as well as a different "code" for the action parameter (e.g. + 208 instead of + 220). To then wanting to trace the lines in the console with the button again.
I tried to add
myAgent1.p_durchFahrt(); traceln(myAgent1.p_Station());
to it.
But before I coul even run it, I keep getting the error "v_myFahrt cannot be resolved to a variable" for myAgent1. Inspecting the error it keeps referring to myAgent1 with the newly added code for p_Station and I can't seem to find a way around it.
What am I doing majorly wrong here?
it looks like you have created v_myFahrt in main, right? (that would explain your symptoms).
If yes, you should create it in MyAgent instead.

How can I run createOptimProblem in matlab?

My question is a little bit stupid, but still, I would like someone who can help me if he/she face the same problem as me.
I copy the codes directly from MATLAB mathwork:
anonrosen = #(x)(100*(x(2) - x(1)^2)^2 + (1-x(1))^2);
opts = optimoptions(#fmincon,'Algorithm','interior-point');
problem = createOptimProblem('fmincon','x0',randn(2,1),...
'objective',anonrosen,'lb',[-2;-2],'ub',[2;2],'options',opts);
However, it gives the following error message:
Undefined function 'createOptimProblem' for input arguments of type 'optim.options.Fmincon'.
createOptimProblem should be a built-in function, but with the presence of the error message, I wonder if I need to declare sth before using createOptimProblem, what should I do?
I am using R2013a version

Requesting member of node_element results in "undefined"

I'm using Opa for a school project in which there has to be some synchronization of a textfield between several users. The easy way to solve this, is to transmit the complete field whenever there is a change performed by one of the users. The better way is of course to only transmit the changes.
My idea was to use the caret position in the textfield. As a user types, one can get the last typed character based on the caret position (simply the character before the caret). A DOM element has an easy-to-use field for this called selectionStart. I have this small Javascript for this:
document.getElementById('content').selectionStart
which correctly returns 5 if the caret stands at the fifth character in the field. In Opa, I cannot use selectionStart on either a DOM or a dom_element so I thought I'd write a small plugin. The result is this:
##extern-type dom_element
##register jsGetCaretPosition: dom_element -> int
##args(node)
{
return node.selectionStart;
}
This compiles with the opp-builder without any problem and when I put this small line of code in my Opa script:
#pos = %%caret.jsGetCaretPosition%%(Dom.of_selection(Dom.select_id("content")));
that also compiles without problems. However, when I run the script, it always returns "undefined" and I have no idea what I'm doing wrong. I've looked in the API and Dom.of_selection(Dom.select_id("content")) looked like the correct way to get the corresponding dom_element typed data to give to the plugin. The fact that the plugin returns "undefined" seems to suggest that the selected element does not know the member "selectionStart" eventhough my testcode in Javascript suggest otherwise. Anyone can help?
In Opa dom_element are the results of jQuery selection (i.e. an array of dom nodes). So if I well understood your program you should write something like node[0].selectionStart instead of node.selectionStart.
Moreover you should take care of empty selection and selection which doesn't contains textarea node (without selectionStart property). Perhaps the right code is tmp == undefined ? -1 : tmp = node[0].selectionStart == undefined ? -1 : tmp