I have a global struct added to my task using taskVarAdd() API.
But during some scenarios, the same global struct is is added to the same task again using taskVarAdd() API. [i.e., taskVarAdd() is called twice from a task for a same variable].
This struct will maintain the taskID, message queue ids for that task
Following is the sample program witten by Benoit to explain the scenario,
int v1;
void tvl()
{
int i = 0;
v1 = 1;
taskVarAdd(0, &v1);
v1 = 2;
taskVarAdd(0, &v1);
v1 = 3;
taskDelay(1);
printf("Initial v1 = %d\n", v1);
for(i = 0;i<10;i++)
{
v1++;
taskDelay(60);
printf("v1 = %d\n", v1);
}
}
When I tested the code using tornado and i am getting different results every time i execute your program
//1st Attempt
-> tv1
Inital v1 = V1 = 3
V1 = 3
V1 = 2
V1 = 4
V1 = 4
V1 = 3
V1 = 5
V1 = 5
V1 = 5
V1 = 6
//2nd attempt
-> tv1
Inital v1 = V1 = 1
V1 = 3
V1 = 4
V1 = 2
V1 = 4
V1 = 5
V1 = 3
V1 = 5
V1 = 6
But When i commented the second taskVarAdd() and tested it, i am getting the consistent expected results as follows
//1st Attempt
-> tv1
Inital v1 = 3
V1 = 4
V1 = 5
V1 = 6
V1 = 7
V1 = 8
V1 = 9
V1 = 10
V1 = 11
V1 = 12
V1 = 13
//2nd Attempt
-> tv1
Inital v1 = 3
V1 = 4
V1 = 5
V1 = 6
V1 = 7
V1 = 8
V1 = 9
V1 = 10
V1 = 11
V1 = 12
V1 = 13
We are using VxWork 5.5
My Questions:
Is it right to use two taskVarAdd() inside same task for same variable?
What will be the behavior if two taskVarAdd() is used for same variable inside same task?
Kindly explain the flow of your program
I'd like to say it is not right to add taskVarAdd two times:
first, the vxworks's implementation did not deal with this situation.(I checked the vxworks source, when two taskvar have the same address, the taskVar will set two times which will get the value wrong. As vxworks is close source, so I am not going to paste the source here, but it's the vxworks' implementation makes it wrong)
second, why you need to add two times? taskAddVar make a address to be private to current task, when the task is switch out, the value be saved to task's TCB; and when the task is switch back, the private address's value will be copied back. So different task will have different value even in the same address.
vxworks implements the taskVar mechanism by adding a switch hook to make a task's private var to be save/set at task switch, which make same routine but run in different task context can have different private value at same address.
Related
I am analyzing RNA sequencing data with 4 treatments. During the process in r, I got an error below with the code. It is to make a glimma MDplot. It would be appreciated that anyone solve this problem.
All treatments include 4 replicates, but one of them has only 3. I am unsure that this exerts the error, but just in case, I informed.
glMDPlot(fit.trend2, counts = logCPM.trend, status = trend_global_0.1, coef = 1, groups = d.filt$samples$group, samples = d.filt$samples$Label, sample.cols = d.filt$samples$col, folder = "glimma-plots", html = "HvsC_trend_globalFDR", main = "H. vs. C.", launch = TRUE)
Error in if (all(x > 0)) { : missing value where TRUE/FALSE needed
I'm modifying someone else's showershell script that's used within our database to try and have it do some extra steps behind the scenes: reject code, location code, and start date.
It starts by asking for 3 values to pass as variables, but I want to add 2 additional values using a dictionary based on the location code. I don't want to share the entire batch - I know it works without this one specific part, but I'll include enough to illustrate my point.
The issue is with the variables $AREA1 and $AREA2 - these are what I'm trying to add.
The "parameters" are being injected using one way where it asks for the user to supply them but i don't want the user to supply these, they're supposed to be a lookup.
For instance, if the LOC was 5300 then AREA1 should be 101 and AREA 2 should be 111.
param(
[ImdsParameter(FullName = "REJ_CODE", Description = "Enter a 4 digit reject code to filter the data. Will not run without one.", Length = 4)]
[string] $REJ,
[ImdsParameter(FullName = "LOC", Description = "The Location code you want to run this against. Example 5300.", Length = 4)]
[string] $LOC,
[ImdsParameter(FullName = "STDTE", Description = "Start date. This is the start date from how back to run the report. Example 2021-01-01", Length = 10)]
[string] $STDTE
)
$areaStart = #{
5300 = 101 ;
5304 = 112 ;
5305 = 123 ;
5306 = 134 ;
//there’s well over 100 of these
}
$areaEnd = #{
5300 = 111 ;
5304 = 122 ;
5305 = 133 ;
5306 = 144 ;
//same
}
$AREA1 = $areaStart.Get_Item($LOC)
$AREA2 = $areaEnd.Get_Item($LOC)
$jobSql = #"
SELECT TB1.dataitem1,
TB1. Dataitem2,
TB1. Dataitem3,
TB2. Dataitem1
FROM firstTable AS TB1 INNER JOIN secondTable AS TB2
ON TB1. dataitem = TB2. dataitem
WHERE TB1.LOCATION = #LOC AND TB2.AREA BETWEEN '$($AREA1)' AND '$($AREA2)'
"#
$edbms = Get-Rdms -SQL $jobSql -Parameters #{LOC = $LOC; REJ = $REJ; STDTE = $STDTE; }
$edbms | ConvertTo-Csv -NoTypeInformation
EDIT: I need to add that the script will run, but returns no data. If I just plug the SQL in with all the values manually, it will run just fine.
Thank you for your time.
The values in the SQL were being treated as strings while the values in the dictionaries were being treated as numbers.
I changed this:
5300 = 101 ;
5304 = 112 ;
5305 = 123 ;
5306 = 134 ;
To this:
'5300' = '101' ;
'5304' = '112' ;
'5305' = '123' ;
'5306' = '134' ;
And it provided the data expected.
is TYPO3 able to collect recursive and show the amount of subpages (no storages) from a specific root page? Tried this typoscript snippet but it is not working somehow.
20 = CONTENT
20 {
table = pages
select {
selectFields = count(*)
pidInList = <ROOT-PID>
andWhere = (hidden=0 AND deleted=0)
}
renderObj = COA
renderObj {
10 = TEXT
10 {
field = count(*)
wrap = Counted pages: |
}
}
}
Maybe there is some function in TYPO3 9?
Thanks in advance!
As the data is stored as a tree you need a recursion to get all pages from all sublevels.
As you can't know the depth (or expect a high number) and typoscript as a configuration language has no recursion build in a pure typoscript solution would be complicated.
Here a userfunc written in PHP and with recursion could be a quick solution.
In general:
Why do you need that number?
Maybe there is a simpler solution
here a pure typoscript solution you might start with:
for each menu-entry you get the sum of all pages up to three levels deeper and the count of pages on the next level.
temp.menudef = TMENU
temp.menudef {
#target = _top
noBlur = 1
#expAll = 1
wrap = <ol>|</ol>
NO = 1
NO {
stdWrap.cObject = COA
stdWrap.cObject {
1 = TEXT
1.field = title
1.required = 1
10 = LOAD_REGISTER
10.level1uids.cObject = COA
10.level1uids.cObject {
10 = CONTENT
10.table = pages
10.select.pidInList.data = field:uid
10.renderObj = TEXT
10.renderObj.field = uid
10.renderObj.wrap = |,
20 = TEXT
#20.field = uid
20.data = field:uid
}
10.level2uids.cObject < .10.level1uids.cObject
10.level2uids.cObject.10.select.pidInList.data = register:level1uids
10.level2uids.cObject.20.data = register:level1uids
10.level3uids.cObject < .10.level1uids.cObject
10.level3uids.cObject.10.select.pidInList.data = register:level2uids
10.level3uids.cObject.20.data = register:level2uids
20 = TEXT
20.wrap = <!-- --> (|
20.required = 1
20.override.numRows.table = pages
20.override.numRows.select.pidInList.data = register:level3uids
20.override.stdWrap.ifEmpty =
20.override.stdWrap.ifEmpty.wrap = |
30 = TEXT
30.wrap = -|)
30.required = 1
30.override.numRows.table = pages
30.override.numRows.select.pidInList.field = uid
30.override.stdWrap.ifEmpty =
30.override.stdWrap.ifEmpty.wrap = |
}
}
NO.wrapItemAndSub = <li>|</li>
NO.accessKey = 1
ACT < .NO
#ACT = 1
ACT.wrapItemAndSub = <li class="activ">|</li>
SPC < .NO
#SPC = 1
SPC.wrapItemAndSub = <li><span class="spacer">|</span></li>
CUR < .ACT
#CUR = 1
CUR.linkWrap = <span class="act">|</span>
CUR.wrapItemAndSub = <li class="current">|</li>
}
temp.submenu = HMENU
temp.submenu {
entryLevel = 0
wrap = <div class="smenu">|</div>
1 < temp.menudef
2 < .1
3 < .2
4 < .3
5 < .4
}
I have a problem with adding rows of table to the transport request in programming way.
When i wrote down the transport request number i get the error:
You cannot use request EAMK913244
the code I use is
data lt_variable_changed type table of ztable_task2.
data: l_request type trkorr,
lt_e071 type tr_objects,
lt_e071k type tr_keys,
lv_tabkey type trobj_name,
ls_e071 type e071,
ls_e071k type e071k.
ls_e071-pgmid = 'R3TR'.
ls_e071-object = 'TABU'. "for table
ls_e071-obj_name = 'ZTABLE_TASK2'.
ls_e071-objfunc = 'K'.
append ls_e071 to lt_e071.
loop at lt_variable_changed into ls_variable.
lv_tabkey = ls_variable-num.
ls_e071k-pgmid = 'R3TR'.
ls_e071k-object = 'TABU'.
ls_e071k-objname = 'ZTABLE_TASK2'.
ls_e071k-mastertype = 'TABU'.
ls_e071k-mastername = 'ZTABLE_TASK2'.
ls_e071k-tabkey = lv_tabkey.
append ls_e071k to lt_e071k.
endloop.
call function 'TR_REQUEST_CHOICE'
exporting
iv_suppress_dialog = 'X'
iv_request = var_query
it_e071 = lt_e071
it_e071k = lt_e071k.
message 'Ok' type 'I'.
Screen from se01:
Thanks for help and good luck!
three function modules shall be used to transport changes
call function 'TR_ORDER_CHOICE_CORRECTION'
exporting
iv_category = 'CUST'
importing
ev_order = ev_request
ev_task = ev_task
exceptions
invalid_category = 1
no_correction_selected = 2
others = 3.
call function 'TR_OBJECTS_CHECK'
exporting
iv_no_show_option = abap_true
tables
wt_ko200 = lt_ko200_customizing
wt_e071k = lt_e071k_customizing
exceptions
cancel_edit_other_error = 1
show_only_other_error = 2
others = 3.
call function 'TR_OBJECTS_INSERT'
exporting
wi_order = lv_request
iv_no_show_option = abap_true
tables
wt_ko200 = lt_ko200_customizing
wt_e071k = lt_e071k_customizing
exceptions
cancel_edit_other_error = 1
show_only_other_error = 2
others = 3.
You can also use object-oriented approach for transporting tables.
This piece creates a customizing request and puts contents of a table in it:
DATA(instance) = cl_adt_cts_management=>create_instance( ).
TRY.
instance->insert_objects_in_wb_request( EXPORTING pgmid = 'R3TR'
object = 'TABU'
obj_name = CONV trobj_name( 'Z_TABLE' )
CHANGING trkorr = l_trkorr ).
CATCH cx_adt_cts_insert_error.
RETURN.
ENDTRY.
This piece uses ADT CTS classes and is very flexible. Despite the name wb_request this method is adaptive and will create workbench or customizing request depending on the objects passed.
Sprite = {x = 0, y = 0, pos = {z=0}}
function Sprite:new()
o = {}
setmetatable(o,self)
self.__index = self
return o
end
s1 = Sprite:new()
s2 = Sprite:new()
s1.x = 10
s1.pos.z = 5
print("s1.x", s1.x, "s2.x", s2.x, "s1.z",s1.pos.z, "s2.z", s2.pos.z )
s2.x = 20
s2.pos.z = 50
print("s1.x", s1.x, "s2.x", s2.x, "s1.z",s1.pos.z, "s2.z", s2.pos.z )
In the above code snippet, I define a class Sprite which has x(int),y(int),pos(table) 3 attributes, but when I init two object s1,s2. I found that they shared the pos attribute.
If you run the code, it will print:
s1.x 10 s2.x 0 s1.z 5 s2.z 5
s1.x 10 s2.x 20 s1.z 50 s2.z 50
s1 and s2 has their own x,y attribute, but share pos attribute, if s1.pos.z is changed, so as the s2.pos.z.
How can I fix this?
In Sprite:new, the variable self always has Sprite as its value. So, self.pos refers to Sprite.pos. Try changing to o.pos={}. Also, consider making o a local.
Sprite represents the class, hence you can think of Sprite table as the "class wide" entries: they will be shared by all "instances". Instance specific entries should be in the o table:
Sprite = {classX = 0, classY = 0} -- class; vars shared by all instances
function Sprite:new()
o = {pos = {z=0}}
setmetatable(o,self)
self.__index = self
return o
end
Note that "shared" really does mean shared at the reference level, so all instances will see the same values and any changes made by one instance will be seen by all others. OTOH data you put in o table is per instance. Putting this in Sprite.new() ensures that all instances have the same fields, but their own data; changes by one instance will not affect any other instance.
That said, your Sprite:new() does not define self.__newindex. So Sprite.classX = 5 will be seen by all instances, as expected, but s1.classX = 6 will only be seen by s1: it will create a new field, thus hiding that of Sprite. From then on, changes to Sprite.classX will no longer be seen by s1 (but will be by all other instances that have not overridden Sprite.classX). To get around that, you could do this:
function Sprite:new()
o = {pos = {z=0}}
setmetatable(o,self)
self.__index = self
self.__newindex = self
return o
end
In Lua console you would see this if you played around with this:
> s1=Sprite:new()
> s2=Sprite:new()
> print(s1.classX, s2.classX)
0 0
> Sprite.classX=1
> print(s1.classX, s2.classX)
1 1
> s1.classX=3
> print(s1.classX, s2.classX)
3 3
Without that change, that last output will show "3 1" and changes to Sprite.classX would not be visible in s1.
Lua shares tables(keeps them as reference), and copy variables. Use metatables for methods, and keep fields copying them in your object table.
Sprite = {
instanceData = { x = 0, y = 0, pos = {z = 0} },
method = function(self) print("do smth with "..self) end
}
function Sprite:new()
local o = deepCopy(self.instanceData)
setmetatable(o,self)
self.__index = self
return o
end
deep copy implementation can be found wiki/CopyTable