Jump to content

xcontrol switching between control/indicator


Recommended Posts

I am working on an XControl whose Facade (front panel) is composed of standard LV numeric controls.

I want to handle the "Direction Change" event simply by changing the numeric controls to indicators (or vice versa). Is it possible to get references to controls that are "hosted" by the XControl Facade VI? If so, I could simply set the Indicator property on each of them and be done.

I tried creating references to the controls on the Facade front panel, but that didn't work. Makes sense because each instance of the XControl has its own instances of the numeric controls. I can use the Container State:Refnum item to get a reference to the XControl instance, but I don't know how to get references to the numeric controls from that.

If that approach is a dead end, what other technique is available to accomplish the same thing?

Thanks,

Mark Zvilius

Link to comment

I think it's a dead-end.

Changing the appearence of your Facade controls isn't allowed programmatically at runtime (XControl is running when loaded on a front panel) so you'd get an error. However, you can use the "Direction Change" event in your XControl's Facade VI to show/hide controls and indicators. See this screencast I prepared.

<object id="scPlayer" class="embeddedObject" width="1012" height="684" type="application/x-shockwave-flash" data="http://content.screencast.com/users/normandinf/folders/Jing/media/c3902d34-b2fd-40e3-a318-49a665849992/jingh264player.swf" >

<param name="movie" value="http://content.screencast.com/users/normandinf/folders/Jing/media/c3902d34-b2fd-40e3-a318-49a665849992/jingh264player.swf" />

<param name="quality" value="high" />

<param name="bgcolor" value="#FFFFFF" />

<param name="flashVars" value="thumb=http://content.screencast.com/users/normandinf/folders/Jing/media/c3902d34-b2fd-40e3-a318-49a665849992/FirstFrame.jpg&containerwidth=1012&containerheight=684&content=http://content.screencast.com/users/normandinf/folders/Jing/media/c3902d34-b2fd-40e3-a318-49a665849992/2010-07-14_1936.mp4&blurover=false" />

<param name="allowFullScreen" value="true" />

<param name="scale" value="showall" />

<param name="allowScriptAccess" value="always" />

<param name="base" value="http://content.screencast.com/users/normandinf/folders/Jing/media/c3902d34-b2fd-40e3-a318-49a665849992/" />

<video width="1012" height="684" controls="controls"><br />

<source src="http://content.screencast.com/users/normandinf/folders/Jing/media/c3902d34-b2fd-40e3-a318-49a665849992/2010-07-14_1936.mp4" type="video/mp4;" /><br />

<b>Your browser cannot play this video. <a href="http://www.screencast.com/handlers/redirect.ashx?target=viewingembededhelp">Learn how to fix this</a>.</b>

</video>

</object>

Link to comment

I want to handle the "Direction Change" event simply by changing the numeric controls to indicators (or vice versa).

If that approach is a dead end, what other technique is available to accomplish the same thing?

Thanks,

Mark Zvilius

It might help to not think in terms of indicators and controls.

I know this idea has been drilled into our heads since we first started working in LabVIEW but X-controls are a different animal.

Instead try and think of an X-control items as having 4 states

  1. Development time Input mode
  2. Development time Output mode
  3. Runtime Input mode
  4. Runtime Output mode

The Facade defines how the x-control with look and act for each state.

If we use a numeric control as an example

  1. Increment arrows shown, White background, Data entry allowed
  2. No increment arrows, Gray background, Data entry allowed
  3. Increment arrows shown, White background, Data entry allowed
  4. No increment arrows, Gray background, Data entry not allowed

So instead of trying to force the numeric controls by hiding and showing them I would instead change a numeric control's properties depending on its current state.

  1. Show arrows, Color background white, Enable
  2. Hide arrows, color background gray, Enable
  3. Show arrows, Color background white, Enable
  4. Hide arrows, color background gray, Disable

I have found this way of approaching X-control design much less aggravating.

Mark

  • Like 1
Link to comment

So instead of trying to force the numeric controls by hiding and showing them I would instead change a numeric control's properties depending on its current state.

I am under the assumption that both methods presented thus far are valid (depending on what you are trying to achieve/ how you like to program).

Anyone care to list their thoughts on known pros and cons of each method from experience? beer_mug.gif

Link to comment

I am under the assumption that both methods presented thus far are valid (depending on what you are trying to achieve/ how you like to program).

Anyone care to list their thoughts on known pros and cons of each method from experience? beer_mug.gif

I would have to say that I like Mark's idea better in the long run because you don't have to deal with managing the values of indicator and control when you switch. You surely don't want to have a control with value 0.000 and then switch to indicator and see 3.14159.

Using only a control and playing with the disabled property and background color seems a much better avenue for XControl indeed. In fact, my tutorial was more about showing the "Direction Change" event and that's where you'd go anyway to implement this architecture instead.

Link to comment

I am under the assumption that both methods presented thus far are valid (depending on what you are trying to achieve/ how you like to program).

Anyone care to list their thoughts on known pros and cons of each method from experience? beer_mug.gif

How about a third?

Why not a tab control? One tab for indicator. One tab for control.

Link to comment

I would have to say that I like Mark's idea better in the long run

I agree also.

I've only wandered into XControl territory a few times but I didn't like the way indicators and controls were duplicated in order to allow for both cases. I like the idea of using a single control and "manually" updating its appearance and behaviour to match an indicator. Seems more logical to me.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.