Example #1
0
def power_setting_div(cur_inputs, cur_tab):
    if cur_inputs is None or len(cur_inputs) == 0:
        cur_inputs = init_input
    return html.Div(
        className='row power-settings-tab',
        children=[
            html.Div(className='Title',
                     children=html.H3("Power",
                                      id='power-title',
                                      style={'color': theme['primary']})),
            html.Div(
                # power-controllers
                [
                    html.Div([
                        daq.PowerButton(
                            id='function-generator',
                            on=cur_inputs[cur_tab]['function_generator'],
                            label="Function Generator",
                            labelPosition='bottom',
                            color=theme['primary']),
                    ],
                             className='six columns',
                             style={'margin-bottom': '15px'}),
                    html.Div([
                        daq.PowerButton(id='oscilloscope',
                                        on=cur_inputs[cur_tab]['oscilloscope'],
                                        label="Oscilloscope",
                                        labelPosition='bottom',
                                        color=theme['primary'])
                    ],
                             className='six columns',
                             style={'margin-bottom': '15px'}),
                ],
                style={'margin': '15px 0'})
        ])
Example #2
0
def power_setting_div(cur_inputs, cur_tab):
    if cur_inputs is None or len(cur_inputs) == 0:
        cur_inputs = init_input
    return html.Div(
        className="row power-settings-tab",
        children=[
            # Title
            html.Div(
                className="Title",
                children=html.H3(
                    "Power", id="power-title", style={"color": theme["primary"]}
                ),
            ),
            # Power Controllers
            html.Div(
                className="power-controllers",
                children=[
                    html.Div(
                        [
                            daq.PowerButton(
                                id="function-generator",
                                on=cur_inputs[cur_tab]["function_generator"],
                                label="Function Generator",
                                labelPosition="bottom",
                                color=theme["primary"],
                            )
                        ],
                        className="six columns",
                    ),
                    html.Div(
                        [
                            daq.PowerButton(
                                id="oscilloscope",
                                on=cur_inputs[cur_tab]["oscilloscope"],
                                label="Oscilloscope",
                                labelPosition="bottom",
                                color=theme["primary"],
                            )
                        ],
                        className="six columns",
                    ),
                ],
            ),
        ],
    )
Example #3
0
 def trace_group():
     return dbc.FormGroup([
         daq.PowerButton(id='trace-button',
                         on=False,
                         color='#00FF00',
                         style=element_style()),
         html.Div(id='trace-error-notification',
                  children=None,
                  style=element_style())
     ])
Example #4
0
def createLowerBanner():
    return html.Div(
        id="dssLowerBanner",
        className="dssLowerBanner",
        children=[
            html.Div(
                id="assignment",
                className="assignment",
                children="Deep Learning for predicting bacterial spots on leaves"
            ),
            html.Div(
                id="group",
                className='group',
                children=[
                    html.Div(
                        id="groupNumber",
                        className="GroupNumber",
                        children='Group 2'
                    ),
                    html.Div(
                        id="groupMembers",
                        className="groupMembers",
                        children=[
                            'Marije Gemmink (2628341)', html.Br(),
                            'Joep van Genderingen (2627749)', html.Br(),
                            'Krzysztof Linke (2674002)', html.Br(),
                            'Daan Schönberger (2566280)', html.Br(),
                            'Tim Vorstenbosch (2588989)'
                        ]
                    ),
                ]
            ),
            html.Div(
                id="powerButtonDiv",
                className="powerButtonDiv",
                children=
                daq.PowerButton(
                    id='powerButton',
                    className='powerButton',
                    on=True,
                ),
            ),
        ],
    )
def create_boxplot_options():
    return [
        dbc.Row([
            dbc.Col([
                daq.PowerButton(
                    id='boxplot-on', on=False, color=power_button_on_color),
            ],
                    className='mb-3',
                    md=3),
            dbc.Col([
                dbc.FormGroup([
                    dbc.Checklist(options=get_boxplot_options(True),
                                  value=[],
                                  id='boxplot-options',
                                  inline=False,
                                  switch=True)
                ])
            ],
                    md=8)
        ])
    ]
Example #6
0
    def get_power_box(self):
        # power box
        pwr_box = html.Div(
            id='power-box',
            children=[
                # power button
                html.Div(
                    id='power-button-container',
                    title='Turn the power on to begin viewing the data and controlling \
                                                    the spectrometer.',
                    children=[
                        daq.PowerButton(
                            id='power-button',
                            size=70,
                            color=colors['accent'],
                            on=True
                        ),
                    ],
                ),

            ]
        )
        return pwr_box
Example #7
0
import dash_html_components as html
import dash_table
import dash_bootstrap_components as dbc
import dash_daq as daq
from dash.dependencies import Input, Output
from app import app, lab
import components as comp
layout = [
    comp.header('Home'),
    daq.PowerButton(id='my-power-button',
                    on=False,
                    size=150,
                    label='Connect Instruments'),
    html.Div(id='power-button-output', className='d-none')
]


@app.callback(Output('power-button-output', 'children'),
              [Input('my-power-button', 'on')],
              prevent_initial_call=True)
def update_output(on):
    if on:
        lab.load_instruments()
        return '/instruments'
    else:
        return lab.shutdown()
