Search in sources :

Example 6 with DoubleVariable

use of net.sourceforge.usbdm.deviceEditor.information.DoubleVariable in project usbdm-eclipse-plugins by podonoghue.

the class FtmValidate method validate.

/**
 * Class to determine LPTMR settings
 * @throws Exception
 */
@Override
public void validate(Variable variable) throws Exception {
    super.validate(variable);
    // =================================
    DoubleVariable clockFrequencyVar = getDoubleVariable("clockFrequency");
    DoubleVariable clockPeriodVar = getDoubleVariable("clockPeriod");
    ChoiceVariable ftm_sc_clksVar = getChoiceVariable("ftm_sc_clks");
    ChoiceVariable ftm_sc_psVar = getChoiceVariable("ftm_sc_ps");
    LongVariable ftm_modVar = getLongVariable("ftm_mod");
    DoubleVariable ftm_mod_periodVar = getDoubleVariable("ftm_mod_period");
    BooleanVariable ftm_sc_cpwmsVar = getBooleanVariable("ftm_sc_cpwms");
    LongVariable clockSourceVar = null;
    switch((int) ftm_sc_clksVar.getValueAsLong()) {
        case 0:
            clockSourceVar = new LongVariable("Disabled", "/Ftm/Disabled");
            clockSourceVar.setOrigin("Disabled");
            clockSourceVar.setValue(0);
            break;
        default:
            ftm_sc_clksVar.setValue(1);
        case 1:
            clockSourceVar = getLongVariable("/SIM/system_bus_clock");
            break;
        case 2:
            clockSourceVar = getLongVariable("/MCG/system_mcgffclk_clock");
            break;
        case 3:
            clockSourceVar = getLongVariable("ftmExternalClock");
            break;
    }
    double clockFrequency = clockSourceVar.getValueAsDouble();
    String clockOrigin = clockSourceVar.getOrigin();
    clockFrequency = clockFrequency / (1L << ftm_sc_psVar.getValueAsLong());
    clockFrequencyVar.setValue(clockFrequency);
    clockFrequencyVar.setOrigin(clockOrigin + " frequency / prescaler");
    clockFrequencyVar.setStatus(clockSourceVar.getFilteredStatus());
    clockPeriodVar.setOrigin(clockOrigin + " period * prescaler");
    clockPeriodVar.setStatus(clockSourceVar.getFilteredStatus());
    clockFrequencyVar.enable(clockFrequency != 0);
    clockPeriodVar.enable(clockFrequency != 0);
    ftm_mod_periodVar.enable(clockFrequency != 0);
    if (clockFrequency != 0) {
        long ftm_mod = ftm_modVar.getValueAsLong();
        double clockPeriod = 1.0 / clockFrequency;
        clockPeriodVar.setValue(clockPeriod);
        boolean ftm_sc_cpwms = ftm_sc_cpwmsVar.getValueAsBoolean();
        double ftm_mod_period = clockPeriod * (ftm_sc_cpwms ? (2 * (ftm_mod)) : ((ftm_mod + 1)));
        if (variable != null) {
            // Update selectively
            if (variable.equals(ftm_mod_periodVar)) {
                ftm_mod_period = ftm_mod_periodVar.getValueAsDouble();
                // Calculate rounded value
                if (ftm_sc_cpwms) {
                    ftm_mod = Math.max(0, Math.round((ftm_mod_period / clockPeriod) / 2));
                } else {
                    ftm_mod = Math.max(0, Math.round((ftm_mod_period / clockPeriod) - 1));
                }
                ftm_mod_period = clockPeriod * (ftm_sc_cpwms ? (2 * (ftm_mod)) : ((ftm_mod + 1)));
                // Update
                ftm_modVar.setValue(ftm_mod);
            }
        }
        double ftm_mod_periodMax = clockPeriod * (ftm_sc_cpwms ? (2 * (65535.5)) : ((65536.5)));
        ftm_mod_periodVar.setValue(ftm_mod_period);
        ftm_mod_periodVar.setMax(ftm_mod_periodMax);
    }
}
Also used : LongVariable(net.sourceforge.usbdm.deviceEditor.information.LongVariable) BooleanVariable(net.sourceforge.usbdm.deviceEditor.information.BooleanVariable) DoubleVariable(net.sourceforge.usbdm.deviceEditor.information.DoubleVariable) ChoiceVariable(net.sourceforge.usbdm.deviceEditor.information.ChoiceVariable)

Example 7 with DoubleVariable

use of net.sourceforge.usbdm.deviceEditor.information.DoubleVariable in project usbdm-eclipse-plugins by podonoghue.

the class AdcValidate method validate.

/**
 * Class to determine LPTMR settings
 * @throws Exception
 */
@Override
public void validate(Variable variable) throws Exception {
    super.validate(variable);
    // Clock Mapping
    // =================
    final StringVariable osc0_peripheralVar = getStringVariable("/SIM/osc0_peripheral");
    final LongVariable osc0_oscer_clockVar = getLongVariable(osc0_peripheralVar.getValueAsString() + "/oscer_clock");
    // Variables
    // =================================
    DoubleVariable clockFrequencyVar = (DoubleVariable) getVariable("clockFrequency");
    Variable adc_cfg1_adiclkVar = getVariable("adc_cfg1_adiclk");
    Variable adc_cfg1_adivVar = getVariable("adc_cfg1_adiv");
    Variable adcInternalClockVar = getVariable("adcInternalClock");
    Variable system_bus_clockVar = getVariable("/SIM/system_bus_clock");
    Variable adc_cfg1_adlpcVar = getVariable("adc_cfg1_adlpc");
    Variable adc_cfg2_adhscVar = getVariable("adc_cfg2_adhsc");
    Variable adc_cfg1_modeVar = getVariable("adc_cfg1_mode");
    BooleanVariable adc_cfg1_adlsmpVar = getBooleanVariable("adc_cfg1_adlsmp");
    ChoiceVariable adc_cfg2_adlstsVar = getChoiceVariable("adc_cfg2_adlsts");
    LongVariable low_comparison_valueVar = getLongVariable("low_comparison_value");
    LongVariable high_comparison_valueVar = getLongVariable("high_comparison_value");
    LongVariable adc_cv1Var = getLongVariable("adc_cv1");
    LongVariable adc_cv2Var = getLongVariable("adc_cv2");
    ChoiceVariable adc_sc2_compareVar = getChoiceVariable("adc_sc2_compare");
    LongVariable adc_sc2_acfeVar = getLongVariable("adc_sc2_acfe");
    LongVariable adc_sc2_acfgtVar = getLongVariable("adc_sc2_acfgt");
    LongVariable adc_sc2_acrenVar = getLongVariable("adc_sc2_acren");
    int cv1 = 0;
    int cv2 = 0;
    int low = (int) low_comparison_valueVar.getValueAsLong();
    int high = (int) high_comparison_valueVar.getValueAsLong();
    int compareChoice = (int) adc_sc2_compareVar.getValueAsLong();
    boolean adc_sc2_acfe = true;
    boolean adc_sc2_acfgt = false;
    boolean adc_sc2_acren = false;
    switch(compareChoice) {
        case // Disabled
        0:
            adc_sc2_acfe = false;
            break;
        case // ADC < low(CV1)
        1:
            cv1 = low;
            adc_sc2_acfgt = false;
            adc_sc2_acren = false;
            break;
        case // ADC >= low(CV1)
        2:
            cv1 = low;
            adc_sc2_acfgt = true;
            adc_sc2_acren = false;
            break;
        case // (ADC<low(CV1)) or (high(CV2)<ADC)      CV1<CV2
        3:
            cv1 = low;
            cv2 = high;
            adc_sc2_acfgt = false;
            adc_sc2_acren = true;
            break;
        case // (low(CV2)<ADC<high(CV1))             CV1>CV2 <==> CV2<CV1
        4:
            cv2 = low;
            cv1 = high;
            adc_sc2_acfgt = false;
            adc_sc2_acren = true;
            break;
        case // (low(CV1)<=ADC<=high(CV2)            CV1<CV2
        5:
            cv1 = low;
            cv2 = high;
            adc_sc2_acfgt = true;
            adc_sc2_acren = true;
            break;
        case // (ADC<=low(CV2)) or (high(CV1<=ADC))    CV1>CV2 <==> CV2<CV1
        6:
            cv2 = low;
            cv1 = high;
            adc_sc2_acfgt = true;
            adc_sc2_acren = true;
            break;
    }
    adc_cv1Var.enable(compareChoice >= 1);
    adc_cv2Var.enable(compareChoice >= 3);
    low_comparison_valueVar.enable(compareChoice >= 1);
    high_comparison_valueVar.enable(compareChoice >= 3);
    adc_cv1Var.setValue(cv1);
    adc_cv2Var.setValue(cv2);
    adc_sc2_acfeVar.setValue(adc_sc2_acfe);
    adc_cfg2_adlstsVar.enable(adc_cfg1_adlsmpVar.getValueAsBoolean());
    adc_sc2_acfeVar.setValue(adc_sc2_acfe);
    adc_sc2_acfgtVar.setValue(adc_sc2_acfgt);
    adc_sc2_acrenVar.setValue(adc_sc2_acren);
    // Varies with power settings etc
    adcInternalClockVar.setValue(ADC_CLOCK_VALUES[(int) (2 * adc_cfg1_adlpcVar.getValueAsLong() + adc_cfg2_adhscVar.getValueAsLong())]);
    LongVariable system_irc48m_clockVar = safeGetLongVariable("/MCG/system_irc48m_clock");
    Variable clockSourceVar = null;
    double clockFrequency;
    switch((int) adc_cfg1_adiclkVar.getValueAsLong()) {
        case 0:
            clockSourceVar = system_bus_clockVar;
            clockFrequency = system_bus_clockVar.getValueAsLong();
            break;
        case 1:
            /* 
          * TODO - better method of clock selection
          * ALTCLK2: Varies with device but assume irc48m if available else busClock/2
          */
            if (system_irc48m_clockVar != null) {
                clockSourceVar = system_irc48m_clockVar;
                clockFrequency = system_irc48m_clockVar.getValueAsLong();
            } else {
                clockSourceVar = system_bus_clockVar;
                clockFrequency = system_bus_clockVar.getValueAsLong() / 2.0;
            }
            break;
        case 2:
            clockSourceVar = osc0_oscer_clockVar;
            clockFrequency = osc0_oscer_clockVar.getValueAsLong();
            break;
        default:
            adc_cfg1_adiclkVar.setValue(1);
        case 3:
            clockSourceVar = adcInternalClockVar;
            clockFrequency = adcInternalClockVar.getValueAsLong();
            break;
    }
    // Set MIN and MAX before updating value
    if (adc_cfg1_modeVar.getValueAsLong() >= 2) {
        clockFrequencyVar.setMin(FADC_HIGH_RES_MIN);
        clockFrequencyVar.setMax(FADC_HIGH_RES_MAX);
    } else {
        clockFrequencyVar.setMin(FADC_LOW_RES_MIN);
        clockFrequencyVar.setMax(FADC_LOW_RES_MAX);
    }
    clockFrequency = clockFrequency / (1L << adc_cfg1_adivVar.getValueAsLong());
    clockFrequencyVar.setValue(clockFrequency);
    clockFrequencyVar.setStatus(clockSourceVar.getFilteredStatus());
    clockFrequencyVar.setOrigin(clockSourceVar.getOrigin() + " divided by adc_cfg1_adiv");
}
Also used : BooleanVariable(net.sourceforge.usbdm.deviceEditor.information.BooleanVariable) StringVariable(net.sourceforge.usbdm.deviceEditor.information.StringVariable) DoubleVariable(net.sourceforge.usbdm.deviceEditor.information.DoubleVariable) ChoiceVariable(net.sourceforge.usbdm.deviceEditor.information.ChoiceVariable) Variable(net.sourceforge.usbdm.deviceEditor.information.Variable) LongVariable(net.sourceforge.usbdm.deviceEditor.information.LongVariable) LongVariable(net.sourceforge.usbdm.deviceEditor.information.LongVariable) BooleanVariable(net.sourceforge.usbdm.deviceEditor.information.BooleanVariable) StringVariable(net.sourceforge.usbdm.deviceEditor.information.StringVariable) DoubleVariable(net.sourceforge.usbdm.deviceEditor.information.DoubleVariable) ChoiceVariable(net.sourceforge.usbdm.deviceEditor.information.ChoiceVariable)

