Support for science experiments that use part module DMModuleScienceAnimateGeneric
djungelorm opened this issue ยท 3 comments
The [x] Science mod uses reflection to interact with DMagic, source code is here:
https://github.com/thewebbooth/KSP-X-Science/blob/master/X-Science/DMagic.cs
We should do something similar.
DMModuleScienceAnimateGeneric
actually implements ModuleScienceExperiment
and IScienceDataContainer
so works just like a stock experiment.
However, we need to be careful to cast the part module instance to ModuleScienceExperiment
or IScienceDataContainer
depending on the method being called, e.g. GetData()
needs to be called from a reference of type IScienceDataContainer
otherwise always returns an empty array.
This is likely due to method dispatch getting confused as we are not compiling kRPC against a DLL with DMModuleScienceAnimateGeneric
.
Also : For RO: Reset() Doesn't work without dump()
RuntimeError: Experiment already contains data
So I need to Reset and Dump.
Test code for this.
import krpc
import time
conn = krpc.connect(name='Science Test')
vessel = conn.space_center.active_vessel
for experiment in vessel.parts.experiments:
print(experiment.part.name)
if experiment.part.name == 'RO-HeliumMagnet':
scs = experiment.science_subject
experiment.reset()
experiment.dump() #Reset() Doesn't work without dump() RuntimeError: Experiment already contains data
experiment.run()
while not scs.is_complete:
transmitAmount = sum([x.transmit_value for x in experiment.data])
print("transmitAmount= ", transmitAmount, "scs.science=", scs.science, scs.science_cap, scs.data_scale,
scs.subject_value, scs.scientific_value)
print("Waiting till end experiment scs.is_complete= ", scs.is_complete)
time.sleep(1)