NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving ResultList as binary file

Just want to add that if you want to fix your property object file version so that you could still set the parameter back to your unserialized data here's an idea that should work. Rather than deleting the original, you can remove it from it's parent and replace it with a place holder object by creating a placeholder object using Engine.NewPropertyObject and using SetPropertyObject to replace the original with the place holder. Then at the end, once you've unserialized your object you can set Parameters.MainSequenceResult to your unserialized version using SetPropertyObject again to replace the place holder object with your unserialized one.

-Doug
0 Kudos
Message 11 of 14
(1,603 Views)
Hi Doug,
 
Thanks for great anwsers(5!). At the monemt i would save my stream to disk. Just to see which serializing technic (Engine or PropertyObjectFile) is the best. As you saw all was done in Active-X calls. I did it to keep it simple for discussing. But now like to it in a C++ dll.
 
Now i have a problem which seems not  solveable for me (i spent some hours).  The TS/C++ API  SerializeObjects (SAFEARRAY * objects,long options ) needs an SAFEARRAY pointer .
How i will get this from my PropertyObject created with:
PropertyObjectPtr pObjArray = pEngine->NewPropertyObject(PropValType_Reference,VARIANT_TRUE,"",0);
 
In TSVCUTIL.H there was no help because they are using <vector>
 
Do you know if there is a solution.
or should i do my code in C#
 
greetings
 
juergen
  
--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 12 of 14
(1,584 Views)
Using SAFEARRAYs in C++ isn't that easy, but our classes in tsvcutil.h do make it a little easier.

The following should work:

TSUTIL::SafeArray<> objectsToSerialize;
std::vector<TS::PropertyObjectPtr> objectsToSerializeVector;

objectsToSerializeVector.push_back(yourResultObject);
objectsToSerialize.SetFromVector(objectsToSerializeVector);

engine->SerializeObjects(...objectsToSerialize.Get()...);

Then on the unserialize side you can do something like:

TSUTIL::SafeArray<> safeArray(engine->UnserializeObjectsAndTypes(...));  // safeArray will take ownership of the SAFEARRAY object and destroy it automatically in its destructor when it goes out of scope
std::vector<TS::PropertyObjectPtr> unserializedObjects;

safeArray.GetVector(unserializedObjects);

// You might want to check unserializedObjects.size() before accessing it to make sure that there are the number of objects you are expecting.
ASSERT(unserializedObjects.size() == 1); // just an example of checking the size. you might want to do it explicitly with an 'if' statement rather than in an assert.

TS::PropertyObjectPtr myResultObject = unserializedObjects[0];

Edited message: *sigh*, the forum turned some of the code into smiley faces the smiley faces are really a ':' character followed by a 'P' character. Sorry not sure how to tell the forum to leave that text alone.

-Doug


Message Edited by dug9000 on 02-21-2008 10:43 AM
Message 13 of 14
(1,573 Views)
Hi Doug,Smiley Tongue
 
Where is the 6!, Thank you for posting the code
 
I would never figure out this stuff.
objectsToSerializeVector.push_back(yourResultObject);
objectsToSerialize.SetFromVector(objectsToSerializeVector);
 
Now i have done my Performance Test:
 
The PropertyObjectFile won the battle against Engine.Serialization
 
23kB Filesize in 160ms Executiontime  beats 30kB in 188ms
 
Thanks for all.
 
Have nice weekend
 
Juergen
 
 
--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 14 of 14
(1,559 Views)