Example 8 with DoubleVariable

use of net.sourceforge.usbdm.deviceEditor.information.DoubleVariable in project usbdm-eclipse-plugins by podonoghue.

the class LcdValidate method validate.

/**
 * Class to validate LCD settings
 * @throws Exception
 */
@Override
public void validate(Variable variable) throws Exception {
    super.validate(variable);
    String osc0_peripheral = getStringVariable("/SIM/osc0_peripheral").getValueAsString();
    LongVariable osc0_oscer_clockVar = getLongVariable(osc0_peripheral + "/oscer_clock");
    LongVariable system_erclk32k_clockVar = getLongVariable("/SIM/system_erclk32k_clock");
    LongVariable system_mcgirclk_clockVar = getLongVariable("/MCG/system_mcgirclk_clock");
    ChoiceVariable lcd_gcr_clockVar = getChoiceVariable("lcd_gcr_clock");
    ChoiceVariable lcd_gcr_altdivVar = getChoiceVariable("lcd_gcr_altdiv");
    DoubleVariable lcdClockVar = getDoubleVariable("lcdClock");
    BooleanVariable lcd_gcr_rvenVar = getBooleanVariable("lcd_gcr_rven");
    ChoiceVariable lcd_gcr_rvtrimVar = getChoiceVariable("lcd_gcr_rvtrim");
    lcd_gcr_rvtrimVar.enable(lcd_gcr_rvenVar.getValueAsBoolean());
    ChoiceVariable lcd_gcr_dutyVar = getChoiceVariable("lcd_gcr_duty");
    PinListVariable backplanesVar = (PinListVariable) getVariable("backplanes");
    PinListVariable frontplanesVar = (PinListVariable) getVariable("frontplanes");
    Vector<Signal> table = getPeripheral().getSignalTables().get(0).table;
    Status unmappedBackplanesMessage = null;
    int[] backPlaneValues = backplanesVar.getValues();
    for (int pinNum : backPlaneValues) {
        Signal entry = table.get(pinNum);
        if ((entry == null) || (entry.getMappedPin().getPin() == Pin.UNASSIGNED_PIN)) {
            unmappedBackplanesMessage = UNMAPPED_PIN_STATUS;
            break;
        }
    }
    backplanesVar.setStatus(unmappedBackplanesMessage);
    Status unmappedFrontplanesMessage = null;
    int[] frontPlaneValues = frontplanesVar.getValues();
    for (int pinNum : frontPlaneValues) {
        Signal entry = table.get(pinNum);
        if ((entry == null) || (entry.getMappedPin().getPin() == Pin.UNASSIGNED_PIN)) {
            unmappedFrontplanesMessage = UNMAPPED_PIN_STATUS;
            break;
        }
    }
    frontplanesVar.setStatus(unmappedFrontplanesMessage);
    // Number of back-planes is determined by duty-cycle
    backplanesVar.setMinListLength(0);
    backplanesVar.setListLength((int) lcd_gcr_dutyVar.getValueAsLong() + 1);
    // Number of front-planes is determined by pins left over from back-planes
    frontplanesVar.setMinListLength(0);
    frontplanesVar.setMaxListLength(63 - ((int) lcd_gcr_dutyVar.getValueAsLong() + 1));
    double divider = 1 << (3 * lcd_gcr_altdivVar.getValueAsLong());
    switch((int) lcd_gcr_clockVar.getValueAsLong()) {
        default:
            lcd_gcr_clockVar.setValue(0);
        case 0:
            lcd_gcr_altdivVar.enable(false);
            lcdClockVar.setValue(system_erclk32k_clockVar.getValueAsLong());
            lcdClockVar.setOrigin(system_erclk32k_clockVar.getOrigin());
            lcdClockVar.setStatus(system_erclk32k_clockVar.getFilteredStatus());
            break;
        case 1:
            lcd_gcr_altdivVar.enable(true);
            lcdClockVar.setValue(system_mcgirclk_clockVar.getValueAsLong() / divider);
            lcdClockVar.setOrigin(system_mcgirclk_clockVar.getOrigin() + " / ALTDIV");
            lcdClockVar.setStatus(system_mcgirclk_clockVar.getFilteredStatus());
            break;
        case 2:
            lcd_gcr_altdivVar.enable(true);
            lcdClockVar.setValue(osc0_oscer_clockVar.getValueAsLong() / divider);
            lcdClockVar.setOrigin(osc0_oscer_clockVar.getOrigin() + " / ALTDIV");
            lcdClockVar.setStatus(osc0_oscer_clockVar.getFilteredStatus());
            break;
    }
}
Also used : PinListVariable(net.sourceforge.usbdm.deviceEditor.information.PinListVariable) Status(net.sourceforge.usbdm.deviceEditor.model.Status) Signal(net.sourceforge.usbdm.deviceEditor.information.Signal) LongVariable(net.sourceforge.usbdm.deviceEditor.information.LongVariable) BooleanVariable(net.sourceforge.usbdm.deviceEditor.information.BooleanVariable) DoubleVariable(net.sourceforge.usbdm.deviceEditor.information.DoubleVariable) ChoiceVariable(net.sourceforge.usbdm.deviceEditor.information.ChoiceVariable)

