/** Output the standard scale display box @return None */ protected function scale_box() { ?> <div id="scalebox"> <div id="scaleTop" class="coloredArea"> <?php echo _("weight"); ?> </div> <div id="scaleBottom"> <?php echo DisplayLib::scaledisplaymsg(); ?> </div> <div id="scaleIconBox"> <?php echo DisplayLib::drawNotifications(); ?> </div> </div> <?php }
function ReadFromScale() { $rel = MiscLib::base_url(); $readfile = $rel . 'scale-drivers/drivers/NewMagellan/scanner-scale'; $readdir = $rel . 'scale-drivers/drivers/NewMagellan/ss-output'; $scale_display = ""; $scans = array(); /* if (file_exists($readfile.".data") && !file_exists($readfile.".lock")){ $fp = fopen($readfile.".lock","w"); fclose($fp); $data = file_get_contents($readfile.".data"); unlink($readfile.".data"); unlink($readfile.".lock"); foreach(explode("\n",$data) as $line){ $line = rtrim($line,"\r"); // in case OS adds it if (empty($line)) continue; if ($line[0] == 'S'){ $scale_display = scaledisplaymsg($line); } else { $scans[] = $line; } } } */ $files = scandir($readdir); foreach ($files as $fn) { if (is_dir($readdir . "/" . $fn)) { continue; } $data = file_get_contents($readdir . "/" . $fn); unlink($readdir . "/" . $fn); $line = rtrim($data, "\r\n"); if (empty($line)) { continue; } if ($line[0] == 'S') { $scale_display = DisplayLib::scaledisplaymsg($line); if (is_array($scale_display)) { if (isset($scale_display['upc'])) { $scans[] = $scale_display['upc']; } $scale_display = $scale_display['display']; } } else { $scans[] = $line; } break; } $output = array(); if (!empty($scale_display)) { $output['scale'] = $scale_display; } if (!empty($scans)) { $output['scans'] = ltrim($scans[0], '0'); } if (!empty($output)) { echo JsonLib::array_to_json($output); } else { echo "{}"; } }
function ReadFromScale() { $rel = MiscLib::base_url(); $scale_data = file_get_contents($rel . 'scale-drivers/drivers/rs232/scale'); $fp = fopen($rel . 'scale-drivers/drivers/rs232/scale', 'w'); fclose($fp); $scan_data = file_get_contents($rel . 'scale-drivers/drivers/rs232/scanner'); $fp = fopen($rel . 'scale-drivers/drivers/rs232/scanner', 'w'); fclose($fp); $scale_display = ''; $scans = array(); if ($scale_data !== False && !empty($scale_data)) { $scale_display = DisplayLib::scaledisplaymsg($scale_data); if (is_array($scale_display)) { if (isset($scale_display['upc'])) { $scans[] = $scale_display['upc']; } $scale_display = $scale_display['display']; } } if ($scan_data !== False && !empty($scan_data)) { $scans[] = $scan_data; } $output = array(); if (!empty($scale_display)) { $output['scale'] = $scale_display; } if (!empty($scans)) { $output['scans'] = ltrim($scans[0], '0'); } if (!empty($output)) { echo JsonLib::array_to_json($output); } else { echo "{}"; } }
} } else { $arr = array('main_frame' => false, 'target' => '.baseHeight', 'output' => DisplayLib::inputUnknown()); $json = $arr; if (is_object($sd)) { $sd->WriteToScale('errorBeep'); } } } } CoreLocal::set("msgrepeat", 0); if (empty($json)) { echo "{}"; } else { if (isset($json['redraw_footer']) && $json['redraw_footer'] !== False) { $json['redraw_footer'] = DisplayLib::printfooter(); } if (isset($json['scale']) && $json['scale'] !== False) { $display = DisplayLib::scaledisplaymsg($json['scale']); if (is_array($display)) { $json['scale'] = $display['display']; } else { $json['scale'] = $display; } $term_display = DisplayLib::drawNotifications(); if (!empty($term_display)) { $json['term'] = $term_display; } } echo JsonLib::array_to_json($json); }
public function testDisplayLib() { $footer = DisplayLib::printfooter(); $this->assertInternalType('string', $footer); $this->assertNotEmpty($footer); $pmsg = DisplayLib::plainmsg('test message'); $this->assertInternalType('string', $pmsg); $this->assertNotEmpty($pmsg); $this->assertContains('test message', $pmsg); $mbox = DisplayLib::msgbox('test msgbox', '', True); $this->assertInternalType('string', $mbox); $this->assertNotEmpty($mbox); $this->assertContains('test msgbox', $mbox); $xbox = DisplayLib::xboxMsg('test xboxMsg'); $this->assertInternalType('string', $xbox); $this->assertNotEmpty($xbox); $this->assertContains('test xboxMsg', $xbox); $bmsg = DisplayLib::boxMsg('test boxMsg', '', True); $this->assertInternalType('string', $bmsg); $this->assertNotEmpty($bmsg); $this->assertContains('test boxMsg', $bmsg); $unk = DisplayLib::inputUnknown(); $this->assertInternalType('string', $unk); $this->assertNotEmpty($unk); $headerb = DisplayLib::printheaderb(); $this->assertInternalType('string', $headerb); $this->assertNotEmpty($headerb); $item = DisplayLib::printItem('name', 'weight', '1.99', 'T', 1); $this->assertInternalType('string', $item); $this->assertNotEmpty($item); $itemC = DisplayLib::printItemColor('004080', 'name', 'weight', '1.99', 'T', 2); $this->assertInternalType('string', $itemC); $this->assertNotEmpty($itemC); $itemH = DisplayLib::printItemColorHilite('004080', 'name', 'weight', '1.99', 'T'); $this->assertInternalType('string', $itemH); $this->assertNotEmpty($itemH); CoreLocal::set('weight', 0); CoreLocal::set('scale', 0); CoreLocal::set('SNR', 0); $basic = DisplayLib::scaledisplaymsg(); $this->assertInternalType('string', $basic); $this->assertEquals('0.00 lb', $basic); $scale_in_out = array('S11000' => '0.00 lb', 'S11001' => '0.01 lb', 'S11' => '_ _ _ _', 'S141' => '_ _ _ _', 'S143' => '0.00 lb', 'S145' => 'err -0', 'S142' => 'error', 'ASDF' => '? ? ? ?', 'S144000' => '0.00 lb', 'S144002' => '0.02 lb'); foreach ($scale_in_out as $input => $output) { $test = DisplayLib::scaledisplaymsg($input); $this->assertInternalType('array', $test); $this->assertArrayHasKey('display', $test); $this->assertEquals($output, $test['display']); } $this->assertEquals(1, CoreLocal::get('scale')); $this->assertEquals(0.02, CoreLocal::get('weight')); CoreLocal::set('SNR', '4011'); $both = DisplayLib::scaledisplaymsg('S11050'); $this->assertInternalType('array', $both); $this->assertArrayHasKey('display', $both); $this->assertArrayHasKey('upc', $both); $this->assertEquals('0.50 lb', $both['display']); $this->assertEquals('4011', $both['upc']); $list = DisplayLib::listItems(0, 0); $this->assertInternalType('string', $list); $rf = DisplayLib::printReceiptFooter(); $this->assertInternalType('string', $rf); $draw = DisplayLib::drawItems(0, 11, 0); $this->assertInternalType('string', $draw); $lp = DisplayLib::lastpage(); $this->assertInternalType('string', $lp); $this->assertEquals($lp, $list); }
/******************************************************************************* Copyright 2010 Whole Foods Co-op. This file is part of IT CORE. IT CORE is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. IT CORE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License in the file license.txt along with IT CORE; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *********************************************************************************/ ini_set('display_errors', 'Off'); include_once dirname(__FILE__) . '/../lib/AutoLoader.php'; $input = isset($_REQUEST['input']) ? $_REQUEST['input'] : ''; $display = DisplayLib::scaledisplaymsg($input); if (is_array($display)) { echo $display['display']; } else { echo $display; }