Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deploy/packaging/debian/kernel.noarch
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
./usr/local/mdsplus/tdi/treeshr/TreeOpenEdit.fun
./usr/local/mdsplus/tdi/treeshr/TreeOpenNew.fun
./usr/local/mdsplus/tdi/treeshr/TreePut.fun
./usr/local/mdsplus/tdi/treeshr/TreePutDeserialized.fun
./usr/local/mdsplus/tdi/treeshr/TreePutRecord.fun
./usr/local/mdsplus/tdi/treeshr/TreeQuit.fun
./usr/local/mdsplus/tdi/treeshr/TreeSetCurrentShot.fun
Expand Down
1 change: 1 addition & 0 deletions deploy/packaging/redhat/kernel.noarch
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
./usr/local/mdsplus/tdi/treeshr/TreeOpenEdit.fun
./usr/local/mdsplus/tdi/treeshr/TreeOpenNew.fun
./usr/local/mdsplus/tdi/treeshr/TreePut.fun
./usr/local/mdsplus/tdi/treeshr/TreePutDeserialized.fun
./usr/local/mdsplus/tdi/treeshr/TreePutRecord.fun
./usr/local/mdsplus/tdi/treeshr/TreeQuit.fun
./usr/local/mdsplus/tdi/treeshr/TreeSetCurrentShot.fun
Expand Down
3 changes: 2 additions & 1 deletion include/mdsobjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -4504,9 +4504,10 @@ namespace MDSplus
closeAllTrees();
}
void setDefault(char *path);
Data *get(const char *expr, Data **args, int nArgs);
Data *get(const char *expr, Data **args, int nArgs, bool serialized = true);
Data *get(const char *expr) { return get(expr, 0, 0); }
void put(const char *path, char *expr, Data **args, int nArgs);
void put(const char *path, Data *data);
PutMany *putMany() { return new PutMany(this); }
GetMany *getMany() { return new GetMany(this); }
// Get TreeNode instance for (a subset of) TreeNode functionality in thin
Expand Down
94 changes: 80 additions & 14 deletions mdsobjects/cpp/mdsipobjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void Connection::closeAllTrees()
throw MdsException(status);
}

Data *Connection::get(const char *expr, Data **args, int nArgs)
Data *Connection::get(const char *expr, Data **args, int nArgs, bool serialized)
{
char clazz, dtype, nDims;
short length;
Expand All @@ -395,8 +395,22 @@ Data *Connection::get(const char *expr, Data **args, int nArgs)
}

lockLocal();
status = SendArg(sockId, 0, DTYPE_CSTRING_IP, nArgs + 1,
std::string(expr).size(), 0, 0, (char *)expr);

if(serialized)
{
std::string expExpr("serializeout(`(data(");
expExpr +=expr;
expExpr += ")))";
status = SendArg(sockId, 0, DTYPE_CSTRING_IP, nArgs + 1,
expExpr.size(), 0, 0, (char *)expExpr.c_str());
}
else
{
status = SendArg(sockId, 0, DTYPE_CSTRING_IP, nArgs + 1,
strlen((char *)expr), 0, 0, (char *)expr);
}
// std::string(expr).size(), 0, 0, (char *)expr);

if (STATUS_NOT_OK)
{
unlockLocal();
Expand Down Expand Up @@ -519,10 +533,23 @@ Data *Connection::get(const char *expr, Data **args, int nArgs)

if (mem)
FreeMessage(mem);
return resData;


if(!serialized || nDims == 0) //Error code returned
return resData;


Data *deserData = deserialize(resData); //Otherwise deserialze it
deleteData(resData);

return deserData;
}
void Connection::put(const char *inPath, Data *data)
{
put(inPath, (char *)"$", &data, 1);
}

