OpenCores
URL https://opencores.org/ocsvn/pcie_ds_dma/pcie_ds_dma/trunk

Subversion Repositories pcie_ds_dma

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /pcie_ds_dma/trunk/soft/linux
    from Rev 7 to Rev 8
    Reverse comparison

Rev 7 → Rev 8

/application/adm_test/src/Makefile
19,17 → 19,19
../../../common/utils \
../../../common/dac \
../../../common/adc \
../../../common/dma
../../../common/dma \
../../../common/console
INCLUDE := $(addprefix -I, $(INCDIR))
 
CFLAGS := -D__LINUX__ -O2 -Wall $(INCLUDE)
LFLAGS := -Wl -ldl -lrt -lpthread -lm
LFLAGS := -Wl -ldl -lrt -lpthread -lm -lncurses
 
SRCFILE := $(wildcard *.cpp)
SRCFILE += $(wildcard ../../../common/board/*.cpp)
SRCFILE += $(wildcard ../../../common/pex/*.cpp)
SRCFILE += $(wildcard ../../../common/utils/*.cpp)
SRCFILE += $(wildcard ../../../common/console/*.cpp)
#SRCFILE += $(wildcard ../../../common/dma/*.cpp)
#SRCFILE += $(wildcard ../../../common/adc/*.cpp)
#SRCFILE += $(wildcard ../../../common/dac/*.cpp)
/common/console/nctable.cpp
0,0 → 1,373
 
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <ncurses.h>
#include <signal.h>
#include <vector>
 
#ifndef __NCTABLE_H__
#include "nctable.h"
#endif
 
//-----------------------------------------------------------------------------
 
void table::init()
{
initscr();
cbreak();
noecho();
keypad(stdscr, TRUE);
nonl();
}
 
//-----------------------------------------------------------------------------
 
table::table(int cell_width, int cell_height)
{
init();
 
m_row = 0;
m_colomn = 0;
m_CW = cell_width;
m_CH = cell_height;
m_table.clear();
 
getmaxyx(stdscr,m_maxH,m_maxW);
 
m_W0 = m_maxW/2;
m_H0 = m_maxH/2;
 
m_header.w = NULL;
m_header.X0 = m_header.Y0 = m_header.W = m_header.H = 0;
m_status.clear();
//m_status.w = NULL;
//m_status.X0 = m_status.Y0 = m_status.W = m_status.H = 0;
}
 
//-----------------------------------------------------------------------------
 
table::table(int colomn_number, int cell_width, int cell_height)
{
init();
 
m_row = 0;
m_colomn = colomn_number;
m_CW = cell_width;
m_CH = cell_height;
m_table.clear();
 
getmaxyx(stdscr,m_maxH,m_maxW);
 
m_W0 = m_maxW/2;
m_H0 = m_maxH/2;
 
m_header.w = NULL;
m_header.X0 = m_header.Y0 = m_header.W = m_header.H = 0;
m_status.clear();
//m_status.w = NULL;
//m_status.X0 = m_status.Y0 = m_status.W = m_status.H = 0;
}
 
//-----------------------------------------------------------------------------
 
table::table(int row, int col, int cell_width, int cell_height)
{
init();
 
m_row = row;
m_colomn = col;
m_CW = cell_width;
m_CH = cell_height;
 
getmaxyx(stdscr,m_maxH,m_maxW);
 
m_W0 = m_maxW/2;
m_H0 = m_maxH/2;
 
m_header.w = NULL;
m_header.X0 = m_header.Y0 = m_header.W = m_header.H = 0;
m_status.clear();
//m_status.w = NULL;
//m_status.X0 = m_status.Y0 = m_status.W = m_status.H = 0;
 
create_table(row, col);
}
 
//-----------------------------------------------------------------------------
 
table::~table()
{
clear_table();
clear_header();
clear_status();
endwin();
}
 
//-----------------------------------------------------------------------------
 
void table::clear_table()
{
for(unsigned i=0; i<m_table.size(); i++) {
row_t row = m_table.at(i);
for(unsigned j=0; j<row.w.size(); j++) {
WINDOW *w = row.w.at(j);
delwin(w);
}
row.w.clear();
}
m_table.clear();
}
 
//-----------------------------------------------------------------------------
 
int table::create_table(int nrow, int ncol)
{
clear_table();
 
int dX = m_CW * ncol/2;
int dY = m_CH * nrow/2;
 
for(int row = 0; row < nrow; row++) {
 
int x0 = m_W0 - dX;
int y0 = m_H0 + m_CH * row - dY;
 
row_t new_row;
 
new_row.X0 = x0;
new_row.Y0 = y0;
 
for(int col = 0; col < ncol; col++) {
 
int xn = x0 + m_CW * col;
int yn = y0;
 
WINDOW *w = newwin(m_CH, m_CW, yn, xn);
if(!w)
break;
box(w, 0 , 0);
wrefresh(w);
new_row.w.push_back(w);
}
 
m_table.push_back(new_row);
}
 
return m_table.size();
}
 
//-----------------------------------------------------------------------------
 
int table::add_row()
{
int x0 = 0;
int y0 = 0;
 
if(m_table.size()) {
 
x0 = m_W0 - m_CW * m_colomn/2;
y0 = m_H0 - m_H0/2 + m_CH * m_table.size();
 
} else {
 
x0 = m_W0 - m_CW * m_colomn/2;
y0 = m_H0 - m_H0/2;
}
 
row_t new_row;
 
new_row.X0 = x0;
new_row.Y0 = y0;
 
for(int col = 0; col < m_colomn; col++) {
 
int xn = x0 + m_CW * col;
int yn = y0;
 
WINDOW *w = newwin(m_CH, m_CW, yn, xn);
if(!w)
break;
box(w, 0 , 0);
wrefresh(w);
new_row.w.push_back(w);
}
 
m_table.push_back(new_row);
 
return m_table.size();
}
 
//-----------------------------------------------------------------------------
 
int table::set_cell_text(unsigned nrow, unsigned ncol, const char *fmt, ...)
{
if(nrow >= m_table.size())
return -1;
 
row_t& row = m_table.at(nrow);
 
if(ncol >= row.w.size())
return -2;
 
WINDOW *w = row.w.at(ncol);
 
if(!w)
return -3;
 
va_list argptr;
va_start(argptr, fmt);
char msg[256];
vsprintf(msg, fmt, argptr);
wmove(w, m_CH/2, m_CW/2-strlen(msg)/2);
wprintw(w, "%s", msg);
wrefresh(w);
 
return 0;
}
 
//-----------------------------------------------------------------------------
 
bool table::create_header()
{
if(m_header.w)
return true;
 
if(m_table.empty())
return false;
 
row_t row0 = m_table.at(0);
 
m_header.X0 = row0.X0;
m_header.Y0 = row0.Y0-m_CH;
 
m_header.H = m_CH;
m_header.W = m_CW*row0.w.size();
 
WINDOW *w = newwin(m_header.H, m_header.W, m_header.Y0, m_header.X0);
if(!w) {
return false;
}
 
m_header.w = w;
box(w, 0 , 0);
 
wrefresh(w);
 
return true;
}
 
//-----------------------------------------------------------------------------
 
bool table::create_status()
{
if(m_table.empty())
return false;
 
struct header_t status_bar;
 
if(m_status.empty()) {
 
row_t rowN = m_table.at(m_table.size()-1);
 
status_bar.X0 = rowN.X0;
status_bar.Y0 = rowN.Y0+m_CH;
 
status_bar.H = m_CH;
status_bar.W = m_CW*rowN.w.size();
 
} else {
 
struct header_t last_bar = m_status.at(m_status.size()-1);
 
status_bar.X0 = last_bar.X0;
status_bar.Y0 = last_bar.Y0+m_CH;
 
status_bar.H = m_CH;
status_bar.W = last_bar.W;
}
 
WINDOW *w = newwin(status_bar.H, status_bar.W, status_bar.Y0, status_bar.X0);
if(!w) {
return false;
}
 
status_bar.w = w;
box(status_bar.w, 0 , 0);
wrefresh(w);
 
m_status.push_back(status_bar);
 
return true;
}
 
//-----------------------------------------------------------------------------
 
int table::set_header_text(const char *fmt, ...)
{
if(!m_header.w)
return -1;
 
va_list argptr;
va_start(argptr, fmt);
char msg[256];
vsprintf(msg, fmt, argptr);
wmove(m_header.w, m_header.H/2, m_header.W/2-strlen(msg)/2);
wprintw(m_header.w, "%s", msg);
wrefresh(m_header.w);
 
return 0;
}
 
//-----------------------------------------------------------------------------
 
int table::set_status_text(unsigned id, const char *fmt, ...)
{
if(id >= m_status.size())
return -1;
 
struct header_t status_bar = m_status.at(id);
if(!status_bar.w)
return -1;
 
va_list argptr;
va_start(argptr, fmt);
char msg[256];
vsprintf(msg, fmt, argptr);
wmove(status_bar.w, status_bar.H/2, status_bar.W/2-strlen(msg)/2);
wprintw(status_bar.w, "%s", msg);
wrefresh(status_bar.w);
 
return 0;
}
 
//-----------------------------------------------------------------------------
 
void table::clear_status()
{
for(unsigned i=0; i<m_status.size(); i++) {
struct header_t status_bar = m_status.at(i);
if(status_bar.w) {
delwin(status_bar.w);
status_bar.w = NULL;
}
}
m_status.clear();
}
 
//-----------------------------------------------------------------------------
 
void table::clear_header()
{
if(m_header.w) {
delwin(m_header.w);
m_header.w = NULL;
}
}
 
//-----------------------------------------------------------------------------
 
//-----------------------------------------------------------------------------
/common/console/nctable.h
0,0 → 1,60
 
#ifndef __NCTABLE_H__
#define __NCTABLE_H__
 
#include <ncurses.h>
#include <vector>
 
struct row_t {
int X0;
int Y0;
std::vector<WINDOW*> w;
};
 
struct header_t {
int X0;
int Y0;
int W;
int H;
WINDOW *w;
};
 
class table {
 
public:
table(int colomn_number, int cell_width, int cell_height);
table(int row, int col, int cell_width, int cell_height);
table(int cell_width, int cell_height);
virtual ~table();
 
int create_table(int nrow, int ncol);
int add_row();
bool create_header();
int set_header_text(const char *fmt, ...);
bool create_status();
int set_status_text(unsigned id, const char *fmt, ...);
int set_cell_text(unsigned nrow, unsigned ncol, const char *fmt, ...);
int set_colomn_number(int col);
 
private:
 
void init();
void clear_table();
void clear_status();
void clear_header();
 
int m_colomn;
int m_row;
int m_maxW;
int m_maxH;
int m_W0;
int m_H0;
int m_CW;
int m_CH;
 
header_t m_header;
std::vector<struct row_t> m_table;
std::vector<struct header_t> m_status;
};
 
#endif //__NCTABLE_H__

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.