Example #8
0
def bodyLayoutGen():
    bodyLayout = html.Div(
        id="body",
        className=textClassName[theme],
        children=[
            html.Div(
                id="tempSection",
                style={"backgroundColor": cardColor[theme]},
                children=[
                    html.H5("System Temprature"),
                    dcc.Interval(
                        id='tempInterval',
                        interval=2 * 1000,  # in milliseconds
                        n_intervals=0),
                    html.Div(id="tempGraphSection",
                             className="seven columns",
                             style={"backgroundColor": backgroundColor[theme]},
                             children=[
                                 html.Div(id="tempLedDispSection",
                                          style={
                                              "backgroundColor":
                                              cardColor[theme],
                                          },
                                          children=[
                                              daq.LEDDisplay(
                                                  id="cpuTempLiveLed",
                                                  label="Cpu Temp",
                                                  value=0,
                                                  color=lightColor[theme],
                                              ),
                                              daq.LEDDisplay(
                                                  id="gpuTempLiveLed",
                                                  label="Gpu Temp",
                                                  value=0,
                                                  color=lightColor[theme],
                                              ),
                                          ]),
                                 dcc.Graph(id="tempLiveGraph",
                                           style={"width": "100%"}),
                             ]),
                    html.Div(id="tempControlSection",
                             className="two columns",
                             style={"backgroundColor": cardColor[theme]},
                             children=[
                                 html.Button("Reset Graph",
                                             id="tempDataResetButton",
                                             n_clicks=0,
                                             className=textClassName[theme]),
                                 daq.PowerButton(
                                     id="tempStopButton",
                                     color=lightColor[theme],
                                     on=True,
                                     size=120,
                                 ),
                             ])
                ]),
            html.Div(
                id="usageSection",
                style={"backgroundColor": cardColor[theme]},
                children=[
                    html.H5("System Usage"),
                    dcc.Interval(
                        id='usageInterval',
                        interval=2 * 1000,  # in milliseconds
                        n_intervals=0),
                    html.Div(id="usageGraphSection",
                             className="seven columns",
                             style={"backgroundColor": backgroundColor[theme]},
                             children=[
                                 html.Div(id="usageGaugeDispSection",
                                          style={
                                              "backgroundColor":
                                              cardColor[theme]
                                          },
                                          children=[
                                              daq.Gauge(
                                                  id='cpuUsageLiveGauge',
                                                  min=0,
                                                  value=0,
                                                  max=100,
                                                  label="Cpu Usage",
                                                  color=lightColor[theme],
                                              ),
                                              daq.Gauge(
                                                  id='memUsageLiveGauge',
                                                  min=0,
                                                  value=0,
                                                  label="Mem Usage",
                                                  max=100,
                                                  color=lightColor[theme],
                                              ),
                                          ]),
                                 dcc.Graph(id="usageLiveGraph",
                                           style={"width": "100%"}),
                             ]),
                    html.Div(id="usageControlSection",
                             className="two columns",
                             style={"backgroundColor": cardColor[theme]},
                             children=[
                                 html.Button("Reset Graph",
                                             id="usageDataResetButton",
                                             n_clicks=0,
                                             className=textClassName[theme]),
                                 daq.PowerButton(
                                     id="usageStopButton",
                                     color=lightColor[theme],
                                     on=True,
                                     size=120,
                                 ),
                             ])
                ])
        ])

    if theme == "dark":
        return daq.DarkThemeProvider(children=bodyLayout)
    if theme == "light":
        return bodyLayout
