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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
var sensortype=14;
var interval_refresh_images;
function init(){
var t = $("<table>").html("\
<tr>\
<td id='controls' valign='top'></td>\
<td id='pic1'></td>\
<td id='pic2'></td>\
</tr><tr>\
<td></td>\
<td id='pic3'></td>\
<td id='pic4'></td>\
</tr>");
$("body").append(t);
var port = 2323;
for(i=0;i<4;i++){
var url = "http://"+window.location.hostname+":"+(port+i)+"/img";
var ref = "http://"+window.location.hostname+":"+(port+i)+"/mimg";
a = $("<a>",{href:ref});
img = $("<img>",{id:"chn"+i}).css({
width: "500px"
});
img.attr("src",url);
img.attr("src_init",url);
$("#pic"+(i+1)).append($("<div>").append(a.append(img)));
/*
img.load(function(){
d = new Date();
n = d.getTime();
this.src = $(this).attr("src_init")+"&"+n;
});
*/
}
ct = $("<div style='padding-top:10px;'>");
tmpstr = "<table>\
<tr>\
<td>Sensors type:</td>\
<td><button id='s5'><b>5 MPix</b></button></td>\
<td><button id='s14'><b>14 MPix</b></button></td>\
</tr>\
</table>";
ct.html(tmpstr);
$("#controls").append(ct);
$("#s5").addClass("btn nooutline");
$("#s14").addClass("btn nooutline");
ct2 = $("<div style='padding-top:20px;'>");
tmpstr = "<tr><td>Chn </td><td>Test Pattern </td><td id='sp'>Sensor Phase (0-7) </td></tr>";
for(i=0;i<4;i++){
tmpstr += "\
<tr>\
<td valign='bottom'>"+(i+1)+"</td>\
<td valign='bottom'><input type='checkbox' id='tp"+i+"' class='tp'/></td>\
<td valign='bottom'><input type='text' id='sp"+i+"' value='0' class='sp'/></td>\
</tr>\
";
}
ct2.html(tmpstr);
$("#controls").append(ct2);
$(".tp").css({
width:"20px",
height:"20px"
});
$(".sp").css({
width: "50px",
"text-align":"right"
});
$(".tp").change(function(){
var tmp = $(this).attr("id");
var index = tmp[2];
console.log("index= "+index+" state="+$(this).prop("checked"));
send_cmd("set_test_pattern",index,$(this).prop("checked"));
});
$(".sp").change(function(){
var tmp = $(this).attr("id");
var index = tmp[2];
console.log("index= "+index+" state="+$(this).val());
send_cmd("set_sensor_phase",index,$(this).val());
});
ct3 = $("<div style='padding-top:20px;'>");
var sdram_phase_button = $("<button>",{id:"sdram_phase",class:"btn btn-danger nooutline"}).html("<b>SDRAM phase scan</b> (~10-minute process)");
//ct3.prepend(sdram_phase_button);
$("#controls").append(ct3);
init_sensor_type();
init_images();
}
function init_images(){
interval_refresh_images = setInterval(function(){
for(var j=0;j<4;j++){
d = new Date();
n = d.getTime();
$("#chn"+j).attr("src",$("#chn"+j).attr("src_init")+"&"+n);
}
},500);
}
function send_cmd(command,index,value){
$.ajax({
url: "setup.php?cmd="+command+"&chn="+index+"&val="+value,
complete: function(){
console.log("complete");
}
});
}
function init_sensor_type(){
$.ajax({
url: "setup.php?cmd=get_sensor_type",
complete: function(data){
r = JSON.parse(data.responseText);
if (r.sensortype==5){
sensortype=5;
$("#s5").addClass("btn-success");
$(".sp").css({
display:"none"
});
$("#sp").css({
display:"none"
});
}
if (r.sensortype==14){
sensortype=14;
$("#s14").addClass("btn-success");
}
}
});
}