Skip to content
Snippets Groups Projects
Commit 35442ee4 authored by Pieter Donker's avatar Pieter Donker
Browse files

after cleanup this files are not needed anymore

parent f6c53bee
Branches
No related tags found
No related merge requests found
/* *************************************************************************
* Copyright 2020
* ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* *********************************************************************** */
/* *************************************************************************
* Author:
* . Leon Hiemstra
* . Pieter Donker
* Purpose:
* . opc-ua to ucp translator
* Description:
* . board info
* *********************************************************************** */
#ifndef _REENTRANT
#error ACK! You need to compile with _REENTRANT defined since this uses threads
#endif
#include <exception>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <arpa/inet.h> //inet_pton
#include "board.h"
using namespace std;
extern int debug;
Board::Board(list<class Node*>& nodelist)
{
NODE = nodelist;
}
Board::~Board()
{
for (auto node : NODE) {
delete node;
}
}
Node * Board::select_node(const int nr)
{
for (auto node : NODE) {
if (node->GetGlobalNr() == (uint)nr) {
return node;
}
}
throw runtime_error("select_node: not found");
}
uint Board::node_number(Node *node)
{
return (node->GetUniboardNr() * 4) + node->GetLocalNr();
}
vector<int> Board::get_nodes(void)
{
vector<int> nodes;
for (auto node : NODE) {
nodes.push_back(node->GetGlobalNr());
}
return nodes;
}
bool Board::monitor(TermOutput& termout)
{
// cout << "board_monitor start" << endl;
bool retval=false;
uint retcnt=0;
vector<int> nodes = get_nodes();
for (uint idx=0; idx<nodes.size(); idx++) {
auto node = select_node(nodes[idx]);
if (idx > 0) {
}
try {
if (node->monitor(termout)) {
retcnt++;
}
} catch (exception& e) {
cerr << e.what() << endl;
}
}
retval = (retcnt == nodes.size());
return retval;
}
uint Board::ipaddr_to_id(const string ipaddr)
{
struct in_addr sa;
// store this IP address in sa:
inet_pton(AF_INET, ipaddr.c_str(), &(sa.s_addr));
uint32_t ip = ntohl(sa.s_addr);
// example: ipaddr="10.99.0.2" then ip will be: 0xa630002
/*
* Assuming every uniboard has 8 nodes and the ipaddress of the node is held
* in the least significand IP address tuble.
*/
uint8_t node = (uint8_t)(ip & 0xf) - 1;
uint8_t unb = (uint8_t)(ip >> 8); // unb number is stored in 2nd least significant tuble
return (unb * 8 + node);
}
/* *************************************************************************
* Copyright 2020
* ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* *********************************************************************** */
/* *************************************************************************
* Author:
* . Leon Hiemstra
* . Pieter Donker
* Purpose:
* . opc-ua to ucp translator
* Description:
* . board info
* *********************************************************************** */
#ifndef BOARD_H
#define BOARD_H 1
#include <string>
#include <list>
#include <vector>
#include <sstream>
#include "node.h"
#include "tools/util.h"
#include "registers.h"
#define c_NOF_PN_on_UNB 4
class Board
{
private:
Tictoc tictoc;
std::list<class Node*> NODE;
Node * select_node(const int nodeId);
uint node_number(Node *node);
public:
Board(std::list<class Node*>& nodelist);
~Board();
std::vector<int> get_nodes(void);
bool monitor(TermOutput& termout);
uint ipaddr_to_id(const std::string ipaddr);
};
#endif
/* *************************************************************************
* Copyright 2020
* ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* *********************************************************************** */
/* *************************************************************************
* Author:
* . Leon Hiemstra
* . Pieter Donker
* Purpose:
* . opc-ua to ucp translator
* Description:
* .
* *********************************************************************** */
#include "map.h"
#include "sdptr.h"
using namespace std;
extern int debug;
UniboardMap::UniboardMap(list<class Node*>& nodelist, const int32_t n_beamsets) : Board(nodelist), Fpga(nodelist, n_beamsets)
{
initialized = false;
}
bool UniboardMap::init(TermOutput& termout)
{
throw runtime_error("map init not executed");
bool retval = false;
initialized = false;
// add all registers
if (retval) initialized = true;
return retval;
}
bool UniboardMap::read(TermOutput& termout,
const string addr,
const int nvalues)
{
bool retval = false;
if (is_fpga(addr)) { // addressed with FPGA_...
//cout << "UniboardMap::read fpga application" << endl;
retval = point(termout, 'R', addr, NULL, nvalues);
}
return retval;
}
bool UniboardMap::write(TermOutput& termout,
const string addr,
const char *data,
const int nvalues)
{
bool retval = false;
if (is_fpga(addr)) { // addressed with FPGA_...
//cout << "UniboardMap::write fpga point [" << addr << "]" << endl;
retval = point(termout, 'W', addr, data, nvalues);
}
return retval;
}
/* *************************************************************************
* Copyright 2020
* ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
* P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* *********************************************************************** */
/* *************************************************************************
* Author:
* . Leon Hiemstra
* . Pieter Donker
* Purpose:
* . opc-ua to ucp translator
* Description:
* .
* *********************************************************************** */
#ifndef UNIBOARD_MAP_H
#define UNIBOARD_MAP_H 1
#include <string>
#include <vector>
#include <list>
#include <stdexcept>
#include "tools/util.h"
#include "board.h"
#include "fpga.h"
class UniboardMap : public Board, public Fpga
{
private:
bool initialized;
// std::vector<uint> Subband_mapping; // ...
public:
UniboardMap(std::list<class Node*>& nodelist, const int32_t n_beamsets);
~UniboardMap() {};
bool is_initialized(void) { return initialized; }
bool init(TermOutput& termout);
bool write(TermOutput& termout, const std::string addr,
const char *data, const int nvalues);
bool read(TermOutput& termout, const std::string addr,
const int nvalues);
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment