Commit 18a7162f authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Remove block_pand (still an empty block and not used anywhere)

parent c2e21364
/*
* Copyright (c) 2014,
* Daan Vreeken <Daan @ Vitsch . nl> - Vitsch Electronics
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS `AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <errno.h>
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <controller/controller_block.h>
#include <log/log.h>
/*
pand
input output
name name
----------------------------------------------
---| TODO: fill in.. |---
----------------------------------------------
Omschrijving:
...
*/
// definitie van variabelen die we gebruiken
struct controller_block_private {
// ingangen
bool *reset_button, *start_button;
float *temp_test, *temp_wtw[4];
float *co2_test;
// uitgangen
bool test_out;
float test_analog;
// interne variabelen
};
// een paar definities voor de leesbaarheid van de code
#define OUTPUT(name) (sub->private->name)
#define INPUT(name) (*sub->private->name)
static int show_debug = 0;
static int no_debug_override = 0;
/*
static int dprintf(const char *fmt, ...)
{
va_list args;
int ret;
if ((! show_debug) || (no_debug_override))
return (0);
va_start(args, fmt);
ret = vprintf(fmt, args);
va_end(args);
return (ret);
}
*/
struct timespec last_t;
static void calculate(struct controller_block *sub)
{
struct controller_block_private *priv;
struct timespec t;
priv = sub->private;
//priv->now = gettick();
clock_gettime(0, &t);
OUTPUT(test_out) = (t.tv_nsec >= 500 * 1000 * 1000) ? 1 : 0;
OUTPUT(test_analog) = (t.tv_nsec * 10.0) / 1.0e9;
if (last_t.tv_sec != t.tv_sec) {
last_t.tv_sec = t.tv_sec;
log_send(LOG_T_DEBUG,
" %0.3f mA %0.5f %0.2f %0.2f %0.2f "
"%0.2f\n", INPUT(co2_test) * 1.0e3,
INPUT(temp_test), INPUT(temp_wtw[0]), INPUT(temp_wtw[1]),
INPUT(temp_wtw[2]), INPUT(temp_wtw[3])
);
}
}
static struct controller_block_interm_list interms[] = {
{ "reset", CONTROLLER_BLOCK_TERM_BOOL,
offsetof(struct controller_block_private, reset_button) },
{ "start", CONTROLLER_BLOCK_TERM_BOOL,
offsetof(struct controller_block_private, start_button) },
{ "temp_test", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, temp_test) },
{ "co2_test", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, co2_test) },
{ "temp_wtw_1", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, temp_wtw[0]) },
{ "temp_wtw_2", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, temp_wtw[1]) },
{ "temp_wtw_3", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, temp_wtw[2]) },
{ "temp_wtw_4", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, temp_wtw[3]) },
{ NULL },
};
static struct controller_block_outterm_list outterms[] = {
{ "test_out", CONTROLLER_BLOCK_TERM_BOOL,
offsetof(struct controller_block_private, test_out) },
{ "test_analog", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, test_analog) },
{ NULL },
};
static struct controller_block * block_pand_create(char *name, int argc, va_list val)
{
struct controller_block *sub;
struct controller_block_private *priv;
int failed;
sub = controller_block_alloc("pand", name,
sizeof(struct controller_block_private));
if (sub == NULL)
return NULL;
priv = sub->private;
// lijst van inputs
if (controller_block_interm_list_init(sub, interms))
goto err_sub;
failed = 0;
#if 0
failed = controller_block_add_bool_input(sub, "reset",
&priv->reset_button);
failed |= controller_block_add_bool_input(sub, "start",
&priv->start_button);
failed |= controller_block_add_float_input(sub, "temp_test",
&priv->temp_test);
failed |= controller_block_add_float_input(sub, "co2_test",
&priv->co2_test);
failed |= controller_block_add_float_input(sub, "temp_wtw_1",
&priv->temp_wtw[0]);
failed |= controller_block_add_float_input(sub, "temp_wtw_2",
&priv->temp_wtw[1]);
failed |= controller_block_add_float_input(sub, "temp_wtw_3",
&priv->temp_wtw[2]);
failed |= controller_block_add_float_input(sub, "temp_wtw_4",
&priv->temp_wtw[3]);
#endif
// outputs
if (controller_block_outterm_list_init(sub, outterms))
goto err_sub;
#if 0
failed |= controller_block_add_bool_output(sub, "test_out",
&sub->private->test_out);
failed |= controller_block_add_float_output(sub, "test_analog",
&sub->private->test_analog);
#endif
OUTPUT(test_out) = false;
if (failed)
goto err_sub;
sub->calculate = calculate;
log_send(LOG_T_DEBUG, "pand: booted V0.1 2014-12-15");
if (controller_block_add(sub))
goto err_sub;
return sub;
err_sub:
controller_block_free(sub);
return NULL;
}
BLOCK_CREATE(pand) = {
.create = block_pand_create,
.args = { NULL },
};
......@@ -27,7 +27,6 @@ BLOCKS := \
log \
matrix_2x2 \
multiplexer \
pand \
pid \
pid_aw \
quadrature_decoder \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment