Пример #1
0
 public function generate()
 {
     $serial = new Serial();
     $serial->serial = $this->serial;
     $serial->duration = $this->duration;
     $serial->save();
     for ($number = 1; $number <= $this->quantity; $number++) {
         $card = new Card();
         $card->serial_id = $serial->id;
         $card->number = $number;
         $card->save();
     }
 }
Пример #2
0
 /**
  * Get the Serial ID
  **/
 public function actionGetSerialID()
 {
     $model = Serial::model()->findByPk(array('unused_id' => 1));
     header("Content->type: application/json");
     echo CJSON::encode($model);
     $model->id = "guodegang";
     $model->save();
     Yii::app()->end();
 }
Пример #3
0
<?php

require 'includes/master.inc.php';
$Auth->requireAdmin('login.php');
$nav = 'applications';
$app = new Application($_GET['id']);
if (!$app->ok()) {
    redirect('index.php');
}
if (isset($_POST['btnSerial'])) {
    if (strlen($_POST['serial']) > 0) {
        $s = new Serial();
        $s->app_id = $app->id;
        $s->dt = dater();
        $s->guid = $_POST['guid'];
        $s->serial = $_POST['serial'];
        $s->insert();
        redirect('pirates.php?id=' . $app->id);
    }
}
$db = Database::getDatabase();
$pirates = $db->getRows("SELECT * FROM pirates WHERE app_id = '{$app->id}' ORDER BY dt DESC");
$serial_count = $db->getValue("SELECT COUNT(*) from pirated_serials WHERE app_id = '{$app->id}'");
$serial_date = $db->getValue("SELECT dt FROM pirated_serials WHERE app_id = '{$app->id}' ORDER BY dt DESC LIMIT 1");
$serial_date = $serial_date ? time2str($serial_date) : 'never';
if (isset($_GET['feed']) && $_GET['feed'] == 'json') {
    $serials = DBObject::glob('Serial', "SELECT * from pirated_serials WHERE app_id = '{$app->id}'");
    $arr = array();
    foreach ($serials as $s) {
        $arr[] = array('dt' => $s->dt, 'guid' => $s->guid, 'serial' => $s->serial);
    }
Пример #4
0
<?php

include '/var/www/lib/config.php';
include '/var/www/lib/utilities.php';
include '/var/www/lib/serial.php';
define('TIME_TO_SLEEP', 0.5);
//init serial class
$serial = new Serial();
$serial->deviceSet(PORT_NAME);
$serial->confBaudRate(BOUD_RATE);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->deviceOpen();
$serial->serialflush();
$time_to_sleep_after_post = 0;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (isset($_POST['action'])) {
        $action = $_POST['action'];
        switch ($action) {
            case 'eeprom':
                // restore eprom
                $time_to_sleep_after_post = 5;
                //;Steps per unit:
                $serial->sendMessage('M92 X72.58 Y72.58 Z2133.33 E3048.16' . PHP_EOL);
                $serial->serialflush();
                //sleep(TIME_TO_SLEEP);
                //$serial->sendMessage('M500'.PHP_EOL);
                //sleep(TIME_TO_SLEEP);
                $serial->sendMessage('M203 X550.00 Y550.00 Z15.00 E12.00 ' . PHP_EOL);
                $serial->serialflush();
Пример #5
0
 public function actionOpenDrawCash()
 {
     $configSoftware = ConfigSoftware::model()->find();
     $serial = new Serial();
     $serial->deviceSet($configSoftware->serial_port);
     $serial->deviceOpen();
     $serial->sendMessage("Open");
     $read = $serial->readPort();
     $serial->deviceClose();
     $serial->confBaudRate(2400);
 }
Пример #6
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/config.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/database.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/utilities.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/serial.php';
$over = $_POST['over'];
$serial = new Serial();
$probe_lenght = 0;
$serial->deviceSet(PORT_NAME);
$serial->confBaudRate(BOUD_RATE);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->deviceOpen();
$serial->sendMessage('M503' . PHP_EOL);
$response = $serial->readPort();
$temp = explode(PHP_EOL, $response);
$length_string = '';
foreach ($temp as $line) {
    if (strpos($line, 'Probe Length') !== false) {
        $length_string = $line;
    }
}
if ($length_string != '') {
    $temp_length = explode(':', $length_string);
    $probe_lenght = trim($temp_length[2]);
}
$new_lenght = abs($probe_lenght) - $over;
$serial->sendMessage('M710 S' . abs($new_lenght) . PHP_EOL);
$response = $serial->readPort();
 public function actionOpenDrawCash()
 {
     $serial = new Serial();
     $serial->deviceOpen();
 }
Пример #8
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/config.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/utilities.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/serial.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/fabui/application/config/fabtotum.php';
$head = $_POST['head'];
$pid = $config['heads_pids'][$head];
$description = $config['heads_list'][$head];
if ($pid != '') {
    //init serial
    $serial = new Serial();
    $serial->deviceSet(PORT_NAME);
    $serial->confBaudRate(BOUD_RATE);
    $serial->confParity("none");
    $serial->confCharacterLength(8);
    $serial->confStopBits(1);
    $serial->deviceOpen();
    $serial->serialflush();
    $serial->serialflush();
    $serial->sendMessage($pid . PHP_EOL);
    sleep(0.1);
    $serial->sendMessage('M500' . PHP_EOL);
    $reply = $serial->readPort();
    sleep(0.1);
    $serial->sendMessage('M730' . PHP_EOL . 'M999' . PHP_EOL . 'M728' . PHP_EOL);
    $serial->deviceClose();
}
/** GET UNITS */
$_units = json_decode(file_get_contents(FABUI_PATH . 'config/config.json'), TRUE);
$_units['hardware']['head']['type'] = $head;
Пример #9
0
 *  BOOT SCRIPT FILE - INITIALIZE MACHINE CUSTOM PARAMETERS
 * 
 * 
 */
require_once '/var/www/lib/config.php';
require_once '/var/www/lib/serial.php';
define('TIME_TO_SLEEP', 1);
//==================================================================
//force serial flush
shell_exec('sudo python ' . PYTHON_PATH . 'flush.py');
sleep(1);
//==================================================================
//load config
$configs = json_decode(file_get_contents(FABUI_PATH . 'config/config.json'), TRUE);
//init serial
$serial = new Serial();
$serial->deviceSet(PORT_NAME);
$serial->confBaudRate(BOUD_RATE);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->deviceOpen();
$serial->serialflush();
//==================================================================
//alive machine
$serial->serialflush();
$serial->sendMessage('M728' . PHP_EOL);
sleep(TIME_TO_SLEEP);
$alive_machine = $serial->readPort();
//==================================================================
$serial->serialflush();
Пример #10
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $units = $_POST['unit'];
     $i = 1;
     foreach ($units as $unit) {
         $units_array['unit_' . $i] = $unit;
         $i++;
     }
     Input::merge($units_array);
     $numunits = array('numunits' => sizeof($units_array));
     Input::merge($numunits);
     // echo "<pre>";
     // print_r(Input::all());
     // echo "</pre>";
     // exit;
     $rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email', 'unit_1' => 'required|digits:10|numeric', 'unit_2' => 'digits:10|numeric', 'unit_3' => 'digits:10|numeric', 'unit_4' => 'digits:10|numeric', 'unit_5' => 'digits:10|numeric', 'unit_6' => 'digits:10|numeric', 'unit_7' => 'digits:10|numeric', 'unit_8' => 'digits:10|numeric', 'unit_9' => 'digits:10|numeric', 'unit_10' => 'digits:10|numeric', 'address' => 'required', 'city' => 'required', 'state' => 'required', 'zip' => 'required', 'installer_id' => 'required');
     $messages = array('unit_1.required' => 'You must enter at least one serial number.', 'unit_1.digits' => 'Your serial number must be 10 digits.', 'unit_1.exists' => 'That serial number doesn\'t exist in our database.', 'installer_id.required' => 'You must choose an installer.');
     $validator = Validator::make(Input::all(), $rules, $messages);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('register')->withErrors($validator)->withInput(Input::all());
     } else {
         // echo "<pre>";
         // print_r($_POST);
         // echo "</pre>";
         // exit;
         // store
         $user = new User();
         $user->first_name = Input::get('first_name');
         $user->last_name = Input::get('last_name');
         $user->address = Input::get('address');
         $user->address_2 = Input::get('address_2');
         $user->city = Input::get('city');
         $user->state = Input::get('state');
         $user->zip = Input::get('zip');
         $user->country = Input::get('country');
         $user->phone = Input::get('phone');
         $user->email = Input::get('email');
         $user->comments = Input::get('comments');
         $user->installer_id = Input::get('installer_id');
         //$user->password         = Hash::make('test');
         $user->save();
         $units = $_POST['unit'];
         foreach ($units as $unit) {
             if ($unit) {
                 $serial = new Serial();
                 // $serials = $serial->where('serial','=',$unit)->first();
                 $serial->serial = $unit;
                 $serial->save();
                 $serialid = $serial->id;
                 $user->serials()->attach($user->id, array('serial_id' => $serialid));
             }
         }
         // //Find Serial Outdoor
         // $serial_input = Input::get('serial_outdoor');
         // $serial = new Serial;
         // $serials = $serial->where('serial','=',$serial_input)->first();
         // if($serials) {
         //     $user->serials()->attach($user->id,array('serial_id' => $serials->id ));
         // }
         // $serial_indoor_coil = Input::get('serial_indoor_coil');
         // if($serial_indoor_coil) {
         //     $serial_2 = new Serial;
         //     $serials_2 = $serial_2->where('serial','=',$serial_indoor_coil)->first();
         //     if($serials_2) {
         //         $user->serials()->attach($user->id,array('serial_id' => $serials_2->id ));
         //     }
         // }
         // $serial_indoor_furnace = Input::get('serial_indoor_furnace');
         // if($serial_indoor_furnace) {
         //     $serial_3 = new Serial;
         //     $serials_3 = $serial_3->where('serial','=',$serial_indoor_coil)->first();
         //     if($serials_2) {
         //         $user->serials()->attach($user->id,array('serial_id' => $serials_3->id ));
         //     }
         // }
         //Review
         // $rating = new Rating();
         // $rating->user_id                = $user->id;
         // $rating->timeliness_rating      = Input::get('timeliness_rating');
         // $rating->cleanliness_rating     = Input::get('cleanliness_rating');
         // $rating->courteous_rating       = Input::get('courteous_rating');
         // $rating->answer_rating          = Input::get('answer_rating');
         // $rating->recommend              = Input::get('recommend');
         // $rating->review                 = Input::get('review');
         // if( !$rating->save() ) {
         //     echo "Whoops";
         //     exit;
         // }
         $data = Input::all();
         //Mail
         Mail::send('emails.thankyouregister', $data, function ($message) {
             $username = Input::get('first_name') . " " . Input::get('last_name');
             $message->from(Config::get('site.mail_from'), Config::get('site.mail_from_name'));
             $message->to(Input::get('email'), $username)->subject(Input::get('first_name') . ', Thank You for Registering your Product!');
         });
         Mail::send('emails.adminregister', $data, function ($message) {
             // $username = Input::get('first_name')." ".Input::get('last_name');
             $message->from(Config::get('site.mail_from'), Config::get('site.mail_from_name'));
             $message->to(Config::get('site.mail_from'), Config::get('site.mail_from_name'))->subject('New Registration: ' . Input::get('email'));
         });
         // redirect
         Session::flash('message', 'Successfully registered!');
         Session::put('user_id', $user->id);
         Session::put('units', $units);
         return Redirect::action('UserController@confirm');
         //return Redirect::route('register.confirm')->with('user', $user->id);
     }
 }
Пример #11
0
<?php

/**
 * 
 * SETTING VERSION 3
 * 
 */
require_once '/var/www/lib/config.php';
require_once '/var/www/lib/serial.php';
define('HARDWARE_ID', 3);
define('SHOW_FEEDER', false);
define('E_MODE', 3048.1593);
define('A_MODE', 177.777778);
//init serial
$serial = new Serial();
$serial->deviceSet(PORT_NAME);
$serial->confBaudRate(BOUD_RATE);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->deviceOpen();
$serial->serialflush();
/**
 * 
 *  INVERT X ENDSTOP LOGIC - M732
 * 
 */
$serial->sendMessage('M747 X1' . PHP_EOL);
sleep(0.5);
/**
 * Maximum feedrates (mm/s):
Пример #12
0
 public function __construct($serial)
 {
     parent::__construct($serial);
 }
Пример #13
0
<?php

/**
 * 
 * CUSTOM SETTINGS - DEFINED IN SETTINGS->ADVANCED
 * 
 * 
 */
require_once '/var/www/lib/config.php';
//load config
$configs = json_decode(file_get_contents(FABUI_PATH . 'config/custom_config.json'), TRUE);
$custom_overrides = file_get_contents($configs['custom_overrides']);
//init serial
$serial = new Serial();
$serial->deviceSet(PORT_NAME);
$serial->confBaudRate(BOUD_RATE);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->deviceOpen();
$serial->serialflush();
/**
 * SEND COUSTOM OVERRIDES
 */
/**
 * INVERT X ENDSTOP LOGIC
 */
$extra_ovverride = 'M747 X';
$extra_ovverride = $configs['invert_x_endstop_logic'] ? 'M747 X1' : 'M747 X0';
$custom_overrides = $extra_ovverride . PHP_EOL . $custom_overrides;
$serial->sendMessage($custom_overrides . PHP_EOL);
Пример #14
0
 $_settings['layout'] = '';
 $_user_data['first_name'] = $_first_name;
 $_user_data['last_name'] = $_last_name;
 $_user_data['email'] = $_email;
 $_user_data['password'] = md5($_password);
 $_user_data['settings'] = json_encode($_settings);
 /** ADD TASK RECORD TO DB */
 $id_user = $db->insert('sys_user', $_user_data);
 $wlan = wlan();
 $wlan_ip = isset($wlan['ip']) ? $wlan['ip'] : '';
 /** UPDATE WIFI */
 $_data_update = array();
 $_data_update['value'] = json_encode(array('ssid' => $_net, 'password' => $_net_password, 'ip' => $wlan_ip));
 $db->update('sys_configuration', array('column' => 'sys_configuration.key', 'value' => 'wifi', 'sign' => '='), $_data_update);
 //=========== SERIAL CLASS - GET FW VERSION
 $serial = new Serial();
 $serial->deviceSet(PORT_NAME);
 $serial->confBaudRate(BOUD_RATE);
 $serial->confParity("none");
 $serial->confCharacterLength(8);
 $serial->confStopBits(1);
 $serial->deviceOpen();
 $serial->sendMessage("M765\r\n");
 $fw_verision_reply = $serial->readPort();
 $serial->deviceClose();
 $fw_version = '';
 $temp = explode(PHP_EOL, $fw_verision_reply);
 if (isset($temp[0])) {
     if (strpos($temp[0], 'V') !== false) {
         $fw_version = trim(str_replace('V', '', $temp[0]));
     }
Пример #15
0
 public function testSetRotate()
 {
     $this->chart->setRotate(true);
     $this->assertTrue($this->chart->getRotate());
 }
Пример #16
0
function get_fw_version()
{
    $serial = new Serial();
    $serial->deviceSet(PORT_NAME);
    $serial->confBaudRate(BOUD_RATE);
    $serial->confParity("none");
    $serial->confCharacterLength(8);
    $serial->confStopBits(1);
    $serial->deviceOpen();
    $serial->sendMessage("M765\r\n");
    $reply = $serial->readPort();
    $serial->deviceClose();
    return trim(str_replace('V ', '', str_replace(PHP_EOL . 'ok', '', $reply)));
}
Пример #17
0
 public function import($name)
 {
     // echo $name;
     // exit;
     $file = '../laravel/app/storage/csv/' . $name . '.csv';
     // echo $file;
     // exit;
     $allowedfilenames = array("serials", "installers");
     if (in_array($name, $allowedfilenames)) {
         //Parse into array
         $array = $this->csvtoarray($file);
         switch ($name) {
             case 'serials':
                 foreach ($array as $item) {
                     $serial = new Serial();
                     $find = $serial->where('serial', '=', $item['serial'])->first();
                     if (!$find) {
                         $serial->model_id = $item['model_id'];
                         $serial->serial = $item['serial'];
                         $serial->save();
                     }
                 }
                 break;
             case 'installers':
                 // echo "<pre>";
                 // print_r($array);
                 // echo "</pre>";
                 // exit;
                 $insertcount = 0;
                 $updatecount = 0;
                 foreach ($array as $item) {
                     $installer = new Installer();
                     $find = $installer->where('account_number', '=', $item['account_number'])->first();
                     if ($find->id) {
                         $installer = Installer::find($find->id);
                     }
                     $installer->account_number = trim($item['account_number']);
                     $installer->business_name = trim($item['business_name']);
                     $installer->address = trim($item['address']);
                     $installer->city = trim($item['city']);
                     $installer->state = trim($item['state']);
                     $installer->zip = trim($item['zip']);
                     $installer->phone = trim($item['phone']);
                     if ($installer->save()) {
                         if ($find->id) {
                             $updatecount++;
                         } else {
                             $insertcount++;
                         }
                     } else {
                         echo "Whoops";
                         exit;
                     }
                 }
                 echo "Updated: " . $updatecount . "<br />";
                 echo "Inserted: " . $insertcount . "<br />";
                 break;
         }
     }
     // echo "<pre>";
     // print_r($array);
     // echo "</pre>";
 }
Пример #18
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/config.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/database.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/serial.php';
/** LOAD SERIAL CLASS */
$serial = new Serial();
$serial->deviceSet(PORT_NAME);
$serial->confBaudRate(BOUD_RATE);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->deviceOpen();
$_command = 'M114';
$serial->sendMessage($_command . "\r\n");
$response = $serial->readPort();
$serial->serialflush();
$serial->deviceClose();
$position = str_replace('ok', '', $response);
$p = explode(' ', $position);
$pos['planner']['x'] = str_replace('X:', '', $p[0]);
$pos['planner']['y'] = str_replace('Y:', '', $p[1]);
$pos['planner']['z'] = str_replace('Z:', '', $p[2]);
$pos['planner']['e'] = str_replace('E:', '', $p[3]);
$pos['stepper']['x'] = $p[6];
$pos['stepper']['y'] = str_replace('Y:', '', $p[7]);
$pos['stepper']['z'] = str_replace('Z:', '', $p[8]);
$_response_items['x'] = $pos['planner']['x'];
$_response_items['y'] = $pos['planner']['y'];
$_response_items['z'] = $pos['planner']['z'];
header('Content-Type: application/json');
Пример #19
0
 public function findModel()
 {
     if (Request::ajax()) {
         $data = Input::all();
         $serial = $data['serial'];
         $findserial = Serial::where('serial', '=', $serial)->first();
         if (is_null($findserial)) {
             //Not Found
             $data = array('serial' => $serial, 'model' => '');
         } else {
             $data = array('serial' => $findserial->serial, 'model' => $findserial->model_id);
         }
         echo json_encode($data);
     }
 }