Commit 420d938b authored by Pavel Vainerman's avatar Pavel Vainerman

backported to p9 as 2.9.3-alt0.M90P.0.1 (with rpmbph script)

parents d03993a8 04ccad89
......@@ -26,8 +26,8 @@
%define oname uniset2
Name: libuniset2
Version: 2.9.2
Release: alt0.M90P.1
Version: 2.9.3
Release: alt0.M90P.0.1
Summary: UniSet - library for building distributed industrial control systems
License: LGPL-2.1
......@@ -560,9 +560,12 @@ rm -f %buildroot%_docdir/%oname/html/*.md5
# history of current unpublished changes
%changelog
* Sat Jan 09 2021 Pavel Vainerman <pv@altlinux.ru> 2.9.2-alt0.M90P.1
* Wed Jan 13 2021 Pavel Vainerman <pv@altlinux.ru> 2.9.3-alt0.M90P.0.1
- backport to ALTLinux p9 (by rpmbph script)
* Wed Jan 13 2021 Pavel Vainerman <pv@altlinux.ru> 2.9.3-alt0.1
- test build for websocketgate
* Sat Jan 09 2021 Pavel Vainerman <pv@altlinux.ru> 2.9.2-alt1
- admin: added 'sinfo' function
- admin: freezeValue -> freeze/unfreeze
......
......@@ -48,6 +48,7 @@
</LogDB>
<BackendOpenTSDB name="BackendOpenTSDB" host="localhost" filter_field="tsdb" filter_value="1" tags="host=localhost uniset=1" prefix="uniset"/>
<UWebSocketGate name="UWebSocketGate1"/>
<settings>
......@@ -5502,6 +5503,7 @@
<item id="6088" name="TestGroup"/>
<item id="6089" name="MQTTPublisher1"/>
<item id="6090" name="BackendOpenTSDB"/>
<item id="6091" name="UWebSocketGate1"/>
<item id="6101" name="MBTCP1"/>
<item id="6102" name="MBTCP2"/>
<item id="6103" name="MBTCP3"/>
......
......@@ -593,6 +593,7 @@ AC_CONFIG_FILES([Makefile
extensions/LogDB/tests/Makefile
extensions/HttpResolver/Makefile
extensions/HttpResolver/tests/Makefile
extensions/UWebSocketGate/Makefile
testsuite/Makefile
wrappers/Makefile
wrappers/python/lib/Makefile
......
......@@ -7,7 +7,7 @@ SUBDIRS = lib include SharedMemory SharedMemory/tests IOControl IOControl/tests
ModbusMaster ModbusSlave SMViewer UniNetwork UNetUDP UNetUDP/tests \
DBServer-MySQL DBServer-SQLite DBServer-PostgreSQL MQTTPublisher \
RRDServer tests ModbusMaster/tests ModbusSlave/tests LogDB LogDB/tests \
Backend-OpenTSDB HttpResolver HttpResolver/tests
Backend-OpenTSDB HttpResolver HttpResolver/tests UWebSocketGate
pkgconfigdir = $(libdir)/pkgconfig
......
bin_PROGRAMS = @PACKAGE@-wsgate
@PACKAGE@_wsgate_LDADD = $(top_builddir)/lib/libUniSet2.la
@PACKAGE@_wsgate_SOURCES = UWebSocketGate.cc main.cc
include $(top_builddir)/include.mk
#ifndef UWebSocketGateSugar_H_
#define UWebSocketGateSugar_H_
// "синтаксический сахар"..
#ifndef myinfo
#define myinfo if( mylog->debugging(Debug::INFO) ) mylog->info()
#endif
#ifndef mywarn
#define mywarn if( mylog->debugging(Debug::WARN) ) mylog->warn()
#endif
#ifndef mycrit
#define mycrit if( mylog->debugging(Debug::CRIT) ) mylog->crit()
#endif
#ifndef mylog1
#define mylog1 if( mylog->debugging(Debug::LEVEL1) ) mylog->level1()
#endif
#ifndef mylog2
#define mylog2 if( mylog->debugging(Debug::LEVEL2) ) mylog->level2()
#endif
#ifndef mylog3
#define mylog3 if( mylog->debugging(Debug::LEVEL3) ) mylog->level3()
#endif
#ifndef mylog4
#define mylog4 if( mylog->debugging(Debug::LEVEL4) ) mylog->level4()
#endif
#ifndef mylog5
#define mylog5 if( mylog->debugging(Debug::LEVEL5) ) mylog->level5()
#endif
#ifndef mylog6
#define mylog6 if( mylog->debugging(Debug::LEVEL6) ) mylog->level6()
#endif
#ifndef mylog7
#define mylog7 if( mylog->debugging(Debug::LEVEL7) ) mylog->level7()
#endif
#ifndef mylog8
#define mylog8 if( mylog->debugging(Debug::LEVEL8) ) mylog->level8()
#endif
#ifndef mylog9
#define mylog9 if( mylog->debugging(Debug::LEVEL9) ) mylog->level9()
#endif
#ifndef mylogany
#define mylogany mylog->any()
#endif
#endif
#include "Configuration.h"
#include "UWebSocketGate.h"
#include "Configuration.h"
#include "UniSetActivator.h"
// --------------------------------------------------------------------------
using namespace uniset;
using namespace std;
// --------------------------------------------------------------------------
int main(int argc, char** argv)
{
// std::ios::sync_with_stdio(false);
try
{
if( argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) )
{
cout << "--confile filename - configuration file. Default: configure.xml" << endl;
UWebSocketGate::help_print();
return 0;
}
auto conf = uniset_init(argc, argv);
auto ws = UWebSocketGate::init_wsgate(argc, argv, "ws-");
if( !ws )
return 1;
auto act = UniSetActivator::Instance();
act->add(ws);
SystemMessage sm(SystemMessage::StartUp);
act->broadcast( sm.transport_msg() );
act->run(false);
return 0;
}
catch( const std::exception& ex )
{
cerr << "(UWebSocketGate::main): " << ex.what() << endl;
}
catch(...)
{
cerr << "(UWebSocketGate::main): catch ..." << endl;
}
return 1;
}
#!/bin/sh
ulimit -Sc 1000000
uniset2-start.sh -f ./uniset2-wsgate --confile test.xml --ws-name UWebSocketGate1 --ws-log-add-levels any $*
../../conf/test.xml
\ No newline at end of file
../../Utilities/scripts/uniset2-functions.sh
\ No newline at end of file
../../Utilities/scripts/uniset2-start.sh
\ No newline at end of file
../../Utilities/scripts/uniset2-stop.sh
\ No newline at end of file
......@@ -33,6 +33,8 @@ namespace uniset
~SMonitor();
// -----
static std::string printEvent( const uniset::SensorMessage* sm );
protected:
virtual void sysCommand( const uniset::SystemMessage* sm ) override;
virtual void sensorInfo( const uniset::SensorMessage* si ) override;
......
......@@ -95,25 +95,33 @@ void SMonitor::sysCommand( const SystemMessage* sm )
}
}
// ------------------------------------------------------------------------------------------
void SMonitor::sensorInfo( const SensorMessage* si )
std::string SMonitor::printEvent( const uniset::SensorMessage* sm )
{
auto conf = uniset_conf();
ostringstream s;
string s_sup("");
if( si->supplier == uniset::AdminID )
if( sm->supplier == uniset::AdminID )
s_sup = "uniset-admin";
else
s_sup = ORepHelpers::getShortName(conf->oind->getMapName(si->supplier));
s_sup = ORepHelpers::getShortName(conf->oind->getMapName(sm->supplier));
cout << "(" << setw(6) << si->id << "):"
<< "[(" << std::right << setw(5) << si->supplier << ")"
s << "(" << setw(6) << sm->id << "):"
<< "[(" << std::right << setw(5) << sm->supplier << ")"
<< std::left << setw(20) << s_sup << "] "
<< std::right << setw(8) << timeToString(si->sm_tv.tv_sec, ":")
<< "(" << setw(6) << si->sm_tv.tv_nsec << "): "
<< std::right << setw(45) << conf->oind->getMapName(si->id)
<< " value:" << std::right << setw(9) << si->value
<< " fvalue:" << std::right << setw(12) << ( (float)si->value / pow(10.0, si->ci.precision) ) << endl;
<< std::right << setw(8) << timeToString(sm->sm_tv.tv_sec, ":")
<< "(" << setw(6) << sm->sm_tv.tv_nsec << "): "
<< std::right << setw(45) << conf->oind->getMapName(sm->id)
<< " value:" << std::right << setw(9) << sm->value
<< " fvalue:" << std::right << setw(12) << ( (float)sm->value / pow(10.0, sm->ci.precision) ) << endl;
return s.str();
}
// ------------------------------------------------------------------------------------------
void SMonitor::sensorInfo( const SensorMessage* si )
{
cout << printEvent(si) << endl;
if( !script.empty() )
{
......@@ -124,7 +132,7 @@ void SMonitor::sensorInfo( const SensorMessage* si )
if( script[0] == '.' || script[0] == '/' )
cmd << script;
else
cmd << conf->getBinDir() << script;
cmd << uniset_conf()->getBinDir() << script;
cmd << " " << si->id << " " << si->value << " " << si->sm_tv.tv_sec << " " << si->sm_tv.tv_nsec;
......
......@@ -295,6 +295,11 @@
./extensions/UniNetwork/UniExchange.cc
./extensions/UniNetwork/UniExchange.h
./extensions/UniNetwork/uninet.cc
./extensions/UWebSocketGate/main.cc
./extensions/UWebSocketGate/Makefile.am
./extensions/UWebSocketGate/UWebSocketGate.cc
./extensions/UWebSocketGate/UWebSocketGate.h
./extensions/UWebSocketGate/UWebSocketGateSugar.h
./IDL/Makefile.am
./IDL/Processes/Makefile.am
./IDL/UniSetTypes/Makefile.am
......
Markdown is supported
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