Beispiel #1
0
 TotalOutput makeOutput(PlotYield plotYield, YieldModifier yieldModifier, CommerceModifier commerceModifier, CommerceModifier commercePercent, int scaleFactor)
 {
     // e.g. PlotYield = (2, 2, 3) with YieldModifier(100, 125, 100) (food, hammers, commerce) and CommerceModifier(125, 150, 150, 100) (gold, research, culture, esp)
     // gives TotalOutput = (2 * 100, 2 * 125, 3 * 100 * 125 / 100, 3 * 100 * 150 / 100, 3 * 100 * 150 / 100, 3 * 100 * 100 / 100) =>
     // TotalOutput = (200, 250, 375, 450, 450, 300) (potential output - implies slider at 100% for each type!)
     return makeOutput(plotYield, Commerce(), yieldModifier, commerceModifier, commercePercent, scaleFactor);
 }
/*******************************************************************************//**
* \brief Setup the UART module
*
* > This function is called for setting up the UART module peripheral
*
* > <BR>
* > **Syntax:**<BR>
* >     setupSoftSerial(module, tx_pin, rx_pin, baudrate)
* > <BR><BR>
* > **Parameters:**<BR>
* >     baudrate - desired UART baudrate (supports only standard baudrates)
* > <BR><BR>
* > **Returns:**<BR>
* >     none
* > <BR><BR>
***********************************************************************************/
void setupSoftSerial(enum SoftUARTModules_e eSUARTModule, uint8_t ui8TXPin, uint8_t ui8RXPin, uint16_t ui16Baudrate)
{
    /* Clear TX Buffers */
    stSUART_TXFiFo[eSUARTModule].ui8Head = 0;
    stSUART_TXFiFo[eSUARTModule].ui8Tail = 0;
    stSUART_TXFiFo[eSUARTModule].ui8Pin = ui8TXPin;
    stSUART_TXFiFo[eSUARTModule].ui8TXState = TX_IDLE;
    makeOutput(ui8TXPin);
    setPin(ui8TXPin);
    
    /* Clear RX Buffers */
    stSUART_RXFiFo[eSUARTModule].ui8Head = 0;
    stSUART_RXFiFo[eSUARTModule].ui8Tail = 0;
    stSUART_RXFiFo[eSUARTModule].ui8Pin = ui8RXPin;
    stSUART_RXFiFo[eSUARTModule].blPinVal = HIGH; 
    stSUART_RXFiFo[eSUARTModule].blPrevPinVal = HIGH;
    stSUART_RXFiFo[eSUARTModule].ui8RXState = RX_IDLE;
    makeInput(ui8RXPin);
    
    /* Set Baudrate */
    ui16SUARTBitPeriod_div3 = K_SOFT_SERIAL_POLLING_INTERVAL;
    
    /* Use 16Bit Timer Peripheral */
    setup8BitTimer(K_SUART_TIMER, softUARTController);
    set8BitTimer(K_SUART_TIMER, ui16SUARTBitPeriod_div3);
}
Beispiel #3
0
void testApp::update() {
	ls.clear();

	for(int i = 0; i < n; i++) {
		ofPoint& pt = data[i];
		ls.add(makeInput(pt.x), makeOutput(pt.y));
	}

	ls.removeOutliers(ofMap(mouseX, 0, ofGetWidth(), 4, .1));
}
Beispiel #4
0
void pointFitter::calculateWeights(vector <ofPoint> trackedPoints, vector <ofPoint> knownPoints){
	// calculate the weights for an equation that goes from tracked points to known points.

	int length = trackedPoints.size();
	
	ls.clear();
	
	for(int i = 0; i < length; i++) {
		ofPoint& ipt = trackedPoints[i];
		ofPoint& opt = knownPoints[i];
		ls.add(makeInput(ipt.x, ipt.y), makeOutput(opt.x, opt.y));
	}
	
	bBeenFit = true;
}
Beispiel #5
0
void Output::doOutputNonlinearIteration(Process const& process,
                                        const int process_id,
                                        ProcessOutput const& process_output,
                                        const unsigned timestep, const double t,
                                        GlobalVector const& x,
                                        const unsigned iteration)
{
    if (!_output_nonlinear_iteration_results)
    {
        return;
    }

    BaseLib::RunTime time_output;
    time_output.start();

    processOutputData(t, x, process.getMesh(),
                      process.getDOFTable(process_id),
                      process.getProcessVariables(process_id),
                      process.getSecondaryVariables(),
                      process.getIntegrationPointWriter(),
                      process_output);

    // For the staggered scheme for the coupling, only the last process, which
    // gives the latest solution within a coupling loop, is allowed to make
    // output.
    if (!(process_id == static_cast<int>(_process_to_process_data.size()) - 1 ||
          process.isMonolithicSchemeUsed()))
        return;

    // Only check whether a process data is available for output.
    findProcessData(process, process_id);

    std::string const output_file_name =
        _output_file_prefix + "_pcs_" + std::to_string(process_id) + "_ts_" +
        std::to_string(timestep) + "_t_" + std::to_string(t) + "_nliter_" +
        std::to_string(iteration) + ".vtu";
    std::string const output_file_path =
        BaseLib::joinPaths(_output_directory, output_file_name);

    DBUG("output iteration results to %s", output_file_path.c_str());

    INFO("[time] Output took %g s.", time_output.elapsed());

    makeOutput(output_file_path, process.getMesh(), _output_file_compression,
               _output_file_data_mode);
}
Beispiel #6
0
void Output::doOutputAlways(Process const& process,
                            const int process_id,
                            ProcessOutput const& process_output,
                            unsigned timestep,
                            const double t,
                            GlobalVector const& x)
{
    BaseLib::RunTime time_output;
    time_output.start();

    // Need to add variables of process to vtu even no output takes place.
    processOutputData(t, x, process.getMesh(), process.getDOFTable(process_id),
                      process.getProcessVariables(process_id),
                      process.getSecondaryVariables(),
                      process.getIntegrationPointWriter(),
                      process_output);

    // For the staggered scheme for the coupling, only the last process, which
    // gives the latest solution within a coupling loop, is allowed to make
    // output.
    if (!(process_id == static_cast<int>(_process_to_process_data.size()) - 1 ||
          process.isMonolithicSchemeUsed()))
        return;

    std::string const output_file_name =
        _output_file_prefix + "_pcs_" + std::to_string(process_id) + "_ts_" +
        std::to_string(timestep) + "_t_" + std::to_string(t) + ".vtu";
    std::string const output_file_path =
        BaseLib::joinPaths(_output_directory, output_file_name);

    DBUG("output to %s", output_file_path.c_str());

    ProcessData* process_data = findProcessData(process, process_id);
    process_data->pvd_file.addVTUFile(output_file_name, t);
    INFO("[time] Output of timestep %d took %g s.", timestep,
         time_output.elapsed());

    makeOutput(output_file_path, process.getMesh(), _output_file_compression,
               _output_file_data_mode);
}
Beispiel #7
0
void makeMathOutput(void)
{ makeOutput(startMath,diagramMath,endMath);}
Beispiel #8
0
void makeReduceOutput(void)
{  makeOutput(startReduce,diagramReduce,endReduce);}
Beispiel #9
0
constexpr decltype(MPL::list(makeOutput(T{}),makeOutput(U{}),makeOutput(Ts{})...))
makeOutput(T,U,Ts...) {
    return {};
}