Example #9
0
def generate_main_layout(
    theme='light',
    src_type='V',
    mode_val='single',
    fig=None,
    sourcemeter=iv_generator
):
    """generate the layout of the app"""

    source_label, measure_label = get_source_labels(src_type)
    source_unit, measure_unit = get_source_units(src_type)
    source_max = get_source_max(src_type)

    if mode_val == 'single':
        single_style = {
            'display': 'flex',
            'flex-direction': 'column',
            'alignItems': 'center'
        }
        sweep_style = {'display': 'none'}

        label_btn = 'Single measure'
    else:
        single_style = {'display': 'none'}
        sweep_style = {
            'display': 'flex',
            'flex-direction': 'column',
            'alignItems': 'center'
        }

        label_btn = 'Start sweep'

    # As the trigger-measure btn will have its n_clicks reset by the reloading
    # of the layout we need to reset this one as well
    local_vars.reset_n_clicks()

    # Doesn't clear the data of the graph
    if fig is None:
        data = []
    else:
        data = fig['data']

    html_layout = [
        html.Div(
            className='row',
            children=[
                # graph to trace out the result(s) of the measurement(s)
                html.Div(
                    id='IV_graph_div',
                    className="eight columns",
                    children=[
                        dcc.Graph(
                            id='IV_graph',
                            figure={
                                'data': data,
                                'layout': dict(
                                    paper_bgcolor=bkg_color[theme],
                                    plot_bgcolor=bkg_color[theme],
                                    font=dict(
                                        color=text_color[theme],
                                        size=15,
                                    ),
                                    xaxis={
                                        'color': grid_color[theme],
                                        'gridcolor': grid_color[theme]
                                    },
                                    yaxis={
                                        'color': grid_color[theme],
                                        'gridcolor': grid_color[theme]
                                    }
                                )
                            }
                        )
                    ]
                ),
                # controls and options for the IV tracer
                html.Div(
                    className="two columns",
                    id='IV-options_div',
                    children=[
                        html.H4(
                            'Sourcing',
                            title='Choose whether you want to source voltage '
                                  'and measure current or source current and '
                                  'measure voltage'
                        ),
                        dcc.RadioItems(
                            id='source-choice',
                            options=[
                                {'label': 'Voltage', 'value': 'V'},
                                {'label': 'Current', 'value': 'I'}
                            ],
                            value=src_type
                        ),
                        html.Br(),
                        html.H4(
                            'Measure mode',
                            title='Choose if you want to do single measurement'
                                  ' or to start a sweep'
                        ),
                        dcc.RadioItems(
                            id='mode-choice',
                            options=[
                                {'label': 'Single measure', 'value': 'single'},
                                {'label': 'Sweep', 'value': 'sweep'}
                            ],
                            value=mode_val
                        ),
                        html.Br(),
                        html.Div(
                            daq.StopButton(
                                id='clear-graph_btn',
                                buttonText='Clear graph',
                                size=150
                            ),
                            style={
                                'alignItems': 'center',
                                'display': 'flex',
                                'flex-direction': 'row'
                            }
                        ),
                        html.Br(),
                        daq.Indicator(
                            id='clear-graph_ind',
                            value=False,
                            style={'display': 'none'}
                        )
                    ]
                ),
                # controls for the connexion to the instrument
                html.Div(
                    id='instr_controls',
                    children=[
                        html.H4(
                            sourcemeter.instr_user_name,
                        ),
                        # A button to turn the instrument on or off
                        html.Div(
                            children=[
                                html.Div(
                                    id='power_button_div',
                                    children=daq.PowerButton(
                                        id='power_button',
                                        on='false'
                                    )
                                ),
                                html.Br(),
                                html.Div(
                                    children=daq.Indicator(
                                        id='mock_indicator',
                                        value=sourcemeter.mock_mode,
                                        label='is mock?'
                                    ),
                                    style={'margin': '20px'},
                                    title='If the indicator is on, it means '
                                          'the instrument is in mock mode'
                                )
                            ],
                            style=h_style
                        ),
                        # An input to choose the COM/GPIB port
                        dcc.Input(
                            id='instr_port_input',
                            placeholder='Enter port name...',
                            type='text',
                            value=''
                        ),
                        html.Br(),
                        # A button which will initiate the connexion
                        daq.StopButton(
                            id='instr_port_button',
                            buttonText='Connect',
                            disabled=True
                        ),
                        html.Br(),
                        html.Div(
                            id='instr_status_div',
                            children="",
                            style={'margin': '10 px'}
                        )
                    ],
                    style={
                        'display': 'flex',
                        'flex-direction': 'column',
                        'alignItems': 'center',
                        'justifyContent': 'space-between',
                        'border': '2px solid #C8D4E3',
                        'background': '#f2f5fa'
                    }
                )
            ]
        ),
        html.Div(
            id='measure_controls_div',
            className='row',
            children=[
                # Sourcing controls
                html.Div(
                    id='source-div',
                    className="three columns",
                    children=[
                        # To perform single measures adjusting the source with
                        # a knob
                        html.Div(
                            id='single_div',
                            children=[
                                daq.Knob(
                                    id='source-knob',
                                    value=0.00,
                                    min=0,
                                    max=source_max,
                                    label='%s (%s)' % (
                                        source_label,
                                        source_unit
                                    )
                                ),
                                daq.LEDDisplay(
                                    id="source-knob-display",
                                    label='Knob readout',
                                    value=0.00
                                )
                            ],
                            style=single_style
                        ),
                        # To perfom automatic sweeps of the source
                        html.Div(
                            id='sweep_div',
                            children=[
                                html.Div(
                                    id='sweep-title',
                                    children=html.H4(
                                        "%s sweep:" % source_label
                                    )
                                ),
                                html.Div(
                                    [
                                        'Start',
                                        html.Br(),
                                        daq.PrecisionInput(
                                            id='sweep-start',
                                            precision=4,
                                            min=0,
                                            max=source_max,
                                            label=' %s' % source_unit,
                                            labelPosition='right',
                                            value=1,
                                            style={'margin': '5px'}
                                        ),

                                    ],
                                    title='The lowest value of the sweep',
                                    style=h_style
                                ),
                                html.Div(
                                    [
                                        'Stop',
                                        daq.PrecisionInput(
                                            id='sweep-stop',
                                            precision=4,
                                            min=0,
                                            max=source_max,
                                            label=' %s' % source_unit,
                                            labelPosition='right',
                                            value=9,
                                            style={'margin': '5px'}
                                        )
                                    ],
                                    title='The highest value of the sweep',
                                    style=h_style
                                ),
                                html.Div(
                                    [
                                        'Step',
                                        daq.PrecisionInput(
                                            id='sweep-step',
                                            precision=4,
                                            min=0,
                                            max=source_max,
                                            label=' %s' % source_unit,
                                            labelPosition='right',
                                            value=source_max / 20.,
                                            style={'margin': '5px'}
                                        )
                                    ],
                                    title='The increment of the sweep',
                                    style=h_style
                                ),
                                html.Div(
                                    [
                                        'Time of a step',
                                        daq.NumericInput(
                                            id='sweep-dt',
                                            value=0.5,
                                            min=0.1,
                                            style={'margin': '5px'}
                                        ),
                                        's'
                                    ],
                                    title='The time spent on each increment',
                                    style=h_style
                                ),
                                html.Div(
                                    [
                                        daq.Indicator(
                                            id='sweep-status',
                                            label='Sweep active',
                                            value=False
                                        )
                                    ],
                                    title='Indicates if the sweep is running',
                                    style=h_style
                                )
                            ],
                            style=sweep_style
                        )
                    ]
                ),
                # measure button and indicator
                html.Div(
                    id='trigger_div',
                    className="two columns",
                    children=[
                        daq.StopButton(
                            id='trigger-measure_btn',
                            buttonText=label_btn,
                            size=150
                        ),
                        daq.Indicator(
                            id='measure-triggered',
                            value=False,
                            label='Measure active'
                        ),
                    ]
                ),
                # Display the sourced and measured values
                html.Div(
                    id='measure_div',
                    className="five columns",
                    children=[
                        daq.LEDDisplay(
                            id="source-display",
                            label='Applied %s (%s)' % (
                                source_label,
                                source_unit
                            ),
                            value="0.0000"
                        ),
                        daq.LEDDisplay(
                            id="measure-display",
                            label='Measured %s (%s)' % (
                                measure_label,
                                measure_unit
                            ),
                            value="0.0000"
                        )
                    ]
                )

            ],
            style={
                'width': '100%',
                'flexDirection': 'column',
                'alignItems': 'center',
                'justifyContent': 'space-between'
            }
        ),
        html.Div(
            children=[
                html.Div(
                    children=dcc.Markdown('''
**What is this app about?**

This is an app to show the graphic elements of Dash DAQ used to create an
interface for an IV curve tracer using a Keithley 2400 SourceMeter. This mock
demo does not actually connect to a physical instrument the values displayed
are generated from an IV curve model for demonstration purposes.

**How to use the app**

First choose if you want to source (apply) current or voltage, using the radio
item located on the right of the graph area. Then choose if you want to operate
in a single measurement mode or in a sweep mode.

***Single measurement mode***

Adjust the value of the source with the knob at the bottom of the graph area
and click on the `SINGLE MEASURE` button, the measured value will be displayed.
Repetition of this procedure for different source values will reveal the full
IV curve.

***Sweep mode***

Set the sweep parameters `start`, `stop` and `step` as well as the time
spent on each step, then click on the button `START SWEEP`, the result of the
sweep will be displayed on the graph.

The data is never erased unless the button `CLEAR GRAPH is pressed` or if the
source type is changed.

You can purchase the Dash DAQ components at [
dashdaq.io](https://www.dashdaq.io/)
                    '''),
                    style={
                        'max-width': '600px',
                        'margin': '15px auto 300 px auto',
                        'padding': '40px',
                        'alignItems': 'left',
                        'box-shadow': '10px 10px 5px rgba(0, 0, 0, 0.2)',
                        'border': '1px solid #DFE8F3',
                        'color': text_color[theme],
                        'background': bkg_color[theme]
                    }
                )
            ]
        )
    ]

    if theme == 'dark':
        return daq.DarkThemeProvider(children=html_layout)
    elif theme == 'light':
        return html_layout
 daq.LEDDisplay(
     value="3.14159",
     color=theme['primary'],
     id='darktheme-daq-leddisplay',
     className='dark-theme-control'
 ), html.Br(),
 daq.NumericInput(
     min=0,
     max=10,
     value=4,
     id='darktheme-daq-numericinput',
     className='dark-theme-control'
 ), html.Br(),
 daq.PowerButton(
     on=True,
     color=theme['primary'],
     id='darktheme-daq-powerbutton',
     className='dark-theme-control'
 ), html.Br(),
 daq.PrecisionInput(
     precision=4,
     value=299792458,
     id='darktheme-daq-precisioninput',
     className='dark-theme-control'
 ), html.Br(),
 daq.StopButton(
     id='darktheme-daq-stopbutton',
     className='dark-theme-control'
 ), html.Br(),
 daq.Slider(
     min=0,
     max=100,
Example #11
0
         html.Span(id='resource-selection',
                   children=['Sourcemeter address']),
         dcc.Dropdown(id='resource-dropdown',
                      options=[{
                          'label': name,
                          'value': name
                      } for name in list_of_resources],
                      value=default_resource,
                      style={'width': '100%'},
                      searchable=False),
     ]),
 html.Div(className='column middle',
          children=[
              daq.PowerButton(
                  id='power-button',
                  color="#FF5E5E",
                  size=60,
                  on=False,
              ),
              daq.StopButton(
                  id='my-daq-startbutton',
                  disabled=True,
                  buttonText='Start',
                  n_clicks=0,
              ),
              daq.StopButton(
                  id='clear-button',
                  n_clicks=0,
                  buttonText='Clear',
              ),
              daq.StopButton(
                  id='refresh-button',
Example #12
0
         html.Span(id='resource-selection',
                   children=['Sourcemeter address']),
         dcc.Dropdown(id='resource-dropdown',
                      options=[{
                          'label': name,
                          'value': name
                      } for name in list_of_resources],
                      value=default_resource,
                      style={'width': '100%'},
                      searchable=False),
     ]),
 html.Div(className='column middle',
          children=[
              daq.PowerButton(id='power-button',
                              color="#FF5E5E",
                              size=60,
                              on=False,
                              label='Power OFF',
                              labelPosition='top'),
              daq.StopButton(
                  id='my-daq-startbutton',
                  disabled=True,
                  buttonText='Run',
                  n_clicks=0,
              ),
              daq.StopButton(
                  id='clear-button',
                  n_clicks=0,
                  buttonText='Clear',
              ),
              daq.StopButton(
                  id='refresh-button',
    id='pv_gauge',
    labelPosition='top',
    style=dict(display='inline-block', height='80px'),
)

fc_power_led = daq.LEDDisplay(id='fc_apow_led',
                              label="Next Forecasted Value",
                              value=30.538,
                              size=20,
                              color='#7567f5',
                              labelPosition='bottom',
                              className='gauge')

on_button = daq.PowerButton(id='on_button',
                            size=60,
                            on=True,
                            label=' ',
                            labelPosition='top',
                            color='#55f4e2')

real_input = [
    html.Div([
        html.Div('Forecast Steps: ',
                 className='inputGroup__label d-inline-block'),
        daq.NumericInput(id='real_step',
                         min=1,
                         value=6,
                         max=12,
                         className='inputGroup__input d-inline-block')
    ],
             className='inputGroup inline d-inline-block'),
    dbc.Button(id='show_button',
                        },
                    })
     ],
     style={
         'width': '200px',
         'margin-left': '770px',
         'margin-top': '55px',
         'margin-bottom': '0px'
     }),
 daq.PowerButton(
     id='Inicio',
     color='#FF5E5E',
     label='Play/Stop',
     on=True,
     size=50,
     #className='btn-floating pulse',
     style={
         'position': 'absolute',
         'float': 'left',
         'left': '1050px',
         'margin-top': '-85px',
         'margin-bottom': '10px'
     }),
 daq.Indicator(id='indicador',
               label="Control",
               value=False,
               style={
                   'position': 'absolute',
                   'float': 'left',
                   'left': '1155px',
                   'margin-top': '-85px'
               }),
