Code:
using System;
using System.Collections.Generic;
using FB_USB_2011;
using FuseGL.GUI.Text;
using FuseGL.Logic;
using System.Windows.Forms;
namespace FuseGL_doOnAnalogue
{
class ShowMessageBoxWithValue
{
Dictionary<FB_Monitor.AnalogueInputPort, System.Timers.Timer> allAnaloguePortsToDisplay = new Dictionary<FB_Monitor.AnalogueInputPort, System.Timers.Timer>();
public ShowMessageBoxWithValue()
{
Console.WriteLine("This gets called the first time only...");
}
public object RegisterAnalogueInput(FB_Monitor.AnalogueInputPort _port, int how_often_in_milliseconds, object[] extraInputParams)
{
if (allAnaloguePortsToDisplay.ContainsKey(_port)) { return true; }
System.Timers.Timer _timer = new System.Timers.Timer();
_timer.AutoReset = true;
_timer.Interval = how_often_in_milliseconds;
_timer.Elapsed += delegate(object sender, System.Timers.ElapsedEventArgs e)
{
string s = "here for port " + _port.Port.ToString() + ": " + _port.Value.ToString("0.000") + "v";
Console.WriteLine(s);
FuseGL.FuseGL_Debugger.Trace.Add(s);
System.Windows.Forms.MessageBox.Show(s);
};
_timer.Start();
return true;
}
}
}
Code:
<?xml version="1.0" encoding="utf-8" ?>
<FuseGL_User_Settings>
<FuseGL_GUI_Settings>
<setting type="size" name="gui_size" width="90%" height="600" />
<setting type="int" gui_border_thickness="1" />
<setting type="colour" gui_border_colour="85,85,85" />
</FuseGL_GUI_Settings>
<Startup_Events>
<events>
<startup action="FuseGL.ExecuteCode" inputArgs="Logic/doOnAnalogue.cs;FuseGL_doOnAnalogue.ShowMessageBoxWithValue;RegisterAnalogueInput;{FB.AnalogueInput(0.1)};{(int)10000};" />
<startup action="FB.TurnOnDigitalOutput" inputArgs="Port:0.10" />
</events>
</Startup_Events>
<Persistant_Variables>
<variable type="bool" first_value="true" name="persistant_boolean" />
<variable type="int" first_value="0" name="persistant_incrementer" />
</Persistant_Variables>
<User_Object type="FuseGL_Object">
<setting type="string" name="Digital Output Test Button ON" />
<image location="internal" path="FuseGL.Configurator.Configurator_IMG_Resources.BaseButton" />
<image_hover location="internal" path="FuseGL.Configurator.Configurator_IMG_Resources.BaseButtonHover" />
<image_click location="internal" path="FuseGL.Configurator.Configurator_IMG_Resources.BaseButtonHover" />
<text text="Turn On 0.10" />
<!-- Make all the customizations like font size, and the actual font optional -->
<setting type="bool" mouse_cursor_to_hand_on_hover="true" />
<size width="200" height="33" />
<location x="100" y="100" z="0" alignment="center" />
<events>
<onMouseDown action="FB.TurnOnDigitalOutput" inputArgs="Port:0.10" />
<onMouseDown action="FuseGL.ExecuteCode" inputArgs="ChangeTextOnDigitalOutputChange.cs;FuseGL_TextManipulation.InternalFlyCompile_ChangeTextOnDigitalOutputChange;ChangeButtonTextOnDigitalOutputPersistant;{FB.DigitalOutput(0.10)};{this.text};" outputTo="this.text.text" />
</events>
</User_Object>
<User_Object type="FuseGL_Object">
<setting type="string" name="Digital Output Test Button OFF" />
<image location="internal" path="FuseGL.Configurator.Configurator_IMG_Resources.BaseButton" />
<image_hover location="internal" path="FuseGL.Configurator.Configurator_IMG_Resources.BaseButtonHover" />
<image_click location="internal" path="FuseGL.Configurator.Configurator_IMG_Resources.BaseButtonHover" />
<text text="Turn On 0.10" />
<setting type="bool" mouse_cursor_to_hand_on_hover="true" />
<size width="200" height="33" />
<location x="100" y="150" z="0" alignment="center" />
<events>
<startup action="FuseGL.ExecuteCode" inputArgs="ChangeTextOnDigitalOutputChange.cs;FuseGL_TextManipulation.InternalFlyCompile_ChangeTextOnDigitalOutputChange;ChangeButtonTextOnDigitalOutputPersistant;{FB.DigitalOutput(0.10)};{this.text};" outputTo="this.text.text" />
<onMouseDown action="FB.TurnOffDigitalOutput" inputArgs="Port:0.10" />
</events>
</User_Object>
<User_Object type="FuseGL_Object">
<setting type="string" name="Digital Output Test Button Toggle" />
<image location="internal" path="FuseGL.Configurator.Configurator_IMG_Resources.BaseButton" />
<image_hover location="internal" path="FuseGL.Configurator.Configurator_IMG_Resources.BaseButtonHover" />
<image_click location="internal" path="FuseGL.Configurator.Configurator_IMG_Resources.BaseButtonHover" />
<text text="Unknown State" />
<setting type="bool" mouse_cursor_to_hand_on_hover="true" />
<size width="200" height="33" />
<location x="100" y="200" z="0" alignment="center" />
<events>
<startup action="FuseGL.ExecuteCode" inputArgs="ChangeTextOnDigitalOutputChange.cs;FuseGL_TextManipulation.InternalFlyCompile_ChangeTextOnDigitalOutputChange;ChangeButtonTextOnDigitalOutputPersistant;{FB.DigitalOutput(0.10)};{this.text};FLY Digital Output ON; FLY Digital Output OFF;" outputTo="this.text.text" />
<onMouseDown action="FB.ToggleDigitalOutput" inputArgs="Port:0.10" />
</events>
</User_Object>
<User_Object type="FuseGL_Object">
<setting type="string" name="Analogue Input 0.0 Display Label" />
<image location="internal" path="FuseGL.Configurator.Configurator_IMG_Resources.BaseButton" />
<text text="Unknown State" />
<setting type="bool" mouse_cursor_to_hand_on_hover="true" />
<size width="200" height="33" />
<location x="500" y="500" z="0" alignment="center" />
<events>
<startup action="FuseGL.ExecuteCode" inputArgs="UpdateLabelText.cs;FuseGL_TextManipulation.InternalFlyCompile_UpdateLabelText;ChangeButtonTextOnAnalogueInputPersistant;{FB.AnalogueInput(0.1)};{this.text};0.000;" outputTo="this.text.text" />
</events>
</User_Object>
<User_Object type="FuseGL_Object">
<setting type="string" name="GL - LBL - Show Thing:Variable[persistant_incrementer]" />
<image location="internal" path="FuseGL.Configurator.Configurator_IMG_Resources.UserButtonBackground" />
<text text="{$[*].persistant_incrementer}" />
<size width="180" height="30" />
<location x="105" y="300" alignment="left" z="0.0" />
<setting type="int" border_size="1" />
<setting type="bool" mouse_cursor_to_hand_on_hover="false" />
<events>
<startup action="FuseGL.ExecuteCode" inputArgs="UpdateLabelText.cs;FuseGL_TextManipulation.InternalFlyCompile_UpdateLabelText;ChangeButtonTextOnVariablePersistant;{$[*].persistant_incrementer};{this.text};" outputTo="this.text.text" />
</events>
</User_Object>
<User_Object type="FuseGL_Object">
<setting type="string" name="GL - LBL - Show Thing:Variable[persistant_incrementer]" />
<image location="internal" path="FuseGL.Configurator.Configurator_IMG_Resources.UserButtonBackground" />
<text text="{$[*].persistant_incrementer.Value}" />
<size width="180" height="30" />
<location x="90" y="345" alignment="left" z="0.0" />
<setting type="int" border_size="1" />
<setting type="bool" mouse_cursor_to_hand_on_hover="false" />
<events>
<startup action="FuseGL.ExecuteCode" inputArgs="UpdateLabelText.cs;FuseGL_TextManipulation.InternalFlyCompile_UpdateLabelText;ChangeButtonTextOnVariablePersistant;{$[*].persistant_incrementer};{this.text};" outputTo="this.text.text" />
</events>
</User_Object>
<User_Object type="FuseGL_Object">
<setting type="string" name="GL - LBL - Show Thing:Variable[persistant_incrementer]" />
<image location="internal" path="FuseGL.Configurator.Configurator_IMG_Resources.UserButtonBackground" />
<text text="{$[*].persistant_incrementer.Value}" />
<size width="180" height="30" />
<location x="90" y="390" alignment="left" z="0.0" />
<setting type="int" border_size="1" />
<setting type="bool" mouse_cursor_to_hand_on_hover="false" />
<events>
<onMouseDown action="FuseGL.ExecuteCode" inputArgs="CustomGooCode.cs;CustomGoo_Namespace.YourCustomGooParentClassName;DigitalOutputPort___IncreaseValue;{FB.DigitalOutput(0.10)};"/>
</events>
</User_Object>
</FuseGL_User_Settings>
Bookmarks