Example 9 with DoubleVariable

use of net.sourceforge.usbdm.deviceEditor.information.DoubleVariable in project usbdm-eclipse-plugins by podonoghue.

the class LptmrValidate method validate.

/**
 * Class to determine LPTMR settings
 * @throws Exception
 */
@Override
public void validate(Variable variable) throws Exception {
    super.validate(variable);
    // System.err.println("LptmrValidate.validate("+variable+")");
    final String osc0_peripheral = getStringVariable("/SIM/osc0_peripheral").getValueAsString();
    // Variables
    // =================================
    DoubleVariable clockFrequencyVar = getDoubleVariable("clockFrequency");
    DoubleVariable clockPeriodVar = getDoubleVariable("clockPeriod");
    DoubleVariable maximumPeriodVar = getDoubleVariable("maximumPeriod");
    Variable lptmr_psr_pcsVar = getVariable("lptmr_psr_pcs");
    BooleanVariable lptmr_psr_pbypVar = getBooleanVariable("lptmr_psr_pbyp");
    Variable lptmr_psr_prescalerVar = getVariable("lptmr_psr_prescaler");
    BooleanVariable lptmr_csr_tmsVar = getBooleanVariable("lptmr_csr_tms");
    Variable lptmr_csr_tpsVar = getVariable("lptmr_csr_tps");
    Variable lptmr_csr_tppVar = getVariable("lptmr_csr_tpp");
    LongVariable lptmr_cmrVar = getLongVariable("lptmr_cmr");
    DoubleVariable lptmr_cmrPeriodVar = getDoubleVariable("lptmr_cmrPeriod");
    DoubleVariable lptmr_cmrFrequencyVar = getDoubleVariable("lptmr_cmrFrequency");
    // Enable/disable parameters that depend on mode
    boolean lptmr_csr_tms = lptmr_csr_tmsVar.getValueAsBoolean();
    lptmr_csr_tpsVar.enable(lptmr_csr_tms);
    lptmr_csr_tppVar.enable(lptmr_csr_tms);
    lptmr_cmrPeriodVar.enable(!lptmr_csr_tms);
    lptmr_cmrFrequencyVar.enable(!lptmr_csr_tms);
    Variable clockSourceVar = null;
    switch((int) lptmr_psr_pcsVar.getValueAsLong()) {
        default:
            lptmr_psr_pcsVar.setValue(0);
        case 0:
            clockSourceVar = getVariable("/MCG/system_mcgirclk_clock[0]");
            break;
        case 1:
            clockSourceVar = getVariable("/MCG/system_low_power_clock");
            break;
        case 2:
            clockSourceVar = getVariable("/SIM/system_erclk32k_clock");
            break;
        case 3:
            clockSourceVar = getVariable(osc0_peripheral + "/oscer_clock");
            break;
    }
    boolean clockChanged = // Initial setup
    (variable == null) || // Clock source selection change
    (variable == lptmr_psr_pcsVar) || // Change in the currently selected clock source
    (variable == clockSourceVar) || // Prescaler bypass
    (variable == lptmr_psr_pbypVar) || // Prescaler changed
    (variable == lptmr_psr_prescalerVar);
    if (variable == lptmr_psr_pbypVar) {
        // Update bypass affected things
        if (lptmr_psr_pbypVar.getValueAsBoolean()) {
            // Clock divider bypassed
            lptmr_psr_prescalerVar.enable(false);
            lptmr_psr_prescalerVar.setOrigin("Disabled by lptmr_psr_pbyp");
            clockFrequencyVar.setOrigin(clockSourceVar.getOrigin());
            clockPeriodVar.setOrigin(clockSourceVar.getOrigin());
        } else {
            // Clock divider used
            lptmr_psr_prescalerVar.enable(true);
            lptmr_psr_prescalerVar.setOrigin(null);
            clockFrequencyVar.setOrigin(clockSourceVar.getOrigin() + " frequency divided by lptmr_psr_prescaler");
            clockPeriodVar.setOrigin(clockSourceVar.getOrigin() + " period multiplied by lptmr_psr_prescaler");
        }
    }
    // Current values
    double clockFrequency = clockSourceVar.getValueAsLong();
    if (!lptmr_psr_pbypVar.getValueAsBoolean()) {
        // Clock divider used
        clockFrequency = clockFrequency / (1L << (lptmr_psr_prescalerVar.getValueAsLong() + 1));
    }
    double clockPeriod = (clockFrequency == 0) ? 0 : (1 / clockFrequency);
    clockFrequencyVar.setStatus(clockSourceVar.getFilteredStatus());
    if (clockChanged) {
        // Update clockFrequency, clockPeriod
        clockFrequencyVar.setValue(clockFrequency);
        clockPeriodVar.setStatus(clockSourceVar.getStatus());
        if (clockFrequency == 0) {
            clockFrequencyVar.enable(false);
            clockPeriodVar.enable(false);
            clockPeriod = 0.0;
            clockPeriodVar.setValue(clockPeriod);
        } else {
            clockFrequencyVar.enable(true);
            clockPeriodVar.enable(true);
            clockPeriod = 1 / clockFrequency;
            clockPeriodVar.setValue(clockPeriod);
        }
    }
    double maximumPeriod = clockPeriod * 65536;
    maximumPeriodVar.setValue(maximumPeriod);
    lptmr_cmrPeriodVar.setMax(maximumPeriod);
    long lptmr_cmr = lptmr_cmrVar.getValueAsLong();
    if (clockChanged) {
        // cmr==0 produced infinity which is OK!
        Double cmrFrequency = clockFrequency / lptmr_cmr;
        Double cmrPeriod = clockPeriod * lptmr_cmr;
        lptmr_cmrPeriodVar.setValue(cmrPeriod);
        lptmr_cmrFrequencyVar.setValue(cmrFrequency);
    } else if (variable != null) {
        if (variable.equals(lptmr_cmrVar)) {
            // cmr==0 produced infinity which is OK!
            Double cmrFrequency = clockFrequency / lptmr_cmr;
            Double cmrPeriod = clockPeriod * lptmr_cmr;
            lptmr_cmrPeriodVar.setValue(cmrPeriod);
            lptmr_cmrFrequencyVar.setValue(cmrFrequency);
        } else if (variable.equals(lptmr_cmrPeriodVar)) {
            // Calculate rounded value
            lptmr_cmr = Math.round(lptmr_cmrPeriodVar.getValueAsDouble() * clockFrequency);
            // cmr==0 produced infinity which is OK!
            Double cmrFrequency = clockFrequency / lptmr_cmr;
            Double cmrPeriod = clockPeriod * lptmr_cmr;
            // Update
            lptmr_cmrVar.setValue(lptmr_cmr);
            // Need to show effect of rounding
            lptmr_cmrPeriodVar.setValue(cmrPeriod);
            lptmr_cmrFrequencyVar.setValue(cmrFrequency);
        } else if (variable.equals(lptmr_cmrFrequencyVar)) {
            // Calculate rounded value
            Double cmrFrequency = lptmr_cmrFrequencyVar.getValueAsDouble();
            if (cmrFrequency <= (clockFrequency / 65535)) {
                lptmr_cmr = 65535;
            } else {
                lptmr_cmr = Math.round(clockFrequency / cmrFrequency);
            }
            // cmr==0 produced infinity which is OK!
            cmrFrequency = clockFrequency / lptmr_cmr;
            Double cmrPeriod = clockPeriod * lptmr_cmr;
            // Update
            lptmr_cmrVar.setValue(lptmr_cmr);
            // Need to show effect of rounding
            lptmr_cmrPeriodVar.setValue(cmrPeriod);
            lptmr_cmrFrequencyVar.setValue(cmrFrequency);
        }
    }
}
Also used : BooleanVariable(net.sourceforge.usbdm.deviceEditor.information.BooleanVariable) DoubleVariable(net.sourceforge.usbdm.deviceEditor.information.DoubleVariable) Variable(net.sourceforge.usbdm.deviceEditor.information.Variable) LongVariable(net.sourceforge.usbdm.deviceEditor.information.LongVariable) LongVariable(net.sourceforge.usbdm.deviceEditor.information.LongVariable) BooleanVariable(net.sourceforge.usbdm.deviceEditor.information.BooleanVariable) DoubleVariable(net.sourceforge.usbdm.deviceEditor.information.DoubleVariable)