PowerButton = html.Div(children=[
    html.H1('Power Button Examples and Reference'),
    html.Hr(),
    html.H3('Default Power Button'),
    reusable_components.Markdown("An example of a default power button without \
            any extra properties."),
    reusable_components.Markdown(
        examples['power-button'][0],
        style=styles.code_container
    ),
    html.Div(
        examples['power-button'][1],
        className='example-container',
        style={'overflow-x': 'initial'}
    ),

    html.Hr(),
    html.H3('Label'),
    reusable_components.Markdown("Set the label and label position with `label` and `labelPosition`."),
    ComponentBlock('''import dash_daq as daq

daq.PowerButton(
    on='True',
    label='Label',
    labelPosition='top'
)''', style=styles.code_container),
    html.Hr(),
    html.H3('Size'),
    reusable_components.Markdown("Adjust the size (diameter in pixels) of the power button with `size`."),
    ComponentBlock('''import dash_daq as daq

daq.PowerButton(
    on='True',
    size=100
)''', style=styles.code_container),
    html.H3('Color'),
    reusable_components.Markdown("Set the color of the power button with `color`."),
    ComponentBlock('''import dash_daq as daq

daq.PowerButton(
    on='True',
    color='#FF5E5E'
)''', style=styles.code_container),
    html.Hr(),
    html.H3("Power Button Properties"),
    generate_prop_info('PowerButton', lib=daq)
])
Example #16
0
import dash_daq as daq
import dash_html_components as html
from dash.dependencies import Input, Output
import numpy as np

