<?php 
namespace App\Models;

use App\Models\BaseModel;

class ComSettingsModel extends BaseModel
{
    protected $table      = 'tbl_com_settings';
    protected $primaryKey = 'com_setting_id';

    protected $returnType     = 'array';
    protected $useSoftDeletes = false;

    protected $allowedFields = [
        'baud_rate', 'data_bits', 'parity_bits', 'flow_control', 'stop_bits', 'mode', 'updated_by', 'updated_at'
    ];

    protected $useTimestamps = true;
    protected $createdField  = 'created_at';
    protected $updatedField  = 'updated_at';
   
    protected $validationRules    = [];
    protected $validationMessages = [];
    protected $skipValidation     = false;

    const DEFAULT_BAUD_RATE   = 9800;
    const DEFAULT_DATA_BITS   = 8;
    const DEFAULT_PARITY_BITS = 0;
    const DEFAULT_STOP_BITS   = 1;

    public static $s_arrintBaudRate = [
        2400   => 2400,
        4800   => 4800,
        9600   => 9600,
        19200  => 19200,
        38400  => 38400,
        57600  => 57600,
        115200 => 115200,
        230400 => 230400
    ];

    public static $s_arrintDataBits = [ 
        7 => 7,
        8 => 8 
    ];

    public static $s_arrstrParityBits = [ 
        0 => 'NONE',
        1 => 'ODD',
        2 => 'EVEN' 
    ];

    public static $s_arrstrStopBits = [ 
        1   => 1,
        1.5 => 1.5,
        2   => 2
    ];

    public static $s_arrstrModes = [ 
        1 => 'Slave-Modbus-RTU',
        2 => 'Slave-Modbus-ASCII',
        3 => 'Master-Modbus-RTU',
        4 => 'Master-Modbus -ASCII'
    ];
    
    
}