Example 10 with DoubleVariable

use of net.sourceforge.usbdm.deviceEditor.information.DoubleVariable in project usbdm-eclipse-plugins by podonoghue.

the class PdbValidate method doDacValidate.

/**
 * Validate a DAC settings
 *
 * @param  variable   Variable that triggered change (may be null)
 * @param  channel    The DAC to validate e.g. 0, 1 etc
 *
 * @throws Exception
 */
void doDacValidate(Variable variable, int channel) throws Exception {
    // In/Out
    BooleanVariable pdb_intXc_toeVar = safeGetBooleanVariable("pdb_int" + channel + "c_toe");
    if (pdb_intXc_toeVar == null) {
        // Dac trigger doesn't exit
        return;
    }
    BooleanVariable pdb_intXc_extVar = getBooleanVariable("pdb_int" + channel + "c_ext");
    LongVariable pdb_intX_intVar = getLongVariable("pdb_int" + channel + "_int");
    // Out/Out
    DoubleVariable pdb_intX_int_delayVar = getDoubleVariable("pdb_int" + channel + "_int_delay");
    boolean triggerEnable = pdb_intXc_toeVar.getRawValueAsBoolean();
    // Do enable/disable first
    pdb_intXc_extVar.enable(triggerEnable);
    pdb_intX_intVar.enable(triggerEnable);
    pdb_intX_int_delayVar.enable(triggerEnable);
    // Get current values
    long pdb_intX_int = pdb_intX_intVar.getRawValueAsLong();
    double pdb_intX_int_delay = pdb_intX_int_delayVar.getRawValueAsDouble();
    if (clockChanged) {
        pdb_intX_int_delayVar.setOrigin(pdbClockOrigin + " period * pdb_int" + channel + "_int");
    }
    if (variable != null) {
        if (variable.equals(pdb_intX_int_delayVar)) {
            // Calculate rounded value
            pdb_intX_int = Math.max(0, Math.round((pdb_intX_int_delay / pdb_period) - 1));
            // Update
            pdb_intX_intVar.setValue(pdb_intX_int);
        // Need to show effect of rounding
        }
    }
    pdb_intX_intVar.setMax(pdb_mod);
    pdb_intX_int_delayVar.setMax((pdb_mod + 1.5) * pdb_period);
    pdb_intX_int_delayVar.setValue(pdb_period * (pdb_intX_int + 1));
}
Also used : LongVariable(net.sourceforge.usbdm.deviceEditor.information.LongVariable) BooleanVariable(net.sourceforge.usbdm.deviceEditor.information.BooleanVariable) DoubleVariable(net.sourceforge.usbdm.deviceEditor.information.DoubleVariable)

Aggregations

DoubleVariable (net.sourceforge.usbdm.deviceEditor.information.DoubleVariable)12 LongVariable (net.sourceforge.usbdm.deviceEditor.information.LongVariable)11 BooleanVariable (net.sourceforge.usbdm.deviceEditor.information.BooleanVariable)7 ChoiceVariable (net.sourceforge.usbdm.deviceEditor.information.ChoiceVariable)4 Variable (net.sourceforge.usbdm.deviceEditor.information.Variable)3 FileNotFoundException (java.io.FileNotFoundException)1 PinListVariable (net.sourceforge.usbdm.deviceEditor.information.PinListVariable)1 Signal (net.sourceforge.usbdm.deviceEditor.information.Signal)1 StringVariable (net.sourceforge.usbdm.deviceEditor.information.StringVariable)1 Status (net.sourceforge.usbdm.deviceEditor.model.Status)1 UsbdmException (net.sourceforge.usbdm.jni.UsbdmException)1