<commit_before>
// =================================================================================================
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
// width of 100 characters per line.
//
// Author(s):
//   Cedric Nugteren <www.cedricnugteren.nl>
//
// This file implements the triangular matrix solver (A * X = B) TRSM class. This code is based
// on the TRSM implementation in the CUDA version of Magma version 2.2.0 and the poster "Triangular
// Linear System Solver for GPU with CUDA and OpenCL" by Peng Du, Stanimire Tomov, Piotr Luszczek,
// and Jack Dongarra and the OpenCL implementation in clBLAS.
//
// =================================================================================================

#include "routines/level3/xtrsm.hpp"
#include "routines/levelx/xinvert.hpp"

#include <string>
#include <vector>

namespace clblast {
// =================================================================================================

// Constructor: forwards to base class constructor
template <typename T>
Xtrsm<T>::Xtrsm(Queue &queue, EventPointer event, const std::string &name):
    Xgemm<T>(queue, event, name) {
}

// =================================================================================================

// The entry point: transforming into col-major (if needed) and then running the col-major version
template <typename T>
void Xtrsm<T>::DoTrsm(const Layout layout, Side side, Triangle triangle,
                      const Transpose a_transpose, const Diagonal diagonal,
                      size_t m, size_t n,
                      const T alpha,
                      const Buffer<T> &a_buffer, const size_t a_offset, const size_t a_ld,
                      const Buffer<T> &b_buffer, const size_t b_offset, const size_t b_ld) {

  // Converts row-major to a col-major problem:
  // The idea is that
  //   B = A*X
  // can be computed as
  //   B' = (A*X)' = X'*A'
  // Since changing the order is basically a transpose on each matrix, the formula becomes:
  //   B = X*A
  // So only the side (left/right) and the triangle (upper/lower) are changed and M/N are swapped
  if (layout == Layout::kRowMajor) {
    std::swap(m, n);
    side = (side == Side::kLeft) ? Side::kRight : Side::kLeft;
    triangle = (triangle == Triangle::kLower) ? Triangle::kUpper : Triangle::kLower;
  }

  // Runs the col-major version of TRSM
  TrsmColMajor(side, triangle, a_transpose, diagonal,
               m, n, alpha,
               a_buffer, a_offset, a_ld,
               b_buffer, b_offset, b_ld);
}

// =================================================================================================

// The main routine
template <typename T>
void Xtrsm<T>::TrsmColMajor(const Side side, const Triangle triangle,
                            const Transpose a_transpose, const Diagonal diagonal,
                            const size_t m, const size_t n,
                            const T alpha,
                            const Buffer<T> &a_buffer, const size_t a_offset, const size_t a_ld,
                            const Buffer<T> &b_buffer, const size_t b_offset, const size_t b_ld) {

  // Settings
  constexpr auto block_size = size_t{32}; // tuneable

  // Makes sure all dimensions are larger than zero
  if ((m == 0) || (n == 0)) { throw BLASError(StatusCode::kInvalidDimension); }

  // Computes the k dimension. This is based on whether or not matrix is A (on the left)
  // or B (on the right) in the Xgemm routine.
  const auto k = (side == Side::kLeft) ? m : n;

  // Checks for validity of the triangular A matrix
  TestMatrixA(k, k, a_buffer, a_offset, a_ld);

  // Checks for validity of the input B matrix
  TestMatrixB(m, n, b_buffer, b_offset, b_ld);

  // Creates a copy of B to avoid overwriting input in GEMM while computing output
  const auto b_size = b_ld * (n - 1) + m + b_offset;
  const auto x_one = m;
  const auto x_two = n;
  const auto x_size = b_size;
  const auto x_ld = b_ld;
  const auto x_offset = b_offset;
  auto x_buffer = Buffer<T>(context_, x_size);
  b_buffer.CopyTo(queue_, x_size, x_buffer);

  // Temporary buffer for the inverse of the A matrix
  const auto a_inv_size = Ceil(k, block_size) * block_size;
  auto a_inv_buffer = Buffer<T>(context_, a_inv_size);

  // Fills the output buffer with zeros
  auto eventWaitList = std::vector<Event>();
  auto fill_matrix_event = Event();
  FillMatrix(queue_, device_, program_, db_, fill_matrix_event.pointer(), eventWaitList,
             x_one, x_two, x_ld, x_offset, x_buffer, ConstantZero<T>());
  fill_matrix_event.WaitForCompletion();

  // Inverts the diagonal blocks
  auto diagonal_invert_event = Event();
  auto inverter = Xinvert<T>(queue_, diagonal_invert_event.pointer());
  inverter.InvertMatrixDiagonalBlocks(Layout::kColMajor, triangle, diagonal,
                                      k, block_size, a_buffer, a_offset, a_ld, a_inv_buffer);
  diagonal_invert_event.WaitForCompletion();

  // Derives properties based on the arguments
  const auto condition = ((triangle == Triangle::kUpper && a_transpose != Transpose::kNo) ||
                          (triangle == Triangle::kLower && a_transpose == Transpose::kNo));

  // Left side
  if (side == Side::kLeft) {

    // True when (lower triangular) or (upper triangular and transposed)
    if (condition) {
      for (auto i = size_t{0}; i < m; i += block_size) {
        const auto gemm_alpha = (i == 0) ? alpha : ConstantOne<T>();
        const auto current_block_size = std::min(m - i, block_size);
        DoGemm(Layout::kColMajor, a_transpose, Transpose::kNo,
               current_block_size, n, current_block_size, gemm_alpha,
               a_inv_buffer, i * block_size, block_size,
               b_buffer, b_offset + i, b_ld, ConstantZero<T>(),
               x_buffer, x_offset + i, x_ld);
        if (i + block_size >= m) { break; }
        const auto this_a_offset = (a_transpose == Transpose::kNo) ? (i + block_size) + i * a_ld : i + (block_size + i) * a_ld;
        DoGemm(Layout::kColMajor, a_transpose, Transpose::kNo,
               m - i - block_size, n, block_size, ConstantNegOne<T>(),
               a_buffer, this_a_offset, a_ld,
               x_buffer, x_offset + i, x_ld, gemm_alpha,
               b_buffer, b_offset + i + block_size, b_ld);
      }
    }

    // True when (upper triangular) or (lower triangular and transposed)
    else {
      const auto current_block_size = (m % block_size == 0) ? block_size : (m % block_size);
      const auto i_start = static_cast<int>(m) - static_cast<int>(current_block_size);
      for (auto i = i_start; i >= 0; i -= static_cast<int>(block_size)) {
        const auto gemm_alpha = (i == i_start) ? alpha : ConstantOne<T>();
        DoGemm(Layout::kColMajor, a_transpose, Transpose::kNo,
               current_block_size, n, current_block_size, gemm_alpha,
               a_inv_buffer, i * block_size, block_size,
               b_buffer, b_offset + i, b_ld, ConstantZero<T>(),
               x_buffer, x_offset + i, x_ld);
        if (i - static_cast<int>(block_size) < 0) { break; }
        const auto this_a_offset = (a_transpose == Transpose::kNo) ? i * a_ld : i;
        DoGemm(Layout::kColMajor, a_transpose, Transpose::kNo,
               i, n, block_size, ConstantNegOne<T>(),
               a_buffer, this_a_offset, a_ld,
               x_buffer, x_offset + i, x_ld, gemm_alpha,
               b_buffer, b_offset, b_ld);
      }
    }
  }

  // Right side
  else {

    // True when (lower triangular) or (upper triangular and transposed)
    if (condition) {
      const auto current_block_size = (n % block_size == 0) ? block_size : (n % block_size);
      const auto i_start = static_cast<int>(n) - static_cast<int>(current_block_size);
      for (auto i = i_start; i >= 0; i -= static_cast<int>(block_size)) {
        const auto gemm_alpha = (i == i_start) ? alpha : ConstantOne<T>();
        DoGemm(Layout::kColMajor, Transpose::kNo, a_transpose,
               m, current_block_size, current_block_size, gemm_alpha,
               b_buffer, b_offset + i * b_ld, b_ld,
               a_inv_buffer, i * block_size, block_size, ConstantZero<T>(),
               x_buffer, x_offset + i * x_ld, x_ld);
        if (i - static_cast<int>(block_size) < 0) { break; }
        const auto this_a_offset = (a_transpose == Transpose::kNo) ? i : i * a_ld;
        DoGemm(Layout::kColMajor, Transpose::kNo, a_transpose,
               m, i, block_size, ConstantNegOne<T>(),
               x_buffer, x_offset + i * x_ld, x_ld,
               a_buffer, this_a_offset, a_ld, gemm_alpha,
               b_buffer, b_offset, b_ld);
      }
    }

    // True when (upper triangular) or (lower triangular and transposed)
    else {
      for (auto i = size_t{0}; i < n; i += block_size) {
        const auto gemm_alpha = (i == 0) ? alpha : ConstantOne<T>();
        const auto current_block_size = std::min(n - i, block_size);
        DoGemm(Layout::kColMajor, Transpose::kNo, a_transpose,
               m, current_block_size, current_block_size, gemm_alpha,
               b_buffer, b_offset + i * b_ld, b_ld,
               a_inv_buffer, i * block_size, block_size, ConstantZero<T>(),
               x_buffer, x_offset + i * x_ld, x_ld);
        if (i + block_size >= n) { break; }
        const auto this_a_offset = (a_transpose == Transpose::kNo) ? i + (block_size + i) * a_ld : (i + block_size) + i * a_ld;
        DoGemm(Layout::kColMajor, Transpose::kNo, a_transpose,
               m, n - i - block_size, block_size, ConstantNegOne<T>(),
               x_buffer, x_offset + i * x_ld, x_ld,
               a_buffer, this_a_offset, a_ld, gemm_alpha,
               b_buffer, b_offset + (i + block_size) * b_ld, b_ld);
      }
    }
  }

  // Retrieves the results
  x_buffer.CopyTo(queue_, b_size, b_buffer);
}

// =================================================================================================

// Compiles the templated class
template class Xtrsm<half>;
template class Xtrsm<float>;
template class Xtrsm<double>;
template class Xtrsm<float2>;
template class Xtrsm<double2>;

// =================================================================================================
} // namespace clblast
<commit_msg>Fixed an TRSM issue caused by incorrect block size calculation<commit_after>
// =================================================================================================
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
// width of 100 characters per line.
//
// Author(s):
//   Cedric Nugteren <www.cedricnugteren.nl>
//
// This file implements the triangular matrix solver (A * X = B) TRSM class. This code is based
// on the TRSM implementation in the CUDA version of Magma version 2.2.0 and the poster "Triangular
// Linear System Solver for GPU with CUDA and OpenCL" by Peng Du, Stanimire Tomov, Piotr Luszczek,
// and Jack Dongarra and the OpenCL implementation in clBLAS.
//
// =================================================================================================

#include "routines/level3/xtrsm.hpp"
#include "routines/levelx/xinvert.hpp"

#include <string>
#include <vector>

