Added TCL version

This commit is contained in:
svk28 2017-08-16 13:15:56 +03:00
parent ee5aa426da
commit a6dc8d3836

View File

@ -8,11 +8,13 @@
package require mysqltcl
# параметры соединения с СУБД
set db(host) "host"
set db(user) "user"
set db(pass) "password"
set db(dbname) "ats_test"
set out_dir "~/tmp/ats"
#source config.tcl
#set db(host) "host"
#set db(user) "user"
#set db(pass) "password"
#set db(dbname) "ats_test"
#set out_dir "~/tmp/ats"
proc InsertData {} {
global arrVariables db
@ -72,22 +74,26 @@ proc ParceString {line} {
proc PortDataRead {portName} {
global out_dir
set fh [open $portName RD]
fconfigure $fh -blocking 0 -buffering none -mode 9600,n,8,1 -translation binary -eofchar {}
while [gets line $fh] {
set line = [string trim $line]
ParceString $line
}
set fh [open $portName RDONLY]
fconfigure $fh -blocking 0 -buffering none -mode 9600,n,8,1 -translation crlf -eofchar {}
fileevent $fh readable [list read $fh]
puts "Waiting for Capture data"
vwait forever
}
# Обработка ключей командной сроки
if {[llength $argv] >= 2} {
if {[lindex $argv 0] == "-port"} {
set port_name [lindex $argv 2]
if {[lindex $argv 0] == "-conf"} {
source [lindex $argv 1]
} else {
puts "Не указан конфигурационный файл"
}
if {[lindex $argv 2] == "-port"} {
set port_name [lindex $argv 3]
PortDataRead $port_name
}
if {[lindex $argv 0] == "-file"} {
set log_file_name [lindex $argv 1]
if {[lindex $argv 2] == "-file"} {
set log_file_name [lindex $argv 3]
set log [open $log_file_name "r"]
# проверям наличие каталога и если его нет то создаём
if {[file isdirectory $out_dir] == 0} {
@ -101,9 +107,10 @@ if {[llength $argv] >= 2} {
}
} else {
puts "\nФормат вызова:\n- для обработки файла\
\n # python data_reader.py -file TDA20013082015_12052016.lg\
\n # -conf config.tcl
\n # tclsh logger.tcl -conf config.tcl -file TDA20013082015_12052016.lg\
\n- для чтения данных напрямую с com-порта АТС\
\n # python data_reader.py -port /dev/ttyUSB0\n"
\n # tclsh logger.tcl -conf config.tcl -port /dev/ttyUSB0\n"
exit
}