Browse Source

Some Preparation to Japan Preview Version

pull/7/head
Evgeny Gagua 4 years ago
parent
commit
90c34999b5
  1. 6
      Projects/argus/argus.vpj
  2. 22
      Projects/argus/makefile
  3. 35
      Projects/argus/sys_ungrant/create_backup.sh
  4. 431
      Projects/argus/sys_ungrant/pishrink.sh
  5. 25
      Projects/argus/sys_ungrant/test.sh
  6. 8
      Projects/argus/sys_ungrant/tete.sh
  7. 7
      Projects/argus/sys_ungrant/upgrade.php
  8. 4
      lib/App/argus/ArgusBackend.cpp
  9. 3
      lib/components/base/basicEvent.h
  10. 6
      lib/components/base/basicMediaDestination.h
  11. 1
      lib/components/base/basicMediaSource.h
  12. 3
      lib/components/base/basicThread.cpp
  13. 18
      lib/data/media/video/videoAVLIBSource.cpp
  14. 25
      lib/data/protocol/protocolKAFKA.cpp
  15. 50
      lib/rgoose/rgooseCamera.cpp
  16. 244
      lib/rgoose/rgooseDBConnector.cpp
  17. 28
      lib/rgoose/rgooseDBConnector.h
  18. 58
      lib/rgoose/rgooseHardwareResourceSerialProvider.cpp
  19. 6
      lib/rgoose/rgooseHardwareResourceSerialProvider.h
  20. 27
      lib/rgoose/rgooseKernel.cpp
  21. 106
      lib/rgoose/rgooseModuleEmbedVideo.cpp
  22. 6
      lib/rgoose/rgooseModuleEmbedVideo.h
  23. 8
      lib/rgoose/rgooseModuleFactory.cpp
  24. 1
      lib/rgoose/rgooseNode.h
  25. 280
      lib/rgoose/rgooseNode2D.cpp
  26. 14
      lib/rgoose/rgooseNode2D.h
  27. 42
      lib/rgoose/rgooseNodeFactory.cpp
  28. 9
      lib/rgoose/rgooseNodeFactory.h
  29. 32
      lib/rgoose/rgooseNodePTZCamControl.cpp
  30. 153
      lib/rgoose/rgooseNodeSensor.cpp
  31. 16
      lib/rgoose/rgooseNodeSensor.h
  32. 17
      lib/rgoose/rgooseNodeStaticCamControl.cpp
  33. 19
      lib/rgoose/rgooseTypes.h

6
Projects/argus/argus.vpj

@ -13,7 +13,7 @@
Version="1"
OutputFile="%bdargus"
CompilerConfigName="Latest Version"
Defines='"/DDEBUG" "/D__STDC_CONSTANT_MACROS" "/D_CLIENT_APPLICATION_" "/D_OPENCV_"'>
Defines='"/DDEBUG" "/D__STDC_CONSTANT_MACROS" "/D_CLIENT_APPLICATION_" "/D_OPENCV_" "/DRASPI_HARDWARE"'>
<Menu>
<Target
Name="Compile"
@ -130,6 +130,7 @@
<Lib File="openssl"/>
<Lib File="opencv4"/>
<Lib File="rdkafka++`"/>
<Lib File="-lwiringPi"/>
</Libs>
</Config>
<Config
@ -139,7 +140,7 @@
Version="1"
OutputFile="%bdargus"
CompilerConfigName="Latest Version"
Defines='"/D__STDC_CONSTANT_MACROS" "/D_CLIENT_APPLICATION_" "/D_OPENCV_"'>
Defines='"/D__STDC_CONSTANT_MACROS" "/D_CLIENT_APPLICATION_" "/D_OPENCV_" "/DRASPI_HARDWARE"'>
<Menu>
<Target
Name="Compile"
@ -257,6 +258,7 @@
<Lib File="libssl"/>
<Lib File="opencv4"/>
<Lib File="rdkafka++`"/>
<Lib File="-lwiringPi"/>
</Libs>
</Config>
<Files>

22
Projects/argus/makefile
File diff suppressed because it is too large
View File

35
Projects/argus/sys_ungrant/create_backup.sh

@ -0,0 +1,35 @@
#!/bin/bash
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter access_log | bzip2 > access_log.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter camera_ptz_protocols | bzip2 > camera_ptz_protocols.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter cameras | bzip2 > cameras.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter connection_types | bzip2 > connection_types.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter connections | bzip2 > connections.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter events_2_pictures | bzip2 > events_2_pictures.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter events_2_videos | bzip2 > events_2_videos.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter events_archive | bzip2 > events_archive.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter events_cloud | bzip2 > events_cloud.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter labels_js | bzip2 > labels_js.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter labels_php | bzip2 > labels_php.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter languages | bzip2 > languages.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter lrf_detection_profiles | bzip2 > lrf_detection_profiles.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter lrf_draw | bzip2 > lrf_draw.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter lrf_mask_trace_zones | bzip2 > lrf_mask_trace_zones.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter lrf_mask_traces | bzip2 > lrf_mask_traces.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter lrf_mask_vertex_points | bzip2 > lrf_mask_vertex_points.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter lrf_mask_vertexes | bzip2 > lrf_mask_vertexes.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter lrf_masks | bzip2 > lrf_masks.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter lrf_runtime_status | bzip2 > lrf_runtime_status.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter lrf_sensors | bzip2 > lrf_sensors.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter lrf_uploads | bzip2 > lrf_uploads.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter map_tiles | bzip2 > map_tiles.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter maps | bzip2 > maps.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter media_server_streams | bzip2 > media_server_streams.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter media_servers | bzip2 > media_servers.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter media_streams | bzip2 > media_streams.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter module_dcr_chanels | bzip2 > module_dcr_chanels.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter module_dcr_settings | bzip2 > module_dcr_settings.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter module_embed_video_settings | bzip2 > module_embed_video_settings.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter module_kafka_settings | bzip2 > module_kafka_settings.sql.bz2
mysqldump -h localhost -u dbroot --skip-comments --compress --quick -pNoGud4U dfsl_gunter module_mm_modems | bzip2 > module_mm_modems.sql.bz2

431
Projects/argus/sys_ungrant/pishrink.sh

@ -0,0 +1,431 @@
#!/bin/bash
version="v0.1.2"
CURRENT_DIR="$(pwd)"
SCRIPTNAME="${0##*/}"
MYNAME="${SCRIPTNAME%.*}"
LOGFILE="${CURRENT_DIR}/${SCRIPTNAME%.*}.log"
REQUIRED_TOOLS="parted losetup tune2fs md5sum e2fsck resize2fs"
ZIPTOOLS=("gzip xz")
declare -A ZIP_PARALLEL_TOOL=( [gzip]="pigz" [xz]="xz" ) # parallel zip tool to use in parallel mode
declare -A ZIP_PARALLEL_OPTIONS=( [gzip]="-f9" [xz]="-T0" ) # options for zip tools in parallel mode
declare -A ZIPEXTENSIONS=( [gzip]="gz" [xz]="xz" ) # extensions of zipped files
function info() {
echo "$SCRIPTNAME: $1 ..."
}
function error() {
echo -n "$SCRIPTNAME: ERROR occurred in line $1: "
shift
echo "$@"
}
function cleanup() {
if losetup "$loopback" &>/dev/null; then
losetup -d "$loopback"
fi
if [ "$debug" = true ]; then
local old_owner=$(stat -c %u:%g "$src")
chown "$old_owner" "$LOGFILE"
fi
}
function logVariables() {
if [ "$debug" = true ]; then
echo "Line $1" >> "$LOGFILE"
shift
local v var
for var in "$@"; do
eval "v=\$$var"
echo "$var: $v" >> "$LOGFILE"
done
fi
}
function checkFilesystem() {
info "Checking filesystem"
e2fsck -pf "$loopback"
(( $? < 4 )) && return
info "Filesystem error detected!"
info "Trying to recover corrupted filesystem"
e2fsck -y "$loopback"
(( $? < 4 )) && return
if [[ $repair == true ]]; then
info "Trying to recover corrupted filesystem - Phase 2"
e2fsck -fy -b 32768 "$loopback"
(( $? < 4 )) && return
fi
error $LINENO "Filesystem recoveries failed. Giving up..."
exit 9
}
function set_autoexpand() {
#Make pi expand rootfs on next boot
mountdir=$(mktemp -d)
partprobe "$loopback"
mount "$loopback" "$mountdir"
if [ ! -d "$mountdir/etc" ]; then
info "/etc not found, autoexpand will not be enabled"
umount "$mountdir"
return
fi
if [[ -f "$mountdir/etc/rc.local" ]] && [[ "$(md5sum "$mountdir/etc/rc.local" | cut -d ' ' -f 1)" != "1c579c7d5b4292fd948399b6ece39009" ]]; then
echo "Creating new /etc/rc.local"
if [ -f "$mountdir/etc/rc.local" ]; then
mv "$mountdir/etc/rc.local" "$mountdir/etc/rc.local.bak"
fi
#####Do not touch the following lines#####
cat <<\EOF1 > "$mountdir/etc/rc.local"
#!/bin/bash
do_expand_rootfs() {
ROOT_PART=$(mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p')
PART_NUM=${ROOT_PART#mmcblk0p}
if [ "$PART_NUM" = "$ROOT_PART" ]; then
echo "$ROOT_PART is not an SD card. Don't know how to expand"
return 0
fi
# Get the starting offset of the root partition
PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d: | sed 's/[^0-9]//g')
[ "$PART_START" ] || return 1
# Return value will likely be error for fdisk as it fails to reload the
# partition table because the root fs is mounted
fdisk /dev/mmcblk0 <<EOF
p
d
$PART_NUM
n
p
$PART_NUM
$PART_START
p
w
EOF
cat <<EOF > /etc/rc.local &&
#!/bin/sh
echo "Expanding /dev/$ROOT_PART"
resize2fs /dev/$ROOT_PART
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
EOF
reboot
exit
}
raspi_config_expand() {
/usr/bin/env raspi-config --expand-rootfs
if [[ $? != 0 ]]; then
return -1
else
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
reboot
exit
fi
}
raspi_config_expand
echo "WARNING: Using backup expand..."
sleep 5
do_expand_rootfs
echo "ERROR: Expanding failed..."
sleep 5
if [[ -f /etc/rc.local.bak ]]; then
cp -f /etc/rc.local.bak /etc/rc.local
/etc/rc.local
fi
exit 0
EOF1
#####End no touch zone#####
chmod +x "$mountdir/etc/rc.local"
fi
umount "$mountdir"
}
help() {
local help
read -r -d '' help << EOM
Usage: $0 [-adhrspvzZ] imagefile.img [newimagefile.img]
-s Don't expand filesystem when image is booted the first time
-v Be verbose
-r Use advanced filesystem repair option if the normal one fails
-z Compress image after shrinking with gzip
-Z Compress image after shrinking with xz
-a Compress image in parallel using multiple cores
-p Remove logs, apt archives, dhcp leases and ssh hostkeys
-d Write debug messages in a debug log file
EOM
echo "$help"
exit 1
}
should_skip_autoexpand=false
debug=false
repair=false
parallel=false
verbose=false
prep=false
ziptool=""
while getopts ":adhprsvzZ" opt; do
case "${opt}" in
a) parallel=true;;
d) debug=true;;
h) help;;
p) prep=true;;
r) repair=true;;
s) should_skip_autoexpand=true ;;
v) verbose=true;;
z) ziptool="gzip";;
Z) ziptool="xz";;
*) help;;
esac
done
shift $((OPTIND-1))
if [ "$debug" = true ]; then
info "Creating log file $LOGFILE"
rm "$LOGFILE" &>/dev/null
exec 1> >(stdbuf -i0 -o0 -e0 tee -a "$LOGFILE" >&1)
exec 2> >(stdbuf -i0 -o0 -e0 tee -a "$LOGFILE" >&2)
fi
echo "${0##*/} $version"
#Args
src="$1"
img="$1"
#Usage checks
if [[ -z "$img" ]]; then
help
fi
if [[ ! -f "$img" ]]; then
error $LINENO "$img is not a file..."
exit 2
fi
if (( EUID != 0 )); then
error $LINENO "You need to be running as root."
exit 3
fi
# set locale to POSIX(English) temporarily
# these locale settings only affect the script and its sub processes
export LANGUAGE=POSIX
export LC_ALL=POSIX
export LANG=POSIX
# check selected compression tool is supported and installed
if [[ -n $ziptool ]]; then
if [[ ! " ${ZIPTOOLS[@]} " =~ $ziptool ]]; then
error $LINENO "$ziptool is an unsupported ziptool."
exit 17
else
if [[ $parallel == true && $ziptool == "gzip" ]]; then
REQUIRED_TOOLS="$REQUIRED_TOOLS pigz"
else
REQUIRED_TOOLS="$REQUIRED_TOOLS $ziptool"
fi
fi
fi
#Check that what we need is installed
for command in $REQUIRED_TOOLS; do
command -v $command >/dev/null 2>&1
if (( $? != 0 )); then
error $LINENO "$command is not installed."
exit 4
fi
done
#Copy to new file if requested
if [ -n "$2" ]; then
f="$2"
if [[ -n $ziptool && "${f##*.}" == "${ZIPEXTENSIONS[$ziptool]}" ]]; then # remove zip extension if zip requested because zip tool will complain about extension
f="${f%.*}"
fi
info "Copying $1 to $f..."
cp --reflink=auto --sparse=always "$1" "$f"
if (( $? != 0 )); then
error $LINENO "Could not copy file..."
exit 5
fi
old_owner=$(stat -c %u:%g "$1")
chown "$old_owner" "$f"
img="$f"
fi
# cleanup at script exit
trap cleanup EXIT
#Gather info
info "Gathering data"
beforesize="$(ls -lh "$img" | cut -d ' ' -f 5)"
parted_output="$(parted -ms "$img" unit B print)"
rc=$?
if (( $rc )); then
error $LINENO "parted failed with rc $rc"
info "Possibly invalid image. Run 'parted $img unit B print' manually to investigate"
exit 6
fi
partnum="$(echo "$parted_output" | tail -n 1 | cut -d ':' -f 1)"
partstart="$(echo "$parted_output" | tail -n 1 | cut -d ':' -f 2 | tr -d 'B')"
if [ -z "$(parted -s "$img" unit B print | grep "$partstart" | grep logical)" ]; then
parttype="primary"
else
parttype="logical"
fi
loopback="$(losetup -f --show -o "$partstart" "$img")"
tune2fs_output="$(tune2fs -l "$loopback")"
rc=$?
if (( $rc )); then
echo "$tune2fs_output"
error $LINENO "tune2fs failed. Unable to shrink this type of image"
exit 7
fi
currentsize="$(echo "$tune2fs_output" | grep '^Block count:' | tr -d ' ' | cut -d ':' -f 2)"
blocksize="$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':' -f 2)"
logVariables $LINENO beforesize parted_output partnum partstart parttype tune2fs_output currentsize blocksize
#Check if we should make pi expand rootfs on next boot
if [ "$parttype" == "logical" ]; then
echo "WARNING: PiShrink does not yet support autoexpanding of this type of image"
elif [ "$should_skip_autoexpand" = false ]; then
set_autoexpand
else
echo "Skipping autoexpanding process..."
fi
if [[ $prep == true ]]; then
info "Syspreping: Removing logs, apt archives, dhcp leases and ssh hostkeys"
mountdir=$(mktemp -d)
mount "$loopback" "$mountdir"
rm -rvf $mountdir/var/cache/apt/archives/* $mountdir/var/lib/dhcpcd5/* $mountdir/var/log/* $mountdir/var/tmp/* $mountdir/tmp/* $mountdir/etc/ssh/*_host_*
umount "$mountdir"
fi
#Make sure filesystem is ok
checkFilesystem
if ! minsize=$(resize2fs -P "$loopback"); then
rc=$?
error $LINENO "resize2fs failed with rc $rc"
exit 10
fi
minsize=$(cut -d ':' -f 2 <<< "$minsize" | tr -d ' ')
logVariables $LINENO currentsize minsize
if [[ $currentsize -eq $minsize ]]; then
error $LINENO "Image already shrunk to smallest size"
exit 11
fi
#Add some free space to the end of the filesystem
extra_space=$(($currentsize - $minsize))
logVariables $LINENO extra_space
for space in 5000 1000 100; do
if [[ $extra_space -gt $space ]]; then
minsize=$(($minsize + $space))
break
fi
done
logVariables $LINENO minsize
#Shrink filesystem
info "Shrinking filesystem"
resize2fs -p "$loopback" $minsize
rc=$?
if (( $rc )); then
error $LINENO "resize2fs failed with rc $rc"
mount "$loopback" "$mountdir"
mv "$mountdir/etc/rc.local.bak" "$mountdir/etc/rc.local"
umount "$mountdir"
losetup -d "$loopback"
exit 12
fi
sleep 1
#Shrink partition
partnewsize=$(($minsize * $blocksize))
newpartend=$(($partstart + $partnewsize))
logVariables $LINENO partnewsize newpartend
parted -s -a minimal "$img" rm "$partnum"
rc=$?
if (( $rc )); then
error $LINENO "parted failed with rc $rc"
exit 13
fi
parted -s "$img" unit B mkpart "$parttype" "$partstart" "$newpartend"
rc=$?
if (( $rc )); then
error $LINENO "parted failed with rc $rc"
exit 14
fi
#Truncate the file
info "Shrinking image"
endresult=$(parted -ms "$img" unit B print free)
rc=$?
if (( $rc )); then
error $LINENO "parted failed with rc $rc"
exit 15
fi
endresult=$(tail -1 <<< "$endresult" | cut -d ':' -f 2 | tr -d 'B')
logVariables $LINENO endresult
truncate -s "$endresult" "$img"
rc=$?
if (( $rc )); then
error $LINENO "trunate failed with rc $rc"
exit 16
fi
# handle compression
if [[ -n $ziptool ]]; then
options=""
envVarname="${MYNAME^^}_${ziptool^^}" # PISHRINK_GZIP or PISHRINK_XZ environment variables allow to override all options for gzip or xz
[[ $parallel == true ]] && options="${ZIP_PARALLEL_OPTIONS[$ziptool]}"
[[ -v $envVarname ]] && options="${!envVarname}" # if environment variable defined use these options
[[ $verbose == true ]] && options="$options -v" # add verbose flag if requested
if [[ $parallel == true ]]; then
parallel_tool="${ZIP_PARALLEL_TOOL[$ziptool]}"
info "Using $parallel_tool on the shrunk image"
if ! $parallel_tool ${options} "$img"; then
rc=$?
error $LINENO "$parallel_tool failed with rc $rc"
exit 18
fi
else # sequential
info "Using $ziptool on the shrunk image"
if ! $ziptool ${options} "$img"; then
rc=$?
error $LINENO "$ziptool failed with rc $rc"
exit 19
fi
fi
img=$img.${ZIPEXTENSIONS[$ziptool]}
fi
aftersize=$(ls -lh "$img" | cut -d ' ' -f 5)
logVariables $LINENO aftersize
info "Shrunk $img from $beforesize to $aftersize"

25
Projects/argus/sys_ungrant/test.sh

@ -0,0 +1,25 @@
#!/bin/bash
FILE=/srv/etc/upgrade.php
if [ -f "$FILE" ]; then
echo "System Upgrade $FILE exists."
echo "Starting Upgrade ..."
/usr/bin/php $FILE
cp $FILE "$FILE.old"
else
echo "No Upgrade!"
fi
bz2
tar -jxf file.tar --directory /path/to/directory
-z = gz
-J = xz
-v = verbose
tar -cvjSf folder.tar.bz2 folder
tar -cvjSf folder.tar.bz2 *

8
Projects/argus/sys_ungrant/tete.sh

@ -0,0 +1,8 @@
#!/bin/bash
#mysqldump -h localhost -u dbroot –p --protocol=TCP dfsl_gunter servers > dumpfilename.sql
#mysqldump -h localhost -P 3306 -u dbroot --protocol=TCP -pNoGud4U dfsl_gunter servers > dumpfilename.sql
mysqldump -h localhost -P 3306 -u dbroot --protocol=TCP --skip-comments --compress --quick -pNoGud4U dfsl_gunter > dumpfilename.sql

7
Projects/argus/sys_ungrant/upgrade.php

@ -0,0 +1,7 @@
<?php
echo "System Upgrade Started!\n\n";
?>

4
lib/App/argus/ArgusBackend.cpp

@ -130,7 +130,7 @@ int main (int argc, char *argv[]){
switch( argv[i][1] ){
case 'h': case 'H': case 'v': case 'V': case '?':{
printf( "Dr Frucht Systems R-Goose Server\n");
printf( "Software version <%s>\n", VERSION_NUMBER );
printf( "Software version <%s>\n", ARGUS_BUILD_STRING );
printf( " -h -H This Message\n" );
printf( " -i -I Interactive Mode\n" );
return 0;
@ -195,7 +195,7 @@ int main (int argc, char *argv[]){
};
// Demonizing or not
if( WBG ){
printf( "Dr Frucht Systems LRF Server ver. %s\n", VERSION_NUMBER );
printf( "Dr Frucht Systems LRF Server ver. <%s>\n", ARGUS_BUILD_STRING );
printf( "Configuration Applied:\n");
printf( " Service Established %s at %d\n", gsCFG_ADDRESS, guCFG_PORT );
printf( " PID File: %s\n", gsCFG_PID_FILE );

3
lib/components/base/basicEvent.h

@ -66,7 +66,8 @@ typedef enum E_basicEventTypeID {
EVT_CAMERA_DM = 33,
EVT_CAMERA_ON_POSITION = 34,
EVT_ERROR = 35,
EVT_COUNT = 36
EVT_ROI_ACTIVE = 36,
EVT_COUNT = 37
} basicEventTypeID;

6
lib/components/base/basicMediaDestination.h

@ -16,9 +16,9 @@ class basicMediaDestination {
public:
basicMediaDestination();
virtual ~basicMediaDestination();
virtual void pushFrame(AVFrame *Frame, void* src = NULL) {};
virtual void pushFrame(cv::Mat *Frame, void* src = NULL) {};
virtual void pushFrame(cv::Mat &Frame, void* src = NULL) {};
virtual bool pushFrame(AVFrame *Frame, void* src = NULL) { return false; };
virtual bool pushFrame(cv::Mat *Frame, void* src = NULL) { return false; };
virtual bool pushFrame(cv::Mat &Frame, void* src = NULL) { return false; };
virtual void setError(bool A, CSTR BOBO = NULL ){};
virtual int startRecord(uint32_t FramesToRecord) { return -1; };
virtual void startRecord(CSTR FileName) {};

1
lib/components/base/basicMediaSource.h

@ -24,6 +24,7 @@ class basicMediaSource {
};
return false;
};
bool isAttached( void ) { return ( m_pMediaDestination != NULL ); };
void setStreaming(bool T){ m_bStreamingSource = T; };
virtual bool _stop(void){ return true; };
MediaStateStatus getStatus( void ){ return m_eMediaStatus;};

3
lib/components/base/basicThread.cpp

@ -10,7 +10,7 @@ bool basicThread::init( void ){
#ifdef DEBUG_EXTRA
LOG("Init Single Thread");
#endif
if (m_bThreadStatus == TH_PRE_INIT) {
if( m_bThreadStatus == TH_PRE_INIT ){
m_bThreadStatus = TH_ARMED;
#if defined( __linux__ ) || defined(WIN_PTHREAD)
int RetVal = pthread_create( &m_sThreadHandler, NULL, m_fThreadEntryPoint, ( void * ) this );
@ -85,6 +85,7 @@ bool basicThread::uninit( void ){
WaitForSingleObject(m_hThreadHandle, DEFAULT_THREAD_SLEEP_TIME);
CloseHandle(m_hThreadHandle);
#endif
m_bThreadStatus = TH_PRE_INIT;
return true;
};

18
lib/data/media/video/videoAVLIBSource.cpp

@ -299,6 +299,7 @@ bool videoAVLIBSource::_open(char *URI, bool ShowDeviceMenu, float framerate, in
#endif
av_dict_set(&m_pVideoState->m_pFormatOpts, "rtsp_transport", "tcp", 0);
av_dict_set(&m_pVideoState->m_pFormatOpts, "stimeout", "5000000", 0);
av_dict_set(&m_pVideoState->m_pFormatOpts, "buffer_size", "1024000", 0);
} else {
#ifdef DEBUG
LOG("Linux Video Device");
@ -307,13 +308,18 @@ bool videoAVLIBSource::_open(char *URI, bool ShowDeviceMenu, float framerate, in
m_bSizeIsAutomatic = false;
sprintf(tChar, "%dx%d", width, height);
av_dict_set(&m_pVideoState->m_pFormatOpts, "video_size", tChar, 0);
if( inputPin > 0 ) {
switch ( inputPin ) {
case 1: av_dict_set(&m_pVideoState->m_pFormatOpts, "pixel_format", "YUYV", 0); break;
case 2: av_dict_set(&m_pVideoState->m_pFormatOpts, "pixel_format", "MJPEG", 0); break;
};
};
} else {
//m_bSizeIsAutomatic = true;
};
av_dict_set(&m_pVideoState->m_pFormatOpts, "fflags", "nobuffer", 0);
};
av_dict_set(&m_pVideoState->m_pFormatOpts, "buffer_size", "1024000", 0);
av_dict_set(&m_pVideoState->m_pFormatOpts, "max_delay", "100", 0);
av_dict_set(&m_pVideoState->m_pFormatOpts, "fflags", "nobuffer", 0);
av_dict_set(&m_pVideoState->m_pFormatOpts, "max_delay", "100", 0);
//av_dict_set(&options, "analyzeduration", "1000000", 0);
if( framerate != -1 ){
sprintf(tChar, "%0.2f", framerate);
@ -321,7 +327,7 @@ bool videoAVLIBSource::_open(char *URI, bool ShowDeviceMenu, float framerate, in
av_dict_set(&m_pVideoState->m_pFormatOpts, "framerate", tChar, 0);
//av_dict_set(&options, "frame_rate", tChar, 0);
};
//av_dict_set(&options, "pixel_format", "mjpeg", 0);
//av_dict_set(&options, "timeout", "8000", 0);
int RetVal = 0;
strncpy( m_pVideoState->m_pFileName, URI, MAX_PATH_LEN );
@ -649,7 +655,9 @@ void videoAVLIBSource::m_fThreadProc( void ){
//LOG(tB);
memcpy( mRGB.data, pFrameBGR->data[0], pFrameBGR->linesize[0] * m_nHeight );
//LOG("13");
m_pMediaDestination->pushFrame( mRGB, m_pOpaque );
if(!m_pMediaDestination->pushFrame( mRGB, m_pOpaque )){
m_pMediaDestination = NULL;
};
//LOG("14");
} catch (cv::Exception & e) {
LOG_ERROR( e.msg.c_str() );

25
lib/data/protocol/protocolKAFKA.cpp

@ -251,6 +251,18 @@ bool protocolKAFKA::init(){
delete( tGlobalConf );
return false;
};
//std::string Kuser = "";
//std::string Kpass = "";
//if( tGlobalConf->set( "sasl.username", Kuser, tBuffer ) != RdKafka::Conf::CONF_OK ){
// LOG_ERROR( tBuffer.c_str() );
// delete( tGlobalConf );
// return false;
//};
//if( tGlobalConf->set( "sasl.password", Kuser, tBuffer ) != RdKafka::Conf::CONF_OK ){
// LOG_ERROR( tBuffer.c_str() );
// delete( tGlobalConf );
// return false;
//};
#ifdef DEBUG_KAFKA
LOG( m_pKafkaBrokerSTR );
LOG("bootstrap.servers is SET");
@ -381,7 +393,7 @@ retry:
BufferSize,
NULL,
NULL
);
);
if( err != RdKafka::ERR_NO_ERROR ) {
///std::cerr << "% Failed to produce to topic " << topic << ": " << RdKafka::err2str(err) << std::endl;
sprintf( tBuf, "Failed to produce to topic[%s]: %s", topic.c_str(), RdKafka::err2str(err).c_str() );
@ -404,7 +416,16 @@ retry:
}
#ifdef DEBUG_KAFKA
else {
sprintf( tBuf, "Enqueued message (%d bytes) for topic %s", BufferSize, topic.c_str() );
//MOCK
FILE *fd;
fd = fopen("KAFKA_M.txt","a+");
if ( fd ) {
fprintf( fd, "\n*****************\n");
fprintf( fd, Buffer );
fprintf( fd, "\n*****************\nEnqueued message (%d bytes) for topic %s\n", BufferSize, topic.c_str());
fclose( fd );
};
sprintf(tBuf, "Enqueued message (%d bytes) for topic %s", BufferSize, topic.c_str());
LOG( tBuf );
}
#endif

50
lib/rgoose/rgooseCamera.cpp

@ -1016,6 +1016,7 @@ void ARGUS_Camera::m_fThreadProc( void ){
// Lowest Priority to Web Client Commands
PUSHED = m_pDBC->getNodePushedCMD( m_sCamData.node_id );
if( PUSHED != NULL ) {
m_pDBC->updateNodePushedCMD( PUSHED->id, DBC_CMD_READY_TO_CLEAN );
if( ( PUSHED->CMD & ARGUS_CAM_PCMD_CMD_MASK ) == ARGUS_CAM_PCMD_CMD_MASK ) {
switch( PUSHED->CMD ) {
case 0x80:{
@ -1266,7 +1267,10 @@ bool ARGUS_Camera::connectToStream( uint32_t id ){
if( tDATA ) {
LOG( tDATA->mrl_proto );
m_sMediaSource.mediaStreamId = id;
m_pSource = new videoAVLIBSource( &m_sMediaSource );
if( m_pSource != NULL ) delete( m_pSource );
m_pSource = new videoAVLIBSource(&m_sMediaSource);
if( m_pSource != NULL ) {
char tMRL[1024];
#ifdef DEBUG
@ -1274,14 +1278,25 @@ bool ARGUS_Camera::connectToStream( uint32_t id ){
#endif
int tW = ((argusModuleEmbedVideo*)tKM)->getWidh();
int tH = ((argusModuleEmbedVideo*)tKM)->getHeight();
int pix = -1;
bool in_16_9 = (((tDATA->width*100) / tDATA->height ) > 140 );
bool out_16_9 = (((tW*100) / tH ) > 140 );
updateOpticalParameters( tW, tH );
if( strlen( tDATA->c_type ) ){
if( tW > 0 ) {
//m_pSource->setProportionalByWidth( tW );
m_pSource->setSize( tW, tH );
};
if( strncmp( tDATA->mrl_proto, "v4l2", 4 ) == 0 ){
//if( tW > 0 ){
// //m_pSource->setProportionalByWidth( tW );
// m_pSource->setSize( tW, tH );
//};
if( in_16_9 != out_16_9 ){
if( in_16_9 ){
tH = ((( tW * 1000 ) / 16 ) * 9 ) / 1000;
} else {
tW = ((( tH * 1000 ) / 3 ) * 4 ) / 1000;
};
};
if (strncmp(tDATA->mrl_proto, "v4l2", 4) == 0) {
sprintf( tMRL, tDATA->mrl );
} else {
DBC_CAM_DATA *tCAM = m_pDBC->getCamData( tDATA->source_id );
@ -1296,8 +1311,7 @@ bool ARGUS_Camera::connectToStream( uint32_t id ){
};
};
LOG( tMRL );
//m_pSource = new videoAVLIBSource( tMRL, &m_sMediaSource );
if( m_pSource->_open( tMRL ) ) {
if( m_pSource->_open( tMRL, false, -1, pix, tDATA->width, tDATA->height, true, tW, tH ) ){
m_bSourceConnected = m_pSource->attachDestination( (argusModuleEmbedVideo*) tKM );
if ( !m_bSourceConnected ) {
delete( m_pSource );
@ -1315,7 +1329,7 @@ bool ARGUS_Camera::connectToStream( uint32_t id ){
};
} else {
LOG_ERROR("Video Source Stream Failure!");
};
};
free( tDATA );
};
}
@ -1341,14 +1355,18 @@ bool ARGUS_Camera::disconnectFromStream( void ){
bool ARGUS_Camera::validateStream( void ){
if( m_bSourceConnected ) {
if( m_pSource ) {
if( !m_pSource->isFinished() ){
return true;
if( m_pSource->isAttached() ){
if( !m_pSource->isFinished() ) return true;
#ifdef DEBUG
LOG("Source is Finished!");
#endif
};
LOG("Source is Finished!");
} else {
LOG_ERROR("No Source Object! Set Disconnected!");
m_bSourceConnected = false;
};
#ifdef DEBUG
LOG("Source is Disconnected!");
#endif
} else LOG_ERROR("No Source Object! Set Disconnected!");
disconnectFromStream();
};
return false;
};

244
lib/rgoose/rgooseDBConnector.cpp

@ -783,15 +783,23 @@ bool argusDBC::getAllCamRecords( uint32_t SiteID, vectorCamRecords &VR ){
};
DBC_INT_LIST *argusDBC::listNodes( uint32_t SiteID, bool all ){
DBC_INT_LIST *argusDBC::listNodes( uint32_t SiteID, uint32_t ServerID, bool all ){
DBC_INT_LIST * tVal = NULL;
if( m_bIsConnected ){
char tQBuf[1024];
AAssoc *result;
if( all ) {
sprintf(tQBuf, "SELECT `id` FROM `nodes` WHERE `site_id`=%d", SiteID);
if ( ServerID == 0 ) {
sprintf(tQBuf, "SELECT `id` FROM `nodes` WHERE `site_id`=%d", SiteID);
} else {
sprintf(tQBuf, "SELECT `id` FROM `nodes` WHERE `site_id`=%d AND `server_id`=%d", SiteID, ServerID );
};
} else {
sprintf(tQBuf, "SELECT `id` FROM `nodes` WHERE `site_id`=%d AND `type` > 0", SiteID);
if ( ServerID == 0 ){
sprintf(tQBuf, "SELECT `id` FROM `nodes` WHERE `site_id`=%d AND `type` > 0", SiteID );
} else {
sprintf(tQBuf, "SELECT `id` FROM `nodes` WHERE `site_id`=%d AND `server_id`=%d AND `type` > 0", SiteID, ServerID );
};
};
#ifdef DEBUG_EXTRA
LOG(tQBuf);
@ -818,7 +826,7 @@ DBC_INT_LIST *argusDBC::listNodes( uint32_t SiteID, bool all ){
return tVal;
};
DBC_INT_LIST *argusDBC::listNewNodes( uint32_t SiteID, DBC_INT_LIST *old_ids ){
DBC_INT_LIST *argusDBC::listNewNodes( uint32_t SiteID, uint32_t ServerID, DBC_INT_LIST *old_ids ){
DBC_INT_LIST * tVal = NULL;
char tParam[CTEXT];
//memset( tParam, 0, CTEXT );
@ -833,7 +841,11 @@ DBC_INT_LIST *argusDBC::listNewNodes( uint32_t SiteID, DBC_INT_LIST *old_ids ){
if( m_bIsConnected ){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT id FROM nodes WHERE `site_id`=%d AND `type` > 0 AND `id` NOT IN(%s)", SiteID, tParam );
if ( ServerID == 0 ) {
sprintf(tQBuf, "SELECT id FROM nodes WHERE `site_id`=%d AND `type` > 0 AND `id` NOT IN(%s)", SiteID, tParam);
} else {
sprintf(tQBuf, "SELECT id FROM nodes WHERE `site_id`=%d AND `server_id`=%d AND `type` > 0 AND `id` NOT IN(%s)", SiteID, ServerID, tParam );
};
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
@ -2511,7 +2523,87 @@ DBC_CAM_DATA *argusDBC::getCamData( uint32_t ID ){
return tVal;
};
DBC_PUSHED_CMD *argusDBC::getNodePushedCMD( uint32_t NodeID ){
DBC_PUSHED_CMD *argusDBC::getActivePushedCMD( uint32_t NodeID ){
DBC_PUSHED_CMD *RetVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT * FROM `nodes_qcq` WHERE `node_id`=%d AND `status` > 0 AND `status` < 100", NodeID );
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
if( result!= NULL ) {
if( result->size() > 0 ) {
RetVal = (DBC_PUSHED_CMD*)malloc(sizeof(DBC_PUSHED_CMD));
if( RetVal ) {
Assoc * cArr;
Assoc::iterator it;
memset( RetVal, 0, sizeof(DBC_PUSHED_CMD));
cArr = result->at(0);
it = cArr->find("id");
if( it != cArr->end() ){
RetVal->id = atoi( it->second.c_str() );
};
it = cArr->find("cmd");
if( it != cArr->end() ){
RetVal->CMD = atoi( it->second.c_str() );
};
it = cArr->find("parameter");
if( it != cArr->end() ){
strncpy( RetVal->PARAM, it->second.c_str(), 256 );
RetVal->PARAM[255] = (char)0;
};
};
};
};
deleteResult( result );
};
return RetVal;
};
DBC_PUSHED_CMD *argusDBC::getPushedCMD( uint32_t CmdID ){
DBC_PUSHED_CMD *RetVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
AAssoc *result;
sprintf(tQBuf, "SELECT * FROM `nodes_qcq` WHERE `id`=%d", CmdID );
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
if( result!= NULL ) {
if( result->size() > 0 ) {
RetVal = (DBC_PUSHED_CMD*)malloc(sizeof(DBC_PUSHED_CMD));
if( RetVal ) {
Assoc * cArr;
Assoc::iterator it;
memset( RetVal, 0, sizeof(DBC_PUSHED_CMD));
cArr = result->at(0);
it = cArr->find("id");
if( it != cArr->end() ){
RetVal->id = atoi( it->second.c_str() );
};
it = cArr->find("cmd");
if( it != cArr->end() ){
RetVal->CMD = atoi( it->second.c_str() );
};
it = cArr->find("parameter");
if( it != cArr->end() ){
strncpy( RetVal->PARAM, it->second.c_str(), 256 );
RetVal->PARAM[255] = (char)0;
};
};
};
};
deleteResult( result );
};
return RetVal;
};
DBC_PUSHED_CMD *argusDBC::getNodePushedCMD( uint32_t NodeID ){
DBC_PUSHED_CMD *RetVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
@ -2544,8 +2636,8 @@ DBC_PUSHED_CMD *argusDBC::getNodePushedCMD( uint32_t NodeID ){
RetVal->PARAM[255] = (char)0;
};
//Only If Result is Fetched - Clear Current CMD
sprintf(tQBuf, "DELETE FROM `nodes_qcq` WHERE `id`=%d", RetVal->id );
m_pDatabase->SilentQuery( tQBuf );
//sprintf(tQBuf, "DELETE FROM `nodes_qcq` WHERE `id`=%d", RetVal->id );
//m_pDatabase->SilentQuery( tQBuf );
};
};
};
@ -2554,7 +2646,18 @@ DBC_PUSHED_CMD *argusDBC::getNodePushedCMD( uint32_t NodeID ){
return RetVal;
};
bool argusDBC::updateNodePushedCMD( uint32_t CmdID, uint8_t status ){
if(m_bIsConnected){
char tQBuf[CTEXT];
sprintf(tQBuf, "UPDATE `nodes_qcq` SET `status`=%d WHERE `id`=%d ", status, CmdID );
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
return true;
};
return false;
};
DBC_MODULE_DATA *argusDBC::getModuleData( uint32_t ID ){
DBC_MODULE_DATA *tVal = NULL;
@ -2654,6 +2757,7 @@ DBC_MEDIA_STREAM_DATA *argusDBC::getMediaStreamData( uint32_t ID ){
Assoc *cArr;
tVal = (DBC_MEDIA_STREAM_DATA*) malloc(sizeof(DBC_MEDIA_STREAM_DATA));
if( tVal != NULL ) {
memset( tVal, 0, sizeof(DBC_MEDIA_STREAM_DATA) );
Assoc::iterator it;
cArr = result->at(0);
tVal->id = ID;
@ -2685,6 +2789,14 @@ DBC_MEDIA_STREAM_DATA *argusDBC::getMediaStreamData( uint32_t ID ){
if( it != cArr->end() ){
tVal->height = atoi( it->second.c_str() );
};
it = cArr->find("fps");
if( it != cArr->end() ){
tVal->fps = atoi( it->second.c_str() );
};
it = cArr->find("compression_type");
if( it != cArr->end() ){
sprintf(tVal->c_type, it->second.c_str());
};
it = cArr->find("mrl_proto");
if( it != cArr->end() ){
sprintf( tVal->mrl_proto, it->second.c_str() );
@ -2844,55 +2956,58 @@ DBC_MEDIA_SERVER_STREAM_DATA *argusDBC::getMediaServerStreamData( uint32_t ID ){
return tVal;
};
void argusDBC::registerServer(uint32_t SiteID, CSTR identity, int PID ){
void argusDBC::registerServer( uint32_t SiteID, CSTR identity, int PID, uint32_t *ServID, uint32_t *ServNode ){
if(m_bIsConnected){
m_nSiteID = SiteID;
char tQBuf[CTEXT];
sprintf(tQBuf,"INSERT INTO servers SET `site_id`=%d, `identity`='%s', `online`=1, `ts`=UNIX_TIMESTAMP(now()), pid=%d ON DUPLICATE KEY UPDATE `ts`=UNIX_TIMESTAMP(now()), `online`=1, pid=%d", SiteID, identity, PID, PID );
#ifdef DEBUG_ALL
char tQBuf[MAX_PATH_LEN];
sprintf( tQBuf, "INSERT INTO servers SET `site_id`=%d, `identity`='%s', `version_string`='%s', `online`=1, `ts`=UNIX_TIMESTAMP(now()), pid=%d ON DUPLICATE KEY UPDATE `version_string`='%s', `ts`=UNIX_TIMESTAMP(now()), `online`=1, pid=%d",
SiteID, identity, ARGUS_BUILD_STRING, PID, ARGUS_BUILD_STRING, PID );
#ifdef DEBUG
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
// Clenup Nodes and services ...
sprintf(tQBuf,"UPDATE nodes SET `online`=0 WHERE `site_id`=%d ", SiteID );
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
sprintf(tQBuf,"UPDATE cameras SET `online`=0 WHERE `site_id`=%d ", SiteID );
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
*ServID = getServerID( identity );
if( *ServID ) {
sprintf(tQBuf,"UPDATE media_streams SET `valid`=0 WHERE `site_id`=%d ", SiteID );
sprintf(tQBuf,"INSERT INTO nodes SET `site_id`=%d, `aux_id`='%d', `type`= 0, `online`=1, `name`='Server Node' ON DUPLICATE KEY UPDATE `online`=1", m_nSiteID, *ServID );
#ifdef DEBUG_ALL
LOG(tQBuf);
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
*ServNode = ( uint32_t ) m_pDatabase->QueryID( tQBuf );
sprintf(tQBuf,"UPDATE media_server_streams SET `valid`=0, `online`=0 WHERE `site_id`=%d ", SiteID );
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
if( *ServNode == 0 ){
*ServNode = getServerNode( *ServID );
};
uint32_t tServerID = getServerID( identity );
if( tServerID ) {
sprintf(tQBuf,"INSERT INTO nodes SET `site_id`=%d, `aux_id`='%d', `type`= 0, `online`=1, `name`='Server Node' ON DUPLICATE KEY UPDATE `online`=1", m_nSiteID, tServerID );
#ifdef DEBUG_ALL
// Clenup Nodes and services ...
sprintf(tQBuf,"UPDATE nodes SET `online`=0 WHERE `server_id`=%d ", *ServID );
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif
uint32_t tServerNodeID = ( uint32_t ) m_pDatabase->QueryID( tQBuf );
if( tServerNodeID == 0 ){
tServerNodeID = getServerNode( tServerID );
};
#endif
m_pDatabase->SilentQuery( tQBuf );
sprintf(tQBuf,"UPDATE cameras SET `online`=0 WHERE `site_id`=%d ", SiteID );
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
sprintf(tQBuf,"UPDATE media_streams SET `valid`=0 WHERE `site_id`=%d ", SiteID );
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
sprintf(tQBuf,"UPDATE media_server_streams SET `valid`=0, `online`=0 WHERE `site_id`=%d ", SiteID );
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif
m_pDatabase->SilentQuery( tQBuf );
//cleanResources( tServerNodeID );
setNodeOnline( tServerNodeID );
};
setNodeOnline( *ServNode );
}
};
};
@ -3077,8 +3192,8 @@ uint32_t argusDBC::addLocalMediaSource( uint32_t SiteID, CSTR path, uint32_t wid
memcpy( tM5, tMD5, 33 );
tM5[32]=(char)0;
free( tMD5 );
sprintf( tQBuf, "INSERT INTO media_streams SET `site_id`=%d, `source_id`=0, source_type='A', `valid`=1, `name`='Local Frame Grabber', `token`='%s', `img_width`=%d, `img_height`=%d, `mrl_proto`='v4l2', `mrl_port`='', `picture_proto`='', mrl='%s' ON DUPLICATE KEY UPDATE id=id, `valid`=1, img_width=%d, img_height=%d",
SiteID, tM5, width, height, path, width, height );
sprintf( tQBuf, "INSERT INTO media_streams SET `site_id`=%d, `source_id`=0, source_type='A', `valid`=1, `name`='Local Frame Grabber', `token`='%s', `img_width`=%d, `img_height`=%d, `mrl_proto`='v4l2', `mrl_port`='', `picture_proto`='', mrl='%s' ON DUPLICATE KEY UPDATE id=id, `valid`=1",//, img_width=%d, img_height=%d",
SiteID, tM5, width, height, path );//, width, height );
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif
@ -3821,6 +3936,33 @@ uint32_t argusDBC::addEvent( uint32_t SRC, CSTR UUID, uint32_t tss, uint32_t tsm
return RetVal;
};
bool argusDBC::addDeviceDraw( uint32_t DBID, uint8_t type, uint8_t lrf, void *th_data, uint32_t th_size ){
bool rVal = false;
if( th_data != NULL && th_size ){
if( m_bIsConnected ){
CSTR tPData = m_pDatabase->escapeBinary( (uint8_t *) th_data, th_size );
if ( tPData ) {
CSTR tQBuf = (CSTR)malloc(BUF_4MB);
if( tQBuf ) {
sprintf( tQBuf, "DELETE FROM `lrf_draw` WHERE `node_id`=%d AND `lrf_id`=%d AND `type`=%d", DBID, lrf, type );
LOG( tQBuf );
m_pDatabase->SilentQuery( tQBuf );
sprintf( tQBuf, "INSERT INTO lrf_draw(node_id,ts,lrf_id,type,size,data) VALUES(%d,NOW(),%d,%d,%d,'%s')", DBID, lrf, type, th_size, tPData );
m_pDatabase->SilentQuery( tQBuf );
free( tQBuf );
rVal = true;
} else {
LOG_ERROR("Error Allocating Query Buffer!");
};
free( tPData );
} else {
LOG_ERROR( "Error escaping Pic Data!");
};
};
};
return rVal;
};
bool argusDBC::addVideoEvent( uint32_t evtID, uint32_t videoID ){
if( m_bIsConnected ) {
char tQBuf[MAX_PATH_LEN];
@ -4166,10 +4308,15 @@ bool argusDBC::setLRFAltVerison( uint32_t lrfID, CSTR version ){
};
return false;
};
bool argusDBC::setStreamValid( uint32_t streamID ){
bool argusDBC::setStreamValid( uint32_t streamID, bool status ){
if( m_bIsConnected ) {
char tQBuf[MAX_PATH_LEN];
sprintf( tQBuf, "UPDATE `media_streams` SET `valid`=1 WHERE `id`=%d", streamID );
if ( status ) {
sprintf(tQBuf, "UPDATE `media_streams` SET `valid`=1 WHERE `id`=%d", streamID);
} else {
sprintf(tQBuf, "UPDATE `media_streams` SET `valid`=0 WHERE `id`=%d", streamID);
};
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif
@ -4178,6 +4325,7 @@ bool argusDBC::setStreamValid( uint32_t streamID ){
};
return false;
};
bool argusDBC::updateAFPBox( uint32_t filterID, CSTR Tag, float x, float y, float z ){
if( m_bIsConnected ) {
char tQBuf[MAX_PATH_LEN];

28
lib/rgoose/rgooseDBConnector.h

@ -37,6 +37,8 @@ class argusDBC{
uint32_t addEvent( uint32_t SRC, CSTR UUID, uint32_t tss, uint32_t tsms, uint8_t evt_type, uint8_t k_id=0, uint16_t dig_r=0, float EL=.0f, float AZ=.0f, float RANGE=.0f, float AREA=.0f, float lat=.0f, float lon=.0f, float alt=.0f, uint32_t RefID=0, CSTR RefUUID=NULL );
bool addDeviceDraw( uint32_t DBID, uint8_t type, uint8_t lrf, void *th_data, uint32_t th_size );
bool addLRFDraw( uint32_t DBID, uint32_t SIZE, CSTR ID, uint8_t kID =0, uint8_t type = 0, bool rendered = false );
uint32_t addLRFMask( uint32_t devID, uint8_t lrfID = 0, uint8_t layerID = 0 );
uint32_t addLRFMaskPolygone( uint32_t maskID, uint8_t r, uint8_t g, uint8_t b );
@ -65,23 +67,25 @@ class argusDBC{
bool cleanEvents2PictureBinding( uint32_t PicID );
bool cleanEvents2VideoBinding( uint32_t PicID );
void lazyEventArchiver( uint32_t DalayTime = 10 );
DBC_INT_LIST * listCamMediaStreams( uint32_t CAMID );
DBC_INT_LIST * listStreamCapPictures( uint32_t StreamID, uint32_t cnt );
DBC_INT_LIST * listDetectionProfileIDs( uint32_t nodeID );
DBC_INT_LIST * listDetectionProfiles( uint32_t nodeID );
DBC_INT_LIST * listFilters( uint32_t m_nServerID );
DBC_INT_LIST * listFilters( uint32_t ServerID );
DBC_INT_LIST * listLRFMaskVertexes( uint32_t MaskID );
DBC_INT_LIST * listLRFMaskVertexPoints( uint32_t VertexID );
DBC_INT_LIST * listMediaServerStreams( uint32_t SiteId, uint32_t MediaServerID, uint8_t listingType = LIST_ALL_RECORDS );
DBC_INT_LIST * listMediaStreams( uint32_t SiteId, uint8_t listingType = LIST_ALL_RECORDS );
DBC_INT_LIST * listModules( uint32_t SiteID );
DBC_INT_LIST * listNetworks( uint32_t nif_id );
DBC_INT_LIST * listNewModules( uint32_t SiteID, DBC_INT_LIST * old_ids );
DBC_INT_LIST * listNewNodes( uint32_t SiteID, DBC_INT_LIST * old_ids );
DBC_INT_LIST * listNodes( uint32_t SiteID, bool all = false );
DBC_INT_LIST * listModules( uint32_t ServerID );
DBC_INT_LIST * listNetworks( uint32_t nif_id );
DBC_INT_LIST * listNewModules( uint32_t ServerID, DBC_INT_LIST * old_ids );
DBC_INT_LIST * listNewNodes( uint32_t SiteID, uint32_t ServerID, DBC_INT_LIST * old_ids );
DBC_INT_LIST * listNodes( uint32_t SiteID, uint32_t ServerID, bool all = false );
//DBC_INT_LIST * listSockets( uint32_t NodeID );
DBC_INT_LIST * listResources( uint32_t NodeID = 0 );
DBC_INT_LIST * listResources( uint32_t NodeID = 0 );
simplePolygone * loadLRFMaskVertex( uint32_t vid );
bool getAllCamRecords( uint32_t SiteID, vectorCamRecords &VR );
@ -115,6 +119,9 @@ class argusDBC{
DBC_NODE_DATA * getNodeData( uint32_t ID );
DBC_PUSHED_CMD * getNodePushedCMD( uint32_t NodeID );
DBC_PUSHED_CMD * getActivePushedCMD( uint32_t NodeID );
DBC_PUSHED_CMD * getPushedCMD( uint32_t CmdID );
//uint32_t getNodeSocketID( uint32_t NodeID, uint32_t auxID, uint8_t SocketType, CSTR path );
DBC_RESOURCE_DATA * getResourceData( uint32_t ResourceID );
uint32_t getResourceID( uint32_t NodeID, uint8_t type, uint32_t auxID );
@ -141,8 +148,8 @@ class argusDBC{
void deleteUART( uint32_t UARTID );
void registerServer(uint32_t SiteID, CSTR identity, int PID );
void unregisterServer(uint32_t ServerID, uint32_t NodeID );
void registerServer( uint32_t SiteID, CSTR identity, int PID, uint32_t *ServID, uint32_t *ServNode );
void unregisterServer( uint32_t ServerID, uint32_t NodeID );
bool transferEvtToArchive( uint32_t SECONDS = ONE_DAY_HISTORY );
@ -156,7 +163,7 @@ class argusDBC{
bool setLRFAltSerial( uint32_t lrfID, CSTR Serial );
bool setLRFAltVerison( uint32_t lrfID, CSTR version );
bool setLRFMaskStatus( uint32_t maskID, bool status );
bool setStreamValid( uint32_t streamID );
bool setStreamValid( uint32_t streamID, bool status = true );
//bool syncEventArchive( void ); ALTER TABLE table_name AUTO_INCREMENT = start_value;
bool update3DRuntimeStatus( uint32_t lrfID, ALG_RUN_STATUS *ptr );
bool updateAFPBox( uint32_t filterID, CSTR Tag, float x, float y, float z );
@ -168,6 +175,7 @@ class argusDBC{
bool updateLRFDetectionProfile( uint32_t lrfID, uint8_t profileID, bool master, uint16_t nOrder, uint16_t nOffset, uint16_t nDelta, uint16_t nWidth, uint16_t nFlip, uint16_t nSun, uint8_t bSST, uint32_t GP=0, uint32_t spikes=0 );
bool updateMediaServerStream( uint32_t id, CSTR mrl=NULL, CSTR key = NULL );
bool updateNetworkNode( bool OnlineStatus );
bool updateNodePushedCMD( uint32_t CmdID, uint8_t status );
bool updateResourceAUX( uint32_t ResID, uint32_t AUX );
bool updateServerUtilisation( uint32_t ServerID, uint32_t nCores, float cpu1, float cpu5, float cpu15, float mem, float disk, uint64_t dtsize, uint64_t dcsize, uint64_t mtsize, uint64_t mcsize );
private:

58
lib/rgoose/rgooseHardwareResourceSerialProvider.cpp

@ -21,9 +21,12 @@ argusHardwareResourceSerialProvider::argusHardwareResourceSerialProvider( uint32
m_nInputBufferSize = 0;
m_nOutputBufferSize = 0;
m_iDeviceFD = -1;
m_iMasterFD = -1;
m_iMasterFD = -1;
#ifdef __linux__
m_iInFID = -1;
m_iOutFID = -1;
m_bManualRTS = false;
#endif
};
argusHardwareResourceSerialProvider::~argusHardwareResourceSerialProvider(){
@ -424,10 +427,20 @@ bool argusHardwareResourceSerialProvider::create_HW(){
int result;
/* Open File Descriptor */
//m_iFID = open( DevicePath, O_RDWR| O_NONBLOCK | O_NDELAY );
do{
if( strstr( m_sUartData.path, "USB" ) == NULL ){
m_bManualRTS = true;
wiringPiSetup();
//Set RTS Pin
pinMode( 0, OUTPUT );
} else {
m_bManualRTS = false;
};
do{
m_iInFID = open( m_sUartData.path, O_RDONLY | O_NONBLOCK | O_NDELAY );
} while( m_iInFID == -1 && errno == EINTR );
if( m_iInFID == -1 ){
LOG_ERROR("Can not open Input Stream");
return false;
@ -937,7 +950,7 @@ int argusHardwareResourceSerialProvider::recptBlock( unsigned char *Buffer, int
return -1;
};
}
#ifdef DEBUG
#ifdef DEBUG_EXTRA
else LOG( "Port is not Ready to Receive" )
#endif
;
@ -954,7 +967,7 @@ int argusHardwareResourceSerialProvider::recptBlock( unsigned char *Buffer, int
};
LOG( MsgBuffer );
for (int i = 0; i < RetVal; i++) {
sprintf(MsgBuffer, "0x%02X", Buffer[i]);
sprintf(MsgBuffer, "<0x%02X", Buffer[i]);
LOG(MsgBuffer);
};
#endif
@ -976,6 +989,17 @@ int argusHardwareResourceSerialProvider::recptBlock( unsigned char *Buffer, int
return 0;
};
void argusHardwareResourceSerialProvider::setRTS( uint8_t Val ){
if ( Val ) {
//Use RTS GPIO
digitalWrite( 0, HIGH );
} else {
digitalWrite( 0, LOW );
};
};
#include <sys/ioctl.h>
int argusHardwareResourceSerialProvider::sendBlock(unsigned char* Data, int DataSize) {
#ifdef __linux__
int RetVal = 0;
@ -986,11 +1010,23 @@ int argusHardwareResourceSerialProvider::sendBlock(unsigned char* Data, int Data
if( m_eConnectionStatus== CS_CONNECTED ){
switch( m_sUartData.type ) {
case ARGUS_HARDWARE_UART:{
#ifdef __linux__
#ifdef __linux__
// setRTS( 1 );
do{
RetVal = write( m_iOutFID, Data, DataSize );
if( RetVal == DataSize ) usleep(100);
if( m_bManualRTS ) digitalWrite( 0, HIGH );
RetVal = write( m_iOutFID, Data, DataSize);
if( m_bManualRTS ){
uint8_t lsr;
do {
int r = ioctl( m_iOutFID, TIOCSERGETLSR, &lsr );
} while (!(lsr & TIOCSER_TEMT));
digitalWrite( 0, LOW);
};
if( RetVal == DataSize ){
usleep( 10 );
};
} while (RetVal == -1 && (errno == EINTR || errno == EWOULDBLOCK) && m_bThreadAStatus == TH_WORKING );
//if( m_bManualRTS ) setRTS( 0 );
#else
WriteFile(m_ioFID, Data, DataSize, &RetVal, NULL);
#endif
@ -998,9 +1034,9 @@ int argusHardwareResourceSerialProvider::sendBlock(unsigned char* Data, int Data
char MsgBuffer[CLOG];
sprintf( MsgBuffer, "Sent %d byte(s) of %d", RetVal, DataSize );
LOG( MsgBuffer );
#ifdef DEBUG_COMMUNICATION
#ifdef DEBUG_SERIAL_COMMUNICATION
for( int i = 0; i < DataSize; i++ ){
sprintf( MsgBuffer, "0x%02X", Data[i] );
sprintf( MsgBuffer, ">0x%02X", Data[i] );
LOG( MsgBuffer );
};
#endif
@ -1060,7 +1096,7 @@ int argusHardwareResourceSerialProvider::sendBlock(unsigned char* Data, int Data
};
};
} else {
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG( "Port is not Ready to Send" );
#endif
return -1;

6
lib/rgoose/rgooseHardwareResourceSerialProvider.h

@ -13,6 +13,10 @@
#ifdef __linux__
#include <unistd.h> // UNIX standard function definitions
#include <termios.h> // POSIX terminal control definitions
#ifdef RASPI_HARDWARE
#include <wiringPi.h>
#endif
#endif
@ -39,6 +43,8 @@ class argusHardwareResourceSerialProvider: public argusHardwareResource, public
struct termios m_sTTY;
int m_iInFID;
int m_iOutFID;
bool m_bManualRTS;
void setRTS( uint8_t Val );
#else
DCB PortDCB;
HANDLE m_ioFID;

27
lib/rgoose/rgooseKernel.cpp

@ -100,7 +100,9 @@ argusKernel::~argusKernel(){
#ifdef DEBUG
LOG("HW PNP Detection Requested...");
#endif
//m_pDBC->updateNodePushedCMD( tCMD->id, 30 );
m_pHardwareManager->enumerateHardware();
//m_pDBC->updateNodePushedCMD( tCMD->id, 60 );
};
#ifdef DEBUG
LOG("Close DataBase Connection...");
@ -168,9 +170,9 @@ bool argusKernel::create( void ){
#ifdef DEBUG
LOG( "Settings Read Done" );
#endif
m_pDBC->registerServer( m_nSiteID, m_sIdentity, getpid() );
m_nServerID = m_pDBC->getServerID( m_sIdentity );
m_nServerNodeID = m_pDBC->getServerNode( m_nServerID );
m_pDBC->registerServer( m_nSiteID, m_sIdentity, getpid(), &m_nServerID, &m_nServerNodeID );
//m_nServerID = m_pDBC->getServerID( m_sIdentity );
//m_nServerNodeID = m_pDBC->getServerNode( m_nServerID );
DBC_SITE_DATA *tSiteData = m_pDBC->getSiteData( m_nSiteID );
if( tSiteData ) {
@ -183,6 +185,13 @@ bool argusKernel::create( void ){
} else {
LOG_ERROR("Error Loading Site DATA!");
};
//Check To Finish Reset
DBC_PUSHED_CMD *tCMD = m_pDBC->getActivePushedCMD( m_nServerNodeID );
if( tCMD ) {
m_pDBC->updateNodePushedCMD( tCMD->id, 100 );
free( tCMD );
};
//Init Subcomponents
m_pHardwareManager = argusHardwareManager::getInstance( m_bSkipResignComponents );
if( m_pHardwareManager!= NULL ) {
@ -223,7 +232,7 @@ bool argusKernel::create( void ){
#endif
m_pNodeFactory = argusNodeFactory::getInstance( m_nSiteID );
m_pNodeFactory = argusNodeFactory::getInstance( m_nSiteID, m_nServerID );
if( !m_pNodeFactory ) {
LOG_ERROR("Failure to get Node Factory Instance!");
@ -407,11 +416,12 @@ void argusKernel::m_fThreadProc( void ){
} else {
LOG_ERROR("Error while getting System Info!");
};
const uint32_t MB = 1 << 10;//(1024 * 1024);// * 1024;
//const uint32_t MB = 1 << 10;//(1024 * 1024);// * 1024;
if( statvfs("/", &DI) == 0 ){
tDISK = ( DI.f_blocks * DI.f_frsize ) / MB;
cDISK = ( DI.f_bavail * DI.f_frsize ) / MB;
tDISK = ( DI.f_blocks * (unsigned long long) DI.f_frsize ) >> 10;// / MB;
//cDISK = ( DI.f_bavail * (unsigned long long) DI.f_bsize ) >> 10;// / MB;
cDISK = tDISK - ( ( DI.f_bfree * (unsigned long long) DI.f_bsize ) >> 10 );
disk = (float)cDISK / (float)tDISK;
} else {
LOG_ERROR("Error while getting Disk Info!");
@ -421,6 +431,8 @@ void argusKernel::m_fThreadProc( void ){
DBC_PUSHED_CMD *tCMD = m_pDBC->getNodePushedCMD( m_nServerNodeID );
//tCMD = m_pDBC->getActiveSiteCommand( m_nSiteID );
if( tCMD != NULL ){
// Mask as Started!
m_pDBC->updateNodePushedCMD( tCMD->id, 1 );
switch( tCMD->CMD ) {
case ARGUS_CMD_KRNL_RELOAD:{
LOG("Reload ARGUS SERVER!");
@ -539,6 +551,7 @@ void argusKernel::m_fThreadProc( void ){
};
};
} catch (exception e) {
m_pDBC->updateNodePushedCMD( tCMD->id, 226 );
LOG_ERROR("EXCEPTION");
};
break;

106
lib/rgoose/rgooseModuleEmbedVideo.cpp

@ -106,8 +106,24 @@ argusModuleEmbedVideo::argusModuleEmbedVideo( uint32_t moduleID ): argusKernelMo
};
argusModuleEmbedVideo::~argusModuleEmbedVideo(){
if( !m_bDetached ) stopService( true );
if( n_pNoSignalData ) free( n_pNoSignalData );
m_bEnabled = false;
waitThreadEnd( true );
if( m_vHandlersPool.size() ) { // Kill-Wait Started Probes
#ifdef DEBUG
char tB[200];
sprintf(tB, "Have to Wait Client Handlers[%d]!", m_vHandlersPool.size() );
LOG( tB );
#endif
for( vectorHANDLERS::iterator index = m_vHandlersPool.begin(); index < m_vHandlersPool.end(); index++ ) pthread_cancel( (*index)->m_hThreadHandle );
m_vHandlersPool.clear();
};
#ifdef DEBUG
LOG("No More Client Handlers!");
#endif
if( m_mapCAPTURES.size() ) m_mapCAPTURES.clear();
if( m_mapMATS.size() ) m_mapMATS.clear();
if(n_pNoSignalData) free(n_pNoSignalData);
};
static const char * ht_head = "HTTP/1.1 200 OK\r\n"
@ -598,7 +614,7 @@ bool argusModuleEmbedVideo::startService(){
bool argusModuleEmbedVideo::stopService( bool force ){
m_bEnabled = false;
waitThreadEnd( true );
m_bDetached = uninit();
#ifdef DEBUG
LOG("Service Thread ended!");
#endif
@ -627,27 +643,71 @@ bool argusModuleEmbedVideo::stopService( bool force ){
#ifdef DEBUG
LOG("No More Client Handlers!");
#endif
m_bDetached = true;
if( m_mapCAPTURES.size() ){
m_mapCAPTURES.clear();
//for( mapSTREAMCAPS::iterator idx = m_mapCAPTURES.begin(); idx < m_mapCAPTURES.end(); idx++ ) {
//};
};
if( m_mapMATS.size() ){
m_mapMATS.clear();
//for( mapSTREAMMAPS::iterator idx = m_mapMATS.begin(); idx < m_mapMATS.end(); idx++ ) {
//};
};
if ( n_pNoSignalData ) {
free( n_pNoSignalData );
n_pNoSignalData = NULL;
m_nNoSignalSize = 0;
};
return m_bDetached;
};
bool argusModuleEmbedVideo::reloadSettings(){
return true;
LOG("Reload Service");
if( m_pDBC ){
DBC_MODULE_EMBED_VIDEO_DATA *tDATA = m_pDBC->getEmbedVideoData( m_nDBAUXID );
if( tDATA ) {
if( stopService() ){
LOG("Stoped!");
memcpy( &m_sEmbedVideoData, tDATA, sizeof(DBC_MODULE_EMBED_VIDEO_DATA));
free( tDATA );
LOG("Starting...");
return startService();
} else {
free( tDATA );
};
};
};
return false;
};
bool argusModuleEmbedVideo::validate(){
return true;
if( m_pDBC ){
DBC_MODULE_EMBED_VIDEO_DATA *tDATA = m_pDBC->getEmbedVideoData( m_nDBAUXID );
if( tDATA ) {
if( memcmp( &m_sEmbedVideoData, tDATA, sizeof(DBC_MODULE_EMBED_VIDEO_DATA)) != 0 ){
free( tDATA );
LOG("Module Settings Changed!");
return reloadSettings();
};
free( tDATA );
return true;
};
} else {
LOG_ERROR( "DB Error!" );
};
return false;
};
void argusModuleEmbedVideo::pushFrame( AVFrame *Frame, void* src){
MEDIA_SOURCE_DESC * tMD = (MEDIA_SOURCE_DESC *) src;
bool argusModuleEmbedVideo::pushFrame( AVFrame *Frame, void* src){
if( !m_bEnabled ) return false;
MEDIA_SOURCE_DESC *tMD = (MEDIA_SOURCE_DESC *)src;
if( tMD ) {
};
return true;
};
void argusModuleEmbedVideo::pushFrame( cv::Mat &Frame, void* src ){
bool argusModuleEmbedVideo::pushFrame( cv::Mat &Frame, void* src ){
if( !m_bEnabled ) return false;
MEDIA_SOURCE_DESC * tMD = (MEDIA_SOURCE_DESC *) src;
char tBuffer[128];
if( tMD ) {
@ -691,20 +751,23 @@ void argusModuleEmbedVideo::pushFrame( cv::Mat &Frame, void* src ){
if(( m_sEmbedVideoData.height==Frame.rows )&&( m_sEmbedVideoData.width==Frame.cols )){
Frame.copyTo( m_mapMATS[tMD->mediaStreamId] );
} else {
if( m_sEmbedVideoData.height < Frame.rows ) {
ROI.x = 0;
ROI.width = m_sEmbedVideoData.width;
ROI.y = ( Frame.rows - m_sEmbedVideoData.height ) >> 1;
ROI.height = m_sEmbedVideoData.height;
cv::Mat mROI = Frame( ROI );
mROI.copyTo(m_mapMATS[tMD->mediaStreamId]);
} else {
//Mat dst_roi = dst(Rect(left, top, src.cols, src.rows));
//src.copyTo(dst_roi);
if (m_sEmbedVideoData.width == Frame.cols ) {
ROI.width = Frame.cols;
ROI.height = Frame.rows;
ROI.x = 0;
ROI.width = m_sEmbedVideoData.width;
ROI.y = ( m_sEmbedVideoData.height - Frame.rows ) >> 1;
cv::Mat mROI = m_mapMATS[tMD->mediaStreamId]( ROI );
Frame.copyTo(mROI);
} else {
ROI.width = Frame.cols;
ROI.height = Frame.rows;
ROI.x = ( m_sEmbedVideoData.width - Frame.cols ) >> 1;
ROI.y = 0;
cv::Mat mROI = m_mapMATS[tMD->mediaStreamId]( ROI );
Frame.copyTo( mROI );
Frame.copyTo(mROI);
};
};
#endif
@ -837,6 +900,7 @@ void argusModuleEmbedVideo::pushFrame( cv::Mat &Frame, void* src ){
*/
m_mPictureProtector.unlock();
};
return true;
};
bool argusModuleEmbedVideo::registerForMediaStream( uint32_t id, WEB_CLIENT_CTX *&CTX ){

6
lib/rgoose/rgooseModuleEmbedVideo.h

@ -167,9 +167,9 @@ class argusModuleEmbedVideo: public argusKernelModule, public basicMediaDestinat
virtual void dispatchEvent(EVENT_CONTAINER *Evt);
virtual bool validate();
/* from Media Destination */
virtual void pushFrame(AVFrame *Frame, void* src = NULL);
//virtual void pushFrame(cv::Mat* Frame, void* src = NULL);
virtual void pushFrame( cv::Mat &Frame, void* src = NULL);
virtual bool pushFrame( AVFrame *Frame, void* src = NULL);
//virtual void pushFrame( cv::Mat* Frame, void* src = NULL);
virtual bool pushFrame( cv::Mat &Frame, void* src = NULL);
/* Module Specific Functionality */
int getWidh( void );
int getHeight( void );

8
lib/rgoose/rgooseModuleFactory.cpp

@ -357,11 +357,13 @@ void argusModuleFactory::m_fThreadProc( void ){
#endif
while( m_vKernelModules.size() ) deleteModule( 0 );
};
} else {
#ifdef DEBUG
}
#ifdef DEBUG_EXTRA
else {
LOG("No Modules to Validate!");
}
#endif
};
;
m_mModulesProtector.unlock();
#ifdef MEM_DEBUG
memEnd = getCurrentRSS();

1
lib/rgoose/rgooseNode.h

@ -9,6 +9,7 @@
typedef struct S_NODE_COMMAND{
uint8_t cmd;
uint32_t db_cmd;
void * parameter;
}NODE_COMMAND;

280
lib/rgoose/rgooseNode2D.cpp

@ -106,31 +106,23 @@ LPCTSTR m_pSetting[] =
*/
ARGUS_2DSensor::ARGUS_2DSensor( uint32_t id ):argusNodeSensor( id ), basicThread(), protocolLGS_2D(){
m_bWM = ANODE_WM_2D_BEFORE_START;
m_eSensorClass = EVT_CLASS_SENSOR_LFS;
m_pLog = basicLogCollection::getInstance();
//m_pPosition = new basicPosition();
m_pEventHeap = basicEventHeap::getInstance();
DBC_LRF_DATA *tDATA = m_pDBC->getLRFData( m_sNodeData.aux_id );
cleanupDeviceStructures();
m_bPortType = 0;
m_pPort = NULL;
m_bPortType = 0;
m_bOpRetryCnt = 3;
m_nProcessingCmdId = 0;
cleanupDeviceStructures();
memset( m_vDrawRanges, 0, sizeof( m_vDrawRanges ));
if( tDATA != NULL ) {
memcpy( &m_sLRF_DATA, tDATA, sizeof(DBC_LRF_DATA));
if( m_sLRF_DATA.uart_id ) {
DBC_UART_DATA *tUART = NULL;
tUART = m_pDBC->getUartData( m_sLRF_DATA.uart_id );
if( tUART!= NULL ) {
m_bPortType = tUART->type;
// in start service setDeviceID( m_sLRF_DATA.device_id );
free( tUART );
};
free( tDATA );
} else {
memset( &m_sLRF_DATA, 0, sizeof(DBC_LRF_DATA));
};
m_eSensorClass = EVT_CLASS_SENSOR_LFS;
};
void ARGUS_2DSensor::cleanupDeviceStructures( void ){
@ -140,6 +132,7 @@ void ARGUS_2DSensor::cleanupDeviceStructures( void ){
m_bInitialFlips = LGS_INITIAL_FLIPS;
m_nCurrentAngle = 0;
m_bDrawType = 0;
m_bOpRetryCnt = 3;
memset( m_tSN, 0, 33 );
memset( m_tSV, 0, 65 );
m_bSerialStringValid = false;
@ -227,6 +220,7 @@ bool ARGUS_2DSensor::validate(){
if( m_pDBC == NULL ) return false;
DBC_PUSHED_CMD *tCMD = m_pDBC->getNodePushedCMD(m_sNodeData.node_id);
if ( tCMD!= NULL ) {
m_pDBC->updateNodePushedCMD( tCMD->id, DBC_CMD_STARTED );
switch( tCMD->CMD ){
case ARGUS_LRF_PCMD_FULL_RESET:{
#ifdef DEBUG
@ -235,6 +229,7 @@ bool ARGUS_2DSensor::validate(){
NODE_COMMAND *tNCMD = (NODE_COMMAND *) malloc( sizeof(NODE_COMMAND));
if (tNCMD) {
tNCMD->cmd = NODE_CMD_FULL_RESET;
tNCMD->db_cmd = tCMD->id;
tNCMD->parameter = NULL;
enqueueCommand( tNCMD );
};
@ -247,6 +242,7 @@ bool ARGUS_2DSensor::validate(){
NODE_COMMAND *tNCMD = (NODE_COMMAND *) malloc( sizeof(NODE_COMMAND));
if (tNCMD) {
tNCMD->cmd = NODE_CMD_RESET_STUDY;
tNCMD->db_cmd = tCMD->id;
tNCMD->parameter = NULL;
enqueueCommand( tNCMD );
};
@ -259,6 +255,7 @@ bool ARGUS_2DSensor::validate(){
NODE_COMMAND *tNCMD = (NODE_COMMAND *) malloc( sizeof(NODE_COMMAND));
if (tNCMD) {
tNCMD->cmd = NODE_CMD_GET_DEVICE_DRAW;
tNCMD->db_cmd = tCMD->id;
tNCMD->parameter = NULL;
enqueueCommand( tNCMD );
}
@ -273,6 +270,7 @@ bool ARGUS_2DSensor::validate(){
NODE_COMMAND *tNCMD = (NODE_COMMAND *)malloc(sizeof(NODE_COMMAND));
if( tNCMD ){
tNCMD->cmd = NODE_CMD_UPLOAD_FILE;
tNCMD->db_cmd = tCMD->id;
tNCMD->parameter = malloc( sz+1 );
if ( tNCMD->parameter != NULL ) {
memcpy(tNCMD->parameter, tCMD->PARAM, sz);
@ -285,6 +283,59 @@ bool ARGUS_2DSensor::validate(){
};
break;
};
case ARGUS_LRF_ROI_ACTIVATION:{
#ifdef DEBUG
LOG("ROI Cam Move!");
#endif
uint16_t sz = strlen(tCMD->PARAM);
if( sz ){
//NODE_COMMAND *tNCMD = (NODE_COMMAND *)malloc(sizeof(NODE_COMMAND));
//if( tNCMD ){
// tNCMD->cmd = NODE_CMD_ROI_ACTIVE;
// tNCMD->db_cmd = tCMD->id;
// tNCMD->parameter = malloc( sizeof( ROI_CMD_DATA ) );
// if ( tNCMD->parameter != NULL ) {
// memset( tNCMD->parameter, 0, sizeof( ROI_CMD_DATA ) );
// ((ROI_CMD_DATA *)tNCMD->parameter)->az_d = atoi( tCMD->PARAM );
// ((ROI_CMD_DATA *)tNCMD->parameter)->az_d = atoi( strstr(tCMD->PARAM,":") + 1 );
// //((ROI_CMD_DATA *)tNCMD->parameter)->el_d
// enqueueCommand( tNCMD );
// } else {
// free( tNCMD );
// };
//};
uint16_t AZ, RANGE, WIDTH;
uint8_t LRFID = 0;
AZ = atoi(strstr(tCMD->PARAM, ":") + 1) - m_sLRF_DATA.base_shift;
RANGE = atoi( tCMD->PARAM );
WIDTH = 8888;
#ifdef DEBUG
char tBuff[128];
sprintf( tBuff, "ROI AZ: %d RANGE: %d WIDTH: %d", AZ, RANGE, WIDTH );
LOG( tBuff );
#endif
EVENT_CONTAINER * bEVT = NULL;
TARGET_DATA * tData = prepareTargetData( AZ, RANGE, WIDTH, LRFID );
bEVT = createBasicEvent( m_sNodeData.node_id, m_eSensorClass, EVT_ROI_ACTIVE, NULL, NULL, tData );
if( bEVT != NULL ) {
m_pEventHeap->broadcast(bEVT);
} else {
free( tData );
};
};
break;
};
case ARGUS_LRF_PUSH_FALSE_TARGET:{
#ifdef DEBUG
LOG("Simulate Target by Command!");
#endif
break;
};
default:
m_pDBC->updateNodePushedCMD( tCMD->id, DBC_CMD_FINISHED );
};
free(tCMD);
};
@ -309,15 +360,18 @@ void ARGUS_2DSensor::m_fThreadProc( void ){
if( tRES != NULL ) {
if( tRES->isValid()) {
m_pPort = static_cast<basicTransport *>(static_cast<argusHardwareResourceSerialProvider *>(tRES));
//m_pPort = (basicTransport *)((argusHardwareResourceIpUART *) tRES );
#ifdef DEBUG_EXTRA
//Bind To Proto
char tB[64];
sprintf( tB, "PortOBJ: %p", m_pPort );
LOG( tB );
#endif
if( !setTransport( m_pPort, false )){
LOG_ERROR("Binding Port Failure!");
} else {
#ifdef DEBUG_EXTRA
LOG("Port Bind Sucessfully Done");
#endif
m_bDeviceWM = 0x00;
setWM( ANODE_WM_2D_CONNECT );
break;
@ -370,11 +424,9 @@ void ARGUS_2DSensor::m_fThreadProc( void ){
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
if( !setMode(MODE_DETECTOR) ) {
m_pDBC->setNodeOffline( m_sNodeData.node_id );
setWM( ANODE_WM_2D_CREATE_PORT );
LOG_ERROR("Fall Back to Disconnected!");
} else {
setWM( ANODE_WM_2D_WAIT_INIT_MODE );
};
setWM( ANODE_WM_2D_CREATE_PORT );
} else setWM( ANODE_WM_2D_WAIT_INIT_MODE );
break;
};
case ANODE_WM_2D_WAIT_INIT_MODE:{
@ -387,10 +439,9 @@ void ARGUS_2DSensor::m_fThreadProc( void ){
case ANODE_WM_2D_GET_SERIAL_NUM:{
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
if( !getSerialNumber() ) {
setWM( ANODE_WM_2D_SET_INIT_MODE );
} else {
setWM( ANODE_WM_2D_WAIT_SERIAL_NUM );
};
LOG_ERROR("Fall Back to Disconnected!");
setWM( ANODE_WM_2D_CREATE_PORT );
} else setWM( ANODE_WM_2D_WAIT_SERIAL_NUM );
break;
};
case ANODE_WM_2D_WAIT_SERIAL_NUM:{
@ -403,10 +454,9 @@ void ARGUS_2DSensor::m_fThreadProc( void ){
case ANODE_WM_2D_GET_VERSION:{
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
if( !getVersionString() ) {
setWM( ANODE_WM_2D_GET_SERIAL_NUM );
} else {
setWM( ANODE_WM_2D_WAIT_VERSION );
};
LOG_ERROR("Fall Back to Disconnected!");
setWM( ANODE_WM_2D_CREATE_PORT );
} else setWM( ANODE_WM_2D_WAIT_VERSION );
break;
};
case ANODE_WM_2D_WAIT_VERSION:{
@ -419,10 +469,9 @@ void ARGUS_2DSensor::m_fThreadProc( void ){
case ANODE_WM_2D_GET_DETECTION_PROFILE:{
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
if( !getDetectionProfile() ) {
setWM( ANODE_WM_2D_GET_VERSION );
} else {
setWM( ANODE_WM_2D_WAIT_DETECTION_PROFILE );
};
LOG_ERROR("Fall Back to Disconnected!");
setWM( ANODE_WM_2D_CREATE_PORT );
} else setWM( ANODE_WM_2D_WAIT_DETECTION_PROFILE );
break;
};
case ANODE_WM_2D_WAIT_DETECTION_PROFILE:{
@ -467,20 +516,22 @@ void ARGUS_2DSensor::m_fThreadProc( void ){
break;
};
case ANODE_WM_2D_SET_BORDER_MODE:{
m_nSleepTime = LGS_DEFAULT_SLEEP_TIME;
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
if( !setMode( MODE_BORDER )){
LOG_ERROR("Fall Back to Disconnected!");
setWM( ANODE_WM_2D_CREATE_PORT );
} else {
LOG("Set DWM as Border!");
setWM( ANODE_WM_2D_WAIT_BORDER_MODE );
};
} else setWM( ANODE_WM_2D_WAIT_BORDER_MODE );
break;
};
case ANODE_WM_2D_WAIT_BORDER_MODE:{
if((m_bTimeOutCounter--)==0){
LOG_ERROR("Communication TO!");
setWM( ANODE_WM_2D_SET_BORDER_MODE );
if( m_bOpRetryCnt-- ){
setWM( ANODE_WM_2D_SET_BORDER_MODE );
} else {
LOG_ERROR("Communication TO!");
setWM( ANODE_WM_2D_SET_BORDER_MODE );
};
};
break;
};
@ -488,12 +539,13 @@ void ARGUS_2DSensor::m_fThreadProc( void ){
if( m_bDeviceWM != MODE_BORDER ) {
setWM( ANODE_WM_2D_SET_BORDER_MODE );
} else {
m_nSleepTime = LGS_DEFAULT_SLEEP_TIME;
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
if( !getFastDraw( m_nCurrentAngle ) ) {
LOG_ERROR("Fall Back to Disconnected!");
setWM( ANODE_WM_2D_CREATE_PORT );
} else {
m_nSleepTime = LGS_DEFAULT_TO_COUNTER;//LGS_ALERT_SLEEP_TIME;
m_nSleepTime = LGS_ALERT_SLEEP_TIME;
setWM( ANODE_WM_2D_WAIT_FAST_DRAW );
};
}
@ -501,9 +553,13 @@ void ARGUS_2DSensor::m_fThreadProc( void ){
};
case ANODE_WM_2D_WAIT_FAST_DRAW:{
if((m_bTimeOutCounter--)==0){
LOG_ERROR("Waited Angle Draw Communication TO!");
m_nCurrentAngle = 0;
setWM( ANODE_WM_2D_SET_DETECTION_MODE );
if( m_bOpRetryCnt-- ){
setWM( ANODE_WM_2D_GET_FAST_DRAW );
} else {
LOG_ERROR("Waited Angle Draw Communication TO!");
m_nCurrentAngle = 0;
setWM( ANODE_WM_2D_SET_DETECTION_MODE );
};
};
break;
};
@ -583,40 +639,70 @@ void ARGUS_2DSensor::m_fThreadProc( void ){
if( NODE_COMMAND * tCMD = fetchCommand() ) {
switch( tCMD->cmd ) {
case NODE_CMD_FULL_RESET:{
setWM( ANODE_WM_2D_ISSUE_FULL_RESET );
if( tCMD->db_cmd ) m_nProcessingCmdId = tCMD->db_cmd; else m_nProcessingCmdId = 0;
setWM(ANODE_WM_2D_ISSUE_FULL_RESET);
break;
};
case NODE_CMD_RESET_STUDY:{
if( tCMD->db_cmd ) m_nProcessingCmdId = tCMD->db_cmd; else m_nProcessingCmdId = 0;
setWM( ANODE_WM_2D_ISSUE_RESET );
break;
};
case NODE_CMD_UPLOAD_FILE:{
if( tCMD->db_cmd ) m_nProcessingCmdId = tCMD->db_cmd; else m_nProcessingCmdId = 0;
m_nUploadID = atoi( (CSTR) tCMD->parameter );
//m_sCurrentFile, m_pDBC->get
break;
};
case NODE_CMD_GET_DEVICE_DRAW:{
if( tCMD->db_cmd ) m_nProcessingCmdId = tCMD->db_cmd; else m_nProcessingCmdId = 0;
setWM( ANODE_WM_2D_SET_BORDER_MODE );
break;
};
case NODE_CMD_ROI_ACTIVE:{
uint16_t AZ, RANGE, WIDTH;
uint8_t LRFID = 0;
AZ = ((ROI_CMD_DATA *)tCMD->parameter)->az_d;
RANGE = ((ROI_CMD_DATA *)tCMD->parameter)->r_d;
WIDTH = 8888;
#ifdef DEBUG
char tBuff[128];
sprintf( tBuff, "ROI AZ: %d RANGE: %d WIDTH: %d", AZ, RANGE, WIDTH );
LOG( tBuff );
#endif
EVENT_CONTAINER * bEVT = NULL;
TARGET_DATA * tData = prepareTargetData( AZ, RANGE, WIDTH, LRFID );
bEVT = createBasicEvent( m_sNodeData.node_id, m_eSensorClass, EVT_ROI_ACTIVE, NULL, NULL, tData );
if( bEVT != NULL ) {
m_pEventHeap->broadcast(bEVT);
} else {
free( tData );
};
break;
};
};
if( tCMD->parameter ) free( tCMD->parameter );
free( tCMD );
} else {
if( !getState2() ) {
LOG_ERROR("Fall Back to Disconnected!");
setWM( ANODE_WM_2D_CREATE_PORT );
LOG_ERROR("Fall Back to getState1!");
setWM( ANODE_WM_2D_CONNECT );
} else {
setWM( ANODE_WM_2D_PONG );
};
}
};
break;
};
case ANODE_WM_2D_PONG:{
//Wait ACK
if((m_bTimeOutCounter--)==0){
LOG_ERROR("Communication TO!");
setWM( ANODE_WM_2D_CREATE_PORT );
if( m_bOpRetryCnt-- ){
setWM( ANODE_WM_2D_PING );
} else {
LOG_ERROR("Communication TO!");
setWM( ANODE_WM_2D_PING );
};
};
break;
};
@ -628,6 +714,7 @@ void ARGUS_2DSensor::m_fThreadProc( void ){
};
};
SLEEP( m_nSleepTime );
validate();
};
};
@ -649,6 +736,7 @@ uint8_t ARGUS_2DSensor::getWM( void ){
m_mWMProtector.unlock();
return RetVal;
};
void ARGUS_2DSensor::setWM( uint8_t MD ){
m_mWMProtector.lock();
m_bWM = MD;
@ -689,8 +777,8 @@ bool ARGUS_2DSensor::packetHandler( protocolPackage *Package ){
break;
};
case CMD_BORDER:{
//LOG("Angle Draw!");
if ( m_bWM == ANODE_WM_2D_WAIT_FAST_DRAW ) {
if ( getWM() == ANODE_WM_2D_WAIT_FAST_DRAW ) {
m_bOpRetryCnt = 3;
if ((Package->m_pData[SUB_CMD_IDX] & 0xC0) == 0x00) {
uint16_t AZ;
uint16_t RANGE_A;
@ -698,44 +786,54 @@ bool ARGUS_2DSensor::packetHandler( protocolPackage *Package ){
AZ = ( ( ( Package->m_pData[SUB_CMD_IDX] & 0x10 ) >> 4 ) << 8 ) | Package->m_pData[5];
RANGE_A = ( ( ( Package->m_pData[SUB_CMD_IDX] & 0x0C ) >> 2 ) << 8 ) | Package->m_pData[6];
RANGE_B = ( ( Package->m_pData[SUB_CMD_IDX] & 0x03 ) << 8 ) | Package->m_pData[7];
//sprintf( tBuff, "B[%d]>", AZ );
//LOG( tBuff );
if( AZ < 359 ) {
m_vDrawRanges[m_nCurrentAngle]=( RANGE_A << 16 ) | RANGE_B;
m_nCurrentAngle = AZ+1;
setWM( ANODE_WM_2D_GET_FAST_DRAW );
if( m_nProcessingCmdId ){
m_pDBC->updateNodePushedCMD( m_nProcessingCmdId, (( ( 100 * AZ ) / 360 ) - 1 ) | 1 );
m_nProcessingCmdId = 0;
};
} else {
// Store Draw
saveRawDrawData( 360 );
LOG("Draw Complete!");
m_nCurrentAngle = 0;
setWM( ANODE_WM_2D_SET_DETECTION_MODE );
handleDeviceDraw( 0, (void *)m_vDrawRanges, 360 * sizeof(uint32_t) );
if( m_nProcessingCmdId ){
m_pDBC->updateNodePushedCMD(m_nProcessingCmdId, 100 );
m_nProcessingCmdId = 0;
};
};
} else {
if( Package->m_pData[SUB_CMD_IDX] == 0x80 ) {
LOG("ERR Data Not Ready");
// Data Not Ready
m_nCurrentAngle = 0;
//check WM
setWM( ANODE_WM_2D_GET_FAST_DRAW );
} else {
LOG("ERR REQ AZ");
// Error Requested Angle
setWM( ANODE_WM_2D_PING );
};
};
} else {
LOG("ERR Wrong Mode!");
setWM( ANODE_WM_2D_SET_DETECTION_MODE );
m_nCurrentAngle = 0;
};
break;
};
case CMD_MODE:{
#ifdef DEBUG
LOG("CMD MODE");
#endif
m_bDeviceWM = Package->m_pData[SUB_CMD_IDX];
uint8_t tCWD = getWM();
#ifdef DEBUG
sprintf( tBuff, " RM:[0x%02X] Current Device Mode: 0x%02X", m_bWM, m_bDeviceWM );
sprintf( tBuff, "CWD:%d Remote Mode:[0x%02X] Current Device Mode: 0x%02X", tCWD, m_bWM, m_bDeviceWM );
LOG( tBuff );
#endif
switch( getWM() ) {
switch( tCWD ) {
case ANODE_WM_2D_WAIT_CONNECT:{
// Initial Connection
m_pDBC->setNodeOnline( m_sNodeData.node_id, ARGUS_NODE_STATUS_INIT );
@ -760,7 +858,7 @@ bool ARGUS_2DSensor::packetHandler( protocolPackage *Package ){
//m_nSleepTime = LGS_ALERT_SLEEP_TIME;
m_nCurrentAngle = 0;
} else {
m_bWM = ANODE_WM_2D_SET_BORDER_MODE;
setWM( ANODE_WM_2D_SET_BORDER_MODE );
};
break;
};
@ -985,6 +1083,7 @@ bool ARGUS_2DSensor::packetHandler( protocolPackage *Package ){
// PRINTOUT;
//};
#endif
m_bOpRetryCnt = 3;
setWM( ANODE_WM_2D_PING );
m_nSleepTime = LGS_DEFAULT_SLEEP_TIME;
while( Package->m_nSize > ( cIDX + 2 ) ) {
@ -996,15 +1095,42 @@ bool ARGUS_2DSensor::packetHandler( protocolPackage *Package ){
sprintf( tBuff, "Sub Size: %d", Package->m_pData[cIDX] );
LOG( tBuff );
#endif
uint16_t AZ, RANGE;
uint32_t WIDTH;
uint8_t LRFID = 0;
AZ = (( Package->m_pData[cIDX + 3] >> 3 ) << 8 ) | Package->m_pData[cIDX + 4];
RANGE = (( Package->m_pData[cIDX + 3] & 0x07 ) << 8 ) | Package->m_pData[cIDX + 5];
WIDTH = 8888;
#ifdef DEBUG_EXTRA
sprintf( tBuff, "AZ: %d RANGE: %d WIDTH: %d", AZ, RANGE, WIDTH );
LOG( tBuff );
#endif
EVENT_CONTAINER * bEVT = NULL;
TARGET_DATA * tData = prepareTargetData( AZ, RANGE, WIDTH, LRFID );
if( m_pTargetFilter != NULL ) {
if( !m_pTargetFilter->validateTarget( m_sNodeData.node_id, tData ) ){
free( tData );
break;
};
};
bEVT = createBasicEvent( m_sNodeData.node_id, m_eSensorClass, EVT_TARGET_2D_WHITE, NULL, NULL, tData );
if( bEVT != NULL ) {
m_pEventHeap->broadcast(bEVT);
} else {
free( tData );
};
m_nSleepTime = LGS_ALERT_SLEEP_TIME;
cIDX += 6;
break;
};
case 0x02:{
#ifdef DEBUG
//LOG("SUB PACKAGE - Maintenance notification");
//sprintf( tBuff, "Sub Size: %d", Package->m_pData[cIDX] );
//LOG( tBuff );
#ifdef DEBUG_EXTRA
LOG("SUB PACKAGE - Maintenance notification");
sprintf( tBuff, "Sub Size: %d", Package->m_pData[cIDX] );
LOG( tBuff );
#endif
cIDX += 3;
break;
@ -1036,15 +1162,21 @@ bool ARGUS_2DSensor::packetHandler( protocolPackage *Package ){
if( m_bInitialFlips ){
m_bInitialFlips--;
} else {
//LOG("INITIAL FLIPS ARE DONE!");
#ifdef DEBUG_EXTRA
LOG("INITIAL FLIPS ARE DONE!");
#endif
if ( m_bWM == ANODE_WM_2D_PING ) {
if (m_sLRF_DATA.auto_draw > 0) {
//LOG("Start AutoDraw!");
#ifdef DEBUG_EXTRA
LOG("Start AutoDraw!");
#endif
m_bInitialFlips = m_sLRF_DATA.auto_draw;
setWM( ANODE_WM_2D_SET_BORDER_MODE );
m_nCurrentAngle = 0;
} else {
//LOG("No AutoDraw Defined!");
#ifdef DEBUG_EXTRA
LOG("No AutoDraw Defined!");
#endif
};
} else {
LOG_ERROR("Wrong WM Mode! (possible error in init process)");
@ -1063,19 +1195,19 @@ bool ARGUS_2DSensor::packetHandler( protocolPackage *Package ){
break;
};
case 0x07:{
#ifdef DEBUG
//LOG("SUB PACKAGE - Intruder with Width detected");
//sprintf( tBuff, "Sub Size: %d", Package->m_pData[cIDX] );
//LOG( tBuff );
#ifdef DEBUG_EXTRA
LOG("SUB PACKAGE - Intruder with Width detected");
sprintf( tBuff, "Sub Size: %d", Package->m_pData[cIDX] );
LOG( tBuff );
#endif
uint16_t AZ, RANGE;
uint32_t WIDTH;
AZ = (( Package->m_pData[cIDX + 3] >> 3 ) << 8 ) | Package->m_pData[cIDX + 4];
RANGE = (( Package->m_pData[cIDX + 3] & 0x07 ) << 8 ) | Package->m_pData[cIDX + 5];
WIDTH = ( Package->m_pData[cIDX + 6] << 24 ) | ( Package->m_pData[cIDX + 7] << 16 ) | ( Package->m_pData[cIDX + 8] << 8 ) | Package->m_pData[cIDX + 9];
#ifdef DEBUG
//sprintf( tBuff, "AZ: %d RANGE: %d WIDTH: %d", AZ, RANGE, WIDTH );
//LOG( tBuff );
#ifdef DEBUG_EXTRA
sprintf( tBuff, "AZ: %d RANGE: %d WIDTH: %d", AZ, RANGE, WIDTH );
LOG( tBuff );
#endif
EVENT_CONTAINER * bEVT = NULL;
TARGET_DATA * tData = prepareTargetData( AZ, RANGE, WIDTH );
@ -1129,7 +1261,7 @@ bool ARGUS_2DSensor::packetHandler( protocolPackage *Package ){
#undef PRINTOUT
TARGET_DATA *ARGUS_2DSensor::prepareTargetData( uint16_t AZ, uint16_t RANGE, uint32_t WIDTH ){
TARGET_DATA *ARGUS_2DSensor::prepareTargetData( uint16_t AZ, uint16_t RANGE, uint32_t WIDTH, uint8_t LRFID ){
TARGET_DATA* tVal = NULL;
systemAnchor* tSystem = systemAnchor::getInstance();
if( tSystem != NULL ) {
@ -1146,7 +1278,7 @@ TARGET_DATA *ARGUS_2DSensor::prepareTargetData( uint16_t AZ, uint16_t RANGE, uin
tVal->local_target.tetta = 90.0f;
tVal->local_target.fi = (360.0f / 6000.0f) * (float) AZ;
tVal->area = WIDTH;
tVal->lrf_id = 0; // Always Master?
tVal->lrf_id = LRFID;//0; // Always Master?
tVal->digital = RANGE;
// local - C3D_SPH_DEGREES
// system - C3D_DECART
@ -1182,6 +1314,7 @@ void ARGUS_2DSensor::simulateTarget( void ){
};
};
/*
void ARGUS_2DSensor::saveRawDrawData( uint16_t alngles ){
CSTR tID = getUniqID_MD5();
if( tID!= NULL ) {
@ -1201,6 +1334,7 @@ void ARGUS_2DSensor::saveRawDrawData( uint16_t alngles ){
free( tID );
};
};
*/
CSTR ARGUS_2DSensor::generateSettingFile(){
FILE * fd = NULL;

14
lib/rgoose/rgooseNode2D.h

@ -15,9 +15,9 @@
#include "../data/protocol/protocolLGS2D.h"
#define LGS_DEFAULT_SLEEP_TIME 333
#define LGS_ALERT_SLEEP_TIME 10
#define LGS_DEFAULT_TO_COUNTER 10
#define LGS_INITIAL_FLIPS 4
#define LGS_ALERT_SLEEP_TIME 30
#define LGS_DEFAULT_TO_COUNTER 30
#define LGS_INITIAL_FLIPS 8
#define ANODE_WM_2D_BEFORE_START 0
#define ANODE_WM_2D_CREATE_PORT 1
@ -67,7 +67,7 @@ class ARGUS_2DSensor: public argusNodeSensor, public basicThread, public protoco
basicLogCollection * m_pLog;
basicEventHeap * m_pEventHeap;
basicEventClassID m_eSensorClass;
DBC_LRF_DATA m_sLRF_DATA;
uint8_t m_bPortType;
basicTransport * m_pPort;
uint8_t m_bWM;
@ -78,6 +78,8 @@ class ARGUS_2DSensor: public argusNodeSensor, public basicThread, public protoco
uint8_t m_bInitialFlips;
uint16_t m_nCurrentAngle;
uint8_t m_bDrawType;
uint8_t m_bOpRetryCnt;
uint32_t m_nProcessingCmdId;
uint32_t m_vDrawRanges[ANODE_2D_MAX_DRAW_ANGLES];
bool m_bSerialStringValid;
bool m_bVersionStringValid;
@ -87,8 +89,8 @@ class ARGUS_2DSensor: public argusNodeSensor, public basicThread, public protoco
uint32_t m_nUploadID;
uint8_t m_nActiveDetectionProfile;
TARGET_DATA * prepareTargetData( uint16_t AZ, uint16_t RANGE, uint32_t WIDTH );
void saveRawDrawData( uint16_t alngles );
TARGET_DATA * prepareTargetData( uint16_t AZ, uint16_t RANGE, uint32_t WIDTH, uint8_t LRFID = 0 );
//void saveRawDrawData( uint16_t alngles );
uint8_t getWM( void );
void setWM( uint8_t MD );
void cleanupDeviceStructures();

42
lib/rgoose/rgooseNodeFactory.cpp

@ -18,16 +18,20 @@ argusNodeFactory * argusNodeFactory::_instance = NULL;
/**
* Returns the single instance of the object.
*/
argusNodeFactory* argusNodeFactory::getInstance( uint32_t ServerID ) {
if( NULL == _instance) {
if( ServerID ) {
_instance = new argusNodeFactory( ServerID );
argusNodeFactory* argusNodeFactory::getInstance( uint32_t SiteID, uint32_t ServerID ) {
if( NULL == _instance ) {
if ( SiteID ) {
if (ServerID) {
_instance = new argusNodeFactory( SiteID, ServerID );
};
};
};
return _instance;
};
argusNodeFactory::argusNodeFactory( uint32_t ServerID ): basicThread(){
m_nSiteID = ServerID;
argusNodeFactory::argusNodeFactory( uint32_t SiteID, uint32_t ServerID ): basicThread(){
m_nSiteID = SiteID;
m_nServerID = ServerID;
m_pLog = basicLogCollection::getInstance();
m_pDBC = argusDBC::getInstance();
init();
@ -111,10 +115,11 @@ bool argusNodeFactory::loadNodes( uint32_t SiteID ){
return false;
};
*/
bool argusNodeFactory::loadNodes( uint32_t SiteID ){
bool argusNodeFactory::loadNodes( uint32_t SiteID, uint32_t ServerID ){
if( m_pDBC == NULL ) return false;
m_nSiteID = SiteID;
DBC_INT_LIST *tList = m_pDBC->listNodes( SiteID );
if( SiteID ) m_nSiteID = SiteID;
if( ServerID ) m_nServerID = ServerID;
DBC_INT_LIST *tList = m_pDBC->listNodes( m_nSiteID, m_nServerID );
if( tList != NULL ) {
for( DBC_INT_LIST::iterator idx = tList->begin(); idx < tList->end(); idx++ ) createNode((*idx));
tList->clear();
@ -128,9 +133,9 @@ bool argusNodeFactory::loadNodes( uint32_t SiteID ){
return true;
};
bool argusNodeFactory::reloadNodes( uint32_t SiteID ){
bool argusNodeFactory::reloadNodes( uint32_t SiteID, uint32_t ServerID ){
if(!unloadNodes()) return false;
return loadNodes( SiteID );
return loadNodes( SiteID, ServerID );
};
bool argusNodeFactory::reloadNode( uint32_t NodeID ){
@ -376,7 +381,7 @@ void argusNodeFactory::deleteNode( argusNetNode *ptr ){
#ifdef DEBUG
LOG("Destroying Network Static Camera");
#endif
SLEEP(2000);
//SLEEP(2000);
LOG("Actual Destroying Network Static Camera");
delete((ARGUS_PTZCAM *) ptr );
break;
@ -384,7 +389,7 @@ void argusNodeFactory::deleteNode( argusNetNode *ptr ){
#ifdef DEBUG
LOG("Destroying Network PTZ Camera");
#endif
SLEEP(2000);
//SLEEP(2000);
delete((ARGUS_PTZCAM *) ptr );
#ifdef DEBUG
LOG("Done Successfuly");
@ -404,26 +409,31 @@ void argusNodeFactory::deleteNode( argusNetNode *ptr ){
#ifdef DEBUG
LOG("Destroying LFS Sensor");
#endif
delete((ARGUS_2DSensor *) ptr );
break;
case ARGUS_ALS_SENSOR:
#ifdef DEBUG
LOG("Destroying ALS Sensor");
#endif
delete((ARGUS_2DSensor *) ptr );
break;
case ARGUS_PLS_200_SENSOR:
#ifdef DEBUG
LOG("Destroying PLS200 Sensor");
#endif
delete((ARGUS_2DSensor *) ptr );
break;
case ARGUS_PLS_360_SENSOR:
#ifdef DEBUG
LOG("Destroying PLS360 Sensor");
#endif
delete((ARGUS_2DSensor *) ptr );
break;
case ARGUS_3D_SENSOR:
#ifdef DEBUG
LOG("Destroying 3D Sensor");
#endif
delete((argus3DLIDAR *) ptr );
break;
case ARGUS_JAMER:
#ifdef DEBUG
@ -485,10 +495,10 @@ void argusNodeFactory::m_fThreadProc( void ){
if( m_vNetNodes.size() ) {
DBC_INT_LIST tL;
for( vectorNetNodes::iterator idx = m_vNetNodes.begin(); idx < m_vNetNodes.end(); idx++ ) tL.push_back( (*idx)->getNodeID() );
tList = m_pDBC->listNewNodes( m_nSiteID, &tL );
tList = m_pDBC->listNewNodes( m_nSiteID, m_nServerID, &tL );
tL.clear();
} else {
tList = m_pDBC->listNewNodes( m_nSiteID, NULL );
tList = m_pDBC->listNewNodes( m_nSiteID, m_nServerID, NULL );
};
if( tList != NULL ) {
#ifdef DEBUG
@ -512,7 +522,7 @@ void argusNodeFactory::m_fThreadProc( void ){
if( m_vNetNodes.size() ) {
//Get Full List
tList = m_pDBC->listNodes( m_nSiteID );
tList = m_pDBC->listNodes( m_nSiteID, m_nServerID );
if( tList != NULL ) {
for( vectorNetNodes::iterator idx = m_vNetNodes.begin(); idx < m_vNetNodes.end(); idx++ ){
bool tRemoved = true;

9
lib/rgoose/rgooseNodeFactory.h

@ -13,10 +13,11 @@ class argusNodeFactory: public basicThread{
basicLogCollection * m_pLog;
argusDBC * m_pDBC;
uint32_t m_nSiteID;
uint32_t m_nServerID;
vectorNetNodes m_vNetNodes;
mapNode2Id m_mNetNodesIDS;
public:
static argusNodeFactory * getInstance( uint32_t ServerID = 0 );
static argusNodeFactory * getInstance( uint32_t SiteID = 0, uint32_t ServerID = 0 );
virtual ~argusNodeFactory();
argusNetNode * createNode( uint32_t id );
void deleteNode( argusNetNode *ptr );
@ -24,13 +25,13 @@ class argusNodeFactory: public basicThread{
uint32_t fetchNodes( ARGUS_NODE_TYPE type, argusNetNode **&RA );
argusNetNode * getNode( uint32_t id );
uint32_t getNodesCount( ARGUS_NODE_TYPE type );
bool loadNodes( uint32_t SiteID = 0 );
bool loadNodes( uint32_t SiteID = 0, uint32_t ServerID = 0 );
bool unloadNodes( void );
bool reloadNodes( uint32_t SiteID = 0 );
bool reloadNodes( uint32_t SiteID = 0, uint32_t ServerID = 0 );
bool reloadNode( uint32_t NodeID );
bool validate( void );
protected:
explicit argusNodeFactory( uint32_t ServerID );
explicit argusNodeFactory( uint32_t SiteID, uint32_t ServerID );
virtual void m_fThreadProc( void );
private:
static argusNodeFactory * _instance;

32
lib/rgoose/rgooseNodePTZCamControl.cpp

@ -80,7 +80,8 @@ void ARGUS_PTZCAM::dispatchEvent( EVENT_CONTAINER *E ){
case EVT_TARGET_2D_BLACK:
case EVT_TARGET_2D_WHITE:
case EVT_TARGET_3D_BLACK:
case EVT_TARGET_3D_WHITE:{
case EVT_TARGET_3D_WHITE:
case EVT_ROI_ACTIVE:{
TARGET_DATA *tDATA;
tDATA = (TARGET_DATA *)E->m_pEvtData;
if( tDATA ) {
@ -154,7 +155,7 @@ bool ARGUS_PTZCAM::validate(){
if( !argusNetNode::m_pDBC ) return false;
//Validate Node Settings
{
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG("Validation Stage 1");
#endif
DBC_NODE_DATA *tDATA = argusNetNode::m_pDBC->getNodeData( m_sNodeData.node_id );
@ -186,19 +187,20 @@ bool ARGUS_PTZCAM::validate(){
};
}*/
// Validate Stream
{
LOG("VALIDATE Stream");
if( m_sNodeData.aux_parameter ) { // Has Choosed Stream
if( !m_bSourceConnected ) {
LOG("Not Connected->Connecting");
if( connectToStream( m_sNodeData.aux_parameter ) ) {
argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter );
} else return false;
} else {
LOG("Connected->Check Stream");
if (!validateStream()) return false;
LOG("Stream Checked!");
};
{
if( m_sNodeData.aux_parameter ) {
#ifdef DEBUG_EXTRA
LOG("VALIDATE Stream");
#endif
if( !m_bSourceConnected ) {
if( connectToStream( m_sNodeData.aux_parameter ) ) {
argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter );
} else {
argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter, false );
};
} else {
validateStream();
};
};
}
return true;

153
lib/rgoose/rgooseNodeSensor.cpp

@ -5,13 +5,29 @@
#define LOG_ERROR( X ) m_pLog->Log( "NODSEN", this, _LOG_ERROR, X )
argusNodeSensor::argusNodeSensor( uint32_t id ):argusNetNode( id ),m_oPosition(){
m_pLog = basicLogCollection::getInstance();
m_pTargetFilter = NULL;
m_pLog = basicLogCollection::getInstance();
memset( &m_sLRF_DATA, 0, sizeof(DBC_LRF_DATA));
if( m_pDBC ){
DBC_LRF_DATA *tDATA = m_pDBC->getLRFData(m_sNodeData.aux_id);
if( tDATA != NULL ) {
memcpy( &m_sLRF_DATA, tDATA, sizeof(DBC_LRF_DATA));
free( tDATA );
};
};
};
argusNodeSensor::argusNodeSensor( DBC_NODE_DATA *Data ):argusNetNode( Data ),m_oPosition(){
m_pLog = basicLogCollection::getInstance();
m_pTargetFilter = NULL;
m_pLog = basicLogCollection::getInstance();
memset( &m_sLRF_DATA, 0, sizeof(DBC_LRF_DATA));
if( m_pDBC ){
DBC_LRF_DATA *tDATA = m_pDBC->getLRFData(m_sNodeData.aux_id);
if( tDATA != NULL ) {
memcpy( &m_sLRF_DATA, tDATA, sizeof(DBC_LRF_DATA));
free( tDATA );
};
};
};
@ -24,11 +40,100 @@ argusNodeSensor::~argusNodeSensor(){
#define WIDTH 1024
// scale factor -> 4/9
uint8_t *argusNodeSensor::create2dDraw( uint32_t *out_size, uint32_t *th_data, size_t th_size, uint16_t max_digital, int radial_shift, CSTR tpl, bool byMinimum ){
uint8_t *RetVal = NULL;
*out_size = 0;
if( th_data != NULL && th_size != 0 ) {
if ( fileExist( tpl ) ) {
cv::Mat tImage = cv::imread( tpl, cv::IMREAD_UNCHANGED );
int psize = th_size / ( sizeof( uint32_t ));
float stp = 2.0f * ( M_PI / (float) psize );
//float MR = m_sLRF_DATA.max_range;
float S = ( M_PI / 3000.0f) * (float) radial_shift;
int x0 = (tImage.cols >> 1);
int y0 = (tImage.rows >> 1);
float maxR = ((float) x0 ) * 0.98f;
cv::Point pts[(psize << 1)];
cv::Point ptt[(psize+2)];
const cv::Point * ppt[1];
int npp[1];
const cv::Point * ppz[1];
int npz[1];
float rst;
int rpt;
uint16_t RANGE = 0;
ptt[0].x = x0;
ptt[0].y = y0;
rst = maxR / ((float)(max_digital+1));
rpt = 1;
for( int i=0; i < psize; i++ ){
if( byMinimum ) {
RANGE = ( th_data[i] >> 16 ) & 0xFFFF;
} else {
RANGE = th_data[i] & 0xFFFF;
};
float ca = 0.0 - ( S + i * stp );
if( RANGE > 0 ){
pts[psize+i].x = x0 + maxR * cosf( ca );
pts[psize+i].y = y0 + maxR * sinf( ca );
if( RANGE > max_digital ){
pts[i].x = pts[psize+i].x;
pts[i].y = pts[psize+i].y;
} else {
float cr = (rst * RANGE);
pts[i].x = x0 + cr * cosf( ca );
pts[i].y = y0 + cr * sinf( ca );
};
} else {
ptt[rpt].x = pts[psize+i].x = pts[i].x = x0 + maxR * cosf( ca );
ptt[rpt].y = pts[psize+i].y = pts[i].y = y0 + maxR * sinf( ca );
rpt++;
};
};
ppt[0] = pts;
npp[0] = ( psize<<1 );
ppz[0] = ptt;
npz[0] = ( rpt - 1);
cv::Mat ttMOMO = cv::imread( tpl, cv::IMREAD_UNCHANGED );
cv::fillPoly( ttMOMO, ppt, npp, 1, cv::Scalar( 0, 128, 255, 50 ), cv::LINE_8 );
cv::fillPoly( ttMOMO, ppz, npz, 1, cv::Scalar( 0, 0, 0, 100 ), cv::LINE_8 );
cv::addWeighted( tImage, 0.5, ttMOMO, 0.5, 0.0, tImage );
ttMOMO.release();
vector<int> compression_params;
compression_params.push_back( cv::IMWRITE_PNG_COMPRESSION );
compression_params.push_back(9);
vector<uchar> buf;
cv::imencode( ".png", tImage, buf, compression_params );
tImage.release();
*out_size = buf.size();
RetVal = (uint8_t *) malloc( *out_size );
if( RetVal ) {
memcpy( RetVal, buf.data(), *out_size );
} else *out_size =0;
buf.clear();
};
};
return RetVal;
};
bool argusNodeSensor::handleDeviceDraw( uint8_t kID, void *th_data, size_t th_size, bool byMinimum ){
if( th_data == NULL ) return false;
if( th_size == 0 ) return false;
if( m_pDBC == NULL ) return false;
m_pDBC->addDeviceDraw( getNodeID(), DRAW_MODE_RAW_DATA, kID, th_data, th_size );
/*
//Clear Old Draw
CSTR old = m_pDBC->getLRFDraw( getNodeID() );
if ( old ) {
@ -56,7 +161,7 @@ bool argusNodeSensor::handleDeviceDraw( uint8_t kID, void *th_data, size_t th_si
};
free( old );
};
*/
CSTR uid = getUniqID_MD5();
if( uid == NULL ) return false;
switch( getNodeType() ){
@ -64,20 +169,32 @@ bool argusNodeSensor::handleDeviceDraw( uint8_t kID, void *th_data, size_t th_si
case ARGUS_LFS_SENSOR:
case ARGUS_PLS_200_SENSOR:
case ARGUS_PLS_360_SENSOR:
case ARGUS_NET_PLS_200:{
char * emptyBG = "data/assets/images/lfs_draw_empty_100.png";
if ( fileExist( emptyBG ) ) {
cv::Mat tImage = cv::imread( emptyBG, cv::IMREAD_UNCHANGED );
if( tImage.rows != 512 || tImage.cols != 1024 ){
LOG_ERROR( "Background Image wrong size (should be 1024x512)!" );
free( uid );
return false;
};
//m_pDBC->addLRFDraw( getNodeID(), TH_SIZE_NODES, uid, kID, 1, true );
} else {
LOG_ERROR( "Background Image is Not Found!" );
free( uid );
return false;
case ARGUS_NET_PLS_200:{
uint32_t tSize;
uint8_t *tBuff = create2dDraw( &tSize, (uint32_t *) th_data, th_size, 1024, m_sLRF_DATA.base_shift, "data/assets/images/lfs_draw_empty_100.png" );
if ( tBuff ) {
m_pDBC->addDeviceDraw( getNodeID(), DRAW_MODE_2D_100, kID, tBuff, tSize );
free( tBuff );
};
tBuff = create2dDraw( &tSize, (uint32_t *) th_data, th_size, 512, m_sLRF_DATA.base_shift, "data/assets/images/lfs_draw_empty_50.png" );
if ( tBuff ) {
m_pDBC->addDeviceDraw( getNodeID(), DRAW_MODE_2D_50, kID, tBuff, tSize );
free( tBuff );
};
tBuff = create2dDraw( &tSize, (uint32_t *) th_data, th_size, 256, m_sLRF_DATA.base_shift, "data/assets/images/lfs_draw_empty_25.png" );
if ( tBuff ) {
m_pDBC->addDeviceDraw( getNodeID(), DRAW_MODE_2D_25, kID, tBuff, tSize );
free( tBuff );
};
tBuff = create2dDraw( &tSize, (uint32_t *) th_data, th_size, 128, m_sLRF_DATA.base_shift, "data/assets/images/lfs_draw_empty_12.png" );
if ( tBuff ) {
m_pDBC->addDeviceDraw( getNodeID(), DRAW_MODE_2D_12, kID, tBuff, tSize );
free( tBuff );
};
tBuff = create2dDraw( &tSize, (uint32_t *) th_data, th_size, 1024, m_sLRF_DATA.base_shift, "data/assets/images/2d_MAP.png" );
if ( tBuff ) {
m_pDBC->addDeviceDraw( getNodeID(), DRAW_MODE_MAP, kID, tBuff, tSize );
free( tBuff );
};
break;
};

16
lib/rgoose/rgooseNodeSensor.h

@ -8,6 +8,9 @@
#define ARGUS_LRF_PCMD_DRAW 3
#define ARGUS_LRF_PCMD_GET_PROFILE 3
#define ARGUS_LRF_ROI_ACTIVATION 42
#define ARGUS_LRF_PUSH_FALSE_TARGET 45
#define ARGUS_LRF_PCMD_SET_MASK_1 60
#define ARGUS_LRF_PCMD_SET_MASK_2 61
#define ARGUS_LRF_PCMD_SET_MASK_3 62
@ -38,9 +41,18 @@
#define ARGUS_LRF_PCMD_SET_DP_3 103
#define ARGUS_LRF_PCMD_UPLOAD_FILE 120
#define ARGUS_LRF_PCMD_UPDATE_ALL 255
#define DRAW_MODE_RAW_DATA 0
#define DRAW_MODE_MAP 1
#define DRAW_MODE_3D 2
#define DRAW_MODE_2D_100 3
#define DRAW_MODE_2D_50 4
#define DRAW_MODE_2D_25 5
#define DRAW_MODE_2D_12 6
#define NODE_CMD_RESET_STUDY 230
@ -48,14 +60,18 @@
#define NODE_CMD_UPLOAD_SHADOW 234
#define NODE_CMD_UPLOAD_FILE 240
#define NODE_CMD_GET_DEVICE_DRAW 100
#define NODE_CMD_ROI_ACTIVE 65
#define NODE_CMD_ALARM 66
class argusNodeSensor: public argusNetNode{
private:
basicLogCollection * m_pLog;
protected:
DBC_LRF_DATA m_sLRF_DATA;
basicPosition m_oPosition;
ARGUS_TARGET_FILTER * m_pTargetFilter;
bool handleDeviceDraw( uint8_t kID, void *th_data, size_t th_size, bool byMinimum = true );
uint8_t * create2dDraw( uint32_t *out_size, uint32_t *th_data, size_t th_size, uint16_t max_digital, int radial_shift, CSTR tpl, bool byMinimum = true );
public:
explicit argusNodeSensor( uint32_t id );
explicit argusNodeSensor( DBC_NODE_DATA *Data );

17
lib/rgoose/rgooseNodeStaticCamControl.cpp

@ -162,13 +162,16 @@ bool ARGUS_CAM::validate(){
}*/
// Validate Stream
{
if( !m_bSourceConnected ) {
if( m_sNodeData.aux_parameter ) { // Has Choosed Stream
if( connectToStream( m_sNodeData.aux_parameter ) ){
//DBC_MEDIA_STREAM_DATA *tDATA = argusNetNode::m_pDBC->getMediaStreamData( m_sNodeData.aux_parameter );
m_bSourceConnected = true;
return argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter );
};
if( m_sNodeData.aux_parameter ) {
//LOG("VALIDATE Stream");
if( !m_bSourceConnected ) {
if( connectToStream( m_sNodeData.aux_parameter ) ) {
argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter );
} else {
argusNetNode::m_pDBC->setStreamValid( m_sNodeData.aux_parameter, false );
};
} else {
validateStream();
};
};
}

19
lib/rgoose/rgooseTypes.h

@ -346,12 +346,23 @@ typedef struct S_DBC_RESOURCE_DATA{
char device[64];
}DBC_RESOURCE_DATA;
#define DBC_CMD_STARTED 1
#define DBC_CMD_FINISHED 100
#define DBC_CMD_READY_TO_CLEAN 250
typedef struct S_DBC_PUSHED_CMD{
uint32_t id;
uint8_t CMD;
char PARAM[256];
}DBC_PUSHED_CMD;
typedef struct S_ROI_CMD_DATA{
uint16_t az_d;
uint16_t el_d;
uint16_t r_d;
}ROI_CMD_DATA;
typedef struct S_DBC_MEDIA_STREAM_DATA{
uint32_t id;
uint32_t source_id;
@ -361,6 +372,8 @@ typedef struct S_DBC_MEDIA_STREAM_DATA{
char token[65];
uint32_t width;
uint32_t height;
uint8_t fps;
char c_type[7];
char mrl_proto[6];
uint16_t mrl_port;
char mrl[251];
@ -421,8 +434,8 @@ typedef struct S_DBC_LRF_DATA{
uint16_t slave_port;
uint16_t enabled_lrf;
float max_range;
uint32_t base_shift;
uint32_t mirror_shift;
int32_t base_shift;
int32_t mirror_shift;
uint8_t detection_profile_id;
uint8_t draw_lrf_id;
uint32_t width_table_id;
@ -601,7 +614,7 @@ typedef struct S_DBC_SNAPSHOT_DATA{
uint8_t * data;
}DBC_SNAPSHOT_DATA;
#define ARGUS_BUILD_STRING ( "RPI_22.06.17 [" __DATE__ " " __TIME__ "]")
#define ARGUS_NM_DISMISS_LEVEL_VIEWER 1
#define ARGUS_NM_DISMISS_LEVEL_OPERATOR 2

Loading…
Cancel
Save