void Connection::put(const char *inPath, char *expr, Data **args, int nArgs)
void Connection::put(const char *inPath, char *expr, Data **inArgs, int nArgs)
{
char clazz, dtype, nDims;
short length;
Expand All @@ -532,23 +559,50 @@ void Connection::put(const char *inPath, char *expr, Data **args, int nArgs)

int sockId = getSockId();

// Check whether arguments are compatible (Scalars or Arrays)
for (std::size_t argIdx = 0; argIdx < (std::size_t)nArgs; ++argIdx)

Data **args;

//Check id any passed argument is APD. Serialize arguments only in this case
bool serialized = false;

for(int i = 0; i < nArgs; i++)
{
args[argIdx]->getInfo(&clazz, &dtype, &length, &nDims, &dims, &ptr);
if (!ptr)
throw MdsException("Invalid argument passed to Connection::put(). Can "
"only be Scalar or Array");
if (nDims > 0)
delete[] dims;
if (inArgs[i]->clazz == CLASS_APD)
serialized = true;
}

//Serialize Arguments
if(serialized)
{
args = new Data*[nArgs];
for (std::size_t argIdx = 0; argIdx < (std::size_t)nArgs; ++argIdx)
{
int currSerSize;
char *currSer = inArgs[argIdx]->serialize(&currSerSize);
args[argIdx] = new Uint8Array((unsigned char *)currSer, currSerSize);
delete []currSer;
}
}
else
{
args = inArgs;
}

// Double backslashes!!
std::string path(inPath);
if (path.at(0) == '\\')
path.insert(path.begin(), '\\');

std::string putExpr("TreePut(\'");
std::string putExpr;
if(serialized)
{
putExpr += "TreePutDeserialized(\'";
}
else
{
putExpr += "TreePut(\'";
}

putExpr += path + "\',\'" + expr + "\'";
for (int varIdx = 0; varIdx < nArgs; ++varIdx)
putExpr += ",$";
Expand Down Expand Up @@ -588,6 +642,18 @@ void Connection::put(const char *inPath, char *expr, Data **args, int nArgs)
status = *(reinterpret_cast<int *>(ptr));
if (mem)
FreeMessage(mem);

//Delete serialize args
if (serialized)
{
for (std::size_t argIdx = 0; argIdx < (std::size_t)nArgs; ++argIdx)
{
deleteData(args[argIdx]);
}
delete [] args;
}


if (STATUS_NOT_OK)
throw MdsException(status);
}
Expand Down
25 changes: 25 additions & 0 deletions tdi/treeshr/TreePutDeserialized.fun
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
public fun TreePutDeserialized(in _nodename, in _expression, optional in _a, optional in _b,
optional in _c, optional in _d, optional in _e, optional in _f, optional in _g, optional in _h,
optional in _i, optional in _j, optional in _k, optional in _l, optional in _m, optional in _n,
optional in _o, optional in _p, optional in _q, optional in _r, optional in _s, optional in _t,
optional in _u, optional in _v, optional in _w, optional in _x, optional in _y, optional in _z)
{
_list = List(*,_expression);
for (_narg=1;_narg <= 26; _narg++)
{
_argnam = "_"//char(96+_narg); /* char(97 is 'a') */
_argcheck = "present("//_argnam//")";
if (execute(_argcheck))
_list = List(_list,SerializeIn(execute(_argnam)));
else
break;
}
_treeput_ans = *;
write(*, _list);
_status = TdiShr->TdiIntrinsic(val(BUILTIN_OPCODE("COMPILE")),val(_narg),ref(_list),xd(_treeput_ans));

write(*, 'STATUS ', _status);
if (_status & 1)
_status = TreeShr->TreePutRecord(val(getnci(_nodename,"nid_number")),xd(_treeput_ans),val(0));
return(_status);
}
25 changes: 14 additions & 11 deletions tditest/testing/test-tab.ans
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@ TR
%TDI Error in EXECUTE("TR")

tree
tree_from_tag( treefindnodewild( treeput(
treeabspath( treefindtagend( treeputrecord(
treeaddnode( treefindtagwild( treequit(
treeaddtag( treeflushoff( treesetcurrentshot(
treeclose( treeflushreset( treesetdbiitm(
treecreatepulsefile( treegetcurrentshot( treesetdefault(
treedeletepulsefile( treegetrecord( treesetnciitm(
treedirname( treegetsource( treesetsource(
treefilename( treeopen( treeturnoff(
treefindnodetags( treeopenedit( treeturnon(
treefindnodetagsjeff( treeopennew( treewrite(
tree_from_tag( treefindtagend( treeputrecord(
treeabspath( treefindtagwild( treequit(
treeaddnode( treeflushoff( treesetcurrentshot(
treeaddtag( treeflushreset( treesetdbiitm(
treeclose( treegetcurrentshot( treesetdefault(
treecreatepulsefile( treegetrecord( treesetnciitm(
treedeletepulsefile( treegetsource( treesetsource(
treedirname( treeopen( treeturnoff(
treefilename( treeopenedit( treeturnon(
treefindnodetags( treeopennew( treewrite(
treefindnodetagsjeff( treeput(
treefindnodewild( treeputdeserialized(
tree
%TREE-W-NOT_OPEN, Tree not currently open
%TDI Error compiling region marked by ^
tree
^
%TDI Error in EXECUTE("tree")