namespace clblast {
// =================================================================================================

// Constructor: forwards to base class constructor
template <typename T>
Xtrsm<T>::Xtrsm(Queue &queue, EventPointer event, const std::string &name):
    Xgemm<T>(queue, event, name) {
}

// =================================================================================================

// The entry point: transforming into col-major (if needed) and then running the col-major version
template <typename T>
void Xtrsm<T>::DoTrsm(const Layout layout, Side side, Triangle triangle,
                      const Transpose a_transpose, const Diagonal diagonal,
                      size_t m, size_t n,
                      const T alpha,
                      const Buffer<T> &a_buffer, const size_t a_offset, const size_t a_ld,
                      const Buffer<T> &b_buffer, const size_t b_offset, const size_t b_ld) {

  // Converts row-major to a col-major problem:
  // The idea is that
  //   B = A*X
  // can be computed as
  //   B' = (A*X)' = X'*A'
  // Since changing the order is basically a transpose on each matrix, the formula becomes:
  //   B = X*A
  // So only the side (left/right) and the triangle (upper/lower) are changed and M/N are swapped
  if (layout == Layout::kRowMajor) {
    std::swap(m, n);
    side = (side == Side::kLeft) ? Side::kRight : Side::kLeft;
    triangle = (triangle == Triangle::kLower) ? Triangle::kUpper : Triangle::kLower;
  }

  // Runs the col-major version of TRSM
  TrsmColMajor(side, triangle, a_transpose, diagonal,
               m, n, alpha,
               a_buffer, a_offset, a_ld,
               b_buffer, b_offset, b_ld);
}

// =================================================================================================

// The main routine
template <typename T>
void Xtrsm<T>::TrsmColMajor(const Side side, const Triangle triangle,
                            const Transpose a_transpose, const Diagonal diagonal,
                            const size_t m, const size_t n,
                            const T alpha,
                            const Buffer<T> &a_buffer, const size_t a_offset, const size_t a_ld,
                            const Buffer<T> &b_buffer, const size_t b_offset, const size_t b_ld) {

  // Settings
  constexpr auto block_size = size_t{32}; // tuneable

  // Makes sure all dimensions are larger than zero
  if ((m == 0) || (n == 0)) { throw BLASError(StatusCode::kInvalidDimension); }

  // Computes the k dimension. This is based on whether or not matrix is A (on the left)
  // or B (on the right) in the Xgemm routine.
  const auto k = (side == Side::kLeft) ? m : n;

  // Checks for validity of the triangular A matrix
  TestMatrixA(k, k, a_buffer, a_offset, a_ld);

  // Checks for validity of the input B matrix
  TestMatrixB(m, n, b_buffer, b_offset, b_ld);

  // Creates a copy of B to avoid overwriting input in GEMM while computing output
  const auto b_size = b_ld * (n - 1) + m + b_offset;
  const auto x_one = m;
  const auto x_two = n;
  const auto x_size = b_size;
  const auto x_ld = b_ld;
  const auto x_offset = b_offset;
  auto x_buffer = Buffer<T>(context_, x_size);
  b_buffer.CopyTo(queue_, x_size, x_buffer);

  // Temporary buffer for the inverse of the A matrix
  const auto a_inv_size = Ceil(k, block_size) * block_size;
  auto a_inv_buffer = Buffer<T>(context_, a_inv_size);

  // Fills the output buffer with zeros
  auto eventWaitList = std::vector<Event>();
  auto fill_matrix_event = Event();
  FillMatrix(queue_, device_, program_, db_, fill_matrix_event.pointer(), eventWaitList,
             x_one, x_two, x_ld, x_offset, x_buffer, ConstantZero<T>());
  fill_matrix_event.WaitForCompletion();

  // Inverts the diagonal blocks
  auto diagonal_invert_event = Event();
  auto inverter = Xinvert<T>(queue_, diagonal_invert_event.pointer());
  inverter.InvertMatrixDiagonalBlocks(Layout::kColMajor, triangle, diagonal,
                                      k, block_size, a_buffer, a_offset, a_ld, a_inv_buffer);
  diagonal_invert_event.WaitForCompletion();

  // Derives properties based on the arguments
  const auto condition = ((triangle == Triangle::kUpper && a_transpose != Transpose::kNo) ||
                          (triangle == Triangle::kLower && a_transpose == Transpose::kNo));

  // Left side
  if (side == Side::kLeft) {

    // True when (lower triangular) or (upper triangular and transposed)
    if (condition) {
      for (auto i = size_t{0}; i < m; i += block_size) {
        const auto gemm_alpha = (i == 0) ? alpha : ConstantOne<T>();
        const auto current_block_size = std::min(m - i, block_size);
        DoGemm(Layout::kColMajor, a_transpose, Transpose::kNo,
               current_block_size, n, current_block_size, gemm_alpha,
               a_inv_buffer, i * block_size, block_size,
               b_buffer, b_offset + i, b_ld, ConstantZero<T>(),
               x_buffer, x_offset + i, x_ld);
        if (i + block_size >= m) { break; }
        const auto this_a_offset = (a_transpose == Transpose::kNo) ? (i + block_size) + i * a_ld : i + (block_size + i) * a_ld;
        DoGemm(Layout::kColMajor, a_transpose, Transpose::kNo,
               m - i - block_size, n, block_size, ConstantNegOne<T>(),
               a_buffer, this_a_offset, a_ld,
               x_buffer, x_offset + i, x_ld, gemm_alpha,
               b_buffer, b_offset + i + block_size, b_ld);
      }
    }

    // True when (upper triangular) or (lower triangular and transposed)
    else {
      const auto special_block_size = (m % block_size == 0) ? block_size : (m % block_size);
      const auto i_start = static_cast<int>(m) - static_cast<int>(special_block_size);
      for (auto i = i_start; i >= 0; i -= static_cast<int>(block_size)) {
        const auto current_block_size = (i == i_start) ? special_block_size : block_size;
        const auto gemm_alpha = (i == i_start) ? alpha : ConstantOne<T>();
        DoGemm(Layout::kColMajor, a_transpose, Transpose::kNo,
               current_block_size, n, current_block_size, gemm_alpha,
               a_inv_buffer, i * block_size, block_size,
               b_buffer, b_offset + i, b_ld, ConstantZero<T>(),
               x_buffer, x_offset + i, x_ld);
        if (i - static_cast<int>(block_size) < 0) { break; }
        const auto this_a_offset = (a_transpose == Transpose::kNo) ? i * a_ld : i;
        DoGemm(Layout::kColMajor, a_transpose, Transpose::kNo,
               i, n, current_block_size, ConstantNegOne<T>(),
               a_buffer, this_a_offset, a_ld,
               x_buffer, x_offset + i, x_ld, gemm_alpha,
               b_buffer, b_offset, b_ld);
      }
    }
  }

  // Right side
  else {

    // True when (lower triangular) or (upper triangular and transposed)
    if (condition) {
      const auto special_block_size = (n % block_size == 0) ? block_size : (n % block_size);
      const auto i_start = static_cast<int>(n) - static_cast<int>(special_block_size);
      for (auto i = i_start; i >= 0; i -= static_cast<int>(block_size)) {
        const auto current_block_size = (i == i_start) ? special_block_size : block_size;
        const auto gemm_alpha = (i == i_start) ? alpha : ConstantOne<T>();
        DoGemm(Layout::kColMajor, Transpose::kNo, a_transpose,
               m, current_block_size, current_block_size, gemm_alpha,
               b_buffer, b_offset + i * b_ld, b_ld,
               a_inv_buffer, i * block_size, block_size, ConstantZero<T>(),
               x_buffer, x_offset + i * x_ld, x_ld);
        if (i - static_cast<int>(block_size) < 0) { break; }
        const auto this_a_offset = (a_transpose == Transpose::kNo) ? i : i * a_ld;
        DoGemm(Layout::kColMajor, Transpose::kNo, a_transpose,
               m, i, current_block_size, ConstantNegOne<T>(),
               x_buffer, x_offset + i * x_ld, x_ld,
               a_buffer, this_a_offset, a_ld, gemm_alpha,
               b_buffer, b_offset, b_ld);
      }
    }

    // True when (upper triangular) or (lower triangular and transposed)
    else {
      for (auto i = size_t{0}; i < n; i += block_size) {
        const auto gemm_alpha = (i == 0) ? alpha : ConstantOne<T>();
        const auto current_block_size = std::min(n - i, block_size);
        DoGemm(Layout::kColMajor, Transpose::kNo, a_transpose,
               m, current_block_size, current_block_size, gemm_alpha,
               b_buffer, b_offset + i * b_ld, b_ld,
               a_inv_buffer, i * block_size, block_size, ConstantZero<T>(),
               x_buffer, x_offset + i * x_ld, x_ld);
        if (i + block_size >= n) { break; }
        const auto this_a_offset = (a_transpose == Transpose::kNo) ? i + (block_size + i) * a_ld : (i + block_size) + i * a_ld;
        DoGemm(Layout::kColMajor, Transpose::kNo, a_transpose,
               m, n - i - block_size, block_size, ConstantNegOne<T>(),
               x_buffer, x_offset + i * x_ld, x_ld,
               a_buffer, this_a_offset, a_ld, gemm_alpha,
               b_buffer, b_offset + (i + block_size) * b_ld, b_ld);
      }
    }
  }

  // Retrieves the results
  x_buffer.CopyTo(queue_, b_size, b_buffer);
}

// =================================================================================================

// Compiles the templated class
template class Xtrsm<half>;
template class Xtrsm<float>;
template class Xtrsm<double>;
template class Xtrsm<float2>;
template class Xtrsm<double2>;

// =================================================================================================
} // namespace clblast
<|endoftext|>


<commit_before>/* This file is part of Ingen.
 * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
 *
 * Ingen is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "config.h"
#include "App.h"
#include <cassert>
#include <string>
#include <fstream>
#include <libgnomecanvasmm.h>
#include <time.h>
#include <sys/time.h>
#include <raul/Path.h>
#include "interface/EngineInterface.h"
#include "client/ObjectModel.h"
#include "client/PatchModel.h"
#include "client/Store.h"
#include "NodeModule.h"
#include "ControlPanel.h"
#include "SubpatchModule.h"
#include "LoadPluginWindow.h"
#include "PatchWindow.h"
#include "MessagesWindow.h"
#include "ConfigWindow.h"
#include "GladeFactory.h"
#include "PatchTreeWindow.h"
#include "Configuration.h"
#include "ConnectWindow.h"
#include "ThreadedLoader.h"
#include "WindowFactory.h"
#ifdef HAVE_LASH
#include "LashController.h"
#endif
using std::cerr; using std::cout; using std::endl;
using std::string;
namespace Ingen { namespace Client { class PluginModel; } }
using namespace Ingen::Client;

namespace Ingen {
namespace GUI {

class Port;

/// Singleton instance
App* App::_instance = 0;

App::App()
: _configuration(new Configuration()),
  _about_dialog(NULL),
  _window_factory(new WindowFactory()),
  _enable_signal(true)
{
	Glib::RefPtr<Gnome::Glade::Xml> glade_xml = GladeFactory::new_glade_reference();

	glade_xml->get_widget_derived("connect_win", _connect_window);
	glade_xml->get_widget_derived("messages_win", _messages_window);
	glade_xml->get_widget_derived("patch_tree_win", _patch_tree_window);
	glade_xml->get_widget_derived("config_win", _config_window);
	glade_xml->get_widget("about_win", _about_dialog);

	_rdf_world.add_prefix("xsd", "http://www.w3.org/2001/XMLSchema#");
	_rdf_world.add_prefix("ingen", "http://drobilla.net/ns/ingen#");
	_rdf_world.add_prefix("ingenuity", "http://drobilla.net/ns/ingenuity#");
	_rdf_world.add_prefix("lv2", "http://lv2plug.in/ontology#");
	_rdf_world.add_prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
	_rdf_world.add_prefix("doap", "http://usefulinc.com/ns/doap#");

	_config_window->configuration(_configuration);

#ifdef HAVE_SLV2
	SLV2World slv2_world = slv2_world_new_using_rdf_world(_rdf_world.world());
	PluginModel::set_slv2_world(slv2_world);
#endif
}

App::~App()
{
}

void
App::run(int argc, char** argv,
		SharedPtr<Engine> engine,
		SharedPtr<Shared::EngineInterface> interface)
{
	Gnome::Canvas::init();
	Gtk::Main main(argc, argv);

	if (!_instance)
		_instance = new App();

	/* Load settings */
	_instance->configuration()->load_settings();
	_instance->configuration()->apply_settings();

	if (Glib::file_test(PKGDATADIR "/ingen.svg", Glib::FILE_TEST_EXISTS))
		Gtk::Window::set_default_icon_from_file(PKGDATADIR "/ingen.svg");

	App::instance().connect_window()->start(engine, interface);

	main.run();
}

void
App::attach(const SharedPtr<EngineInterface>& engine, const SharedPtr<SigClientInterface>& client)
{
	assert( ! _engine);
	assert( ! _client);
	assert( ! _store);
	assert( ! _loader);

	_engine = engine;
	_client = client;
	_store = SharedPtr<Store>(new Store(engine, client));
	_loader = SharedPtr<ThreadedLoader>(new ThreadedLoader(engine));

	_patch_tree_window->init(*_store);
}

void
App::detach()
{
	if (_engine) {
		_window_factory->clear();
		_store->clear();

		_loader.reset();
		_store.reset();
		_client.reset();
		_engine.reset();
	}
}

void
App::error_message(const string& str)
{
	_messages_window->post(str);
	_messages_window->show();
	_messages_window->raise();
}

/*
bool
App::idle_callback()
{
	_client_hooks->process_events();

#ifdef HAVE_LASH
	//if (lash_controller->enabled())
	//	lash_controller->process_events();
#endif

	return true;
}
*/

/******** Event Handlers ************/

#if 0
App::event_load_session()
{
	Gtk::FileChooserDialog* dialog
		= new Gtk::FileChooserDialog(*_main_window, "Load Session", Gtk::FILE_CHOOSER_ACTION_OPEN);

	dialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
	dialog->add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
	int result = dialog->run();
	string filename = dialog->get_filename();
	delete dialog;

	cout << result << endl;

	assert(result == Gtk::RESPONSE_OK || result == Gtk::RESPONSE_CANCEL || result == Gtk::RESPONSE_NONE);

	if (result == Gtk::RESPONSE_OK)
		//configuration->load_session(filename);
		_controller->load_session(filename);
}

void
App::event_save_session_as()
{
	Gtk::FileChooserDialog dialog(*_main_window, "Save Session", Gtk::FILE_CHOOSER_ACTION_SAVE);

	/*
	Gtk::VBox* box = dialog.get_vbox();
	Gtk::Label warning("Warning:  Recursively saving will overwrite any subpatch files \
		without confirmation.");
	box->pack_start(warning, false, false, 2);
	Gtk::CheckButton recursive_checkbutton("Recursively save all subpatches");
	box->pack_start(recursive_checkbutton, false, false, 0);
	recursive_checkbutton.show();
	*/
	dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
	dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);

	int result = dialog.run();
	//bool recursive = recursive_checkbutton.get_active();

	assert(result == Gtk::RESPONSE_OK || result == Gtk::RESPONSE_CANCEL || result == Gtk::RESPONSE_NONE);

	if (result == Gtk::RESPONSE_OK) {
		string filename = dialog.get_filename();
		if (filename.length() < 11 || filename.substr(filename.length()-10) != ".omsession")
			filename += ".omsession";

		bool confirm = false;
		std::fstream fin;
		fin.open(filename.c_str(), std::ios::in);
		if (fin.is_open()) {  // File exists
			string msg = "File already exists!  Are you sure you want to overwrite ";
			msg += filename + "?";
			Gtk::MessageDialog confir_dialog(*_main_window,
				msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true);
			if (confir_dialog.run() == Gtk::RESPONSE_YES)
				confirm = true;
			else
				confirm = false;
		} else {  // File doesn't exist
			confirm = true;
		}
		fin.close();

		if (confirm) {
			_controller->save_session(filename);
		}
	}
}
#endif

void
App::quit()
{
	Gtk::Main::quit();
}

} // namespace GUI
} // namespace Ingen

<commit_msg>Gracefully handle inability to load window icon (SVG).<commit_after>/* This file is part of Ingen.
 * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
 *
 * Ingen is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "config.h"
#include "App.h"
#include <cassert>
#include <string>
#include <fstream>
#include <libgnomecanvasmm.h>
#include <time.h>
#include <sys/time.h>
#include <raul/Path.h>
#include "interface/EngineInterface.h"
#include "client/ObjectModel.h"
#include "client/PatchModel.h"
#include "client/Store.h"
#include "NodeModule.h"
#include "ControlPanel.h"
#include "SubpatchModule.h"
#include "LoadPluginWindow.h"
#include "PatchWindow.h"
#include "MessagesWindow.h"
#include "ConfigWindow.h"
#include "GladeFactory.h"
#include "PatchTreeWindow.h"
#include "Configuration.h"
#include "ConnectWindow.h"
#include "ThreadedLoader.h"
#include "WindowFactory.h"
#ifdef HAVE_LASH
#include "LashController.h"
#endif
using std::cerr; using std::cout; using std::endl;
using std::string;
namespace Ingen { namespace Client { class PluginModel; } }
using namespace Ingen::Client;

namespace Ingen {
namespace GUI {

class Port;

/// Singleton instance
App* App::_instance = 0;

App::App()
: _configuration(new Configuration()),
  _about_dialog(NULL),
  _window_factory(new WindowFactory()),
  _enable_signal(true)
{
	Glib::RefPtr<Gnome::Glade::Xml> glade_xml = GladeFactory::new_glade_reference();

	glade_xml->get_widget_derived("connect_win", _connect_window);
	glade_xml->get_widget_derived("messages_win", _messages_window);
	glade_xml->get_widget_derived("patch_tree_win", _patch_tree_window);
	glade_xml->get_widget_derived("config_win", _config_window);
	glade_xml->get_widget("about_win", _about_dialog);

	_rdf_world.add_prefix("xsd", "http://www.w3.org/2001/XMLSchema#");
	_rdf_world.add_prefix("ingen", "http://drobilla.net/ns/ingen#");
	_rdf_world.add_prefix("ingenuity", "http://drobilla.net/ns/ingenuity#");
	_rdf_world.add_prefix("lv2", "http://lv2plug.in/ontology#");
	_rdf_world.add_prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
	_rdf_world.add_prefix("doap", "http://usefulinc.com/ns/doap#");

	_config_window->configuration(_configuration);

#ifdef HAVE_SLV2
	SLV2World slv2_world = slv2_world_new_using_rdf_world(_rdf_world.world());
	PluginModel::set_slv2_world(slv2_world);
#endif
}

App::~App()
{
}

void
App::run(int argc, char** argv,
		SharedPtr<Engine> engine,
		SharedPtr<Shared::EngineInterface> interface)
{
	Gnome::Canvas::init();
	Gtk::Main main(argc, argv);

	if (!_instance)
		_instance = new App();

	/* Load settings */
	_instance->configuration()->load_settings();
	_instance->configuration()->apply_settings();

	const Glib::ustring icon_path = PKGDATADIR "/ingen.svg";
	try {
		if (Glib::file_test(icon_path, Glib::FILE_TEST_EXISTS))
			Gtk::Window::set_default_icon_from_file(icon_path);
	} catch (Gdk::PixbufError err) {
		cerr << "Unable to load window icon " << icon_path << ": " << err.what() << endl;
	}

	App::instance().connect_window()->start(engine, interface);

	main.run();
}

void
App::attach(const SharedPtr<EngineInterface>& engine, const SharedPtr<SigClientInterface>& client)
{
	assert( ! _engine);
	assert( ! _client);
	assert( ! _store);
	assert( ! _loader);

	_engine = engine;
	_client = client;
	_store = SharedPtr<Store>(new Store(engine, client));
	_loader = SharedPtr<ThreadedLoader>(new ThreadedLoader(engine));

	_patch_tree_window->init(*_store);
}

void
App::detach()
{
	if (_engine) {
		_window_factory->clear();
		_store->clear();

		_loader.reset();
		_store.reset();
		_client.reset();
		_engine.reset();
	}
}

void
App::error_message(const string& str)
{
	_messages_window->post(str);
	_messages_window->show();
	_messages_window->raise();
}

/*
bool
App::idle_callback()
{
	_client_hooks->process_events();

#ifdef HAVE_LASH
	//if (lash_controller->enabled())
	//	lash_controller->process_events();
#endif

	return true;
}
*/

/******** Event Handlers ************/

#if 0
App::event_load_session()
{
	Gtk::FileChooserDialog* dialog
		= new Gtk::FileChooserDialog(*_main_window, "Load Session", Gtk::FILE_CHOOSER_ACTION_OPEN);

	dialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
	dialog->add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
	int result = dialog->run();
	string filename = dialog->get_filename();
	delete dialog;

	cout << result << endl;

	assert(result == Gtk::RESPONSE_OK || result == Gtk::RESPONSE_CANCEL || result == Gtk::RESPONSE_NONE);

	if (result == Gtk::RESPONSE_OK)
		//configuration->load_session(filename);
		_controller->load_session(filename);
}

void
App::event_save_session_as()
{
	Gtk::FileChooserDialog dialog(*_main_window, "Save Session", Gtk::FILE_CHOOSER_ACTION_SAVE);

	/*
	Gtk::VBox* box = dialog.get_vbox();
	Gtk::Label warning("Warning:  Recursively saving will overwrite any subpatch files \
		without confirmation.");
	box->pack_start(warning, false, false, 2);
	Gtk::CheckButton recursive_checkbutton("Recursively save all subpatches");
	box->pack_start(recursive_checkbutton, false, false, 0);
	recursive_checkbutton.show();
	*/
	dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
	dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);

	int result = dialog.run();
	//bool recursive = recursive_checkbutton.get_active();

	assert(result == Gtk::RESPONSE_OK || result == Gtk::RESPONSE_CANCEL || result == Gtk::RESPONSE_NONE);

	if (result == Gtk::RESPONSE_OK) {
		string filename = dialog.get_filename();
		if (filename.length() < 11 || filename.substr(filename.length()-10) != ".omsession")
			filename += ".omsession";

		bool confirm = false;
		std::fstream fin;
		fin.open(filename.c_str(), std::ios::in);
		if (fin.is_open()) {  // File exists
			string msg = "File already exists!  Are you sure you want to overwrite ";
			msg += filename + "?";
			Gtk::MessageDialog confir_dialog(*_main_window,
				msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true);
			if (confir_dialog.run() == Gtk::RESPONSE_YES)
				confirm = true;
			else
				confirm = false;
		} else {  // File doesn't exist
			confirm = true;
		}
		fin.close();

		if (confirm) {
			_controller->save_session(filename);
		}
	}
}
#endif

void
App::quit()
{
	Gtk::Main::quit();
}

} // namespace GUI
} // namespace Ingen

<|endoftext|>


<commit_before>// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html

#include <bse/bseresampler.hh>
#include <bse/bsemathsignal.hh>
#include <bse/bsemain.hh>
#include <bse/bseblockutils.hh>
#include <bse/gslfft.hh>
#include <sfi/sfitests.hh>
#include <sfi/sfi.hh>
#include <stdlib.h>
#include <stdio.h>

using namespace Bse;

using Bse::Resampler::Resampler2;
using Bse::AlignedArray;
using std::vector;
using std::max;
using std::min;

struct Options
{
  size_t test_size;
  size_t rand_samples;
  // default test parameters
  Options() :
    test_size (512),
    rand_samples (64)
  {
  }
} options;

class ResamplerTest
{
public:
  double passband_err;
  double stopband_err;
  double max_error;

  void  check_spectrum (const vector<float>& impulse_response, int p);
  void  check_resampler_up (BseResampler2Precision precision);
  void  check_resampler_down (BseResampler2Precision precision);
};

void
ResamplerTest::check_spectrum (const vector<float>& impulse_response, int p)
{
  vector<double> fft_in (4096), spect (fft_in.size());

  for (size_t i = 0; i < min (impulse_response.size(), fft_in.size()); i++)
    {
      fft_in[i] = impulse_response[i] / 2;
    }
  gsl_power2_fftar (fft_in.size(), &fft_in[0], &spect[0]);
  spect[1] = 0; // special packing

  passband_err = 0;
  stopband_err = 0;

  for (size_t i = 0; i < 4096; i += 2)
    {
      const double re = spect[i], im = spect[i + 1];
      const double mag = sqrt (re * re + im * im);
      const double freq = i * 44100.0 / 4096;
      if (freq < 18000)
        passband_err = max (passband_err, fabs (1 - mag));
      if (freq > 26100)
        stopband_err = max (stopband_err, fabs (mag));
    }
}

void
ResamplerTest::check_resampler_up (BseResampler2Precision precision)
{
  Resampler2 *ups = Resampler2::create (BSE_RESAMPLER2_MODE_UPSAMPLE, precision);
  AlignedArray<float,16> input (options.test_size);
  AlignedArray<float,16> output (options.test_size * 2);
  vector< vector<float> > results;

  for (size_t i = 0; i < (options.test_size / 2); i++)
    {
      input[i] = 1;
      ups->process_block (&input[0], input.size(), &output[0]);
      input[i] = 0;
      results.push_back (vector<float> (&output[0], &output[output.size()]));
      for (size_t j = 0; j < output.size(); j++)
        {
          if (j >= i * 2)
            {
              assert_return (output[j] == results[0][j - i * 2]);
            }
          // printf ("%d %.17g #p%d,%d\n", j, output[j], precision, i);
        }
    }
  for (size_t i = 0; i < options.rand_samples; i++)
    input[i] = g_random_double_range (-1, 1);
  ups->process_block (&input[0], input.size(), &output[0]);

  max_error = 0;
  for (size_t j = 0; j < output.size(); j++)
    {
      double acc = 0;
      for (size_t i = 0; i < options.rand_samples; i++)
        {
          acc += results[i][j] * input[i];
        }
      max_error = max (fabs (output[j] - acc), max_error);
    }
  check_spectrum (results[0], precision);
}

