-
Notifications
You must be signed in to change notification settings - Fork 2
/
checkstatusescl.php
152 lines (149 loc) · 4.99 KB
/
checkstatusescl.php
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
<?php
include_once 'config.inc.php';
include_once 'checkpingescl.php';
// Generates staus messages to pass to eSCL Protocol XML ScannerStatus(.xml). Only "Stopped" , "Idle" and "Processing" apply to eSCL. Any other result may show unpredictable or "unknown" status, but here they are anyway.
if ($scanneronline=='yes')
{
$status = "$s400w $host $port status";
$string = shell_exec("$status");
//$string = $statusoutput;
if (($string!='') && ($string!=NULL) && (isset($string)))
{
$last_word_start = strrpos($string, ' ') + 1; // +1 so we don't include the space in our result
$last_word = substr($string, $last_word_start); // $last_word = PHP.
$lastword=preg_replace('/\s+/', '', $last_word);
$now=time();
// apparently no session support at least on mopria so we save to file
$expiration=file_get_contents($root.'eSCL/Scans/lastscan.txt'); //if we just did a scan this has an valid expiration to keep it from showing "No Page" when we should see "processing"
//echo $expiration-$now;
/*Idle Status
Aborted
Canceled
Completed
Processing if (!is_numeric($expiration))
{
$pwgstate=$expiration;
}
else*/
//$now=time();
//$jobdownloaded=file_get_contents
if ((is_numeric($expiration)) && ($expiration+10>=$now)) //(($expiration-$now <= 0) && ($expiration-$now >= 15))
{
$pwgstate='Processing'; // need proper response here! ScanReady ???? ReadyToUpload?? Ready??
$pwgjobstatereason='JobScanning';
$pwgjobstate='Processing';
}
/* elseif (($nowscanning=='yes')&&($lastword=='nopaper'))
{
$pwgstate='Idle';
$pwgjobstate='Aborted';
$pwgjobstatereason='JobRestartable';
}*/
elseif ((is_numeric($expiration)) && ($expiration+10<=$now)) // ((trim($lastword)=='nopaper') && ($expiration+15<=$now))
{ //online but no page loaded -nested if
$pwgstate='Idle';
$pwgjobstatereason='JobCompletedSuccessfully';
$pwgjobstate='Processing'; //!!! pretty sure this is correct
$scanage=$now-$expiration;
}
elseif (!is_numeric($expiration)) //&& (($expiration=='Completed')) // && ($expiration>=$now)) // && ($expiration>=$now)) // ((trim($lastword)=='nopaper') && ($expiration+15<=$now))
{ //online but no page loaded -nested if
$pwgstate='Idle';
$pwgjobstatereason='';
$pwgjobstate=$expiration; // !!! pretty sure this is correct
$scanage='';
}
elseif ((trim($lastword)=='') || (trim($lastword)==NULL) || (!isset($lastword)))
{ //(trim($lastword)=='')) { //online scanning -nested if //getting '' while scanning on halo magic scanner
$pwgstate='Processing';
$pwgjobstatereason='JobScanning';
$pwgjobstate='Processing';
}
elseif (trim($lastword=='devbusy'))
{ //online device is busy -nested if
$pwgstate='Processing';
$pwgjobstatereason='JobScanning';
$pwgjobstate='Processing';
}
elseif (trim($lastword=='battlow'))
{ //online but battery low -nested if
$pwgstate='Disable()';
$pwgjobstatereason='';
$pwgjobstate='';
}
elseif (trim($lastword=='scanready'))
{ //online with page loaded -nested elseif
$pwgstate='Idle';
$pwgjobstatereason='';
}
elseif (trim($lastword)=='calgo')
{ //online calibrating -nested elseif
$pwgstate='Disable()';
$pwgjobstatereason='JobScanning';
$pwgjobstate='Processing';
}
elseif (trim($lastword)=='cleango')
{ //online cleaning -nested elseif
$pwgstate='Disable()';
$pwgjobstatereason='JobScanning';
$pwgjobstate='Processing';
}
elseif (trim($lastword)=='calibrate')
{ //online calibration complete -nested elseif
$pwgstate='Disable()';
$pwgjobstatereason='';
$pwgjobstate='';
}
elseif (trim($lastword)=='cleanend')
{ //online cleaning complete -nested elseif
$pwgstate='Idle';
$pwgjobstatereason='';
}
elseif (trim($lastword)=='dpifine')
{ //600dpi calibrating -nested elseif
$pwgstate='600DPI';
$pwgjobstatereason='';
$pwgjobstate='';
}
elseif (trim($lastword)=='dpistd')
{ //300dpi -nested elseif
$pwgstate='300DPI';
$pwgjobstatereason='';
$pwgjobstate='';
}
else { //other- unknown paper condition -nested else
//$pwgstate= 'Stopped';
$pwgstate= 'Stopped';
$pwgjobstatereason='';
$pwgjobstate='';
}
}
else
{
$pwgstate= 'Idle';
$pwgjobstatereason='';
$pwgjobstate='';
}
}
elseif ($scanneronline=='no')
{ //offline -nested else
$pwgstate= 'Stopped';
$pwgjobstatereason='';
$pwgjobstate=''; //found "Stopped" in PWG document. Makes red dot on Mopria , so seems to work! //
} //So when scanner off we still generate ScannerStatus.xml.
//This shows Red Dot and "Stopped" in Mopria instad of yellow dot and "unknown"
//Coincides with indicators on scanner
/*
echo $expiration;
echo '<br>';
echo $now;
$key = false;
while($key){
sleep(1);
$now2=time();
if($expiration <= $nowagain) $key = true;
}
echo '<br>Exp'.$expiration;
echo '<br>now'.$now2;
echo '<br>dif'.$expiration - $nowagain;*/
?>