Commit 2ad8d098 authored by Pavel Vainerman's avatar Pavel Vainerman

add new vtype

parent 70d2a89b
...@@ -5,9 +5,9 @@ test_LDADD = $(top_builddir)/lib/libUniSet.la ...@@ -5,9 +5,9 @@ test_LDADD = $(top_builddir)/lib/libUniSet.la
test_CXXFLAGS = -I$(top_builddir)/include test_CXXFLAGS = -I$(top_builddir)/include
test_SOURCES = TestGen_SK.cc TestGen.cc TestGen-main.cc test_SOURCES = TestGen_SK.cc TestGen.cc TestGen-main.cc
test2_LDADD = $(top_builddir)/lib/libUniSet.la #test2_LDADD = $(top_builddir)/lib/libUniSet.la
test2_CXXFLAGS = -I$(top_builddir)/include #test2_CXXFLAGS = -I$(top_builddir)/include
test2_SOURCES = TestGenAlone_SK.cc TestGenAlone.cc TestGenAlone-main.cc #test2_SOURCES = TestGenAlone_SK.cc TestGenAlone.cc TestGenAlone-main.cc
GENERATED=TestGen_SK.h TestGen_SK.cc TestGen-main.cc GENERATED=TestGen_SK.h TestGen_SK.cc TestGen-main.cc
GENERATED2=TestGenAlone_SK.h TestGenAlone_SK.cc TestGenAlone-main.cc GENERATED2=TestGenAlone_SK.h TestGenAlone_SK.cc TestGenAlone-main.cc
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Name: libuniset Name: libuniset
Version: 0.97 Version: 0.97
Release: eter15 Release: eter16
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
License: GPL License: GPL
Group: Development/C++ Group: Development/C++
...@@ -178,6 +178,9 @@ rm -f %buildroot%_libdir/*.la ...@@ -178,6 +178,9 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc %exclude %_pkgconfigdir/libUniSet.pc
%changelog %changelog
* Sat Sep 26 2009 Pavel Vainerman <pv@altlinux.ru> 0.97-eter15
- new build
* Sat Sep 26 2009 Pavel Vainerman <pv@etersoft.ru> 0.97-eter14 * Sat Sep 26 2009 Pavel Vainerman <pv@etersoft.ru> 0.97-eter14
- add default heartbeat time to Configuration - add default heartbeat time to Configuration
......
...@@ -17,7 +17,9 @@ namespace VTypes ...@@ -17,7 +17,9 @@ namespace VTypes
vtUnknown, vtUnknown,
vtF2, vtF2,
vtF4, vtF4,
vtByte vtByte,
vtUnsigned,
vtSigned
}; };
std::ostream& operator<<( std::ostream& os, const VType& vt ); std::ostream& operator<<( std::ostream& os, const VType& vt );
...@@ -140,6 +142,66 @@ namespace VTypes ...@@ -140,6 +142,66 @@ namespace VTypes
Bytemem raw; Bytemem raw;
}; };
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
class Unsigned
{
public:
// ------------------------------------------
// ...
Unsigned():raw(0){}
Unsigned( const long val )
{
raw = val;
}
Unsigned( const ModbusRTU::ModbusData dat )
{
raw = dat;
}
~Unsigned(){}
// ------------------------------------------
/*! */
static int wsize(){ return sizeof(unsigned short); }
/*! */
static VType type(){ return vtUnsigned; }
// ------------------------------------------
operator long(){ return raw; }
unsigned short raw;
};
// --------------------------------------------------------------------------
class Signed
{
public:
// ------------------------------------------
// ...
Signed():raw(0){}
Signed( const long val )
{
raw = val;
}
Signed( const ModbusRTU::ModbusData dat )
{
raw = dat;
}
~Signed(){}
// ------------------------------------------
/*! */
static int wsize(){ return sizeof(signed short); }
/*! */
static VType type(){ return vtSigned; }
// ------------------------------------------
operator long(){ return raw; }
signed short raw;
};
// --------------------------------------------------------------------------
} // end of namespace VTypes } // end of namespace VTypes
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
......
...@@ -23,6 +23,10 @@ VType str2type( const std::string s ) ...@@ -23,6 +23,10 @@ VType str2type( const std::string s )
return vtF2; return vtF2;
if( s == "F4" ) if( s == "F4" )
return vtF4; return vtF4;
if( s == "Unsigned" )
return vtUnsigned;
if( s == "Signed" )
return vtSigned;
return vtUnknown; return vtUnknown;
} }
...@@ -35,6 +39,10 @@ string type2str( VType t ) ...@@ -35,6 +39,10 @@ string type2str( VType t )
return "F2"; return "F2";
if( t == vtF4 ) if( t == vtF4 )
return "F4"; return "F4";
if( t == vtUnsigned )
return "Unsigned";
if( t == vtSigned )
return "Signed";
return "vtUnknown"; return "vtUnknown";
} }
...@@ -47,6 +55,10 @@ int wsize( VType t ) ...@@ -47,6 +55,10 @@ int wsize( VType t )
return F2::wsize(); return F2::wsize();
if( t == vtF4 ) if( t == vtF4 )
return F4::wsize(); return F4::wsize();
if( t == vtUnsigned )
return Unsigned::wsize();
if( t == vtSigned )
return Signed::wsize();
return 1; return 1;
} }
......
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