void
ResamplerTest::check_resampler_down (BseResampler2Precision precision)
{
  Resampler2 *downs = Resampler2::create (BSE_RESAMPLER2_MODE_DOWNSAMPLE, precision);
  AlignedArray<float,16> input (options.test_size * 2);
  AlignedArray<float,16> output (options.test_size);
  vector< vector<float> > results;

  for (size_t i = 0; i < (options.test_size / 2); i++)
    {
      input[i] = 1;
      downs->process_block (&input[0], input.size(), &output[0]);
      input[i] = 0;
      results.push_back (vector<float> (&output[0], &output[output.size()]));
      for (size_t j = 0; j < output.size(); j++)
        {
          if (j >= i/2)
            assert_return (output[j] == results[i % 2][j - i/2]);
          //printf ("%zd %.17g #%d,%zd\n", j, output[j], precision, i);
        }
    }
  for (size_t i = 0; i < options.rand_samples; i++)
    input[i] = g_random_double_range (-1, 1);
  downs->process_block (&input[0], input.size(), &output[0]);
  max_error = 0;
  for (size_t j = 0; j < output.size(); j++)
    {
      double acc = 0;
      for (size_t i = 0; i < options.rand_samples; i++)
        {
          acc += results[i][j] * input[i];
        }
      max_error = max (fabs (output[j] - acc), max_error);
    }

  /* The downsampler convolves the input with an FIR filter to achieve a
   * lowpass filter around half the sampling frequency. Since it throws
   * away every second sample, we need to merge the impulse responses
   * for two adjacent impulse responses to figure out the total impulse
   * response of the resampling FIR filter
   */
  vector<float> merged_ir;
  for (size_t i = 0; i < results[0].size(); i++)
    {
      merged_ir.push_back (results[1][i] * 2);
      merged_ir.push_back (results[0][i] * 2);
    }
  check_spectrum (merged_ir, precision);
}

static double
band_err (BseResampler2Precision p)
{
  /* the filter design is not always exactly as specified by the precision,
   * so sometimes we achieve a lower db value than requested, and sometimes
   * a higher db value than specified
   */
  switch (p)
    {
      case BSE_RESAMPLER2_PREC_LINEAR:  return -8.5;
      case BSE_RESAMPLER2_PREC_48DB:    return -51;
      case BSE_RESAMPLER2_PREC_72DB:    return -74;
      case BSE_RESAMPLER2_PREC_96DB:    return -95;
      case BSE_RESAMPLER2_PREC_120DB:   return -120;
      case BSE_RESAMPLER2_PREC_144DB:   return -144;
      default:                          assert_return_unreached (NAN);
    }
}

static void
run_tests (const char *label)
{
  BseResampler2Precision p = BSE_RESAMPLER2_PREC_96DB;  // should not be equal to the first resampler precision

  for (int i = 0; i < 32; i++)
    {
      BseResampler2Precision new_p = Resampler2::find_precision_for_bits (i);
      if (new_p != p)
        {
          p = new_p;

          TSTART ("Resampler %s Precision %d", label, p);

          ResamplerTest rt_up;
          rt_up.check_resampler_up (p);

          TASSERT (bse_db_from_factor (rt_up.max_error, -200) < -125);
          TASSERT (bse_db_from_factor (rt_up.passband_err, -200) < band_err (p));
          TASSERT (bse_db_from_factor (rt_up.stopband_err, -200) < band_err (p));

          //printf ("## UP   %d %.17g %.17g %.17g\n", p, bse_db_from_factor (rt_up.max_error, -200),
                                                    //bse_db_from_factor (rt_up.passband_err, -200),
                                                    //bse_db_from_factor (rt_up.stopband_err, -200));
          ResamplerTest rt_down;
          rt_down.check_resampler_down (p);

          TASSERT (bse_db_from_factor (rt_up.max_error, -200) < -125);
          TASSERT (bse_db_from_factor (rt_up.passband_err, -200) < band_err (p));
          TASSERT (bse_db_from_factor (rt_up.stopband_err, -200) < band_err (p));

          //printf ("## DOWN %d %.17g %.17g %.17g\n", p, bse_db_from_factor (rt_down.max_error, -200),
                                                    //bse_db_from_factor (rt_down.passband_err, -200),
                                                    //bse_db_from_factor (rt_down.stopband_err, -200));
          TDONE();
        }
    }
}

int
main (int argc, char **argv)
{
  // usually we'd call bse_init_test() here, but we have tests to rnu before plugins are loaded
  Rapicorn::init_core_test (RAPICORN_PRETTY_FILE, &argc, argv);
  Rapicorn::StringVector sv = Rapicorn::string_split (Rapicorn::cpu_info(), " ");
  Rapicorn::String machine = sv.size() >= 2 ? sv[1] : "Unknown";
  printout ("  NOTE     Running on: %s+%s", machine.c_str(), bse_block_impl_name()); // usually done by bse_init_test

  if (argc > 1)
    {
      options.test_size = atoi (argv[1]);
    }
  if (argc > 2)
    {
      options.rand_samples = atoi (argv[2]);
    }
  assert_return (options.rand_samples <= options.test_size / 2, -1);
  assert_return (options.test_size >= 128, -1);
  printout ("Resampler test parameters: test_size=%zd rand_samples=%zd\n",
           options.test_size, options.rand_samples);
  run_tests ("FPU");

  /* load plugins */
  Bse::assertion_failed_hook (NULL); // hack to allow test reinitialization
  bse_init_test (&argc, argv, Bse::cstrings_to_vector ("load-core-plugins=1", NULL));
  /* check for possible specialization */
  if (Bse::Block::default_singleton() == Bse::Block::current_singleton())
    return 0;   /* nothing changed */
  run_tests ("SSE");
  return 0;
}
<commit_msg>TESTS: use Bse namespace elements instead of Rapicorn<commit_after>// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html

#include <bse/bseresampler.hh>
#include <bse/bsemathsignal.hh>
#include <bse/bsemain.hh>
#include <bse/bseblockutils.hh>
#include <bse/gslfft.hh>
#include <sfi/sfitests.hh>
#include <sfi/sfi.hh>
#include <stdlib.h>
#include <stdio.h>

using namespace Bse;

using Bse::Resampler::Resampler2;
using Bse::AlignedArray;
using std::vector;
using std::max;
using std::min;

struct Options
{
  size_t test_size;
  size_t rand_samples;
  // default test parameters
  Options() :
    test_size (512),
    rand_samples (64)
  {
  }
} options;

class ResamplerTest
{
public:
  double passband_err;
  double stopband_err;
  double max_error;

  void  check_spectrum (const vector<float>& impulse_response, int p);
  void  check_resampler_up (BseResampler2Precision precision);
  void  check_resampler_down (BseResampler2Precision precision);
};

void
ResamplerTest::check_spectrum (const vector<float>& impulse_response, int p)
{
  vector<double> fft_in (4096), spect (fft_in.size());

  for (size_t i = 0; i < min (impulse_response.size(), fft_in.size()); i++)
    {
      fft_in[i] = impulse_response[i] / 2;
    }
  gsl_power2_fftar (fft_in.size(), &fft_in[0], &spect[0]);
  spect[1] = 0; // special packing

  passband_err = 0;
  stopband_err = 0;

  for (size_t i = 0; i < 4096; i += 2)
    {
      const double re = spect[i], im = spect[i + 1];
      const double mag = sqrt (re * re + im * im);
      const double freq = i * 44100.0 / 4096;
      if (freq < 18000)
        passband_err = max (passband_err, fabs (1 - mag));
      if (freq > 26100)
        stopband_err = max (stopband_err, fabs (mag));
    }
}

void
ResamplerTest::check_resampler_up (BseResampler2Precision precision)
{
  Resampler2 *ups = Resampler2::create (BSE_RESAMPLER2_MODE_UPSAMPLE, precision);
  AlignedArray<float,16> input (options.test_size);
  AlignedArray<float,16> output (options.test_size * 2);
  vector< vector<float> > results;

  for (size_t i = 0; i < (options.test_size / 2); i++)
    {
      input[i] = 1;
      ups->process_block (&input[0], input.size(), &output[0]);
      input[i] = 0;
      results.push_back (vector<float> (&output[0], &output[output.size()]));
      for (size_t j = 0; j < output.size(); j++)
        {
          if (j >= i * 2)
            {
              assert_return (output[j] == results[0][j - i * 2]);
            }
          // printf ("%d %.17g #p%d,%d\n", j, output[j], precision, i);
        }
    }
  for (size_t i = 0; i < options.rand_samples; i++)
    input[i] = g_random_double_range (-1, 1);
  ups->process_block (&input[0], input.size(), &output[0]);

  max_error = 0;
  for (size_t j = 0; j < output.size(); j++)
    {
      double acc = 0;
      for (size_t i = 0; i < options.rand_samples; i++)
        {
          acc += results[i][j] * input[i];
        }
      max_error = max (fabs (output[j] - acc), max_error);
    }
  check_spectrum (results[0], precision);
}

void
ResamplerTest::check_resampler_down (BseResampler2Precision precision)
{
  Resampler2 *downs = Resampler2::create (BSE_RESAMPLER2_MODE_DOWNSAMPLE, precision);
  AlignedArray<float,16> input (options.test_size * 2);
  AlignedArray<float,16> output (options.test_size);
  vector< vector<float> > results;

  for (size_t i = 0; i < (options.test_size / 2); i++)
    {
      input[i] = 1;
      downs->process_block (&input[0], input.size(), &output[0]);
      input[i] = 0;
      results.push_back (vector<float> (&output[0], &output[output.size()]));
      for (size_t j = 0; j < output.size(); j++)
        {
          if (j >= i/2)
            assert_return (output[j] == results[i % 2][j - i/2]);
          //printf ("%zd %.17g #%d,%zd\n", j, output[j], precision, i);
        }
    }
  for (size_t i = 0; i < options.rand_samples; i++)
    input[i] = g_random_double_range (-1, 1);
  downs->process_block (&input[0], input.size(), &output[0]);
  max_error = 0;
  for (size_t j = 0; j < output.size(); j++)
    {
      double acc = 0;
      for (size_t i = 0; i < options.rand_samples; i++)
        {
          acc += results[i][j] * input[i];
        }
      max_error = max (fabs (output[j] - acc), max_error);
    }

  /* The downsampler convolves the input with an FIR filter to achieve a
   * lowpass filter around half the sampling frequency. Since it throws
   * away every second sample, we need to merge the impulse responses
   * for two adjacent impulse responses to figure out the total impulse
   * response of the resampling FIR filter
   */
  vector<float> merged_ir;
  for (size_t i = 0; i < results[0].size(); i++)
    {
      merged_ir.push_back (results[1][i] * 2);
      merged_ir.push_back (results[0][i] * 2);
    }
  check_spectrum (merged_ir, precision);
}

static double
band_err (BseResampler2Precision p)
{
  /* the filter design is not always exactly as specified by the precision,
   * so sometimes we achieve a lower db value than requested, and sometimes
   * a higher db value than specified
   */
  switch (p)
    {
      case BSE_RESAMPLER2_PREC_LINEAR:  return -8.5;
      case BSE_RESAMPLER2_PREC_48DB:    return -51;
      case BSE_RESAMPLER2_PREC_72DB:    return -74;
      case BSE_RESAMPLER2_PREC_96DB:    return -95;
      case BSE_RESAMPLER2_PREC_120DB:   return -120;
      case BSE_RESAMPLER2_PREC_144DB:   return -144;
      default:                          assert_return_unreached (NAN);
    }
}

static void
run_tests (const char *label)
{
  BseResampler2Precision p = BSE_RESAMPLER2_PREC_96DB;  // should not be equal to the first resampler precision

  for (int i = 0; i < 32; i++)
    {
      BseResampler2Precision new_p = Resampler2::find_precision_for_bits (i);
      if (new_p != p)
        {
          p = new_p;

          TSTART ("Resampler %s Precision %d", label, p);

          ResamplerTest rt_up;
          rt_up.check_resampler_up (p);

          TASSERT (bse_db_from_factor (rt_up.max_error, -200) < -125);
          TASSERT (bse_db_from_factor (rt_up.passband_err, -200) < band_err (p));
          TASSERT (bse_db_from_factor (rt_up.stopband_err, -200) < band_err (p));

          //printf ("## UP   %d %.17g %.17g %.17g\n", p, bse_db_from_factor (rt_up.max_error, -200),
                                                    //bse_db_from_factor (rt_up.passband_err, -200),
                                                    //bse_db_from_factor (rt_up.stopband_err, -200));
          ResamplerTest rt_down;
          rt_down.check_resampler_down (p);

          TASSERT (bse_db_from_factor (rt_up.max_error, -200) < -125);
          TASSERT (bse_db_from_factor (rt_up.passband_err, -200) < band_err (p));
          TASSERT (bse_db_from_factor (rt_up.stopband_err, -200) < band_err (p));

          //printf ("## DOWN %d %.17g %.17g %.17g\n", p, bse_db_from_factor (rt_down.max_error, -200),
                                                    //bse_db_from_factor (rt_down.passband_err, -200),
                                                    //bse_db_from_factor (rt_down.stopband_err, -200));
          TDONE();
        }
    }
}

int
main (int argc, char **argv)
{
  // usually we'd call bse_init_test() here, but we have tests to rnu before plugins are loaded
  Rapicorn::init_core_test (RAPICORN_PRETTY_FILE, &argc, argv);
  Bse::StringVector sv = Bse::string_split (Bse::cpu_info(), " ");
  Bse::String machine = sv.size() >= 2 ? sv[1] : "Unknown";
  printout ("  NOTE     Running on: %s+%s", machine.c_str(), bse_block_impl_name()); // usually done by bse_init_test

  if (argc > 1)
    {
      options.test_size = atoi (argv[1]);
    }
  if (argc > 2)
    {
      options.rand_samples = atoi (argv[2]);
    }
  assert_return (options.rand_samples <= options.test_size / 2, -1);
  assert_return (options.test_size >= 128, -1);
  printout ("Resampler test parameters: test_size=%zd rand_samples=%zd\n",
           options.test_size, options.rand_samples);
  run_tests ("FPU");

  /* load plugins */
  Bse::assertion_failed_hook (NULL); // hack to allow test reinitialization
  bse_init_test (&argc, argv, Bse::cstrings_to_vector ("load-core-plugins=1", NULL));
  /* check for possible specialization */
  if (Bse::Block::default_singleton() == Bse::Block::current_singleton())
    return 0;   /* nothing changed */
  run_tests ("SSE");
  return 0;
}
<|endoftext|>


<commit_before>// For conditions of distribution and use, see copyright notice in license.txt

#include "StableHeaders.h"
#include "DebugOperatorNew.h"

#include "ECComponentEditor.h"
#include "ECEditorModule.h"

#include "IAttribute.h"
#include "ECAttributeEditor.h"
#include "IComponent.h"
#include "Transform.h"
#include "AssetReference.h"
#include "LoggingFunctions.h"
DEFINE_POCO_LOGGING_FUNCTIONS("ECAttributeEditorBase")

#include <QtTreePropertyBrowser>
#include <QtGroupPropertyManager>
#include <QtProperty>

#include <QSize>
#include <QPoint>

#include "MemoryLeakCheck.h"

// static
ECAttributeEditorBase *ECComponentEditor::CreateAttributeEditor(
    QtAbstractPropertyBrowser *browser,
    ECComponentEditor *editor,
    ComponentPtr component,
    const QString &name,
    const QString &type)
{
    ECAttributeEditorBase *attributeEditor = 0;
    if(type == "real")
        attributeEditor = new ECAttributeEditor<float>(browser, component, name, type, editor);
    else if(type == "int")
        attributeEditor = new ECAttributeEditor<int>(browser, component, name, type, editor);
    else if(type == "vector3df")
        attributeEditor = new ECAttributeEditor<Vector3df>(browser, component, name, type, editor);
    else if(type == "color")
        attributeEditor = new ECAttributeEditor<Color>(browser, component, name, type, editor);
    else if(type == "string")
        attributeEditor = new ECAttributeEditor<QString>(browser, component, name, type, editor);
    else if(type == "bool")
        attributeEditor = new ECAttributeEditor<bool>(browser, component, name, type, editor);
    else if(type == "qvariant")
        attributeEditor = new ECAttributeEditor<QVariant>(browser, component, name, type, editor);
    else if(type == "qvariantlist")
        attributeEditor = new ECAttributeEditor<QVariantList>(browser, component, name, type, editor);
    else if(type == "assetreference")
        attributeEditor = new ECAttributeEditor<AssetReference>(browser, component, name, type, editor);
    else if(type == "assetreferencelist")
        attributeEditor = new ECAttributeEditor<AssetReferenceList>(browser, component, name, type, editor);
    else if(type == "transform")
        attributeEditor = new ECAttributeEditor<Transform>(browser, component, name, type, editor);
    else if(type == "qsize")
        attributeEditor = new ECAttributeEditor<QSize>(browser, component, name, type, editor);
    else if(type == "qsizef")
        attributeEditor = new ECAttributeEditor<QSizeF>(browser, component, name, type, editor);
    else if(type == "qpoint")
        attributeEditor = new ECAttributeEditor<QPoint>(browser, component, name, type, editor);
    else if(type == "qpointf")
        attributeEditor = new ECAttributeEditor<QPointF>(browser, component, name, type, editor);
    else
        LogError("Unknown attribute type " + type.toStdString() + " for ECAttributeEditorBase creation.");

    return attributeEditor;
}

ECComponentEditor::ECComponentEditor(ComponentPtr component, QtAbstractPropertyBrowser *propertyBrowser):
    QObject(propertyBrowser),
    groupProperty_(0),
    groupPropertyManager_(0),
    propertyBrowser_(propertyBrowser)
{
    assert(component);
    typeName_ = component->TypeName();
    name_ = component->Name();

    assert(propertyBrowser_);
    if(!propertyBrowser_)
       return;

    groupPropertyManager_ = new QtGroupPropertyManager(this);
    if(groupPropertyManager_)
    {
        groupProperty_ = groupPropertyManager_->addProperty();
        CreateAttributeEditors(component);
        AddNewComponent(component);
    }

    propertyBrowser_->addProperty(groupProperty_);
}

ECComponentEditor::~ECComponentEditor()
{
    propertyBrowser_->unsetFactoryForManager(groupPropertyManager_);
    SAFE_DELETE(groupProperty_)
    SAFE_DELETE(groupPropertyManager_)
    while(!attributeEditors_.empty())
    {
        SAFE_DELETE(attributeEditors_.begin().value())
        attributeEditors_.erase(attributeEditors_.begin());
    }
}

void ECComponentEditor::CreateAttributeEditors(ComponentPtr component)
{
    AttributeVector attributes = component->GetAttributes();
    for(uint i = 0; i < attributes.size(); i++)
    {
        // Check metadata if this attribute is intended to be shown in designer/editor ui
        if (attributes[i]->HasMetadata())
            if (!attributes[i]->GetMetadata()->designable)
                continue;

        ECAttributeEditorBase *attributeEditor = ECComponentEditor::CreateAttributeEditor(propertyBrowser_, this,
            component, QString(attributes[i]->GetNameString().c_str()), QString(attributes[i]->TypeName().c_str()));
        if (!attributeEditor)
            continue;

        attributeEditors_[attributes[i]->GetName()] = attributeEditor;
        groupProperty_->setToolTip("Component type is " + component->TypeName());
        groupProperty_->addSubProperty(attributeEditor->GetProperty());
        connect(attributeEditor, SIGNAL(EditorChanged(const QString &)), this, SLOT(OnEditorChanged(const QString &)));
    }
}

void ECComponentEditor::UpdateGroupPropertyText()
{
    if(!groupProperty_ || !components_.size())
        return;
    QString componentName = typeName_;
    componentName.replace("EC_", "");
    QString groupPropertyName = componentName;
    if(!name_.isEmpty())
        groupPropertyName += " (" + name_ + ") ";
    if(components_.size() > 1)
        groupPropertyName += QString(" (%1 components)").arg(components_.size());
    groupProperty_->setPropertyName(groupPropertyName);
}

bool ECComponentEditor::ContainProperty(QtProperty *property) const
{
    AttributeEditorMap::const_iterator constIter = attributeEditors_.begin();
    while(constIter != attributeEditors_.end())
    {
        if(constIter.value()->ContainsProperty(property))
            return true;
        constIter++;
    }
    return false;
}

void ECComponentEditor::AddNewComponent(ComponentPtr component)
{
    PROFILE(ECComponentEditor_AddNewComponent);
    //! Check that component type is same as editor's typename (We only want to add same type of components to editor).
    if(component->TypeName() != typeName_)
        return;

    components_.push_back(ComponentWeakPtr(component));
    //! insert new component to each attribute editor.
    AttributeEditorMap::iterator iter = attributeEditors_.begin();
    while(iter != attributeEditors_.end())
    {
        IAttribute *attribute = component->GetAttribute(iter.value()->GetAttributeName());
        if(attribute)
            iter.value()->AddComponent(component);
        iter++;
    }
    UpdateGroupPropertyText();
}

void ECComponentEditor::RemoveComponent(ComponentPtr component)
{
    if(!component)
        return;

    if(component->TypeName() != typeName_)
        return;

    ComponentSet::iterator iter = components_.begin();
    while(iter != components_.end())
    {
        ComponentPtr comp_ptr = (*iter).lock();
        if(comp_ptr.get() == component.get())
        {
            AttributeEditorMap::iterator attributeIter = attributeEditors_.begin();
            while(attributeIter != attributeEditors_.end())
            {
                IAttribute *attribute = comp_ptr->GetAttribute(attributeIter.value()->GetAttributeName());
                if(attribute)
                    attributeIter.value()->RemoveComponent(component);
                attributeIter++;
            }
            components_.erase(iter);
            break;
        }
        iter++;
    }
    UpdateGroupPropertyText();
}

void ECComponentEditor::UpdateUi()
{
    for(AttributeEditorMap::iterator iter = attributeEditors_.begin();
        iter != attributeEditors_.end();
        iter++)
    {
        iter.value()->UpdateEditorUI();
    }
}

void ECComponentEditor::OnEditorChanged(const QString &name)
{
    PROFILE(ECComponentEditor_OnEditorChanged);
    ECAttributeEditorBase *editor = qobject_cast<ECAttributeEditorBase*>(sender());
    if(!editor)
    {
        ECEditorModule::LogWarning("Fail to convert signal sender to ECAttributeEditorBase.");
        return;
    }
    groupProperty_->addSubProperty(editor->GetProperty());
}

QString ECComponentEditor::GetAttributeType(const QString &name) const
{
    AttributeEditorMap::const_iterator iter = attributeEditors_.find(name);
    if (iter != attributeEditors_.end())
        return (*iter)->GetAttributeType();
    return QString();
}
<commit_msg>Change LogError("Unknown attribute type " + type + " for ECAttributeEditorBase creation.") to LogWarning instead.<commit_after>// For conditions of distribution and use, see copyright notice in license.txt

#include "StableHeaders.h"
#include "DebugOperatorNew.h"

#include "ECComponentEditor.h"
#include "ECEditorModule.h"

#include "IAttribute.h"
#include "ECAttributeEditor.h"
#include "IComponent.h"
#include "Transform.h"
#include "AssetReference.h"
#include "LoggingFunctions.h"
DEFINE_POCO_LOGGING_FUNCTIONS("ECAttributeEditorBase")

#include <QtTreePropertyBrowser>
#include <QtGroupPropertyManager>
#include <QtProperty>

#include <QSize>
#include <QPoint>

#include "MemoryLeakCheck.h"

// static
ECAttributeEditorBase *ECComponentEditor::CreateAttributeEditor(
    QtAbstractPropertyBrowser *browser,
    ECComponentEditor *editor,
    ComponentPtr component,
    const QString &name,
    const QString &type)
{
    ECAttributeEditorBase *attributeEditor = 0;
    if(type == "real")
        attributeEditor = new ECAttributeEditor<float>(browser, component, name, type, editor);
    else if(type == "int")
        attributeEditor = new ECAttributeEditor<int>(browser, component, name, type, editor);
    else if(type == "vector3df")
        attributeEditor = new ECAttributeEditor<Vector3df>(browser, component, name, type, editor);
    else if(type == "color")
        attributeEditor = new ECAttributeEditor<Color>(browser, component, name, type, editor);
    else if(type == "string")
        attributeEditor = new ECAttributeEditor<QString>(browser, component, name, type, editor);
    else if(type == "bool")
        attributeEditor = new ECAttributeEditor<bool>(browser, component, name, type, editor);
    else if(type == "qvariant")
        attributeEditor = new ECAttributeEditor<QVariant>(browser, component, name, type, editor);
    else if(type == "qvariantlist")
        attributeEditor = new ECAttributeEditor<QVariantList>(browser, component, name, type, editor);
    else if(type == "assetreference")
        attributeEditor = new ECAttributeEditor<AssetReference>(browser, component, name, type, editor);
    else if(type == "assetreferencelist")
        attributeEditor = new ECAttributeEditor<AssetReferenceList>(browser, component, name, type, editor);
    else if(type == "transform")
        attributeEditor = new ECAttributeEditor<Transform>(browser, component, name, type, editor);
    else if(type == "qsize")
        attributeEditor = new ECAttributeEditor<QSize>(browser, component, name, type, editor);
    else if(type == "qsizef")
        attributeEditor = new ECAttributeEditor<QSizeF>(browser, component, name, type, editor);
    else if(type == "qpoint")
        attributeEditor = new ECAttributeEditor<QPoint>(browser, component, name, type, editor);
    else if(type == "qpointf")
        attributeEditor = new ECAttributeEditor<QPointF>(browser, component, name, type, editor);
    else
        LogWarning("Unknown attribute type " + type + " for ECAttributeEditorBase creation.");

    return attributeEditor;
}

