From 0c2fd6985a1341ee4f8c88242a67b592cf23329d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=8B=D1=87=D0=BA=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Fri, 28 Apr 2017 08:22:36 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@479 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- main.cpp | 146 +++++++++++++++++++++++++---- src_main/console/piscreen.h | 4 +- src_main/console/piscreenconsole.h | 26 +++++ src_main/containers/picontainers.h | 4 +- src_main/containers/pilist.h | 23 +++++ src_main/containers/pimap.h | 2 +- src_main/containers/pipair.h | 23 +++++ src_main/containers/piqueue.h | 2 +- src_main/containers/pivector2d.h | 2 +- src_main/core/pibitarray.h | 3 + src_main/core/pichunkstream.h | 4 +- src_main/core/picout.cpp | 2 +- src_main/core/picout.h | 2 +- src_main/core/piincludes_p.h | 2 +- src_main/core/pipropertystorage.h | 24 +++++ src_main/core/pistring_std.h | 23 +++++ src_main/io/piserial.h | 5 - 17 files changed, 261 insertions(+), 36 deletions(-) diff --git a/main.cpp b/main.cpp index 877ad2ca..08cd414a 100644 --- a/main.cpp +++ b/main.cpp @@ -32,33 +32,141 @@ const char pult_config[] = "; */ +#include -class A: public PIObject { - PIOBJECT(A) -public: - EVENT1(ev1, float, f) +template +struct Info { + enum {Defined = 0}; +}; +template +struct TypeInfo { + typedef T PureType; + typedef const T ConstPureType; + typedef T * PointerType; + typedef const T * ConstPointerType; + typedef T & ReferenceType; + typedef const T & ConstReferenceType; }; -class B: public PIObject { - PIOBJECT(B) +#define TYPEINFO_SINGLE(PT, T) \ + template<> struct TypeInfo { \ + typedef PT PureType; \ + typedef const PT ConstPureType; \ + typedef PT * PointerType; \ + typedef const PT * ConstPointerType; \ + typedef PT & ReferenceType; \ + typedef const PT & ConstReferenceType; \ + }; +#define TYPEINFO(T) \ + TYPEINFO_SINGLE(T, T &) \ + TYPEINFO_SINGLE(T, const T) \ + TYPEINFO_SINGLE(T, const T &) \ + TYPEINFO_SINGLE(T, T *) \ + TYPEINFO_SINGLE(T, const T *) + +TYPEINFO(PIString) + + +template +class A { public: - EVENT_HANDLER0(void, eh0) {piCout << "eh0";} - EVENT_HANDLER1(void, eh1, float, f) {piCout << "eh1" << f;} + void f() { + piCout << "T"; + } +}; + +template +class A { +public: + void f() { + piCout << "const T&"; + } }; +#include "pivector2d.h" int main(int argc, char *argv[]) { - A a; - B b; - CONNECTU_QUEUED(&a, ev1, &b, eh0, &b); - CONNECTU_QUEUED(&a, ev1, &b, eh1, &a); - piCout << "start"; - a.ev1(1.5); - piSleep(1); - piCout << a.maybeCallQueuedEvents(); - piSleep(1); - piCout << b.maybeCallQueuedEvents(); - piCout << "end"; + /* + enum VCO_Aim_Type {VCO_Aim_Type_None, VCO_Aim_Type_Detected, VCO_Aim_Type_New, VCO_Aim_Type_Confirmed, VCO_Aim_Type_Deleted = 127}; +#pragma pack (push, 1) + struct VCO_Element { + VCO_Element() {} + VCO_Aim_Type type; + double elapsed; + float wls_a; // m/s + float wls_b; // m + float speed; + float acceleration; // m/s^2 + float prediction_pos; // m + float variance; // m + float power; + float angle; + int id; + int missed; + int missed_ml; + int confirmed; + int history_size; + bool tracing; + bool _found; + bool _checked; + bool _delete; + PIVector > history; + }; +#pragma pack (pop) + struct VCO_ElementX { + VCO_Aim_Type type; + double elapsed; + float wls_a; // m/s + float wls_b; // m + float speed; + float acceleration; // m/s^2 + float prediction_pos; // m + float variance; // m + float power; + float angle; + int id; + int missed; + int missed_ml; + int confirmed; + int history_size; + bool tracing; + bool _found; + bool _checked; + bool _delete; + }; + struct VCO_ElementY : VCO_ElementX { + PIVector > history; + }; + VCO_Element v; + VCO_ElementX x; + VCO_ElementY y; + piCout << sizeof(x); + piCout << sizeof(y) << sizeof(y.history) << sizeof(y) - sizeof(y.history) ; + piCout << sizeof(v) << sizeof(v.history) << sizeof(v) - sizeof(v.history) ; + return 0;*/ + + PIVector > in; + in.resize(5); + for (int i = 0; i < in.size_s(); ++i) + for (int j = 0; j < 20; ++j) + in[i] << j+i*100; +// piCout << in.size() << in[0].size(); + PIVector2D f0; + PIVector2D f1(30, 40); + //in.resize(1); + PIVector2D f2(in); + f0 = f2; +// piCout << f0; +// piCout << f1; +// piCout << f2; +// piCout << f2.rows() << f2.cols() << f2.size_all() << f2.rows()*f2.cols(); + piCout << in; + piCout << f2; + piCout << f2.toVectors(); + PIVector t = f2.toPlainVector(); + piCout << t; + piCout << PIVector2D(f2.rows(), f2.cols(), t); + return 0; // PIFFTWf fft; // fft.preparePlan(50, PIFFTWf::foReal); // PIVector out = fft.calcFFT(in); diff --git a/src_main/console/piscreen.h b/src_main/console/piscreen.h index 8d44f260..78995f9f 100644 --- a/src_main/console/piscreen.h +++ b/src_main/console/piscreen.h @@ -1,9 +1,9 @@ /*! \file piscreen.h - * \brief Console output class + * \brief Console GUI class */ /* PIP - Platform Independent Primitives - Console output/input + Console GUI Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru This program is free software: you can redistribute it and/or modify diff --git a/src_main/console/piscreenconsole.h b/src_main/console/piscreenconsole.h index f68a5092..636c60cc 100644 --- a/src_main/console/piscreenconsole.h +++ b/src_main/console/piscreenconsole.h @@ -1,8 +1,34 @@ +/*! \file piscreenconsole.h + * \brief Tile for PIScreen with PIConsole API + * + * This file declares TileVars +*/ +/* + PIP - Platform Independent Primitives + Tile for PIScreen with PIConsole API + Copyright (C) 2017 Andrey Bychkov work.a.b@yandex.ru + + This program 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 3 of the License, or + (at your option) any later version. + + This program 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 more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ #ifndef PISCREENCONSOLE_H #define PISCREENCONSOLE_H #include "piscreentiles.h" +/// NOTE: incomplete class +/// TODO: write TileVars + class PIP_EXPORT TileVars: public PIScreenTile { public: TileVars(const PIString & n = PIString()); diff --git a/src_main/containers/picontainers.h b/src_main/containers/picontainers.h index b3ff06ae..20e9bb53 100755 --- a/src_main/containers/picontainers.h +++ b/src_main/containers/picontainers.h @@ -1,12 +1,12 @@ /*! \file picontainers.h - * \brief Generic containers + * \brief Base for generic containers * * This file declare all containers and useful macros * to use them */ /* PIP - Platform Independent Primitives - Generic containers + Base for generic containers Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru This program is free software: you can redistribute it and/or modify diff --git a/src_main/containers/pilist.h b/src_main/containers/pilist.h index ea46d72b..cc95904e 100644 --- a/src_main/containers/pilist.h +++ b/src_main/containers/pilist.h @@ -1,3 +1,26 @@ +/*! \file pilist.h + * \brief Linked list container, wrapper for std::list + * + * This file declares PIList +*/ +/* + PIP - Platform Independent Primitives + Linked list container, wrapper for std::list + Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru + + This program 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 3 of the License, or + (at your option) any later version. + + This program 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 more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ #ifndef PILIST_H #define PILIST_H #include "pibase.h" diff --git a/src_main/containers/pimap.h b/src_main/containers/pimap.h index 43795744..c8e9753f 100644 --- a/src_main/containers/pimap.h +++ b/src_main/containers/pimap.h @@ -5,7 +5,7 @@ */ /* PIP - Platform Independent Primitives - Dynamic array of any type + Associative array with custom types of key and value Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru This program is free software: you can redistribute it and/or modify diff --git a/src_main/containers/pipair.h b/src_main/containers/pipair.h index 59ed514f..d42b4da5 100644 --- a/src_main/containers/pipair.h +++ b/src_main/containers/pipair.h @@ -1,3 +1,26 @@ +/*! \file pipair.h + * \brief pair + * + * This file declare PIPair +*/ +/* + PIP - Platform Independent Primitives + pair + Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru + + This program 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 3 of the License, or + (at your option) any later version. + + This program 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 more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ #ifndef PIPAIR_H #define PIPAIR_H diff --git a/src_main/containers/piqueue.h b/src_main/containers/piqueue.h index 025786aa..e6da0370 100755 --- a/src_main/containers/piqueue.h +++ b/src_main/containers/piqueue.h @@ -1,4 +1,4 @@ -/*! \file picontainers.h +/*! \file pideque.h * \brief Queue container * * This file declare PIQueue diff --git a/src_main/containers/pivector2d.h b/src_main/containers/pivector2d.h index 59b09f6f..8d5a9cae 100644 --- a/src_main/containers/pivector2d.h +++ b/src_main/containers/pivector2d.h @@ -1,4 +1,4 @@ -/*! \file pivecto2Dr.h +/*! \file pivecto2d.h * \brief 2D wrapper around PIVector * * This file declares PIVector diff --git a/src_main/core/pibitarray.h b/src_main/core/pibitarray.h index 37f53a03..62836e7c 100755 --- a/src_main/core/pibitarray.h +++ b/src_main/core/pibitarray.h @@ -1,3 +1,6 @@ +/*! \file pibitarray.h + * \brief Bit array +*/ /* PIP - Platform Independent Primitives Bit array diff --git a/src_main/core/pichunkstream.h b/src_main/core/pichunkstream.h index 3265a8ad..8a4b1c4d 100644 --- a/src_main/core/pichunkstream.h +++ b/src_main/core/pichunkstream.h @@ -1,9 +1,9 @@ /*! \file pichunkstream.h - * \brief Binary serializator + * \brief Binary markup serializator */ /* PIP - Platform Independent Primitives - Binary serializator + Binary markup serializator Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru This program is free software: you can redistribute it and/or modify diff --git a/src_main/core/picout.cpp b/src_main/core/picout.cpp index 961fb24f..582eed1a 100644 --- a/src_main/core/picout.cpp +++ b/src_main/core/picout.cpp @@ -168,7 +168,7 @@ PICout PICout::operator <<(const PICoutAction v) { case PICoutManipulators::ClearScreen: if (!PICout::buffer_) { #ifdef WINDOWS - /// TODO !!! + /// TODO : wondows ClearScreen !!! /*GetConsoleCursorInfo(__Private__::hOut, &curinfo); curinfo.bVisible = false; SetConsoleCursorInfo(__Private__::hOut, &curinfo); diff --git a/src_main/core/picout.h b/src_main/core/picout.h index b7531a14..4aa8e5b7 100644 --- a/src_main/core/picout.h +++ b/src_main/core/picout.h @@ -105,7 +105,7 @@ namespace PICoutManipulators { }; typedef PIFlags PICoutControls; -}; +} diff --git a/src_main/core/piincludes_p.h b/src_main/core/piincludes_p.h index 5c6b43a3..85a7dfc5 100644 --- a/src_main/core/piincludes_p.h +++ b/src_main/core/piincludes_p.h @@ -1,6 +1,6 @@ /* PIP - Platform Independent Primitives - Initialization + Private PIP includes Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru This program is free software: you can redistribute it and/or modify diff --git a/src_main/core/pipropertystorage.h b/src_main/core/pipropertystorage.h index e2aa114d..0efcac98 100644 --- a/src_main/core/pipropertystorage.h +++ b/src_main/core/pipropertystorage.h @@ -1,3 +1,27 @@ +/*! \file pipropertystorage.h + * \brief Storage of properties for GUI usage + * + * This file declare PIPropertyStorage +*/ +/* + PIP - Platform Independent Primitives + Storage of properties for GUI usage + Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru + + This program 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 3 of the License, or + (at your option) any later version. + + This program 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 more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + #ifndef PIPROPERTYSTORAGE_H #define PIPROPERTYSTORAGE_H diff --git a/src_main/core/pistring_std.h b/src_main/core/pistring_std.h index f6c21b80..9a580896 100644 --- a/src_main/core/pistring_std.h +++ b/src_main/core/pistring_std.h @@ -1,3 +1,26 @@ +/*! \file pistring.h + * \brief String + * + * This file declare std operators and string conversions +*/ +/* + PIP - Platform Independent Primitives + STD for PIString + Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru + + This program 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 3 of the License, or + (at your option) any later version. + + This program 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 more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ #ifndef PISTRING_STD_H #define PISTRING_STD_H #include diff --git a/src_main/io/piserial.h b/src_main/io/piserial.h index 6a45d7c3..ebecd5b6 100755 --- a/src_main/io/piserial.h +++ b/src_main/io/piserial.h @@ -166,11 +166,6 @@ public: //! \returns \b true if sended bytes count = "size" bool send(const void * data, int size) {return (write(data, size) == size);} - /// NOTE: no reason to use this function, use PIString::toUtf8() or PIString::dataAscii(),lengthAscii() instead - //! \brief Write to device string "data" and wait for data written if "wait" is \b true. - //! \returns \b true if sended bytes count = size of string - //bool send(const PIString & data, bool wait = false) {return (write(data.data(), data.lengthAscii(), wait) == data.size_s());} - //! \brief Write to device byte array "data" and wait for data written if "wait" is \b true. //! \returns \b true if sended bytes count = size of string bool send(const PIByteArray & data) {return (write(data.data(), data.size_s()) == data.size_s());}