external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

# ➊ レイアウト
app.layout = html.Div([
    html.Div([
        daq.PowerButton(
            id="daq-powerbutton",
            label="計器を動作させるボタン",
            on=False,
            size=100,
            color="red",
        ),
        dcc.Interval(id="daq-interval", interval=1000, n_intervals=0),
    ]),
    # ➍ 計器を並べる
    html.Div(
        [
            html.Div(
                [html.H2("ゲージ"), daq.Gauge(id="guage1")],
                className="three columns",
            ),
            html.Div(
                [html.H2("グラデュエートバー"),
                 daq.GraduatedBar(id="guage2")],
Example #17
0
                       style={
                           'width': '100%',
                           'height': '60px',
                           'lineHeight': '60px',
                           'borderWidth': '1px',
                           'borderStyle': 'dashed',
                           'borderRadius': '5px',
                           'textAlign': 'center',
                           'margin': '10px'
                       },
                       multiple=False),
            html.Br(),
            daq.PowerButton(on=False,
                            color=theme['primary'],
                            id='powerbutton',
                            className='dark-theme-control',
                            size=70,
                            style={
                                'display': 'none',
                            }),
            #  sd_material_ui.FlatButton(id='iut', label='Click me', backgroundColor='#2ab7ca'),
            html.Br(),

            # <div class="card border-primary mb-3" style="max-width: 18rem;">
            #   <div class="card-header">Header</div>
            #   <div class="card-body text-primary">
            #     <h5 class="card-title">Primary card title</h5>
            #     <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
            #   </div>
            html.Div(
                [
                    sd_material_ui.IconButton(
 style=tab_style,
 selected_style=tab_selected_style,
 children=html.Div([
     html.Div(
         className="row center-align",
         children=[
             html.H6([
                 html.H3([('Sensores CFIS')],
                         className="center-align")
             ],
                     className="col s12 m12 l3"),
             html.P([
                 html.Div(children='Play/Stop'),
                 daq.PowerButton(
                     id='Inicio',
                     color='#FF5E5E',
                     on=True,
                     className='btn-floating pulse',
                 )
             ],
                    className="col s2 m1 l1"),  #Tamaño PLAY
             html.Div(
                 [
                     html.Div([
                         html.Div([
                             html.P([
                                 daq.Indicator(
                                     id='indicador',
                                     label="Control",
                                     value=False,
                                 )
                             ],
Example #19
0
def Add_Dash(server):
    def protect_dashviews(dashapp):
        for view_func in dashapp.server.view_functions:
            if view_func.startswith(dashapp.url_base_pathname):
                dashapp.server.view_functions[view_func] = login_required(
                    dashapp.server.view_functions[view_func])

    dashapp = dash.Dash(__name__,
                        server=server,
                        url_base_pathname='/instant_dash/',
                        external_stylesheets=[dbc.themes.BOOTSTRAP])
    protect_dashviews(dashapp)
    server = dashapp.server

    body1 = dbc.Container(
        [
            dbc.Row(dbc.Col(html.Div(html.H2('Volume Instantâneo das ETEs')))),
            dbc.Row([
                dbc.Col(
                    [
                        daq.Tank(label='ETE #1',
                                 id='tank_1',
                                 units="Vol H2O",
                                 style={'margin-left': '50px'},
                                 showCurrentValue=True,
                                 max=5,
                                 min=0,
                                 value=2),
                        html.P('', style={'padding': '2em 0 0 2em'}),
                        dcc.Slider(
                            id='tank_1-slider', min=0, max=5, step=1, value=2),
                    ],
                    md=4,
                ),
                dbc.Col(
                    [
                        daq.Tank(label='ETE #2',
                                 id='tank_2',
                                 style={'margin-left': '50px'},
                                 showCurrentValue=True,
                                 units="Vol H2O",
                                 max=5,
                                 min=0,
                                 value=3),
                        html.P('', style={'padding': '2em 0 0 2em'}),
                        dcc.Slider(
                            id='tank_2-slider', min=0, max=5, step=1, value=3),
                    ],
                    md=4,
                ),
                dbc.Col(
                    [
                        daq.Tank(label='ETE #3',
                                 id='tank_3',
                                 style={'margin-left': '50px'},
                                 showCurrentValue=True,
                                 units="Vol H2O",
                                 max=5,
                                 min=0,
                                 value=4),
                        html.P('', style={'padding': '2em 0 0 2em'}),
                        dcc.Slider(
                            id='tank_3-slider', min=0, max=5, step=1, value=4),
                    ],
                    md=4,
                ),
            ]),
        ],
        className="mt-4",
        fluid=True,
    )

    body2 = dbc.Container(
        [
            dbc.Row(dbc.Col(html.Div(html.H2('Status das Bombas')))),
            dbc.Row([
                dbc.Col(
                    [
                        daq.LEDDisplay(label="Bomba A / ETE #1",
                                       value='110.00',
                                       backgroundColor="#007acc"),
                        html.P('', style={'padding': '2em 0 0 2em'}),
                        daq.PowerButton(
                            on='True', theme='dark', color="#009933"),
                    ],
                    md=4,
                ),
                dbc.Col(
                    [
                        daq.LEDDisplay(label="Bomba A / ETE #2",
                                       value='110.00',
                                       backgroundColor="#007acc"),
                        html.P('', style={'padding': '2em 0 0 2em'}),
                        daq.PowerButton(on='True', color="#009933"),
                    ],
                    md=4,
                ),
                dbc.Col(
                    [
                        daq.LEDDisplay(label="Bomba A / ETE #3",
                                       value='110.00',
                                       backgroundColor="#007acc"),
                        html.P('', style={'padding': '2em 0 0 2em'}),
                        daq.PowerButton(on='True', color="#009933"),
                    ],
                    md=4,
                ),
            ]),
        ],
        className="mt-4",
        fluid=True,
    )

    dashapp.layout = html.Div([body1, body2])

    ### Tanks
    @dashapp.callback(dash.dependencies.Output('tank_1', 'value'),
                      [dash.dependencies.Input('tank_1-slider', 'value')])
    def update_output_4(value):
        return value

    @dashapp.callback(dash.dependencies.Output('tank_2', 'value'),
                      [dash.dependencies.Input('tank_2-slider', 'value')])
    def update_output_5(value):
        return value

    @dashapp.callback(dash.dependencies.Output('tank_3', 'value'),
                      [dash.dependencies.Input('tank_3-slider', 'value')])
    def update_output_6(value):
        return value

    return dashapp.server
Example #20
0
def generate_main_layout(theme="light",
                         src_type="V",
                         mode_val="single",
                         fig=None,
                         sourcemeter=iv_generator):
    """generate the layout of the app"""

    source_label, measure_label = get_source_labels(src_type)
    source_unit, measure_unit = get_source_units(src_type)
    source_max = get_source_max(src_type)

    if mode_val == "single":
        single_style = {
            "display": "flex",
            "flex-direction": "column",
            "alignItems": "center",
        }
        sweep_style = {"display": "none"}

        label_btn = "Single measure"
    else:
        single_style = {"display": "none"}
        sweep_style = {
            "display": "flex",
            "flex-direction": "column",
            "alignItems": "center",
        }

        label_btn = "Start sweep"

    # As the trigger-measure btn will have its n_clicks reset by the reloading
    # of the layout we need to reset this one as well
    local_vars.reset_n_clicks()

    # Doesn't clear the data of the graph
    if fig is None:
        data = []
    else:
        data = fig["data"]

    html_layout = [
        html.Div(
            className="row",
            children=[
                # graph to trace out the result(s) of the measurement(s)
                html.Div(
                    id="IV_graph_div",
                    className="eight columns",
                    style={"margin": "20px"},
                    children=[
                        dcc.Graph(
                            id="IV_graph",
                            figure={
                                "data":
                                data,
                                "layout":
                                dict(
                                    paper_bgcolor=bkg_color[theme],
                                    plot_bgcolor=bkg_color[theme],
                                    font=dict(color=text_color[theme],
                                              size=15),
                                    xaxis={
                                        "color": grid_color[theme],
                                        "gridcolor": grid_color[theme],
                                    },
                                    yaxis={
                                        "color": grid_color[theme],
                                        "gridcolor": grid_color[theme],
                                    },
                                ),
                            },
                        )
                    ],
                ),
                # controls for the connexion to the instrument
                html.Div(
                    id="instr_controls",
                    className="two columns",
                    children=[
                        html.H4(sourcemeter.instr_user_name),
                        # A button to turn the instrument on or off
                        html.Div(
                            children=[
                                html.Div(
                                    id="power_button_div",
                                    children=daq.PowerButton(id="power_button",
                                                             on="false"),
                                ),
                                html.Br(),
                                html.Div(
                                    children=daq.Indicator(
                                        id="mock_indicator",
                                        value=sourcemeter.mock_mode,
                                        label="is mock?",
                                    ),
                                    style={"margin": "20px"},
                                    title="If the indicator is on, it means "
                                    "the instrument is in mock mode",
                                ),
                            ],
                            style=h_style,
                        ),
                        # An input to choose the COM/GPIB port
                        dcc.Input(
                            id="instr_port_input",
                            placeholder="Enter port name...",
                            type="text",
                            value="",
                        ),
                        html.Br(),
                        # A button which will initiate the connexion
                        daq.StopButton(id="instr_port_button",
                                       buttonText="Connect",
                                       disabled=True),
                        html.Br(),
                        html.Div(
                            id="instr_status_div",
                            children="",
                            style={"margin": "10 px"},
                        ),
                    ],
                    style={
                        "margin": "50px",
                        "display": "flex",
                        "flex-direction": "column",
                        "alignItems": "center",
                        "justifyContent": "space-between",
                        "border": "2px solid #C8D4E3",
                        "background": "#f2f5fa",
                    },
                ),
            ],
        ),
        html.Div(
            id="measure_controls_div",
            className="row",
            children=[
                # controls and options for the IV tracer
                html.Div(
                    className="two columns",
                    id="IV-options_div",
                    children=[
                        html.H4(
                            "Sourcing",
                            title="Choose whether you want to source voltage "
                            "and measure current or source current and "
                            "measure voltage",
                        ),
                        dcc.RadioItems(
                            id="source-choice",
                            options=[
                                {
                                    "label": "Voltage",
                                    "value": "V"
                                },
                                {
                                    "label": "Current",
                                    "value": "I"
                                },
                            ],
                            value=src_type,
                        ),
                        html.Br(),
                        html.H4(
                            "Measure mode",
                            title="Choose if you want to do single measurement"
                            " or to start a sweep",
                        ),
                        dcc.RadioItems(
                            id="mode-choice",
                            options=[
                                {
                                    "label": "Single measure",
                                    "value": "single"
                                },
                                {
                                    "label": "Sweep",
                                    "value": "sweep"
                                },
                            ],
                            value=mode_val,
                        ),
                        html.Br(),
                        html.Div(
                            daq.StopButton(id="clear-graph_btn",
                                           buttonText="Clear graph",
                                           size=150),
                            style={
                                "alignItems": "center",
                                "display": "flex",
                                "flex-direction": "row",
                            },
                        ),
                        html.Br(),
                        daq.Indicator(id="clear-graph_ind",
                                      value=False,
                                      style={"display": "none"}),
                    ],
                ),
                # Sourcing controls
                html.Div(
                    id="source-div",
                    className="three columns",
                    children=[
                        # To perform single measures adjusting the source with
                        # a knob
                        html.Div(
                            id="single_div",
                            children=[
                                daq.Knob(
                                    id="source-knob",
                                    value=0.00,
                                    min=0,
                                    max=source_max,
                                    label="%s (%s)" %
                                    (source_label, source_unit),
                                ),
                                daq.LEDDisplay(
                                    id="source-knob-display",
                                    label="Knob readout",
                                    value=0.00,
                                ),
                            ],
                            style=single_style,
                        ),
                        # To perfom automatic sweeps of the source
                        html.Div(
                            id="sweep_div",
                            children=[
                                html.Div(
                                    id="sweep-title",
                                    children=html.H4("%s sweep:" %
                                                     source_label),
                                ),
                                html.Div(
                                    [
                                        "Start",
                                        html.Br(),
                                        daq.PrecisionInput(
                                            id="sweep-start",
                                            precision=4,
                                            min=0,
                                            max=source_max,
                                            label=" %s" % source_unit,
                                            labelPosition="right",
                                            value=1,
                                            style={"margin": "5px"},
                                        ),
                                    ],
                                    title="The lowest value of the sweep",
                                    style=h_style,
                                ),
                                html.Div(
                                    [
                                        "Stop",
                                        daq.PrecisionInput(
                                            id="sweep-stop",
                                            precision=4,
                                            min=0,
                                            max=source_max,
                                            label=" %s" % source_unit,
                                            labelPosition="right",
                                            value=9,
                                            style={"margin": "5px"},
                                        ),
                                    ],
                                    title="The highest value of the sweep",
                                    style=h_style,
                                ),
                                html.Div(
                                    [
                                        "Step",
                                        daq.PrecisionInput(
                                            id="sweep-step",
                                            precision=4,
                                            min=0,
                                            max=source_max,
                                            label=" %s" % source_unit,
                                            labelPosition="right",
                                            value=source_max / 20.0,
                                            style={"margin": "5px"},
                                        ),
                                    ],
                                    title="The increment of the sweep",
                                    style=h_style,
                                ),
                                html.Div(
                                    [
                                        "Time of a step",
                                        daq.NumericInput(
                                            id="sweep-dt",
                                            value=0.5,
                                            min=0.1,
                                            style={"margin": "5px"},
                                        ),
                                        "s",
                                    ],
                                    title="The time spent on each increment",
                                    style=h_style,
                                ),
                                html.Div(
                                    [
                                        daq.Indicator(
                                            id="sweep-status",
                                            label="Sweep active",
                                            value=False,
                                        )
                                    ],
                                    title="Indicates if the sweep is running",
                                    style=h_style,
                                ),
                            ],
                            style=sweep_style,
                        ),
                    ],
                ),
                # measure button and indicator
                html.Div(
                    id="trigger_div",
                    className="two columns",
                    children=[
                        daq.StopButton(id="trigger-measure_btn",
                                       buttonText=label_btn,
                                       size=150),
                        daq.Indicator(id="measure-triggered",
                                      value=False,
                                      label="Measure active"),
                    ],
                ),
                # Display the sourced and measured values
                html.Div(
                    id="measure_div",
                    className="five columns",
                    children=[
                        daq.LEDDisplay(
                            id="source-display",
                            label="Applied %s (%s)" %
                            (source_label, source_unit),
                            value="0.0000",
                        ),
                        daq.LEDDisplay(
                            id="measure-display",
                            label="Measured %s (%s)" %
                            (measure_label, measure_unit),
                            value="0.0000",
                        ),
                    ],
                ),
            ],
            style={
                # "width": "100%",
                "flexDirection": "column",
                "alignItems": "center",
                "justifyContent": "space-between",
            },
        ),
        html.Div(children=[
            html.Div(
                children=dcc.Markdown("""
**What is this app about?**

This is an app to show the graphic elements of Dash DAQ used to create an
interface for an IV curve tracer using a Keithley 2400 SourceMeter. This mock
demo does not actually connect to a physical instrument the values displayed
are generated from an IV curve model for demonstration purposes.

**How to use the app**

First choose if you want to source (apply) current or voltage, using the radio
item located on the right of the graph area. Then choose if you want to operate
in a single measurement mode or in a sweep mode.

***Single measurement mode***

Adjust the value of the source with the knob at the bottom of the graph area
and click on the `SINGLE MEASURE` button, the measured value will be displayed.
Repetition of this procedure for different source values will reveal the full
IV curve.

***Sweep mode***

Set the sweep parameters `start`, `stop` and `step` as well as the time
spent on each step, then click on the button `START SWEEP`, the result of the
sweep will be displayed on the graph.

The data is never erased unless the button `CLEAR GRAPH is pressed` or if the
source type is changed.

You can purchase the Dash DAQ components at [
dashdaq.io](https://www.dashdaq.io/)
                    """),
                style={
                    "margin": "20px",
                    "padding": "50px",
                    "alignItems": "left",
                    "border": "1px solid #DFE8F3",
                    "color": text_color[theme],
                    "background": bkg_color[theme],
                },
            )
        ]),
    ]

    if theme == "dark":
        return daq.DarkThemeProvider(children=html_layout)
    elif theme == "light":
        return html_layout
Example #21
0
                        dcc.Dropdown(
                            id="select_models",
                            options = [{'label':x, 'value':x} for x in models],
                            value = models,
                            multi=True,
                            clearable=False,
                            className="dcc_control",

                        ),
                        html.Div(
                            id = 'best-model', style={'color': 'blue', 'fontSize': 15} 
                        ),html.Br(),
                        daq.PowerButton(
                            id = 'id-daq-switch-model',
                            on='True',
                            color='#1ABC9C', 
                            size = 75,
                            label = 'Initiate Model Buidling'
                        ) ,
                                                                                               
                    ],
                    className="pretty_container four columns",
                    id="cross-filter-options",
                ),
                #--------------------------------------------------------------------------------------------------------------------
                html.Div(
                    [
                         html.Div(
                            daq.LEDDisplay(
                                id='records',
                                #label="Default",
Example #22
0
            html.Div(
                id="graph-container",
                children=[
                    html.Div(
                        children=[
                            html.H6(
                                id="graph-title", children=["Ocean Optics"]
                            ),
                            html.Div(
                                id="power-button-container",
                                title="Turn the power on to begin viewing the data and controlling \
the spectrometer.",
                                children=[
                                    daq.PowerButton(
                                        id="power-button",
                                        size=50,
                                        color=colors["accent"],
                                        on=True if DEMO else False,
                                    )
                                ],
                            ),
                            dcc.Markdown(
                                dedent(base_intro), id="graph-title-intro"
                            ),
                            html.Button(
                                "Learn More", id="learn-more-btn", n_clicks=0
                            ),
                            dcc.Graph(
                                id="spec-readings",
                                animate=True,
                                figure=dict(
                                    data=[],
Example #23
0
def OnOffButton(name, **kwargs):
    return html.Div(
        # style={"margin": "auto"},
        children=[daq.PowerButton(**kwargs)], )
Example #24
0
                          'value': name
                      } for name in lresources],
                      value='GPIB0::5::INSTR'
                      if 'GPIB0::5::INSTR' in lresources else None,
                      placeholder='Sourcemeter address',
                      style={
                          'width': '80%',
                          'min-width': '150px'
                      },
                      searchable=False)
     ]),
 html.Div(className='column middle',
          children=[
              daq.PowerButton(
                  id='power-button',
                  on=None,
                  color="#FF5E5E",
              ),
              daq.StopButton(
                  id='my-daq-startbutton',
                  buttonText='Start',
                  n_clicks=0,
              ),
              daq.StopButton(
                  id='my-daq-clearbutton',
                  n_clicks=0,
                  buttonText='Clear',
              ),
              daq.StopButton(
                  id='refresh-button',
                  n_clicks=0,
Example #25
0
     className="row",
     style={
         "display": "flex",
         "justify-content": "center",
         "align-items": "center",
     },
 ),
 html.Br(),
 html.Div(
     [
         daq.PowerButton(
             id="power",
             label="On/Off",
             labelPosition="top",
             on=True,
             className="one columns",
             style={
                 "width": "8%",
                 "paddingBottom": "1%"
             },
             color="",
         ),
         daq.NumericInput(
             id="led-select",
             label="Led Select",
             className="one columns",
             style={
                 "width": "5%",
                 "textAlign": "center",
                 "marginLeft": "3%",
                 "paddingBottom": "1%",
             },
Example #26
0
              5: {'label': '5X'},
              10: {'label': '10X'},
              15: {'label': '15X'},
              20: {'label': '20X'},
              },
        
        )
        ],className="col s12 m12 l12"),
        ],className="row"),
        ],className="container"),
        ],className="col s6 m4 l3"),#Tamaño zomm y tanque
     
        html.P([html.Div(children='Play/Stop'),
        daq.PowerButton(
        id='Inicio',
        color='#FF5E5E',
        on=True,
        #className='btn-floating pulse',
        )],className="col s3 m1 l1"), #Tamaño PLAY
                        
        html.Div([
        html.Div([
        html.Div([         
        html.P([
        daq.Indicator(
        id='indicador',
        label="Control",
        value=False,
        )                
        ],className="col s12 m12 l12"),

        html.Div([
Example #27
0
                                    },
                                    className="btn btn-primary")
                    ],
                    className="col-3")
            ],
            className="row"),

        # Instrument connection
        html.Div(
            [

                # Connect button
                html.Div([
                    daq.PowerButton(id="button_instrument_connect",
                                    on=False,
                                    label="Connect",
                                    labelPosition="bottom",
                                    disabled=True,
                                    style={"padding-left": 30})
                ],
                         className="col-1"),

                # Port name
                html.Div([
                    html.Label('Port: '),
                    dcc.Input(id='input_port_name',
                              type='text',
                              style={'margin-left': '20'}),
                ],
                         className="col-4"),

                # Status
Example #28
0
 ),
 html.Div(
     [
         html.Div(
             id="graph-container",
             children=[
                 html.Div(children=[
                     html.H6(id="graph-title",
                             children=["EVONANO TEST"]),
                     html.Div(
                         id="run-sim-button-container",
                         title="Run the simulator.",
                         children=[
                             daq.PowerButton(
                                 id="power-button",
                                 size=50,
                                 color=colors["accent"],
                                 on=True,
                             )
                         ],
                     ),
                     dcc.Markdown(dedent(base_intro),
                                  id="graph-title-intro"),
                     html.Button(
                         "Learn More", id="learn-more-btn", n_clicks=0),
                     dcc.Graph(
                         id="spec-readings",
                         animate=False,
                         figure=dict(
                             data=[],
                             layout=dict(
                                 height=600,
Example #29
0
             html.Button(id='submit-button-state',
                         n_clicks=0,
                         children='Submit'),
         ],
                  style={'backgroundColor': 'rgb(250,250,250)'})
     ],
     style={
         'borderBottom': 'thin lightgrey solid',
         'backgroundColor': 'rgb(250, 250, 250)'
     }),
 html.Div(
     [
         html.H2('Datalogger Control'),
         html.Div([
             html.Div([
                 daq.PowerButton(id='loggerbutton', on=False, size=100),
                 dcc.Slider(id='rate-slider',
                            min=2,
                            max=22,
                            step=0.25,
                            value=guiint.getrate(),
                            marks={
                                2: {
                                    'label': '2 s',
                                    'style': {
                                        'color': '#77b0b1'
                                    }
                                },
                                7: {
                                    'label': '7 s',
                                    'style': {
Example #30
0
         style={'marginLeft': '40px'}),
     html.Img(
         src="https://s3-us-west-1.amazonaws.com/plotly-tutorials/" +
         "excel/dash-daq/dash-daq-logo-by-plotly-stripe+copy.png")
 ],
          className='banner',
          id='header'),
 html.Div([
     html.Div([
         html.Div([html.H3("POWER", id="power-title")],
                  className='Title'),
         html.Div([
             html.Div([
                 daq.PowerButton(id='function-generator',
                                 on='true',
                                 label="Function Generator",
                                 labelPosition='bottom',
                                 color="#447EFF"),
             ],
                      className='six columns',
                      style={'margin-bottom': '15px'}),
             html.Div([
                 daq.PowerButton(id='oscilloscope',
                                 on='true',
                                 label="Oscilloscope",
                                 labelPosition='bottom',
                                 color="#447EFF")
             ],
                      className='six columns',
                      style={'margin-bottom': '15px'}),
         ],