ECComponentEditor::ECComponentEditor(ComponentPtr component, QtAbstractPropertyBrowser *propertyBrowser):
    QObject(propertyBrowser),
    groupProperty_(0),
    groupPropertyManager_(0),
    propertyBrowser_(propertyBrowser)
{
    assert(component);
    typeName_ = component->TypeName();
    name_ = component->Name();

    assert(propertyBrowser_);
    if(!propertyBrowser_)
       return;

    groupPropertyManager_ = new QtGroupPropertyManager(this);
    if(groupPropertyManager_)
    {
        groupProperty_ = groupPropertyManager_->addProperty();
        CreateAttributeEditors(component);
        AddNewComponent(component);
    }

    propertyBrowser_->addProperty(groupProperty_);
}

ECComponentEditor::~ECComponentEditor()
{
    propertyBrowser_->unsetFactoryForManager(groupPropertyManager_);
    SAFE_DELETE(groupProperty_)
    SAFE_DELETE(groupPropertyManager_)
    while(!attributeEditors_.empty())
    {
        SAFE_DELETE(attributeEditors_.begin().value())
        attributeEditors_.erase(attributeEditors_.begin());
    }
}

void ECComponentEditor::CreateAttributeEditors(ComponentPtr component)
{
    AttributeVector attributes = component->GetAttributes();
    for(uint i = 0; i < attributes.size(); i++)
    {
        // Check metadata if this attribute is intended to be shown in designer/editor ui
        if (attributes[i]->HasMetadata())
            if (!attributes[i]->GetMetadata()->designable)
                continue;

        ECAttributeEditorBase *attributeEditor = ECComponentEditor::CreateAttributeEditor(propertyBrowser_, this,
            component, QString(attributes[i]->GetNameString().c_str()), QString(attributes[i]->TypeName().c_str()));
        if (!attributeEditor)
            continue;

        attributeEditors_[attributes[i]->GetName()] = attributeEditor;
        groupProperty_->setToolTip("Component type is " + component->TypeName());
        groupProperty_->addSubProperty(attributeEditor->GetProperty());
        connect(attributeEditor, SIGNAL(EditorChanged(const QString &)), this, SLOT(OnEditorChanged(const QString &)));
    }
}

void ECComponentEditor::UpdateGroupPropertyText()
{
    if(!groupProperty_ || !components_.size())
        return;
    QString componentName = typeName_;
    componentName.replace("EC_", "");
    QString groupPropertyName = componentName;
    if(!name_.isEmpty())
        groupPropertyName += " (" + name_ + ") ";
    if(components_.size() > 1)
        groupPropertyName += QString(" (%1 components)").arg(components_.size());
    groupProperty_->setPropertyName(groupPropertyName);
}

bool ECComponentEditor::ContainProperty(QtProperty *property) const
{
    AttributeEditorMap::const_iterator constIter = attributeEditors_.begin();
    while(constIter != attributeEditors_.end())
    {
        if(constIter.value()->ContainsProperty(property))
            return true;
        constIter++;
    }
    return false;
}

void ECComponentEditor::AddNewComponent(ComponentPtr component)
{
    PROFILE(ECComponentEditor_AddNewComponent);
    //! Check that component type is same as editor's typename (We only want to add same type of components to editor).
    if(component->TypeName() != typeName_)
        return;

    components_.push_back(ComponentWeakPtr(component));
    //! insert new component to each attribute editor.
    AttributeEditorMap::iterator iter = attributeEditors_.begin();
    while(iter != attributeEditors_.end())
    {
        IAttribute *attribute = component->GetAttribute(iter.value()->GetAttributeName());
        if(attribute)
            iter.value()->AddComponent(component);
        iter++;
    }
    UpdateGroupPropertyText();
}

void ECComponentEditor::RemoveComponent(ComponentPtr component)
{
    if(!component)
        return;

    if(component->TypeName() != typeName_)
        return;

    ComponentSet::iterator iter = components_.begin();
    while(iter != components_.end())
    {
        ComponentPtr comp_ptr = (*iter).lock();
        if(comp_ptr.get() == component.get())
        {
            AttributeEditorMap::iterator attributeIter = attributeEditors_.begin();
            while(attributeIter != attributeEditors_.end())
            {
                IAttribute *attribute = comp_ptr->GetAttribute(attributeIter.value()->GetAttributeName());
                if(attribute)
                    attributeIter.value()->RemoveComponent(component);
                attributeIter++;
            }
            components_.erase(iter);
            break;
        }
        iter++;
    }
    UpdateGroupPropertyText();
}

void ECComponentEditor::UpdateUi()
{
    for(AttributeEditorMap::iterator iter = attributeEditors_.begin();
        iter != attributeEditors_.end();
        iter++)
    {
        iter.value()->UpdateEditorUI();
    }
}

void ECComponentEditor::OnEditorChanged(const QString &name)
{
    PROFILE(ECComponentEditor_OnEditorChanged);
    ECAttributeEditorBase *editor = qobject_cast<ECAttributeEditorBase*>(sender());
    if(!editor)
    {
        ECEditorModule::LogWarning("Fail to convert signal sender to ECAttributeEditorBase.");
        return;
    }
    groupProperty_->addSubProperty(editor->GetProperty());
}

QString ECComponentEditor::GetAttributeType(const QString &name) const
{
    AttributeEditorMap::const_iterator iter = attributeEditors_.find(name);
    if (iter != attributeEditors_.end())
        return (*iter)->GetAttributeType();
    return QString();
}
<|endoftext|>


<commit_before>#include "MotorView.h"

MotorView::MotorView(KeyMotorPresenter& keyMotorPresenter, MotorDetailsPresenter& motorDetailsPresenter,
                     I_MotorUi& ui)
    : keyMotorPresenter_(keyMotorPresenter)
    , motorDetailsPresenter_(motorDetailsPresenter)
    , ui_(ui)
{
    connectMotor(keyMotorPresenter_, motorDetailsPresenter_ );
}

MotorView::~MotorView()
{
}

void MotorView::connectMotor(KeyMotorPresenter& keyMotorPresenter, MotorDetailsPresenter& motorDetailsPresenter)
{
    connect(&keyMotorPresenter, SIGNAL(motorZeroReceived(KeyMotor)),
            this, SIGNAL(motorZeroReceived(KeyMotor)));
    connect(&keyMotorPresenter, SIGNAL(motorOneReceived(KeyMotor)),
            this, SIGNAL(motorOneReceived(KeyMotor)));
    connect(&keyMotorPresenter, SIGNAL(motorSetCurrentReceived(double setCurrent)),
            this, SIGNAL(motorSetCurrentReceived(double setCurrent)));
    connect(&keyMotorPresenter, SIGNAL(motorActualSpeedReceived(double actualSpeed)),
            this, SIGNAL(motorActualSpeedReceived(double actualSpeed)));
    connect(&keyMotorPresenter, SIGNAL(motorBusVoltageReceived(double busVoltage)),
            this, SIGNAL(motorBusVoltageReceived(double busVoltage)));
    connect(&keyMotorPresenter, SIGNAL(motorBusCurrentReceived(double busCurrent)),
            this, SIGNAL(motorBusCurrentReceived(double busCurrent)));

    connect(&motorDetailsPresenter, SIGNAL(motorZeroDetailsReceived(MotorDetails)),
            this, SIGNAL(motorZeroDetailsReceived(MotorDetails)));
    connect(&motorDetailsPresenter, SIGNAL(motorOneDetailsReceived(MotorDetails)),
            this, SIGNAL(motorOneDetailsReceived(MotorDetails)));
}

void MotorView::setCurrentLeftReceived(double setCurrentLeft)
{
    ui_.setCurrentLeftLabel().setNum(setCurrentLeft);
}

void MotorView::setCurrentRightReceived(double setCurrentRight)
{
    ui_.setCurrentRightLabel().setNum(setCurrentRight);
}

void MotorView::setCurrentAvg(double setCurrentLeft, double setCurrentRight)
{
    double setCurrentAvg = (setCurrentLeft + setCurrentRight) / 2;
    ui_.setCurrentAvgLabel().setNum(setCurrentAvg);
}

void MotorView::setVelocityLeftReceived(double setVelocityLeft)
{
    ui_.setVelocityLeftLabel().setNum(setVelocityLeft);
}

void MotorView::setVelocityRightReceived(double setVelocityRight)
{
    ui_.setVelocityRightLabel().setNum(setVelocityRight);
}

void MotorView::setVelocityAvg(double setVelocityLeft, double setVelocityRight)
{
    double setVelocityAvg = (setVelocityLeft + setVelocityRight) / 2;
    ui_.setVelocityAvgLabel().setNum(setVelocityAvg);
}

void MotorView::busCurrentLeftReceived(double busCurrentLeft)
{
    ui_.busCurrentLeftLabel().setNum(busCurrentLeft);
}

void MotorView::busCurrentRightReceived(double busCurrentRight)
{
    ui_.busCurrentRightLabel().setNum(busCurrentRight);
}

void MotorView::busCurrentAvg(double busCurrentLeft, double busCurrentRight)
{
    double busCurrentAvg = (busCurrentLeft + busCurrentRight) / 2;
    ui_.busCurrentAvgLabel().setNum(busCurrentAvg);
}

void MotorView::busVoltageLeftReceived(double busVoltageLeft)
{
    ui_.busVoltageLeftLabel().setNum(busVoltageLeft);
}

void MotorView::busVoltageRightReceived(double busVoltageRight)
{
    ui_.busVoltageRightLabel().setNum(busVoltageRight);
}

void MotorView::busVoltageAvg(double busVoltageLeft, double busVoltageRight)
{
    double busVoltageAvg = (busVoltageLeft + busVoltageRight) / 2;
    ui_.busVoltageAvgLabel().setNum(busVoltageAvg);
}

void MotorView::vehicleVelocityLeftReceived(double vehicleVelocityLeft)
{
    ui_.vehicleVelocityLeftLabel().setNum(vehicleVelocityLeft);
}

void MotorView::vehicleVelocityRightReceived(double vehicleVelocityRight)
{
    ui_.vehicleVelocityRightLabel().setNum(vehicleVelocityRight);
}

void MotorView::vehicleVelocityAvg(double vehicleVelocityLeft, double vehicleVelocityRight)
{
    double vehicleVelocityAvg = (vehicleVelocityLeft + vehicleVelocityRight) / 2;
    ui_.vehicleVelocityAvgLabel().setNum(vehicleVelocityAvg);
}

void MotorView::phaseCCurrentLeftReceived(double phaseCCurrentLeft)
{
    ui_.phaseCCurrentLeftLabel().setNum(phaseCCurrentLeft);
}

void MotorView::phaseCCurrentRightReceived(double phaseCCurrentRight)
{
    ui_.phaseCCurrentRightLabel().setNum(phaseCCurrentRight);
}

void MotorView::phaseCCurrentAvg(double phaseCCurrentLeft, double phaseCCurrentRight)
{
    double phaseCCurrentAvg = (phaseCCurrentLeft + phaseCCurrentRight) / 2;
    ui_.phaseCCurrentAvgLabel().setNum(phaseCCurrentAvg);
}

void MotorView::phaseBCurrentLeftReceived(double phaseBCurrentLeft)
{
    ui_.phaseBCurrentLeftLabel().setNum(phaseBCurrentLeft);
}

void MotorView::phaseBCurrentRightReceived(double phaseBCurrentRight)
{
    ui_.phaseBCurrentRightLabel().setNum(phaseBCurrentRight);
}

void MotorView::phaseBCurrentAvg(double phaseBCurrentLeft, double phaseBCurrentRight)
{
    double phaseBCurrentAvg = (phaseBCurrentLeft + phaseBCurrentRight) / 2;
    ui_.phaseBCurrentAvgLabel().setNum(phaseBCurrentAvg);
}

void MotorView::motorVoltageRealLeftReceived(double motorVoltageRealLeft)
{
    ui_.motorVoltageRealLeftLabel().setNum(motorVoltageRealLeft);
}

void MotorView::motorVoltageRealRightReceived(double motorVoltageRealRight)
{
    ui_.motorVoltageRealRightLabel().setNum(motorVoltageRealRight);
}

