Beispiel #1
0
        void AdjustOutputsPanel()
        {
            int maxcount = 0;

            foreach (TBasePin pin in FPluginHost.Outputs)
            {
                if (pin.Visibility != TPinVisibility.False)
                {
                    maxcount = Math.Max(maxcount, pin.SliceCount * pin.Dimension);
                }
            }

            OutputsPanel.Height = Math.Min(200, (maxcount + 1) * FSliceHeight + 2);
            OutputsPanel.Invalidate();
        }
 /// <summary>
 /// Builder
 /// </summary>
 /// <param name="simulator"></param>
 public SimulatorPanel(ISimulator simulator)
 {
     InitializeComponent();
     //The simulator is saved
     this.simulator = simulator;
     //A Simulator status Change event is logged
     this.simulator.StateChanged += new EventHandler(Simulator_StateChanged);
     //MOway module panels are added
     this.outputPanel = new OutputsPanel(this.simulator.MowayModel);
     this.LoadSubPanel(this.outputPanel);
     this.sensorsPanel = new SensorsPanel(this.simulator.MowayModel);
     this.LoadSubPanel(this.sensorsPanel);
     this.enviromentPanel = new EnviromentPanel(this.simulator.MowayModel);
     this.LoadSubPanel(this.enviromentPanel);
     this.accelerometerPanel = new AccelerometerPanel(this.simulator.MowayModel);
     this.LoadSubPanel(this.accelerometerPanel);
     this.communicationPanel = new CommunicationPanel(this.simulator.MowayModel);
     this.LoadSubPanel(this.communicationPanel);
     this.registersPanel = new RegistersPanel(this.simulator.MowayModel);
     this.LoadSubPanel(this.registersPanel);
     this.cbMowayModule.SelectedIndex = 0;
 }
Beispiel #3
0
        private void PinCountChangedCB()
        {
            //slicecounts
            FSliceCountControls.Clear();
            SliceCountsPanel.Controls.Clear();
            NumericUpDown ud;

            int idx = 0;

            foreach (TBasePin pin in FPluginHost.Inputs)
            {
                if (pin.Visibility != TPinVisibility.False)
                {
                    ud             = new NumericUpDown();
                    ud.Width       = FPinWidth;
                    ud.Left        = ud.Width * idx;
                    ud.Minimum     = 0;
                    ud.Maximum     = int.MaxValue;
                    ud.Value       = Math.Max(0, pin.SliceCount);
                    ud.BorderStyle = BorderStyle.None;
                    SliceCountsPanel.Controls.Add(ud);
                    FSliceCountControls.Add(ud);
                    idx++;
                }
            }

            InputsPanel.UpdateVisiblePinList();
            OutputsPanel.UpdateVisiblePinList();

            //adjust inputpins areas height
            AdjustInputsPanel();

            //adjust outputpins areas height
            AdjustOutputsPanel();

            //adjust plugin areas height
            AdjustPluginPanel();
        }
Beispiel #4
0
        void AfterEvaluateCB()
        {
            if (EnableOSCCheckBox.Checked)
            {
                //double time;
                //GetCurrentTime(out time);
                OSCBundle bundle = new OSCBundle();

                //send outputs as OSC
                for (int i = 0; i < FPluginHost.Outputs.Count; i++)
                {
                    string pinname = FPluginHost.Outputs[i].Name;
                    // pinname = pinname.Replace(" ", "_");
                    OSCMessage message = new OSCMessage(FOSCAddress + "/" + pinname);

                    if (FPluginHost.Outputs[i] is TValuePin)
                    {
                        double val;
                        for (int j = 0; j < (FPluginHost.Outputs[i] as TValuePin).SliceCount; j++)
                        {
                            (FPluginHost.Outputs[i] as TValuePin).GetValue(j, out val);
                            message.Append((float)val);
                        }
                    }
                    else if (FPluginHost.Outputs[i] is TStringPin)
                    {
                        string str;
                        for (int j = 0; j < (FPluginHost.Outputs[i] as TStringPin).SliceCount; j++)
                        {
                            (FPluginHost.Outputs[i] as TStringPin).GetString(j, out str);
                            message.Append(str);
                        }
                    }
                    else if (FPluginHost.Outputs[i] is TColorPin)
                    {
                        RGBAColor col;
                        for (int j = 0; j < (FPluginHost.Outputs[i] as TColorPin).SliceCount; j++)
                        {
                            (FPluginHost.Outputs[i] as TColorPin).GetColor(j, out col);
                            message.Append(col.ToString());
                        }
                    }

                    bundle.Append(message);
                }

                try
                {
                    if (FOSCTransmitter != null)
                    {
                        FOSCTransmitter.Send(bundle);
                    }
                }
                catch (Exception ex)
                {
                    DebugLog.Items.Add("UDP: " + ex.Message);
                }
            }

            bool redraw = false;

            for (int i = 0; i < FPluginHost.Inputs.Count; i++)
            {
                redraw       |= (FPluginHost.Inputs[i] as TBasePin).PinIsChanged;
                FPinsChanged |= (FPluginHost.Inputs[i] as TBasePin).SliceCountIsChanged;
                (FPluginHost.Inputs[i] as TBasePin).Invalidate();
            }
            if (redraw)
            {
                InputsPanel.Invalidate();
            }

            redraw = false;
            for (int i = 0; i < FPluginHost.Outputs.Count; i++)
            {
                redraw       |= (FPluginHost.Outputs[i] as TBasePin).PinIsChanged;
                FPinsChanged |= (FPluginHost.Outputs[i] as TBasePin).SliceCountIsChanged;
                (FPluginHost.Outputs[i] as TBasePin).Invalidate();
            }
            if (redraw)
            {
                OutputsPanel.Invalidate();
            }
        }