DASYLab

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting 3:1 input to output channel ratio in DASYLab 2016 scripting module

Solved!
Go to solution

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

0 Kudos
Message 1 of 7
(4,323 Views)
Solution
Accepted by topic author AW22

See if this is a starting point. 

 

Note changes in Create, DlgInit and DlgOK

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
Message 2 of 7
(4,295 Views)

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. 

 

 

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
Message 3 of 7
(4,289 Views)

Great, thanks for the help and quick response!

0 Kudos
Message 4 of 7
(4,264 Views)

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

0 Kudos
Message 5 of 7
(4,261 Views)

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. 

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
0 Kudos
Message 6 of 7
(4,258 Views)

@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).

M.Sc. Holger Wons | measX GmbH&Co. KG, Mönchengladbach, Germany | DASYLab, DIAdem, LabView --- Support, Projects, Training | Platinum NI Alliance Partner | www.measx.com
Message 7 of 7
(4,175 Views)