void MotorView::motorVoltageRealAvg(double motorVoltageRealLeft, double motorVoltageRealRight)
{
    double motorVoltageRealAvg = (motorVoltageRealLeft + motorVoltageRealRight) / 2;
    ui_.motorVoltageRealAvgLabel().setNum(motorVoltageRealAvg);
}

void MotorView::motorVoltageImaginaryLeftReceived(double motorVoltageImaginaryLeft)
{
    ui_.motorVoltageImaginaryLeftLabel().setNum(motorVoltageImaginaryLeft);
}

void MotorView::motorVoltageImaginaryRightReceived(double motorVoltageImaginaryRight)
{
    ui_.motorVoltageImaginaryRightLabel().setNum(motorVoltageImaginaryRight);
}

void MotorView::motorVoltageImaginaryAvg(double motorVoltageImaginaryLeft, double motorVoltageImaginaryRight)
{
    double motorVoltageImaginaryAvg = (motorVoltageImaginaryLeft + motorVoltageImaginaryRight) / 2;
    ui_.motorVoltageImaginaryAvgLabel().setNum(motorVoltageImaginaryAvg);
}

void MotorView::motorCurrentRealLeftReceived(double motorCurrentRealLeft)
{
    ui_.motorCurrentRealLeftLabel().setNum(motorCurrentRealLeft);
}

void MotorView::motorCurrentRealRightReceived(double motorCurrentRealRight)
{
    ui_.motorCurrentRealRightLabel().setNum(motorCurrentRealRight);
}

void MotorView::motorCurrentRealAvg(double motorCurrentRealLeft, double motorCurrentRealRight)
{
    double motorCurrentRealAvg = (motorCurrentRealLeft + motorCurrentRealRight) / 2;
    ui_.motorCurrentRealAvgLabel().setNum(motorCurrentRealAvg);
}

void MotorView::motorCurrentImaginaryLeftReceived(double motorCurrentImaginaryLeft)
{
    ui_.motorCurrentImaginaryLeftLabel().setNum(motorCurrentImaginaryLeft);
}

void MotorView::motorCurrentImaginaryRightReceived(double motorCurrentImaginaryRight)
{
    ui_.motorCurrentImaginaryRightLabel().setNum(motorCurrentImaginaryRight);
}

void MotorView::motorCurrentImaginaryAvg(double motorCurrentImaginaryLeft, double motorCurrentImaginaryRight)
{
    double motorCurrentImaginaryAvg = (motorCurrentImaginaryLeft + motorCurrentImaginaryRight) / 2;
    ui_.motorCurrentImaginaryAvgLabel().setNum(motorCurrentImaginaryAvg);
}

void MotorView::backEmfRealLeftReceived(double backEmfRealLeft)
{
    ui_.backEmfRealLeftLabel().setNum(backEmfRealLeft);
}

void MotorView::backEmfRealRightReceived(double backEmfRealRight)
{
    ui_.backEmfRealRightLabel().setNum(backEmfRealRight);
}

void MotorView::backEmfRealAvg(double backEmfRealLeft, double backEmfRealRight)
{
    double backEmfRealAvg = (backEmfRealLeft + backEmfRealRight) / 2;
    ui_.backEmfRealAvgLabel().setNum(backEmfRealAvg);
}

void MotorView::voltageRail15VSupplyLeftReceived(double voltageRail15VSupplyLeft)
{
    ui_.voltageRail15VSupplyLeftLabel().setNum(voltageRail15VSupplyLeft);
}

void MotorView::voltageRail15VSupplyRightReceived(double voltageRail15VSupplyRight)
{
    ui_.voltageRail15VSupplyRightLabel().setNum(voltageRail15VSupplyRight);
}

void MotorView::voltageRail15VSupplyAvg(double voltageRail15VSupplyLeft, double voltageRail15VSupplyRight)
{
    double voltageRail15VSupplyAvg = (voltageRail15VSupplyLeft + voltageRail15VSupplyRight) / 2;
    ui_.voltageRail15VSupplyAvgLabel().setNum(voltageRail15VSupplyAvg);
}

void MotorView::voltageRail3VSupplyLeftReceived(double voltageRail3VSupplyLeft)
{
    ui_.voltageRail3VSupplyLeftLabel().setNum(voltageRail3VSupplyLeft);
}

void MotorView::voltageRail3VSupplyRightReceived(double voltageRail3VSupplyRight)
{
    ui_.voltageRail3VSupplyRightLabel().setNum(voltageRail3VSupplyRight);
}

void MotorView::voltageRail3VSupplyAvg(double voltageRail3VSupplyLeft, double voltageRail3VSupplyRight)
{
    double voltageRail3VSupplyAvg = (voltageRail3VSupplyLeft + voltageRail3VSupplyRight) / 2;
    ui_.voltageRail3VSupplyAvgLabel().setNum(voltageRail3VSupplyAvg);
}

void MotorView::voltageRail1VSupplyLeftReceived(double voltageRail1VSupplyLeft)
{
    ui_.voltageRail1VSupplyLeftLabel().setNum(voltageRail1VSupplyLeft);
}

void MotorView::voltageRail1VSupplyRightReceived(double voltageRail1VSupplyRight)
{
    ui_.voltageRail1VSupplyRightLabel().setNum(voltageRail1VSupplyRight);
}

void MotorView::voltageRail1VSupplyAvg(double voltageRail1VSupplyLeft, double voltageRail1VSupplyRight)
{
    double voltageRail1VSupplyAvg = (voltageRail1VSupplyLeft + voltageRail1VSupplyRight) / 2;
    ui_.voltageRail1VSupplyAvgLabel().setNum(voltageRail1VSupplyAvg);
}

void MotorView::heatSinkTempLeftReceived(double heatSinkTempLeft)
{
    ui_.heatSinkTempLeftLabel().setNum(heatSinkTempLeft);
}

void MotorView::heatSinkTempRightReceived(double heatSinkTempRight)
{
    ui_.heatSinkTempRightLabel().setNum(heatSinkTempRight);
}

void MotorView::heatSinkTempAvg(double heatSinkTempLeft, double heatSinkTempRight)
{
    double heatSinkTempAvg = (heatSinkTempLeft + heatSinkTempRight) / 2;
    ui_.heatSinkTempAvgLabel().setNum(heatSinkTempAvg);
}

void MotorView::motorTempLeftReceived(double motorTempLeft)
{
    ui_.motorTempLeftLabel().setNum(motorTempLeft);
}

void MotorView::motorTempRightReceived(double motorTempRight)
{
    ui_.motorTempRightLabel().setNum(motorTempRight);
}

void MotorView::motorTempAvg(double motorTempLeft, double motorTempRight)
{
    double motorTempAvg = (motorTempLeft + motorTempRight) / 2;
    ui_.motorTempAvgLabel().setNum(motorTempAvg);
}

void MotorView::dspBoardTempLeftReceived(double dspBoardTempLeft)
{
    ui_.dspBoardTempLeftLabel().setNum(dspBoardTempLeft);
}

void MotorView::dspBoardTempRightReceived(double dspBoardTempRight)
{
    ui_.dspBoardTempRightLabel().setNum(dspBoardTempRight);
}

void MotorView::dspBoardTempAvg(double dspBoardTempLeft, double dspBoardTempRight)
{
    double dspBoardTempAvg = (dspBoardTempLeft + dspBoardTempRight) / 2;
    ui_.dspBoardTempAvgLabel().setNum(dspBoardTempAvg);
}

void MotorView::dcBusAmpHoursLeftReceived(double dcBusAmpHoursLeft)
{
    ui_.dcBusAmpHoursLeftLabel().setNum(dcBusAmpHoursLeft);
}

void MotorView::dcBusAmpHoursRightReceived(double dcBusAmpHoursRight)
{
    ui_.dcBusAmpHoursRightLabel().setNum(dcBusAmpHoursRight);
}

void MotorView::dcBusAmpHoursAvg(double dcBusAmpHoursLeft, double dcBusAmpHoursRight)
{
    double dcBusAmpHoursAvg = (dcBusAmpHoursLeft + dcBusAmpHoursRight) / 2;
    ui_.dcBusAmpHoursAvgLabel().setNum(dcBusAmpHoursAvg);
}

void MotorView::odometerLeftReceived(double odometerLeft)
{
    ui_.odometerLeftLabel().setNum(odometerLeft);
}

void MotorView::odometerRightReceived(double odometerRight)
{
    ui_.odometerRightLabel().setNum(odometerRight);
}

void MotorView::odometerAvg(double odometerLeft, double odometerRight)
{
    double odometerAvg = (odometerLeft + odometerRight) / 2;
    ui_.odometerAvgLabel().setNum(odometerAvg);
}

void MotorView::slipSpeedLeftReceived(double slipSpeedLeft)
{
    ui_.slipSpeedLeftLabel().setNum(slipSpeedLeft);
}

void MotorView::slipSpeedRightReceived(double slipSpeedRight)
{
    ui_.slipSpeedRightLabel().setNum(slipSpeedRight);
}

void MotorView::slipSpeedAvg(double slipSpeedLeft, double slipSpeedRight)
{
    double slipSpeedAvg = (slipSpeedLeft + slipSpeedRight) / 2;
    ui_.slipSpeedAvgLabel().setNum(slipSpeedAvg);
}

<commit_msg> got rid of whitespace<commit_after>#include "MotorView.h"

MotorView::MotorView(KeyMotorPresenter& keyMotorPresenter, MotorDetailsPresenter& motorDetailsPresenter,
                     I_MotorUi& ui)
    : keyMotorPresenter_(keyMotorPresenter)
    , motorDetailsPresenter_(motorDetailsPresenter)
    , ui_(ui)
{
    connectMotor(keyMotorPresenter_, motorDetailsPresenter_ );
}

MotorView::~MotorView()
{
}

void MotorView::connectMotor(KeyMotorPresenter& keyMotorPresenter, MotorDetailsPresenter& motorDetailsPresenter)
{
    connect(&keyMotorPresenter, SIGNAL(motorZeroReceived(KeyMotor)),
            this, SIGNAL(motorZeroReceived(KeyMotor)));
    connect(&keyMotorPresenter, SIGNAL(motorOneReceived(KeyMotor)),
            this, SIGNAL(motorOneReceived(KeyMotor)));
    connect(&keyMotorPresenter, SIGNAL(motorSetCurrentReceived(double setCurrent)),
            this, SIGNAL(motorSetCurrentReceived(double setCurrent)));
    connect(&keyMotorPresenter, SIGNAL(motorActualSpeedReceived(double actualSpeed)),
            this, SIGNAL(motorActualSpeedReceived(double actualSpeed)));
    connect(&keyMotorPresenter, SIGNAL(motorBusVoltageReceived(double busVoltage)),
            this, SIGNAL(motorBusVoltageReceived(double busVoltage)));
    connect(&keyMotorPresenter, SIGNAL(motorBusCurrentReceived(double busCurrent)),
            this, SIGNAL(motorBusCurrentReceived(double busCurrent)));

    connect(&motorDetailsPresenter, SIGNAL(motorZeroDetailsReceived(MotorDetails)),
            this, SIGNAL(motorZeroDetailsReceived(MotorDetails)));
    connect(&motorDetailsPresenter, SIGNAL(motorOneDetailsReceived(MotorDetails)),
            this, SIGNAL(motorOneDetailsReceived(MotorDetails)));
}

void MotorView::setCurrentLeftReceived(double setCurrentLeft)
{
    ui_.setCurrentLeftLabel().setNum(setCurrentLeft);
}

void MotorView::setCurrentRightReceived(double setCurrentRight)
{
    ui_.setCurrentRightLabel().setNum(setCurrentRight);
}

void MotorView::setCurrentAvg(double setCurrentLeft, double setCurrentRight)
{
    double setCurrentAvg = (setCurrentLeft + setCurrentRight) / 2;
    ui_.setCurrentAvgLabel().setNum(setCurrentAvg);
}

void MotorView::setVelocityLeftReceived(double setVelocityLeft)
{
    ui_.setVelocityLeftLabel().setNum(setVelocityLeft);
}

void MotorView::setVelocityRightReceived(double setVelocityRight)
{
    ui_.setVelocityRightLabel().setNum(setVelocityRight);
}

void MotorView::setVelocityAvg(double setVelocityLeft, double setVelocityRight)
{
    double setVelocityAvg = (setVelocityLeft + setVelocityRight) / 2;
    ui_.setVelocityAvgLabel().setNum(setVelocityAvg);
}

void MotorView::busCurrentLeftReceived(double busCurrentLeft)
{
    ui_.busCurrentLeftLabel().setNum(busCurrentLeft);
}

