07-26-2019 10:15 AM
Hi all,
I'm struggling to correctly establish a 3:1 input to output ratio in the scripting module. I first set the predefined settings to user defined with a channel assignment of n:1 and made the following adjustments to the basic python script:
def DlgInit (self, dlg):
self.DlgNumChannels = self.NumInChannel/3
self.DlgMaxChannels = Ly.MAX_CHANNELS/3
def DlgOk (self, dlg):
self.SetConnectors(self.DlgNumChannels*3, self.DlgNumChannels)
This provides the correct correlation between inputs and outputs and operates correctly but only if I have one input and output pair (3 inputs and 1 output). As soon as I try to add another channel to have 6 inputs and 2 outputs, I get "The internal data structure of this module is corrupt. Abort" message.
Next, I tried to set the predefined settings as no channel assignments with the same code as before but DASYLab crashes when I load the code into the script module and try to move the module in the worksheet.
Any thoughts on what I'm missing?
Thanks,
AW
DASYLab 2016 full
Solved! Go to Solution.
07-26-2019 11:00 AM
See if this is a starting point.
Note changes in Create, DlgInit and DlgOK
07-26-2019 11:05 AM
Check out the set of examples that MeasX has on their DASYLab web site.
https://www.measx.com/en/products/software/dasylab/examples
The example_scriptmodule__channelrelation_m_n.dsb is a much better example than mine - but you have to edit externally to DASYLab and then import it.
07-26-2019 12:52 PM
Great, thanks for the help and quick response!
07-26-2019 12:58 PM
These are helpful as well. One thing I noted in the example_scriptmodule_channelrelation_m_n.py was that there is a portion:
def Load(self):
self.ChannelRelation = Ly.CR_ALL_ALL
that is not in your solution and does not seem like it is needed. Is there a particular reason why it would be good to have this code here?
Thanks,
AW
07-26-2019 01:48 PM
I put that in the Create tab...
The people who created the MeasX examples know more about the guts of the Script module and how it works with DASYLab.
If you look at the help for the Ly channel constants, there is some description. The relationship between channels is important and DASYLab specifically calls out 1:1, 2:1, 1:2, 1:many, many:1, but not 3:1. ALL:ALL solves that problem generally.
07-31-2019 02:50 AM - edited 07-31-2019 02:53 AM
@AW22 wrote:
These are helpful as well. One thing I noted in the example_scriptmodule_channelrelation_m_n.py was that there is a portion:
def Load(self):
self.ChannelRelation = Ly.CR_ALL_ALL
that is not in your solution and does not seem like it is needed. Is there a particular reason why it would be good to have this code here?
Actually, you do not need to set the Channel Relation in Load():
When you create a Script Module (Drag/Drop from Module Browser), DASYLab configures the module's properties corresponding to the settings you made during the lifetime of the little assistant. When the assistant closes, the module IS configured with a Channel Relation, without need of setting one manually somewhere in the script.
But if you want tho change the Channel Relation afterwards (module exists in worksheet), you need to set it in Create().
When the script's Create() is called (e.g. loading script into the module), the script reconfigures the "underlying" part of the script module that was programmed in C/C++ language.
When you save the worksheet, the script module's settings are (of course) saved. When you load the worksheet, the settings are restored, and then the Load() method from the script kicks in. The Channel Relation was already restored from the worksheet file. No need to set it again (it's not harmful as long as it is the same that was set in Create(), or selected in the little assistant).