-
Notifications
You must be signed in to change notification settings - Fork 1
/
readVisibility.tcl
executable file
·58 lines (51 loc) · 1.25 KB
/
readVisibility.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Slurp visibility matrix file
# name: satsVisibility
# type: cell
# rows: 1
# columns: 30
# name: <cell-element>
# type: matrix
# rows: 21601
# columns: 30
set file_name "satsVisibility.mat"
set mychar #
if { [file exists $file_name] == 1} {
catch {set vf [ open $file_name r]}
set visibility_matrix_data [ read -nonewline $vf ]
close $vf
set visibility_data [split $visibility_matrix_data "\n"]
set n 1
set satIndex 0
set timeslot 1
foreach line $visibility_data {
# This indicates a new element
# name: <cell-element>
# type: matrix
# rows: 21601
# columns: 30
if {[string match $mychar* $line]} {
# Check if it is a new <cell-element>
set substring "cell-element"
if {[string first $substring $line] != -1} {
set satIndex [expr $satIndex+1]
set timeslot 1
}
} else {
# if not a blank line
if { $line ne ""} {
puts "$n $satIndex $timeslot $line"
if { $timeslot > 21601 } {
puts "Error: too many timeslots!"
exit
}
lappend satsVisibility($satIndex) $line
set n [expr $n+1]
set timeslot [expr $timeslot+1]
}
}
}
set satsrc 1
set timeslot 1
set satdst 2
puts [lindex [lindex $satsVisibility($satsrc) $timeslot] $satdst]
}