void MotorView::busCurrentRightReceived(double busCurrentRight)
{
    ui_.busCurrentRightLabel().setNum(busCurrentRight);
}

void MotorView::busCurrentAvg(double busCurrentLeft, double busCurrentRight)
{
    double busCurrentAvg = (busCurrentLeft + busCurrentRight) / 2;
    ui_.busCurrentAvgLabel().setNum(busCurrentAvg);
}

void MotorView::busVoltageLeftReceived(double busVoltageLeft)
{
    ui_.busVoltageLeftLabel().setNum(busVoltageLeft);
}

void MotorView::busVoltageRightReceived(double busVoltageRight)
{
    ui_.busVoltageRightLabel().setNum(busVoltageRight);
}

void MotorView::busVoltageAvg(double busVoltageLeft, double busVoltageRight)
{
    double busVoltageAvg = (busVoltageLeft + busVoltageRight) / 2;
    ui_.busVoltageAvgLabel().setNum(busVoltageAvg);
}

void MotorView::vehicleVelocityLeftReceived(double vehicleVelocityLeft)
{
    ui_.vehicleVelocityLeftLabel().setNum(vehicleVelocityLeft);
}

void MotorView::vehicleVelocityRightReceived(double vehicleVelocityRight)
{
    ui_.vehicleVelocityRightLabel().setNum(vehicleVelocityRight);
}

void MotorView::vehicleVelocityAvg(double vehicleVelocityLeft, double vehicleVelocityRight)
{
    double vehicleVelocityAvg = (vehicleVelocityLeft + vehicleVelocityRight) / 2;
    ui_.vehicleVelocityAvgLabel().setNum(vehicleVelocityAvg);
}

void MotorView::phaseCCurrentLeftReceived(double phaseCCurrentLeft)
{
    ui_.phaseCCurrentLeftLabel().setNum(phaseCCurrentLeft);
}

void MotorView::phaseCCurrentRightReceived(double phaseCCurrentRight)
{
    ui_.phaseCCurrentRightLabel().setNum(phaseCCurrentRight);
}

void MotorView::phaseCCurrentAvg(double phaseCCurrentLeft, double phaseCCurrentRight)
{
    double phaseCCurrentAvg = (phaseCCurrentLeft + phaseCCurrentRight) / 2;
    ui_.phaseCCurrentAvgLabel().setNum(phaseCCurrentAvg);
}

void MotorView::phaseBCurrentLeftReceived(double phaseBCurrentLeft)
{
    ui_.phaseBCurrentLeftLabel().setNum(phaseBCurrentLeft);
}

void MotorView::phaseBCurrentRightReceived(double phaseBCurrentRight)
{
    ui_.phaseBCurrentRightLabel().setNum(phaseBCurrentRight);
}

void MotorView::phaseBCurrentAvg(double phaseBCurrentLeft, double phaseBCurrentRight)
{
    double phaseBCurrentAvg = (phaseBCurrentLeft + phaseBCurrentRight) / 2;
    ui_.phaseBCurrentAvgLabel().setNum(phaseBCurrentAvg);
}

void MotorView::motorVoltageRealLeftReceived(double motorVoltageRealLeft)
{
    ui_.motorVoltageRealLeftLabel().setNum(motorVoltageRealLeft);
}

void MotorView::motorVoltageRealRightReceived(double motorVoltageRealRight)
{
    ui_.motorVoltageRealRightLabel().setNum(motorVoltageRealRight);
}

void MotorView::motorVoltageRealAvg(double motorVoltageRealLeft, double motorVoltageRealRight)
{
    double motorVoltageRealAvg = (motorVoltageRealLeft + motorVoltageRealRight) / 2;
    ui_.motorVoltageRealAvgLabel().setNum(motorVoltageRealAvg);
}

void MotorView::motorVoltageImaginaryLeftReceived(double motorVoltageImaginaryLeft)
{
    ui_.motorVoltageImaginaryLeftLabel().setNum(motorVoltageImaginaryLeft);
}

void MotorView::motorVoltageImaginaryRightReceived(double motorVoltageImaginaryRight)
{
    ui_.motorVoltageImaginaryRightLabel().setNum(motorVoltageImaginaryRight);
}

void MotorView::motorVoltageImaginaryAvg(double motorVoltageImaginaryLeft, double motorVoltageImaginaryRight)
{
    double motorVoltageImaginaryAvg = (motorVoltageImaginaryLeft + motorVoltageImaginaryRight) / 2;
    ui_.motorVoltageImaginaryAvgLabel().setNum(motorVoltageImaginaryAvg);
}

void MotorView::motorCurrentRealLeftReceived(double motorCurrentRealLeft)
{
    ui_.motorCurrentRealLeftLabel().setNum(motorCurrentRealLeft);
}

void MotorView::motorCurrentRealRightReceived(double motorCurrentRealRight)
{
    ui_.motorCurrentRealRightLabel().setNum(motorCurrentRealRight);
}

void MotorView::motorCurrentRealAvg(double motorCurrentRealLeft, double motorCurrentRealRight)
{
    double motorCurrentRealAvg = (motorCurrentRealLeft + motorCurrentRealRight) / 2;
    ui_.motorCurrentRealAvgLabel().setNum(motorCurrentRealAvg);
}

void MotorView::motorCurrentImaginaryLeftReceived(double motorCurrentImaginaryLeft)
{
    ui_.motorCurrentImaginaryLeftLabel().setNum(motorCurrentImaginaryLeft);
}

void MotorView::motorCurrentImaginaryRightReceived(double motorCurrentImaginaryRight)
{
    ui_.motorCurrentImaginaryRightLabel().setNum(motorCurrentImaginaryRight);
}

void MotorView::motorCurrentImaginaryAvg(double motorCurrentImaginaryLeft, double motorCurrentImaginaryRight)
{
    double motorCurrentImaginaryAvg = (motorCurrentImaginaryLeft + motorCurrentImaginaryRight) / 2;
    ui_.motorCurrentImaginaryAvgLabel().setNum(motorCurrentImaginaryAvg);
}

void MotorView::backEmfRealLeftReceived(double backEmfRealLeft)
{
    ui_.backEmfRealLeftLabel().setNum(backEmfRealLeft);
}

void MotorView::backEmfRealRightReceived(double backEmfRealRight)
{
    ui_.backEmfRealRightLabel().setNum(backEmfRealRight);
}

void MotorView::backEmfRealAvg(double backEmfRealLeft, double backEmfRealRight)
{
    double backEmfRealAvg = (backEmfRealLeft + backEmfRealRight) / 2;
    ui_.backEmfRealAvgLabel().setNum(backEmfRealAvg);
}

void MotorView::voltageRail15VSupplyLeftReceived(double voltageRail15VSupplyLeft)
{
    ui_.voltageRail15VSupplyLeftLabel().setNum(voltageRail15VSupplyLeft);
}

void MotorView::voltageRail15VSupplyRightReceived(double voltageRail15VSupplyRight)
{
    ui_.voltageRail15VSupplyRightLabel().setNum(voltageRail15VSupplyRight);
}

void MotorView::voltageRail15VSupplyAvg(double voltageRail15VSupplyLeft, double voltageRail15VSupplyRight)
{
    double voltageRail15VSupplyAvg = (voltageRail15VSupplyLeft + voltageRail15VSupplyRight) / 2;
    ui_.voltageRail15VSupplyAvgLabel().setNum(voltageRail15VSupplyAvg);
}

void MotorView::voltageRail3VSupplyLeftReceived(double voltageRail3VSupplyLeft)
{
    ui_.voltageRail3VSupplyLeftLabel().setNum(voltageRail3VSupplyLeft);
}

void MotorView::voltageRail3VSupplyRightReceived(double voltageRail3VSupplyRight)
{
    ui_.voltageRail3VSupplyRightLabel().setNum(voltageRail3VSupplyRight);
}

void MotorView::voltageRail3VSupplyAvg(double voltageRail3VSupplyLeft, double voltageRail3VSupplyRight)
{
    double voltageRail3VSupplyAvg = (voltageRail3VSupplyLeft + voltageRail3VSupplyRight) / 2;
    ui_.voltageRail3VSupplyAvgLabel().setNum(voltageRail3VSupplyAvg);
}

void MotorView::voltageRail1VSupplyLeftReceived(double voltageRail1VSupplyLeft)
{
    ui_.voltageRail1VSupplyLeftLabel().setNum(voltageRail1VSupplyLeft);
}

void MotorView::voltageRail1VSupplyRightReceived(double voltageRail1VSupplyRight)
{
    ui_.voltageRail1VSupplyRightLabel().setNum(voltageRail1VSupplyRight);
}

void MotorView::voltageRail1VSupplyAvg(double voltageRail1VSupplyLeft, double voltageRail1VSupplyRight)
{
    double voltageRail1VSupplyAvg = (voltageRail1VSupplyLeft + voltageRail1VSupplyRight) / 2;
    ui_.voltageRail1VSupplyAvgLabel().setNum(voltageRail1VSupplyAvg);
}

void MotorView::heatSinkTempLeftReceived(double heatSinkTempLeft)
{
    ui_.heatSinkTempLeftLabel().setNum(heatSinkTempLeft);
}

void MotorView::heatSinkTempRightReceived(double heatSinkTempRight)
{
    ui_.heatSinkTempRightLabel().setNum(heatSinkTempRight);
}

void MotorView::heatSinkTempAvg(double heatSinkTempLeft, double heatSinkTempRight)
{
    double heatSinkTempAvg = (heatSinkTempLeft + heatSinkTempRight) / 2;
    ui_.heatSinkTempAvgLabel().setNum(heatSinkTempAvg);
}

void MotorView::motorTempLeftReceived(double motorTempLeft)
{
    ui_.motorTempLeftLabel().setNum(motorTempLeft);
}

void MotorView::motorTempRightReceived(double motorTempRight)
{
    ui_.motorTempRightLabel().setNum(motorTempRight);
}

void MotorView::motorTempAvg(double motorTempLeft, double motorTempRight)
{
    double motorTempAvg = (motorTempLeft + motorTempRight) / 2;
    ui_.motorTempAvgLabel().setNum(motorTempAvg);
}

void MotorView::dspBoardTempLeftReceived(double dspBoardTempLeft)
{
    ui_.dspBoardTempLeftLabel().setNum(dspBoardTempLeft);
}

void MotorView::dspBoardTempRightReceived(double dspBoardTempRight)
{
    ui_.dspBoardTempRightLabel().setNum(dspBoardTempRight);
}

void MotorView::dspBoardTempAvg(double dspBoardTempLeft, double dspBoardTempRight)
{
    double dspBoardTempAvg = (dspBoardTempLeft + dspBoardTempRight) / 2;
    ui_.dspBoardTempAvgLabel().setNum(dspBoardTempAvg);
}

void MotorView::dcBusAmpHoursLeftReceived(double dcBusAmpHoursLeft)
{
    ui_.dcBusAmpHoursLeftLabel().setNum(dcBusAmpHoursLeft);
}

void MotorView::dcBusAmpHoursRightReceived(double dcBusAmpHoursRight)
{
    ui_.dcBusAmpHoursRightLabel().setNum(dcBusAmpHoursRight);
}

void MotorView::dcBusAmpHoursAvg(double dcBusAmpHoursLeft, double dcBusAmpHoursRight)
{
    double dcBusAmpHoursAvg = (dcBusAmpHoursLeft + dcBusAmpHoursRight) / 2;
    ui_.dcBusAmpHoursAvgLabel().setNum(dcBusAmpHoursAvg);
}

void MotorView::odometerLeftReceived(double odometerLeft)
{
    ui_.odometerLeftLabel().setNum(odometerLeft);
}

void MotorView::odometerRightReceived(double odometerRight)
{
    ui_.odometerRightLabel().setNum(odometerRight);
}

void MotorView::odometerAvg(double odometerLeft, double odometerRight)
{
    double odometerAvg = (odometerLeft + odometerRight) / 2;
    ui_.odometerAvgLabel().setNum(odometerAvg);
}

void MotorView::slipSpeedLeftReceived(double slipSpeedLeft)
{
    ui_.slipSpeedLeftLabel().setNum(slipSpeedLeft);
}

void MotorView::slipSpeedRightReceived(double slipSpeedRight)
{
    ui_.slipSpeedRightLabel().setNum(slipSpeedRight);
}

void MotorView::slipSpeedAvg(double slipSpeedLeft, double slipSpeedRight)
{
    double slipSpeedAvg = (slipSpeedLeft + slipSpeedRight) / 2;
    ui_.slipSpeedAvgLabel().setNum(slipSpeedAvg);
}

<|endoftext|>