package oko.tm.oko_pro_classic;
// oko_u2/pro  key_alias, to get SHA1 type command in TERMINAL: keytool -list -v -keystore key_oko_u2_pro.jks

        import android.Manifest;
        import android.app.ActivityManager;
        import android.app.AlertDialog;
        import android.content.DialogInterface;
        import android.content.pm.PackageManager;
        import android.content.res.AssetFileDescriptor;
        import android.graphics.Color;
        import android.graphics.Typeface;
        import android.media.MediaPlayer;
        import android.net.Uri;
        import android.os.Build;
        import android.os.Handler;
        import android.os.Message;
        import android.os.StrictMode;
        import android.os.Vibrator;



        //import android.support.v7.app.ActionBarActivity;
        import android.preference.PreferenceManager;
        import android.provider.Settings;
        import android.support.v4.content.LocalBroadcastManager;
        import android.support.v7.app.AppCompatActivity;
        //import android.telephony.gsm.SmsManager;
        import android.telephony.SmsManager;
        import android.text.method.LinkMovementMethod;
        import android.util.Log;
        import android.view.Gravity;
        import android.view.Menu;
        import android.view.MenuItem;
        import android.app.Activity;
        import android.app.PendingIntent;
        import android.content.BroadcastReceiver;
        import android.content.Context;
        import android.content.Intent;
        import android.content.IntentFilter;
        import android.os.Bundle;

        import android.view.View;
        import android.view.Window;
        import android.view.WindowManager;
        import android.widget.AdapterView;
        import android.widget.ArrayAdapter;
        import android.widget.Button;
        import android.widget.CheckBox;
        import android.widget.ImageButton;
        import android.widget.ImageView;

        import android.widget.LinearLayout;
        import android.widget.RelativeLayout;
        import android.widget.Spinner;
        import android.widget.TextView;
        import android.widget.Toast;
        import android.content.SharedPreferences;
/*
        import com.google.android.gms.maps.CameraUpdateFactory;
        import com.google.android.gms.maps.GoogleMap;
        import com.google.android.gms.maps.MapView;
        import com.google.android.gms.maps.MapsInitializer;
        import com.google.android.gms.maps.OnMapReadyCallback;
        import com.google.android.gms.maps.SupportMapFragment;
        import com.google.android.gms.maps.model.BitmapDescriptorFactory;
        import com.google.android.gms.maps.model.CameraPosition;
        import com.google.android.gms.maps.model.LatLng;
        import com.google.android.gms.maps.model.Marker;
        import com.google.android.gms.maps.model.MarkerOptions;
*/
        import java.math.BigInteger;
        import java.text.Format;
        import java.text.SimpleDateFormat;
        import java.util.Date;
        import java.util.HashSet;
        import java.util.Locale;
        import java.util.Set;
        import java.util.Timer;
        import java.util.TimerTask;




public class MainActivity extends AppCompatActivity  {  //ActionBarActivity  AppCompatActivity  implements OnMapReadyCallback

    public static Context mContext;

    private static volatile boolean Service_Restart=false;
    public static volatile boolean Client_Thread_stop=false;
    public static volatile boolean Periodic_Thread_stop=false;

    public int COMMAND_POSITION = 0;

//----------------------------------------------------------

    //----- для создания служебного лога
    private static final String TAG = "myLogs";

    // это будет именем файла настроек,данных
    //public static String APP_PREFERENCES = ""; //"oko_pro_classic_settings";
    private String object_setting = "";

    public static final int MAX_EVENTS=200;
    public static final String EVENTS_ARRAY="events";
    // переменная для работы с файлом
    SharedPreferences mSettings;

    /*
    private MapView mapView;
    private GoogleMap gmap;
    Marker currentMarker;
    Marker marker1;
    private static final String MAP_VIEW_BUNDLE_KEY = "MapViewBundleKey";

    private final int[] MAP_TYPES = { GoogleMap.MAP_TYPE_SATELLITE,
            GoogleMap.MAP_TYPE_NORMAL,
            GoogleMap.MAP_TYPE_HYBRID,
            GoogleMap.MAP_TYPE_TERRAIN,
            GoogleMap.MAP_TYPE_NONE };
    private int curMapTypeIndex = 1;
    int temp=0;
    int temp1=1;
    double prev_lon_;
    double prev_lat_;
    double cur_lon_;
    double cur_lat_;
    boolean isPrev=false;
    */


    // настройки, подлежащие хранению
    public static final String APP_PREFERENCES_PHONE = "phone";
    public static final String APP_PREFERENCES_PASSWORD = "password";
    public static final String APP_PREFERENCES_IMEI = "imei";
    public static final String APP_PREFERENCES_SOUND = "sound";
    public static final String APP_PREFERENCES_VIBRO = "vibro";

    public static final String APP_PREFERENCES_QUERY = "query";
    public static final String APP_PREFERENCES_POWER = "power";
    public static final String APP_PREFERENCES_ARM = "arm";
    public static final String APP_PREFERENCES_GSM = "gsm";
    public static final String APP_PREFERENCES_CONNECTION = "connection";
    public static final String APP_PREFERENCES_PROTOCOL = "protocol";
    public static final String APP_PREFERENCES_SERVER = "server";
    public static final String APP_PREFERENCES_PORT = "port";
    public static final String APP_PREFERENCES_CHECK_BOX_QUERY = "checkBox_query";
    public static final String APP_PREFERENCES_ALIVE_TIMEOUT = "alive_timeout";

    public static final String APP_PREFERENCES_IMAGE_VIEW_POWER = "imageView_power";
    public static final String APP_PREFERENCES_IMAGE_VIEW_ARM = "imageView_arm";
    public static final String APP_PREFERENCES_IMAGE_VIEW_GSM = "imageView_GSM";
    public static final String APP_PREFERENCES_IMAGE_VIEW_INPUT = "imageView_input";


    // имена входов
    public static final String APP_PREFERENCES_NAME_TAMPER = "name_tamper";

    public static final String APP_PREFERENCES_NAME_INPUT1 = "name_input1";
    public static final String APP_PREFERENCES_NAME_INPUT2 = "name_input2";
    public static final String APP_PREFERENCES_NAME_INPUT3 = "name_input3";
    public static final String APP_PREFERENCES_NAME_INPUT4 = "name_input4";
    public static final String APP_PREFERENCES_NAME_INPUT5 = "name_input5";
    public static final String APP_PREFERENCES_NAME_INPUT6 = "name_input6";
    public static final String APP_PREFERENCES_NAME_INPUT7 = "name_input7";
    public static final String APP_PREFERENCES_NAME_INPUT8 = "name_input8";

    public static final String APP_PREFERENCES_NAME_INPUT1_EXT0 = "name_input1_ext0";
    public static final String APP_PREFERENCES_NAME_INPUT2_EXT0 = "name_input2_ext0";
    public static final String APP_PREFERENCES_NAME_INPUT3_EXT0 = "name_input3_ext0";
    public static final String APP_PREFERENCES_NAME_INPUT4_EXT0 = "name_input4_ext0";
    public static final String APP_PREFERENCES_NAME_INPUT5_EXT0 = "name_input5_ext0";
    public static final String APP_PREFERENCES_NAME_INPUT6_EXT0 = "name_input6_ext0";
    public static final String APP_PREFERENCES_NAME_INPUT7_EXT0 = "name_input7_ext0";
    public static final String APP_PREFERENCES_NAME_INPUT8_EXT0 = "name_input8_ext0";

    public static final String APP_PREFERENCES_NAME_INPUT1_EXT1 = "name_input1_ext1";
    public static final String APP_PREFERENCES_NAME_INPUT2_EXT1 = "name_input2_ext1";
    public static final String APP_PREFERENCES_NAME_INPUT3_EXT1 = "name_input3_ext1";
    public static final String APP_PREFERENCES_NAME_INPUT4_EXT1 = "name_input4_ext1";
    public static final String APP_PREFERENCES_NAME_INPUT5_EXT1 = "name_input5_ext1";
    public static final String APP_PREFERENCES_NAME_INPUT6_EXT1 = "name_input6_ext1";
    public static final String APP_PREFERENCES_NAME_INPUT7_EXT1 = "name_input7_ext1";
    public static final String APP_PREFERENCES_NAME_INPUT8_EXT1 = "name_input8_ext1";



    public static final String APP_PREFERENCES_NAME_INPUT1_EXT2 = "name_input1_ext2";
    public static final String APP_PREFERENCES_NAME_INPUT2_EXT2 = "name_input2_ext2";
    public static final String APP_PREFERENCES_NAME_INPUT3_EXT2 = "name_input3_ext2";
    public static final String APP_PREFERENCES_NAME_INPUT4_EXT2 = "name_input4_ext2";
    public static final String APP_PREFERENCES_NAME_INPUT5_EXT2 = "name_input5_ext2";
    public static final String APP_PREFERENCES_NAME_INPUT6_EXT2 = "name_input6_ext2";
    public static final String APP_PREFERENCES_NAME_INPUT7_EXT2 = "name_input7_ext2";
    public static final String APP_PREFERENCES_NAME_INPUT8_EXT2 = "name_input8_ext2";

    public static final String APP_PREFERENCES_NAME_INPUT1_EXT3 = "name_input1_ext3";
    public static final String APP_PREFERENCES_NAME_INPUT2_EXT3 = "name_input2_ext3";
    public static final String APP_PREFERENCES_NAME_INPUT3_EXT3 = "name_input3_ext3";
    public static final String APP_PREFERENCES_NAME_INPUT4_EXT3 = "name_input4_ext3";
    public static final String APP_PREFERENCES_NAME_INPUT5_EXT3 = "name_input5_ext3";
    public static final String APP_PREFERENCES_NAME_INPUT6_EXT3 = "name_input6_ext3";
    public static final String APP_PREFERENCES_NAME_INPUT7_EXT3 = "name_input7_ext3";
    public static final String APP_PREFERENCES_NAME_INPUT8_EXT3 = "name_input8_ext3";

    public static final String APP_PREFERENCES_NAME_INPUT1_EXT4 = "name_input1_ext4";
    public static final String APP_PREFERENCES_NAME_INPUT2_EXT4 = "name_input2_ext4";
    public static final String APP_PREFERENCES_NAME_INPUT3_EXT4 = "name_input3_ext4";
    public static final String APP_PREFERENCES_NAME_INPUT4_EXT4 = "name_input4_ext4";
    public static final String APP_PREFERENCES_NAME_INPUT5_EXT4 = "name_input5_ext4";
    public static final String APP_PREFERENCES_NAME_INPUT6_EXT4 = "name_input6_ext4";
    public static final String APP_PREFERENCES_NAME_INPUT7_EXT4 = "name_input7_ext4";
    public static final String APP_PREFERENCES_NAME_INPUT8_EXT4 = "name_input8_ext4";

    //отображение
    public static final String APP_PREFERENCES_VIEW_TAMPER = "view_tamper";

    public static final String APP_PREFERENCES_VIEW_I1 = "view_i1";
    public static final String APP_PREFERENCES_VIEW_I2 = "view_i2";
    public static final String APP_PREFERENCES_VIEW_I3 = "view_i3";
    public static final String APP_PREFERENCES_VIEW_I4 = "view_i4";
    public static final String APP_PREFERENCES_VIEW_I5 = "view_i5";
    public static final String APP_PREFERENCES_VIEW_I6 = "view_i6";
    public static final String APP_PREFERENCES_VIEW_I7 = "view_i7";
    public static final String APP_PREFERENCES_VIEW_I8 = "view_i8";

    public static final String APP_PREFERENCES_VIEW_I1_EXT0 = "view_i1_ext0";
    public static final String APP_PREFERENCES_VIEW_I2_EXT0 = "view_i2_ext0";
    public static final String APP_PREFERENCES_VIEW_I3_EXT0 = "view_i3_ext0";
    public static final String APP_PREFERENCES_VIEW_I4_EXT0 = "view_i4_ext0";
    public static final String APP_PREFERENCES_VIEW_I5_EXT0 = "view_i5_ext0";
    public static final String APP_PREFERENCES_VIEW_I6_EXT0 = "view_i6_ext0";
    public static final String APP_PREFERENCES_VIEW_I7_EXT0 = "view_i7_ext0";
    public static final String APP_PREFERENCES_VIEW_I8_EXT0 = "view_i8_ext0";

    public static final String APP_PREFERENCES_VIEW_I1_EXT1 = "view_i1_ext1";
    public static final String APP_PREFERENCES_VIEW_I2_EXT1 = "view_i2_ext1";
    public static final String APP_PREFERENCES_VIEW_I3_EXT1 = "view_i3_ext1";
    public static final String APP_PREFERENCES_VIEW_I4_EXT1 = "view_i4_ext1";
    public static final String APP_PREFERENCES_VIEW_I5_EXT1 = "view_i5_ext1";
    public static final String APP_PREFERENCES_VIEW_I6_EXT1 = "view_i6_ext1";
    public static final String APP_PREFERENCES_VIEW_I7_EXT1 = "view_i7_ext1";
    public static final String APP_PREFERENCES_VIEW_I8_EXT1 = "view_i8_ext1";

    public static final String APP_PREFERENCES_VIEW_I1_EXT2 = "view_i1_ext2";
    public static final String APP_PREFERENCES_VIEW_I2_EXT2 = "view_i2_ext2";
    public static final String APP_PREFERENCES_VIEW_I3_EXT2 = "view_i3_ext2";
    public static final String APP_PREFERENCES_VIEW_I4_EXT2 = "view_i4_ext2";
    public static final String APP_PREFERENCES_VIEW_I5_EXT2 = "view_i5_ext2";
    public static final String APP_PREFERENCES_VIEW_I6_EXT2 = "view_i6_ext2";
    public static final String APP_PREFERENCES_VIEW_I7_EXT2 = "view_i7_ext2";
    public static final String APP_PREFERENCES_VIEW_I8_EXT2 = "view_i8_ext2";

    public static final String APP_PREFERENCES_VIEW_I1_EXT3 = "view_i1_ext3";
    public static final String APP_PREFERENCES_VIEW_I2_EXT3 = "view_i2_ext3";
    public static final String APP_PREFERENCES_VIEW_I3_EXT3 = "view_i3_ext3";
    public static final String APP_PREFERENCES_VIEW_I4_EXT3 = "view_i4_ext3";
    public static final String APP_PREFERENCES_VIEW_I5_EXT3 = "view_i5_ext3";
    public static final String APP_PREFERENCES_VIEW_I6_EXT3 = "view_i6_ext3";
    public static final String APP_PREFERENCES_VIEW_I7_EXT3 = "view_i7_ext3";
    public static final String APP_PREFERENCES_VIEW_I8_EXT3 = "view_i8_ext3";

    public static final String APP_PREFERENCES_VIEW_I1_EXT4 = "view_i1_ext4";
    public static final String APP_PREFERENCES_VIEW_I2_EXT4 = "view_i2_ext4";
    public static final String APP_PREFERENCES_VIEW_I3_EXT4 = "view_i3_ext4";
    public static final String APP_PREFERENCES_VIEW_I4_EXT4 = "view_i4_ext4";
    public static final String APP_PREFERENCES_VIEW_I5_EXT4 = "view_i5_ext4";
    public static final String APP_PREFERENCES_VIEW_I6_EXT4 = "view_i6_ext4";
    public static final String APP_PREFERENCES_VIEW_I7_EXT4 = "view_i7_ext4";
    public static final String APP_PREFERENCES_VIEW_I8_EXT4 = "view_i8_ext4";



    //состояние входов, выходов
    public static final String APP_PREFERENCES_TAMPER = "tamper";

    public static final String APP_PREFERENCES_INPUT1 = "input1";
    public static final String APP_PREFERENCES_INPUT2 = "input2";
    public static final String APP_PREFERENCES_INPUT3 = "input3";
    public static final String APP_PREFERENCES_INPUT4 = "input4";
    public static final String APP_PREFERENCES_INPUT5 = "input5";
    public static final String APP_PREFERENCES_INPUT6 = "input6";
    public static final String APP_PREFERENCES_INPUT7 = "input7";
    public static final String APP_PREFERENCES_INPUT8 = "input8";

    public static final String APP_PREFERENCES_INPUT1_EXT0 = "input1_ext0";
    public static final String APP_PREFERENCES_INPUT2_EXT0 = "input2_ext0";
    public static final String APP_PREFERENCES_INPUT3_EXT0 = "input3_ext0";
    public static final String APP_PREFERENCES_INPUT4_EXT0 = "input4_ext0";
    public static final String APP_PREFERENCES_INPUT5_EXT0 = "input5_ext0";
    public static final String APP_PREFERENCES_INPUT6_EXT0 = "input6_ext0";
    public static final String APP_PREFERENCES_INPUT7_EXT0 = "input7_ext0";
    public static final String APP_PREFERENCES_INPUT8_EXT0 = "input8_ext0";

    public static final String APP_PREFERENCES_INPUT1_EXT1 = "input1_ext1";
    public static final String APP_PREFERENCES_INPUT2_EXT1 = "input2_ext1";
    public static final String APP_PREFERENCES_INPUT3_EXT1 = "input3_ext1";
    public static final String APP_PREFERENCES_INPUT4_EXT1 = "input4_ext1";
    public static final String APP_PREFERENCES_INPUT5_EXT1 = "input5_ext1";
    public static final String APP_PREFERENCES_INPUT6_EXT1 = "input6_ext1";
    public static final String APP_PREFERENCES_INPUT7_EXT1 = "input7_ext1";
    public static final String APP_PREFERENCES_INPUT8_EXT1 = "input8_ext1";

    public static final String APP_PREFERENCES_INPUT1_EXT2 = "input1_ext2";
    public static final String APP_PREFERENCES_INPUT2_EXT2 = "input2_ext2";
    public static final String APP_PREFERENCES_INPUT3_EXT2 = "input3_ext2";
    public static final String APP_PREFERENCES_INPUT4_EXT2 = "input4_ext2";
    public static final String APP_PREFERENCES_INPUT5_EXT2 = "input5_ext2";
    public static final String APP_PREFERENCES_INPUT6_EXT2 = "input6_ext2";
    public static final String APP_PREFERENCES_INPUT7_EXT2 = "input7_ext2";
    public static final String APP_PREFERENCES_INPUT8_EXT2 = "input8_ext2";

    public static final String APP_PREFERENCES_INPUT1_EXT3 = "input1_ext3";
    public static final String APP_PREFERENCES_INPUT2_EXT3 = "input2_ext3";
    public static final String APP_PREFERENCES_INPUT3_EXT3 = "input3_ext3";
    public static final String APP_PREFERENCES_INPUT4_EXT3 = "input4_ext3";
    public static final String APP_PREFERENCES_INPUT5_EXT3 = "input5_ext3";
    public static final String APP_PREFERENCES_INPUT6_EXT3 = "input6_ext3";
    public static final String APP_PREFERENCES_INPUT7_EXT3 = "input7_ext3";
    public static final String APP_PREFERENCES_INPUT8_EXT3 = "input8_ext3";

    public static final String APP_PREFERENCES_INPUT1_EXT4 = "input1_ext4";
    public static final String APP_PREFERENCES_INPUT2_EXT4 = "input2_ext4";
    public static final String APP_PREFERENCES_INPUT3_EXT4 = "input3_ext4";
    public static final String APP_PREFERENCES_INPUT4_EXT4 = "input4_ext4";
    public static final String APP_PREFERENCES_INPUT5_EXT4 = "input5_ext4";
    public static final String APP_PREFERENCES_INPUT6_EXT4 = "input6_ext4";
    public static final String APP_PREFERENCES_INPUT7_EXT4 = "input7_ext4";
    public static final String APP_PREFERENCES_INPUT8_EXT4 = "input8_ext4";


    // имена входов, выходов

    public static final String APP_PREFERENCES_NAME_OUTPUT1 = "name_output1";
    public static final String APP_PREFERENCES_NAME_OUTPUT2 = "name_output2";
    public static final String APP_PREFERENCES_NAME_OUTPUT3 = "name_output3";
    public static final String APP_PREFERENCES_NAME_OUTPUT4 = "name_output4";
    public static final String APP_PREFERENCES_NAME_OUTPUT5 = "name_output5";
    public static final String APP_PREFERENCES_NAME_OUTPUT6 = "name_output6";
    public static final String APP_PREFERENCES_NAME_OUTPUT7 = "name_output7";
    public static final String APP_PREFERENCES_NAME_OUTPUT8 = "name_output8";

    public static final String APP_PREFERENCES_NAME_OUTPUT1_EXT0 = "name_output1_ext0";
    public static final String APP_PREFERENCES_NAME_OUTPUT2_EXT0 = "name_output2_ext0";
    public static final String APP_PREFERENCES_NAME_OUTPUT3_EXT0 = "name_output3_ext0";
    public static final String APP_PREFERENCES_NAME_OUTPUT4_EXT0 = "name_output4_ext0";
    public static final String APP_PREFERENCES_NAME_OUTPUT5_EXT0 = "name_output5_ext0";
    public static final String APP_PREFERENCES_NAME_OUTPUT6_EXT0 = "name_output6_ext0";
    public static final String APP_PREFERENCES_NAME_OUTPUT7_EXT0 = "name_output7_ext0";
    public static final String APP_PREFERENCES_NAME_OUTPUT8_EXT0 = "name_output8_ext0";

    public static final String APP_PREFERENCES_NAME_OUTPUT1_EXT1 = "name_output1_ext1";
    public static final String APP_PREFERENCES_NAME_OUTPUT2_EXT1 = "name_output2_ext1";
    public static final String APP_PREFERENCES_NAME_OUTPUT3_EXT1 = "name_output3_ext1";
    public static final String APP_PREFERENCES_NAME_OUTPUT4_EXT1 = "name_output4_ext1";
    public static final String APP_PREFERENCES_NAME_OUTPUT5_EXT1 = "name_output5_ext1";
    public static final String APP_PREFERENCES_NAME_OUTPUT6_EXT1 = "name_output6_ext1";
    public static final String APP_PREFERENCES_NAME_OUTPUT7_EXT1 = "name_output7_ext1";
    public static final String APP_PREFERENCES_NAME_OUTPUT8_EXT1 = "name_output8_ext1";

    public static final String APP_PREFERENCES_NAME_OUTPUT1_EXT2 = "name_output1_ext2";
    public static final String APP_PREFERENCES_NAME_OUTPUT2_EXT2 = "name_output2_ext2";
    public static final String APP_PREFERENCES_NAME_OUTPUT3_EXT2 = "name_output3_ext2";
    public static final String APP_PREFERENCES_NAME_OUTPUT4_EXT2 = "name_output4_ext2";
    public static final String APP_PREFERENCES_NAME_OUTPUT5_EXT2 = "name_output5_ext2";
    public static final String APP_PREFERENCES_NAME_OUTPUT6_EXT2 = "name_output6_ext2";
    public static final String APP_PREFERENCES_NAME_OUTPUT7_EXT2 = "name_output7_ext2";
    public static final String APP_PREFERENCES_NAME_OUTPUT8_EXT2 = "name_output8_ext2";

    public static final String APP_PREFERENCES_NAME_OUTPUT1_EXT3 = "name_output1_ext3";
    public static final String APP_PREFERENCES_NAME_OUTPUT2_EXT3 = "name_output2_ext3";
    public static final String APP_PREFERENCES_NAME_OUTPUT3_EXT3 = "name_output3_ext3";
    public static final String APP_PREFERENCES_NAME_OUTPUT4_EXT3 = "name_output4_ext3";
    public static final String APP_PREFERENCES_NAME_OUTPUT5_EXT3 = "name_output5_ext3";
    public static final String APP_PREFERENCES_NAME_OUTPUT6_EXT3 = "name_output6_ext3";
    public static final String APP_PREFERENCES_NAME_OUTPUT7_EXT3 = "name_output7_ext3";
    public static final String APP_PREFERENCES_NAME_OUTPUT8_EXT3 = "name_output8_ext3";

    public static final String APP_PREFERENCES_NAME_OUTPUT1_EXT4 = "name_output1_ext4";
    public static final String APP_PREFERENCES_NAME_OUTPUT2_EXT4 = "name_output2_ext4";
    public static final String APP_PREFERENCES_NAME_OUTPUT3_EXT4 = "name_output3_ext4";
    public static final String APP_PREFERENCES_NAME_OUTPUT4_EXT4 = "name_output4_ext4";
    public static final String APP_PREFERENCES_NAME_OUTPUT5_EXT4 = "name_output5_ext4";
    public static final String APP_PREFERENCES_NAME_OUTPUT6_EXT4 = "name_output6_ext4";
    public static final String APP_PREFERENCES_NAME_OUTPUT7_EXT4 = "name_output7_ext4";
    public static final String APP_PREFERENCES_NAME_OUTPUT8_EXT4 = "name_output8_ext4";

    public static final String APP_PREFERENCES_NAME_SOCKET1_BLK1 = "name_socket1_blk1";
    public static final String APP_PREFERENCES_NAME_SOCKET2_BLK1 = "name_socket2_blk1";
    public static final String APP_PREFERENCES_NAME_SOCKET3_BLK1 = "name_socket3_blk1";
    public static final String APP_PREFERENCES_NAME_SOCKET4_BLK1 = "name_socket4_blk1";
    public static final String APP_PREFERENCES_NAME_SOCKET5_BLK1 = "name_socket5_blk1";
    public static final String APP_PREFERENCES_NAME_SOCKET6_BLK1 = "name_socket6_blk1";
    public static final String APP_PREFERENCES_NAME_SOCKET7_BLK1 = "name_socket7_blk1";
    public static final String APP_PREFERENCES_NAME_SOCKET8_BLK1 = "name_socket8_blk1";

    public static final String APP_PREFERENCES_NAME_SOCKET1_BLK2 = "name_socket1_blk2";
    public static final String APP_PREFERENCES_NAME_SOCKET2_BLK2 = "name_socket2_blk2";
    public static final String APP_PREFERENCES_NAME_SOCKET3_BLK2 = "name_socket3_blk2";
    public static final String APP_PREFERENCES_NAME_SOCKET4_BLK2 = "name_socket4_blk2";
    public static final String APP_PREFERENCES_NAME_SOCKET5_BLK2 = "name_socket5_blk2";
    public static final String APP_PREFERENCES_NAME_SOCKET6_BLK2 = "name_socket6_blk2";
    public static final String APP_PREFERENCES_NAME_SOCKET7_BLK2 = "name_socket7_blk2";
    public static final String APP_PREFERENCES_NAME_SOCKET8_BLK2 = "name_socket8_blk2";

    public static final String APP_PREFERENCES_NAME_SOCKET1_BLK3 = "name_socket1_blk3";
    public static final String APP_PREFERENCES_NAME_SOCKET2_BLK3 = "name_socket2_blk3";
    public static final String APP_PREFERENCES_NAME_SOCKET3_BLK3 = "name_socket3_blk3";
    public static final String APP_PREFERENCES_NAME_SOCKET4_BLK3 = "name_socket4_blk3";
    public static final String APP_PREFERENCES_NAME_SOCKET5_BLK3 = "name_socket5_blk3";
    public static final String APP_PREFERENCES_NAME_SOCKET6_BLK3 = "name_socket6_blk3";
    public static final String APP_PREFERENCES_NAME_SOCKET7_BLK3 = "name_socket7_blk3";
    public static final String APP_PREFERENCES_NAME_SOCKET8_BLK3 = "name_socket8_blk3";

    public static final String APP_PREFERENCES_NAME_SOCKET1_BLK4 = "name_socket1_blk4";
    public static final String APP_PREFERENCES_NAME_SOCKET2_BLK4 = "name_socket2_blk4";
    public static final String APP_PREFERENCES_NAME_SOCKET3_BLK4 = "name_socket3_blk4";
    public static final String APP_PREFERENCES_NAME_SOCKET4_BLK4 = "name_socket4_blk4";
    public static final String APP_PREFERENCES_NAME_SOCKET5_BLK4 = "name_socket5_blk4";
    public static final String APP_PREFERENCES_NAME_SOCKET6_BLK4 = "name_socket6_blk4";
    public static final String APP_PREFERENCES_NAME_SOCKET7_BLK4 = "name_socket7_blk4";
    public static final String APP_PREFERENCES_NAME_SOCKET8_BLK4 = "name_socket8_blk4";



    public static final String APP_PREFERENCES_VIEW_O1 = "view_o1";
    public static final String APP_PREFERENCES_VIEW_O2 = "view_o2";
    public static final String APP_PREFERENCES_VIEW_O3 = "view_o3";
    public static final String APP_PREFERENCES_VIEW_O4 = "view_o4";
    public static final String APP_PREFERENCES_VIEW_O5 = "view_o5";
    public static final String APP_PREFERENCES_VIEW_O6 = "view_o6";
    public static final String APP_PREFERENCES_VIEW_O7 = "view_o7";
    public static final String APP_PREFERENCES_VIEW_O8 = "view_o8";

    public static final String APP_PREFERENCES_VIEW_O1_EXT0 = "view_o1_ext0";
    public static final String APP_PREFERENCES_VIEW_O2_EXT0 = "view_o2_ext0";
    public static final String APP_PREFERENCES_VIEW_O3_EXT0 = "view_o3_ext0";
    public static final String APP_PREFERENCES_VIEW_O4_EXT0 = "view_o4_ext0";
    public static final String APP_PREFERENCES_VIEW_O5_EXT0 = "view_o5_ext0";
    public static final String APP_PREFERENCES_VIEW_O6_EXT0 = "view_o6_ext0";
    public static final String APP_PREFERENCES_VIEW_O7_EXT0 = "view_o7_ext0";
    public static final String APP_PREFERENCES_VIEW_O8_EXT0 = "view_o8_ext0";

    public static final String APP_PREFERENCES_VIEW_O1_EXT1 = "view_o1_ext1";
    public static final String APP_PREFERENCES_VIEW_O2_EXT1 = "view_o2_ext1";
    public static final String APP_PREFERENCES_VIEW_O3_EXT1 = "view_o3_ext1";
    public static final String APP_PREFERENCES_VIEW_O4_EXT1 = "view_o4_ext1";
    public static final String APP_PREFERENCES_VIEW_O5_EXT1 = "view_o5_ext1";
    public static final String APP_PREFERENCES_VIEW_O6_EXT1 = "view_o6_ext1";
    public static final String APP_PREFERENCES_VIEW_O7_EXT1 = "view_o7_ext1";
    public static final String APP_PREFERENCES_VIEW_O8_EXT1 = "view_o8_ext1";

    public static final String APP_PREFERENCES_VIEW_O1_EXT2 = "view_o1_ext2";
    public static final String APP_PREFERENCES_VIEW_O2_EXT2 = "view_o2_ext2";
    public static final String APP_PREFERENCES_VIEW_O3_EXT2 = "view_o3_ext2";
    public static final String APP_PREFERENCES_VIEW_O4_EXT2 = "view_o4_ext2";
    public static final String APP_PREFERENCES_VIEW_O5_EXT2 = "view_o5_ext2";
    public static final String APP_PREFERENCES_VIEW_O6_EXT2 = "view_o6_ext2";
    public static final String APP_PREFERENCES_VIEW_O7_EXT2 = "view_o7_ext2";
    public static final String APP_PREFERENCES_VIEW_O8_EXT2 = "view_o8_ext2";

    public static final String APP_PREFERENCES_VIEW_O1_EXT3 = "view_o1_ext3";
    public static final String APP_PREFERENCES_VIEW_O2_EXT3 = "view_o2_ext3";
    public static final String APP_PREFERENCES_VIEW_O3_EXT3 = "view_o3_ext3";
    public static final String APP_PREFERENCES_VIEW_O4_EXT3 = "view_o4_ext3";
    public static final String APP_PREFERENCES_VIEW_O5_EXT3 = "view_o5_ext3";
    public static final String APP_PREFERENCES_VIEW_O6_EXT3 = "view_o6_ext3";
    public static final String APP_PREFERENCES_VIEW_O7_EXT3 = "view_o7_ext3";
    public static final String APP_PREFERENCES_VIEW_O8_EXT3 = "view_o8_ext3";


    public static final String APP_PREFERENCES_VIEW_O1_EXT4 = "view_o1_ext4";
    public static final String APP_PREFERENCES_VIEW_O2_EXT4 = "view_o2_ext4";
    public static final String APP_PREFERENCES_VIEW_O3_EXT4 = "view_o3_ext4";
    public static final String APP_PREFERENCES_VIEW_O4_EXT4 = "view_o4_ext4";
    public static final String APP_PREFERENCES_VIEW_O5_EXT4 = "view_o5_ext4";
    public static final String APP_PREFERENCES_VIEW_O6_EXT4 = "view_o6_ext4";
    public static final String APP_PREFERENCES_VIEW_O7_EXT4 = "view_o7_ext4";
    public static final String APP_PREFERENCES_VIEW_O8_EXT4 = "view_o8_ext4";

    public static final String APP_PREFERENCES_VIEW_SOCKET1_BLK1 = "view_socket1_blk1";
    public static final String APP_PREFERENCES_VIEW_SOCKET2_BLK1 = "view_socket2_blk1";
    public static final String APP_PREFERENCES_VIEW_SOCKET3_BLK1 = "view_socket3_blk1";
    public static final String APP_PREFERENCES_VIEW_SOCKET4_BLK1 = "view_socket4_blk1";
    public static final String APP_PREFERENCES_VIEW_SOCKET5_BLK1 = "view_socket5_blk1";
    public static final String APP_PREFERENCES_VIEW_SOCKET6_BLK1 = "view_socket6_blk1";
    public static final String APP_PREFERENCES_VIEW_SOCKET7_BLK1 = "view_socket7_blk1";
    public static final String APP_PREFERENCES_VIEW_SOCKET8_BLK1 = "view_socket8_blk1";

    public static final String APP_PREFERENCES_VIEW_SOCKET1_BLK2 = "view_socket1_blk2";
    public static final String APP_PREFERENCES_VIEW_SOCKET2_BLK2 = "view_socket2_blk2";
    public static final String APP_PREFERENCES_VIEW_SOCKET3_BLK2 = "view_socket3_blk2";
    public static final String APP_PREFERENCES_VIEW_SOCKET4_BLK2 = "view_socket4_blk2";
    public static final String APP_PREFERENCES_VIEW_SOCKET5_BLK2 = "view_socket5_blk2";
    public static final String APP_PREFERENCES_VIEW_SOCKET6_BLK2 = "view_socket6_blk2";
    public static final String APP_PREFERENCES_VIEW_SOCKET7_BLK2 = "view_socket7_blk2";
    public static final String APP_PREFERENCES_VIEW_SOCKET8_BLK2 = "view_socket8_blk2";

    public static final String APP_PREFERENCES_VIEW_SOCKET1_BLK3 = "view_socket1_blk3";
    public static final String APP_PREFERENCES_VIEW_SOCKET2_BLK3 = "view_socket2_blk3";
    public static final String APP_PREFERENCES_VIEW_SOCKET3_BLK3 = "view_socket3_blk3";
    public static final String APP_PREFERENCES_VIEW_SOCKET4_BLK3 = "view_socket4_blk3";
    public static final String APP_PREFERENCES_VIEW_SOCKET5_BLK3 = "view_socket5_blk3";
    public static final String APP_PREFERENCES_VIEW_SOCKET6_BLK3 = "view_socket6_blk3";
    public static final String APP_PREFERENCES_VIEW_SOCKET7_BLK3 = "view_socket7_blk3";
    public static final String APP_PREFERENCES_VIEW_SOCKET8_BLK3 = "view_socket8_blk3";

    public static final String APP_PREFERENCES_VIEW_SOCKET1_BLK4 = "view_socket1_blk4";
    public static final String APP_PREFERENCES_VIEW_SOCKET2_BLK4 = "view_socket2_blk4";
    public static final String APP_PREFERENCES_VIEW_SOCKET3_BLK4 = "view_socket3_blk4";
    public static final String APP_PREFERENCES_VIEW_SOCKET4_BLK4 = "view_socket4_blk4";
    public static final String APP_PREFERENCES_VIEW_SOCKET5_BLK4 = "view_socket5_blk4";
    public static final String APP_PREFERENCES_VIEW_SOCKET6_BLK4 = "view_socket6_blk4";
    public static final String APP_PREFERENCES_VIEW_SOCKET7_BLK4 = "view_socket7_blk4";
    public static final String APP_PREFERENCES_VIEW_SOCKET8_BLK4 = "view_socket8_blk4";



    public static final String APP_PREFERENCES_OUTPUT1 = "output1";
    public static final String APP_PREFERENCES_OUTPUT2 = "output2";
    public static final String APP_PREFERENCES_OUTPUT3 = "output3";
    public static final String APP_PREFERENCES_OUTPUT4 = "output4";
    public static final String APP_PREFERENCES_OUTPUT5 = "output5";
    public static final String APP_PREFERENCES_OUTPUT6 = "output6";
    public static final String APP_PREFERENCES_OUTPUT7 = "output7";
    public static final String APP_PREFERENCES_OUTPUT8 = "output8";

    public static final String APP_PREFERENCES_OUTPUT1_EXT0 = "output1_ext0";
    public static final String APP_PREFERENCES_OUTPUT2_EXT0 = "output2_ext0";
    public static final String APP_PREFERENCES_OUTPUT3_EXT0 = "output3_ext0";
    public static final String APP_PREFERENCES_OUTPUT4_EXT0 = "output4_ext0";
    public static final String APP_PREFERENCES_OUTPUT5_EXT0 = "output5_ext0";
    public static final String APP_PREFERENCES_OUTPUT6_EXT0 = "output6_ext0";
    public static final String APP_PREFERENCES_OUTPUT7_EXT0 = "output7_ext0";
    public static final String APP_PREFERENCES_OUTPUT8_EXT0 = "output8_ext0";

    public static final String APP_PREFERENCES_OUTPUT1_EXT1 = "output1_ext1";
    public static final String APP_PREFERENCES_OUTPUT2_EXT1 = "output2_ext1";
    public static final String APP_PREFERENCES_OUTPUT3_EXT1 = "output3_ext1";
    public static final String APP_PREFERENCES_OUTPUT4_EXT1 = "output4_ext1";
    public static final String APP_PREFERENCES_OUTPUT5_EXT1 = "output5_ext1";
    public static final String APP_PREFERENCES_OUTPUT6_EXT1 = "output6_ext1";
    public static final String APP_PREFERENCES_OUTPUT7_EXT1 = "output7_ext1";
    public static final String APP_PREFERENCES_OUTPUT8_EXT1 = "output8_ext1";

    public static final String APP_PREFERENCES_OUTPUT1_EXT2 = "output1_ext2";
    public static final String APP_PREFERENCES_OUTPUT2_EXT2 = "output2_ext2";
    public static final String APP_PREFERENCES_OUTPUT3_EXT2 = "output3_ext2";
    public static final String APP_PREFERENCES_OUTPUT4_EXT2 = "output4_ext2";
    public static final String APP_PREFERENCES_OUTPUT5_EXT2 = "output5_ext2";
    public static final String APP_PREFERENCES_OUTPUT6_EXT2 = "output6_ext2";
    public static final String APP_PREFERENCES_OUTPUT7_EXT2 = "output7_ext2";
    public static final String APP_PREFERENCES_OUTPUT8_EXT2 = "output8_ext2";

    public static final String APP_PREFERENCES_OUTPUT1_EXT3 = "output1_ext3";
    public static final String APP_PREFERENCES_OUTPUT2_EXT3 = "output2_ext3";
    public static final String APP_PREFERENCES_OUTPUT3_EXT3 = "output3_ext3";
    public static final String APP_PREFERENCES_OUTPUT4_EXT3 = "output4_ext3";
    public static final String APP_PREFERENCES_OUTPUT5_EXT3 = "output5_ext3";
    public static final String APP_PREFERENCES_OUTPUT6_EXT3 = "output6_ext3";
    public static final String APP_PREFERENCES_OUTPUT7_EXT3 = "output7_ext3";
    public static final String APP_PREFERENCES_OUTPUT8_EXT3 = "output8_ext3";


    public static final String APP_PREFERENCES_OUTPUT1_EXT4 = "output1_ext4";
    public static final String APP_PREFERENCES_OUTPUT2_EXT4 = "output2_ext4";
    public static final String APP_PREFERENCES_OUTPUT3_EXT4 = "output3_ext4";
    public static final String APP_PREFERENCES_OUTPUT4_EXT4 = "output4_ext4";
    public static final String APP_PREFERENCES_OUTPUT5_EXT4 = "output5_ext4";
    public static final String APP_PREFERENCES_OUTPUT6_EXT4 = "output6_ext4";
    public static final String APP_PREFERENCES_OUTPUT7_EXT4 = "output7_ext4";
    public static final String APP_PREFERENCES_OUTPUT8_EXT4 = "output8_ext4";

    public static final String APP_PREFERENCES_SOCKET1_BLK1 = "socket1_blk1";
    public static final String APP_PREFERENCES_SOCKET2_BLK1 = "socket2_blk1";
    public static final String APP_PREFERENCES_SOCKET3_BLK1 = "socket3_blk1";
    public static final String APP_PREFERENCES_SOCKET4_BLK1 = "socket4_blk1";
    public static final String APP_PREFERENCES_SOCKET5_BLK1 = "socket5_blk1";
    public static final String APP_PREFERENCES_SOCKET6_BLK1 = "socket6_blk1";
    public static final String APP_PREFERENCES_SOCKET7_BLK1 = "socket7_blk1";
    public static final String APP_PREFERENCES_SOCKET8_BLK1 = "socket8_blk1";

    public static final String APP_PREFERENCES_SOCKET1_BLK2 = "socket1_blk2";
    public static final String APP_PREFERENCES_SOCKET2_BLK2 = "socket2_blk2";
    public static final String APP_PREFERENCES_SOCKET3_BLK2 = "socket3_blk2";
    public static final String APP_PREFERENCES_SOCKET4_BLK2 = "socket4_blk2";
    public static final String APP_PREFERENCES_SOCKET5_BLK2 = "socket5_blk2";
    public static final String APP_PREFERENCES_SOCKET6_BLK2 = "socket6_blk2";
    public static final String APP_PREFERENCES_SOCKET7_BLK2 = "socket7_blk2";
    public static final String APP_PREFERENCES_SOCKET8_BLK2 = "socket8_blk2";

    public static final String APP_PREFERENCES_SOCKET1_BLK3 = "socket1_blk3";
    public static final String APP_PREFERENCES_SOCKET2_BLK3 = "socket2_blk3";
    public static final String APP_PREFERENCES_SOCKET3_BLK3 = "socket3_blk3";
    public static final String APP_PREFERENCES_SOCKET4_BLK3 = "socket4_blk3";
    public static final String APP_PREFERENCES_SOCKET5_BLK3 = "socket5_blk3";
    public static final String APP_PREFERENCES_SOCKET6_BLK3 = "socket6_blk3";
    public static final String APP_PREFERENCES_SOCKET7_BLK3 = "socket7_blk3";
    public static final String APP_PREFERENCES_SOCKET8_BLK3 = "socket8_blk3";


    public static final String APP_PREFERENCES_SOCKET1_BLK4 = "socket1_blk4";
    public static final String APP_PREFERENCES_SOCKET2_BLK4 = "socket2_blk4";
    public static final String APP_PREFERENCES_SOCKET3_BLK4 = "socket3_blk4";
    public static final String APP_PREFERENCES_SOCKET4_BLK4 = "socket4_blk4";
    public static final String APP_PREFERENCES_SOCKET5_BLK4 = "socket5_blk4";
    public static final String APP_PREFERENCES_SOCKET6_BLK4 = "socket6_blk4";
    public static final String APP_PREFERENCES_SOCKET7_BLK4 = "socket7_blk4";
    public static final String APP_PREFERENCES_SOCKET8_BLK4 = "socket8_blk4";


    public static final String APP_PREFERENCES_VIEW_R1 = "view_r1";
    public static final String APP_PREFERENCES_VIEW_R2 = "view_r2";
    public static final String APP_PREFERENCES_VIEW_R3 = "view_r3";
    public static final String APP_PREFERENCES_VIEW_R4 = "view_r4";
    public static final String APP_PREFERENCES_VIEW_R5 = "view_r5";
    public static final String APP_PREFERENCES_VIEW_R6 = "view_r6";
    public static final String APP_PREFERENCES_VIEW_R7 = "view_r7";
    public static final String APP_PREFERENCES_VIEW_R8 = "view_r8";
    public static final String APP_PREFERENCES_VIEW_R9 = "view_r9";
    public static final String APP_PREFERENCES_VIEW_R10 = "view_r10";
    public static final String APP_PREFERENCES_VIEW_R11 = "view_r11";
    public static final String APP_PREFERENCES_VIEW_R12 = "view_r12";
    public static final String APP_PREFERENCES_VIEW_R13 = "view_r13";
    public static final String APP_PREFERENCES_VIEW_R14 = "view_r14";
    public static final String APP_PREFERENCES_VIEW_R15 = "view_r15";
    public static final String APP_PREFERENCES_VIEW_R16 = "view_r16";

    //имена беспроводных датчиков
    public static final String APP_PREFERENCES_NAME_RADIO1 = "name_radio1";
    public static final String APP_PREFERENCES_NAME_RADIO2 = "name_radio2";
    public static final String APP_PREFERENCES_NAME_RADIO3 = "name_radio3";
    public static final String APP_PREFERENCES_NAME_RADIO4 = "name_radio4";
    public static final String APP_PREFERENCES_NAME_RADIO5 = "name_radio5";
    public static final String APP_PREFERENCES_NAME_RADIO6 = "name_radio6";
    public static final String APP_PREFERENCES_NAME_RADIO7 = "name_radio7";
    public static final String APP_PREFERENCES_NAME_RADIO8 = "name_radio8";
    public static final String APP_PREFERENCES_NAME_RADIO9 = "name_radio9";
    public static final String APP_PREFERENCES_NAME_RADIO10 = "name_radio10";
    public static final String APP_PREFERENCES_NAME_RADIO11 = "name_radio11";
    public static final String APP_PREFERENCES_NAME_RADIO12 = "name_radio12";
    public static final String APP_PREFERENCES_NAME_RADIO13 = "name_radio13";
    public static final String APP_PREFERENCES_NAME_RADIO14 = "name_radio14";
    public static final String APP_PREFERENCES_NAME_RADIO15 = "name_radio15";
    public static final String APP_PREFERENCES_NAME_RADIO16 = "name_radio16";
    //state radio
    public static final String APP_PREFERENCES_RADIO1 = "radio1";
    public static final String APP_PREFERENCES_RADIO2 = "radio2";
    public static final String APP_PREFERENCES_RADIO3 = "radio3";
    public static final String APP_PREFERENCES_RADIO4 = "radio4";
    public static final String APP_PREFERENCES_RADIO5 = "radio5";
    public static final String APP_PREFERENCES_RADIO6 = "radio6";
    public static final String APP_PREFERENCES_RADIO7 = "radio7";
    public static final String APP_PREFERENCES_RADIO8 = "radio8";
    public static final String APP_PREFERENCES_RADIO9 = "radio9";
    public static final String APP_PREFERENCES_RADIO10 = "radio10";
    public static final String APP_PREFERENCES_RADIO11 = "radio11";
    public static final String APP_PREFERENCES_RADIO12 = "radio12";
    public static final String APP_PREFERENCES_RADIO13 = "radio13";
    public static final String APP_PREFERENCES_RADIO14 = "radio14";
    public static final String APP_PREFERENCES_RADIO15 = "radio15";
    public static final String APP_PREFERENCES_RADIO16 = "radio16";


    public static final String APP_PREFERENCES_VIEW_T1 = "view_t1";
    public static final String APP_PREFERENCES_VIEW_T2 = "view_t2";
    public static final String APP_PREFERENCES_VIEW_T3 = "view_t3";
    public static final String APP_PREFERENCES_VIEW_T4 = "view_t4";
    public static final String APP_PREFERENCES_VIEW_T5 = "view_t5";
    public static final String APP_PREFERENCES_VIEW_T6 = "view_t6";
    public static final String APP_PREFERENCES_VIEW_T7 = "view_t7";
    public static final String APP_PREFERENCES_VIEW_T8 = "view_t8";


    //имена проводных термодатчиков
    public static final String APP_PREFERENCES_NAME_TERMO1 = "name_termo1";
    public static final String APP_PREFERENCES_NAME_TERMO2 = "name_termo2";
    public static final String APP_PREFERENCES_NAME_TERMO3 = "name_termo3";
    public static final String APP_PREFERENCES_NAME_TERMO4 = "name_termo4";
    public static final String APP_PREFERENCES_NAME_TERMO5 = "name_termo5";
    public static final String APP_PREFERENCES_NAME_TERMO6 = "name_termo6";
    public static final String APP_PREFERENCES_NAME_TERMO7 = "name_termo7";
    public static final String APP_PREFERENCES_NAME_TERMO8 = "name_termo8";

    //state termo
    public static final String APP_PREFERENCES_TERMO1 = "termo1";
    public static final String APP_PREFERENCES_TERMO2 = "termo2";
    public static final String APP_PREFERENCES_TERMO3 = "termo3";
    public static final String APP_PREFERENCES_TERMO4 = "termo4";
    public static final String APP_PREFERENCES_TERMO5 = "termo5";
    public static final String APP_PREFERENCES_TERMO6 = "termo6";
    public static final String APP_PREFERENCES_TERMO7 = "termo7";
    public static final String APP_PREFERENCES_TERMO8 = "termo8";

    public static final String APP_PREFERENCES_CONTROLLER = "controller";

    public static final String APP_PREFERENCES_NAME_COMAND1 = "name_command1";
    public static final String APP_PREFERENCES_NAME_COMAND2 = "name_command2";
    public static final String APP_PREFERENCES_NAME_COMAND3 = "name_command3";
    public static final String APP_PREFERENCES_NAME_COMAND4 = "name_command4";
    public static final String APP_PREFERENCES_NAME_COMAND5 = "name_command5";
    public static final String APP_PREFERENCES_NAME_COMAND6 = "name_command6";
    public static final String APP_PREFERENCES_NAME_COMAND7 = "name_command7";
    public static final String APP_PREFERENCES_NAME_COMAND8 = "name_command8";

    public static final String APP_PREFERENCES_CODE_COMAND1 = "code_command1";
    public static final String APP_PREFERENCES_CODE_COMAND2 = "code_command2";
    public static final String APP_PREFERENCES_CODE_COMAND3 = "code_command3";
    public static final String APP_PREFERENCES_CODE_COMAND4 = "code_command4";
    public static final String APP_PREFERENCES_CODE_COMAND5 = "code_command5";
    public static final String APP_PREFERENCES_CODE_COMAND6 = "code_command6";
    public static final String APP_PREFERENCES_CODE_COMAND7 = "code_command7";
    public static final String APP_PREFERENCES_CODE_COMAND8 = "code_command8";



    // --- телефонный номер
    public String PHONE_NUMBER = "";
    public static String PASSWORD = "";
    //IMEI
    public static String IMEI = "";
    String cur_IMEI = "";
    String cur_Server = ClientThread.SERVER_INI;
    int  cur_Port = ClientThread.SERVERPORT;
    String protocol="1";

    public static int CONNECTION_POSITION=0;


    public static final String SMS_220V_ON = "220V ON";
    public String EST = "";
    public static final String SMS_220V_OFF = "220V OFF";
    public String NET = "";
    public static final String SMS_RAZRYAD_AKKUM = "RAZRYAD AKKUM";
    public String RAZRYAD_AKKUM ="";
    public static final String SMS_OUTPUTS = "OUTPUTS: ";
    public static final String SMS_EXT0_OUTPUTS = "ext0 OUTPUTS: ";
    public static final String SMS_EXT1_OUTPUTS = "ext1 OUTPUTS: ";
    public static final String SMS_EXT2_OUTPUTS = "ext2 OUTPUTS: ";
    public static final String SMS_EXT3_OUTPUTS = "ext3 OUTPUTS: ";
    public static final String SMS_EXT4_OUTPUTS = "ext4 OUTPUTS: ";

    public static final String SMS_BLK1_SOCKETS = "blk1 SOCKETS: ";
    public static final String SMS_BLK2_SOCKETS = "blk2 SOCKETS: ";
    public static final String SMS_BLK3_SOCKETS = "blk3 SOCKETS: ";
    public static final String SMS_BLK4_SOCKETS = "blk4 SOCKETS: ";

    public String OUTPUT_ON = "";
    public String OUTPUT_OFF = "";

    //for oko-s2 differens sms text
    public static final String SMS_ZONA_NORMA = "VXOD NORMA";
    public static final String SMS_ZONA_1_NORMA = "VXOD-1 NORMA";
    public static final String SMS_ZONA_2_NORMA = "VXOD-2 NORMA";
    public static final String SMS_ZONA_TREVOGA = "VXOD TREVOGA";
    public static final String SMS_ZONA_1_TREVOGA = "VXOD-1 TREVOGA";
    public static final String SMS_ZONA_2_TREVOGA = "VXOD-2 TREVOGA";
    public static final String SMS_RELE_ON = "RELE ON";
    public static final String SMS_RELE_1_ON = "RELE-1 ON";
    public static final String SMS_RELE_2_ON = "RELE-2 ON";
    public static final String SMS_RELE_OFF = "RELE OFF";
    public static final String SMS_RELE_1_OFF = "RELE-1 OFF";
    public static final String SMS_RELE_2_OFF = "RELE-2 OFF";



    public static final String SMS_ARM_ON = "OHRANA ON";
    public String VKL = "";
    public static final String SMS_ARM_OFF = "OHRANA OFF";
    public  String VYKL = "";
    public  String GROUP = "";

    public static final String SMS_TAMPER_NORMA = "TAMPER NORMA";

    public static final String SMS_ZONA1_NORMA = "z1 NORMA";
    public static final String SMS_ZONA2_NORMA = "z2 NORMA";
    public static final String SMS_ZONA3_NORMA = "z3 NORMA";
    public static final String SMS_ZONA4_NORMA = "z4 NORMA";
    public static final String SMS_ZONA5_NORMA = "z5 NORMA";
    public static final String SMS_ZONA6_NORMA = "z6 NORMA";
    public static final String SMS_ZONA7_NORMA = "z7 NORMA";
    public static final String SMS_ZONA8_NORMA = "z8 NORMA";

    public static final String SMS_EXT0_ZONA1_NORMA = "e0_z1 NORMA";
    public static final String SMS_EXT0_ZONA2_NORMA = "e0_z2 NORMA";
    public static final String SMS_EXT0_ZONA3_NORMA = "e0_z3 NORMA";
    public static final String SMS_EXT0_ZONA4_NORMA = "e0_z4 NORMA";
    public static final String SMS_EXT0_ZONA5_NORMA = "e0_z5 NORMA";
    public static final String SMS_EXT0_ZONA6_NORMA = "e0_z6 NORMA";
    public static final String SMS_EXT0_ZONA7_NORMA = "e0_z7 NORMA";
    public static final String SMS_EXT0_ZONA8_NORMA = "e0_z8 NORMA";

    public static final String SMS_EXT1_ZONA1_NORMA = "e1_z1 NORMA";
    public static final String SMS_EXT1_ZONA2_NORMA = "e1_z2 NORMA";
    public static final String SMS_EXT1_ZONA3_NORMA = "e1_z3 NORMA";
    public static final String SMS_EXT1_ZONA4_NORMA = "e1_z4 NORMA";
    public static final String SMS_EXT1_ZONA5_NORMA = "e1_z5 NORMA";
    public static final String SMS_EXT1_ZONA6_NORMA = "e1_z6 NORMA";
    public static final String SMS_EXT1_ZONA7_NORMA = "e1_z7 NORMA";
    public static final String SMS_EXT1_ZONA8_NORMA = "e1_z8 NORMA";

    public static final String SMS_EXT2_ZONA1_NORMA = "e2_z1 NORMA";
    public static final String SMS_EXT2_ZONA2_NORMA = "e2_z2 NORMA";
    public static final String SMS_EXT2_ZONA3_NORMA = "e2_z3 NORMA";
    public static final String SMS_EXT2_ZONA4_NORMA = "e2_z4 NORMA";
    public static final String SMS_EXT2_ZONA5_NORMA = "e2_z5 NORMA";
    public static final String SMS_EXT2_ZONA6_NORMA = "e2_z6 NORMA";
    public static final String SMS_EXT2_ZONA7_NORMA = "e2_z7 NORMA";
    public static final String SMS_EXT2_ZONA8_NORMA = "e2_z8 NORMA";

    public static final String SMS_EXT3_ZONA1_NORMA = "e3_z1 NORMA";
    public static final String SMS_EXT3_ZONA2_NORMA = "e3_z2 NORMA";
    public static final String SMS_EXT3_ZONA3_NORMA = "e3_z3 NORMA";
    public static final String SMS_EXT3_ZONA4_NORMA = "e3_z4 NORMA";
    public static final String SMS_EXT3_ZONA5_NORMA = "e3_z5 NORMA";
    public static final String SMS_EXT3_ZONA6_NORMA = "e3_z6 NORMA";
    public static final String SMS_EXT3_ZONA7_NORMA = "e3_z7 NORMA";
    public static final String SMS_EXT3_ZONA8_NORMA = "e3_z8 NORMA";

    public static final String SMS_EXT4_ZONA1_NORMA = "e4_z1 NORMA";
    public static final String SMS_EXT4_ZONA2_NORMA = "e4_z2 NORMA";
    public static final String SMS_EXT4_ZONA3_NORMA = "e4_z3 NORMA";
    public static final String SMS_EXT4_ZONA4_NORMA = "e4_z4 NORMA";
    public static final String SMS_EXT4_ZONA5_NORMA = "e4_z5 NORMA";
    public static final String SMS_EXT4_ZONA6_NORMA = "e4_z6 NORMA";
    public static final String SMS_EXT4_ZONA7_NORMA = "e4_z7 NORMA";
    public static final String SMS_EXT4_ZONA8_NORMA = "e4_z8 NORMA";

    public String NORMA = "";
    public static final String SMS_TAMPER_TREVOGA = "TAMPER TREVOGA";

    public static final String SMS_ZONA1_TREVOGA = "z1 TREVOGA";
    public static final String SMS_ZONA2_TREVOGA = "z2 TREVOGA";
    public static final String SMS_ZONA3_TREVOGA = "z3 TREVOGA";
    public static final String SMS_ZONA4_TREVOGA = "z4 TREVOGA";
    public static final String SMS_ZONA5_TREVOGA = "z5 TREVOGA";
    public static final String SMS_ZONA6_TREVOGA = "z6 TREVOGA";
    public static final String SMS_ZONA7_TREVOGA = "z7 TREVOGA";
    public static final String SMS_ZONA8_TREVOGA = "z8 TREVOGA";

    public static final String SMS_EXT0_ZONA1_TREVOGA = "e0_z1 TREVOGA";
    public static final String SMS_EXT0_ZONA2_TREVOGA = "e0_z2 TREVOGA";
    public static final String SMS_EXT0_ZONA3_TREVOGA = "e0_z3 TREVOGA";
    public static final String SMS_EXT0_ZONA4_TREVOGA = "e0_z4 TREVOGA";
    public static final String SMS_EXT0_ZONA5_TREVOGA = "e0_z5 TREVOGA";
    public static final String SMS_EXT0_ZONA6_TREVOGA = "e0_z6 TREVOGA";
    public static final String SMS_EXT0_ZONA7_TREVOGA = "e0_z7 TREVOGA";
    public static final String SMS_EXT0_ZONA8_TREVOGA = "e0_z8 TREVOGA";

    public static final String SMS_EXT1_ZONA1_TREVOGA = "e1_z1 TREVOGA";
    public static final String SMS_EXT1_ZONA2_TREVOGA = "e1_z2 TREVOGA";
    public static final String SMS_EXT1_ZONA3_TREVOGA = "e1_z3 TREVOGA";
    public static final String SMS_EXT1_ZONA4_TREVOGA = "e1_z4 TREVOGA";
    public static final String SMS_EXT1_ZONA5_TREVOGA = "e1_z5 TREVOGA";
    public static final String SMS_EXT1_ZONA6_TREVOGA = "e1_z6 TREVOGA";
    public static final String SMS_EXT1_ZONA7_TREVOGA = "e1_z7 TREVOGA";
    public static final String SMS_EXT1_ZONA8_TREVOGA = "e1_z8 TREVOGA";

    public static final String SMS_EXT2_ZONA1_TREVOGA = "e2_z1 TREVOGA";
    public static final String SMS_EXT2_ZONA2_TREVOGA = "e2_z2 TREVOGA";
    public static final String SMS_EXT2_ZONA3_TREVOGA = "e2_z3 TREVOGA";
    public static final String SMS_EXT2_ZONA4_TREVOGA = "e2_z4 TREVOGA";
    public static final String SMS_EXT2_ZONA5_TREVOGA = "e2_z5 TREVOGA";
    public static final String SMS_EXT2_ZONA6_TREVOGA = "e2_z6 TREVOGA";
    public static final String SMS_EXT2_ZONA7_TREVOGA = "e2_z7 TREVOGA";
    public static final String SMS_EXT2_ZONA8_TREVOGA = "e2_z8 TREVOGA";

    public static final String SMS_EXT3_ZONA1_TREVOGA = "e3_z1 TREVOGA";
    public static final String SMS_EXT3_ZONA2_TREVOGA = "e3_z2 TREVOGA";
    public static final String SMS_EXT3_ZONA3_TREVOGA = "e3_z3 TREVOGA";
    public static final String SMS_EXT3_ZONA4_TREVOGA = "e3_z4 TREVOGA";
    public static final String SMS_EXT3_ZONA5_TREVOGA = "e3_z5 TREVOGA";
    public static final String SMS_EXT3_ZONA6_TREVOGA = "e3_z6 TREVOGA";
    public static final String SMS_EXT3_ZONA7_TREVOGA = "e3_z7 TREVOGA";
    public static final String SMS_EXT3_ZONA8_TREVOGA = "e3_z8 TREVOGA";

    public static final String SMS_EXT4_ZONA1_TREVOGA = "e4_z1 TREVOGA";
    public static final String SMS_EXT4_ZONA2_TREVOGA = "e4_z2 TREVOGA";
    public static final String SMS_EXT4_ZONA3_TREVOGA = "e4_z3 TREVOGA";
    public static final String SMS_EXT4_ZONA4_TREVOGA = "e4_z4 TREVOGA";
    public static final String SMS_EXT4_ZONA5_TREVOGA = "e4_z5 TREVOGA";
    public static final String SMS_EXT4_ZONA6_TREVOGA = "e4_z6 TREVOGA";
    public static final String SMS_EXT4_ZONA7_TREVOGA = "e4_z7 TREVOGA";
    public static final String SMS_EXT4_ZONA8_TREVOGA = "e4_z8 TREVOGA";



    public  String TREVOGA = "";
    public static final String SMS_ZONA1_KZ = "KZ-z1 TREVOGA";
    public static final String SMS_ZONA2_KZ = "KZ-z2 TREVOGA";
    public static final String SMS_ZONA3_KZ = "KZ-z3 TREVOGA";
    public static final String SMS_ZONA4_KZ = "KZ-z4 TREVOGA";
    public static final String SMS_ZONA5_KZ = "KZ-z5 TREVOGA";
    public static final String SMS_ZONA6_KZ = "KZ-z6 TREVOGA";
    public static final String SMS_ZONA7_KZ = "KZ-z7 TREVOGA";
    public static final String SMS_ZONA8_KZ = "KZ-z8 TREVOGA";

    public static final String SMS_EXT0_ZONA1_KZ = "KZ-e0_z1 TREVOGA";
    public static final String SMS_EXT0_ZONA2_KZ = "KZ-e0_z2 TREVOGA";
    public static final String SMS_EXT0_ZONA3_KZ = "KZ-e0_z3 TREVOGA";
    public static final String SMS_EXT0_ZONA4_KZ = "KZ-e0_z4 TREVOGA";
    public static final String SMS_EXT0_ZONA5_KZ = "KZ-e0_z5 TREVOGA";
    public static final String SMS_EXT0_ZONA6_KZ = "KZ-e0_z6 TREVOGA";
    public static final String SMS_EXT0_ZONA7_KZ = "KZ-e0_z7 TREVOGA";
    public static final String SMS_EXT0_ZONA8_KZ = "KZ-e0_z8 TREVOGA";

    public static final String SMS_EXT1_ZONA1_KZ = "KZ-e1_z1 TREVOGA";
    public static final String SMS_EXT1_ZONA2_KZ = "KZ-e1_z2 TREVOGA";
    public static final String SMS_EXT1_ZONA3_KZ = "KZ-e1_z3 TREVOGA";
    public static final String SMS_EXT1_ZONA4_KZ = "KZ-e1_z4 TREVOGA";
    public static final String SMS_EXT1_ZONA5_KZ = "KZ-e1_z5 TREVOGA";
    public static final String SMS_EXT1_ZONA6_KZ = "KZ-e1_z6 TREVOGA";
    public static final String SMS_EXT1_ZONA7_KZ = "KZ-e1_z7 TREVOGA";
    public static final String SMS_EXT1_ZONA8_KZ = "KZ-e1_z8 TREVOGA";

    public static final String SMS_EXT2_ZONA1_KZ = "KZ-e2_z1 TREVOGA";
    public static final String SMS_EXT2_ZONA2_KZ = "KZ-e2_z2 TREVOGA";
    public static final String SMS_EXT2_ZONA3_KZ = "KZ-e2_z3 TREVOGA";
    public static final String SMS_EXT2_ZONA4_KZ = "KZ-e2_z4 TREVOGA";
    public static final String SMS_EXT2_ZONA5_KZ = "KZ-e2_z5 TREVOGA";
    public static final String SMS_EXT2_ZONA6_KZ = "KZ-e2_z6 TREVOGA";
    public static final String SMS_EXT2_ZONA7_KZ = "KZ-e2_z7 TREVOGA";
    public static final String SMS_EXT2_ZONA8_KZ = "KZ-e2_z8 TREVOGA";

    public static final String SMS_EXT3_ZONA1_KZ = "KZ-e3_z1 TREVOGA";
    public static final String SMS_EXT3_ZONA2_KZ = "KZ-e3_z2 TREVOGA";
    public static final String SMS_EXT3_ZONA3_KZ = "KZ-e3_z3 TREVOGA";
    public static final String SMS_EXT3_ZONA4_KZ = "KZ-e3_z4 TREVOGA";
    public static final String SMS_EXT3_ZONA5_KZ = "KZ-e3_z5 TREVOGA";
    public static final String SMS_EXT3_ZONA6_KZ = "KZ-e3_z6 TREVOGA";
    public static final String SMS_EXT3_ZONA7_KZ = "KZ-e3_z7 TREVOGA";
    public static final String SMS_EXT3_ZONA8_KZ = "KZ-e3_z8 TREVOGA";

    public static final String SMS_EXT4_ZONA1_KZ = "KZ-e4_z1 TREVOGA";
    public static final String SMS_EXT4_ZONA2_KZ = "KZ-e4_z2 TREVOGA";
    public static final String SMS_EXT4_ZONA3_KZ = "KZ-e4_z3 TREVOGA";
    public static final String SMS_EXT4_ZONA4_KZ = "KZ-e4_z4 TREVOGA";
    public static final String SMS_EXT4_ZONA5_KZ = "KZ-e4_z5 TREVOGA";
    public static final String SMS_EXT4_ZONA6_KZ = "KZ-e4_z6 TREVOGA";
    public static final String SMS_EXT4_ZONA7_KZ = "KZ-e4_z7 TREVOGA";
    public static final String SMS_EXT4_ZONA8_KZ = "KZ-e4_z8 TREVOGA";



    public  String KZ = "";
    public static final String SMS_ZONA1_OBRIV = "OBRIV-z1 TREVOGA";
    public static final String SMS_ZONA2_OBRIV = "OBRIV-z2 TREVOGA";
    public static final String SMS_ZONA3_OBRIV = "OBRIV-z3 TREVOGA";
    public static final String SMS_ZONA4_OBRIV = "OBRIV-z4 TREVOGA";
    public static final String SMS_ZONA5_OBRIV = "OBRIV-z5 TREVOGA";
    public static final String SMS_ZONA6_OBRIV = "OBRIV-z6 TREVOGA";
    public static final String SMS_ZONA7_OBRIV = "OBRIV-z7 TREVOGA";
    public static final String SMS_ZONA8_OBRIV = "OBRIV-z8 TREVOGA";

    public static final String SMS_EXT0_ZONA1_OBRIV = "OBRIV-e0_z1 TREVOGA";
    public static final String SMS_EXT0_ZONA2_OBRIV = "OBRIV-e0_z2 TREVOGA";
    public static final String SMS_EXT0_ZONA3_OBRIV = "OBRIV-e0_z3 TREVOGA";
    public static final String SMS_EXT0_ZONA4_OBRIV = "OBRIV-e0_z4 TREVOGA";
    public static final String SMS_EXT0_ZONA5_OBRIV = "OBRIV-e0_z5 TREVOGA";
    public static final String SMS_EXT0_ZONA6_OBRIV = "OBRIV-e0_z6 TREVOGA";
    public static final String SMS_EXT0_ZONA7_OBRIV = "OBRIV-e0_z7 TREVOGA";
    public static final String SMS_EXT0_ZONA8_OBRIV = "OBRIV-e0_z8 TREVOGA";

    public static final String SMS_EXT1_ZONA1_OBRIV = "OBRIV-e1_z1 TREVOGA";
    public static final String SMS_EXT1_ZONA2_OBRIV = "OBRIV-e1_z2 TREVOGA";
    public static final String SMS_EXT1_ZONA3_OBRIV = "OBRIV-e1_z3 TREVOGA";
    public static final String SMS_EXT1_ZONA4_OBRIV = "OBRIV-e1_z4 TREVOGA";
    public static final String SMS_EXT1_ZONA5_OBRIV = "OBRIV-e1_z5 TREVOGA";
    public static final String SMS_EXT1_ZONA6_OBRIV = "OBRIV-e1_z6 TREVOGA";
    public static final String SMS_EXT1_ZONA7_OBRIV = "OBRIV-e1_z7 TREVOGA";
    public static final String SMS_EXT1_ZONA8_OBRIV = "OBRIV-e1_z8 TREVOGA";

    public static final String SMS_EXT2_ZONA1_OBRIV = "OBRIV-e2_z1 TREVOGA";
    public static final String SMS_EXT2_ZONA2_OBRIV = "OBRIV-e2_z2 TREVOGA";
    public static final String SMS_EXT2_ZONA3_OBRIV = "OBRIV-e2_z3 TREVOGA";
    public static final String SMS_EXT2_ZONA4_OBRIV = "OBRIV-e2_z4 TREVOGA";
    public static final String SMS_EXT2_ZONA5_OBRIV = "OBRIV-e2_z5 TREVOGA";
    public static final String SMS_EXT2_ZONA6_OBRIV = "OBRIV-e2_z6 TREVOGA";
    public static final String SMS_EXT2_ZONA7_OBRIV = "OBRIV-e2_z7 TREVOGA";
    public static final String SMS_EXT2_ZONA8_OBRIV = "OBRIV-e2_z8 TREVOGA";

    public static final String SMS_EXT3_ZONA1_OBRIV = "OBRIV-e3_z1 TREVOGA";
    public static final String SMS_EXT3_ZONA2_OBRIV = "OBRIV-e3_z2 TREVOGA";
    public static final String SMS_EXT3_ZONA3_OBRIV = "OBRIV-e3_z3 TREVOGA";
    public static final String SMS_EXT3_ZONA4_OBRIV = "OBRIV-e3_z4 TREVOGA";
    public static final String SMS_EXT3_ZONA5_OBRIV = "OBRIV-e3_z5 TREVOGA";
    public static final String SMS_EXT3_ZONA6_OBRIV = "OBRIV-e3_z6 TREVOGA";
    public static final String SMS_EXT3_ZONA7_OBRIV = "OBRIV-e3_z7 TREVOGA";
    public static final String SMS_EXT3_ZONA8_OBRIV = "OBRIV-e3_z8 TREVOGA";

    public static final String SMS_EXT4_ZONA1_OBRIV = "OBRIV-e4_z1 TREVOGA";
    public static final String SMS_EXT4_ZONA2_OBRIV = "OBRIV-e4_z2 TREVOGA";
    public static final String SMS_EXT4_ZONA3_OBRIV = "OBRIV-e4_z3 TREVOGA";
    public static final String SMS_EXT4_ZONA4_OBRIV = "OBRIV-e4_z4 TREVOGA";
    public static final String SMS_EXT4_ZONA5_OBRIV = "OBRIV-e4_z5 TREVOGA";
    public static final String SMS_EXT4_ZONA6_OBRIV = "OBRIV-e4_z6 TREVOGA";
    public static final String SMS_EXT4_ZONA7_OBRIV = "OBRIV-e4_z7 TREVOGA";
    public static final String SMS_EXT4_ZONA8_OBRIV = "OBRIV-e4_z8 TREVOGA";



    public  String OBRIV = "";

    public static final String SMS_GSM_LEVEL_HIGH = "VYSOKIJ";
    public  String VYSOKIJ = "";

    public static final String SMS_GSM_LEVEL_MEDIUN = "SREDNIJ";
    public  String SREDNIJ = "";

    public static final String SMS_GSM_LEVEL_LOW = "NIZKIJ";
    public  String NIZKIJ = "";

    //беспроводные датчики
    public static final String SMS_RADIO1 = "Radio-1";
    public static final String SMS_RADIO2 = "Radio-2";
    public static final String SMS_RADIO3 = "Radio-3";
    public static final String SMS_RADIO4 = "Radio-4";
    public static final String SMS_RADIO5 = "Radio-5";
    public static final String SMS_RADIO6 = "Radio-6";
    public static final String SMS_RADIO7 = "Radio-7";
    public static final String SMS_RADIO8 = "Radio-8";
    public static final String SMS_RADIO9 = "Radio-9";
    public static final String SMS_RADIO10 = "Radio-10";
    public static final String SMS_RADIO11 = "Radio-11";
    public static final String SMS_RADIO12 = "Radio-12";
    public static final String SMS_RADIO13 = "Radio-13";
    public static final String SMS_RADIO14 = "Radio-14";
    public static final String SMS_RADIO15 = "Radio-15";
    public static final String SMS_RADIO16 = "Radio-16";


    //проводные термодатчики

    public static final String SMS_TERMO1 = "Termo-1";
    public static final String SMS_TERMO2 = "Termo-2";
    public static final String SMS_TERMO3 = "Termo-3";
    public static final String SMS_TERMO4 = "Termo-4";
    public static final String SMS_TERMO5 = "Termo-5";
    public static final String SMS_TERMO6 = "Termo-6";
    public static final String SMS_TERMO7 = "Termo-7";
    public static final String SMS_TERMO8 = "Termo-8";


    public static final String SMS_PANIKA = "PANIKA";
    public  String PANIKA = ""; //"ТРЕВОЖНАЯ КНОПКА";
    public  String ARM = ""; //"ПОСТАНОВКА НА ОХРАНУ";
    public  String DISARM = ""; //"СНЯТИЕ С ОХРАНЫ";
    public  String HOME = ""; //"ЧАСТИЧНАЯ ПОСТАНОВКА НА ОХРАНУ";
    public static final String SMS_VSKRYTIE_DATCHIKA = "VSKRYTIE DATCHIKA";
    public  String VSKRYTIE_DATCHIKA = ""; //"ВСКРЫТИЕ ДАТЧИКА";
    public static final String SMS_RAZRIAD_BATTAREYKI = "RAZRIAD BATTAREYKI";
    public  String RAZRIAD_BATTAREYKI = ""; //"РАЗРЯД БАТАРЕЕК ДАТЧИКА";
    public static final String SMS_NET_TESTOVOGO_SIGNALA = "NET TESTOVOGO SIGNALA";
    public  String NET_TESTOVOGO_SIGNALA = ""; //"ОТСУТСТВУЕТ ТЕСТОВЫЙ СИГНАЛ ДАТЧИКА";
    public static final String SMS_VOSSTANOVLENIE = "VOSSTANOVLENIE";
    public  String VOSSTANOVLENIE = ""; //"ВОССТАНОВЛЕНИЕ";
    public static final String SMS_NARUSHENIE = "NARUSHENIE";
    public  String NARUSHENIE = ""; //"НАРУШЕНИЕ";

    public static final String SMS_TEMPERATURA = "T=";
    public  String TEMPERATURA = ""; //"Температура: ";
    public static final String SMS_T_MIN = "Tmin=";
    public  String T_MIN = ""; //"Тминимум: ";
    public static final String SMS_T_MAX = "Tmax=";
    public  String T_MAX = ""; //"Тмаксимум: ";

    public static final int COLOR_WHITE=0xffffffff ;
    public static final int COLOR_GREY=0x40808080 ;
    public static final int COLOR_RED=0xffffaaaa ;
    public static final int COLOR_GREEN=0xffaaffaa ; //0xffaaffaa
    public static final int COLOR_YELLOW=0xaaffff66 ;

    // --- элементы отображения и управления
    Button btn_event_log;
    Button btn_restart_connection;
    Button btn_send_command;
    //Button btn_arm;
    //Button btn_query;

    Button btn_output1;
    Button btn_output2;
    Button btn_output3;
    Button btn_output4;
    Button btn_output5;
    Button btn_output6;
    Button btn_output7;
    Button btn_output8;

    Button btn_output1_ext0;
    Button btn_output2_ext0;
    Button btn_output3_ext0;
    Button btn_output4_ext0;
    Button btn_output5_ext0;
    Button btn_output6_ext0;
    Button btn_output7_ext0;
    Button btn_output8_ext0;

    Button btn_output1_ext1;
    Button btn_output2_ext1;
    Button btn_output3_ext1;
    Button btn_output4_ext1;
    Button btn_output5_ext1;
    Button btn_output6_ext1;
    Button btn_output7_ext1;
    Button btn_output8_ext1;

    Button btn_output1_ext2;
    Button btn_output2_ext2;
    Button btn_output3_ext2;
    Button btn_output4_ext2;
    Button btn_output5_ext2;
    Button btn_output6_ext2;
    Button btn_output7_ext2;
    Button btn_output8_ext2;

    Button btn_output1_ext3;
    Button btn_output2_ext3;
    Button btn_output3_ext3;
    Button btn_output4_ext3;
    Button btn_output5_ext3;
    Button btn_output6_ext3;
    Button btn_output7_ext3;
    Button btn_output8_ext3;

    Button btn_output1_ext4;
    Button btn_output2_ext4;
    Button btn_output3_ext4;
    Button btn_output4_ext4;
    Button btn_output5_ext4;
    Button btn_output6_ext4;
    Button btn_output7_ext4;
    Button btn_output8_ext4;


    Button btn_socket1_blk1;
    Button btn_socket2_blk1;
    Button btn_socket3_blk1;
    Button btn_socket4_blk1;
    Button btn_socket5_blk1;
    Button btn_socket6_blk1;
    Button btn_socket7_blk1;
    Button btn_socket8_blk1;

    Button btn_socket1_blk2;
    Button btn_socket2_blk2;
    Button btn_socket3_blk2;
    Button btn_socket4_blk2;
    Button btn_socket5_blk2;
    Button btn_socket6_blk2;
    Button btn_socket7_blk2;
    Button btn_socket8_blk2;

    Button btn_socket1_blk3;
    Button btn_socket2_blk3;
    Button btn_socket3_blk3;
    Button btn_socket4_blk3;
    Button btn_socket5_blk3;
    Button btn_socket6_blk3;
    Button btn_socket7_blk3;
    Button btn_socket8_blk3;

    Button btn_socket1_blk4;
    Button btn_socket2_blk4;
    Button btn_socket3_blk4;
    Button btn_socket4_blk4;
    Button btn_socket5_blk4;
    Button btn_socket6_blk4;
    Button btn_socket7_blk4;
    Button btn_socket8_blk4;



    //CheckBox checkBox_query;
    TextView btn_query; //textView_query;
    TextView textView_power;
    TextView btn_arm; //textView_arm;
    TextView textView_gsm;

    TextView textView_in;
    TextView textView_tamper;
    TextView textView_input1;
    TextView textView_input2;
    TextView textView_input3;
    TextView textView_input4;
    TextView textView_input5;
    TextView textView_input6;
    TextView textView_input7;
    TextView textView_input8;

    TextView textView_input1_ext0;
    TextView textView_input2_ext0;
    TextView textView_input3_ext0;
    TextView textView_input4_ext0;
    TextView textView_input5_ext0;
    TextView textView_input6_ext0;
    TextView textView_input7_ext0;
    TextView textView_input8_ext0;

    TextView textView_input1_ext1;
    TextView textView_input2_ext1;
    TextView textView_input3_ext1;
    TextView textView_input4_ext1;
    TextView textView_input5_ext1;
    TextView textView_input6_ext1;
    TextView textView_input7_ext1;
    TextView textView_input8_ext1;

    TextView textView_input1_ext2;
    TextView textView_input2_ext2;
    TextView textView_input3_ext2;
    TextView textView_input4_ext2;
    TextView textView_input5_ext2;
    TextView textView_input6_ext2;
    TextView textView_input7_ext2;
    TextView textView_input8_ext2;

    TextView textView_input1_ext3;
    TextView textView_input2_ext3;
    TextView textView_input3_ext3;
    TextView textView_input4_ext3;
    TextView textView_input5_ext3;
    TextView textView_input6_ext3;
    TextView textView_input7_ext3;
    TextView textView_input8_ext3;

    TextView textView_input1_ext4;
    TextView textView_input2_ext4;
    TextView textView_input3_ext4;
    TextView textView_input4_ext4;
    TextView textView_input5_ext4;
    TextView textView_input6_ext4;
    TextView textView_input7_ext4;
    TextView textView_input8_ext4;



    TextView textView_out;

    TextView textView_wr;
    TextView textView_radio1;
    TextView textView_radio2;
    TextView textView_radio3;
    TextView textView_radio4;
    TextView textView_radio5;
    TextView textView_radio6;
    TextView textView_radio7;
    TextView textView_radio8;
    TextView textView_radio9;
    TextView textView_radio10;
    TextView textView_radio11;
    TextView textView_radio12;
    TextView textView_radio13;
    TextView textView_radio14;
    TextView textView_radio15;
    TextView textView_radio16;

    TextView textView_t;
    TextView textView_termo1;
    TextView textView_termo2;
    TextView textView_termo3;
    TextView textView_termo4;
    TextView textView_termo5;
    TextView textView_termo6;
    TextView textView_termo7;
    TextView textView_termo8;
    TextView textView_controller;

    Spinner spinner;


    ImageButton imageButton_ON;
    ImageButton imageButton_OFF;
    ImageButton imageButton_Query;

    ImageView imageView_power_on;
    ImageView imageView_power_off;
    ImageView imageView_power_;
    ImageView imageView_arm_on;
    ImageView imageView_arm_off;
    ImageView imageView_arm_;
    ImageView imageView_GSM_high;
    ImageView imageView_GSM_medium;
    ImageView imageView_GSM_low;
    ImageView imageView_GSM_;
    ImageView imageView_input_norma;
    ImageView imageView_input_trevoga;
    ImageView imageView_input_;


    String Enter_Phone_Password = ""; //"Введите телефонный номер OKO-PRO/U2 и пароль доступа";
    String Enter_Phone = ""; //"Введите телефонный номер OKO-PRO/U2";
    String Enter_Password = ""; //"Введите пароль доступа OKO-PRO/U2";
    String Enter_IMEI = ""; //"Введите IMEI прибора OKO-PRO/U2";
    String Enter_IMEI_Password = ""; //"Введите IMEI прибора OKO-PRO/U2 и пароль доступа";

    // ------- для sms command
    String ini_password = "1234";
    String Arm_on = "01";
    String Arm_off = "00";
    String Query = "02";
    String Query_server = "70";

    String OKO_S2_Out1_on = "06";
    String OKO_S2_Out1_off = "05";
    String OKO_S2_Out2_on = "04";
    String OKO_S2_Out2_off = "03";

    String Out1_on = "*#19";
    String Out1_off = "*#10";
    String Out2_on = "*#29";
    String Out2_off = "*#20";
    String Out3_on = "*#39";
    String Out3_off = "*#30";
    String Out4_on = "*#49";
    String Out4_off = "*#40";
    String Out5_on = "*#59";
    String Out5_off = "*#50";
    String Out6_on = "*#69";
    String Out6_off = "*#60";
    String Out7_on = "*#79";
    String Out7_off = "*#70";
    String Out8_on = "*#89";
    String Out8_off = "*#80";

    String Ext0_Out1_on = "*9#19";
    String Ext0_Out1_off = "*9#10";
    String Ext0_Out2_on = "*9#29";
    String Ext0_Out2_off = "*9#20";
    String Ext0_Out3_on = "*9#39";
    String Ext0_Out3_off = "*9#30";
    String Ext0_Out4_on = "*9#49";
    String Ext0_Out4_off = "*9#40";
    String Ext0_Out5_on = "*9#59";
    String Ext0_Out5_off = "*9#50";
    String Ext0_Out6_on = "*9#69";
    String Ext0_Out6_off = "*9#60";
    String Ext0_Out7_on = "*9#79";
    String Ext0_Out7_off = "*9#70";
    String Ext0_Out8_on = "*9#89";
    String Ext0_Out8_off = "*9#80";

    String Ext1_Out1_on = "*1#19";
    String Ext1_Out1_off = "*1#10";
    String Ext1_Out2_on = "*1#29";
    String Ext1_Out2_off = "*1#20";
    String Ext1_Out3_on = "*1#39";
    String Ext1_Out3_off = "*1#30";
    String Ext1_Out4_on = "*1#49";
    String Ext1_Out4_off = "*1#40";
    String Ext1_Out5_on = "*1#59";
    String Ext1_Out5_off = "*1#50";
    String Ext1_Out6_on = "*1#69";
    String Ext1_Out6_off = "*1#60";
    String Ext1_Out7_on = "*1#79";
    String Ext1_Out7_off = "*1#70";
    String Ext1_Out8_on = "*1#89";
    String Ext1_Out8_off = "*1#80";

    String Ext2_Out1_on = "*2#19";
    String Ext2_Out1_off = "*2#10";
    String Ext2_Out2_on = "*2#29";
    String Ext2_Out2_off = "*2#20";
    String Ext2_Out3_on = "*2#39";
    String Ext2_Out3_off = "*2#30";
    String Ext2_Out4_on = "*2#49";
    String Ext2_Out4_off = "*2#40";
    String Ext2_Out5_on = "*2#59";
    String Ext2_Out5_off = "*2#50";
    String Ext2_Out6_on = "*2#69";
    String Ext2_Out6_off = "*2#60";
    String Ext2_Out7_on = "*2#79";
    String Ext2_Out7_off = "*2#70";
    String Ext2_Out8_on = "*2#89";
    String Ext2_Out8_off = "*2#80";

    String Ext3_Out1_on = "*3#19";
    String Ext3_Out1_off = "*3#10";
    String Ext3_Out2_on = "*3#29";
    String Ext3_Out2_off = "*3#20";
    String Ext3_Out3_on = "*3#39";
    String Ext3_Out3_off = "*3#30";
    String Ext3_Out4_on = "*3#49";
    String Ext3_Out4_off = "*3#40";
    String Ext3_Out5_on = "*3#59";
    String Ext3_Out5_off = "*3#50";
    String Ext3_Out6_on = "*3#69";
    String Ext3_Out6_off = "*3#60";
    String Ext3_Out7_on = "*3#79";
    String Ext3_Out7_off = "*3#70";
    String Ext3_Out8_on = "*3#89";
    String Ext3_Out8_off = "*3#80";

    String Ext4_Out1_on = "*4#19";
    String Ext4_Out1_off = "*4#10";
    String Ext4_Out2_on = "*4#29";
    String Ext4_Out2_off = "*4#20";
    String Ext4_Out3_on = "*4#39";
    String Ext4_Out3_off = "*4#30";
    String Ext4_Out4_on = "*4#49";
    String Ext4_Out4_off = "*4#40";
    String Ext4_Out5_on = "*4#59";
    String Ext4_Out5_off = "*4#50";
    String Ext4_Out6_on = "*4#69";
    String Ext4_Out6_off = "*4#60";
    String Ext4_Out7_on = "*4#79";
    String Ext4_Out7_off = "*4#70";
    String Ext4_Out8_on = "*4#89";
    String Ext4_Out8_off = "*4#80";


    String Blk1_Socket1_on = "*5#19";
    String Blk1_Socket1_off = "*5#10";
    String Blk1_Socket2_on = "*5#29";
    String Blk1_Socket2_off = "*5#20";
    String Blk1_Socket3_on = "*5#39";
    String Blk1_Socket3_off = "*5#30";
    String Blk1_Socket4_on = "*5#49";
    String Blk1_Socket4_off = "*5#40";
    String Blk1_Socket5_on = "*5#59";
    String Blk1_Socket5_off = "*5#50";
    String Blk1_Socket6_on = "*5#69";
    String Blk1_Socket6_off = "*5#60";
    String Blk1_Socket7_on = "*5#79";
    String Blk1_Socket7_off = "*5#70";
    String Blk1_Socket8_on = "*5#89";
    String Blk1_Socket8_off = "*5#80";

    String Blk2_Socket1_on = "*6#19";
    String Blk2_Socket1_off = "*6#10";
    String Blk2_Socket2_on = "*6#29";
    String Blk2_Socket2_off = "*6#20";
    String Blk2_Socket3_on = "*6#39";
    String Blk2_Socket3_off = "*6#30";
    String Blk2_Socket4_on = "*6#49";
    String Blk2_Socket4_off = "*6#40";
    String Blk2_Socket5_on = "*6#59";
    String Blk2_Socket5_off = "*6#50";
    String Blk2_Socket6_on = "*6#69";
    String Blk2_Socket6_off = "*6#60";
    String Blk2_Socket7_on = "*6#79";
    String Blk2_Socket7_off = "*6#70";
    String Blk2_Socket8_on = "*6#89";
    String Blk2_Socket8_off = "*6#80";

    String Blk3_Socket1_on = "*7#19";
    String Blk3_Socket1_off = "*7#10";
    String Blk3_Socket2_on = "*7#29";
    String Blk3_Socket2_off = "*7#20";
    String Blk3_Socket3_on = "*7#39";
    String Blk3_Socket3_off = "*7#30";
    String Blk3_Socket4_on = "*7#49";
    String Blk3_Socket4_off = "*7#40";
    String Blk3_Socket5_on = "*7#59";
    String Blk3_Socket5_off = "*7#50";
    String Blk3_Socket6_on = "*7#69";
    String Blk3_Socket6_off = "*7#60";
    String Blk3_Socket7_on = "*7#79";
    String Blk3_Socket7_off = "*7#70";
    String Blk3_Socket8_on = "*7#89";
    String Blk3_Socket8_off = "*7#80";

    String Blk4_Socket1_on = "*8#19";
    String Blk4_Socket1_off = "*8#10";
    String Blk4_Socket2_on = "*8#29";
    String Blk4_Socket2_off = "*8#20";
    String Blk4_Socket3_on = "*8#39";
    String Blk4_Socket3_off = "*8#30";
    String Blk4_Socket4_on = "*8#49";
    String Blk4_Socket4_off = "*8#40";
    String Blk4_Socket5_on = "*8#59";
    String Blk4_Socket5_off = "*8#50";
    String Blk4_Socket6_on = "*8#69";
    String Blk4_Socket6_off = "*8#60";
    String Blk4_Socket7_on = "*8#79";
    String Blk4_Socket7_off = "*8#70";
    String Blk4_Socket8_on = "*8#89";
    String Blk4_Socket8_off = "*8#80";


    // ---- надписи на главном окне
    String update_time = ""; //"Обновление: ";
    String state_220v = ""; //"Наличие 220В: ";
    String state_arm = ""; //"Охрана: ";
    String gsm_level = ""; //"Уровень GSM: ";

    String name_tamper = "";
    String name_input1 = ""; //"Вход-1";
    String name_input2 = ""; //"Вход-2";
    String name_input3 = ""; //"Вход-3";
    String name_input4 = ""; //"Вход-4";
    String name_input5 = ""; //"Вход-5";
    String name_input6 = ""; //"Вход-6";
    String name_input7 = ""; //"Вход-7";
    String name_input8 = ""; //"Вход-8";

    String name_input1_ext0 = "";
    String name_input2_ext0 = "";
    String name_input3_ext0 = "";
    String name_input4_ext0 = "";
    String name_input5_ext0 = "";
    String name_input6_ext0 = "";
    String name_input7_ext0 = "";
    String name_input8_ext0 = "";

    String name_input1_ext1 = "";
    String name_input2_ext1 = "";
    String name_input3_ext1 = "";
    String name_input4_ext1 = "";
    String name_input5_ext1 = "";
    String name_input6_ext1 = "";
    String name_input7_ext1 = "";
    String name_input8_ext1 = "";

    String name_input1_ext2 = "";
    String name_input2_ext2 = "";
    String name_input3_ext2 = "";
    String name_input4_ext2 = "";
    String name_input5_ext2 = "";
    String name_input6_ext2 = "";
    String name_input7_ext2 = "";
    String name_input8_ext2 = "";

    String name_input1_ext3 = "";
    String name_input2_ext3 = "";
    String name_input3_ext3 = "";
    String name_input4_ext3 = "";
    String name_input5_ext3 = "";
    String name_input6_ext3 = "";
    String name_input7_ext3 = "";
    String name_input8_ext3 = "";

    String name_input1_ext4 = "";
    String name_input2_ext4 = "";
    String name_input3_ext4 = "";
    String name_input4_ext4 = "";
    String name_input5_ext4 = "";
    String name_input6_ext4 = "";
    String name_input7_ext4 = "";
    String name_input8_ext4 = "";

    String name_output1 = ""; //"Выход-1";
    String name_output2 = ""; //"Выход-2";
    String name_output3 = ""; //"Выход-3";
    String name_output4 = ""; //"Выход-4";
    String name_output5 = ""; //"Выход-5";
    String name_output6 = ""; //"Выход-6";
    String name_output7 = ""; //"Выход-7";
    String name_output8 = ""; //"Выход-8";

    String name_output1_ext0 = "";
    String name_output2_ext0 = "";
    String name_output3_ext0 = "";
    String name_output4_ext0 = "";
    String name_output5_ext0 = "";
    String name_output6_ext0 = "";
    String name_output7_ext0 = "";
    String name_output8_ext0 = "";

    String name_output1_ext1 = "";
    String name_output2_ext1 = "";
    String name_output3_ext1 = "";
    String name_output4_ext1 = "";
    String name_output5_ext1 = "";
    String name_output6_ext1 = "";
    String name_output7_ext1 = "";
    String name_output8_ext1 = "";

    String name_output1_ext2 = "";
    String name_output2_ext2 = "";
    String name_output3_ext2 = "";
    String name_output4_ext2 = "";
    String name_output5_ext2 = "";
    String name_output6_ext2 = "";
    String name_output7_ext2 = "";
    String name_output8_ext2 = "";

    String name_output1_ext3 = "";
    String name_output2_ext3 = "";
    String name_output3_ext3 = "";
    String name_output4_ext3 = "";
    String name_output5_ext3 = "";
    String name_output6_ext3 = "";
    String name_output7_ext3 = "";
    String name_output8_ext3 = "";

    String name_output1_ext4 = "";
    String name_output2_ext4 = "";
    String name_output3_ext4 = "";
    String name_output4_ext4 = "";
    String name_output5_ext4 = "";
    String name_output6_ext4 = "";
    String name_output7_ext4 = "";
    String name_output8_ext4 = "";


    String name_socket1_blk1 = "";
    String name_socket2_blk1 = "";
    String name_socket3_blk1 = "";
    String name_socket4_blk1 = "";
    String name_socket5_blk1 = "";
    String name_socket6_blk1 = "";
    String name_socket7_blk1 = "";
    String name_socket8_blk1 = "";

    String name_socket1_blk2 = "";
    String name_socket2_blk2 = "";
    String name_socket3_blk2 = "";
    String name_socket4_blk2 = "";
    String name_socket5_blk2 = "";
    String name_socket6_blk2 = "";
    String name_socket7_blk2 = "";
    String name_socket8_blk2 = "";

    String name_socket1_blk3 = "";
    String name_socket2_blk3 = "";
    String name_socket3_blk3 = "";
    String name_socket4_blk3 = "";
    String name_socket5_blk3 = "";
    String name_socket6_blk3 = "";
    String name_socket7_blk3 = "";
    String name_socket8_blk3 = "";

    String name_socket1_blk4 = "";
    String name_socket2_blk4 = "";
    String name_socket3_blk4 = "";
    String name_socket4_blk4 = "";
    String name_socket5_blk4 = "";
    String name_socket6_blk4 = "";
    String name_socket7_blk4 = "";
    String name_socket8_blk4 = "";



    String separation = ": ";

    String state_tamper = separation ;
    String state_input1 = separation ;
    String state_input2 = separation ;
    String state_input3 = separation ;
    String state_input4 = separation ;
    String state_input5 = separation ;
    String state_input6 = separation ;
    String state_input7 = separation ;
    String state_input8 = separation ;

    String state_input1_ext0 = separation ;
    String state_input2_ext0 = separation ;
    String state_input3_ext0 = separation ;
    String state_input4_ext0 = separation ;
    String state_input5_ext0 = separation ;
    String state_input6_ext0 = separation ;
    String state_input7_ext0 = separation ;
    String state_input8_ext0 = separation ;

    String state_input1_ext1 = separation ;
    String state_input2_ext1 = separation ;
    String state_input3_ext1 = separation ;
    String state_input4_ext1 = separation ;
    String state_input5_ext1 = separation ;
    String state_input6_ext1 = separation ;
    String state_input7_ext1 = separation ;
    String state_input8_ext1 = separation ;

    String state_input1_ext2 = separation ;
    String state_input2_ext2 = separation ;
    String state_input3_ext2 = separation ;
    String state_input4_ext2 = separation ;
    String state_input5_ext2 = separation ;
    String state_input6_ext2 = separation ;
    String state_input7_ext2 = separation ;
    String state_input8_ext2 = separation ;

    String state_input1_ext3 = separation ;
    String state_input2_ext3 = separation ;
    String state_input3_ext3 = separation ;
    String state_input4_ext3 = separation ;
    String state_input5_ext3 = separation ;
    String state_input6_ext3 = separation ;
    String state_input7_ext3 = separation ;
    String state_input8_ext3 = separation ;

    String state_input1_ext4 = separation ;
    String state_input2_ext4 = separation ;
    String state_input3_ext4 = separation ;
    String state_input4_ext4 = separation ;
    String state_input5_ext4 = separation ;
    String state_input6_ext4 = separation ;
    String state_input7_ext4 = separation ;
    String state_input8_ext4 = separation ;


    String state_output1 = separation ;
    String state_output2 = separation ;
    String state_output3 = separation ;
    String state_output4 = separation ;
    String state_output5 = separation ;
    String state_output6 = separation ;
    String state_output7 = separation ;
    String state_output8 = separation ;

    String state_output1_ext0 = separation ;
    String state_output2_ext0 = separation ;
    String state_output3_ext0 = separation ;
    String state_output4_ext0 = separation ;
    String state_output5_ext0 = separation ;
    String state_output6_ext0 = separation ;
    String state_output7_ext0 = separation ;
    String state_output8_ext0 = separation ;

    String state_output1_ext1 = separation ;
    String state_output2_ext1 = separation ;
    String state_output3_ext1 = separation ;
    String state_output4_ext1 = separation ;
    String state_output5_ext1 = separation ;
    String state_output6_ext1 = separation ;
    String state_output7_ext1 = separation ;
    String state_output8_ext1 = separation ;

    String state_output1_ext2 = separation ;
    String state_output2_ext2 = separation ;
    String state_output3_ext2 = separation ;
    String state_output4_ext2 = separation ;
    String state_output5_ext2 = separation ;
    String state_output6_ext2 = separation ;
    String state_output7_ext2 = separation ;
    String state_output8_ext2 = separation ;

    String state_output1_ext3 = separation ;
    String state_output2_ext3 = separation ;
    String state_output3_ext3 = separation ;
    String state_output4_ext3 = separation ;
    String state_output5_ext3 = separation ;
    String state_output6_ext3 = separation ;
    String state_output7_ext3 = separation ;
    String state_output8_ext3 = separation ;

    String state_output1_ext4 = separation ;
    String state_output2_ext4 = separation ;
    String state_output3_ext4 = separation ;
    String state_output4_ext4 = separation ;
    String state_output5_ext4 = separation ;
    String state_output6_ext4 = separation ;
    String state_output7_ext4 = separation ;
    String state_output8_ext4 = separation ;


    String state_socket1_blk1 = separation ;
    String state_socket2_blk1 = separation ;
    String state_socket3_blk1 = separation ;
    String state_socket4_blk1 = separation ;
    String state_socket5_blk1 = separation ;
    String state_socket6_blk1 = separation ;
    String state_socket7_blk1 = separation ;
    String state_socket8_blk1 = separation ;

    String state_socket1_blk2 = separation ;
    String state_socket2_blk2 = separation ;
    String state_socket3_blk2 = separation ;
    String state_socket4_blk2 = separation ;
    String state_socket5_blk2 = separation ;
    String state_socket6_blk2 = separation ;
    String state_socket7_blk2 = separation ;
    String state_socket8_blk2 = separation ;

    String state_socket1_blk3 = separation ;
    String state_socket2_blk3 = separation ;
    String state_socket3_blk3 = separation ;
    String state_socket4_blk3 = separation ;
    String state_socket5_blk3 = separation ;
    String state_socket6_blk3 = separation ;
    String state_socket7_blk3 = separation ;
    String state_socket8_blk3 = separation ;

    String state_socket1_blk4 = separation ;
    String state_socket2_blk4 = separation ;
    String state_socket3_blk4 = separation ;
    String state_socket4_blk4 = separation ;
    String state_socket5_blk4 = separation ;
    String state_socket6_blk4 = separation ;
    String state_socket7_blk4 = separation ;
    String state_socket8_blk4 = separation ;



    String name_radio1 = ""; //"Радио-1";
    String name_radio2 = ""; //"Радио-2";
    String name_radio3 = ""; //"Радио-3";
    String name_radio4 = ""; //"Радио-4";
    String name_radio5 = ""; //"Радио-5";
    String name_radio6 = ""; //"Радио-6";
    String name_radio7 = ""; //"Радио-7";
    String name_radio8 = ""; //"Радио-8";
    String name_radio9 = ""; //"Радио-9";
    String name_radio10 = ""; //"Радио-10";
    String name_radio11 = ""; //"Радио-11";
    String name_radio12 = ""; //"Радио-12";
    String name_radio13 = ""; //"Радио-13";
    String name_radio14 = ""; //"Радио-14";
    String name_radio15 = ""; //"Радио-15";
    String name_radio16 = ""; //"Радио-16";


    String name_termo1 = ""; //"Термо-1";
    String name_termo2 = ""; //"Термо-2";
    String name_termo3 = ""; //"Термо-3";
    String name_termo4 = ""; //"Термо-4";
    String name_termo5 = ""; //"Термо-5";
    String name_termo6 = ""; //"Термо-6";
    String name_termo7 = ""; //"Термо-7";
    String name_termo8 = ""; //"Термо-8";

    String state_termo1 = separation ;
    String state_termo2 = separation ;
    String state_termo3 = separation ;
    String state_termo4 = separation ;
    String state_termo5 = separation ;
    String state_termo6 = separation ;
    String state_termo7 = separation ;
    String state_termo8 = separation ;

    String state_radio1 = separation ;
    String state_radio2 = separation ;
    String state_radio3 = separation ;
    String state_radio4 = separation ;
    String state_radio5 = separation ;
    String state_radio6 = separation ;
    String state_radio7 = separation ;
    String state_radio8 = separation ;
    String state_radio9 = separation ;
    String state_radio10 = separation ;
    String state_radio11 = separation ;
    String state_radio12 = separation ;
    String state_radio13 = separation ;
    String state_radio14 = separation ;
    String state_radio15 = separation ;
    String state_radio16 = separation ;

    String state_controller="";

    boolean inputs_ok=false;

    //для широковещательного приемника, настроенного на прием данных с сервиса
    BroadcastReceiver br_tcp;
    BroadcastReceiver br_sms;


    String object_name="";
    /**
     * Called when the activity is first created.
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mContext = this;



        Log.d(TAG, "MainActivity onCreate");

        Intent intent = getIntent();
        //object name
        object_name = intent.getStringExtra(StartActivity.OBJECT_NAME);
        setTitle(object_name); //getActivity().
        object_setting = intent.getStringExtra(StartActivity.OBJECT_SETTING);
        //APP_PREFERENCES = object_setting;

        //checkPermission();

        StartActivity.MainActivity_Started=false;
        //StartActivity.MainActivity_Started=false;

        //context.getString(R.string.app_name);
        name_tamper=getString(R.string.set_name_tamper);
        name_input1=getString(R.string.set_name_input1);
        name_input2=getString(R.string.set_name_input2);
        name_input3=getString(R.string.set_name_input3);
        name_input4=getString(R.string.set_name_input4);
        name_input5=getString(R.string.set_name_input5);
        name_input6=getString(R.string.set_name_input6);
        name_input7=getString(R.string.set_name_input7);
        name_input8=getString(R.string.set_name_input8);

        name_input1_ext0=getString(R.string.set_name_input1_ext0);
        name_input2_ext0=getString(R.string.set_name_input2_ext0);
        name_input3_ext0=getString(R.string.set_name_input3_ext0);
        name_input4_ext0=getString(R.string.set_name_input4_ext0);
        name_input5_ext0=getString(R.string.set_name_input5_ext0);
        name_input6_ext0=getString(R.string.set_name_input6_ext0);
        name_input7_ext0=getString(R.string.set_name_input7_ext0);
        name_input8_ext0=getString(R.string.set_name_input8_ext0);

        name_input1_ext1=getString(R.string.set_name_input1_ext1);
        name_input2_ext1=getString(R.string.set_name_input2_ext1);
        name_input3_ext1=getString(R.string.set_name_input3_ext1);
        name_input4_ext1=getString(R.string.set_name_input4_ext1);
        name_input5_ext1=getString(R.string.set_name_input5_ext1);
        name_input6_ext1=getString(R.string.set_name_input6_ext1);
        name_input7_ext1=getString(R.string.set_name_input7_ext1);
        name_input8_ext1=getString(R.string.set_name_input8_ext1);

        name_input1_ext2=getString(R.string.set_name_input1_ext2);
        name_input2_ext2=getString(R.string.set_name_input2_ext2);
        name_input3_ext2=getString(R.string.set_name_input3_ext2);
        name_input4_ext2=getString(R.string.set_name_input4_ext2);
        name_input5_ext2=getString(R.string.set_name_input5_ext2);
        name_input6_ext2=getString(R.string.set_name_input6_ext2);
        name_input7_ext2=getString(R.string.set_name_input7_ext2);
        name_input8_ext2=getString(R.string.set_name_input8_ext2);

        name_input1_ext3=getString(R.string.set_name_input1_ext3);
        name_input2_ext3=getString(R.string.set_name_input2_ext3);
        name_input3_ext3=getString(R.string.set_name_input3_ext3);
        name_input4_ext3=getString(R.string.set_name_input4_ext3);
        name_input5_ext3=getString(R.string.set_name_input5_ext3);
        name_input6_ext3=getString(R.string.set_name_input6_ext3);
        name_input7_ext3=getString(R.string.set_name_input7_ext3);
        name_input8_ext3=getString(R.string.set_name_input8_ext3);

        name_input1_ext4=getString(R.string.set_name_input1_ext4);
        name_input2_ext4=getString(R.string.set_name_input2_ext4);
        name_input3_ext4=getString(R.string.set_name_input3_ext4);
        name_input4_ext4=getString(R.string.set_name_input4_ext4);
        name_input5_ext4=getString(R.string.set_name_input5_ext4);
        name_input6_ext4=getString(R.string.set_name_input6_ext4);
        name_input7_ext4=getString(R.string.set_name_input7_ext4);
        name_input8_ext4=getString(R.string.set_name_input8_ext4);


        name_output1=getString(R.string.set_name_output1);
        name_output2=getString(R.string.set_name_output2);
        name_output3=getString(R.string.set_name_output3);
        name_output4=getString(R.string.set_name_output4);
        name_output5=getString(R.string.set_name_output5);
        name_output6=getString(R.string.set_name_output6);
        name_output7=getString(R.string.set_name_output7);
        name_output8=getString(R.string.set_name_output8);

        name_output1_ext0=getString(R.string.set_name_output1_ext0);
        name_output2_ext0=getString(R.string.set_name_output2_ext0);
        name_output3_ext0=getString(R.string.set_name_output3_ext0);
        name_output4_ext0=getString(R.string.set_name_output4_ext0);
        name_output5_ext0=getString(R.string.set_name_output5_ext0);
        name_output6_ext0=getString(R.string.set_name_output6_ext0);
        name_output7_ext0=getString(R.string.set_name_output7_ext0);
        name_output8_ext0=getString(R.string.set_name_output8_ext0);

        name_output1_ext1=getString(R.string.set_name_output1_ext1);
        name_output2_ext1=getString(R.string.set_name_output2_ext1);
        name_output3_ext1=getString(R.string.set_name_output3_ext1);
        name_output4_ext1=getString(R.string.set_name_output4_ext1);
        name_output5_ext1=getString(R.string.set_name_output5_ext1);
        name_output6_ext1=getString(R.string.set_name_output6_ext1);
        name_output7_ext1=getString(R.string.set_name_output7_ext1);
        name_output8_ext1=getString(R.string.set_name_output8_ext1);

        name_output1_ext2=getString(R.string.set_name_output1_ext2);
        name_output2_ext2=getString(R.string.set_name_output2_ext2);
        name_output3_ext2=getString(R.string.set_name_output3_ext2);
        name_output4_ext2=getString(R.string.set_name_output4_ext2);
        name_output5_ext2=getString(R.string.set_name_output5_ext2);
        name_output6_ext2=getString(R.string.set_name_output6_ext2);
        name_output7_ext2=getString(R.string.set_name_output7_ext2);
        name_output8_ext2=getString(R.string.set_name_output8_ext2);

        name_output1_ext3=getString(R.string.set_name_output1_ext3);
        name_output2_ext3=getString(R.string.set_name_output2_ext3);
        name_output3_ext3=getString(R.string.set_name_output3_ext3);
        name_output4_ext3=getString(R.string.set_name_output4_ext3);
        name_output5_ext3=getString(R.string.set_name_output5_ext3);
        name_output6_ext3=getString(R.string.set_name_output6_ext3);
        name_output7_ext3=getString(R.string.set_name_output7_ext3);
        name_output8_ext3=getString(R.string.set_name_output8_ext3);

        name_output1_ext4=getString(R.string.set_name_output1_ext4);
        name_output2_ext4=getString(R.string.set_name_output2_ext4);
        name_output3_ext4=getString(R.string.set_name_output3_ext4);
        name_output4_ext4=getString(R.string.set_name_output4_ext4);
        name_output5_ext4=getString(R.string.set_name_output5_ext4);
        name_output6_ext4=getString(R.string.set_name_output6_ext4);
        name_output7_ext4=getString(R.string.set_name_output7_ext4);
        name_output8_ext4=getString(R.string.set_name_output8_ext4);

        name_socket1_blk1=getString(R.string.set_name_socket1_blk1);
        name_socket2_blk1=getString(R.string.set_name_socket2_blk1);
        name_socket3_blk1=getString(R.string.set_name_socket3_blk1);
        name_socket4_blk1=getString(R.string.set_name_socket4_blk1);
        name_socket5_blk1=getString(R.string.set_name_socket5_blk1);
        name_socket6_blk1=getString(R.string.set_name_socket6_blk1);
        name_socket7_blk1=getString(R.string.set_name_socket7_blk1);
        name_socket8_blk1=getString(R.string.set_name_socket8_blk1);

        name_socket1_blk2=getString(R.string.set_name_socket1_blk2);
        name_socket2_blk2=getString(R.string.set_name_socket2_blk2);
        name_socket3_blk2=getString(R.string.set_name_socket3_blk2);
        name_socket4_blk2=getString(R.string.set_name_socket4_blk2);
        name_socket5_blk2=getString(R.string.set_name_socket5_blk2);
        name_socket6_blk2=getString(R.string.set_name_socket6_blk2);
        name_socket7_blk2=getString(R.string.set_name_socket7_blk2);
        name_socket8_blk2=getString(R.string.set_name_socket8_blk2);

        name_socket1_blk3=getString(R.string.set_name_socket1_blk3);
        name_socket2_blk3=getString(R.string.set_name_socket2_blk3);
        name_socket3_blk3=getString(R.string.set_name_socket3_blk3);
        name_socket4_blk3=getString(R.string.set_name_socket4_blk3);
        name_socket5_blk3=getString(R.string.set_name_socket5_blk3);
        name_socket6_blk3=getString(R.string.set_name_socket6_blk3);
        name_socket7_blk3=getString(R.string.set_name_socket7_blk3);
        name_socket8_blk3=getString(R.string.set_name_socket8_blk3);

        name_socket1_blk4=getString(R.string.set_name_socket1_blk4);
        name_socket2_blk4=getString(R.string.set_name_socket2_blk4);
        name_socket3_blk4=getString(R.string.set_name_socket3_blk4);
        name_socket4_blk4=getString(R.string.set_name_socket4_blk4);
        name_socket5_blk4=getString(R.string.set_name_socket5_blk4);
        name_socket6_blk4=getString(R.string.set_name_socket6_blk4);
        name_socket7_blk4=getString(R.string.set_name_socket7_blk4);
        name_socket8_blk4=getString(R.string.set_name_socket8_blk4);


        name_radio1=getString(R.string.set_name_radio1);
        name_radio2=getString(R.string.set_name_radio2);
        name_radio3=getString(R.string.set_name_radio3);
        name_radio4=getString(R.string.set_name_radio4);
        name_radio5=getString(R.string.set_name_radio5);
        name_radio6=getString(R.string.set_name_radio6);
        name_radio7=getString(R.string.set_name_radio7);
        name_radio8=getString(R.string.set_name_radio8);
        name_radio9=getString(R.string.set_name_radio9);
        name_radio10=getString(R.string.set_name_radio10);
        name_radio11=getString(R.string.set_name_radio11);
        name_radio12=getString(R.string.set_name_radio12);
        name_radio13=getString(R.string.set_name_radio13);
        name_radio14=getString(R.string.set_name_radio14);
        name_radio15=getString(R.string.set_name_radio15);
        name_radio16=getString(R.string.set_name_radio16);

        name_termo1=getString(R.string.set_name_termo1);
        name_termo2=getString(R.string.set_name_termo2);
        name_termo3=getString(R.string.set_name_termo3);
        name_termo4=getString(R.string.set_name_termo4);
        name_termo5=getString(R.string.set_name_termo5);
        name_termo6=getString(R.string.set_name_termo6);
        name_termo7=getString(R.string.set_name_termo7);
        name_termo8=getString(R.string.set_name_termo8);

        state_controller=getString(R.string.state_controller);


        EST = getString(R.string.EST);
        NET = getString(R.string.NET);
        update_time = getString(R.string.update_time);
        state_220v = getString(R.string.state_220v);
        state_arm = getString(R.string.state_arm);
        gsm_level = getString(R.string.gsm_level);
        RAZRYAD_AKKUM = getString(R.string.RAZRYAD_AKKUM);
        OUTPUT_ON = getString(R.string.OUTPUT_ON);
        OUTPUT_OFF = getString(R.string.OUTPUT_OFF);
        VKL = getString(R.string.VKL);
        VYKL = getString(R.string.VYKL);
        GROUP = getString(R.string.GROUP);
        NORMA = getString(R.string.NORMA);
        TREVOGA = getString(R.string.TREVOGA);
        KZ = getString(R.string.KZ);
        OBRIV = getString(R.string.OBRIV);
        VYSOKIJ = getString(R.string.VYSOKIJ);
        SREDNIJ = getString(R.string.SREDNIJ);
        NIZKIJ = getString(R.string.NIZKIJ);
        PANIKA = getString(R.string.PANIKA);
        ARM = getString(R.string.ARM);
        DISARM = getString(R.string.DISARM);
        HOME = getString(R.string.HOME);
        VSKRYTIE_DATCHIKA = getString(R.string.VSKRYTIE_DATCHIKA);
        RAZRIAD_BATTAREYKI = getString(R.string.RAZRIAD_BATTAREYKI);
        NET_TESTOVOGO_SIGNALA = getString(R.string.NET_TESTOVOGO_SIGNALA);
        VOSSTANOVLENIE = getString(R.string.VOSSTANOVLENIE);
        NARUSHENIE = getString(R.string.NARUSHENIE);
        TEMPERATURA = getString(R.string.TEMPERATURA);
        T_MIN = getString(R.string.T_MIN);
        T_MAX = getString(R.string.T_MAX);
        Enter_Phone_Password = getString(R.string.Enter_Phone_Password);
        Enter_Phone = getString(R.string.Enter_Phone);
        Enter_Password = getString(R.string.Enter_Password);
        Enter_IMEI = getString(R.string.Enter_IMEI);
        Enter_IMEI_Password = getString(R.string.Enter_IMEI_Password);




        // создаем BroadcastReceiver для приема данных с сервиса
        br_tcp = new BroadcastReceiver() {
            // действия при получении сообщений
            public void onReceive(Context context, Intent intent) {
            try {
                //int type = intent.getIntExtra(PARAM_TYPE, 0);
                //int data = intent.getIntExtra(PARAM_DATA, 0);
                String type = intent.getStringExtra(ClientThread.PARAM_TYPE);
                String data = intent.getStringExtra(ClientThread.PARAM_DATA);


                Log.d(TAG, "onReceive: type = " + type + ", data = " + data);
                // Ловим сообщения о наличии связи
                if (ClientThread.STATUS_CONNECTION.equals(type)) {

                    switch (data) {
                        case ClientThread.CONNECT_NO:
                            //btn_restart_connection.setBackgroundColor(COLOR_RED);
                            btn_restart_connection.setBackgroundResource(R.drawable.btn_red);
                            break;
                        case ClientThread.CONNECT_TO_SERVER:
                            //btn_restart_connection.setBackgroundColor(COLOR_YELLOW);
                            btn_restart_connection.setBackgroundResource(R.drawable.btn_yellow);
                            break;
                        case ClientThread.CONNECT_TO_DEVISE:
                            //btn_restart_connection.setBackgroundColor(COLOR_GREEN);
                            btn_restart_connection.setBackgroundResource(R.drawable.btn_green);
                            break;

                    }
                }

                // Ловим сообщения от прибора
                if (ClientThread.DEVICE_DATA.equals(type)) {
                    DoParsing(data);
                }

                if (ClientThread.SYSTEM_DATA.equals(type)) {
                    DoSystem(data);

                }
            }catch (Exception e) {
                e.printStackTrace();
            }
            }
        };
        // создаем фильтр для BroadcastReceiver
        IntentFilter intFilt = new IntentFilter(StartActivity.TCP_BROADCAST_TO_MAIN_ACTION);
        // регистрируем (включаем) BroadcastReceiver
        LocalBroadcastManager.getInstance(mContext).registerReceiver(br_tcp, intFilt);


        // создаем BroadcastReceiver для приема данных с sms_receiver (вариант через broadcast)
        br_sms = new BroadcastReceiver() {
            // действия при получении сообщений
            public void onReceive(Context context, Intent intent) {

                String message_text = intent.getStringExtra("message");
                String sender = intent.getStringExtra("sender");
                Log.d(TAG, "Main Activity SMS onReceive: sender = " + sender + ", message = " + message_text);
                sms_anal(message_text, sender);
            }
        };
        // создаем фильтр для BroadcastReceiver
        IntentFilter intFilt_sms = new IntentFilter(StartActivity.SMS_BROADCAST_TO_MAIN_ACTION);
        // регистрируем (включаем) BroadcastReceiver
        LocalBroadcastManager.getInstance(mContext).registerReceiver(br_sms, intFilt_sms);


        //----------- работа с файлом, содержащий настройки

        mSettings= getSharedPreferences(object_setting, Context.MODE_PRIVATE);


        //при старте считываем текущие IMEI и пароль
        if (mSettings.contains(APP_PREFERENCES_IMEI)) {
            IMEI = mSettings.getString(APP_PREFERENCES_IMEI, "");
            cur_IMEI=IMEI;
        }

        if (mSettings.contains(APP_PREFERENCES_SERVER)) {
            cur_Server = mSettings.getString(APP_PREFERENCES_SERVER, ClientThread.SERVER_INI);
        }

        if (mSettings.contains(APP_PREFERENCES_PORT)) {
            cur_Port = Integer.parseInt(mSettings.getString(APP_PREFERENCES_PORT, String.valueOf(ClientThread.SERVERPORT)));
        }

        if (mSettings.contains(APP_PREFERENCES_PASSWORD)) {
            PASSWORD = mSettings.getString(APP_PREFERENCES_PASSWORD, ini_password);
        }

        String connection="2";
        if (mSettings.contains(APP_PREFERENCES_CONNECTION)) {
            connection = mSettings.getString(APP_PREFERENCES_CONNECTION, "2");
        }

        if ("1".equals(connection)) {
            CONNECTION_POSITION=0;

        }
        if ("2".equals(connection)) {
            CONNECTION_POSITION=1;
        }

        btn_restart_connection= (Button) findViewById(R.id.btn_restart_connection);
        btn_send_command= (Button) findViewById(R.id.btn_send_command);
        btn_event_log= (Button) findViewById(R.id.btn_event_log);

        //btn_arm= (Button) findViewById(R.id.btn_arm);
        //btn_query= (Button) findViewById(R.id.btn_query);

        btn_output1= (Button) findViewById(R.id.btn_output1);
        btn_output2= (Button) findViewById(R.id.btn_output2);
        btn_output3= (Button) findViewById(R.id.btn_output3);
        btn_output4= (Button) findViewById(R.id.btn_output4);
        btn_output5= (Button) findViewById(R.id.btn_output5);
        btn_output6= (Button) findViewById(R.id.btn_output6);
        btn_output7= (Button) findViewById(R.id.btn_output7);
        btn_output8= (Button) findViewById(R.id.btn_output8);

        btn_output1_ext0= (Button) findViewById(R.id.btn_output1_ext0);
        btn_output2_ext0= (Button) findViewById(R.id.btn_output2_ext0);
        btn_output3_ext0= (Button) findViewById(R.id.btn_output3_ext0);
        btn_output4_ext0= (Button) findViewById(R.id.btn_output4_ext0);
        btn_output5_ext0= (Button) findViewById(R.id.btn_output5_ext0);
        btn_output6_ext0= (Button) findViewById(R.id.btn_output6_ext0);
        btn_output7_ext0= (Button) findViewById(R.id.btn_output7_ext0);
        btn_output8_ext0= (Button) findViewById(R.id.btn_output8_ext0);

        btn_output1_ext1= (Button) findViewById(R.id.btn_output1_ext1);
        btn_output2_ext1= (Button) findViewById(R.id.btn_output2_ext1);
        btn_output3_ext1= (Button) findViewById(R.id.btn_output3_ext1);
        btn_output4_ext1= (Button) findViewById(R.id.btn_output4_ext1);
        btn_output5_ext1= (Button) findViewById(R.id.btn_output5_ext1);
        btn_output6_ext1= (Button) findViewById(R.id.btn_output6_ext1);
        btn_output7_ext1= (Button) findViewById(R.id.btn_output7_ext1);
        btn_output8_ext1= (Button) findViewById(R.id.btn_output8_ext1);

        btn_output1_ext2= (Button) findViewById(R.id.btn_output1_ext2);
        btn_output2_ext2= (Button) findViewById(R.id.btn_output2_ext2);
        btn_output3_ext2= (Button) findViewById(R.id.btn_output3_ext2);
        btn_output4_ext2= (Button) findViewById(R.id.btn_output4_ext2);
        btn_output5_ext2= (Button) findViewById(R.id.btn_output5_ext2);
        btn_output6_ext2= (Button) findViewById(R.id.btn_output6_ext2);
        btn_output7_ext2= (Button) findViewById(R.id.btn_output7_ext2);
        btn_output8_ext2= (Button) findViewById(R.id.btn_output8_ext2);

        btn_output1_ext3= (Button) findViewById(R.id.btn_output1_ext3);
        btn_output2_ext3= (Button) findViewById(R.id.btn_output2_ext3);
        btn_output3_ext3= (Button) findViewById(R.id.btn_output3_ext3);
        btn_output4_ext3= (Button) findViewById(R.id.btn_output4_ext3);
        btn_output5_ext3= (Button) findViewById(R.id.btn_output5_ext3);
        btn_output6_ext3= (Button) findViewById(R.id.btn_output6_ext3);
        btn_output7_ext3= (Button) findViewById(R.id.btn_output7_ext3);
        btn_output8_ext3= (Button) findViewById(R.id.btn_output8_ext3);

        btn_output1_ext4= (Button) findViewById(R.id.btn_output1_ext4);
        btn_output2_ext4= (Button) findViewById(R.id.btn_output2_ext4);
        btn_output3_ext4= (Button) findViewById(R.id.btn_output3_ext4);
        btn_output4_ext4= (Button) findViewById(R.id.btn_output4_ext4);
        btn_output5_ext4= (Button) findViewById(R.id.btn_output5_ext4);
        btn_output6_ext4= (Button) findViewById(R.id.btn_output6_ext4);
        btn_output7_ext4= (Button) findViewById(R.id.btn_output7_ext4);
        btn_output8_ext4= (Button) findViewById(R.id.btn_output8_ext4);


        btn_socket1_blk1= (Button) findViewById(R.id.btn_socket1_blk1);
        btn_socket2_blk1= (Button) findViewById(R.id.btn_socket2_blk1);
        btn_socket3_blk1= (Button) findViewById(R.id.btn_socket3_blk1);
        btn_socket4_blk1= (Button) findViewById(R.id.btn_socket4_blk1);
        btn_socket5_blk1= (Button) findViewById(R.id.btn_socket5_blk1);
        btn_socket6_blk1= (Button) findViewById(R.id.btn_socket6_blk1);
        btn_socket7_blk1= (Button) findViewById(R.id.btn_socket7_blk1);
        btn_socket8_blk1= (Button) findViewById(R.id.btn_socket8_blk1);

        btn_socket1_blk2= (Button) findViewById(R.id.btn_socket1_blk2);
        btn_socket2_blk2= (Button) findViewById(R.id.btn_socket2_blk2);
        btn_socket3_blk2= (Button) findViewById(R.id.btn_socket3_blk2);
        btn_socket4_blk2= (Button) findViewById(R.id.btn_socket4_blk2);
        btn_socket5_blk2= (Button) findViewById(R.id.btn_socket5_blk2);
        btn_socket6_blk2= (Button) findViewById(R.id.btn_socket6_blk2);
        btn_socket7_blk2= (Button) findViewById(R.id.btn_socket7_blk2);
        btn_socket8_blk2= (Button) findViewById(R.id.btn_socket8_blk2);

        btn_socket1_blk3= (Button) findViewById(R.id.btn_socket1_blk3);
        btn_socket2_blk3= (Button) findViewById(R.id.btn_socket2_blk3);
        btn_socket3_blk3= (Button) findViewById(R.id.btn_socket3_blk3);
        btn_socket4_blk3= (Button) findViewById(R.id.btn_socket4_blk3);
        btn_socket5_blk3= (Button) findViewById(R.id.btn_socket5_blk3);
        btn_socket6_blk3= (Button) findViewById(R.id.btn_socket6_blk3);
        btn_socket7_blk3= (Button) findViewById(R.id.btn_socket7_blk3);
        btn_socket8_blk3= (Button) findViewById(R.id.btn_socket8_blk3);

        btn_socket1_blk4= (Button) findViewById(R.id.btn_socket1_blk4);
        btn_socket2_blk4= (Button) findViewById(R.id.btn_socket2_blk4);
        btn_socket3_blk4= (Button) findViewById(R.id.btn_socket3_blk4);
        btn_socket4_blk4= (Button) findViewById(R.id.btn_socket4_blk4);
        btn_socket5_blk4= (Button) findViewById(R.id.btn_socket5_blk4);
        btn_socket6_blk4= (Button) findViewById(R.id.btn_socket6_blk4);
        btn_socket7_blk4= (Button) findViewById(R.id.btn_socket7_blk4);
        btn_socket8_blk4= (Button) findViewById(R.id.btn_socket8_blk4);



        //checkBox_query = (CheckBox) findViewById(R.id.checkBox_query);
        imageButton_ON = (ImageButton) findViewById(R.id.imageButton_ON);
        imageButton_OFF = (ImageButton) findViewById(R.id.imageButton_OFF);
        imageButton_Query = (ImageButton) findViewById(R.id.imageButton_Query);
        imageView_power_off = (ImageView) findViewById(R.id.imageView_power_off);
        imageView_power_on = (ImageView) findViewById(R.id.imageView_power_on);
        imageView_power_ = (ImageView) findViewById(R.id.imageView_power_);
        imageView_arm_off = (ImageView) findViewById(R.id.imageView_arm_off);
        imageView_arm_on = (ImageView) findViewById(R.id.imageView_arm_on);
        imageView_arm_ = (ImageView) findViewById(R.id.imageView_arm_);
        imageView_GSM_high = (ImageView) findViewById(R.id.imageView_GSM_high);
        imageView_GSM_medium = (ImageView) findViewById(R.id.imageView_GSM_medium);
        imageView_GSM_low = (ImageView) findViewById(R.id.imageView_GSM_low);
        imageView_GSM_ = (ImageView) findViewById(R.id.imageView_GSM_);
        imageView_input_norma = (ImageView) findViewById(R.id.imageView_input_norma);
        imageView_input_trevoga = (ImageView) findViewById(R.id.imageView_input_trevoga);
        imageView_input_ = (ImageView) findViewById(R.id.imageView_input_);

        btn_query = (TextView) findViewById(R.id.textView_query);
        textView_power = (TextView) findViewById(R.id.textView_power);
        btn_arm = (TextView) findViewById(R.id.textView_arm);
        textView_gsm = (TextView) findViewById(R.id.textView_gsm);

        textView_in = (TextView) findViewById(R.id.textView_in);
        textView_tamper = (TextView) findViewById(R.id.textView_tamper);
        textView_input1 = (TextView) findViewById(R.id.textView_input1);
        textView_input2 = (TextView) findViewById(R.id.textView_input2);
        textView_input3 = (TextView) findViewById(R.id.textView_input3);
        textView_input4 = (TextView) findViewById(R.id.textView_input4);
        textView_input5 = (TextView) findViewById(R.id.textView_input5);
        textView_input6 = (TextView) findViewById(R.id.textView_input6);
        textView_input7 = (TextView) findViewById(R.id.textView_input7);
        textView_input8 = (TextView) findViewById(R.id.textView_input8);

        textView_input1_ext0 = (TextView) findViewById(R.id.textView_input1_ext0);
        textView_input2_ext0 = (TextView) findViewById(R.id.textView_input2_ext0);
        textView_input3_ext0 = (TextView) findViewById(R.id.textView_input3_ext0);
        textView_input4_ext0 = (TextView) findViewById(R.id.textView_input4_ext0);
        textView_input5_ext0 = (TextView) findViewById(R.id.textView_input5_ext0);
        textView_input6_ext0 = (TextView) findViewById(R.id.textView_input6_ext0);
        textView_input7_ext0 = (TextView) findViewById(R.id.textView_input7_ext0);
        textView_input8_ext0 = (TextView) findViewById(R.id.textView_input8_ext0);

        textView_input1_ext1 = (TextView) findViewById(R.id.textView_input1_ext1);
        textView_input2_ext1 = (TextView) findViewById(R.id.textView_input2_ext1);
        textView_input3_ext1 = (TextView) findViewById(R.id.textView_input3_ext1);
        textView_input4_ext1 = (TextView) findViewById(R.id.textView_input4_ext1);
        textView_input5_ext1 = (TextView) findViewById(R.id.textView_input5_ext1);
        textView_input6_ext1 = (TextView) findViewById(R.id.textView_input6_ext1);
        textView_input7_ext1 = (TextView) findViewById(R.id.textView_input7_ext1);
        textView_input8_ext1 = (TextView) findViewById(R.id.textView_input8_ext1);

        textView_input1_ext2 = (TextView) findViewById(R.id.textView_input1_ext2);
        textView_input2_ext2 = (TextView) findViewById(R.id.textView_input2_ext2);
        textView_input3_ext2 = (TextView) findViewById(R.id.textView_input3_ext2);
        textView_input4_ext2 = (TextView) findViewById(R.id.textView_input4_ext2);
        textView_input5_ext2 = (TextView) findViewById(R.id.textView_input5_ext2);
        textView_input6_ext2 = (TextView) findViewById(R.id.textView_input6_ext2);
        textView_input7_ext2 = (TextView) findViewById(R.id.textView_input7_ext2);
        textView_input8_ext2 = (TextView) findViewById(R.id.textView_input8_ext2);


        textView_input1_ext3 = (TextView) findViewById(R.id.textView_input1_ext3);
        textView_input2_ext3 = (TextView) findViewById(R.id.textView_input2_ext3);
        textView_input3_ext3 = (TextView) findViewById(R.id.textView_input3_ext3);
        textView_input4_ext3 = (TextView) findViewById(R.id.textView_input4_ext3);
        textView_input5_ext3 = (TextView) findViewById(R.id.textView_input5_ext3);
        textView_input6_ext3 = (TextView) findViewById(R.id.textView_input6_ext3);
        textView_input7_ext3 = (TextView) findViewById(R.id.textView_input7_ext3);
        textView_input8_ext3 = (TextView) findViewById(R.id.textView_input8_ext3);

        textView_input1_ext4 = (TextView) findViewById(R.id.textView_input1_ext4);
        textView_input2_ext4 = (TextView) findViewById(R.id.textView_input2_ext4);
        textView_input3_ext4 = (TextView) findViewById(R.id.textView_input3_ext4);
        textView_input4_ext4 = (TextView) findViewById(R.id.textView_input4_ext4);
        textView_input5_ext4 = (TextView) findViewById(R.id.textView_input5_ext4);
        textView_input6_ext4 = (TextView) findViewById(R.id.textView_input6_ext4);
        textView_input7_ext4 = (TextView) findViewById(R.id.textView_input7_ext4);
        textView_input8_ext4 = (TextView) findViewById(R.id.textView_input8_ext4);


        textView_out = (TextView) findViewById(R.id.textView_out);

        textView_wr = (TextView) findViewById(R.id.textView_wr);
        textView_radio1 = (TextView) findViewById(R.id.textView_radio1);
        textView_radio2 = (TextView) findViewById(R.id.textView_radio2);
        textView_radio3 = (TextView) findViewById(R.id.textView_radio3);
        textView_radio4 = (TextView) findViewById(R.id.textView_radio4);
        textView_radio5 = (TextView) findViewById(R.id.textView_radio5);
        textView_radio6 = (TextView) findViewById(R.id.textView_radio6);
        textView_radio7 = (TextView) findViewById(R.id.textView_radio7);
        textView_radio8 = (TextView) findViewById(R.id.textView_radio8);
        textView_radio9 = (TextView) findViewById(R.id.textView_radio9);
        textView_radio10 = (TextView) findViewById(R.id.textView_radio10);
        textView_radio11 = (TextView) findViewById(R.id.textView_radio11);
        textView_radio12 = (TextView) findViewById(R.id.textView_radio12);
        textView_radio13 = (TextView) findViewById(R.id.textView_radio13);
        textView_radio14 = (TextView) findViewById(R.id.textView_radio14);
        textView_radio15 = (TextView) findViewById(R.id.textView_radio15);
        textView_radio16 = (TextView) findViewById(R.id.textView_radio16);

        textView_t = (TextView) findViewById(R.id.textView_t);
        textView_termo1 = (TextView) findViewById(R.id.textView_termo1);
        textView_termo2 = (TextView) findViewById(R.id.textView_termo2);
        textView_termo3 = (TextView) findViewById(R.id.textView_termo3);
        textView_termo4 = (TextView) findViewById(R.id.textView_termo4);
        textView_termo5 = (TextView) findViewById(R.id.textView_termo5);
        textView_termo6 = (TextView) findViewById(R.id.textView_termo6);
        textView_termo7 = (TextView) findViewById(R.id.textView_termo7);
        textView_termo8 = (TextView) findViewById(R.id.textView_termo8);
        textView_controller=(TextView) findViewById(R.id.textView_controller);

        spinner = (Spinner) findViewById(R.id.spinner);


        read_name();

        //-------------


        //обратотка входящей смс от StartActivity
        String message_text = intent.getStringExtra("message");
        String sender = intent.getStringExtra("sender");
        String type = intent.getStringExtra(ClientThread.PARAM_TYPE);
        String data = intent.getStringExtra(ClientThread.PARAM_DATA);
        //get internet packet
        if (ClientThread.DEVICE_DATA.equals(type)) {
            DoParsing(data);
        }

        if (ClientThread.SYSTEM_DATA.equals(type)) {
            DoSystem(data);
        }
        //check sms
        sms_anal(message_text,sender);
        //--------------------------------


//--------------------------- обработчик события нажатия кнопки
        imageButton_Query.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //
                //Log.d(TAG, "Нажата кнопка Query");
                //try_sendSMS(Query);
                Log.d(TAG, "Нажата кнопка Query");

                //проигрываем файл
                Play_Key_Pressed();


                if (CONNECTION_POSITION==0) try_sendSMS(Query);

                if(CONNECTION_POSITION==1) try_send_to_server(Query_server, false);

            }
        });

//--------------------------- обработчик события нажатия кнопки
        imageButton_ON.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Log.d(TAG, "Нажата кнопка ARM ON");


                //проигрываем файл
                Play_Key_Pressed();


                if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                    if (CONNECTION_POSITION == 0) try_sendSMS(Arm_on + "," + Query);
                    if (CONNECTION_POSITION == 1)
                        try_send_to_server(Arm_on + "," + Query_server, false);
                } else {
                    if (CONNECTION_POSITION == 0) try_sendSMS(Arm_on);
                    if (CONNECTION_POSITION == 1) try_send_to_server(Arm_on, false);
                }

            }
        });
//-------------------------------------------


//--------------------------- обработчик события нажатия кнопки
        imageButton_OFF.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Log.d(TAG, "Нажата кнопка ARM OFF");

                //проигрываем файл
                Play_Key_Pressed();

                if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                    if (CONNECTION_POSITION == 0) try_sendSMS(Arm_off + "," + Query);
                    if (CONNECTION_POSITION == 1)
                        try_send_to_server(Arm_off + "," + Query_server, false);
                } else {
                    if (CONNECTION_POSITION == 0) try_sendSMS(Arm_off);
                    if (CONNECTION_POSITION == 1) try_send_to_server(Arm_off, false);
                }

            }
        });
//-------------------------------------------

        //******* fault click events
        imageView_power_.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //проигрываем файл
                Play_Fault_Pressed();
            }
        });
        imageView_power_on.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //проигрываем файл
                Play_Fault_Pressed();
            }
        });
        imageView_power_off.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //проигрываем файл
                Play_Fault_Pressed();
            }
        });
        imageView_arm_.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //проигрываем файл
                Play_Fault_Pressed();
            }
        });
        imageView_arm_on.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //проигрываем файл
                Play_Fault_Pressed();
                /*
                try {
                    Play_Key_Pressed();

                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Arm_off + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Arm_off + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Arm_off);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Arm_off, false);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                */
            }
        });
        imageView_arm_off.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //проигрываем файл
                Play_Fault_Pressed();
                /*
                try {
                    Play_Key_Pressed();

                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Arm_on + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Arm_on + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Arm_on);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Arm_on, false);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                */
            }
        });
        imageView_GSM_.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //проигрываем файл
                Play_Fault_Pressed();
            }
        });
        imageView_GSM_high.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //проигрываем файл
                Play_Fault_Pressed();
            }
        });
        imageView_GSM_medium.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //проигрываем файл
                Play_Fault_Pressed();
            }
        });
        imageView_GSM_low.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //проигрываем файл
                Play_Fault_Pressed();
            }
        });
        imageView_input_.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //проигрываем файл
                Play_Fault_Pressed();
            }
        });
        imageView_input_norma.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //проигрываем файл
                Play_Fault_Pressed();
            }
        });
        imageView_input_trevoga.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //проигрываем файл
                Play_Fault_Pressed();
            }
        });

//--------------------------- обработчик события нажатия кнопки
        /*
        checkBox_query.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                SharedPreferences.Editor editor = mSettings.edit();
                if (checkBox_query.isChecked()) {
                    editor.putString(APP_PREFERENCES_CHECK_BOX_QUERY,"check");
                } else {
                    editor.putString(APP_PREFERENCES_CHECK_BOX_QUERY,"uncheck");

                }
                editor.commit();
            }
        });
        */
//-------------------------------------------

/*
        //--------------------------- выпадающий список способа управления
        String[] data_connection = {
                Connection_1,
                Connection_2};
        String temp;

        // адаптер
        ArrayAdapter<String> adapter_connection = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, data_connection);
        adapter_connection.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        Spinner spinner_connection = (Spinner) findViewById(R.id.spinner_connection);
        spinner_connection.setAdapter(adapter_connection);
        // заголовок
        spinner_connection.setPrompt("Список способов управления");

        //btn_restart_connection.setBackgroundColor(COLOR_RED);
        btn_restart_connection.setBackgroundResource(R.drawable.btn_red);
        // выделяем элемент
        spinner_connection.setSelection(1);

        if (mSettings.contains(APP_PREFERENCES_CONNECTION)) {
            temp = mSettings.getString(APP_PREFERENCES_CONNECTION, "internet");
            if (temp.equals("sms")) {
                spinner_connection.setSelection(0);
            }
            if (temp.equals("internet")) {
                spinner_connection.setSelection(1);
            }

        }



        // устанавливаем обработчик нажатия
        spinner_connection.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view,
                                       int position, long id) {
                // показываем позицию нажатого элемента
                //Toast.makeText(getBaseContext(), "Position = " + position, Toast.LENGTH_SHORT).show();
                SharedPreferences.Editor editor = mSettings.edit();
                //String temp = mSettings.getString(APP_PREFERENCES_SERVICE, "0");
                CONNECTION_POSITION = position;
                switch (CONNECTION_POSITION) {
                    case 0:
                        editor.putString(APP_PREFERENCES_CONNECTION, "sms");

                        //STOP TCP_client
                        new Thread(new Runnable() {
                            public void run() {
                                try {
                                    Stop_Service();
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        }).start();

                        //btn_restart_connection.setBackgroundColor(COLOR_RED);
                        btn_restart_connection.setBackgroundResource(R.drawable.btn_red);

                        //editor.putString(APP_PREFERENCES_SERVICE, "0");
                        btn_restart_connection.setVisibility(View.INVISIBLE);
                        break;
                    case 1:
                        editor.putString(APP_PREFERENCES_CONNECTION, "internet");
                        //if ("0".equals(temp)) {

                        if ( ! isMyServiceRunning(oko.tm.oko_pro_classic.TCP_client.class)) {
                             new Thread(new Runnable() {
                                public void run() {
                                    try {
                                        startService(new Intent(mContext, TCP_client.class)); //запускаем сервис для супервижинга IP-соединения
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            }).start();

                            //editor.putString(APP_PREFERENCES_SERVICE, "1");
                            btn_restart_connection.setVisibility(View.VISIBLE);
                        }
                        break;

                }
                editor.commit();
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
            }
        });

*/


        //--------------------------------------------------------
//--------------------------- обработчик события нажатия кнопки
        btn_event_log.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Log.d(TAG, "Нажата кнопка Event Log");

            try {
                //проигрываем файл
                Play_Key_Pressed();

                Intent intent = new Intent(mContext, EventLog.class);
                intent.putExtra(StartActivity.OBJECT_SETTING, object_setting);
                intent.putExtra(StartActivity.OBJECT_NAME, object_name);
                startActivity(intent);
                //return true;
            } catch (Exception e) {
                e.printStackTrace();
            }
            }
        });
//-------------------------------------------



//--------------------------- обработчик события нажатия кнопки
        /*
        btn_query.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {

                    //проигрываем файл
                    Play_Key_Pressed();


                    if (CONNECTION_POSITION==0) try_sendSMS(Query);

                    if(CONNECTION_POSITION==1) try_send_to_server(Query_server, false);

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        */

        /*
        btn_arm.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {

                    String command=Arm_on;
                    String temp="";
                    //проигрываем файл
                    Play_Key_Pressed();
                    temp=btn_arm.getText().toString();

                    if (temp.indexOf(VKL)>-1)
                    {
                        command=Arm_off;
                    }
                    if (temp.indexOf(VYKL)>-1)
                    {
                        command=Arm_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        */


        btn_output1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output = state_output1;
                    String Out_on = Out1_on;
                    String Out_off = Out1_off;

                    if (protocol.equals("2")) {
                        Out_on = OKO_S2_Out1_on;
                        Out_off = OKO_S2_Out1_off;
                    }
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            // Click event trigger here
                try {
                    String state_output=state_output2;
                    String Out_on=Out2_on;
                    String Out_off=Out2_off;

                    if (protocol.equals("2")) {
                        Out_on = OKO_S2_Out2_on;
                        Out_off = OKO_S2_Out2_off;
                    }

                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output3;
                    String Out_on=Out3_on;
                    String Out_off=Out3_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output4;
                    String Out_on=Out4_on;
                    String Out_off=Out4_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output5.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output5;
                    String Out_on=Out5_on;
                    String Out_off=Out5_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output6.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output6;
                    String Out_on=Out6_on;
                    String Out_off=Out6_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output7.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output7;
                    String Out_on=Out7_on;
                    String Out_off=Out7_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output8.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output8;
                    String Out_on=Out8_on;
                    String Out_off=Out8_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //extension-0 output
        btn_output1_ext0.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output1_ext0;
                    String Out_on=Ext0_Out1_on;
                    String Out_off=Ext0_Out1_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output2_ext0.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output2_ext0;
                    String Out_on=Ext0_Out2_on;
                    String Out_off=Ext0_Out2_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });


        btn_output3_ext0.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output3_ext0;
                    String Out_on=Ext0_Out3_on;
                    String Out_off=Ext0_Out3_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output4_ext0.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output4_ext0;
                    String Out_on=Ext0_Out4_on;
                    String Out_off=Ext0_Out4_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output5_ext0.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output5_ext0;
                    String Out_on=Ext0_Out5_on;
                    String Out_off=Ext0_Out5_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output6_ext0.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output6_ext0;
                    String Out_on=Ext0_Out6_on;
                    String Out_off=Ext0_Out6_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output7_ext0.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output7_ext0;
                    String Out_on=Ext0_Out7_on;
                    String Out_off=Ext0_Out7_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output8_ext0.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output8_ext0;
                    String Out_on=Ext0_Out8_on;
                    String Out_off=Ext0_Out8_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });


        //extension output
        btn_output1_ext1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output1_ext1;
                    String Out_on=Ext1_Out1_on;
                    String Out_off=Ext1_Out1_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output2_ext1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output2_ext1;
                    String Out_on=Ext1_Out2_on;
                    String Out_off=Ext1_Out2_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });


        btn_output3_ext1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output3_ext1;
                    String Out_on=Ext1_Out3_on;
                    String Out_off=Ext1_Out3_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output4_ext1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output4_ext1;
                    String Out_on=Ext1_Out4_on;
                    String Out_off=Ext1_Out4_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output5_ext1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output5_ext1;
                    String Out_on=Ext1_Out5_on;
                    String Out_off=Ext1_Out5_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output6_ext1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output6_ext1;
                    String Out_on=Ext1_Out6_on;
                    String Out_off=Ext1_Out6_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output7_ext1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output7_ext1;
                    String Out_on=Ext1_Out7_on;
                    String Out_off=Ext1_Out7_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output8_ext1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output8_ext1;
                    String Out_on=Ext1_Out8_on;
                    String Out_off=Ext1_Out8_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //ext2
        btn_output1_ext2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output1_ext2;
                    String Out_on=Ext2_Out1_on;
                    String Out_off=Ext2_Out1_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output2_ext2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output2_ext2;
                    String Out_on=Ext2_Out2_on;
                    String Out_off=Ext2_Out2_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });


        btn_output3_ext2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output3_ext2;
                    String Out_on=Ext2_Out3_on;
                    String Out_off=Ext2_Out3_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output4_ext2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output4_ext2;
                    String Out_on=Ext2_Out4_on;
                    String Out_off=Ext2_Out4_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output5_ext2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output5_ext2;
                    String Out_on=Ext2_Out5_on;
                    String Out_off=Ext2_Out5_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output6_ext2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output6_ext2;
                    String Out_on=Ext2_Out6_on;
                    String Out_off=Ext2_Out6_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output7_ext2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output7_ext2;
                    String Out_on=Ext2_Out7_on;
                    String Out_off=Ext2_Out7_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output8_ext2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output8_ext2;
                    String Out_on=Ext2_Out8_on;
                    String Out_off=Ext2_Out8_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //ext3
        btn_output1_ext3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output1_ext3;
                    String Out_on=Ext3_Out1_on;
                    String Out_off=Ext3_Out1_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output2_ext3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output2_ext3;
                    String Out_on=Ext3_Out2_on;
                    String Out_off=Ext3_Out2_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });


        btn_output3_ext3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output3_ext3;
                    String Out_on=Ext3_Out3_on;
                    String Out_off=Ext3_Out3_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output4_ext3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output4_ext3;
                    String Out_on=Ext3_Out4_on;
                    String Out_off=Ext3_Out4_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output5_ext3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output5_ext3;
                    String Out_on=Ext3_Out5_on;
                    String Out_off=Ext3_Out5_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output6_ext3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output6_ext3;
                    String Out_on=Ext3_Out6_on;
                    String Out_off=Ext3_Out6_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output7_ext3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output7_ext3;
                    String Out_on=Ext3_Out7_on;
                    String Out_off=Ext3_Out7_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output8_ext3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output8_ext3;
                    String Out_on=Ext3_Out8_on;
                    String Out_off=Ext3_Out8_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //ext4
        btn_output1_ext4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output1_ext4;
                    String Out_on=Ext4_Out1_on;
                    String Out_off=Ext4_Out1_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output2_ext4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output2_ext4;
                    String Out_on=Ext4_Out2_on;
                    String Out_off=Ext4_Out2_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });


        btn_output3_ext4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output3_ext4;
                    String Out_on=Ext4_Out3_on;
                    String Out_off=Ext4_Out3_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output4_ext4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output4_ext4;
                    String Out_on=Ext4_Out4_on;
                    String Out_off=Ext4_Out4_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_output5_ext4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output5_ext4;
                    String Out_on=Ext4_Out5_on;
                    String Out_off=Ext4_Out5_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output6_ext4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output6_ext4;
                    String Out_on=Ext4_Out6_on;
                    String Out_off=Ext4_Out6_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output7_ext4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output7_ext4;
                    String Out_on=Ext4_Out7_on;
                    String Out_off=Ext4_Out7_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        btn_output8_ext4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_output8_ext4;
                    String Out_on=Ext4_Out8_on;
                    String Out_off=Ext4_Out8_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //radio sockets
        //blk1
        btn_socket1_blk1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket1_blk1;
                    String Out_on=Blk1_Socket1_on;
                    String Out_off=Blk1_Socket1_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket2_blk1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket2_blk1;
                    String Out_on=Blk1_Socket2_on;
                    String Out_off=Blk1_Socket2_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket3_blk1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket3_blk1;
                    String Out_on=Blk1_Socket3_on;
                    String Out_off=Blk1_Socket3_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket4_blk1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket4_blk1;
                    String Out_on=Blk1_Socket4_on;
                    String Out_off=Blk1_Socket4_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket5_blk1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket5_blk1;
                    String Out_on=Blk1_Socket5_on;
                    String Out_off=Blk1_Socket5_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket6_blk1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket6_blk1;
                    String Out_on=Blk1_Socket6_on;
                    String Out_off=Blk1_Socket6_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket7_blk1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket7_blk1;
                    String Out_on=Blk1_Socket7_on;
                    String Out_off=Blk1_Socket7_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket8_blk1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket8_blk1;
                    String Out_on=Blk1_Socket8_on;
                    String Out_off=Blk1_Socket8_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //blk2
        btn_socket1_blk2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket1_blk2;
                    String Out_on=Blk2_Socket1_on;
                    String Out_off=Blk2_Socket1_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket2_blk2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket2_blk2;
                    String Out_on=Blk2_Socket2_on;
                    String Out_off=Blk2_Socket2_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket3_blk2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket3_blk2;
                    String Out_on=Blk2_Socket3_on;
                    String Out_off=Blk2_Socket3_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket4_blk2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket4_blk2;
                    String Out_on=Blk2_Socket4_on;
                    String Out_off=Blk2_Socket4_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket5_blk2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket5_blk2;
                    String Out_on=Blk2_Socket5_on;
                    String Out_off=Blk2_Socket5_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket6_blk2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket6_blk2;
                    String Out_on=Blk2_Socket6_on;
                    String Out_off=Blk2_Socket6_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket7_blk2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket7_blk2;
                    String Out_on=Blk2_Socket7_on;
                    String Out_off=Blk2_Socket7_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket8_blk2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket8_blk2;
                    String Out_on=Blk2_Socket8_on;
                    String Out_off=Blk2_Socket8_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //blk3
        btn_socket1_blk3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket1_blk3;
                    String Out_on=Blk3_Socket1_on;
                    String Out_off=Blk3_Socket1_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket2_blk3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket2_blk3;
                    String Out_on=Blk3_Socket2_on;
                    String Out_off=Blk3_Socket2_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket3_blk3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket3_blk3;
                    String Out_on=Blk3_Socket3_on;
                    String Out_off=Blk3_Socket3_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket4_blk3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket4_blk3;
                    String Out_on=Blk3_Socket4_on;
                    String Out_off=Blk3_Socket4_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket5_blk3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket5_blk3;
                    String Out_on=Blk3_Socket5_on;
                    String Out_off=Blk3_Socket5_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket6_blk3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket6_blk3;
                    String Out_on=Blk3_Socket6_on;
                    String Out_off=Blk3_Socket6_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket7_blk3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket7_blk3;
                    String Out_on=Blk3_Socket7_on;
                    String Out_off=Blk3_Socket7_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket8_blk3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket8_blk3;
                    String Out_on=Blk3_Socket8_on;
                    String Out_off=Blk3_Socket8_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //blk4
        btn_socket1_blk4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket1_blk4;
                    String Out_on=Blk4_Socket1_on;
                    String Out_off=Blk4_Socket1_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket2_blk4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket2_blk4;
                    String Out_on=Blk4_Socket2_on;
                    String Out_off=Blk4_Socket2_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket3_blk4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket3_blk4;
                    String Out_on=Blk4_Socket3_on;
                    String Out_off=Blk4_Socket3_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket4_blk4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket4_blk4;
                    String Out_on=Blk4_Socket4_on;
                    String Out_off=Blk4_Socket4_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket5_blk4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket5_blk4;
                    String Out_on=Blk4_Socket5_on;
                    String Out_off=Blk4_Socket5_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket6_blk4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket6_blk4;
                    String Out_on=Blk4_Socket6_on;
                    String Out_off=Blk4_Socket6_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket7_blk4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket7_blk4;
                    String Out_on=Blk4_Socket7_on;
                    String Out_off=Blk4_Socket7_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        btn_socket8_blk4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Click event trigger here
                try {
                    String state_output=state_socket8_blk4;
                    String Out_on=Blk4_Socket8_on;
                    String Out_off=Blk4_Socket8_off;
                    String Out_command=Out_on;

                    //проигрываем файл
                    Play_Key_Pressed();

                    if (state_output.indexOf(separation + OUTPUT_ON)>-1)
                    {
                        Out_command=Out_off;
                    }
                    if (state_output.indexOf(separation + OUTPUT_OFF)>-1)
                    {
                        Out_command=Out_on;
                    }

                    //toggle output
                    if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command + "," + Query);
                        if (CONNECTION_POSITION == 1)
                            try_send_to_server(Out_command + "," + Query_server, false);
                    } else {
                        if (CONNECTION_POSITION == 0) try_sendSMS(Out_command);
                        if (CONNECTION_POSITION == 1) try_send_to_server(Out_command, false);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });





        btn_restart_connection.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                if (!Service_Restart) {

                    btn_restart_connection.setBackgroundResource(R.drawable.btn_red);
                    //проигрываем файл
                    Play_Key_Pressed();
                    new Thread(new Runnable() {
                        public void run() {
                            try {
                                Reset_Connection();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }

                        }
                    }).start();
                }
            }
        });
//-------------------------------------------------------


        if (isMyServiceRunning(oko.tm.oko_pro_classic.TCP_client.class) && CONNECTION_POSITION==1) try_send_to_server("", false);

        //VIEW MAP CODE
        /**
        try {
            Bundle mapViewBundle = null;
            if (savedInstanceState != null) {
                mapViewBundle = savedInstanceState.getBundle(MAP_VIEW_BUNDLE_KEY);
            }

            mapView = findViewById(R.id.map_view);
            mapView.onCreate(mapViewBundle);
            mapView.getMapAsync(this);
        } catch (Exception e) {

        }
         */

    }
/*
    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        try {
            Bundle mapViewBundle = outState.getBundle(MAP_VIEW_BUNDLE_KEY);
            if (mapViewBundle == null) {
                mapViewBundle = new Bundle();
                outState.putBundle(MAP_VIEW_BUNDLE_KEY, mapViewBundle);
            }

            mapView.onSaveInstanceState(mapViewBundle);
        } catch (Exception e) {

        }
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        mapView.onLowMemory();
    }

    @Override
    public void onMapReady(GoogleMap googleMap) {
        try {
            Toast.makeText(mContext, "onMapReady", Toast.LENGTH_LONG).show();
            gmap = googleMap;
            gmap.setMinZoomPreference(12);
            LatLng ny = new LatLng(50.4539, 30.429);
            gmap.moveCamera(CameraUpdateFactory.newLatLng(ny));
        } catch (Exception e) {

        }
    }
*/


    //проверка запущен или нет сервис  - для проверки isMyServiceRunning(MyService.class)
    private boolean isMyServiceRunning(Class<?> serviceClass) {
        ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
            if (serviceClass.getName().equals(service.service.getClassName())) {
                return true;
            }
        }
        return false;
    }


    private void Stop_Service(){
        Service_Restart=true;
        try{
            //STOP TCP-client service
            if ( isMyServiceRunning(oko.tm.oko_pro_classic.TCP_client.class)) {
                Client_Thread_stop = false;
                Periodic_Thread_stop = false;
                stopService(new Intent(mContext, TCP_client.class));
                try_send_to_server("", true);
                int timeout = ClientThread.WAIT_SERVER_ANSWER;
                while (timeout != 0 && !(Client_Thread_stop && Periodic_Thread_stop)) {
                    Thread.currentThread();
                    try {
                        Thread.sleep(1000); //1 second
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    timeout--;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        Service_Restart=false;
    }
    //reconnect to server
    private void Reset_Connection(){

        Stop_Service();

        Service_Restart=true;

        //START SERVICE TCP-SOCKET COMMUNICATION
        new Thread(new Runnable() {
            public void run() {
                try {
                    startService(new Intent(mContext, TCP_client.class)); //запускаем сервис для работы через IP в отдельном потоке
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }
        }).start();

        Service_Restart=false;
    }


    @Override
    public void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        //mapView.onResume();

        Log.d(TAG, "MainActivity onResume");

        String temp;



        //-------------восстанавливаем сохраненные настройки, данные

        if (mSettings.contains(APP_PREFERENCES_PROTOCOL)) {
            protocol = mSettings.getString(APP_PREFERENCES_PROTOCOL, "1");
        }

        if (mSettings.contains(APP_PREFERENCES_PHONE)) {
            PHONE_NUMBER = mSettings.getString(APP_PREFERENCES_PHONE, "");
        }

        if (mSettings.contains(APP_PREFERENCES_IMEI)) {
            IMEI = mSettings.getString(APP_PREFERENCES_IMEI, "");
        }

        if (mSettings.contains(APP_PREFERENCES_PASSWORD)) {
            PASSWORD = mSettings.getString(APP_PREFERENCES_PASSWORD, ini_password);
        }

        if (mSettings.contains(APP_PREFERENCES_QUERY)) {
            btn_query.setText(mSettings.getString(APP_PREFERENCES_QUERY, update_time));
        }

        if (mSettings.contains(APP_PREFERENCES_POWER)) {
            textView_power.setText(mSettings.getString(APP_PREFERENCES_POWER, state_220v));
        }

        if (mSettings.contains(APP_PREFERENCES_ARM)) {
            btn_arm.setText(mSettings.getString(APP_PREFERENCES_ARM, state_arm));
        }

        if (mSettings.contains(APP_PREFERENCES_GSM)) {
            textView_gsm.setText(mSettings.getString(APP_PREFERENCES_GSM, gsm_level));
        }

        read_name();

        if (mSettings.contains(APP_PREFERENCES_TAMPER)) {
            state_tamper= mSettings.getString(APP_PREFERENCES_TAMPER, state_tamper);
        }
        textView_tamper.setText(name_tamper + state_tamper);

        if (mSettings.contains(APP_PREFERENCES_INPUT1)) {
            state_input1= mSettings.getString(APP_PREFERENCES_INPUT1, state_input1);
        }
        textView_input1.setText(name_input1 + state_input1);


        if (mSettings.contains(APP_PREFERENCES_INPUT2)) {
            state_input2= mSettings.getString(APP_PREFERENCES_INPUT2, state_input2);
        }
        textView_input2.setText(name_input2+state_input2);

        if (mSettings.contains(APP_PREFERENCES_INPUT3)) {
            state_input3= mSettings.getString(APP_PREFERENCES_INPUT3, state_input3);
        }
        textView_input3.setText(name_input3+state_input3);

        if (mSettings.contains(APP_PREFERENCES_INPUT4)) {
            state_input4= mSettings.getString(APP_PREFERENCES_INPUT4, state_input4);
        }
        textView_input4.setText(name_input4+state_input4);

        if (mSettings.contains(APP_PREFERENCES_INPUT5)) {
            state_input5= mSettings.getString(APP_PREFERENCES_INPUT5, state_input5);
        }
        textView_input5.setText(name_input5+state_input5);

        if (mSettings.contains(APP_PREFERENCES_INPUT6)) {
            state_input6= mSettings.getString(APP_PREFERENCES_INPUT6, state_input6);
        }
        textView_input6.setText(name_input6 + state_input6);

        //for test
        //textView_input6.setVisibility(View.INVISIBLE);

        if (mSettings.contains(APP_PREFERENCES_INPUT7)) {
            state_input7= mSettings.getString(APP_PREFERENCES_INPUT7, state_input7);
        }
        textView_input7.setText(name_input7+state_input7);

        //for test
        //RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) textView_input7.getLayoutParams();
        //lp.addRule(RelativeLayout.BELOW, R.id.textView_input5);
        //textView_input7.setLayoutParams(lp);

        if (mSettings.contains(APP_PREFERENCES_INPUT8)) {
            state_input8= mSettings.getString(APP_PREFERENCES_INPUT8, state_input8);
        }
        textView_input8.setText(name_input8+state_input8);

        //ext0
        if (mSettings.contains(APP_PREFERENCES_INPUT1_EXT0)) {
            state_input1_ext0= mSettings.getString(APP_PREFERENCES_INPUT1_EXT0, state_input1_ext0);
        }
        textView_input1_ext0.setText(name_input1_ext0 + state_input1_ext0);


        if (mSettings.contains(APP_PREFERENCES_INPUT2_EXT0)) {
            state_input2_ext0= mSettings.getString(APP_PREFERENCES_INPUT2_EXT0, state_input2_ext0);
        }
        textView_input2_ext0.setText(name_input2_ext0+state_input2_ext0);

        if (mSettings.contains(APP_PREFERENCES_INPUT3_EXT0)) {
            state_input3_ext0= mSettings.getString(APP_PREFERENCES_INPUT3_EXT0, state_input3_ext0);
        }
        textView_input3_ext0.setText(name_input3_ext0+state_input3_ext0);

        if (mSettings.contains(APP_PREFERENCES_INPUT4_EXT0)) {
            state_input4_ext0= mSettings.getString(APP_PREFERENCES_INPUT4_EXT0, state_input4_ext0);
        }
        textView_input4_ext0.setText(name_input4_ext0+state_input4_ext0);

        if (mSettings.contains(APP_PREFERENCES_INPUT5_EXT0)) {
            state_input5_ext0= mSettings.getString(APP_PREFERENCES_INPUT5_EXT0, state_input5_ext0);
        }
        textView_input5_ext0.setText(name_input5_ext0+state_input5_ext0);

        if (mSettings.contains(APP_PREFERENCES_INPUT6_EXT0)) {
            state_input6_ext0= mSettings.getString(APP_PREFERENCES_INPUT6_EXT0, state_input6_ext0);
        }
        textView_input6_ext0.setText(name_input6_ext0 + state_input6_ext0);


        if (mSettings.contains(APP_PREFERENCES_INPUT7_EXT0)) {
            state_input7_ext0= mSettings.getString(APP_PREFERENCES_INPUT7_EXT0, state_input7_ext0);
        }
        textView_input7_ext0.setText(name_input7_ext0+state_input7_ext0);


        if (mSettings.contains(APP_PREFERENCES_INPUT8_EXT0)) {
            state_input8_ext0= mSettings.getString(APP_PREFERENCES_INPUT8_EXT0, state_input8_ext0);
        }
        textView_input8_ext0.setText(name_input8_ext0+state_input8_ext0);

        //ext1
        if (mSettings.contains(APP_PREFERENCES_INPUT1_EXT1)) {
            state_input1_ext1= mSettings.getString(APP_PREFERENCES_INPUT1_EXT1, state_input1_ext1);
        }
        textView_input1_ext1.setText(name_input1_ext1 + state_input1_ext1);


        if (mSettings.contains(APP_PREFERENCES_INPUT2_EXT1)) {
            state_input2_ext1= mSettings.getString(APP_PREFERENCES_INPUT2_EXT1, state_input2_ext1);
        }
        textView_input2_ext1.setText(name_input2_ext1+state_input2_ext1);

        if (mSettings.contains(APP_PREFERENCES_INPUT3_EXT1)) {
            state_input3_ext1= mSettings.getString(APP_PREFERENCES_INPUT3_EXT1, state_input3_ext1);
        }
        textView_input3_ext1.setText(name_input3_ext1+state_input3_ext1);

        if (mSettings.contains(APP_PREFERENCES_INPUT4_EXT1)) {
            state_input4_ext1= mSettings.getString(APP_PREFERENCES_INPUT4_EXT1, state_input4_ext1);
        }
        textView_input4_ext1.setText(name_input4_ext1+state_input4_ext1);

        if (mSettings.contains(APP_PREFERENCES_INPUT5_EXT1)) {
            state_input5_ext1= mSettings.getString(APP_PREFERENCES_INPUT5_EXT1, state_input5_ext1);
        }
        textView_input5_ext1.setText(name_input5_ext1+state_input5_ext1);

        if (mSettings.contains(APP_PREFERENCES_INPUT6_EXT1)) {
            state_input6_ext1= mSettings.getString(APP_PREFERENCES_INPUT6_EXT1, state_input6_ext1);
        }
        textView_input6_ext1.setText(name_input6_ext1 + state_input6_ext1);


        if (mSettings.contains(APP_PREFERENCES_INPUT7_EXT1)) {
            state_input7_ext1= mSettings.getString(APP_PREFERENCES_INPUT7_EXT1, state_input7_ext1);
        }
        textView_input7_ext1.setText(name_input7_ext1+state_input7_ext1);


        if (mSettings.contains(APP_PREFERENCES_INPUT8_EXT1)) {
            state_input8_ext1= mSettings.getString(APP_PREFERENCES_INPUT8_EXT1, state_input8_ext1);
        }
        textView_input8_ext1.setText(name_input8_ext1+state_input8_ext1);


        //ext2
        if (mSettings.contains(APP_PREFERENCES_INPUT1_EXT2)) {
            state_input1_ext2= mSettings.getString(APP_PREFERENCES_INPUT1_EXT2, state_input1_ext2);
        }
        textView_input1_ext2.setText(name_input1_ext2 + state_input1_ext2);


        if (mSettings.contains(APP_PREFERENCES_INPUT2_EXT2)) {
            state_input2_ext2= mSettings.getString(APP_PREFERENCES_INPUT2_EXT2, state_input2_ext2);
        }
        textView_input2_ext2.setText(name_input2_ext2+state_input2_ext2);

        if (mSettings.contains(APP_PREFERENCES_INPUT3_EXT2)) {
            state_input3_ext2= mSettings.getString(APP_PREFERENCES_INPUT3_EXT2, state_input3_ext2);
        }
        textView_input3_ext2.setText(name_input3_ext2+state_input3_ext2);

        if (mSettings.contains(APP_PREFERENCES_INPUT4_EXT2)) {
            state_input4_ext2= mSettings.getString(APP_PREFERENCES_INPUT4_EXT2, state_input4_ext2);
        }
        textView_input4_ext2.setText(name_input4_ext2+state_input4_ext2);

        if (mSettings.contains(APP_PREFERENCES_INPUT5_EXT2)) {
            state_input5_ext2= mSettings.getString(APP_PREFERENCES_INPUT5_EXT2, state_input5_ext2);
        }
        textView_input5_ext2.setText(name_input5_ext2+state_input5_ext2);

        if (mSettings.contains(APP_PREFERENCES_INPUT6_EXT2)) {
            state_input6_ext2= mSettings.getString(APP_PREFERENCES_INPUT6_EXT2, state_input6_ext2);
        }
        textView_input6_ext2.setText(name_input6_ext2 + state_input6_ext2);


        if (mSettings.contains(APP_PREFERENCES_INPUT7_EXT2)) {
            state_input7_ext2= mSettings.getString(APP_PREFERENCES_INPUT7_EXT2, state_input7_ext2);
        }
        textView_input7_ext2.setText(name_input7_ext2+state_input7_ext2);


        if (mSettings.contains(APP_PREFERENCES_INPUT8_EXT2)) {
            state_input8_ext2= mSettings.getString(APP_PREFERENCES_INPUT8_EXT2, state_input8_ext2);
        }
        textView_input8_ext2.setText(name_input8_ext2+state_input8_ext2);

        //ext3
        if (mSettings.contains(APP_PREFERENCES_INPUT1_EXT3)) {
            state_input1_ext3= mSettings.getString(APP_PREFERENCES_INPUT1_EXT3, state_input1_ext3);
        }
        textView_input1_ext3.setText(name_input1_ext3 + state_input1_ext3);


        if (mSettings.contains(APP_PREFERENCES_INPUT2_EXT3)) {
            state_input2_ext3= mSettings.getString(APP_PREFERENCES_INPUT2_EXT3, state_input2_ext3);
        }
        textView_input2_ext3.setText(name_input2_ext3+state_input2_ext3);

        if (mSettings.contains(APP_PREFERENCES_INPUT3_EXT3)) {
            state_input3_ext3= mSettings.getString(APP_PREFERENCES_INPUT3_EXT3, state_input3_ext3);
        }
        textView_input3_ext3.setText(name_input3_ext3+state_input3_ext3);

        if (mSettings.contains(APP_PREFERENCES_INPUT4_EXT3)) {
            state_input4_ext3= mSettings.getString(APP_PREFERENCES_INPUT4_EXT3, state_input4_ext3);
        }
        textView_input4_ext3.setText(name_input4_ext3+state_input4_ext3);

        if (mSettings.contains(APP_PREFERENCES_INPUT5_EXT3)) {
            state_input5_ext3= mSettings.getString(APP_PREFERENCES_INPUT5_EXT3, state_input5_ext3);
        }
        textView_input5_ext3.setText(name_input5_ext3+state_input5_ext3);

        if (mSettings.contains(APP_PREFERENCES_INPUT6_EXT3)) {
            state_input6_ext3= mSettings.getString(APP_PREFERENCES_INPUT6_EXT3, state_input6_ext3);
        }
        textView_input6_ext3.setText(name_input6_ext3 + state_input6_ext3);


        if (mSettings.contains(APP_PREFERENCES_INPUT7_EXT3)) {
            state_input7_ext3= mSettings.getString(APP_PREFERENCES_INPUT7_EXT3, state_input7_ext3);
        }
        textView_input7_ext3.setText(name_input7_ext3+state_input7_ext3);


        if (mSettings.contains(APP_PREFERENCES_INPUT8_EXT3)) {
            state_input8_ext3= mSettings.getString(APP_PREFERENCES_INPUT8_EXT3, state_input8_ext3);
        }
        textView_input8_ext3.setText(name_input8_ext3+state_input8_ext3);

        //ext4
        if (mSettings.contains(APP_PREFERENCES_INPUT1_EXT4)) {
            state_input1_ext4= mSettings.getString(APP_PREFERENCES_INPUT1_EXT4, state_input1_ext4);
        }
        textView_input1_ext4.setText(name_input1_ext4 + state_input1_ext4);


        if (mSettings.contains(APP_PREFERENCES_INPUT2_EXT4)) {
            state_input2_ext4= mSettings.getString(APP_PREFERENCES_INPUT2_EXT4, state_input2_ext4);
        }
        textView_input2_ext4.setText(name_input2_ext4+state_input2_ext4);

        if (mSettings.contains(APP_PREFERENCES_INPUT3_EXT4)) {
            state_input3_ext4= mSettings.getString(APP_PREFERENCES_INPUT3_EXT4, state_input3_ext4);
        }
        textView_input3_ext4.setText(name_input3_ext4+state_input3_ext4);

        if (mSettings.contains(APP_PREFERENCES_INPUT4_EXT4)) {
            state_input4_ext4= mSettings.getString(APP_PREFERENCES_INPUT4_EXT4, state_input4_ext4);
        }
        textView_input4_ext4.setText(name_input4_ext4+state_input4_ext4);

        if (mSettings.contains(APP_PREFERENCES_INPUT5_EXT4)) {
            state_input5_ext4= mSettings.getString(APP_PREFERENCES_INPUT5_EXT4, state_input5_ext4);
        }
        textView_input5_ext4.setText(name_input5_ext4+state_input5_ext4);

        if (mSettings.contains(APP_PREFERENCES_INPUT6_EXT4)) {
            state_input6_ext4= mSettings.getString(APP_PREFERENCES_INPUT6_EXT4, state_input6_ext4);
        }
        textView_input6_ext4.setText(name_input6_ext4 + state_input6_ext4);


        if (mSettings.contains(APP_PREFERENCES_INPUT7_EXT4)) {
            state_input7_ext4= mSettings.getString(APP_PREFERENCES_INPUT7_EXT4, state_input7_ext4);
        }
        textView_input7_ext4.setText(name_input7_ext4+state_input7_ext4);


        if (mSettings.contains(APP_PREFERENCES_INPUT8_EXT4)) {
            state_input8_ext4= mSettings.getString(APP_PREFERENCES_INPUT8_EXT4, state_input8_ext4);
        }
        textView_input8_ext4.setText(name_input8_ext4+state_input8_ext4);




        //output
        if (mSettings.contains(APP_PREFERENCES_OUTPUT1)) {
            state_output1= mSettings.getString(APP_PREFERENCES_OUTPUT1, state_output1);
        }
        btn_output1.setText(name_output1+state_output1);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT2)) {
            state_output2= mSettings.getString(APP_PREFERENCES_OUTPUT2, state_output2);
        }
        btn_output2.setText(name_output2+state_output2);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT3)) {
            state_output3= mSettings.getString(APP_PREFERENCES_OUTPUT3, state_output3);
        }
        btn_output3.setText(name_output3+state_output3);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT4)) {
            state_output4= mSettings.getString(APP_PREFERENCES_OUTPUT4, state_output4);
        }
        btn_output4.setText(name_output4+state_output4);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT5)) {
            state_output5= mSettings.getString(APP_PREFERENCES_OUTPUT5, state_output5);
        }
        btn_output5.setText(name_output5+state_output5);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT6)) {
            state_output6= mSettings.getString(APP_PREFERENCES_OUTPUT6, state_output6);
        }
        btn_output6.setText(name_output6+state_output6);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT7)) {
            state_output7= mSettings.getString(APP_PREFERENCES_OUTPUT7, state_output7);
        }
        btn_output7.setText(name_output7+state_output7);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT8)) {
            state_output8= mSettings.getString(APP_PREFERENCES_OUTPUT8, state_output8);
        }
        btn_output8.setText(name_output8 + state_output8);

        //ext0
        if (mSettings.contains(APP_PREFERENCES_OUTPUT1_EXT0)) {
            state_output1_ext0= mSettings.getString(APP_PREFERENCES_OUTPUT1_EXT0, state_output1_ext0);
        }
        btn_output1_ext0.setText(name_output1_ext0+state_output1_ext0);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT2_EXT0)) {
            state_output2_ext0= mSettings.getString(APP_PREFERENCES_OUTPUT2_EXT0, state_output2_ext0);
        }
        btn_output2_ext0.setText(name_output2_ext0+state_output2_ext0);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT3_EXT0)) {
            state_output3_ext0= mSettings.getString(APP_PREFERENCES_OUTPUT3_EXT0, state_output3_ext0);
        }
        btn_output3_ext0.setText(name_output3_ext0+state_output3_ext0);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT4_EXT0)) {
            state_output4_ext0= mSettings.getString(APP_PREFERENCES_OUTPUT4_EXT0, state_output4_ext0);
        }
        btn_output4_ext0.setText(name_output4_ext0+state_output4_ext0);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT5_EXT0)) {
            state_output5_ext0= mSettings.getString(APP_PREFERENCES_OUTPUT5_EXT0, state_output5_ext0);
        }
        btn_output5_ext0.setText(name_output5_ext0+state_output5_ext0);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT6_EXT0)) {
            state_output6_ext0= mSettings.getString(APP_PREFERENCES_OUTPUT6_EXT0, state_output6_ext0);
        }
        btn_output6_ext0.setText(name_output6_ext0+state_output6_ext0);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT7_EXT0)) {
            state_output7_ext0= mSettings.getString(APP_PREFERENCES_OUTPUT7_EXT0, state_output7_ext0);
        }
        btn_output7_ext0.setText(name_output7_ext0+state_output7_ext0);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT8_EXT0)) {
            state_output8_ext0= mSettings.getString(APP_PREFERENCES_OUTPUT8_EXT0, state_output8_ext0);
        }
        btn_output8_ext0.setText(name_output8_ext0 + state_output8_ext0);

        //ext1
        if (mSettings.contains(APP_PREFERENCES_OUTPUT1_EXT1)) {
            state_output1_ext1= mSettings.getString(APP_PREFERENCES_OUTPUT1_EXT1, state_output1_ext1);
        }
        btn_output1_ext1.setText(name_output1_ext1+state_output1_ext1);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT2_EXT1)) {
            state_output2_ext1= mSettings.getString(APP_PREFERENCES_OUTPUT2_EXT1, state_output2_ext1);
        }
        btn_output2_ext1.setText(name_output2_ext1+state_output2_ext1);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT3_EXT1)) {
            state_output3_ext1= mSettings.getString(APP_PREFERENCES_OUTPUT3_EXT1, state_output3_ext1);
        }
        btn_output3_ext1.setText(name_output3_ext1+state_output3_ext1);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT4_EXT1)) {
            state_output4_ext1= mSettings.getString(APP_PREFERENCES_OUTPUT4_EXT1, state_output4_ext1);
        }
        btn_output4_ext1.setText(name_output4_ext1+state_output4_ext1);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT5_EXT1)) {
            state_output5_ext1= mSettings.getString(APP_PREFERENCES_OUTPUT5_EXT1, state_output5_ext1);
        }
        btn_output5_ext1.setText(name_output5_ext1+state_output5_ext1);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT6_EXT1)) {
            state_output6_ext1= mSettings.getString(APP_PREFERENCES_OUTPUT6_EXT1, state_output6_ext1);
        }
        btn_output6_ext1.setText(name_output6_ext1+state_output6_ext1);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT7_EXT1)) {
            state_output7_ext1= mSettings.getString(APP_PREFERENCES_OUTPUT7_EXT1, state_output7_ext1);
        }
        btn_output7_ext1.setText(name_output7_ext1+state_output7_ext1);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT8_EXT1)) {
            state_output8_ext1= mSettings.getString(APP_PREFERENCES_OUTPUT8_EXT1, state_output8_ext1);
        }
        btn_output8_ext1.setText(name_output8_ext1 + state_output8_ext1);

        //ext2
        if (mSettings.contains(APP_PREFERENCES_OUTPUT1_EXT2)) {
            state_output1_ext2= mSettings.getString(APP_PREFERENCES_OUTPUT1_EXT2, state_output1_ext2);
        }
        btn_output1_ext2.setText(name_output1_ext2+state_output1_ext2);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT2_EXT2)) {
            state_output2_ext2= mSettings.getString(APP_PREFERENCES_OUTPUT2_EXT2, state_output2_ext2);
        }
        btn_output2_ext2.setText(name_output2_ext2+state_output2_ext2);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT3_EXT2)) {
            state_output3_ext2= mSettings.getString(APP_PREFERENCES_OUTPUT3_EXT2, state_output3_ext2);
        }
        btn_output3_ext2.setText(name_output3_ext2+state_output3_ext2);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT4_EXT2)) {
            state_output4_ext2= mSettings.getString(APP_PREFERENCES_OUTPUT4_EXT2, state_output4_ext2);
        }
        btn_output4_ext2.setText(name_output4_ext2+state_output4_ext2);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT5_EXT2)) {
            state_output5_ext2= mSettings.getString(APP_PREFERENCES_OUTPUT5_EXT2, state_output5_ext2);
        }
        btn_output5_ext2.setText(name_output5_ext2+state_output5_ext2);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT6_EXT2)) {
            state_output6_ext2= mSettings.getString(APP_PREFERENCES_OUTPUT6_EXT2, state_output6_ext2);
        }
        btn_output6_ext2.setText(name_output6_ext2+state_output6_ext2);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT7_EXT2)) {
            state_output7_ext2= mSettings.getString(APP_PREFERENCES_OUTPUT7_EXT2, state_output7_ext2);
        }
        btn_output7_ext2.setText(name_output7_ext2+state_output7_ext2);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT8_EXT2)) {
            state_output8_ext2= mSettings.getString(APP_PREFERENCES_OUTPUT8_EXT2, state_output8_ext2);
        }
        btn_output8_ext2.setText(name_output8_ext2 + state_output8_ext2);

        //ext3
        if (mSettings.contains(APP_PREFERENCES_OUTPUT1_EXT3)) {
            state_output1_ext3= mSettings.getString(APP_PREFERENCES_OUTPUT1_EXT3, state_output1_ext3);
        }
        btn_output1_ext3.setText(name_output1_ext3+state_output1_ext3);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT2_EXT3)) {
            state_output2_ext3= mSettings.getString(APP_PREFERENCES_OUTPUT2_EXT3, state_output2_ext3);
        }
        btn_output2_ext3.setText(name_output2_ext3+state_output2_ext3);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT3_EXT3)) {
            state_output3_ext3= mSettings.getString(APP_PREFERENCES_OUTPUT3_EXT3, state_output3_ext3);
        }
        btn_output3_ext3.setText(name_output3_ext3+state_output3_ext3);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT4_EXT3)) {
            state_output4_ext3= mSettings.getString(APP_PREFERENCES_OUTPUT4_EXT3, state_output4_ext3);
        }
        btn_output4_ext3.setText(name_output4_ext3+state_output4_ext3);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT5_EXT3)) {
            state_output5_ext3= mSettings.getString(APP_PREFERENCES_OUTPUT5_EXT3, state_output5_ext3);
        }
        btn_output5_ext3.setText(name_output5_ext3+state_output5_ext3);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT6_EXT3)) {
            state_output6_ext3= mSettings.getString(APP_PREFERENCES_OUTPUT6_EXT3, state_output6_ext3);
        }
        btn_output6_ext3.setText(name_output6_ext3+state_output6_ext3);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT7_EXT3)) {
            state_output7_ext3= mSettings.getString(APP_PREFERENCES_OUTPUT7_EXT3, state_output7_ext3);
        }
        btn_output7_ext3.setText(name_output7_ext3+state_output7_ext3);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT8_EXT3)) {
            state_output8_ext3= mSettings.getString(APP_PREFERENCES_OUTPUT8_EXT3, state_output8_ext3);
        }
        btn_output8_ext3.setText(name_output8_ext3 + state_output8_ext3);

        //ext4
        if (mSettings.contains(APP_PREFERENCES_OUTPUT1_EXT4)) {
            state_output1_ext4= mSettings.getString(APP_PREFERENCES_OUTPUT1_EXT4, state_output1_ext4);
        }
        btn_output1_ext4.setText(name_output1_ext4+state_output1_ext4);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT2_EXT4)) {
            state_output2_ext4= mSettings.getString(APP_PREFERENCES_OUTPUT2_EXT4, state_output2_ext4);
        }
        btn_output2_ext4.setText(name_output2_ext4+state_output2_ext4);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT3_EXT4)) {
            state_output3_ext4= mSettings.getString(APP_PREFERENCES_OUTPUT3_EXT4, state_output3_ext4);
        }
        btn_output3_ext4.setText(name_output3_ext4+state_output3_ext4);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT4_EXT4)) {
            state_output4_ext4= mSettings.getString(APP_PREFERENCES_OUTPUT4_EXT4, state_output4_ext4);
        }
        btn_output4_ext4.setText(name_output4_ext4+state_output4_ext4);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT5_EXT4)) {
            state_output5_ext4= mSettings.getString(APP_PREFERENCES_OUTPUT5_EXT4, state_output5_ext4);
        }
        btn_output5_ext4.setText(name_output5_ext4+state_output5_ext4);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT6_EXT4)) {
            state_output6_ext4= mSettings.getString(APP_PREFERENCES_OUTPUT6_EXT4, state_output6_ext4);
        }
        btn_output6_ext4.setText(name_output6_ext4+state_output6_ext4);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT7_EXT4)) {
            state_output7_ext4= mSettings.getString(APP_PREFERENCES_OUTPUT7_EXT4, state_output7_ext4);
        }
        btn_output7_ext4.setText(name_output7_ext4+state_output7_ext4);

        if (mSettings.contains(APP_PREFERENCES_OUTPUT8_EXT4)) {
            state_output8_ext4= mSettings.getString(APP_PREFERENCES_OUTPUT8_EXT4, state_output8_ext4);
        }
        btn_output8_ext4.setText(name_output8_ext4 + state_output8_ext4);

        //radio socket
        //blk1
        if (mSettings.contains(APP_PREFERENCES_SOCKET1_BLK1)) {
            state_socket1_blk1= mSettings.getString(APP_PREFERENCES_SOCKET1_BLK1, state_socket1_blk1);
        }
        btn_socket1_blk1.setText(name_socket1_blk1+state_socket1_blk1);

        if (mSettings.contains(APP_PREFERENCES_SOCKET2_BLK1)) {
            state_socket2_blk1= mSettings.getString(APP_PREFERENCES_SOCKET2_BLK1, state_socket2_blk1);
        }
        btn_socket2_blk1.setText(name_socket2_blk1+state_socket2_blk1);

        if (mSettings.contains(APP_PREFERENCES_SOCKET3_BLK1)) {
            state_socket3_blk1= mSettings.getString(APP_PREFERENCES_SOCKET3_BLK1, state_socket3_blk1);
        }
        btn_socket3_blk1.setText(name_socket3_blk1+state_socket3_blk1);

        if (mSettings.contains(APP_PREFERENCES_SOCKET4_BLK1)) {
            state_socket4_blk1= mSettings.getString(APP_PREFERENCES_SOCKET4_BLK1, state_socket4_blk1);
        }
        btn_socket4_blk1.setText(name_socket4_blk1+state_socket4_blk1);

        if (mSettings.contains(APP_PREFERENCES_SOCKET5_BLK1)) {
            state_socket5_blk1= mSettings.getString(APP_PREFERENCES_SOCKET5_BLK1, state_socket5_blk1);
        }
        btn_socket5_blk1.setText(name_socket5_blk1+state_socket5_blk1);

        if (mSettings.contains(APP_PREFERENCES_SOCKET6_BLK1)) {
            state_socket6_blk1= mSettings.getString(APP_PREFERENCES_SOCKET6_BLK1, state_socket6_blk1);
        }
        btn_socket6_blk1.setText(name_socket6_blk1+state_socket6_blk1);

        if (mSettings.contains(APP_PREFERENCES_SOCKET7_BLK1)) {
            state_socket7_blk1= mSettings.getString(APP_PREFERENCES_SOCKET7_BLK1, state_socket7_blk1);
        }
        btn_socket7_blk1.setText(name_socket7_blk1+state_socket7_blk1);

        if (mSettings.contains(APP_PREFERENCES_SOCKET8_BLK1)) {
            state_socket8_blk1= mSettings.getString(APP_PREFERENCES_SOCKET8_BLK1, state_socket8_blk1);
        }
        btn_socket8_blk1.setText(name_socket8_blk1+state_socket8_blk1);

        //blk2
        if (mSettings.contains(APP_PREFERENCES_SOCKET1_BLK2)) {
            state_socket1_blk2= mSettings.getString(APP_PREFERENCES_SOCKET1_BLK2, state_socket1_blk2);
        }
        btn_socket1_blk2.setText(name_socket1_blk2+state_socket1_blk2);

        if (mSettings.contains(APP_PREFERENCES_SOCKET2_BLK2)) {
            state_socket2_blk2= mSettings.getString(APP_PREFERENCES_SOCKET2_BLK2, state_socket2_blk2);
        }
        btn_socket2_blk2.setText(name_socket2_blk2+state_socket2_blk2);

        if (mSettings.contains(APP_PREFERENCES_SOCKET3_BLK2)) {
            state_socket3_blk2= mSettings.getString(APP_PREFERENCES_SOCKET3_BLK2, state_socket3_blk2);
        }
        btn_socket3_blk2.setText(name_socket3_blk2+state_socket3_blk2);

        if (mSettings.contains(APP_PREFERENCES_SOCKET4_BLK2)) {
            state_socket4_blk2= mSettings.getString(APP_PREFERENCES_SOCKET4_BLK2, state_socket4_blk2);
        }
        btn_socket4_blk2.setText(name_socket4_blk2+state_socket4_blk2);

        if (mSettings.contains(APP_PREFERENCES_SOCKET5_BLK2)) {
            state_socket5_blk2= mSettings.getString(APP_PREFERENCES_SOCKET5_BLK2, state_socket5_blk2);
        }
        btn_socket5_blk2.setText(name_socket5_blk2+state_socket5_blk2);

        if (mSettings.contains(APP_PREFERENCES_SOCKET6_BLK2)) {
            state_socket6_blk2= mSettings.getString(APP_PREFERENCES_SOCKET6_BLK2, state_socket6_blk2);
        }
        btn_socket6_blk2.setText(name_socket6_blk2+state_socket6_blk2);

        if (mSettings.contains(APP_PREFERENCES_SOCKET7_BLK2)) {
            state_socket7_blk2= mSettings.getString(APP_PREFERENCES_SOCKET7_BLK2, state_socket7_blk2);
        }
        btn_socket7_blk2.setText(name_socket7_blk2+state_socket7_blk2);

        if (mSettings.contains(APP_PREFERENCES_SOCKET8_BLK2)) {
            state_socket8_blk2= mSettings.getString(APP_PREFERENCES_SOCKET8_BLK2, state_socket8_blk2);
        }
        btn_socket8_blk2.setText(name_socket8_blk2+state_socket8_blk2);

        //blk3
        if (mSettings.contains(APP_PREFERENCES_SOCKET1_BLK3)) {
            state_socket1_blk3= mSettings.getString(APP_PREFERENCES_SOCKET1_BLK3, state_socket1_blk3);
        }
        btn_socket1_blk3.setText(name_socket1_blk3+state_socket1_blk3);

        if (mSettings.contains(APP_PREFERENCES_SOCKET2_BLK3)) {
            state_socket2_blk3= mSettings.getString(APP_PREFERENCES_SOCKET2_BLK3, state_socket2_blk3);
        }
        btn_socket2_blk3.setText(name_socket2_blk3+state_socket2_blk3);

        if (mSettings.contains(APP_PREFERENCES_SOCKET3_BLK3)) {
            state_socket3_blk3= mSettings.getString(APP_PREFERENCES_SOCKET3_BLK3, state_socket3_blk3);
        }
        btn_socket3_blk3.setText(name_socket3_blk3+state_socket3_blk3);

        if (mSettings.contains(APP_PREFERENCES_SOCKET4_BLK3)) {
            state_socket4_blk3= mSettings.getString(APP_PREFERENCES_SOCKET4_BLK3, state_socket4_blk3);
        }
        btn_socket4_blk3.setText(name_socket4_blk3+state_socket4_blk3);

        if (mSettings.contains(APP_PREFERENCES_SOCKET5_BLK3)) {
            state_socket5_blk3= mSettings.getString(APP_PREFERENCES_SOCKET5_BLK3, state_socket5_blk3);
        }
        btn_socket5_blk3.setText(name_socket5_blk3+state_socket5_blk3);

        if (mSettings.contains(APP_PREFERENCES_SOCKET6_BLK3)) {
            state_socket6_blk3= mSettings.getString(APP_PREFERENCES_SOCKET6_BLK3, state_socket6_blk3);
        }
        btn_socket6_blk3.setText(name_socket6_blk3+state_socket6_blk3);

        if (mSettings.contains(APP_PREFERENCES_SOCKET7_BLK3)) {
            state_socket7_blk3= mSettings.getString(APP_PREFERENCES_SOCKET7_BLK3, state_socket7_blk3);
        }
        btn_socket7_blk3.setText(name_socket7_blk3+state_socket7_blk3);

        if (mSettings.contains(APP_PREFERENCES_SOCKET8_BLK3)) {
            state_socket8_blk3= mSettings.getString(APP_PREFERENCES_SOCKET8_BLK3, state_socket8_blk3);
        }
        btn_socket8_blk3.setText(name_socket8_blk3+state_socket8_blk3);

        //blk4
        if (mSettings.contains(APP_PREFERENCES_SOCKET1_BLK4)) {
            state_socket1_blk4= mSettings.getString(APP_PREFERENCES_SOCKET1_BLK4, state_socket1_blk4);
        }
        btn_socket1_blk4.setText(name_socket1_blk4+state_socket1_blk4);

        if (mSettings.contains(APP_PREFERENCES_SOCKET2_BLK4)) {
            state_socket2_blk4= mSettings.getString(APP_PREFERENCES_SOCKET2_BLK4, state_socket2_blk4);
        }
        btn_socket2_blk4.setText(name_socket2_blk4+state_socket2_blk4);

        if (mSettings.contains(APP_PREFERENCES_SOCKET3_BLK4)) {
            state_socket3_blk4= mSettings.getString(APP_PREFERENCES_SOCKET3_BLK4, state_socket3_blk4);
        }
        btn_socket3_blk4.setText(name_socket3_blk4+state_socket3_blk4);

        if (mSettings.contains(APP_PREFERENCES_SOCKET4_BLK4)) {
            state_socket4_blk4= mSettings.getString(APP_PREFERENCES_SOCKET4_BLK4, state_socket4_blk4);
        }
        btn_socket4_blk4.setText(name_socket4_blk4+state_socket4_blk4);

        if (mSettings.contains(APP_PREFERENCES_SOCKET5_BLK4)) {
            state_socket5_blk4= mSettings.getString(APP_PREFERENCES_SOCKET5_BLK4, state_socket5_blk4);
        }
        btn_socket5_blk4.setText(name_socket5_blk4+state_socket5_blk4);

        if (mSettings.contains(APP_PREFERENCES_SOCKET6_BLK4)) {
            state_socket6_blk4= mSettings.getString(APP_PREFERENCES_SOCKET6_BLK4, state_socket6_blk4);
        }
        btn_socket6_blk4.setText(name_socket6_blk4+state_socket6_blk4);

        if (mSettings.contains(APP_PREFERENCES_SOCKET7_BLK4)) {
            state_socket7_blk4= mSettings.getString(APP_PREFERENCES_SOCKET7_BLK4, state_socket7_blk4);
        }
        btn_socket7_blk4.setText(name_socket7_blk4+state_socket7_blk4);

        if (mSettings.contains(APP_PREFERENCES_SOCKET8_BLK4)) {
            state_socket8_blk4= mSettings.getString(APP_PREFERENCES_SOCKET8_BLK4, state_socket8_blk4);
        }
        btn_socket8_blk4.setText(name_socket8_blk4+state_socket8_blk4);




        //radio
        if (mSettings.contains(APP_PREFERENCES_RADIO1)) {
            state_radio1= mSettings.getString(APP_PREFERENCES_RADIO1, state_radio1);
        }
        textView_radio1.setText(name_radio1 + state_radio1);

        if (mSettings.contains(APP_PREFERENCES_RADIO2)) {
            state_radio2= mSettings.getString(APP_PREFERENCES_RADIO2, state_radio2);
        }
        textView_radio2.setText(name_radio2 + state_radio2);

        if (mSettings.contains(APP_PREFERENCES_RADIO3)) {
            state_radio3= mSettings.getString(APP_PREFERENCES_RADIO3, state_radio3);
        }
        textView_radio3.setText(name_radio3 + state_radio3);

        if (mSettings.contains(APP_PREFERENCES_RADIO4)) {
            state_radio4= mSettings.getString(APP_PREFERENCES_RADIO4, state_radio4);
        }
        textView_radio4.setText(name_radio4 + state_radio4);

        if (mSettings.contains(APP_PREFERENCES_RADIO5)) {
            state_radio5= mSettings.getString(APP_PREFERENCES_RADIO5, state_radio5);
        }
        textView_radio5.setText(name_radio5 + state_radio5);

        if (mSettings.contains(APP_PREFERENCES_RADIO6)) {
            state_radio6= mSettings.getString(APP_PREFERENCES_RADIO6, state_radio6);
        }
        textView_radio6.setText(name_radio6 + state_radio6);

        if (mSettings.contains(APP_PREFERENCES_RADIO7)) {
            state_radio7= mSettings.getString(APP_PREFERENCES_RADIO7, state_radio7);
        }
        textView_radio7.setText(name_radio7 + state_radio7);

        if (mSettings.contains(APP_PREFERENCES_RADIO8)) {
            state_radio8= mSettings.getString(APP_PREFERENCES_RADIO8, state_radio8);
        }
        textView_radio8.setText(name_radio8 + state_radio8);

        if (mSettings.contains(APP_PREFERENCES_RADIO9)) {
            state_radio9= mSettings.getString(APP_PREFERENCES_RADIO9, state_radio9);
        }
        textView_radio9.setText(name_radio9 + state_radio9);

        if (mSettings.contains(APP_PREFERENCES_RADIO10)) {
            state_radio10= mSettings.getString(APP_PREFERENCES_RADIO10, state_radio10);
        }
        textView_radio10.setText(name_radio10 + state_radio10);

        if (mSettings.contains(APP_PREFERENCES_RADIO11)) {
            state_radio11= mSettings.getString(APP_PREFERENCES_RADIO11, state_radio11);
        }
        textView_radio11.setText(name_radio11 + state_radio11);

        if (mSettings.contains(APP_PREFERENCES_RADIO12)) {
            state_radio12= mSettings.getString(APP_PREFERENCES_RADIO12, state_radio12);
        }
        textView_radio12.setText(name_radio12 + state_radio12);

        if (mSettings.contains(APP_PREFERENCES_RADIO13)) {
            state_radio13= mSettings.getString(APP_PREFERENCES_RADIO13, state_radio13);
        }
        textView_radio13.setText(name_radio13 + state_radio13);

        if (mSettings.contains(APP_PREFERENCES_RADIO14)) {
            state_radio14= mSettings.getString(APP_PREFERENCES_RADIO14, state_radio14);
        }
        textView_radio14.setText(name_radio14 + state_radio14);

        if (mSettings.contains(APP_PREFERENCES_RADIO15)) {
            state_radio15= mSettings.getString(APP_PREFERENCES_RADIO15, state_radio15);
        }
        textView_radio15.setText(name_radio15 + state_radio15);

        if (mSettings.contains(APP_PREFERENCES_RADIO16)) {
            state_radio16= mSettings.getString(APP_PREFERENCES_RADIO16, state_radio16);
        }
        textView_radio16.setText(name_radio16 + state_radio16);






        //TERMOSENSOR
        if (mSettings.contains(APP_PREFERENCES_TERMO1)) {
            state_termo1= mSettings.getString(APP_PREFERENCES_TERMO1, state_termo1);
        }
        textView_termo1.setText(name_termo1 + state_termo1);

        if (mSettings.contains(APP_PREFERENCES_TERMO2)) {
            state_termo2= mSettings.getString(APP_PREFERENCES_TERMO2, state_termo2);
        }
        textView_termo2.setText(name_termo2 + state_termo2);

        if (mSettings.contains(APP_PREFERENCES_TERMO3)) {
            state_termo3= mSettings.getString(APP_PREFERENCES_TERMO3, state_termo3);
        }
        textView_termo3.setText(name_termo3 + state_termo3);

        if (mSettings.contains(APP_PREFERENCES_TERMO4)) {
            state_termo4= mSettings.getString(APP_PREFERENCES_TERMO4, state_termo4);
        }
        textView_termo4.setText(name_termo4 + state_termo4);

        if (mSettings.contains(APP_PREFERENCES_TERMO5)) {
            state_termo5= mSettings.getString(APP_PREFERENCES_TERMO5, state_termo5);
        }
        textView_termo5.setText(name_termo5 + state_termo5);

        if (mSettings.contains(APP_PREFERENCES_TERMO6)) {
            state_termo6= mSettings.getString(APP_PREFERENCES_TERMO6, state_termo6);
        }
        textView_termo6.setText(name_termo6 + state_termo6);

        if (mSettings.contains(APP_PREFERENCES_TERMO7)) {
            state_termo7= mSettings.getString(APP_PREFERENCES_TERMO7, state_termo7);
        }
        textView_termo7.setText(name_termo7 + state_termo7);

        if (mSettings.contains(APP_PREFERENCES_TERMO8)) {
            state_termo8= mSettings.getString(APP_PREFERENCES_TERMO8, state_termo8);
        }
        textView_termo8.setText(name_termo8 + state_termo8);

        if (mSettings.contains(APP_PREFERENCES_CONTROLLER)) {
            state_controller= mSettings.getString(APP_PREFERENCES_CONTROLLER, state_controller);
        }
        textView_controller.setText(state_controller);


        colour_io();


        //hide invisible

        RelativeLayout.LayoutParams lp;
        int cur_anchor;


        cur_anchor=R.id.textView_gsm;
        //wired

        //in
        lp = (RelativeLayout.LayoutParams) textView_in.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_in.setLayoutParams(lp);
        if (!mSettings.getBoolean(APP_PREFERENCES_VIEW_I1, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I2, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I3, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I4, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I5, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I6, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I7, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I8, true) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT0, false) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT1, false) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT2, false) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT3, false) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_TAMPER, false)
                )
        {
            textView_in.setVisibility(View.INVISIBLE);
        }else{
            textView_in.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_in;
        }

        //tamper
        lp = (RelativeLayout.LayoutParams) textView_tamper.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_tamper.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_TAMPER, false)){
            textView_tamper.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_tamper;
        }else{
            textView_tamper.setVisibility(View.INVISIBLE);
        }

        //input1
        lp = (RelativeLayout.LayoutParams) textView_input1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1, true)){
            textView_input1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input1;
        }else{
            textView_input1.setVisibility(View.INVISIBLE);
        }


        //input2
        lp = (RelativeLayout.LayoutParams) textView_input2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2, true)){
            textView_input2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input2;
        }else{
            textView_input2.setVisibility(View.INVISIBLE);
        }



        //input3
        lp = (RelativeLayout.LayoutParams) textView_input3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3, true)){
            textView_input3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input3;
        }else{
            textView_input3.setVisibility(View.INVISIBLE);
        }

        //input4
        lp = (RelativeLayout.LayoutParams) textView_input4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4, true)){
            textView_input4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input4;
        }else{
            textView_input4.setVisibility(View.INVISIBLE);
        }

        //input5
        lp = (RelativeLayout.LayoutParams) textView_input5.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input5.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5, true)){
            textView_input5.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input5;
        }else{
            textView_input5.setVisibility(View.INVISIBLE);
        }

        //input6
        lp = (RelativeLayout.LayoutParams) textView_input6.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input6.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6, true)){
            textView_input6.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input6;
        }else{
            textView_input6.setVisibility(View.INVISIBLE);
        }

        //input7
        lp = (RelativeLayout.LayoutParams) textView_input7.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input7.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7, true)){
            textView_input7.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input7;
        }else{
            textView_input7.setVisibility(View.INVISIBLE);
        }

        //input8
        lp = (RelativeLayout.LayoutParams) textView_input8.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input8.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8, true)){
            textView_input8.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input8;
        }else{
            textView_input8.setVisibility(View.INVISIBLE);
        }

        //ext0
        lp = (RelativeLayout.LayoutParams) textView_input1_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input1_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT0, false)){
            textView_input1_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input1_ext0;
        }else{
            textView_input1_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input2_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input2_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT0, false)){
            textView_input2_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input2_ext0;
        }else{
            textView_input2_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input3_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input3_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT0, false)){
            textView_input3_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input3_ext0;
        }else{
            textView_input3_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input4_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input4_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT0, false)){
            textView_input4_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input4_ext0;
        }else{
            textView_input4_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input5_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input5_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT0, false)){
            textView_input5_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input5_ext0;
        }else{
            textView_input5_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input6_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input6_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT0, false)){
            textView_input6_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input6_ext0;
        }else{
            textView_input6_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input7_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input7_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT0, false)){
            textView_input7_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input7_ext0;
        }else{
            textView_input7_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input8_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input8_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT0, false)){
            textView_input8_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input8_ext0;
        }else{
            textView_input8_ext0.setVisibility(View.INVISIBLE);
        }

        //ext1
        lp = (RelativeLayout.LayoutParams) textView_input1_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input1_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT1, false)){
            textView_input1_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input1_ext1;
        }else{
            textView_input1_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input2_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input2_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT1, false)){
            textView_input2_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input2_ext1;
        }else{
            textView_input2_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input3_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input3_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT1, false)){
            textView_input3_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input3_ext1;
        }else{
            textView_input3_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input4_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input4_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT1, false)){
            textView_input4_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input4_ext1;
        }else{
            textView_input4_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input5_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input5_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT1, false)){
            textView_input5_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input5_ext1;
        }else{
            textView_input5_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input6_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input6_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT1, false)){
            textView_input6_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input6_ext1;
        }else{
            textView_input6_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input7_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input7_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT1, false)){
            textView_input7_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input7_ext1;
        }else{
            textView_input7_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input8_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input8_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT1, false)){
            textView_input8_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input8_ext1;
        }else{
            textView_input8_ext1.setVisibility(View.INVISIBLE);
        }

        //ext2
        lp = (RelativeLayout.LayoutParams) textView_input1_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input1_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT2, false)){
            textView_input1_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input1_ext2;
        }else{
            textView_input1_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input2_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input2_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT2, false)){
            textView_input2_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input2_ext2;
        }else{
            textView_input2_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input3_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input3_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT2, false)){
            textView_input3_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input3_ext2;
        }else{
            textView_input3_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input4_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input4_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT2, false)){
            textView_input4_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input4_ext2;
        }else{
            textView_input4_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input5_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input5_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT2, false)){
            textView_input5_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input5_ext2;
        }else{
            textView_input5_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input6_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input6_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT2, false)){
            textView_input6_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input6_ext2;
        }else{
            textView_input6_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input7_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input7_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT2, false)){
            textView_input7_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input7_ext2;
        }else{
            textView_input7_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input8_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input8_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT2, false)){
            textView_input8_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input8_ext2;
        }else{
            textView_input8_ext2.setVisibility(View.INVISIBLE);
        }

        //ext3
        lp = (RelativeLayout.LayoutParams) textView_input1_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input1_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT3, false)){
            textView_input1_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input1_ext3;
        }else{
            textView_input1_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input2_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input2_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT3, false)){
            textView_input2_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input2_ext3;
        }else{
            textView_input2_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input3_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input3_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT3, false)){
            textView_input3_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input3_ext3;
        }else{
            textView_input3_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input4_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input4_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT3, false)){
            textView_input4_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input4_ext3;
        }else{
            textView_input4_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input5_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input5_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT3, false)){
            textView_input5_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input5_ext3;
        }else{
            textView_input5_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input6_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input6_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT3, false)){
            textView_input6_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input6_ext3;
        }else{
            textView_input6_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input7_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input7_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT3, false)){
            textView_input7_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input7_ext3;
        }else{
            textView_input7_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input8_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input8_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT3, false)){
            textView_input8_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input8_ext3;
        }else{
            textView_input8_ext3.setVisibility(View.INVISIBLE);
        }

        //ext4
        lp = (RelativeLayout.LayoutParams) textView_input1_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input1_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT4, false)){
            textView_input1_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input1_ext4;
        }else{
            textView_input1_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input2_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input2_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT4, false)){
            textView_input2_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input2_ext4;
        }else{
            textView_input2_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input3_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input3_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT4, false)){
            textView_input3_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input3_ext4;
        }else{
            textView_input3_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input4_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input4_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT4, false)){
            textView_input4_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input4_ext4;
        }else{
            textView_input4_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input5_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input5_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT4, false)){
            textView_input5_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input5_ext4;
        }else{
            textView_input5_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input6_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input6_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT4, false)){
            textView_input6_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input6_ext4;
        }else{
            textView_input6_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input7_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input7_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT4, false)){
            textView_input7_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input7_ext4;
        }else{
            textView_input7_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) textView_input8_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_input8_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT4, false)){
            textView_input8_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_input8_ext4;
        }else{
            textView_input8_ext4.setVisibility(View.INVISIBLE);
        }



        //out
        lp = (RelativeLayout.LayoutParams) textView_out.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_out.setLayoutParams(lp);
        if (!mSettings.getBoolean(APP_PREFERENCES_VIEW_O1, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O2, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O3, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O4, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O5, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O6, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O7, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O8, true) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O1_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O2_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O3_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O4_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O5_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O6_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O7_EXT0, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O8_EXT0, false) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O1_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O2_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O3_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O4_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O5_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O6_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O7_EXT1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O8_EXT1, false) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O1_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O2_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O3_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O4_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O5_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O6_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O7_EXT2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O8_EXT2, false) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O1_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O2_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O3_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O4_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O5_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O6_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O7_EXT3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O8_EXT3, false) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O1_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O2_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O3_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O4_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O5_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O6_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O7_EXT4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_O8_EXT4, false) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET1_BLK1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET2_BLK1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET3_BLK1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET4_BLK1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET5_BLK1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET6_BLK1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET7_BLK1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET8_BLK1, false) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET1_BLK2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET2_BLK2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET3_BLK2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET4_BLK2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET5_BLK2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET6_BLK2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET7_BLK2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET8_BLK2, false) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET1_BLK3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET2_BLK3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET3_BLK3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET4_BLK3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET5_BLK3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET6_BLK3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET7_BLK3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET8_BLK3, false) &&

                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET1_BLK4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET2_BLK4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET3_BLK4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET4_BLK4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET5_BLK4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET6_BLK4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET7_BLK4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET8_BLK4, false)

                )
        {
            textView_out.setVisibility(View.INVISIBLE);
        }else{
            textView_out.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_out;
        }



        //out1
        lp = (RelativeLayout.LayoutParams) btn_output1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O1, true)){
            btn_output1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output1;
        }else{
            btn_output1.setVisibility(View.INVISIBLE);
        }

        //out2
        lp = (RelativeLayout.LayoutParams) btn_output2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O2, true)){
            btn_output2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output2;
        }else{
            btn_output2.setVisibility(View.INVISIBLE);
        }

        //out3
        lp = (RelativeLayout.LayoutParams) btn_output3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O3, true)){
            btn_output3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output3;
        }else{
            btn_output3.setVisibility(View.INVISIBLE);
        }

        //out4
        lp = (RelativeLayout.LayoutParams) btn_output4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O4, true)){
            btn_output4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output4;
        }else{
            btn_output4.setVisibility(View.INVISIBLE);
        }

        //out5
        lp = (RelativeLayout.LayoutParams) btn_output5.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output5.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O5, true)){
            btn_output5.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output5;
        }else{
            btn_output5.setVisibility(View.INVISIBLE);
        }

        //out6
        lp = (RelativeLayout.LayoutParams) btn_output6.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output6.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O6, true)){
            btn_output6.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output6;
        }else{
            btn_output6.setVisibility(View.INVISIBLE);
        }

        //out7
        lp = (RelativeLayout.LayoutParams) btn_output7.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output7.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O7, true)){
            btn_output7.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output7;
        }else{
            btn_output7.setVisibility(View.INVISIBLE);
        }

        //out8
        lp = (RelativeLayout.LayoutParams) btn_output8.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output8.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O8, true)){
            btn_output8.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output8;
        }else{
            btn_output8.setVisibility(View.INVISIBLE);
        }

        //ext0
        lp = (RelativeLayout.LayoutParams) btn_output1_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output1_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O1_EXT0, false)){
            btn_output1_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output1_ext0;
        }else{
            btn_output1_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output2_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output2_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O2_EXT0, false)){
            btn_output2_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output2_ext0;
        }else{
            btn_output2_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output3_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output3_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O3_EXT0, false)){
            btn_output3_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output3_ext0;
        }else{
            btn_output3_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output4_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output4_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O4_EXT0, false)){
            btn_output4_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output4_ext0;
        }else{
            btn_output4_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output5_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output5_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O5_EXT0, false)){
            btn_output5_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output5_ext0;
        }else{
            btn_output5_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output6_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output6_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O6_EXT0, false)){
            btn_output6_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output6_ext0;
        }else{
            btn_output6_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output7_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output7_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O7_EXT0, false)){
            btn_output7_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output7_ext0;
        }else{
            btn_output7_ext0.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output8_ext0.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output8_ext0.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O8_EXT0, false)){
            btn_output8_ext0.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output8_ext0;
        }else{
            btn_output8_ext0.setVisibility(View.INVISIBLE);
        }

        //ext1
        lp = (RelativeLayout.LayoutParams) btn_output1_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output1_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O1_EXT1, false)){
            btn_output1_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output1_ext1;
        }else{
            btn_output1_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output2_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output2_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O2_EXT1, false)){
            btn_output2_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output2_ext1;
        }else{
            btn_output2_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output3_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output3_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O3_EXT1, false)){
            btn_output3_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output3_ext1;
        }else{
            btn_output3_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output4_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output4_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O4_EXT1, false)){
            btn_output4_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output4_ext1;
        }else{
            btn_output4_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output5_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output5_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O5_EXT1, false)){
            btn_output5_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output5_ext1;
        }else{
            btn_output5_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output6_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output6_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O6_EXT1, false)){
            btn_output6_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output6_ext1;
        }else{
            btn_output6_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output7_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output7_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O7_EXT1, false)){
            btn_output7_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output7_ext1;
        }else{
            btn_output7_ext1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output8_ext1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output8_ext1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O8_EXT1, false)){
            btn_output8_ext1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output8_ext1;
        }else{
            btn_output8_ext1.setVisibility(View.INVISIBLE);
        }

        //ext2
        lp = (RelativeLayout.LayoutParams) btn_output1_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output1_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O1_EXT2, false)){
            btn_output1_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output1_ext2;
        }else{
            btn_output1_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output2_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output2_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O2_EXT2, false)){
            btn_output2_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output2_ext2;
        }else{
            btn_output2_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output3_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output3_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O3_EXT2, false)){
            btn_output3_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output3_ext2;
        }else{
            btn_output3_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output4_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output4_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O4_EXT2, false)){
            btn_output4_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output4_ext2;
        }else{
            btn_output4_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output5_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output5_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O5_EXT2, false)){
            btn_output5_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output5_ext2;
        }else{
            btn_output5_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output6_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output6_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O6_EXT2, false)){
            btn_output6_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output6_ext2;
        }else{
            btn_output6_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output7_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output7_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O7_EXT2, false)){
            btn_output7_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output7_ext2;
        }else{
            btn_output7_ext2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output8_ext2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output8_ext2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O8_EXT2, false)){
            btn_output8_ext2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output8_ext2;
        }else{
            btn_output8_ext2.setVisibility(View.INVISIBLE);
        }

        //ext3
        lp = (RelativeLayout.LayoutParams) btn_output1_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output1_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O1_EXT3, false)){
            btn_output1_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output1_ext3;
        }else{
            btn_output1_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output2_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output2_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O2_EXT3, false)){
            btn_output2_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output2_ext3;
        }else{
            btn_output2_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output3_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output3_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O3_EXT3, false)){
            btn_output3_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output3_ext3;
        }else{
            btn_output3_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output4_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output4_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O4_EXT3, false)){
            btn_output4_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output4_ext3;
        }else{
            btn_output4_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output5_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output5_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O5_EXT3, false)){
            btn_output5_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output5_ext3;
        }else{
            btn_output5_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output6_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output6_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O6_EXT3, false)){
            btn_output6_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output6_ext3;
        }else{
            btn_output6_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output7_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output7_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O7_EXT3, false)){
            btn_output7_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output7_ext3;
        }else{
            btn_output7_ext3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output8_ext3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output8_ext3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O8_EXT3, false)){
            btn_output8_ext3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output8_ext3;
        }else{
            btn_output8_ext3.setVisibility(View.INVISIBLE);
        }

        //ext4
        lp = (RelativeLayout.LayoutParams) btn_output1_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output1_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O1_EXT4, false)){
            btn_output1_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output1_ext4;
        }else{
            btn_output1_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output2_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output2_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O2_EXT4, false)){
            btn_output2_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output2_ext4;
        }else{
            btn_output2_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output3_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output3_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O3_EXT4, false)){
            btn_output3_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output3_ext4;
        }else{
            btn_output3_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output4_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output4_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O4_EXT4, false)){
            btn_output4_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output4_ext4;
        }else{
            btn_output4_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output5_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output5_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O5_EXT4, false)){
            btn_output5_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output5_ext4;
        }else{
            btn_output5_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output6_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output6_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O6_EXT4, false)){
            btn_output6_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output6_ext4;
        }else{
            btn_output6_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output7_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output7_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O7_EXT4, false)){
            btn_output7_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output7_ext4;
        }else{
            btn_output7_ext4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_output8_ext4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_output8_ext4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_O8_EXT4, false)){
            btn_output8_ext4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_output8_ext4;
        }else{
            btn_output8_ext4.setVisibility(View.INVISIBLE);
        }


        //radio socket

        //blk1
        lp = (RelativeLayout.LayoutParams) btn_socket1_blk1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket1_blk1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET1_BLK1, false)){
            btn_socket1_blk1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket1_blk1;
        }else{
            btn_socket1_blk1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket2_blk1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket2_blk1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET2_BLK1, false)){
            btn_socket2_blk1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket2_blk1;
        }else{
            btn_socket2_blk1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket3_blk1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket3_blk1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET3_BLK1, false)){
            btn_socket3_blk1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket3_blk1;
        }else{
            btn_socket3_blk1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket4_blk1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket4_blk1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET4_BLK1, false)){
            btn_socket4_blk1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket4_blk1;
        }else{
            btn_socket4_blk1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket5_blk1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket5_blk1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET5_BLK1, false)){
            btn_socket5_blk1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket5_blk1;
        }else{
            btn_socket5_blk1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket6_blk1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket6_blk1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET6_BLK1, false)){
            btn_socket6_blk1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket6_blk1;
        }else{
            btn_socket6_blk1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket7_blk1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket7_blk1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET7_BLK1, false)){
            btn_socket7_blk1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket7_blk1;
        }else{
            btn_socket7_blk1.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket8_blk1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket8_blk1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET8_BLK1, false)){
            btn_socket8_blk1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket8_blk1;
        }else{
            btn_socket8_blk1.setVisibility(View.INVISIBLE);
        }

        //blk2
        lp = (RelativeLayout.LayoutParams) btn_socket1_blk2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket1_blk2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET1_BLK2, false)){
            btn_socket1_blk2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket1_blk2;
        }else{
            btn_socket1_blk2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket2_blk2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket2_blk2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET2_BLK2, false)){
            btn_socket2_blk2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket2_blk2;
        }else{
            btn_socket2_blk2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket3_blk2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket3_blk2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET3_BLK2, false)){
            btn_socket3_blk2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket3_blk2;
        }else{
            btn_socket3_blk2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket4_blk2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket4_blk2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET4_BLK2, false)){
            btn_socket4_blk2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket4_blk2;
        }else{
            btn_socket4_blk2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket5_blk2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket5_blk2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET5_BLK2, false)){
            btn_socket5_blk2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket5_blk2;
        }else{
            btn_socket5_blk2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket6_blk2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket6_blk2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET6_BLK2, false)){
            btn_socket6_blk2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket6_blk2;
        }else{
            btn_socket6_blk2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket7_blk2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket7_blk2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET7_BLK2, false)){
            btn_socket7_blk2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket7_blk2;
        }else{
            btn_socket7_blk2.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket8_blk2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket8_blk2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET8_BLK2, false)){
            btn_socket8_blk2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket8_blk2;
        }else{
            btn_socket8_blk2.setVisibility(View.INVISIBLE);
        }

        //blk3
        lp = (RelativeLayout.LayoutParams) btn_socket1_blk3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket1_blk3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET1_BLK3, false)){
            btn_socket1_blk3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket1_blk3;
        }else{
            btn_socket1_blk3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket2_blk3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket2_blk3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET2_BLK3, false)){
            btn_socket2_blk3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket2_blk3;
        }else{
            btn_socket2_blk3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket3_blk3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket3_blk3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET3_BLK3, false)){
            btn_socket3_blk3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket3_blk3;
        }else{
            btn_socket3_blk3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket4_blk3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket4_blk3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET4_BLK3, false)){
            btn_socket4_blk3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket4_blk3;
        }else{
            btn_socket4_blk3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket5_blk3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket5_blk3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET5_BLK3, false)){
            btn_socket5_blk3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket5_blk3;
        }else{
            btn_socket5_blk3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket6_blk3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket6_blk3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET6_BLK3, false)){
            btn_socket6_blk3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket6_blk3;
        }else{
            btn_socket6_blk3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket7_blk3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket7_blk3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET7_BLK3, false)){
            btn_socket7_blk3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket7_blk3;
        }else{
            btn_socket7_blk3.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket8_blk3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket8_blk3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET8_BLK3, false)){
            btn_socket8_blk3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket8_blk3;
        }else{
            btn_socket8_blk3.setVisibility(View.INVISIBLE);
        }

        //blk4
        lp = (RelativeLayout.LayoutParams) btn_socket1_blk4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket1_blk4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET1_BLK4, false)){
            btn_socket1_blk4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket1_blk4;
        }else{
            btn_socket1_blk4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket2_blk4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket2_blk4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET2_BLK4, false)){
            btn_socket2_blk4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket2_blk4;
        }else{
            btn_socket2_blk4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket3_blk4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket3_blk4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET3_BLK4, false)){
            btn_socket3_blk4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket3_blk4;
        }else{
            btn_socket3_blk4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket4_blk4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket4_blk4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET4_BLK4, false)){
            btn_socket4_blk4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket4_blk4;
        }else{
            btn_socket4_blk4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket5_blk4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket5_blk4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET5_BLK4, false)){
            btn_socket5_blk4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket5_blk4;
        }else{
            btn_socket5_blk4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket6_blk4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket6_blk4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET6_BLK4, false)){
            btn_socket6_blk4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket6_blk4;
        }else{
            btn_socket6_blk4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket7_blk4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket7_blk4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET7_BLK4, false)){
            btn_socket7_blk4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket7_blk4;
        }else{
            btn_socket7_blk4.setVisibility(View.INVISIBLE);
        }

        lp = (RelativeLayout.LayoutParams) btn_socket8_blk4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        btn_socket8_blk4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_SOCKET8_BLK4, false)){
            btn_socket8_blk4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.btn_socket8_blk4;
        }else{
            btn_socket8_blk4.setVisibility(View.INVISIBLE);
        }



        //radio
        lp = (RelativeLayout.LayoutParams) textView_wr.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_wr.setLayoutParams(lp);
        if (!mSettings.getBoolean(APP_PREFERENCES_VIEW_R1, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R5, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R6, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R7, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R8, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R9, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R10, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R11, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R12, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R13, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R14, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R15, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_R16, false)
                )
        {
            textView_wr.setVisibility(View.INVISIBLE);
        }else{
            textView_wr.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_wr;
        }

        //radio1
        lp = (RelativeLayout.LayoutParams) textView_radio1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R1, false)){
            textView_radio1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio1;
        }else{
            textView_radio1.setVisibility(View.INVISIBLE);
        }

        //radio2
        lp = (RelativeLayout.LayoutParams) textView_radio2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R2, false)){
            textView_radio2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio2;
        }else{
            textView_radio2.setVisibility(View.INVISIBLE);
        }

        //radio3
        lp = (RelativeLayout.LayoutParams) textView_radio3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R3, false)){
            textView_radio3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio3;
        }else{
            textView_radio3.setVisibility(View.INVISIBLE);
        }

        //radio4
        lp = (RelativeLayout.LayoutParams) textView_radio4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R4, false)){
            textView_radio4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio4;
        }else{
            textView_radio4.setVisibility(View.INVISIBLE);
        }

        //radio5
        lp = (RelativeLayout.LayoutParams) textView_radio5.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio5.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R5, false)){
            textView_radio5.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio5;
        }else{
            textView_radio5.setVisibility(View.INVISIBLE);
        }

        //radio6
        lp = (RelativeLayout.LayoutParams) textView_radio6.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio6.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R6, false)){
            textView_radio6.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio6;
        }else{
            textView_radio6.setVisibility(View.INVISIBLE);
        }

        //radio7
        lp = (RelativeLayout.LayoutParams) textView_radio7.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio7.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R7, false)){
            textView_radio7.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio7;
        }else{
            textView_radio7.setVisibility(View.INVISIBLE);
        }

        //radio8
        lp = (RelativeLayout.LayoutParams) textView_radio8.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio8.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R8, false)){
            textView_radio8.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio8;
        }else{
            textView_radio8.setVisibility(View.INVISIBLE);
        }

        //radio9
        lp = (RelativeLayout.LayoutParams) textView_radio9.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio9.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R9, false)){
            textView_radio9.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio9;
        }else{
            textView_radio9.setVisibility(View.INVISIBLE);
        }

        //radio10
        lp = (RelativeLayout.LayoutParams) textView_radio10.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio10.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R10, false)){
            textView_radio10.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio10;
        }else{
            textView_radio10.setVisibility(View.INVISIBLE);
        }

        //radio11
        lp = (RelativeLayout.LayoutParams) textView_radio11.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio11.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R11, false)){
            textView_radio11.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio11;
        }else{
            textView_radio11.setVisibility(View.INVISIBLE);
        }

        //radio12
        lp = (RelativeLayout.LayoutParams) textView_radio12.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio12.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R12, false)){
            textView_radio12.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio12;
        }else{
            textView_radio12.setVisibility(View.INVISIBLE);
        }

        //radio13
        lp = (RelativeLayout.LayoutParams) textView_radio13.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio13.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R13, false)){
            textView_radio13.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio13;
        }else{
            textView_radio13.setVisibility(View.INVISIBLE);
        }

        //radio14
        lp = (RelativeLayout.LayoutParams) textView_radio14.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio14.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R14, false)){
            textView_radio14.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio14;
        }else{
            textView_radio14.setVisibility(View.INVISIBLE);
        }

        //radio15
        lp = (RelativeLayout.LayoutParams) textView_radio15.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio15.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R15, false)){
            textView_radio15.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio15;
        }else{
            textView_radio15.setVisibility(View.INVISIBLE);
        }

        //radio16
        lp = (RelativeLayout.LayoutParams) textView_radio16.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_radio16.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_R16, false)){
            textView_radio16.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_radio16;
        }else{
            textView_radio16.setVisibility(View.INVISIBLE);
        }

        //termo
        lp = (RelativeLayout.LayoutParams) textView_t.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_t.setLayoutParams(lp);
        if (!mSettings.getBoolean(APP_PREFERENCES_VIEW_T1, true) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_T2, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_T3, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_T4, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_T5, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_T6, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_T7, false) &&
                !mSettings.getBoolean(APP_PREFERENCES_VIEW_T8, false)
                )
        {
            textView_t.setVisibility(View.INVISIBLE);
        }else{
            textView_t.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_t;
        }

        //termo1
        lp = (RelativeLayout.LayoutParams) textView_termo1.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_termo1.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_T1, true)){
            textView_termo1.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_termo1;
        }else{
            textView_termo1.setVisibility(View.INVISIBLE);
        }

        //termo2
        lp = (RelativeLayout.LayoutParams) textView_termo2.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_termo2.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_T2, false)){
            textView_termo2.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_termo2;
        }else{
            textView_termo2.setVisibility(View.INVISIBLE);
        }

        //termo3
        lp = (RelativeLayout.LayoutParams) textView_termo3.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_termo3.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_T3, false)){
            textView_termo3.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_termo3;
        }else{
            textView_termo3.setVisibility(View.INVISIBLE);
        }

        //termo4
        lp = (RelativeLayout.LayoutParams) textView_termo4.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_termo4.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_T4, false)){
            textView_termo4.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_termo4;
        }else{
            textView_termo4.setVisibility(View.INVISIBLE);
        }

        //termo5
        lp = (RelativeLayout.LayoutParams) textView_termo5.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_termo5.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_T5, false)){
            textView_termo5.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_termo5;
        }else{
            textView_termo5.setVisibility(View.INVISIBLE);
        }

        //termo6
        lp = (RelativeLayout.LayoutParams) textView_termo6.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_termo6.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_T6, false)){
            textView_termo6.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_termo6;
        }else{
            textView_termo6.setVisibility(View.INVISIBLE);
        }

        //termo7
        lp = (RelativeLayout.LayoutParams) textView_termo7.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_termo7.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_T7, false)){
            textView_termo7.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_termo7;
        }else{
            textView_termo7.setVisibility(View.INVISIBLE);
        }

        //termo8
        lp = (RelativeLayout.LayoutParams) textView_termo8.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_termo8.setLayoutParams(lp);
        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_T8, false)){
            textView_termo8.setVisibility(View.VISIBLE);
            cur_anchor=R.id.textView_termo8;
        }else{
            textView_termo8.setVisibility(View.INVISIBLE);
        }

        //controller
        lp = (RelativeLayout.LayoutParams) textView_controller.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        textView_controller.setLayoutParams(lp);
        cur_anchor=R.id.textView_controller;

        //spinner
        lp = (RelativeLayout.LayoutParams) spinner.getLayoutParams();
        lp.addRule(RelativeLayout.BELOW, cur_anchor);
        spinner.setLayoutParams(lp);



        //power
        if (mSettings.contains(APP_PREFERENCES_IMAGE_VIEW_POWER)) {
            temp = mSettings.getString(APP_PREFERENCES_IMAGE_VIEW_POWER, "imageView_power_");
            imageView_power_.setVisibility(View.INVISIBLE);
            if (temp.equals("imageView_power_on")) {
                imageView_power_on.setVisibility(View.VISIBLE);
                imageView_power_off.setVisibility(View.INVISIBLE);
            }
            if (temp.equals("imageView_power_off")) {
                imageView_power_off.setVisibility(View.VISIBLE);
                imageView_power_on.setVisibility(View.INVISIBLE);
            }

        }

        if (mSettings.contains(APP_PREFERENCES_IMAGE_VIEW_ARM)) {
            temp = mSettings.getString(APP_PREFERENCES_IMAGE_VIEW_ARM, "imageView_arm_");
            imageView_arm_.setVisibility(View.INVISIBLE);
            if (temp.equals("imageView_arm_on")) {
                imageView_arm_on.setVisibility(View.VISIBLE);
                imageView_arm_off.setVisibility(View.INVISIBLE);
            }
            if (temp.equals("imageView_arm_off")) {
                imageView_arm_off.setVisibility(View.VISIBLE);
                imageView_arm_on.setVisibility(View.INVISIBLE);
            }

        }


        if (mSettings.contains(APP_PREFERENCES_IMAGE_VIEW_GSM)) {
            temp = mSettings.getString(APP_PREFERENCES_IMAGE_VIEW_GSM, "imageView_GSM_");
            imageView_GSM_.setVisibility(View.INVISIBLE);

            if (temp.equals("imageView_GSM_high")) {
                imageView_GSM_high.setVisibility(View.VISIBLE);
                imageView_GSM_medium.setVisibility(View.INVISIBLE);
                imageView_GSM_low.setVisibility(View.INVISIBLE);
            }

            if (temp.equals("imageView_GSM_medium")) {
                imageView_GSM_high.setVisibility(View.INVISIBLE);
                imageView_GSM_medium.setVisibility(View.VISIBLE);
                imageView_GSM_low.setVisibility(View.INVISIBLE);
            }

            if (temp.equals("imageView_GSM_low")) {
                imageView_GSM_high.setVisibility(View.INVISIBLE);
                imageView_GSM_medium.setVisibility(View.INVISIBLE);
                imageView_GSM_low.setVisibility(View.VISIBLE);
            }


        }



        if (mSettings.contains(APP_PREFERENCES_IMAGE_VIEW_INPUT)) {
            temp = mSettings.getString(APP_PREFERENCES_IMAGE_VIEW_INPUT, "imageView_input_");
            imageView_input_.setVisibility(View.INVISIBLE);

            if (temp.equals("imageView_input_norma")) {

                imageView_input_norma.setVisibility(View.VISIBLE);
                imageView_input_trevoga.setVisibility(View.INVISIBLE);
            }

            if (temp.equals("imageView_input_trevoga")) {

                imageView_input_norma.setVisibility(View.INVISIBLE);
                imageView_input_trevoga.setVisibility(View.VISIBLE);
            }




        }

        /*
        if (mSettings.contains(APP_PREFERENCES_CHECK_BOX_QUERY)) {
            temp = mSettings.getString(APP_PREFERENCES_CHECK_BOX_QUERY, "uncheck");
            checkBox_query.setChecked(false);
            if (temp.equals("check")) {
                checkBox_query.setChecked(true);
            }


        }
        */





//--------------------------- выпадающий список смс-команд
        String[] data = {
                mSettings.getString(APP_PREFERENCES_NAME_COMAND1, getString(R.string.set_command1_)),
                mSettings.getString(APP_PREFERENCES_NAME_COMAND2, getString(R.string.set_command2_)),
                mSettings.getString(APP_PREFERENCES_NAME_COMAND3, getString(R.string.set_command3_)),
                mSettings.getString(APP_PREFERENCES_NAME_COMAND4, getString(R.string.set_command4_)),
                mSettings.getString(APP_PREFERENCES_NAME_COMAND5, getString(R.string.set_command5_)),
                mSettings.getString(APP_PREFERENCES_NAME_COMAND6, getString(R.string.set_command6_)),
                mSettings.getString(APP_PREFERENCES_NAME_COMAND7, getString(R.string.set_command7_)),
                mSettings.getString(APP_PREFERENCES_NAME_COMAND8, getString(R.string.set_command8_))
                };


        // адаптер
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, data);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        Spinner spinner = (Spinner) findViewById(R.id.spinner);
        spinner.setAdapter(adapter);
        // заголовок
        spinner.setPrompt(getString(R.string.command_list)); //"Список команд");
        // выделяем элемент
        spinner.setSelection(0);


        // устанавливаем обработчик нажатия
        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view,
                                       int position, long id) {
                // показываем позиция нажатого элемента
                //Toast.makeText(getBaseContext(), "Position = " + position, Toast.LENGTH_SHORT).show();
                COMMAND_POSITION = position;
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
            }
        });

        //--------------------------- обработчик события нажатия кнопки
        btn_send_command.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
        //Command=Form_T(txtCommand.getText().toString());
                //проигрываем файл
                Play_Key_Pressed();

                switch (COMMAND_POSITION)
                {
                    case 0:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND1, getString(R.string.set_code1_))  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND1, getString(R.string.set_code1_)) + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND1, getString(R.string.set_code1_)));
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND1, getString(R.string.set_code1_)), false);
                        }
                       break;
                    case 1:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND2, getString(R.string.set_code2_))  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND2, getString(R.string.set_code2_)) + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND2, getString(R.string.set_code2_)));
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND2, getString(R.string.set_code2_)), false);
                        }
                        break;
                    case 2:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND3, getString(R.string.set_code3_))  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND3, getString(R.string.set_code3_)) + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND3, getString(R.string.set_code3_)));
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND3, getString(R.string.set_code3_)), false);
                        }
                        break;
                    case 3:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND4, getString(R.string.set_code4_))  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND4, getString(R.string.set_code4_)) + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND4, getString(R.string.set_code4_)));
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND4, getString(R.string.set_code4_)), false);
                        }
                        break;
                    case 4:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND5, getString(R.string.set_code5_))  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND5, getString(R.string.set_code5_)) + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND5, getString(R.string.set_code5_)));
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND5, getString(R.string.set_code5_)), false);
                        }
                        break;
                    case 5:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND6, getString(R.string.set_code6_))  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND6, getString(R.string.set_code6_)) + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND6, getString(R.string.set_code6_)));
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND6, getString(R.string.set_code6_)), false);
                        }
                        break;
                    case 6:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND7, getString(R.string.set_code7_))  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND7, getString(R.string.set_code7_)) + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND7, getString(R.string.set_code7_)));
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND7, getString(R.string.set_code7_)), false);
                        }
                        break;
                    case 7:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND8, getString(R.string.set_code8_)) + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND8, getString(R.string.set_code8_)) + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(mSettings.getString(APP_PREFERENCES_CODE_COMAND8, getString(R.string.set_code8_)));
                            if(CONNECTION_POSITION==1) try_send_to_server(mSettings.getString(APP_PREFERENCES_CODE_COMAND8, getString(R.string.set_code8_)), false);
                        }
                        break;
                    /*
                    case 8:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out5_on  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out5_on + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out5_on);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out5_on, false);
                        }
                        break;
                    case 9:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out5_off  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out5_off + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out5_off);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out5_off, false);
                        }
                        break;
                    case 10:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out6_on  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out6_on + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out6_on);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out6_on, false);
                        }
                        break;
                    case 11:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out6_off  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out6_off + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out6_off);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out6_off, false);
                        }
                        break;
                    case 12:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out7_on  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out7_on + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out7_on);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out7_on, false);
                        }
                        break;
                    case 13:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out7_off  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out7_off + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out7_off);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out7_off, false);
                        }
                        break;
                    case 14:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out8_on  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out8_on + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out8_on);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out8_on, false);
                        }
                        break;
                    case 15:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out8_off  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out8_off + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_out8_off);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_out8_off, false);
                        }
                        break;

                    case 16:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_sirena_on  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_sirena_on + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_sirena_on);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_sirena_on, false);
                        }
                        break;
                    case 17:
                        if (mSettings.getBoolean(APP_PREFERENCES_CHECK_BOX_QUERY, false)) {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_sirena_off  + "," + Query);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_sirena_off + "," + Query_server, false);
                        } else {
                            if(CONNECTION_POSITION==0) try_sendSMS(SMS_Command_sirena_off);
                            if(CONNECTION_POSITION==1) try_send_to_server(SMS_Command_sirena_off, false);
                        }
                        break;

                    case 18:
                        try_sendSMS(SMS_Command_Config);
                        break;
                    */
                }

            }
        });
//-------------------------------------------------------

        //if (isMyServiceRunning(oko.tm.oko_pro_classic.MyService.class)) try_send_to_server(Query_server); //запрос состояния прибора
        String connection="1";
        if (mSettings.contains(APP_PREFERENCES_CONNECTION)) {
            connection = mSettings.getString(APP_PREFERENCES_CONNECTION, "1");
        }

        String server=ClientThread.SERVER_INI;
        if (mSettings.contains(APP_PREFERENCES_SERVER)) {
            server = mSettings.getString(APP_PREFERENCES_SERVER, ClientThread.SERVER_INI);
        }

        int port=ClientThread.SERVERPORT;
        if (mSettings.contains(APP_PREFERENCES_PORT)) {
            port = Integer.parseInt(mSettings.getString(APP_PREFERENCES_PORT, String.valueOf(ClientThread.SERVERPORT)));
        }

        if ("1".equals(connection)) {
            CONNECTION_POSITION=0;

            //check all connections settings
            boolean exist_internet_connection=false;
            try {
                SharedPreferences tempSettings;
                for (int i=0; i< StartActivity.objectsSettings.length; i++){
                    tempSettings= getSharedPreferences(StartActivity.objectsSettings[i], Context.MODE_PRIVATE);
                    String conn="1";
                    if (tempSettings.contains(APP_PREFERENCES_CONNECTION)) {
                        conn = tempSettings.getString(APP_PREFERENCES_CONNECTION, "1");
                    }
                    if ("2".equals(conn)) exist_internet_connection=true;
                }
            }
            catch (Exception e) {
                e.printStackTrace();
            }

            if (!exist_internet_connection) {
                //STOP TCP_client
                new Thread(new Runnable() {
                    public void run() {
                        try {
                            Stop_Service();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }).start();
            }
            btn_restart_connection.setBackgroundResource(R.drawable.btn_red);
            btn_restart_connection.setVisibility(View.INVISIBLE);
        }
        if ("2".equals(connection)) {
            CONNECTION_POSITION=1;
            btn_restart_connection.setVisibility(View.VISIBLE);

            if (!cur_IMEI.equals(IMEI) || !cur_Server.equals(server) || !(cur_Port == port) || !isMyServiceRunning(oko.tm.oko_pro_classic.TCP_client.class) ) { //
                cur_IMEI = IMEI;
                cur_Server=server;
                cur_Port = port;

                    if (!Service_Restart) {
                        //restart connection
                        new Thread(new Runnable() {
                            public void run() {
                                try {
                                    Reset_Connection();
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }

                            }
                        }).start();
                    }

            }
        }

        StartActivity.MainActivity_Started=true;
        //SmsReceiver.MainActivity_Started=true;

        SharedPreferences pSettings;
        pSettings= getSharedPreferences(StartActivity.START_PREFERENCES, Context.MODE_PRIVATE);
        String app_pass = "";
        if (pSettings.contains(StartActivity.START_PREFERENCES_APPPASSWORD)) {
            app_pass = pSettings.getString(StartActivity.START_PREFERENCES_APPPASSWORD, "");
        }

        if (StartActivity.need_check_password  && (app_pass.length() > 0) ) { //
            Intent passwordActivity = new Intent();
            passwordActivity.setClass(mContext, PasswordActivity.class);
            passwordActivity.setAction(PasswordActivity.class.getName());
            //passwordActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP );
            startActivity(passwordActivity);
        }
    }


    @Override
    protected void onDestroy() {
        //mapView.onDestroy();
        super.onDestroy();
        Log.d(TAG, "MainActivity onDestroy");
        //destroid application
        // дерегистрируем (выключаем) BroadcastReceiver
        //unregisterReceiver(br_tcp);
        LocalBroadcastManager.getInstance(mContext).unregisterReceiver(br_tcp);
        //unregisterReceiver(br_sms);
        LocalBroadcastManager.getInstance(mContext).unregisterReceiver(br_sms);
        StartActivity.MainActivity_Started=false;
        //SmsReceiver.MainActivity_Started=false;
    }

    @Override
    protected void onPause() {
        //mapView.onPause();
        super.onPause();
    }

    @Override
    protected void onStart() {
        super.onStart();
        //mapView.onStart();
    }

    @Override
    public void onStop() {
        super.onStop();
        //mapView.onStop();

        Log.d(TAG, "MainActivity onStop");
        //hidden application
        try {
            //ClientThread.StartActivity_Started = false;
            //SmsReceiver.StartActivity_Started = false;
        }catch (Exception e) {
            e.printStackTrace();
        }
    }

    private String Form_T (String command) {
        if (command.length() == 0) {command="0";}
        if (command.substring(0,1).equals("-"))
        {
            command = command.replace('-', '0');
            if (command.length() < 3) {
                command = "000" + command;
            }
            command = '-' + command.substring(command.length() - 2);
        } else {
            command = command.replace('+', '0');
            if (command.length() < 3) {
                command = "000" + command;
            }
            command = command.substring(command.length() - 3);
        }
        return command;
    }

    private void colour_io()
    {
        //if (btn_arm.getText().toString().indexOf(VYKL)>-1) btn_arm.setBackgroundResource(R.drawable.btn_grey); else btn_arm.setBackgroundResource(R.drawable.btn_yellow);
        if (btn_arm.getText().toString().indexOf(VYKL)>-1) btn_arm.setBackgroundColor (COLOR_WHITE); else btn_arm.setBackgroundColor(COLOR_YELLOW);

        if (textView_power.getText().toString().indexOf(RAZRYAD_AKKUM)>-1)
            textView_power.setBackgroundColor (COLOR_RED); else textView_power.setBackgroundColor (COLOR_WHITE);

        //colour inputs and outputs
        if (state_output1.equals(separation + OUTPUT_ON))
            //btn_output1.setBackgroundColor (COLOR_GREEN); else btn_output1.setBackgroundColor(COLOR_GREY);
            btn_output1.setBackgroundResource(R.drawable.btn_green); else btn_output1.setBackgroundResource(R.drawable.btn_grey);

        if (state_output2.equals(separation + OUTPUT_ON))
            //btn_output2.setBackgroundColor (COLOR_GREEN); else btn_output2.setBackgroundColor(COLOR_GREY);
            btn_output2.setBackgroundResource(R.drawable.btn_green); else btn_output2.setBackgroundResource(R.drawable.btn_grey);

        if (state_output3.equals(separation + OUTPUT_ON))
            //btn_output3.setBackgroundColor (COLOR_GREEN); else btn_output3.setBackgroundColor(COLOR_GREY);
            btn_output3.setBackgroundResource(R.drawable.btn_green); else btn_output3.setBackgroundResource(R.drawable.btn_grey);

        if (state_output4.equals(separation + OUTPUT_ON))
            btn_output4.setBackgroundResource(R.drawable.btn_green); else btn_output4.setBackgroundResource(R.drawable.btn_grey);

        if (state_output5.equals(separation + OUTPUT_ON))
            btn_output5.setBackgroundResource(R.drawable.btn_green); else btn_output5.setBackgroundResource(R.drawable.btn_grey);

        if (state_output6.equals(separation + OUTPUT_ON))
            btn_output6.setBackgroundResource(R.drawable.btn_green); else btn_output6.setBackgroundResource(R.drawable.btn_grey);

        if (state_output7.equals(separation + OUTPUT_ON))
            btn_output7.setBackgroundResource(R.drawable.btn_green); else btn_output7.setBackgroundResource(R.drawable.btn_grey);

        if (state_output8.equals(separation + OUTPUT_ON))
            btn_output8.setBackgroundResource(R.drawable.btn_green); else btn_output8.setBackgroundResource(R.drawable.btn_grey);

        //ext0
        if (state_output1_ext0.equals(separation + OUTPUT_ON))
            btn_output1_ext0.setBackgroundResource(R.drawable.btn_green); else btn_output1_ext0.setBackgroundResource(R.drawable.btn_grey);
        if (state_output2_ext0.equals(separation + OUTPUT_ON))
            btn_output2_ext0.setBackgroundResource(R.drawable.btn_green); else btn_output2_ext0.setBackgroundResource(R.drawable.btn_grey);
        if (state_output3_ext0.equals(separation + OUTPUT_ON))
            btn_output3_ext0.setBackgroundResource(R.drawable.btn_green); else btn_output3_ext0.setBackgroundResource(R.drawable.btn_grey);
        if (state_output4_ext0.equals(separation + OUTPUT_ON))
            btn_output4_ext0.setBackgroundResource(R.drawable.btn_green); else btn_output4_ext0.setBackgroundResource(R.drawable.btn_grey);
        if (state_output5_ext0.equals(separation + OUTPUT_ON))
            btn_output5_ext0.setBackgroundResource(R.drawable.btn_green); else btn_output5_ext0.setBackgroundResource(R.drawable.btn_grey);
        if (state_output6_ext0.equals(separation + OUTPUT_ON))
            btn_output6_ext0.setBackgroundResource(R.drawable.btn_green); else btn_output6_ext0.setBackgroundResource(R.drawable.btn_grey);
        if (state_output7_ext0.equals(separation + OUTPUT_ON))
            btn_output7_ext0.setBackgroundResource(R.drawable.btn_green); else btn_output7_ext0.setBackgroundResource(R.drawable.btn_grey);
        if (state_output8_ext0.equals(separation + OUTPUT_ON))
            btn_output8_ext0.setBackgroundResource(R.drawable.btn_green); else btn_output8_ext0.setBackgroundResource(R.drawable.btn_grey);


        //ext1
        if (state_output1_ext1.equals(separation + OUTPUT_ON))
            btn_output1_ext1.setBackgroundResource(R.drawable.btn_green); else btn_output1_ext1.setBackgroundResource(R.drawable.btn_grey);
        if (state_output2_ext1.equals(separation + OUTPUT_ON))
            btn_output2_ext1.setBackgroundResource(R.drawable.btn_green); else btn_output2_ext1.setBackgroundResource(R.drawable.btn_grey);
        if (state_output3_ext1.equals(separation + OUTPUT_ON))
            btn_output3_ext1.setBackgroundResource(R.drawable.btn_green); else btn_output3_ext1.setBackgroundResource(R.drawable.btn_grey);
        if (state_output4_ext1.equals(separation + OUTPUT_ON))
            btn_output4_ext1.setBackgroundResource(R.drawable.btn_green); else btn_output4_ext1.setBackgroundResource(R.drawable.btn_grey);
        if (state_output5_ext1.equals(separation + OUTPUT_ON))
            btn_output5_ext1.setBackgroundResource(R.drawable.btn_green); else btn_output5_ext1.setBackgroundResource(R.drawable.btn_grey);
        if (state_output6_ext1.equals(separation + OUTPUT_ON))
            btn_output6_ext1.setBackgroundResource(R.drawable.btn_green); else btn_output6_ext1.setBackgroundResource(R.drawable.btn_grey);
        if (state_output7_ext1.equals(separation + OUTPUT_ON))
            btn_output7_ext1.setBackgroundResource(R.drawable.btn_green); else btn_output7_ext1.setBackgroundResource(R.drawable.btn_grey);
        if (state_output8_ext1.equals(separation + OUTPUT_ON))
            btn_output8_ext1.setBackgroundResource(R.drawable.btn_green); else btn_output8_ext1.setBackgroundResource(R.drawable.btn_grey);

        //ext2
        if (state_output1_ext2.equals(separation + OUTPUT_ON))
            btn_output1_ext2.setBackgroundResource(R.drawable.btn_green); else btn_output1_ext2.setBackgroundResource(R.drawable.btn_grey);
        if (state_output2_ext2.equals(separation + OUTPUT_ON))
            btn_output2_ext2.setBackgroundResource(R.drawable.btn_green); else btn_output2_ext2.setBackgroundResource(R.drawable.btn_grey);
        if (state_output3_ext2.equals(separation + OUTPUT_ON))
            btn_output3_ext2.setBackgroundResource(R.drawable.btn_green); else btn_output3_ext2.setBackgroundResource(R.drawable.btn_grey);
        if (state_output4_ext2.equals(separation + OUTPUT_ON))
            btn_output4_ext2.setBackgroundResource(R.drawable.btn_green); else btn_output4_ext2.setBackgroundResource(R.drawable.btn_grey);
        if (state_output5_ext2.equals(separation + OUTPUT_ON))
            btn_output5_ext2.setBackgroundResource(R.drawable.btn_green); else btn_output5_ext2.setBackgroundResource(R.drawable.btn_grey);
        if (state_output6_ext2.equals(separation + OUTPUT_ON))
            btn_output6_ext2.setBackgroundResource(R.drawable.btn_green); else btn_output6_ext2.setBackgroundResource(R.drawable.btn_grey);
        if (state_output7_ext2.equals(separation + OUTPUT_ON))
            btn_output7_ext2.setBackgroundResource(R.drawable.btn_green); else btn_output7_ext2.setBackgroundResource(R.drawable.btn_grey);
        if (state_output8_ext2.equals(separation + OUTPUT_ON))
            btn_output8_ext2.setBackgroundResource(R.drawable.btn_green); else btn_output8_ext2.setBackgroundResource(R.drawable.btn_grey);

        //ext3
        if (state_output1_ext3.equals(separation + OUTPUT_ON))
            btn_output1_ext3.setBackgroundResource(R.drawable.btn_green); else btn_output1_ext3.setBackgroundResource(R.drawable.btn_grey);
        if (state_output2_ext3.equals(separation + OUTPUT_ON))
            btn_output2_ext3.setBackgroundResource(R.drawable.btn_green); else btn_output2_ext3.setBackgroundResource(R.drawable.btn_grey);
        if (state_output3_ext3.equals(separation + OUTPUT_ON))
            btn_output3_ext3.setBackgroundResource(R.drawable.btn_green); else btn_output3_ext3.setBackgroundResource(R.drawable.btn_grey);
        if (state_output4_ext3.equals(separation + OUTPUT_ON))
            btn_output4_ext3.setBackgroundResource(R.drawable.btn_green); else btn_output4_ext3.setBackgroundResource(R.drawable.btn_grey);
        if (state_output5_ext3.equals(separation + OUTPUT_ON))
            btn_output5_ext3.setBackgroundResource(R.drawable.btn_green); else btn_output5_ext3.setBackgroundResource(R.drawable.btn_grey);
        if (state_output6_ext3.equals(separation + OUTPUT_ON))
            btn_output6_ext3.setBackgroundResource(R.drawable.btn_green); else btn_output6_ext3.setBackgroundResource(R.drawable.btn_grey);
        if (state_output7_ext3.equals(separation + OUTPUT_ON))
            btn_output7_ext3.setBackgroundResource(R.drawable.btn_green); else btn_output7_ext3.setBackgroundResource(R.drawable.btn_grey);
        if (state_output8_ext3.equals(separation + OUTPUT_ON))
            btn_output8_ext3.setBackgroundResource(R.drawable.btn_green); else btn_output8_ext3.setBackgroundResource(R.drawable.btn_grey);

        //ext4
        if (state_output1_ext4.equals(separation + OUTPUT_ON))
            btn_output1_ext4.setBackgroundResource(R.drawable.btn_green); else btn_output1_ext4.setBackgroundResource(R.drawable.btn_grey);
        if (state_output2_ext4.equals(separation + OUTPUT_ON))
            btn_output2_ext4.setBackgroundResource(R.drawable.btn_green); else btn_output2_ext4.setBackgroundResource(R.drawable.btn_grey);
        if (state_output3_ext4.equals(separation + OUTPUT_ON))
            btn_output3_ext4.setBackgroundResource(R.drawable.btn_green); else btn_output3_ext4.setBackgroundResource(R.drawable.btn_grey);
        if (state_output4_ext4.equals(separation + OUTPUT_ON))
            btn_output4_ext4.setBackgroundResource(R.drawable.btn_green); else btn_output4_ext4.setBackgroundResource(R.drawable.btn_grey);
        if (state_output5_ext4.equals(separation + OUTPUT_ON))
            btn_output5_ext4.setBackgroundResource(R.drawable.btn_green); else btn_output5_ext4.setBackgroundResource(R.drawable.btn_grey);
        if (state_output6_ext4.equals(separation + OUTPUT_ON))
            btn_output6_ext4.setBackgroundResource(R.drawable.btn_green); else btn_output6_ext4.setBackgroundResource(R.drawable.btn_grey);
        if (state_output7_ext4.equals(separation + OUTPUT_ON))
            btn_output7_ext4.setBackgroundResource(R.drawable.btn_green); else btn_output7_ext4.setBackgroundResource(R.drawable.btn_grey);
        if (state_output8_ext4.equals(separation + OUTPUT_ON))
            btn_output8_ext4.setBackgroundResource(R.drawable.btn_green); else btn_output8_ext4.setBackgroundResource(R.drawable.btn_grey);

        //radio socket
        //blk1
        if (state_socket1_blk1.equals(separation + OUTPUT_ON))
            btn_socket1_blk1.setBackgroundResource(R.drawable.btn_green); else btn_socket1_blk1.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket2_blk1.equals(separation + OUTPUT_ON))
            btn_socket2_blk1.setBackgroundResource(R.drawable.btn_green); else btn_socket2_blk1.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket3_blk1.equals(separation + OUTPUT_ON))
            btn_socket3_blk1.setBackgroundResource(R.drawable.btn_green); else btn_socket3_blk1.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket4_blk1.equals(separation + OUTPUT_ON))
            btn_socket4_blk1.setBackgroundResource(R.drawable.btn_green); else btn_socket4_blk1.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket5_blk1.equals(separation + OUTPUT_ON))
            btn_socket5_blk1.setBackgroundResource(R.drawable.btn_green); else btn_socket5_blk1.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket6_blk1.equals(separation + OUTPUT_ON))
            btn_socket6_blk1.setBackgroundResource(R.drawable.btn_green); else btn_socket6_blk1.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket7_blk1.equals(separation + OUTPUT_ON))
            btn_socket7_blk1.setBackgroundResource(R.drawable.btn_green); else btn_socket7_blk1.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket8_blk1.equals(separation + OUTPUT_ON))
            btn_socket8_blk1.setBackgroundResource(R.drawable.btn_green); else btn_socket8_blk1.setBackgroundResource(R.drawable.btn_grey);

        //blk2
        if (state_socket1_blk2.equals(separation + OUTPUT_ON))
            btn_socket1_blk2.setBackgroundResource(R.drawable.btn_green); else btn_socket1_blk2.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket2_blk2.equals(separation + OUTPUT_ON))
            btn_socket2_blk2.setBackgroundResource(R.drawable.btn_green); else btn_socket2_blk2.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket3_blk2.equals(separation + OUTPUT_ON))
            btn_socket3_blk2.setBackgroundResource(R.drawable.btn_green); else btn_socket3_blk2.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket4_blk2.equals(separation + OUTPUT_ON))
            btn_socket4_blk2.setBackgroundResource(R.drawable.btn_green); else btn_socket4_blk2.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket5_blk2.equals(separation + OUTPUT_ON))
            btn_socket5_blk2.setBackgroundResource(R.drawable.btn_green); else btn_socket5_blk2.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket6_blk2.equals(separation + OUTPUT_ON))
            btn_socket6_blk2.setBackgroundResource(R.drawable.btn_green); else btn_socket6_blk2.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket7_blk2.equals(separation + OUTPUT_ON))
            btn_socket7_blk2.setBackgroundResource(R.drawable.btn_green); else btn_socket7_blk2.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket8_blk2.equals(separation + OUTPUT_ON))
            btn_socket8_blk2.setBackgroundResource(R.drawable.btn_green); else btn_socket8_blk2.setBackgroundResource(R.drawable.btn_grey);

        //blk3
        if (state_socket1_blk3.equals(separation + OUTPUT_ON))
            btn_socket1_blk3.setBackgroundResource(R.drawable.btn_green); else btn_socket1_blk3.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket2_blk3.equals(separation + OUTPUT_ON))
            btn_socket2_blk3.setBackgroundResource(R.drawable.btn_green); else btn_socket2_blk3.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket3_blk3.equals(separation + OUTPUT_ON))
            btn_socket3_blk3.setBackgroundResource(R.drawable.btn_green); else btn_socket3_blk3.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket4_blk3.equals(separation + OUTPUT_ON))
            btn_socket4_blk3.setBackgroundResource(R.drawable.btn_green); else btn_socket4_blk3.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket5_blk3.equals(separation + OUTPUT_ON))
            btn_socket5_blk3.setBackgroundResource(R.drawable.btn_green); else btn_socket5_blk3.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket6_blk3.equals(separation + OUTPUT_ON))
            btn_socket6_blk3.setBackgroundResource(R.drawable.btn_green); else btn_socket6_blk3.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket7_blk3.equals(separation + OUTPUT_ON))
            btn_socket7_blk3.setBackgroundResource(R.drawable.btn_green); else btn_socket7_blk3.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket8_blk3.equals(separation + OUTPUT_ON))
            btn_socket8_blk3.setBackgroundResource(R.drawable.btn_green); else btn_socket8_blk3.setBackgroundResource(R.drawable.btn_grey);

        //blk4
        if (state_socket1_blk4.equals(separation + OUTPUT_ON))
            btn_socket1_blk4.setBackgroundResource(R.drawable.btn_green); else btn_socket1_blk4.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket2_blk4.equals(separation + OUTPUT_ON))
            btn_socket2_blk4.setBackgroundResource(R.drawable.btn_green); else btn_socket2_blk4.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket3_blk4.equals(separation + OUTPUT_ON))
            btn_socket3_blk4.setBackgroundResource(R.drawable.btn_green); else btn_socket3_blk4.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket4_blk4.equals(separation + OUTPUT_ON))
            btn_socket4_blk4.setBackgroundResource(R.drawable.btn_green); else btn_socket4_blk4.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket5_blk4.equals(separation + OUTPUT_ON))
            btn_socket5_blk4.setBackgroundResource(R.drawable.btn_green); else btn_socket5_blk4.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket6_blk4.equals(separation + OUTPUT_ON))
            btn_socket6_blk4.setBackgroundResource(R.drawable.btn_green); else btn_socket6_blk4.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket7_blk4.equals(separation + OUTPUT_ON))
            btn_socket7_blk4.setBackgroundResource(R.drawable.btn_green); else btn_socket7_blk4.setBackgroundResource(R.drawable.btn_grey);
        if (state_socket8_blk4.equals(separation + OUTPUT_ON))
            btn_socket8_blk4.setBackgroundResource(R.drawable.btn_green); else btn_socket8_blk4.setBackgroundResource(R.drawable.btn_grey);









        if (state_tamper.indexOf(separation + TREVOGA)>-1)
            textView_tamper.setBackgroundColor (COLOR_RED);
        else if(state_tamper.indexOf(separation + KZ)>-1 || state_tamper.indexOf(separation + OBRIV)>-1) textView_tamper.setBackgroundColor (COLOR_YELLOW); else textView_tamper.setBackgroundColor(COLOR_WHITE);


        if (state_input1.indexOf(separation + TREVOGA)>-1)
            textView_input1.setBackgroundColor (COLOR_RED);
        else if(state_input1.indexOf(separation + KZ)>-1 || state_input1.indexOf(separation + OBRIV)>-1) textView_input1.setBackgroundColor (COLOR_YELLOW); else textView_input1.setBackgroundColor(COLOR_WHITE);

        if (state_input2.indexOf(separation + TREVOGA)>-1)
            textView_input2.setBackgroundColor (COLOR_RED);
        else if(state_input2.indexOf(separation + KZ)>-1 || state_input2.indexOf(separation + OBRIV)>-1) textView_input2.setBackgroundColor (COLOR_YELLOW); else textView_input2.setBackgroundColor(COLOR_WHITE);

        if (state_input3.indexOf(separation + TREVOGA)>-1)
            textView_input3.setBackgroundColor (COLOR_RED);
        else if(state_input3.indexOf(separation + KZ)>-1 || state_input3.indexOf(separation + OBRIV)>-1) textView_input3.setBackgroundColor (COLOR_YELLOW); else textView_input3.setBackgroundColor(COLOR_WHITE);

        if (state_input4.indexOf(separation + TREVOGA)>-1)
            textView_input4.setBackgroundColor (COLOR_RED);
        else if(state_input4.indexOf(separation + KZ)>-1 || state_input4.indexOf(separation + OBRIV)>-1) textView_input4.setBackgroundColor (COLOR_YELLOW); else textView_input4.setBackgroundColor(COLOR_WHITE);

        if (state_input5.indexOf(separation + TREVOGA)>-1)
            textView_input5.setBackgroundColor (COLOR_RED);
        else if(state_input5.indexOf(separation + KZ)>-1 || state_input5.indexOf(separation + OBRIV)>-1) textView_input5.setBackgroundColor (COLOR_YELLOW); else textView_input5.setBackgroundColor(COLOR_WHITE);

        if (state_input6.indexOf(separation + TREVOGA)>-1)
            textView_input6.setBackgroundColor (COLOR_RED);
        else if(state_input6.indexOf(separation + KZ)>-1 || state_input6.indexOf(separation + OBRIV)>-1) textView_input6.setBackgroundColor (COLOR_YELLOW); else textView_input6.setBackgroundColor(COLOR_WHITE);

        if (state_input7.indexOf(separation + TREVOGA)>-1)
            textView_input7.setBackgroundColor (COLOR_RED);
        else if(state_input7.indexOf(separation + KZ)>-1 || state_input7.indexOf(separation + OBRIV)>-1) textView_input7.setBackgroundColor (COLOR_YELLOW); else textView_input7.setBackgroundColor(COLOR_WHITE);

        if (state_input8.indexOf(separation + TREVOGA)>-1)
            textView_input8.setBackgroundColor (COLOR_RED);
        else if(state_input8.indexOf(separation + KZ)>-1 || state_input8.indexOf(separation + OBRIV)>-1) textView_input8.setBackgroundColor (COLOR_YELLOW); else textView_input8.setBackgroundColor(COLOR_WHITE);

        //ext0
        if (state_input1_ext0.indexOf(separation + TREVOGA)>-1)
            textView_input1_ext0.setBackgroundColor (COLOR_RED);
        else if(state_input1_ext0.indexOf(separation + KZ)>-1 || state_input1_ext0.indexOf(separation + OBRIV)>-1)
            textView_input1_ext0.setBackgroundColor (COLOR_YELLOW);
        else textView_input1_ext0.setBackgroundColor(COLOR_WHITE);

        if (state_input2_ext0.indexOf(separation + TREVOGA)>-1)
            textView_input2_ext0.setBackgroundColor (COLOR_RED);
        else if(state_input2_ext0.indexOf(separation + KZ)>-1 || state_input2_ext0.indexOf(separation + OBRIV)>-1)
            textView_input2_ext0.setBackgroundColor (COLOR_YELLOW);
        else textView_input2_ext0.setBackgroundColor(COLOR_WHITE);

        if (state_input3_ext0.indexOf(separation + TREVOGA)>-1)
            textView_input3_ext0.setBackgroundColor (COLOR_RED);
        else if(state_input3_ext0.indexOf(separation + KZ)>-1 || state_input3_ext0.indexOf(separation + OBRIV)>-1)
            textView_input3_ext0.setBackgroundColor (COLOR_YELLOW);
        else textView_input3_ext0.setBackgroundColor(COLOR_WHITE);

        if (state_input4_ext0.indexOf(separation + TREVOGA)>-1)
            textView_input4_ext0.setBackgroundColor (COLOR_RED);
        else if(state_input4_ext0.indexOf(separation + KZ)>-1 || state_input4_ext0.indexOf(separation + OBRIV)>-1)
            textView_input4_ext0.setBackgroundColor (COLOR_YELLOW);
        else textView_input4_ext0.setBackgroundColor(COLOR_WHITE);

        if (state_input5_ext0.indexOf(separation + TREVOGA)>-1)
            textView_input5_ext0.setBackgroundColor (COLOR_RED);
        else if(state_input5_ext0.indexOf(separation + KZ)>-1 || state_input5_ext0.indexOf(separation + OBRIV)>-1)
            textView_input5_ext0.setBackgroundColor (COLOR_YELLOW);
        else textView_input5_ext0.setBackgroundColor(COLOR_WHITE);

        if (state_input6_ext0.indexOf(separation + TREVOGA)>-1)
            textView_input6_ext0.setBackgroundColor (COLOR_RED);
        else if(state_input6_ext0.indexOf(separation + KZ)>-1 || state_input6_ext0.indexOf(separation + OBRIV)>-1)
            textView_input6_ext0.setBackgroundColor (COLOR_YELLOW);
        else textView_input6_ext0.setBackgroundColor(COLOR_WHITE);

        if (state_input7_ext0.indexOf(separation + TREVOGA)>-1)
            textView_input7_ext0.setBackgroundColor (COLOR_RED);
        else if(state_input7_ext0.indexOf(separation + KZ)>-1 || state_input7_ext0.indexOf(separation + OBRIV)>-1)
            textView_input7_ext0.setBackgroundColor (COLOR_YELLOW);
        else textView_input7_ext0.setBackgroundColor(COLOR_WHITE);

        if (state_input8_ext0.indexOf(separation + TREVOGA)>-1)
            textView_input8_ext0.setBackgroundColor (COLOR_RED);
        else if(state_input8_ext0.indexOf(separation + KZ)>-1 || state_input8_ext0.indexOf(separation + OBRIV)>-1)
            textView_input8_ext0.setBackgroundColor (COLOR_YELLOW);
        else textView_input8_ext0.setBackgroundColor(COLOR_WHITE);

        //ext1
        if (state_input1_ext1.indexOf(separation + TREVOGA)>-1)
            textView_input1_ext1.setBackgroundColor (COLOR_RED);
        else if(state_input1_ext1.indexOf(separation + KZ)>-1 || state_input1_ext1.indexOf(separation + OBRIV)>-1)
            textView_input1_ext1.setBackgroundColor (COLOR_YELLOW);
        else textView_input1_ext1.setBackgroundColor(COLOR_WHITE);

        if (state_input2_ext1.indexOf(separation + TREVOGA)>-1)
            textView_input2_ext1.setBackgroundColor (COLOR_RED);
        else if(state_input2_ext1.indexOf(separation + KZ)>-1 || state_input2_ext1.indexOf(separation + OBRIV)>-1)
            textView_input2_ext1.setBackgroundColor (COLOR_YELLOW);
        else textView_input2_ext1.setBackgroundColor(COLOR_WHITE);

        if (state_input3_ext1.indexOf(separation + TREVOGA)>-1)
            textView_input3_ext1.setBackgroundColor (COLOR_RED);
        else if(state_input3_ext1.indexOf(separation + KZ)>-1 || state_input3_ext1.indexOf(separation + OBRIV)>-1)
            textView_input3_ext1.setBackgroundColor (COLOR_YELLOW);
        else textView_input3_ext1.setBackgroundColor(COLOR_WHITE);

        if (state_input4_ext1.indexOf(separation + TREVOGA)>-1)
            textView_input4_ext1.setBackgroundColor (COLOR_RED);
        else if(state_input4_ext1.indexOf(separation + KZ)>-1 || state_input4_ext1.indexOf(separation + OBRIV)>-1)
            textView_input4_ext1.setBackgroundColor (COLOR_YELLOW);
        else textView_input4_ext1.setBackgroundColor(COLOR_WHITE);

        if (state_input5_ext1.indexOf(separation + TREVOGA)>-1)
            textView_input5_ext1.setBackgroundColor (COLOR_RED);
        else if(state_input5_ext1.indexOf(separation + KZ)>-1 || state_input5_ext1.indexOf(separation + OBRIV)>-1)
            textView_input5_ext1.setBackgroundColor (COLOR_YELLOW);
        else textView_input5_ext1.setBackgroundColor(COLOR_WHITE);

        if (state_input6_ext1.indexOf(separation + TREVOGA)>-1)
            textView_input6_ext1.setBackgroundColor (COLOR_RED);
        else if(state_input6_ext1.indexOf(separation + KZ)>-1 || state_input6_ext1.indexOf(separation + OBRIV)>-1)
            textView_input6_ext1.setBackgroundColor (COLOR_YELLOW);
        else textView_input6_ext1.setBackgroundColor(COLOR_WHITE);

        if (state_input7_ext1.indexOf(separation + TREVOGA)>-1)
            textView_input7_ext1.setBackgroundColor (COLOR_RED);
        else if(state_input7_ext1.indexOf(separation + KZ)>-1 || state_input7_ext1.indexOf(separation + OBRIV)>-1)
            textView_input7_ext1.setBackgroundColor (COLOR_YELLOW);
        else textView_input7_ext1.setBackgroundColor(COLOR_WHITE);

        if (state_input8_ext1.indexOf(separation + TREVOGA)>-1)
            textView_input8_ext1.setBackgroundColor (COLOR_RED);
        else if(state_input8_ext1.indexOf(separation + KZ)>-1 || state_input8_ext1.indexOf(separation + OBRIV)>-1)
            textView_input8_ext1.setBackgroundColor (COLOR_YELLOW);
        else textView_input8_ext1.setBackgroundColor(COLOR_WHITE);


        //ext2
        if (state_input1_ext2.indexOf(separation + TREVOGA)>-1)
            textView_input1_ext2.setBackgroundColor (COLOR_RED);
        else if(state_input1_ext2.indexOf(separation + KZ)>-1 || state_input1_ext2.indexOf(separation + OBRIV)>-1)
            textView_input1_ext2.setBackgroundColor (COLOR_YELLOW);
        else textView_input1_ext2.setBackgroundColor(COLOR_WHITE);

        if (state_input2_ext2.indexOf(separation + TREVOGA)>-1)
            textView_input2_ext2.setBackgroundColor (COLOR_RED);
        else if(state_input2_ext2.indexOf(separation + KZ)>-1 || state_input2_ext2.indexOf(separation + OBRIV)>-1)
            textView_input2_ext2.setBackgroundColor (COLOR_YELLOW);
        else textView_input2_ext2.setBackgroundColor(COLOR_WHITE);

        if (state_input3_ext2.indexOf(separation + TREVOGA)>-1)
            textView_input3_ext2.setBackgroundColor (COLOR_RED);
        else if(state_input3_ext2.indexOf(separation + KZ)>-1 || state_input3_ext2.indexOf(separation + OBRIV)>-1)
            textView_input3_ext2.setBackgroundColor (COLOR_YELLOW);
        else textView_input3_ext2.setBackgroundColor(COLOR_WHITE);

        if (state_input4_ext2.indexOf(separation + TREVOGA)>-1)
            textView_input4_ext2.setBackgroundColor (COLOR_RED);
        else if(state_input4_ext2.indexOf(separation + KZ)>-1 || state_input4_ext2.indexOf(separation + OBRIV)>-1)
            textView_input4_ext2.setBackgroundColor (COLOR_YELLOW);
        else textView_input4_ext2.setBackgroundColor(COLOR_WHITE);

        if (state_input5_ext2.indexOf(separation + TREVOGA)>-1)
            textView_input5_ext2.setBackgroundColor (COLOR_RED);
        else if(state_input5_ext2.indexOf(separation + KZ)>-1 || state_input5_ext2.indexOf(separation + OBRIV)>-1)
            textView_input5_ext2.setBackgroundColor (COLOR_YELLOW);
        else textView_input5_ext2.setBackgroundColor(COLOR_WHITE);

        if (state_input6_ext2.indexOf(separation + TREVOGA)>-1)
            textView_input6_ext2.setBackgroundColor (COLOR_RED);
        else if(state_input6_ext2.indexOf(separation + KZ)>-1 || state_input6_ext2.indexOf(separation + OBRIV)>-1)
            textView_input6_ext2.setBackgroundColor (COLOR_YELLOW);
        else textView_input6_ext2.setBackgroundColor(COLOR_WHITE);

        if (state_input7_ext2.indexOf(separation + TREVOGA)>-1)
            textView_input7_ext2.setBackgroundColor (COLOR_RED);
        else if(state_input7_ext2.indexOf(separation + KZ)>-1 || state_input7_ext2.indexOf(separation + OBRIV)>-1)
            textView_input7_ext2.setBackgroundColor (COLOR_YELLOW);
        else textView_input7_ext2.setBackgroundColor(COLOR_WHITE);

        if (state_input8_ext2.indexOf(separation + TREVOGA)>-1)
            textView_input8_ext2.setBackgroundColor (COLOR_RED);
        else if(state_input8_ext2.indexOf(separation + KZ)>-1 || state_input8_ext2.indexOf(separation + OBRIV)>-1)
            textView_input8_ext2.setBackgroundColor (COLOR_YELLOW);
        else textView_input8_ext2.setBackgroundColor(COLOR_WHITE);

        //ext3
        if (state_input1_ext3.indexOf(separation + TREVOGA)>-1)
            textView_input1_ext3.setBackgroundColor (COLOR_RED);
        else if(state_input1_ext3.indexOf(separation + KZ)>-1 || state_input1_ext3.indexOf(separation + OBRIV)>-1)
            textView_input1_ext3.setBackgroundColor (COLOR_YELLOW);
        else textView_input1_ext3.setBackgroundColor(COLOR_WHITE);

        if (state_input2_ext3.indexOf(separation + TREVOGA)>-1)
            textView_input2_ext3.setBackgroundColor (COLOR_RED);
        else if(state_input2_ext3.indexOf(separation + KZ)>-1 || state_input2_ext3.indexOf(separation + OBRIV)>-1)
            textView_input2_ext3.setBackgroundColor (COLOR_YELLOW);
        else textView_input2_ext3.setBackgroundColor(COLOR_WHITE);

        if (state_input3_ext3.indexOf(separation + TREVOGA)>-1)
            textView_input3_ext3.setBackgroundColor (COLOR_RED);
        else if(state_input3_ext3.indexOf(separation + KZ)>-1 || state_input3_ext3.indexOf(separation + OBRIV)>-1)
            textView_input3_ext3.setBackgroundColor (COLOR_YELLOW);
        else textView_input3_ext3.setBackgroundColor(COLOR_WHITE);

        if (state_input4_ext3.indexOf(separation + TREVOGA)>-1)
            textView_input4_ext3.setBackgroundColor (COLOR_RED);
        else if(state_input4_ext3.indexOf(separation + KZ)>-1 || state_input4_ext3.indexOf(separation + OBRIV)>-1)
            textView_input4_ext3.setBackgroundColor (COLOR_YELLOW);
        else textView_input4_ext3.setBackgroundColor(COLOR_WHITE);

        if (state_input5_ext3.indexOf(separation + TREVOGA)>-1)
            textView_input5_ext3.setBackgroundColor (COLOR_RED);
        else if(state_input5_ext3.indexOf(separation + KZ)>-1 || state_input5_ext3.indexOf(separation + OBRIV)>-1)
            textView_input5_ext3.setBackgroundColor (COLOR_YELLOW);
        else textView_input5_ext3.setBackgroundColor(COLOR_WHITE);

        if (state_input6_ext3.indexOf(separation + TREVOGA)>-1)
            textView_input6_ext3.setBackgroundColor (COLOR_RED);
        else if(state_input6_ext3.indexOf(separation + KZ)>-1 || state_input6_ext3.indexOf(separation + OBRIV)>-1)
            textView_input6_ext3.setBackgroundColor (COLOR_YELLOW);
        else textView_input6_ext3.setBackgroundColor(COLOR_WHITE);

        if (state_input7_ext3.indexOf(separation + TREVOGA)>-1)
            textView_input7_ext3.setBackgroundColor (COLOR_RED);
        else if(state_input7_ext3.indexOf(separation + KZ)>-1 || state_input7_ext3.indexOf(separation + OBRIV)>-1)
            textView_input7_ext3.setBackgroundColor (COLOR_YELLOW);
        else textView_input7_ext3.setBackgroundColor(COLOR_WHITE);

        if (state_input8_ext3.indexOf(separation + TREVOGA)>-1)
            textView_input8_ext3.setBackgroundColor (COLOR_RED);
        else if(state_input8_ext3.indexOf(separation + KZ)>-1 || state_input8_ext3.indexOf(separation + OBRIV)>-1)
            textView_input8_ext3.setBackgroundColor (COLOR_YELLOW);
        else textView_input8_ext3.setBackgroundColor(COLOR_WHITE);

        //ext4
        if (state_input1_ext4.indexOf(separation + TREVOGA)>-1)
            textView_input1_ext4.setBackgroundColor (COLOR_RED);
        else if(state_input1_ext4.indexOf(separation + KZ)>-1 || state_input1_ext4.indexOf(separation + OBRIV)>-1)
            textView_input1_ext4.setBackgroundColor (COLOR_YELLOW);
        else textView_input1_ext4.setBackgroundColor(COLOR_WHITE);

        if (state_input2_ext4.indexOf(separation + TREVOGA)>-1)
            textView_input2_ext4.setBackgroundColor (COLOR_RED);
        else if(state_input2_ext4.indexOf(separation + KZ)>-1 || state_input2_ext4.indexOf(separation + OBRIV)>-1)
            textView_input2_ext4.setBackgroundColor (COLOR_YELLOW);
        else textView_input2_ext4.setBackgroundColor(COLOR_WHITE);

        if (state_input3_ext4.indexOf(separation + TREVOGA)>-1)
            textView_input3_ext4.setBackgroundColor (COLOR_RED);
        else if(state_input3_ext4.indexOf(separation + KZ)>-1 || state_input3_ext4.indexOf(separation + OBRIV)>-1)
            textView_input3_ext4.setBackgroundColor (COLOR_YELLOW);
        else textView_input3_ext4.setBackgroundColor(COLOR_WHITE);

        if (state_input4_ext4.indexOf(separation + TREVOGA)>-1)
            textView_input4_ext4.setBackgroundColor (COLOR_RED);
        else if(state_input4_ext4.indexOf(separation + KZ)>-1 || state_input4_ext4.indexOf(separation + OBRIV)>-1)
            textView_input4_ext4.setBackgroundColor (COLOR_YELLOW);
        else textView_input4_ext4.setBackgroundColor(COLOR_WHITE);

        if (state_input5_ext4.indexOf(separation + TREVOGA)>-1)
            textView_input5_ext4.setBackgroundColor (COLOR_RED);
        else if(state_input5_ext4.indexOf(separation + KZ)>-1 || state_input5_ext4.indexOf(separation + OBRIV)>-1)
            textView_input5_ext4.setBackgroundColor (COLOR_YELLOW);
        else textView_input5_ext4.setBackgroundColor(COLOR_WHITE);

        if (state_input6_ext4.indexOf(separation + TREVOGA)>-1)
            textView_input6_ext4.setBackgroundColor (COLOR_RED);
        else if(state_input6_ext4.indexOf(separation + KZ)>-1 || state_input6_ext4.indexOf(separation + OBRIV)>-1)
            textView_input6_ext4.setBackgroundColor (COLOR_YELLOW);
        else textView_input6_ext4.setBackgroundColor(COLOR_WHITE);

        if (state_input7_ext4.indexOf(separation + TREVOGA)>-1)
            textView_input7_ext4.setBackgroundColor (COLOR_RED);
        else if(state_input7_ext4.indexOf(separation + KZ)>-1 || state_input7_ext4.indexOf(separation + OBRIV)>-1)
            textView_input7_ext4.setBackgroundColor (COLOR_YELLOW);
        else textView_input7_ext4.setBackgroundColor(COLOR_WHITE);

        if (state_input8_ext4.indexOf(separation + TREVOGA)>-1)
            textView_input8_ext4.setBackgroundColor (COLOR_RED);
        else if(state_input8_ext4.indexOf(separation + KZ)>-1 || state_input8_ext4.indexOf(separation + OBRIV)>-1)
            textView_input8_ext4.setBackgroundColor (COLOR_YELLOW);
        else textView_input8_ext4.setBackgroundColor(COLOR_WHITE);



        //radio
        if (state_radio1.indexOf(TREVOGA)>-1 || state_radio1.indexOf(PANIKA)>-1)
            textView_radio1.setBackgroundColor (COLOR_RED);
        else if (state_radio1.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio1.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio1.setBackgroundColor (COLOR_YELLOW); else textView_radio1.setBackgroundColor(COLOR_WHITE);

        if (state_radio2.indexOf(TREVOGA)>-1 || state_radio2.indexOf(PANIKA)>-1)
            textView_radio2.setBackgroundColor (COLOR_RED);
        else if (state_radio2.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio2.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio2.setBackgroundColor (COLOR_YELLOW); else textView_radio2.setBackgroundColor(COLOR_WHITE);

        if (state_radio3.indexOf(TREVOGA)>-1 || state_radio3.indexOf(PANIKA)>-1)
            textView_radio3.setBackgroundColor (COLOR_RED);
        else if (state_radio3.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio3.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio3.setBackgroundColor (COLOR_YELLOW); else textView_radio3.setBackgroundColor(COLOR_WHITE);

        if (state_radio4.indexOf(TREVOGA)>-1 || state_radio4.indexOf(PANIKA)>-1)
            textView_radio4.setBackgroundColor (COLOR_RED);
        else if (state_radio4.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio4.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio4.setBackgroundColor (COLOR_YELLOW); else textView_radio4.setBackgroundColor(COLOR_WHITE);

        if (state_radio5.indexOf(TREVOGA)>-1 || state_radio5.indexOf(PANIKA)>-1)
            textView_radio5.setBackgroundColor (COLOR_RED);
        else if (state_radio5.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio5.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio5.setBackgroundColor (COLOR_YELLOW); else textView_radio5.setBackgroundColor(COLOR_WHITE);

        if (state_radio6.indexOf(TREVOGA)>-1 || state_radio6.indexOf(PANIKA)>-1)
            textView_radio6.setBackgroundColor (COLOR_RED);
        else if (state_radio6.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio6.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio6.setBackgroundColor (COLOR_YELLOW); else textView_radio6.setBackgroundColor(COLOR_WHITE);

        if (state_radio7.indexOf(TREVOGA)>-1 || state_radio7.indexOf(PANIKA)>-1)
            textView_radio7.setBackgroundColor (COLOR_RED);
        else if (state_radio7.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio7.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio7.setBackgroundColor (COLOR_YELLOW); else textView_radio7.setBackgroundColor(COLOR_WHITE);

        if (state_radio8.indexOf(TREVOGA)>-1 || state_radio8.indexOf(PANIKA)>-1)
            textView_radio8.setBackgroundColor (COLOR_RED);
        else if (state_radio8.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio8.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio8.setBackgroundColor (COLOR_YELLOW); else textView_radio8.setBackgroundColor(COLOR_WHITE);

        if (state_radio9.indexOf(TREVOGA)>-1 || state_radio9.indexOf(PANIKA)>-1)
            textView_radio9.setBackgroundColor (COLOR_RED);
        else if (state_radio9.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio9.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio9.setBackgroundColor (COLOR_YELLOW); else textView_radio9.setBackgroundColor(COLOR_WHITE);

        if (state_radio10.indexOf(TREVOGA)>-1 || state_radio10.indexOf(PANIKA)>-1)
            textView_radio10.setBackgroundColor (COLOR_RED);
        else if (state_radio10.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio10.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio10.setBackgroundColor (COLOR_YELLOW); else textView_radio10.setBackgroundColor(COLOR_WHITE);

        if (state_radio11.indexOf(TREVOGA)>-1 || state_radio11.indexOf(PANIKA)>-1)
            textView_radio11.setBackgroundColor (COLOR_RED);
        else if (state_radio11.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio11.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio11.setBackgroundColor (COLOR_YELLOW); else textView_radio11.setBackgroundColor(COLOR_WHITE);

        if (state_radio12.indexOf(TREVOGA)>-1 || state_radio12.indexOf(PANIKA)>-1)
            textView_radio12.setBackgroundColor (COLOR_RED);
        else if (state_radio12.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio12.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio12.setBackgroundColor (COLOR_YELLOW); else textView_radio12.setBackgroundColor(COLOR_WHITE);

        if (state_radio13.indexOf(TREVOGA)>-1 || state_radio13.indexOf(PANIKA)>-1)
            textView_radio13.setBackgroundColor (COLOR_RED);
        else if (state_radio13.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio13.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio13.setBackgroundColor (COLOR_YELLOW); else textView_radio13.setBackgroundColor(COLOR_WHITE);

        if (state_radio14.indexOf(TREVOGA)>-1 || state_radio14.indexOf(PANIKA)>-1)
            textView_radio14.setBackgroundColor (COLOR_RED);
        else if (state_radio14.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio14.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio14.setBackgroundColor (COLOR_YELLOW); else textView_radio14.setBackgroundColor(COLOR_WHITE);

        if (state_radio15.indexOf(TREVOGA)>-1 || state_radio15.indexOf(PANIKA)>-1)
            textView_radio15.setBackgroundColor (COLOR_RED);
        else if (state_radio15.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio15.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio15.setBackgroundColor (COLOR_YELLOW); else textView_radio15.setBackgroundColor(COLOR_WHITE);

        if (state_radio16.indexOf(TREVOGA)>-1 || state_radio16.indexOf(PANIKA)>-1)
            textView_radio16.setBackgroundColor (COLOR_RED);
        else if (state_radio16.indexOf(NET_TESTOVOGO_SIGNALA)>-1 || state_radio16.indexOf(RAZRIAD_BATTAREYKI)>-1)
            textView_radio16.setBackgroundColor (COLOR_YELLOW); else textView_radio16.setBackgroundColor(COLOR_WHITE);

    }


    private void read_name()
    {

        if (mSettings.contains(APP_PREFERENCES_NAME_TAMPER)) {
            name_tamper=mSettings.getString(APP_PREFERENCES_NAME_TAMPER, name_tamper);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT1)) {
            name_input1=mSettings.getString(APP_PREFERENCES_NAME_INPUT1, name_input1);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT2)) {
            name_input2=mSettings.getString(APP_PREFERENCES_NAME_INPUT2, name_input2);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT3)) {
            name_input3=mSettings.getString(APP_PREFERENCES_NAME_INPUT3, name_input3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT4)) {
            name_input4=mSettings.getString(APP_PREFERENCES_NAME_INPUT4, name_input4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT5)) {
            name_input5=mSettings.getString(APP_PREFERENCES_NAME_INPUT5, name_input5);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT6)) {
            name_input6=mSettings.getString(APP_PREFERENCES_NAME_INPUT6, name_input6);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT7)) {
            name_input7=mSettings.getString(APP_PREFERENCES_NAME_INPUT7, name_input7);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT8)) {
            name_input8=mSettings.getString(APP_PREFERENCES_NAME_INPUT8, name_input8);
        }

        //ext input

        //ext0
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT1_EXT0)) {
            name_input1_ext0=mSettings.getString(APP_PREFERENCES_NAME_INPUT1_EXT0, name_input1_ext0);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT2_EXT0)) {
            name_input2_ext0=mSettings.getString(APP_PREFERENCES_NAME_INPUT2_EXT0, name_input2_ext0);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT3_EXT0)) {
            name_input3_ext0=mSettings.getString(APP_PREFERENCES_NAME_INPUT3_EXT0, name_input3_ext0);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT4_EXT0)) {
            name_input4_ext0=mSettings.getString(APP_PREFERENCES_NAME_INPUT4_EXT0, name_input4_ext0);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT5_EXT0)) {
            name_input5_ext0=mSettings.getString(APP_PREFERENCES_NAME_INPUT5_EXT0, name_input5_ext0);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT6_EXT0)) {
            name_input6_ext0=mSettings.getString(APP_PREFERENCES_NAME_INPUT6_EXT0, name_input6_ext0);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT7_EXT0)) {
            name_input7_ext0=mSettings.getString(APP_PREFERENCES_NAME_INPUT7_EXT0, name_input7_ext0);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT8_EXT0)) {
            name_input8_ext0=mSettings.getString(APP_PREFERENCES_NAME_INPUT8_EXT0, name_input8_ext0);
        }

        //ext1
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT1_EXT1)) {
            name_input1_ext1=mSettings.getString(APP_PREFERENCES_NAME_INPUT1_EXT1, name_input1_ext1);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT2_EXT1)) {
            name_input2_ext1=mSettings.getString(APP_PREFERENCES_NAME_INPUT2_EXT1, name_input2_ext1);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT3_EXT1)) {
            name_input3_ext1=mSettings.getString(APP_PREFERENCES_NAME_INPUT3_EXT1, name_input3_ext1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT4_EXT1)) {
            name_input4_ext1=mSettings.getString(APP_PREFERENCES_NAME_INPUT4_EXT1, name_input4_ext1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT5_EXT1)) {
            name_input5_ext1=mSettings.getString(APP_PREFERENCES_NAME_INPUT5_EXT1, name_input5_ext1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT6_EXT1)) {
            name_input6_ext1=mSettings.getString(APP_PREFERENCES_NAME_INPUT6_EXT1, name_input6_ext1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT7_EXT1)) {
            name_input7_ext1=mSettings.getString(APP_PREFERENCES_NAME_INPUT7_EXT1, name_input7_ext1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT8_EXT1)) {
            name_input8_ext1=mSettings.getString(APP_PREFERENCES_NAME_INPUT8_EXT1, name_input8_ext1);
        }
        //ext2
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT1_EXT2)) {
            name_input1_ext2=mSettings.getString(APP_PREFERENCES_NAME_INPUT1_EXT2, name_input1_ext2);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT2_EXT2)) {
            name_input2_ext2=mSettings.getString(APP_PREFERENCES_NAME_INPUT2_EXT2, name_input2_ext2);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT3_EXT2)) {
            name_input3_ext2=mSettings.getString(APP_PREFERENCES_NAME_INPUT3_EXT2, name_input3_ext2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT4_EXT2)) {
            name_input4_ext2=mSettings.getString(APP_PREFERENCES_NAME_INPUT4_EXT2, name_input4_ext2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT5_EXT2)) {
            name_input5_ext2=mSettings.getString(APP_PREFERENCES_NAME_INPUT5_EXT2, name_input5_ext2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT6_EXT2)) {
            name_input6_ext2=mSettings.getString(APP_PREFERENCES_NAME_INPUT6_EXT2, name_input6_ext2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT7_EXT2)) {
            name_input7_ext2=mSettings.getString(APP_PREFERENCES_NAME_INPUT7_EXT2, name_input7_ext2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT8_EXT2)) {
            name_input8_ext2=mSettings.getString(APP_PREFERENCES_NAME_INPUT8_EXT2, name_input8_ext2);
        }
        //ext3
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT1_EXT3)) {
            name_input1_ext3=mSettings.getString(APP_PREFERENCES_NAME_INPUT1_EXT3, name_input1_ext3);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT2_EXT3)) {
            name_input2_ext3=mSettings.getString(APP_PREFERENCES_NAME_INPUT2_EXT3, name_input2_ext3);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT3_EXT3)) {
            name_input3_ext3=mSettings.getString(APP_PREFERENCES_NAME_INPUT3_EXT3, name_input3_ext3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT4_EXT3)) {
            name_input4_ext3=mSettings.getString(APP_PREFERENCES_NAME_INPUT4_EXT3, name_input4_ext3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT5_EXT3)) {
            name_input5_ext3=mSettings.getString(APP_PREFERENCES_NAME_INPUT5_EXT3, name_input5_ext3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT6_EXT3)) {
            name_input6_ext3=mSettings.getString(APP_PREFERENCES_NAME_INPUT6_EXT3, name_input6_ext3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT7_EXT3)) {
            name_input7_ext3=mSettings.getString(APP_PREFERENCES_NAME_INPUT7_EXT3, name_input7_ext3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT8_EXT3)) {
            name_input8_ext3=mSettings.getString(APP_PREFERENCES_NAME_INPUT8_EXT3, name_input8_ext3);
        }
        //ext4
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT1_EXT4)) {
            name_input1_ext4=mSettings.getString(APP_PREFERENCES_NAME_INPUT1_EXT4, name_input1_ext4);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT2_EXT4)) {
            name_input2_ext4=mSettings.getString(APP_PREFERENCES_NAME_INPUT2_EXT4, name_input2_ext4);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT3_EXT4)) {
            name_input3_ext4=mSettings.getString(APP_PREFERENCES_NAME_INPUT3_EXT4, name_input3_ext4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT4_EXT4)) {
            name_input4_ext4=mSettings.getString(APP_PREFERENCES_NAME_INPUT4_EXT4, name_input4_ext4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT5_EXT4)) {
            name_input5_ext4=mSettings.getString(APP_PREFERENCES_NAME_INPUT5_EXT4, name_input5_ext4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT6_EXT4)) {
            name_input6_ext4=mSettings.getString(APP_PREFERENCES_NAME_INPUT6_EXT4, name_input6_ext4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT7_EXT4)) {
            name_input7_ext4=mSettings.getString(APP_PREFERENCES_NAME_INPUT7_EXT4, name_input7_ext4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_INPUT8_EXT4)) {
            name_input8_ext4=mSettings.getString(APP_PREFERENCES_NAME_INPUT8_EXT4, name_input8_ext4);
        }

        //output
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT1)) {
            name_output1=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT1, name_output1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT2)) {
            name_output2=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT2, name_output2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT3)) {
            name_output3=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT3, name_output3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT4)) {
            name_output4=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT4, name_output4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT5)) {
            name_output5=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT5, name_output5);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT6)) {
            name_output6=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT6, name_output6);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT7)) {
            name_output7=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT7, name_output7);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT8)) {
            name_output8=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT8, name_output8);
        }

        //ext0
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT1_EXT0)) {
            name_output1_ext0=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT1_EXT0, name_output1_ext0);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT2_EXT0)) {
            name_output2_ext0=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT2_EXT0, name_output2_ext0);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT3_EXT0)) {
            name_output3_ext0=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT3_EXT0, name_output3_ext0);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT4_EXT0)) {
            name_output4_ext0=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT4_EXT0, name_output4_ext0);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT5_EXT0)) {
            name_output5_ext0=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT5_EXT0, name_output5_ext0);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT6_EXT0)) {
            name_output6_ext0=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT6_EXT0, name_output6_ext0);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT7_EXT0)) {
            name_output7_ext0=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT7_EXT0, name_output7_ext0);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT8_EXT0)) {
            name_output8_ext0=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT8_EXT0, name_output8_ext0);
        }

        //ext1
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT1_EXT1)) {
            name_output1_ext1=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT1_EXT1, name_output1_ext1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT2_EXT1)) {
            name_output2_ext1=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT2_EXT1, name_output2_ext1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT3_EXT1)) {
            name_output3_ext1=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT3_EXT1, name_output3_ext1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT4_EXT1)) {
            name_output4_ext1=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT4_EXT1, name_output4_ext1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT5_EXT1)) {
            name_output5_ext1=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT5_EXT1, name_output5_ext1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT6_EXT1)) {
            name_output6_ext1=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT6_EXT1, name_output6_ext1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT7_EXT1)) {
            name_output7_ext1=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT7_EXT1, name_output7_ext1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT8_EXT1)) {
            name_output8_ext1=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT8_EXT1, name_output8_ext1);
        }

        //ext2
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT1_EXT2)) {
            name_output1_ext2=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT1_EXT2, name_output1_ext2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT2_EXT2)) {
            name_output2_ext2=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT2_EXT2, name_output2_ext2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT3_EXT2)) {
            name_output3_ext2=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT3_EXT2, name_output3_ext2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT4_EXT2)) {
            name_output4_ext2=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT4_EXT2, name_output4_ext2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT5_EXT2)) {
            name_output5_ext2=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT5_EXT2, name_output5_ext2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT6_EXT2)) {
            name_output6_ext2=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT6_EXT2, name_output6_ext2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT7_EXT2)) {
            name_output7_ext2=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT7_EXT2, name_output7_ext2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT8_EXT2)) {
            name_output8_ext2=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT8_EXT2, name_output8_ext2);
        }

        //ext3
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT1_EXT3)) {
            name_output1_ext3=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT1_EXT3, name_output1_ext3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT2_EXT3)) {
            name_output2_ext3=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT2_EXT3, name_output2_ext3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT3_EXT3)) {
            name_output3_ext3=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT3_EXT3, name_output3_ext3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT4_EXT3)) {
            name_output4_ext3=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT4_EXT3, name_output4_ext3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT5_EXT3)) {
            name_output5_ext3=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT5_EXT3, name_output5_ext3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT6_EXT3)) {
            name_output6_ext3=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT6_EXT3, name_output6_ext3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT7_EXT3)) {
            name_output7_ext3=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT7_EXT3, name_output7_ext3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT8_EXT3)) {
            name_output8_ext3=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT8_EXT3, name_output8_ext3);
        }

        //ext4
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT1_EXT4)) {
            name_output1_ext4=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT1_EXT4, name_output1_ext4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT2_EXT4)) {
            name_output2_ext4=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT2_EXT4, name_output2_ext4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT3_EXT4)) {
            name_output3_ext4=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT3_EXT4, name_output3_ext4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT4_EXT4)) {
            name_output4_ext4=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT4_EXT4, name_output4_ext4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT5_EXT4)) {
            name_output5_ext4=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT5_EXT4, name_output5_ext4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT6_EXT4)) {
            name_output6_ext4=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT6_EXT4, name_output6_ext4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT7_EXT4)) {
            name_output7_ext4=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT7_EXT4, name_output7_ext4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_OUTPUT8_EXT4)) {
            name_output8_ext4=mSettings.getString(APP_PREFERENCES_NAME_OUTPUT8_EXT4, name_output8_ext4);
        }

        //radio socket
        //blk1
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET1_BLK1)) {
            name_socket1_blk1=mSettings.getString(APP_PREFERENCES_NAME_SOCKET1_BLK1, name_socket1_blk1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET2_BLK1)) {
            name_socket2_blk1=mSettings.getString(APP_PREFERENCES_NAME_SOCKET2_BLK1, name_socket2_blk1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET3_BLK1)) {
            name_socket3_blk1=mSettings.getString(APP_PREFERENCES_NAME_SOCKET3_BLK1, name_socket3_blk1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET4_BLK1)) {
            name_socket4_blk1=mSettings.getString(APP_PREFERENCES_NAME_SOCKET4_BLK1, name_socket4_blk1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET5_BLK1)) {
            name_socket5_blk1=mSettings.getString(APP_PREFERENCES_NAME_SOCKET5_BLK1, name_socket5_blk1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET6_BLK1)) {
            name_socket6_blk1=mSettings.getString(APP_PREFERENCES_NAME_SOCKET6_BLK1, name_socket6_blk1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET7_BLK1)) {
            name_socket7_blk1=mSettings.getString(APP_PREFERENCES_NAME_SOCKET7_BLK1, name_socket7_blk1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET8_BLK1)) {
            name_socket8_blk1=mSettings.getString(APP_PREFERENCES_NAME_SOCKET8_BLK1, name_socket8_blk1);
        }

        //blk2
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET1_BLK2)) {
            name_socket1_blk2=mSettings.getString(APP_PREFERENCES_NAME_SOCKET1_BLK2, name_socket1_blk2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET2_BLK2)) {
            name_socket2_blk2=mSettings.getString(APP_PREFERENCES_NAME_SOCKET2_BLK2, name_socket2_blk2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET3_BLK2)) {
            name_socket3_blk2=mSettings.getString(APP_PREFERENCES_NAME_SOCKET3_BLK2, name_socket3_blk2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET4_BLK2)) {
            name_socket4_blk2=mSettings.getString(APP_PREFERENCES_NAME_SOCKET4_BLK2, name_socket4_blk2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET5_BLK2)) {
            name_socket5_blk2=mSettings.getString(APP_PREFERENCES_NAME_SOCKET5_BLK2, name_socket5_blk2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET6_BLK2)) {
            name_socket6_blk2=mSettings.getString(APP_PREFERENCES_NAME_SOCKET6_BLK2, name_socket6_blk2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET7_BLK2)) {
            name_socket7_blk2=mSettings.getString(APP_PREFERENCES_NAME_SOCKET7_BLK2, name_socket7_blk2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET8_BLK2)) {
            name_socket8_blk2=mSettings.getString(APP_PREFERENCES_NAME_SOCKET8_BLK2, name_socket8_blk2);
        }

        //blk3
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET1_BLK3)) {
            name_socket1_blk3=mSettings.getString(APP_PREFERENCES_NAME_SOCKET1_BLK3, name_socket1_blk3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET2_BLK3)) {
            name_socket2_blk3=mSettings.getString(APP_PREFERENCES_NAME_SOCKET2_BLK3, name_socket2_blk3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET3_BLK3)) {
            name_socket3_blk3=mSettings.getString(APP_PREFERENCES_NAME_SOCKET3_BLK3, name_socket3_blk3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET4_BLK3)) {
            name_socket4_blk3=mSettings.getString(APP_PREFERENCES_NAME_SOCKET4_BLK3, name_socket4_blk3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET5_BLK3)) {
            name_socket5_blk3=mSettings.getString(APP_PREFERENCES_NAME_SOCKET5_BLK3, name_socket5_blk3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET6_BLK3)) {
            name_socket6_blk3=mSettings.getString(APP_PREFERENCES_NAME_SOCKET6_BLK3, name_socket6_blk3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET7_BLK3)) {
            name_socket7_blk3=mSettings.getString(APP_PREFERENCES_NAME_SOCKET7_BLK3, name_socket7_blk3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET8_BLK3)) {
            name_socket8_blk3=mSettings.getString(APP_PREFERENCES_NAME_SOCKET8_BLK3, name_socket8_blk3);
        }

        //blk4
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET1_BLK4)) {
            name_socket1_blk4=mSettings.getString(APP_PREFERENCES_NAME_SOCKET1_BLK4, name_socket1_blk4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET2_BLK4)) {
            name_socket2_blk4=mSettings.getString(APP_PREFERENCES_NAME_SOCKET2_BLK4, name_socket2_blk4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET3_BLK4)) {
            name_socket3_blk4=mSettings.getString(APP_PREFERENCES_NAME_SOCKET3_BLK4, name_socket3_blk4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET4_BLK4)) {
            name_socket4_blk4=mSettings.getString(APP_PREFERENCES_NAME_SOCKET4_BLK4, name_socket4_blk4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET5_BLK4)) {
            name_socket5_blk4=mSettings.getString(APP_PREFERENCES_NAME_SOCKET5_BLK4, name_socket5_blk4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET6_BLK4)) {
            name_socket6_blk4=mSettings.getString(APP_PREFERENCES_NAME_SOCKET6_BLK4, name_socket6_blk4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET7_BLK4)) {
            name_socket7_blk4=mSettings.getString(APP_PREFERENCES_NAME_SOCKET7_BLK4, name_socket7_blk4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_SOCKET8_BLK4)) {
            name_socket8_blk4=mSettings.getString(APP_PREFERENCES_NAME_SOCKET8_BLK4, name_socket8_blk4);
        }





        /*
        Command_out1_on = name_output1 + Command_out_on;
        Command_out1_off = name_output1 + Command_out_off;
        Command_out2_on = name_output2 + Command_out_on;
        Command_out2_off = name_output2 + Command_out_off;
        Command_out3_on = name_output3 + Command_out_on;
        Command_out3_off = name_output3 + Command_out_off;
        Command_out4_on = name_output4 + Command_out_on;
        Command_out4_off = name_output4 + Command_out_off;
        Command_out5_on = name_output5 + Command_out_on;
        Command_out5_off = name_output5 + Command_out_off;
        Command_out6_on = name_output6 + Command_out_on;
        Command_out6_off = name_output6 + Command_out_off;
        Command_out7_on = name_output7 + Command_out_on;
        Command_out7_off = name_output7 + Command_out_off;
        Command_out8_on = name_output8 + Command_out_on;
        Command_out8_off = name_output8 + Command_out_off;
        */

        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO1)) {
            name_radio1=mSettings.getString(APP_PREFERENCES_NAME_RADIO1, name_radio1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO2)) {
            name_radio2=mSettings.getString(APP_PREFERENCES_NAME_RADIO2, name_radio2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO3)) {
            name_radio3=mSettings.getString(APP_PREFERENCES_NAME_RADIO3, name_radio3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO4)) {
            name_radio4=mSettings.getString(APP_PREFERENCES_NAME_RADIO4, name_radio4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO5)) {
            name_radio5=mSettings.getString(APP_PREFERENCES_NAME_RADIO5, name_radio5);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO6)) {
            name_radio6=mSettings.getString(APP_PREFERENCES_NAME_RADIO6, name_radio6);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO7)) {
            name_radio7=mSettings.getString(APP_PREFERENCES_NAME_RADIO7, name_radio7);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO8)) {
            name_radio8=mSettings.getString(APP_PREFERENCES_NAME_RADIO8, name_radio8);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO9)) {
            name_radio9=mSettings.getString(APP_PREFERENCES_NAME_RADIO9, name_radio9);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO10)) {
            name_radio10=mSettings.getString(APP_PREFERENCES_NAME_RADIO10, name_radio10);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO11)) {
            name_radio11=mSettings.getString(APP_PREFERENCES_NAME_RADIO11, name_radio11);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO12)) {
            name_radio12=mSettings.getString(APP_PREFERENCES_NAME_RADIO12, name_radio12);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO13)) {
            name_radio13=mSettings.getString(APP_PREFERENCES_NAME_RADIO13, name_radio13);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO14)) {
            name_radio14=mSettings.getString(APP_PREFERENCES_NAME_RADIO14, name_radio14);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO15)) {
            name_radio15=mSettings.getString(APP_PREFERENCES_NAME_RADIO15, name_radio15);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_RADIO16)) {
            name_radio16=mSettings.getString(APP_PREFERENCES_NAME_RADIO16, name_radio16);
        }

        if (mSettings.contains(APP_PREFERENCES_NAME_TERMO1)) {
            name_termo1=mSettings.getString(APP_PREFERENCES_NAME_TERMO1, name_termo1);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_TERMO2)) {
            name_termo2=mSettings.getString(APP_PREFERENCES_NAME_TERMO2, name_termo2);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_TERMO3)) {
            name_termo3=mSettings.getString(APP_PREFERENCES_NAME_TERMO3, name_termo3);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_TERMO4)) {
            name_termo4=mSettings.getString(APP_PREFERENCES_NAME_TERMO4, name_termo4);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_TERMO5)) {
            name_termo5=mSettings.getString(APP_PREFERENCES_NAME_TERMO5, name_termo5);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_TERMO6)) {
            name_termo6=mSettings.getString(APP_PREFERENCES_NAME_TERMO6, name_termo6);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_TERMO7)) {
            name_termo7=mSettings.getString(APP_PREFERENCES_NAME_TERMO7, name_termo7);
        }
        if (mSettings.contains(APP_PREFERENCES_NAME_TERMO8)) {
            name_termo8=mSettings.getString(APP_PREFERENCES_NAME_TERMO8, name_termo8);
        }


    }



    private void sms_anal(String message_text, String sender)
    {
        try {
        // --- анализируем входящую смс от GSM-розетки
        if (sender != null)
        {
            //-------------- System date
            StringBuilder msgDate = new StringBuilder("");
            Format formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
            msgDate.append(formatter.format(new Date()));

            String TEXT;
            String ext_temp="";


            //String power = textView_power.getText().toString();
            //String arm = btn_arm.getText().toString();
            //String gsm = textView_gsm.getText().toString();
            //String input1 = textView_input1.getText().toString();

            SharedPreferences.Editor editor = mSettings.edit();

            //--------------------проверяем наличие статусной смс
            if (
                            (message_text.indexOf("GSM:") > -1) || (message_text.indexOf("ADC1:") > -1) || (message_text.indexOf("ADC2:") > -1) || (message_text.indexOf("ADC3:") > -1) ||
                            //(message_text.indexOf(SMS_ARM_ON) > -1)  ||
                            //(message_text.indexOf(SMS_ARM_OFF) > -1) ||
                            (message_text.contains(SMS_OUTPUTS)) || (message_text.contains(SMS_EXT0_OUTPUTS)) ||
                            (message_text.contains(SMS_EXT1_OUTPUTS)) ||
                            (message_text.contains(SMS_EXT2_OUTPUTS)) ||
                            (message_text.contains(SMS_EXT3_OUTPUTS)) ||
                            (message_text.contains(SMS_EXT4_OUTPUTS)) ||
                                    (message_text.contains(SMS_BLK1_SOCKETS)) ||
                                    (message_text.contains(SMS_BLK2_SOCKETS)) ||
                                    (message_text.contains(SMS_BLK3_SOCKETS)) ||
                                    (message_text.contains(SMS_BLK4_SOCKETS)) ||
                            (message_text.length()>100)
                    )
            {
                //--- да, статусная - отображаем значения на элементах интерфейса
                btn_query.setText(update_time + msgDate);
                String query = btn_query.getText().toString();

                state_controller = getString(R.string.state_controller);
                textView_controller.setText(state_controller);
                editor.putString(APP_PREFERENCES_CONTROLLER, state_controller);

                if ((message_text.indexOf(SMS_ARM_ON) > -1) || (message_text.indexOf(SMS_ARM_OFF) > -1)) {
                    String imageView_arm = "imageView_arm_";

                    TEXT=SMS_ARM_ON;

                    if (message_text.indexOf(TEXT) > -1) {
                        btn_arm.setText(state_arm + VKL);
                        imageView_arm = "imageView_arm_on";
                        imageView_arm_on.setVisibility(View.VISIBLE);
                        imageView_arm_off.setVisibility(View.INVISIBLE);
                        imageView_arm_.setVisibility(View.INVISIBLE);

                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + state_arm + VKL + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                    }

                    TEXT=SMS_ARM_OFF;
                    if (message_text.indexOf(TEXT) > -1) {
                        btn_arm.setText(state_arm + VYKL);
                        imageView_arm = "imageView_arm_off";
                        imageView_arm_off.setVisibility(View.VISIBLE);
                        imageView_arm_on.setVisibility(View.INVISIBLE);
                        imageView_arm_.setVisibility(View.INVISIBLE);

                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + state_arm + VYKL + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                    }

                    editor.putString(APP_PREFERENCES_IMAGE_VIEW_ARM, imageView_arm);
                    editor.putString(APP_PREFERENCES_ARM, btn_arm.getText().toString());
                }

                if ((message_text.indexOf(SMS_220V_ON) > -1) || (message_text.indexOf(SMS_220V_OFF) > -1) || (message_text.indexOf(SMS_RAZRYAD_AKKUM) > -1) ) {

                    String imageView_power = "imageView_power_";
                    TEXT=SMS_220V_ON;
                    if (message_text.indexOf(TEXT) > -1) {
                        imageView_power = "imageView_power_on";
                        textView_power.setText(state_220v + EST);
                        imageView_power_on.setVisibility(View.VISIBLE);
                        imageView_power_off.setVisibility(View.INVISIBLE);
                        imageView_power_.setVisibility(View.INVISIBLE);

                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + state_220v + EST + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                    }

                    TEXT=SMS_220V_OFF;
                    if (message_text.indexOf(TEXT) > -1) {
                        textView_power.setText(state_220v + NET);
                        imageView_power = "imageView_power_off";
                        imageView_power_off.setVisibility(View.VISIBLE);
                        imageView_power_on.setVisibility(View.INVISIBLE);
                        imageView_power_.setVisibility(View.INVISIBLE);

                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + state_220v + NET + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                    }

                    TEXT=SMS_RAZRYAD_AKKUM;
                    if (message_text.indexOf(TEXT) > -1) {
                        textView_power.setText(textView_power.getText().toString() + ", " + RAZRYAD_AKKUM);

                        message_text = message_text.substring(0, message_text.indexOf(TEXT))  + RAZRYAD_AKKUM + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                    }

                    editor.putString(APP_PREFERENCES_IMAGE_VIEW_POWER, imageView_power);
                    editor.putString(APP_PREFERENCES_POWER, textView_power.getText().toString());
                }

                //ext0
                if (
                        (message_text.indexOf(SMS_EXT0_ZONA1_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA1_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA1_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA1_OBRIV) > -1)
                        )
                {
                    state_input1_ext0 = separation;
                    TEXT=SMS_EXT0_ZONA1_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext0 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext0+state_input1_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA1_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext0 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext0+state_input1_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA1_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext0 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext0+state_input1_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA1_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext0 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext0+state_input1_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input1_ext0.setText(name_input1_ext0 + state_input1_ext0);

                    editor.putString(APP_PREFERENCES_INPUT1_EXT0, state_input1_ext0);
                }

                if (
                        (message_text.indexOf(SMS_EXT0_ZONA2_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA2_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA2_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA2_OBRIV) > -1)
                        )
                {
                    state_input2_ext0 = separation;
                    TEXT=SMS_EXT0_ZONA2_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext0 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext0+state_input2_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA2_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext0 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext0+state_input2_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA2_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext0 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext0+state_input2_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA2_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext0 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext0+state_input2_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input2_ext0.setText(name_input2_ext0 + state_input2_ext0);

                    editor.putString(APP_PREFERENCES_INPUT2_EXT0, state_input2_ext0);
                }

                if (
                        (message_text.indexOf(SMS_EXT0_ZONA3_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA3_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA3_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA3_OBRIV) > -1)
                        )
                {
                    state_input3_ext0 = separation;
                    TEXT=SMS_EXT0_ZONA3_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext0 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext0+state_input3_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA3_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext0 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext0+state_input3_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA3_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext0 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext0+state_input3_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA3_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext0 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext0+state_input3_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input3_ext0.setText(name_input3_ext0 + state_input3_ext0);

                    editor.putString(APP_PREFERENCES_INPUT3_EXT0, state_input3_ext0);
                }

                if (
                        (message_text.indexOf(SMS_EXT0_ZONA4_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA4_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA4_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA4_OBRIV) > -1)
                        )
                {
                    state_input4_ext0 = separation;
                    TEXT=SMS_EXT0_ZONA4_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext0 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext0+state_input4_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA4_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext0 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext0+state_input4_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA4_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext0 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext0+state_input4_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA4_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext0 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext0+state_input4_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input4_ext0.setText(name_input4_ext0 + state_input4_ext0);

                    editor.putString(APP_PREFERENCES_INPUT4_EXT0, state_input4_ext0);
                }

                if (
                        (message_text.indexOf(SMS_EXT0_ZONA5_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA5_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA5_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA5_OBRIV) > -1)
                        )
                {
                    state_input5_ext0 = separation;
                    TEXT=SMS_EXT0_ZONA5_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext0 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext0+state_input5_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA5_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext0 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext0+state_input5_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA5_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext0 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext0+state_input5_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA5_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext0 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext0+state_input5_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input5_ext0.setText(name_input5_ext0 + state_input5_ext0);

                    editor.putString(APP_PREFERENCES_INPUT5_EXT0, state_input5_ext0);
                }

                if (
                        (message_text.indexOf(SMS_EXT0_ZONA6_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA6_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA6_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA6_OBRIV) > -1)
                        )
                {
                    state_input6_ext0 = separation;
                    TEXT=SMS_EXT0_ZONA6_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext0 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext0+state_input6_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA6_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext0 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext0+state_input6_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA6_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext0 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext0+state_input6_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA6_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext0 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext0+state_input6_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input6_ext0.setText(name_input6_ext0+ state_input6_ext0);

                    editor.putString(APP_PREFERENCES_INPUT6_EXT0, state_input6_ext0);
                }


                if (
                        (message_text.indexOf(SMS_EXT0_ZONA7_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA7_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA7_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA7_OBRIV) > -1)
                        )
                {
                    state_input7_ext0 = separation;
                    TEXT=SMS_EXT0_ZONA7_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext0 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext0+state_input7_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA7_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext0 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext0+state_input7_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA7_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext0 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext0+state_input7_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA7_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext0 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext0+state_input7_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input7_ext0.setText(name_input7_ext0 + state_input7_ext0);

                    editor.putString(APP_PREFERENCES_INPUT7_EXT0, state_input7_ext0);
                }

                if (
                        (message_text.indexOf(SMS_EXT0_ZONA8_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA8_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA8_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT0_ZONA8_OBRIV) > -1)
                        )
                {
                    state_input8_ext0 = separation;
                    TEXT=SMS_EXT0_ZONA8_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext0 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext0+state_input8_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA8_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext0 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext0+state_input8_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA8_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext0 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext0+state_input8_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT0_ZONA8_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext0 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext0+state_input8_ext0 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input8_ext0.setText(name_input8_ext0 + state_input8_ext0);

                    editor.putString(APP_PREFERENCES_INPUT8_EXT0, state_input8_ext0);
                }

                //ext1
                if (
                        (message_text.indexOf(SMS_EXT1_ZONA1_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA1_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA1_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA1_OBRIV) > -1)
                        )
                {
                    state_input1_ext1 = separation;
                    TEXT=SMS_EXT1_ZONA1_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext1 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext1+state_input1_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA1_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext1 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext1+state_input1_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA1_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext1 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext1+state_input1_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA1_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext1 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext1+state_input1_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input1_ext1.setText(name_input1_ext1 + state_input1_ext1);

                    editor.putString(APP_PREFERENCES_INPUT1_EXT1, state_input1_ext1);
                }

                if (
                        (message_text.indexOf(SMS_EXT1_ZONA2_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA2_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA2_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA2_OBRIV) > -1)
                        )
                {
                    state_input2_ext1 = separation;
                    TEXT=SMS_EXT1_ZONA2_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext1 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext1+state_input2_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA2_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext1 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext1+state_input2_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA2_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext1 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext1+state_input2_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA2_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext1 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext1+state_input2_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input2_ext1.setText(name_input2_ext1 + state_input2_ext1);

                    editor.putString(APP_PREFERENCES_INPUT2_EXT1, state_input2_ext1);
                }

                if (
                        (message_text.indexOf(SMS_EXT1_ZONA3_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA3_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA3_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA3_OBRIV) > -1)
                        )
                {
                    state_input3_ext1 = separation;
                    TEXT=SMS_EXT1_ZONA3_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext1 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext1+state_input3_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA3_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext1 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext1+state_input3_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA3_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext1 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext1+state_input3_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA3_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext1 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext1+state_input3_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input3_ext1.setText(name_input3_ext1 + state_input3_ext1);

                    editor.putString(APP_PREFERENCES_INPUT3_EXT1, state_input3_ext1);
                }

                if (
                        (message_text.indexOf(SMS_EXT1_ZONA4_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA4_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA4_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA4_OBRIV) > -1)
                        )
                {
                    state_input4_ext1 = separation;
                    TEXT=SMS_EXT1_ZONA4_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext1 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext1+state_input4_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA4_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext1 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext1+state_input4_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA4_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext1 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext1+state_input4_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA4_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext1 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext1+state_input4_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input4_ext1.setText(name_input4_ext1 + state_input4_ext1);

                    editor.putString(APP_PREFERENCES_INPUT4_EXT1, state_input4_ext1);
                }

                if (
                        (message_text.indexOf(SMS_EXT1_ZONA5_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA5_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA5_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA5_OBRIV) > -1)
                        )
                {
                    state_input5_ext1 = separation;
                    TEXT=SMS_EXT1_ZONA5_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext1 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext1+state_input5_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA5_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext1 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext1+state_input5_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA5_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext1 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext1+state_input5_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA5_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext1 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext1+state_input5_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input5_ext1.setText(name_input5_ext1 + state_input5_ext1);

                    editor.putString(APP_PREFERENCES_INPUT5_EXT1, state_input5_ext1);
                }

                if (
                        (message_text.indexOf(SMS_EXT1_ZONA6_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA6_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA6_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA6_OBRIV) > -1)
                        )
                {
                    state_input6_ext1 = separation;
                    TEXT=SMS_EXT1_ZONA6_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext1 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext1+state_input6_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA6_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext1 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext1+state_input6_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA6_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext1 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext1+state_input6_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA6_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext1 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext1+state_input6_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input6_ext1.setText(name_input6_ext1+ state_input6_ext1);

                    editor.putString(APP_PREFERENCES_INPUT6_EXT1, state_input6_ext1);
                }


                if (
                        (message_text.indexOf(SMS_EXT1_ZONA7_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA7_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA7_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA7_OBRIV) > -1)
                        )
                {
                    state_input7_ext1 = separation;
                    TEXT=SMS_EXT1_ZONA7_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext1 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext1+state_input7_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA7_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext1 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext1+state_input7_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA7_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext1 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext1+state_input7_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA7_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext1 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext1+state_input7_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input7_ext1.setText(name_input7_ext1 + state_input7_ext1);

                    editor.putString(APP_PREFERENCES_INPUT7_EXT1, state_input7_ext1);
                }

                if (
                        (message_text.indexOf(SMS_EXT1_ZONA8_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA8_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA8_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT1_ZONA8_OBRIV) > -1)
                        )
                {
                    state_input8_ext1 = separation;
                    TEXT=SMS_EXT1_ZONA8_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext1 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext1+state_input8_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA8_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext1 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext1+state_input8_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA8_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext1 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext1+state_input8_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT1_ZONA8_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext1 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext1+state_input8_ext1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input8_ext1.setText(name_input8_ext1 + state_input8_ext1);

                    editor.putString(APP_PREFERENCES_INPUT8_EXT1, state_input8_ext1);
                }


                //ext2
                if (
                        (message_text.indexOf(SMS_EXT2_ZONA1_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA1_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA1_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA1_OBRIV) > -1)
                        )
                {
                    state_input1_ext2 = separation;
                    TEXT=SMS_EXT2_ZONA1_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext2 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext2+state_input1_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA1_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext2 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext2+state_input1_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA1_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext2 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext2+state_input1_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA1_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext2 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext2+state_input1_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input1_ext2.setText(name_input1_ext2 + state_input1_ext2);

                    editor.putString(APP_PREFERENCES_INPUT1_EXT2, state_input1_ext2);
                }

                if (
                        (message_text.indexOf(SMS_EXT2_ZONA2_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA2_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA2_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA2_OBRIV) > -1)
                        )
                {
                    state_input2_ext2 = separation;
                    TEXT=SMS_EXT2_ZONA2_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext2 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext2+state_input2_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA2_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext2 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext2+state_input2_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA2_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext2 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext2+state_input2_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA2_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext2 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext2+state_input2_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input2_ext2.setText(name_input2_ext2 + state_input2_ext2);

                    editor.putString(APP_PREFERENCES_INPUT2_EXT2, state_input2_ext2);
                }

                if (
                        (message_text.indexOf(SMS_EXT2_ZONA3_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA3_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA3_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA3_OBRIV) > -1)
                        )
                {
                    state_input3_ext2 = separation;
                    TEXT=SMS_EXT2_ZONA3_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext2 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext2+state_input3_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA3_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext2 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext2+state_input3_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA3_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext2 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext2+state_input3_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA3_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext2 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext2+state_input3_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input3_ext2.setText(name_input3_ext2 + state_input3_ext2);

                    editor.putString(APP_PREFERENCES_INPUT3_EXT2, state_input3_ext2);
                }

                if (
                        (message_text.indexOf(SMS_EXT2_ZONA4_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA4_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA4_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA4_OBRIV) > -1)
                        )
                {
                    state_input4_ext2 = separation;
                    TEXT=SMS_EXT2_ZONA4_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext2 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext2+state_input4_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA4_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext2 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext2+state_input4_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA4_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext2 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext2+state_input4_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA4_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext2 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext2+state_input4_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input4_ext2.setText(name_input4_ext2 + state_input4_ext2);

                    editor.putString(APP_PREFERENCES_INPUT4_EXT2, state_input4_ext2);
                }

                if (
                        (message_text.indexOf(SMS_EXT2_ZONA5_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA5_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA5_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA5_OBRIV) > -1)
                        )
                {
                    state_input5_ext2 = separation;
                    TEXT=SMS_EXT2_ZONA5_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext2 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext2+state_input5_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA5_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext2 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext2+state_input5_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA5_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext2 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext2+state_input5_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA5_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext2 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext2+state_input5_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input5_ext2.setText(name_input5_ext2 + state_input5_ext2);

                    editor.putString(APP_PREFERENCES_INPUT5_EXT2, state_input5_ext2);
                }

                if (
                        (message_text.indexOf(SMS_EXT2_ZONA6_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA6_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA6_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA6_OBRIV) > -1)
                        )
                {
                    state_input6_ext2 = separation;
                    TEXT=SMS_EXT2_ZONA6_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext2 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext2+state_input6_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA6_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext2 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext2+state_input6_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA6_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext2 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext2+state_input6_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA6_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext2 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext2+state_input6_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input6_ext2.setText(name_input6_ext2+ state_input6_ext2);

                    editor.putString(APP_PREFERENCES_INPUT6_EXT2, state_input6_ext2);
                }


                if (
                        (message_text.indexOf(SMS_EXT2_ZONA7_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA7_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA7_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA7_OBRIV) > -1)
                        )
                {
                    state_input7_ext2 = separation;
                    TEXT=SMS_EXT2_ZONA7_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext2 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext2+state_input7_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA7_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext2 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext2+state_input7_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA7_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext2 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext2+state_input7_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA7_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext2 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext2+state_input7_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input7_ext2.setText(name_input7_ext2 + state_input7_ext2);

                    editor.putString(APP_PREFERENCES_INPUT7_EXT2, state_input7_ext2);
                }

                if (
                        (message_text.indexOf(SMS_EXT2_ZONA8_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA8_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA8_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT2_ZONA8_OBRIV) > -1)
                        )
                {
                    state_input8_ext2 = separation;
                    TEXT=SMS_EXT2_ZONA8_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext2 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext2+state_input8_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA8_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext2 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext2+state_input8_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA8_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext2 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext2+state_input8_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT2_ZONA8_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext2 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext2+state_input8_ext2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input8_ext2.setText(name_input8_ext2 + state_input8_ext2);

                    editor.putString(APP_PREFERENCES_INPUT8_EXT2, state_input8_ext2);
                }

                //ext3
                if (
                        (message_text.indexOf(SMS_EXT3_ZONA1_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA1_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA1_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA1_OBRIV) > -1)
                        )
                {
                    state_input1_ext3 = separation;
                    TEXT=SMS_EXT3_ZONA1_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext3 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext3+state_input1_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA1_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext3 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext3+state_input1_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA1_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext3 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext3+state_input1_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA1_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext3 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext3+state_input1_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input1_ext3.setText(name_input1_ext3 + state_input1_ext3);

                    editor.putString(APP_PREFERENCES_INPUT1_EXT3, state_input1_ext3);
                }

                if (
                        (message_text.indexOf(SMS_EXT3_ZONA2_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA2_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA2_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA2_OBRIV) > -1)
                        )
                {
                    state_input2_ext3 = separation;
                    TEXT=SMS_EXT3_ZONA2_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext3 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext3+state_input2_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA2_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext3 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext3+state_input2_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA2_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext3 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext3+state_input2_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA2_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext3 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext3+state_input2_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input2_ext3.setText(name_input2_ext3 + state_input2_ext3);

                    editor.putString(APP_PREFERENCES_INPUT2_EXT3, state_input2_ext3);
                }

                if (
                        (message_text.indexOf(SMS_EXT3_ZONA3_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA3_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA3_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA3_OBRIV) > -1)
                        )
                {
                    state_input3_ext3 = separation;
                    TEXT=SMS_EXT3_ZONA3_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext3 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext3+state_input3_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA3_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext3 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext3+state_input3_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA3_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext3 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext3+state_input3_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA3_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext3 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext3+state_input3_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input3_ext3.setText(name_input3_ext3 + state_input3_ext3);

                    editor.putString(APP_PREFERENCES_INPUT3_EXT3, state_input3_ext3);
                }

                if (
                        (message_text.indexOf(SMS_EXT3_ZONA4_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA4_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA4_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA4_OBRIV) > -1)
                        )
                {
                    state_input4_ext3 = separation;
                    TEXT=SMS_EXT3_ZONA4_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext3 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext3+state_input4_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA4_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext3 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext3+state_input4_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA4_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext3 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext3+state_input4_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA4_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext3 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext3+state_input4_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input4_ext3.setText(name_input4_ext3 + state_input4_ext3);

                    editor.putString(APP_PREFERENCES_INPUT4_EXT3, state_input4_ext3);
                }

                if (
                        (message_text.indexOf(SMS_EXT3_ZONA5_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA5_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA5_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA5_OBRIV) > -1)
                        )
                {
                    state_input5_ext3 = separation;
                    TEXT=SMS_EXT3_ZONA5_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext3 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext3+state_input5_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA5_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext3 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext3+state_input5_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA5_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext3 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext3+state_input5_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA5_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext3 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext3+state_input5_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input5_ext3.setText(name_input5_ext3 + state_input5_ext3);

                    editor.putString(APP_PREFERENCES_INPUT5_EXT3, state_input5_ext3);
                }

                if (
                        (message_text.indexOf(SMS_EXT3_ZONA6_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA6_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA6_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA6_OBRIV) > -1)
                        )
                {
                    state_input6_ext3 = separation;
                    TEXT=SMS_EXT3_ZONA6_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext3 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext3+state_input6_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA6_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext3 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext3+state_input6_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA6_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext3 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext3+state_input6_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA6_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext3 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext3+state_input6_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input6_ext3.setText(name_input6_ext3+ state_input6_ext3);

                    editor.putString(APP_PREFERENCES_INPUT6_EXT3, state_input6_ext3);
                }


                if (
                        (message_text.indexOf(SMS_EXT3_ZONA7_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA7_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA7_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA7_OBRIV) > -1)
                        )
                {
                    state_input7_ext3 = separation;
                    TEXT=SMS_EXT3_ZONA7_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext3 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext3+state_input7_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA7_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext3 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext3+state_input7_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA7_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext3 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext3+state_input7_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA7_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext3 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext3+state_input7_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input7_ext3.setText(name_input7_ext3 + state_input7_ext3);

                    editor.putString(APP_PREFERENCES_INPUT7_EXT3, state_input7_ext3);
                }

                if (
                        (message_text.indexOf(SMS_EXT3_ZONA8_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA8_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA8_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT3_ZONA8_OBRIV) > -1)
                        )
                {
                    state_input8_ext3 = separation;
                    TEXT=SMS_EXT3_ZONA8_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext3 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext3+state_input8_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA8_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext3 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext3+state_input8_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA8_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext3 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext3+state_input8_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT3_ZONA8_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext3 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext3+state_input8_ext3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input8_ext3.setText(name_input8_ext3 + state_input8_ext3);

                    editor.putString(APP_PREFERENCES_INPUT8_EXT3, state_input8_ext3);
                }

                //ext4
                if (
                        (message_text.indexOf(SMS_EXT4_ZONA1_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA1_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA1_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA1_OBRIV) > -1)
                        )
                {
                    state_input1_ext4 = separation;
                    TEXT=SMS_EXT4_ZONA1_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext4 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext4+state_input1_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA1_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext4 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext4+state_input1_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA1_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext4 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext4+state_input1_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA1_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1_ext4 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext4+state_input1_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input1_ext4.setText(name_input1_ext4 + state_input1_ext4);

                    editor.putString(APP_PREFERENCES_INPUT1_EXT4, state_input1_ext4);
                }

                if (
                        (message_text.indexOf(SMS_EXT4_ZONA2_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA2_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA2_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA2_OBRIV) > -1)
                        )
                {
                    state_input2_ext4 = separation;
                    TEXT=SMS_EXT4_ZONA2_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext4 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext4+state_input2_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA2_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext4 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext4+state_input2_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA2_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext4 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext4+state_input2_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA2_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2_ext4 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext4+state_input2_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input2_ext4.setText(name_input2_ext4 + state_input2_ext4);

                    editor.putString(APP_PREFERENCES_INPUT2_EXT4, state_input2_ext4);
                }

                if (
                        (message_text.indexOf(SMS_EXT4_ZONA3_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA3_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA3_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA3_OBRIV) > -1)
                        )
                {
                    state_input3_ext4 = separation;
                    TEXT=SMS_EXT4_ZONA3_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext4 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext4+state_input3_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA3_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext4 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext4+state_input3_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA3_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext4 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext4+state_input3_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA3_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3_ext4 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext4+state_input3_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input3_ext4.setText(name_input3_ext4 + state_input3_ext4);

                    editor.putString(APP_PREFERENCES_INPUT3_EXT4, state_input3_ext4);
                }

                if (
                        (message_text.indexOf(SMS_EXT4_ZONA4_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA4_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA4_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA4_OBRIV) > -1)
                        )
                {
                    state_input4_ext4 = separation;
                    TEXT=SMS_EXT4_ZONA4_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext4 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext4+state_input4_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA4_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext4 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext4+state_input4_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA4_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext4 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext4+state_input4_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA4_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4_ext4 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext4+state_input4_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input4_ext4.setText(name_input4_ext4 + state_input4_ext4);

                    editor.putString(APP_PREFERENCES_INPUT4_EXT4, state_input4_ext4);
                }

                if (
                        (message_text.indexOf(SMS_EXT4_ZONA5_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA5_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA5_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA5_OBRIV) > -1)
                        )
                {
                    state_input5_ext4 = separation;
                    TEXT=SMS_EXT4_ZONA5_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext4 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext4+state_input5_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA5_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext4 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext4+state_input5_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA5_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext4 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext4+state_input5_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA5_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5_ext4 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext4+state_input5_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input5_ext4.setText(name_input5_ext4 + state_input5_ext4);

                    editor.putString(APP_PREFERENCES_INPUT5_EXT4, state_input5_ext4);
                }

                if (
                        (message_text.indexOf(SMS_EXT4_ZONA6_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA6_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA6_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA6_OBRIV) > -1)
                        )
                {
                    state_input6_ext4 = separation;
                    TEXT=SMS_EXT4_ZONA6_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext4 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext4+state_input6_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA6_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext4 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext4+state_input6_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA6_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext4 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext4+state_input6_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA6_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6_ext4 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext4+state_input6_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input6_ext4.setText(name_input6_ext4+ state_input6_ext4);

                    editor.putString(APP_PREFERENCES_INPUT6_EXT4, state_input6_ext4);
                }


                if (
                        (message_text.indexOf(SMS_EXT4_ZONA7_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA7_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA7_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA7_OBRIV) > -1)
                        )
                {
                    state_input7_ext4 = separation;
                    TEXT=SMS_EXT4_ZONA7_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext4 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext4+state_input7_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA7_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext4 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext4+state_input7_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA7_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext4 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext4+state_input7_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA7_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7_ext4 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext4+state_input7_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input7_ext4.setText(name_input7_ext4 + state_input7_ext4);

                    editor.putString(APP_PREFERENCES_INPUT7_EXT4, state_input7_ext4);
                }

                if (
                        (message_text.indexOf(SMS_EXT4_ZONA8_NORMA)>-1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA8_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA8_KZ) > -1) ||
                                (message_text.indexOf(SMS_EXT4_ZONA8_OBRIV) > -1)
                        )
                {
                    state_input8_ext4 = separation;
                    TEXT=SMS_EXT4_ZONA8_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext4 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext4+state_input8_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA8_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext4 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext4+state_input8_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA8_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext4 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext4+state_input8_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_EXT4_ZONA8_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8_ext4 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext4+state_input8_ext4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input8_ext4.setText(name_input8_ext4 + state_input8_ext4);

                    editor.putString(APP_PREFERENCES_INPUT8_EXT4, state_input8_ext4);
                }




                //main board
                if (
                        (message_text.indexOf(SMS_TAMPER_NORMA)>-1) ||
                                (message_text.indexOf(SMS_TAMPER_TREVOGA) > -1)
                        )
                {
                    state_tamper = separation;
                    TEXT=SMS_TAMPER_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_tamper = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_tamper+state_tamper + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_TAMPER_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_tamper = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_tamper+state_tamper + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_tamper.setText(name_tamper + state_tamper);

                    editor.putString(APP_PREFERENCES_TAMPER, state_tamper);
                }

                if (
                        (message_text.indexOf(SMS_ZONA1_NORMA)>-1) || (message_text.indexOf(SMS_ZONA_NORMA)>-1) || (message_text.indexOf(SMS_ZONA_1_NORMA)>-1) ||
                                (message_text.indexOf(SMS_ZONA1_TREVOGA) > -1) || (message_text.indexOf(SMS_ZONA_TREVOGA) > -1) || (message_text.indexOf(SMS_ZONA_1_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_ZONA1_KZ) > -1) ||
                                (message_text.indexOf(SMS_ZONA1_OBRIV) > -1)
                        )
                {
                    state_input1 = separation;
                    TEXT=SMS_ZONA1_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1+state_input1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA1_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1+state_input1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA1_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1+state_input1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1+state_input1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA_1_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1+state_input1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    TEXT=SMS_ZONA1_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1+state_input1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1+state_input1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA_1_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input1 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1+state_input1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input1.setText(name_input1 + state_input1);

                    editor.putString(APP_PREFERENCES_INPUT1, state_input1);
                }

                if (
                        (message_text.indexOf(SMS_ZONA2_NORMA)>-1) || (message_text.indexOf(SMS_ZONA_2_NORMA)>-1) ||
                                (message_text.indexOf(SMS_ZONA2_TREVOGA) > -1) || (message_text.indexOf(SMS_ZONA_2_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_ZONA2_KZ) > -1) ||
                                (message_text.indexOf(SMS_ZONA2_OBRIV) > -1)
                        )
                {
                    state_input2 = separation;
                    TEXT=SMS_ZONA2_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2+state_input2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA2_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2+state_input2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA2_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2+state_input2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA_2_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2+state_input2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    TEXT=SMS_ZONA2_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2+state_input2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    TEXT=SMS_ZONA_2_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input2 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2+state_input2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input2.setText(name_input2 + state_input2);

                    editor.putString(APP_PREFERENCES_INPUT2, state_input2);
                }

                if (
                        (message_text.indexOf(SMS_ZONA3_NORMA)>-1) ||
                                (message_text.indexOf(SMS_ZONA3_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_ZONA3_KZ) > -1) ||
                                (message_text.indexOf(SMS_ZONA3_OBRIV) > -1)
                        )
                {
                    state_input3 = separation;
                    TEXT=SMS_ZONA3_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3+state_input3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA3_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3+state_input3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA3_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3+state_input3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA3_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input3 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3+state_input3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input3.setText(name_input3 + state_input3);

                    editor.putString(APP_PREFERENCES_INPUT3, state_input3);
                }

                if (
                        (message_text.indexOf(SMS_ZONA4_NORMA)>-1) ||
                                (message_text.indexOf(SMS_ZONA4_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_ZONA4_KZ) > -1) ||
                                (message_text.indexOf(SMS_ZONA4_OBRIV) > -1)
                        )
                {
                    state_input4 = separation;
                    TEXT=SMS_ZONA4_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4+state_input4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA4_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4+state_input4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA4_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4+state_input4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA4_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input4 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4+state_input4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input4.setText(name_input4 + state_input4);

                    editor.putString(APP_PREFERENCES_INPUT4, state_input4);
                }

                if (
                        (message_text.indexOf(SMS_ZONA5_NORMA)>-1) ||
                                (message_text.indexOf(SMS_ZONA5_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_ZONA5_KZ) > -1) ||
                                (message_text.indexOf(SMS_ZONA5_OBRIV) > -1)
                        )
                {
                    state_input5 = separation;
                    TEXT=SMS_ZONA5_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5+state_input5 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA5_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5+state_input5 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA5_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5+state_input5 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA5_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input5 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5+state_input5 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input5.setText(name_input5 + state_input5);

                    editor.putString(APP_PREFERENCES_INPUT5, state_input5);
                }

                if (
                        (message_text.indexOf(SMS_ZONA6_NORMA)>-1) ||
                                (message_text.indexOf(SMS_ZONA6_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_ZONA6_KZ) > -1) ||
                                (message_text.indexOf(SMS_ZONA6_OBRIV) > -1)
                        )
                {
                    state_input6 = separation;
                    TEXT=SMS_ZONA6_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6+state_input6 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA6_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6+state_input6 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA6_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6+state_input6 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA6_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input6 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6+state_input6 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input6.setText(name_input6+ state_input6);

                    editor.putString(APP_PREFERENCES_INPUT6, state_input6);
                }


                if (
                        (message_text.indexOf(SMS_ZONA7_NORMA)>-1) ||
                                (message_text.indexOf(SMS_ZONA7_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_ZONA7_KZ) > -1) ||
                                (message_text.indexOf(SMS_ZONA7_OBRIV) > -1)
                        )
                {
                    state_input7 = separation;
                    TEXT=SMS_ZONA7_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7+state_input7 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA7_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7+state_input7 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA7_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7+state_input7 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA7_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input7 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7+state_input7 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input7.setText(name_input7 + state_input7);

                    editor.putString(APP_PREFERENCES_INPUT7, state_input7);
                }

                if (
                        (message_text.indexOf(SMS_ZONA8_NORMA)>-1) ||
                                (message_text.indexOf(SMS_ZONA8_TREVOGA) > -1) ||
                                (message_text.indexOf(SMS_ZONA8_KZ) > -1) ||
                                (message_text.indexOf(SMS_ZONA8_OBRIV) > -1)
                        )
                {
                    state_input8 = separation;
                    TEXT=SMS_ZONA8_KZ;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8 = separation + KZ;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8+state_input8 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA8_OBRIV;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8 = separation + OBRIV;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8+state_input8 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA8_NORMA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8 = separation + NORMA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8+state_input8 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }
                    TEXT=SMS_ZONA8_TREVOGA;
                    if (message_text.indexOf(TEXT) > -1) {
                        state_input8 = separation + TREVOGA;
                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8+state_input8 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    }

                    textView_input8.setText(name_input8 + state_input8);

                    editor.putString(APP_PREFERENCES_INPUT8, state_input8);
                }




                String imageView_input = "imageView_termo_";

                String temp="1";
                if ( textView_tamper.isShown() && (!state_tamper.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input1.isShown() && (!state_input1.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input2.isShown() && (!state_input2.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input3.isShown() && (!state_input3.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input4.isShown() && (!state_input4.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input5.isShown() && (!state_input5.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input6.isShown() && (!state_input6.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input7.isShown() && (!state_input7.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input8.isShown() && (!state_input8.equals(separation + NORMA)) ) temp = "0";

                if ( textView_input1_ext0.isShown() && (!state_input1_ext0.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input2_ext0.isShown() && (!state_input2_ext0.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input3_ext0.isShown() && (!state_input3_ext0.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input4_ext0.isShown() && (!state_input4_ext0.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input5_ext0.isShown() && (!state_input5_ext0.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input6_ext0.isShown() && (!state_input6_ext0.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input7_ext0.isShown() && (!state_input7_ext0.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input8_ext0.isShown() && (!state_input8_ext0.equals(separation + NORMA)) ) temp = "0";

                if ( textView_input1_ext1.isShown() && (!state_input1_ext1.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input2_ext1.isShown() && (!state_input2_ext1.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input3_ext1.isShown() && (!state_input3_ext1.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input4_ext1.isShown() && (!state_input4_ext1.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input5_ext1.isShown() && (!state_input5_ext1.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input6_ext1.isShown() && (!state_input6_ext1.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input7_ext1.isShown() && (!state_input7_ext1.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input8_ext1.isShown() && (!state_input8_ext1.equals(separation + NORMA)) ) temp = "0";

                if ( textView_input1_ext2.isShown() && (!state_input1_ext2.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input2_ext2.isShown() && (!state_input2_ext2.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input3_ext2.isShown() && (!state_input3_ext2.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input4_ext2.isShown() && (!state_input4_ext2.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input5_ext2.isShown() && (!state_input5_ext2.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input6_ext2.isShown() && (!state_input6_ext2.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input7_ext2.isShown() && (!state_input7_ext2.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input8_ext2.isShown() && (!state_input8_ext2.equals(separation + NORMA)) ) temp = "0";

                if ( textView_input1_ext3.isShown() && (!state_input1_ext3.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input2_ext3.isShown() && (!state_input2_ext3.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input3_ext3.isShown() && (!state_input3_ext3.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input4_ext3.isShown() && (!state_input4_ext3.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input5_ext3.isShown() && (!state_input5_ext3.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input6_ext3.isShown() && (!state_input6_ext3.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input7_ext3.isShown() && (!state_input7_ext3.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input8_ext3.isShown() && (!state_input8_ext3.equals(separation + NORMA)) ) temp = "0";

                if ( textView_input1_ext4.isShown() && (!state_input1_ext4.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input2_ext4.isShown() && (!state_input2_ext4.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input3_ext4.isShown() && (!state_input3_ext4.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input4_ext4.isShown() && (!state_input4_ext4.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input5_ext4.isShown() && (!state_input5_ext4.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input6_ext4.isShown() && (!state_input6_ext4.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input7_ext4.isShown() && (!state_input7_ext4.equals(separation + NORMA)) ) temp = "0";
                if ( textView_input8_ext4.isShown() && (!state_input8_ext4.equals(separation + NORMA)) ) temp = "0";

                if (temp.equals("1") )
                {
                    imageView_input = "imageView_input_norma";
                    imageView_input_trevoga.setVisibility(View.INVISIBLE);
                    imageView_input_norma.setVisibility(View.VISIBLE);
                    imageView_input_.setVisibility(View.INVISIBLE);
                } else {
                    imageView_input = "imageView_input_trevoga";
                    imageView_input_trevoga.setVisibility(View.VISIBLE);
                    imageView_input_norma.setVisibility(View.INVISIBLE);
                    imageView_input_.setVisibility(View.INVISIBLE);
                }

                //выводим состояние выходов

                //ext0
                try {
                    TEXT=SMS_EXT0_OUTPUTS;
                    ext_temp=TEXT;
                    if (message_text.indexOf(TEXT) > -1){
                        TEXT = message_text.substring(message_text.indexOf(TEXT) + TEXT.length());
                        message_text = message_text.substring(0, message_text.indexOf(ext_temp)) + "EXT0 " + getString(R.string.set_outputs) + message_text.substring(message_text.indexOf(ext_temp) + ext_temp.length(), message_text.length());
                        try {
                            if (TEXT.substring(0, 1).equals("1")) {
                                state_output1_ext0 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(0, 1).equals("0")) {
                                state_output1_ext0 = separation + OUTPUT_OFF;
                            }
                            btn_output1_ext0.setText(name_output1_ext0 + state_output1_ext0);

                            if (TEXT.substring(1, 2).equals("1")) {
                                state_output2_ext0 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(1, 2).equals("0")) {
                                state_output2_ext0 = separation + OUTPUT_OFF;
                            }
                            btn_output2_ext0.setText(name_output2_ext0 + state_output2_ext0);

                            if (TEXT.substring(2, 3).equals("1")) {
                                state_output3_ext0 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(2, 3).equals("0")) {
                                state_output3_ext0 = separation + OUTPUT_OFF;
                            }
                            btn_output3_ext0.setText(name_output3_ext0 + state_output3_ext0);

                            if (TEXT.substring(3, 4).equals("1")) {
                                state_output4_ext0 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(3, 4).equals("0")) {
                                state_output4_ext0 = separation + OUTPUT_OFF;
                            }
                            btn_output4_ext0.setText(name_output4_ext0 + state_output4_ext0);

                            if (TEXT.substring(4, 5).equals("1")) {
                                state_output5_ext0 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(4, 5).equals("0")) {
                                state_output5_ext0 = separation + OUTPUT_OFF;
                            }
                            btn_output5_ext0.setText(name_output5_ext0 + state_output5_ext0);

                            if (TEXT.substring(5, 6).equals("1")) {
                                state_output6_ext0 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(5, 6).equals("0")) {
                                state_output6_ext0 = separation + OUTPUT_OFF;
                            }
                            btn_output6_ext0.setText(name_output6_ext0 + state_output6_ext0);

                            if (TEXT.substring(6, 7).equals("1")) {
                                state_output7_ext0 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(6, 7).equals("0")) {
                                state_output7_ext0 = separation + OUTPUT_OFF;
                            }
                            btn_output7_ext0.setText(name_output7_ext0 + state_output7_ext0);

                            if (TEXT.substring(7, 8).equals("1")) {
                                state_output8_ext0 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(7, 8).equals("0")) {
                                state_output8_ext0 = separation + OUTPUT_OFF;
                            }
                            btn_output8_ext0.setText(name_output8_ext0 + state_output8_ext0);
                        } catch (Exception ex)  {}


                        //ext0
                        editor.putString(APP_PREFERENCES_OUTPUT1_EXT0, state_output1_ext0);
                        editor.putString(APP_PREFERENCES_OUTPUT2_EXT0, state_output2_ext0);
                        editor.putString(APP_PREFERENCES_OUTPUT3_EXT0, state_output3_ext0);
                        editor.putString(APP_PREFERENCES_OUTPUT4_EXT0, state_output4_ext0);
                        editor.putString(APP_PREFERENCES_OUTPUT5_EXT0, state_output5_ext0);
                        editor.putString(APP_PREFERENCES_OUTPUT6_EXT0, state_output6_ext0);
                        editor.putString(APP_PREFERENCES_OUTPUT7_EXT0, state_output7_ext0);
                        editor.putString(APP_PREFERENCES_OUTPUT8_EXT0, state_output8_ext0);

                    }
                } catch (Exception ex)  {}



                //ext1
                try {
                TEXT=SMS_EXT1_OUTPUTS;
                    ext_temp=TEXT;
                if (message_text.indexOf(TEXT) > -1){
                    TEXT = message_text.substring(message_text.indexOf(TEXT) + TEXT.length());
                    message_text = message_text.substring(0, message_text.indexOf(ext_temp)) + "EXT1 " + getString(R.string.set_outputs) + message_text.substring(message_text.indexOf(ext_temp) + ext_temp.length(), message_text.length());
                    try {
                    if (TEXT.substring(0, 1).equals("1")) {
                        state_output1_ext1 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(0, 1).equals("0")) {
                        state_output1_ext1 = separation + OUTPUT_OFF;
                    }
                    btn_output1_ext1.setText(name_output1_ext1 + state_output1_ext1);

                    if (TEXT.substring(1, 2).equals("1")) {
                        state_output2_ext1 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(1, 2).equals("0")) {
                        state_output2_ext1 = separation + OUTPUT_OFF;
                    }
                    btn_output2_ext1.setText(name_output2_ext1 + state_output2_ext1);

                    if (TEXT.substring(2, 3).equals("1")) {
                        state_output3_ext1 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(2, 3).equals("0")) {
                        state_output3_ext1 = separation + OUTPUT_OFF;
                    }
                    btn_output3_ext1.setText(name_output3_ext1 + state_output3_ext1);

                    if (TEXT.substring(3, 4).equals("1")) {
                        state_output4_ext1 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(3, 4).equals("0")) {
                        state_output4_ext1 = separation + OUTPUT_OFF;
                    }
                    btn_output4_ext1.setText(name_output4_ext1 + state_output4_ext1);

                    if (TEXT.substring(4, 5).equals("1")) {
                        state_output5_ext1 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(4, 5).equals("0")) {
                        state_output5_ext1 = separation + OUTPUT_OFF;
                    }
                    btn_output5_ext1.setText(name_output5_ext1 + state_output5_ext1);

                    if (TEXT.substring(5, 6).equals("1")) {
                        state_output6_ext1 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(5, 6).equals("0")) {
                        state_output6_ext1 = separation + OUTPUT_OFF;
                    }
                    btn_output6_ext1.setText(name_output6_ext1 + state_output6_ext1);

                    if (TEXT.substring(6, 7).equals("1")) {
                        state_output7_ext1 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(6, 7).equals("0")) {
                        state_output7_ext1 = separation + OUTPUT_OFF;
                    }
                    btn_output7_ext1.setText(name_output7_ext1 + state_output7_ext1);

                    if (TEXT.substring(7, 8).equals("1")) {
                        state_output8_ext1 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(7, 8).equals("0")) {
                        state_output8_ext1 = separation + OUTPUT_OFF;
                    }
                    btn_output8_ext1.setText(name_output8_ext1 + state_output8_ext1);
                    } catch (Exception ex)  {}

                    //ext1
                    editor.putString(APP_PREFERENCES_OUTPUT1_EXT1, state_output1_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT2_EXT1, state_output2_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT3_EXT1, state_output3_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT4_EXT1, state_output4_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT5_EXT1, state_output5_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT6_EXT1, state_output6_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT7_EXT1, state_output7_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT8_EXT1, state_output8_ext1);

                }
                } catch (Exception ex)  {}

                //ext2
                try {
                    TEXT=SMS_EXT2_OUTPUTS;
                    ext_temp=TEXT;
                    if (message_text.indexOf(TEXT) > -1){
                        TEXT = message_text.substring(message_text.indexOf(TEXT) + TEXT.length());
                        message_text = message_text.substring(0, message_text.indexOf(ext_temp)) + "EXT2 " + getString(R.string.set_outputs) + message_text.substring(message_text.indexOf(ext_temp) + ext_temp.length(), message_text.length());
                        try {
                        if (TEXT.substring(0, 1).equals("1")) {
                            state_output1_ext2 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(0, 1).equals("0")) {
                            state_output1_ext2 = separation + OUTPUT_OFF;
                        }
                        btn_output1_ext2.setText(name_output1_ext2 + state_output1_ext2);

                        if (TEXT.substring(1, 2).equals("1")) {
                            state_output2_ext2 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(1, 2).equals("0")) {
                            state_output2_ext2 = separation + OUTPUT_OFF;
                        }
                        btn_output2_ext2.setText(name_output2_ext2 + state_output2_ext2);

                        if (TEXT.substring(2, 3).equals("1")) {
                            state_output3_ext2 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(2, 3).equals("0")) {
                            state_output3_ext2 = separation + OUTPUT_OFF;
                        }
                        btn_output3_ext2.setText(name_output3_ext2 + state_output3_ext2);

                        if (TEXT.substring(3, 4).equals("1")) {
                            state_output4_ext2 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(3, 4).equals("0")) {
                            state_output4_ext2 = separation + OUTPUT_OFF;
                        }
                        btn_output4_ext2.setText(name_output4_ext2 + state_output4_ext2);

                        if (TEXT.substring(4, 5).equals("1")) {
                            state_output5_ext2 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(4, 5).equals("0")) {
                            state_output5_ext2 = separation + OUTPUT_OFF;
                        }
                        btn_output5_ext2.setText(name_output5_ext2 + state_output5_ext2);

                        if (TEXT.substring(5, 6).equals("1")) {
                            state_output6_ext2 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(5, 6).equals("0")) {
                            state_output6_ext2 = separation + OUTPUT_OFF;
                        }
                        btn_output6_ext2.setText(name_output6_ext2 + state_output6_ext2);

                        if (TEXT.substring(6, 7).equals("1")) {
                            state_output7_ext2 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(6, 7).equals("0")) {
                            state_output7_ext2 = separation + OUTPUT_OFF;
                        }
                        btn_output7_ext2.setText(name_output7_ext2 + state_output7_ext2);

                        if (TEXT.substring(7, 8).equals("1")) {
                            state_output8_ext2 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(7, 8).equals("0")) {
                            state_output8_ext2 = separation + OUTPUT_OFF;
                        }
                        btn_output8_ext2.setText(name_output8_ext2 + state_output8_ext2);
                        } catch (Exception ex)  {}

                        //ext2
                        editor.putString(APP_PREFERENCES_OUTPUT1_EXT2, state_output1_ext2);
                        editor.putString(APP_PREFERENCES_OUTPUT2_EXT2, state_output2_ext2);
                        editor.putString(APP_PREFERENCES_OUTPUT3_EXT2, state_output3_ext2);
                        editor.putString(APP_PREFERENCES_OUTPUT4_EXT2, state_output4_ext2);
                        editor.putString(APP_PREFERENCES_OUTPUT5_EXT2, state_output5_ext2);
                        editor.putString(APP_PREFERENCES_OUTPUT6_EXT2, state_output6_ext2);
                        editor.putString(APP_PREFERENCES_OUTPUT7_EXT2, state_output7_ext2);
                        editor.putString(APP_PREFERENCES_OUTPUT8_EXT2, state_output8_ext2);


                    }
                } catch (Exception ex)  {}


                //ext3

                try {
                    TEXT=SMS_EXT3_OUTPUTS;
                    ext_temp=TEXT;
                    if (message_text.indexOf(TEXT) > -1){
                        TEXT = message_text.substring(message_text.indexOf(TEXT) + TEXT.length());
                        message_text = message_text.substring(0, message_text.indexOf(ext_temp)) + "EXT3 " + getString(R.string.set_outputs) + message_text.substring(message_text.indexOf(ext_temp) + ext_temp.length(), message_text.length());
                        try {
                        if (TEXT.substring(0, 1).equals("1")) {
                            state_output1_ext3 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(0, 1).equals("0")) {
                            state_output1_ext3 = separation + OUTPUT_OFF;
                        }
                        btn_output1_ext3.setText(name_output1_ext3 + state_output1_ext3);

                        if (TEXT.substring(1, 2).equals("1")) {
                            state_output2_ext3 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(1, 2).equals("0")) {
                            state_output2_ext3 = separation + OUTPUT_OFF;
                        }
                        btn_output2_ext3.setText(name_output2_ext3 + state_output2_ext3);

                        if (TEXT.substring(2, 3).equals("1")) {
                            state_output3_ext3 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(2, 3).equals("0")) {
                            state_output3_ext3 = separation + OUTPUT_OFF;
                        }
                        btn_output3_ext3.setText(name_output3_ext3 + state_output3_ext3);

                        if (TEXT.substring(3, 4).equals("1")) {
                            state_output4_ext3 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(3, 4).equals("0")) {
                            state_output4_ext3 = separation + OUTPUT_OFF;
                        }
                        btn_output4_ext3.setText(name_output4_ext3 + state_output4_ext3);

                        if (TEXT.substring(4, 5).equals("1")) {
                            state_output5_ext3 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(4, 5).equals("0")) {
                            state_output5_ext3 = separation + OUTPUT_OFF;
                        }
                        btn_output5_ext3.setText(name_output5_ext3 + state_output5_ext3);

                        if (TEXT.substring(5, 6).equals("1")) {
                            state_output6_ext3 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(5, 6).equals("0")) {
                            state_output6_ext3 = separation + OUTPUT_OFF;
                        }
                        btn_output6_ext3.setText(name_output6_ext3 + state_output6_ext3);

                        if (TEXT.substring(6, 7).equals("1")) {
                            state_output7_ext3 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(6, 7).equals("0")) {
                            state_output7_ext3 = separation + OUTPUT_OFF;
                        }
                        btn_output7_ext3.setText(name_output7_ext3+ state_output7_ext3);

                        if (TEXT.substring(7, 8).equals("1")) {
                            state_output8_ext3 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(7, 8).equals("0")) {
                            state_output8_ext3 = separation + OUTPUT_OFF;
                        }
                        btn_output8_ext3.setText(name_output8_ext3 + state_output8_ext3);
                        } catch (Exception ex)  {}

                        editor.putString(APP_PREFERENCES_OUTPUT1_EXT3, state_output1_ext3);
                        editor.putString(APP_PREFERENCES_OUTPUT2_EXT3, state_output2_ext3);
                        editor.putString(APP_PREFERENCES_OUTPUT3_EXT3, state_output3_ext3);
                        editor.putString(APP_PREFERENCES_OUTPUT4_EXT3, state_output4_ext3);
                        editor.putString(APP_PREFERENCES_OUTPUT5_EXT3, state_output5_ext3);
                        editor.putString(APP_PREFERENCES_OUTPUT6_EXT3, state_output6_ext3);
                        editor.putString(APP_PREFERENCES_OUTPUT7_EXT3, state_output7_ext3);
                        editor.putString(APP_PREFERENCES_OUTPUT8_EXT3, state_output8_ext3);



                    }
                } catch (Exception ex)  {}


                //ext4
                try {
                    TEXT=SMS_EXT4_OUTPUTS;
                    ext_temp=TEXT;
                    if (message_text.indexOf(TEXT) > -1){
                        TEXT = message_text.substring(message_text.indexOf(TEXT) + TEXT.length());
                        message_text = message_text.substring(0, message_text.indexOf(ext_temp)) + "EXT4 " + getString(R.string.set_outputs) + message_text.substring(message_text.indexOf(ext_temp) + ext_temp.length(), message_text.length());
                        try {
                        if (TEXT.substring(0, 1).equals("1")) {
                            state_output1_ext4 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(0, 1).equals("0")) {
                            state_output1_ext4 = separation + OUTPUT_OFF;
                        }
                        btn_output1_ext4.setText(name_output1_ext4 + state_output1_ext4);

                        if (TEXT.substring(1, 2).equals("1")) {
                            state_output2_ext4 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(1, 2).equals("0")) {
                            state_output2_ext4 = separation + OUTPUT_OFF;
                        }
                        btn_output2_ext4.setText(name_output2_ext4 + state_output2_ext4);

                        if (TEXT.substring(2, 3).equals("1")) {
                            state_output3_ext4 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(2, 3).equals("0")) {
                            state_output3_ext4 = separation + OUTPUT_OFF;
                        }
                        btn_output3_ext4.setText(name_output3_ext4 + state_output3_ext4);

                        if (TEXT.substring(3, 4).equals("1")) {
                            state_output4_ext4 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(3, 4).equals("0")) {
                            state_output4_ext4 = separation + OUTPUT_OFF;
                        }
                        btn_output4_ext4.setText(name_output4_ext4 + state_output4_ext4);

                        if (TEXT.substring(4, 5).equals("1")) {
                            state_output5_ext4 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(4, 5).equals("0")) {
                            state_output5_ext4 = separation + OUTPUT_OFF;
                        }
                        btn_output5_ext4.setText(name_output5_ext4 + state_output5_ext4);

                        if (TEXT.substring(5, 6).equals("1")) {
                            state_output6_ext4 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(5, 6).equals("0")) {
                            state_output6_ext4 = separation + OUTPUT_OFF;
                        }
                        btn_output6_ext4.setText(name_output6_ext4 + state_output6_ext4);

                        if (TEXT.substring(6, 7).equals("1")) {
                            state_output7_ext4 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(6, 7).equals("0")) {
                            state_output7_ext4 = separation + OUTPUT_OFF;
                        }
                        btn_output7_ext4.setText(name_output7_ext4 + state_output7_ext4);

                        if (TEXT.substring(7, 8).equals("1")) {
                            state_output8_ext4 = separation + OUTPUT_ON;
                        }
                        if (TEXT.substring(7, 8).equals("0")) {
                            state_output8_ext4 = separation + OUTPUT_OFF;
                        }
                        btn_output8_ext4.setText(name_output8_ext4 + state_output8_ext4);
                        } catch (Exception ex)  {}

                        editor.putString(APP_PREFERENCES_OUTPUT1_EXT4, state_output1_ext4);
                        editor.putString(APP_PREFERENCES_OUTPUT2_EXT4, state_output2_ext4);
                        editor.putString(APP_PREFERENCES_OUTPUT3_EXT4, state_output3_ext4);
                        editor.putString(APP_PREFERENCES_OUTPUT4_EXT4, state_output4_ext4);
                        editor.putString(APP_PREFERENCES_OUTPUT5_EXT4, state_output5_ext4);
                        editor.putString(APP_PREFERENCES_OUTPUT6_EXT4, state_output6_ext4);
                        editor.putString(APP_PREFERENCES_OUTPUT7_EXT4, state_output7_ext4);
                        editor.putString(APP_PREFERENCES_OUTPUT8_EXT4, state_output8_ext4);

                    }
                } catch (Exception ex)  {}


                //radio sockets
                //blk1
                try {
                    TEXT=SMS_BLK1_SOCKETS;
                    ext_temp=TEXT;
                    if (message_text.indexOf(TEXT) > -1){
                        TEXT = message_text.substring(message_text.indexOf(TEXT) + TEXT.length());
                        message_text = message_text.substring(0, message_text.indexOf(ext_temp)) + "BLK1 " + getString(R.string.set_outputs) + message_text.substring(message_text.indexOf(ext_temp) + ext_temp.length(), message_text.length());
                        try {
                            if (TEXT.substring(0, 1).equals("1")) {
                                state_socket1_blk1 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(0, 1).equals("0")) {
                                state_socket1_blk1 = separation + OUTPUT_OFF;
                            }
                            btn_socket1_blk1.setText(name_socket1_blk1 + state_socket1_blk1);

                            if (TEXT.substring(1, 2).equals("1")) {
                                state_socket2_blk1 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(1, 2).equals("0")) {
                                state_socket2_blk1 = separation + OUTPUT_OFF;
                            }
                            btn_socket2_blk1.setText(name_socket2_blk1 + state_socket2_blk1);

                            if (TEXT.substring(2, 3).equals("1")) {
                                state_socket3_blk1 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(2, 3).equals("0")) {
                                state_socket3_blk1 = separation + OUTPUT_OFF;
                            }
                            btn_socket3_blk1.setText(name_socket3_blk1 + state_socket3_blk1);

                            if (TEXT.substring(3, 4).equals("1")) {
                                state_socket4_blk1 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(3, 4).equals("0")) {
                                state_socket4_blk1 = separation + OUTPUT_OFF;
                            }
                            btn_socket4_blk1.setText(name_socket4_blk1 + state_socket4_blk1);

                            if (TEXT.substring(4, 5).equals("1")) {
                                state_socket5_blk1 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(4, 5).equals("0")) {
                                state_socket5_blk1 = separation + OUTPUT_OFF;
                            }
                            btn_socket5_blk1.setText(name_socket5_blk1 + state_socket5_blk1);

                            if (TEXT.substring(5, 6).equals("1")) {
                                state_socket6_blk1 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(5, 6).equals("0")) {
                                state_socket6_blk1 = separation + OUTPUT_OFF;
                            }
                            btn_socket6_blk1.setText(name_socket6_blk1 + state_socket6_blk1);

                            if (TEXT.substring(6, 7).equals("1")) {
                                state_socket7_blk1 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(6, 7).equals("0")) {
                                state_socket7_blk1 = separation + OUTPUT_OFF;
                            }
                            btn_socket7_blk1.setText(name_socket7_blk1 + state_socket7_blk1);

                            if (TEXT.substring(7, 8).equals("1")) {
                                state_socket8_blk1 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(7, 8).equals("0")) {
                                state_socket8_blk1 = separation + OUTPUT_OFF;
                            }
                            btn_socket8_blk1.setText(name_socket8_blk1 + state_socket8_blk1);
                        } catch (Exception ex)  {}

                        editor.putString(APP_PREFERENCES_SOCKET1_BLK1, state_socket1_blk1);
                        editor.putString(APP_PREFERENCES_SOCKET2_BLK1, state_socket2_blk1);
                        editor.putString(APP_PREFERENCES_SOCKET3_BLK1, state_socket3_blk1);
                        editor.putString(APP_PREFERENCES_SOCKET4_BLK1, state_socket4_blk1);
                        editor.putString(APP_PREFERENCES_SOCKET5_BLK1, state_socket5_blk1);
                        editor.putString(APP_PREFERENCES_SOCKET6_BLK1, state_socket6_blk1);
                        editor.putString(APP_PREFERENCES_SOCKET7_BLK1, state_socket7_blk1);
                        editor.putString(APP_PREFERENCES_SOCKET8_BLK1, state_socket8_blk1);

                    }
                } catch (Exception ex)  {}


                //blk2
                try {
                    TEXT=SMS_BLK2_SOCKETS;
                    ext_temp=TEXT;
                    if (message_text.indexOf(TEXT) > -1){
                        TEXT = message_text.substring(message_text.indexOf(TEXT) + TEXT.length());
                        message_text = message_text.substring(0, message_text.indexOf(ext_temp)) + "BLK2 " + getString(R.string.set_outputs) + message_text.substring(message_text.indexOf(ext_temp) + ext_temp.length(), message_text.length());
                        try {
                            if (TEXT.substring(0, 1).equals("1")) {
                                state_socket1_blk2 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(0, 1).equals("0")) {
                                state_socket1_blk2 = separation + OUTPUT_OFF;
                            }
                            btn_socket1_blk2.setText(name_socket1_blk2 + state_socket1_blk2);

                            if (TEXT.substring(1, 2).equals("1")) {
                                state_socket2_blk2 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(1, 2).equals("0")) {
                                state_socket2_blk2 = separation + OUTPUT_OFF;
                            }
                            btn_socket2_blk2.setText(name_socket2_blk2 + state_socket2_blk2);

                            if (TEXT.substring(2, 3).equals("1")) {
                                state_socket3_blk2 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(2, 3).equals("0")) {
                                state_socket3_blk2 = separation + OUTPUT_OFF;
                            }
                            btn_socket3_blk2.setText(name_socket3_blk2 + state_socket3_blk2);

                            if (TEXT.substring(3, 4).equals("1")) {
                                state_socket4_blk2 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(3, 4).equals("0")) {
                                state_socket4_blk2 = separation + OUTPUT_OFF;
                            }
                            btn_socket4_blk2.setText(name_socket4_blk2 + state_socket4_blk2);

                            if (TEXT.substring(4, 5).equals("1")) {
                                state_socket5_blk2 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(4, 5).equals("0")) {
                                state_socket5_blk2 = separation + OUTPUT_OFF;
                            }
                            btn_socket5_blk2.setText(name_socket5_blk2 + state_socket5_blk2);

                            if (TEXT.substring(5, 6).equals("1")) {
                                state_socket6_blk2 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(5, 6).equals("0")) {
                                state_socket6_blk2 = separation + OUTPUT_OFF;
                            }
                            btn_socket6_blk2.setText(name_socket6_blk2 + state_socket6_blk2);

                            if (TEXT.substring(6, 7).equals("1")) {
                                state_socket7_blk2 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(6, 7).equals("0")) {
                                state_socket7_blk2 = separation + OUTPUT_OFF;
                            }
                            btn_socket7_blk2.setText(name_socket7_blk2 + state_socket7_blk2);

                            if (TEXT.substring(7, 8).equals("1")) {
                                state_socket8_blk2 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(7, 8).equals("0")) {
                                state_socket8_blk2 = separation + OUTPUT_OFF;
                            }
                            btn_socket8_blk2.setText(name_socket8_blk2 + state_socket8_blk2);
                        } catch (Exception ex)  {}

                        editor.putString(APP_PREFERENCES_SOCKET1_BLK2, state_socket1_blk2);
                        editor.putString(APP_PREFERENCES_SOCKET2_BLK2, state_socket2_blk2);
                        editor.putString(APP_PREFERENCES_SOCKET3_BLK2, state_socket3_blk2);
                        editor.putString(APP_PREFERENCES_SOCKET4_BLK2, state_socket4_blk2);
                        editor.putString(APP_PREFERENCES_SOCKET5_BLK2, state_socket5_blk2);
                        editor.putString(APP_PREFERENCES_SOCKET6_BLK2, state_socket6_blk2);
                        editor.putString(APP_PREFERENCES_SOCKET7_BLK2, state_socket7_blk2);
                        editor.putString(APP_PREFERENCES_SOCKET8_BLK2, state_socket8_blk2);

                    }
                } catch (Exception ex)  {}


                //blk3
                try {
                    TEXT=SMS_BLK3_SOCKETS;
                    ext_temp=TEXT;
                    if (message_text.indexOf(TEXT) > -1){
                        TEXT = message_text.substring(message_text.indexOf(TEXT) + TEXT.length());
                        message_text = message_text.substring(0, message_text.indexOf(ext_temp)) + "BLK3 " + getString(R.string.set_outputs) + message_text.substring(message_text.indexOf(ext_temp) + ext_temp.length(), message_text.length());
                        try {
                            if (TEXT.substring(0, 1).equals("1")) {
                                state_socket1_blk3 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(0, 1).equals("0")) {
                                state_socket1_blk3 = separation + OUTPUT_OFF;
                            }
                            btn_socket1_blk3.setText(name_socket1_blk3 + state_socket1_blk3);

                            if (TEXT.substring(1, 2).equals("1")) {
                                state_socket2_blk3 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(1, 2).equals("0")) {
                                state_socket2_blk3 = separation + OUTPUT_OFF;
                            }
                            btn_socket2_blk3.setText(name_socket2_blk3 + state_socket2_blk3);

                            if (TEXT.substring(2, 3).equals("1")) {
                                state_socket3_blk3 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(2, 3).equals("0")) {
                                state_socket3_blk3 = separation + OUTPUT_OFF;
                            }
                            btn_socket3_blk3.setText(name_socket3_blk3 + state_socket3_blk3);

                            if (TEXT.substring(3, 4).equals("1")) {
                                state_socket4_blk3 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(3, 4).equals("0")) {
                                state_socket4_blk3 = separation + OUTPUT_OFF;
                            }
                            btn_socket4_blk3.setText(name_socket4_blk3 + state_socket4_blk3);

                            if (TEXT.substring(4, 5).equals("1")) {
                                state_socket5_blk3 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(4, 5).equals("0")) {
                                state_socket5_blk3 = separation + OUTPUT_OFF;
                            }
                            btn_socket5_blk3.setText(name_socket5_blk3 + state_socket5_blk3);

                            if (TEXT.substring(5, 6).equals("1")) {
                                state_socket6_blk3 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(5, 6).equals("0")) {
                                state_socket6_blk3 = separation + OUTPUT_OFF;
                            }
                            btn_socket6_blk3.setText(name_socket6_blk3 + state_socket6_blk3);

                            if (TEXT.substring(6, 7).equals("1")) {
                                state_socket7_blk3 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(6, 7).equals("0")) {
                                state_socket7_blk3 = separation + OUTPUT_OFF;
                            }
                            btn_socket7_blk3.setText(name_socket7_blk3 + state_socket7_blk3);

                            if (TEXT.substring(7, 8).equals("1")) {
                                state_socket8_blk3 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(7, 8).equals("0")) {
                                state_socket8_blk3 = separation + OUTPUT_OFF;
                            }
                            btn_socket8_blk3.setText(name_socket8_blk3 + state_socket8_blk3);
                        } catch (Exception ex)  {}

                        editor.putString(APP_PREFERENCES_SOCKET1_BLK3, state_socket1_blk3);
                        editor.putString(APP_PREFERENCES_SOCKET2_BLK3, state_socket2_blk3);
                        editor.putString(APP_PREFERENCES_SOCKET3_BLK3, state_socket3_blk3);
                        editor.putString(APP_PREFERENCES_SOCKET4_BLK3, state_socket4_blk3);
                        editor.putString(APP_PREFERENCES_SOCKET5_BLK3, state_socket5_blk3);
                        editor.putString(APP_PREFERENCES_SOCKET6_BLK3, state_socket6_blk3);
                        editor.putString(APP_PREFERENCES_SOCKET7_BLK3, state_socket7_blk3);
                        editor.putString(APP_PREFERENCES_SOCKET8_BLK3, state_socket8_blk3);

                    }
                } catch (Exception ex)  {}


                //blk4
                try {
                    TEXT=SMS_BLK4_SOCKETS;
                    ext_temp=TEXT;
                    if (message_text.indexOf(TEXT) > -1){
                        TEXT = message_text.substring(message_text.indexOf(TEXT) + TEXT.length());
                        message_text = message_text.substring(0, message_text.indexOf(ext_temp)) + "BLK4 " + getString(R.string.set_outputs) + message_text.substring(message_text.indexOf(ext_temp) + ext_temp.length(), message_text.length());
                        try {
                            if (TEXT.substring(0, 1).equals("1")) {
                                state_socket1_blk4 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(0, 1).equals("0")) {
                                state_socket1_blk4 = separation + OUTPUT_OFF;
                            }
                            btn_socket1_blk4.setText(name_socket1_blk4 + state_socket1_blk4);

                            if (TEXT.substring(1, 2).equals("1")) {
                                state_socket2_blk4 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(1, 2).equals("0")) {
                                state_socket2_blk4 = separation + OUTPUT_OFF;
                            }
                            btn_socket2_blk4.setText(name_socket2_blk4 + state_socket2_blk4);

                            if (TEXT.substring(2, 3).equals("1")) {
                                state_socket3_blk4 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(2, 3).equals("0")) {
                                state_socket3_blk4 = separation + OUTPUT_OFF;
                            }
                            btn_socket3_blk4.setText(name_socket3_blk4 + state_socket3_blk4);

                            if (TEXT.substring(3, 4).equals("1")) {
                                state_socket4_blk4 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(3, 4).equals("0")) {
                                state_socket4_blk4 = separation + OUTPUT_OFF;
                            }
                            btn_socket4_blk4.setText(name_socket4_blk4 + state_socket4_blk4);

                            if (TEXT.substring(4, 5).equals("1")) {
                                state_socket5_blk4 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(4, 5).equals("0")) {
                                state_socket5_blk4 = separation + OUTPUT_OFF;
                            }
                            btn_socket5_blk4.setText(name_socket5_blk4 + state_socket5_blk4);

                            if (TEXT.substring(5, 6).equals("1")) {
                                state_socket6_blk4 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(5, 6).equals("0")) {
                                state_socket6_blk4 = separation + OUTPUT_OFF;
                            }
                            btn_socket6_blk4.setText(name_socket6_blk4 + state_socket6_blk4);

                            if (TEXT.substring(6, 7).equals("1")) {
                                state_socket7_blk4 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(6, 7).equals("0")) {
                                state_socket7_blk4 = separation + OUTPUT_OFF;
                            }
                            btn_socket7_blk4.setText(name_socket7_blk4 + state_socket7_blk4);

                            if (TEXT.substring(7, 8).equals("1")) {
                                state_socket8_blk4 = separation + OUTPUT_ON;
                            }
                            if (TEXT.substring(7, 8).equals("0")) {
                                state_socket8_blk4 = separation + OUTPUT_OFF;
                            }
                            btn_socket8_blk4.setText(name_socket8_blk4 + state_socket8_blk4);
                        } catch (Exception ex)  {}

                        editor.putString(APP_PREFERENCES_SOCKET1_BLK4, state_socket1_blk4);
                        editor.putString(APP_PREFERENCES_SOCKET2_BLK4, state_socket2_blk4);
                        editor.putString(APP_PREFERENCES_SOCKET3_BLK4, state_socket3_blk4);
                        editor.putString(APP_PREFERENCES_SOCKET4_BLK4, state_socket4_blk4);
                        editor.putString(APP_PREFERENCES_SOCKET5_BLK4, state_socket5_blk4);
                        editor.putString(APP_PREFERENCES_SOCKET6_BLK4, state_socket6_blk4);
                        editor.putString(APP_PREFERENCES_SOCKET7_BLK4, state_socket7_blk4);
                        editor.putString(APP_PREFERENCES_SOCKET8_BLK4, state_socket8_blk4);

                    }
                } catch (Exception ex)  {}




                //main board
                try {
                TEXT=SMS_OUTPUTS;
                    ext_temp=TEXT;
                if (message_text.indexOf(TEXT) > -1) {
                    TEXT = message_text.substring(message_text.indexOf(TEXT) + TEXT.length());
                    //TEXT = message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.indexOf(TEXT) + TEXT.length()+9);

                    message_text = message_text.substring(0, message_text.indexOf(ext_temp))  + getString(R.string.set_outputs) + message_text.substring(message_text.indexOf(ext_temp) + ext_temp.length(), message_text.length());

                    try {
                    if (TEXT.substring(0, 1).equals("1")) {
                        state_output1 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(0, 1).equals("0")) {
                        state_output1 = separation + OUTPUT_OFF;
                    }
                    btn_output1.setText(name_output1 + state_output1);

                    if (TEXT.substring(1, 2).equals("1")) {
                        state_output2 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(1, 2).equals("0")) {
                        state_output2 = separation + OUTPUT_OFF;
                    }
                    btn_output2.setText(name_output2 + state_output2);

                    if (TEXT.substring(2, 3).equals("1")) {
                        state_output3 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(2, 3).equals("0")) {
                        state_output3 = separation + OUTPUT_OFF;
                    }
                    btn_output3.setText(name_output3 + state_output3);

                    if (TEXT.substring(3, 4).equals("1")) {
                        state_output4 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(3, 4).equals("0")) {
                        state_output4 = separation + OUTPUT_OFF;
                    }
                    btn_output4.setText(name_output4 + state_output4);

                    if (TEXT.substring(4, 5).equals("1")) {
                        state_output5 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(4, 5).equals("0")) {
                        state_output5 = separation + OUTPUT_OFF;
                    }
                    btn_output5.setText(name_output5 + state_output5);

                    if (TEXT.substring(5, 6).equals("1")) {
                        state_output6 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(5, 6).equals("0")) {
                        state_output6 = separation + OUTPUT_OFF;
                    }
                    btn_output6.setText(name_output6 + state_output6);

                    if (TEXT.substring(6, 7).equals("1")) {
                        state_output7 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(6, 7).equals("0")) {
                        state_output7 = separation + OUTPUT_OFF;
                    }
                    btn_output7.setText(name_output7 + state_output7);

                    if (TEXT.substring(7, 8).equals("1")) {
                        state_output8 = separation + OUTPUT_ON;
                    }
                    if (TEXT.substring(7, 8).equals("0")) {
                        state_output8 = separation + OUTPUT_OFF;
                    }
                    btn_output8.setText(name_output8 + state_output8);
                    } catch (Exception ex)  {}

                    editor.putString(APP_PREFERENCES_OUTPUT1, state_output1);
                    editor.putString(APP_PREFERENCES_OUTPUT2, state_output2);
                    editor.putString(APP_PREFERENCES_OUTPUT3, state_output3);
                    editor.putString(APP_PREFERENCES_OUTPUT4, state_output4);
                    editor.putString(APP_PREFERENCES_OUTPUT5, state_output5);
                    editor.putString(APP_PREFERENCES_OUTPUT6, state_output6);
                    editor.putString(APP_PREFERENCES_OUTPUT7, state_output7);
                    editor.putString(APP_PREFERENCES_OUTPUT8, state_output8);


                }

                    if ((message_text.indexOf(SMS_RELE_ON) > -1) || (message_text.indexOf(SMS_RELE_1_ON) > -1) ){
                        state_output1 = separation + OUTPUT_ON;
                        editor.putString(APP_PREFERENCES_OUTPUT1, state_output1);
                    }

                    if ((message_text.indexOf(SMS_RELE_OFF) > -1) || (message_text.indexOf(SMS_RELE_1_OFF) > -1) ){
                        state_output1 = separation + OUTPUT_OFF;
                        editor.putString(APP_PREFERENCES_OUTPUT1, state_output1);
                    }

                    if (message_text.indexOf(SMS_RELE_2_ON) > -1){
                        state_output2 = separation + OUTPUT_ON;
                        editor.putString(APP_PREFERENCES_OUTPUT2, state_output2);
                    }
                    if (message_text.indexOf(SMS_RELE_2_OFF) > -1){
                        state_output2 = separation + OUTPUT_OFF;
                        editor.putString(APP_PREFERENCES_OUTPUT2, state_output2);
                    }


                } catch (Exception ex)  {}

                colour_io();

                // уровень сигнала GSM
                if ((message_text.indexOf(SMS_GSM_LEVEL_HIGH) > -1) || (message_text.indexOf(SMS_GSM_LEVEL_MEDIUN) > -1) || (message_text.indexOf(SMS_GSM_LEVEL_LOW) > -1)) {
                    String imageView_GSM = "imageView_GSM_";

                    TEXT=SMS_GSM_LEVEL_HIGH;
                    if (message_text.indexOf(TEXT) > -1) {
                        textView_gsm.setText(gsm_level + VYSOKIJ);
                        imageView_GSM = "imageView_GSM_high";
                        imageView_GSM_high.setVisibility(View.VISIBLE);
                        imageView_GSM_medium.setVisibility(View.INVISIBLE);
                        imageView_GSM_low.setVisibility(View.INVISIBLE);
                        imageView_GSM_.setVisibility(View.INVISIBLE);

                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + VYSOKIJ + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                    }

                    TEXT=SMS_GSM_LEVEL_MEDIUN;
                    if (message_text.indexOf(TEXT) > -1) {
                        textView_gsm.setText(gsm_level + SREDNIJ);
                        imageView_GSM = "imageView_GSM_medium";
                        imageView_GSM_high.setVisibility(View.INVISIBLE);
                        imageView_GSM_medium.setVisibility(View.VISIBLE);
                        imageView_GSM_low.setVisibility(View.INVISIBLE);
                        imageView_GSM_.setVisibility(View.INVISIBLE);

                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + SREDNIJ + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                    }

                    TEXT=SMS_GSM_LEVEL_LOW;
                    if (message_text.indexOf(TEXT) > -1) {
                        textView_gsm.setText(gsm_level + NIZKIJ);
                        imageView_GSM = "imageView_GSM_low";
                        imageView_GSM_high.setVisibility(View.INVISIBLE);
                        imageView_GSM_medium.setVisibility(View.INVISIBLE);
                        imageView_GSM_low.setVisibility(View.VISIBLE);
                        imageView_GSM_.setVisibility(View.INVISIBLE);

                        message_text = message_text.substring(0, message_text.indexOf(TEXT)) + NIZKIJ + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                    }

                    editor.putString(APP_PREFERENCES_IMAGE_VIEW_GSM, imageView_GSM);
                    editor.putString(APP_PREFERENCES_GSM, textView_gsm.getText().toString());
                }

                //TEXT=SMS_TEMPERATURA;
                //if (message_text.indexOf(TEXT) > -1){
                    //message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_termo1 + separation + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                    //state_termo1 = separation + DS1820_1+adress_sensor_1;
                    //textView_termo1.setText(name_termo1 + state_termo1);
                    //editor.putString(APP_PREFERENCES_TERMO1, state_termo1);
                //}


                //------------------- сохраняем данные в файл

                editor.putString(APP_PREFERENCES_QUERY, query);
                //editor.putString(APP_PREFERENCES_POWER, power);
                //editor.putString(APP_PREFERENCES_ARM, arm);
                //editor.putString(APP_PREFERENCES_GSM, gsm);




                //editor.putString(APP_PREFERENCES_IMAGE_VIEW_POWER, imageView_power);
                //editor.putString(APP_PREFERENCES_IMAGE_VIEW_ARM, imageView_arm);
                //editor.putString(APP_PREFERENCES_IMAGE_VIEW_GSM, imageView_GSM);
                editor.putString(APP_PREFERENCES_IMAGE_VIEW_INPUT, imageView_input);
                //editor.apply();
                editor.commit();


                //save event to log
                saveEvent("SMS \u2193\n" + msgDate + "\n" + message_text);

            } else {
                // --- не статусная смс

                //---- замена текста - латиница на кирилицу

                TEXT=SMS_TAMPER_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_tamper + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                //TEXT=SMS_TAMPER_NORMA;
                //if (message_text.indexOf(TEXT) > -1)
                    //message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_tamper + separation + NORMA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                //ext0
                TEXT=SMS_EXT0_ZONA1_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext0 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT0_ZONA2_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext0 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT0_ZONA3_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext0 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT0_ZONA4_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext0 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT0_ZONA5_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext0 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT0_ZONA6_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext0 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT0_ZONA7_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext0 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT0_ZONA8_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext0 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());



                //ext1
                TEXT=SMS_EXT1_ZONA1_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext1 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT1_ZONA2_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext1 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT1_ZONA3_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext1 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT1_ZONA4_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext1 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT1_ZONA5_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext1 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT1_ZONA6_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext1 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT1_ZONA7_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext1 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT1_ZONA8_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext1 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());


                //ext2
                TEXT=SMS_EXT2_ZONA1_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext2 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT2_ZONA2_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext2 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT2_ZONA3_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext2 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT2_ZONA4_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext2 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT2_ZONA5_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext2 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT2_ZONA6_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext2 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT2_ZONA7_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext2 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT2_ZONA8_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext2 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                //ext3
                TEXT=SMS_EXT3_ZONA1_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext3 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT3_ZONA2_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext3 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT3_ZONA3_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext3 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT3_ZONA4_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext3 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT3_ZONA5_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext3 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT3_ZONA6_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext3 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT3_ZONA7_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext3 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT3_ZONA8_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext3 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                //ext4
                TEXT=SMS_EXT4_ZONA1_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1_ext4 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT4_ZONA2_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2_ext4 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT4_ZONA3_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3_ext4 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT4_ZONA4_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4_ext4 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT4_ZONA5_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5_ext4 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT4_ZONA6_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6_ext4 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT4_ZONA7_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7_ext4 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_EXT4_ZONA8_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8_ext4 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());



                TEXT=SMS_ARM_ON;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + state_arm + VKL + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_ARM_OFF;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + state_arm + VYKL + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_220V_ON;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + state_220v + EST + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_220V_OFF;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + state_220v + NET + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());


                TEXT=SMS_RAZRYAD_AKKUM;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + RAZRYAD_AKKUM + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_ZONA1_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_ZONA_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_ZONA_1_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input1 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_ZONA2_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_ZONA_2_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input2 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_ZONA3_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input3 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_ZONA4_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input4 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_ZONA5_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input5 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_ZONA6_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input6 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_ZONA7_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input7 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_ZONA8_TREVOGA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_input8 + separation + TREVOGA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());


                TEXT=SMS_RADIO1;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO2;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO3;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO4;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO5;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio5 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO6;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio6 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO7;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio7 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO8;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio8 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO9;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio9 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO10;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio10 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO11;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio11 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO12;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio12 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO13;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio13 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO14;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio14 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO15;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio15 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_RADIO16;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_radio16 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_TERMO1;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_termo1 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_TERMO2;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_termo2 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_TERMO3;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_termo3 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_TERMO4;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_termo4 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_TERMO5;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_termo5 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_TERMO6;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_termo6 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_TERMO7;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_termo7 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());
                TEXT=SMS_TERMO8;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + name_termo8 + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());



                TEXT=SMS_PANIKA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + PANIKA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_VSKRYTIE_DATCHIKA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + VSKRYTIE_DATCHIKA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());


                TEXT=SMS_RAZRIAD_BATTAREYKI;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + RAZRIAD_BATTAREYKI + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_NET_TESTOVOGO_SIGNALA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + NET_TESTOVOGO_SIGNALA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_VOSSTANOVLENIE;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + VOSSTANOVLENIE + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_NARUSHENIE;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + NARUSHENIE + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_TEMPERATURA;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + TEMPERATURA + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_T_MIN;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + T_MIN + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());

                TEXT=SMS_T_MAX;
                if (message_text.indexOf(TEXT) > -1)
                    message_text = message_text.substring(0, message_text.indexOf(TEXT)) + T_MAX + message_text.substring(message_text.indexOf(TEXT) + TEXT.length(), message_text.length());



                //save event to log
                saveEvent("SMS \u2193\n" + msgDate + "\n" + message_text);

                //-------------вывод сообщения

                AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                builder.setTitle(getString(R.string.sms_from_device) + object_name) //"SMS сообщение от OKO-PRO!")
                        .setMessage(getString(R.string.time) + msgDate + "\n" + message_text)
                        .setIcon(R.drawable.ic_launcher)
                        .setCancelable(false)
                        .setNegativeButton("ОК",
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        dialog.cancel();
                                    }
                                }
                        );
                AlertDialog alert = builder.create();
                alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); //TYPE_SYSTEM_ALERT  TYPE_TOAST
                alert.show();
            }


        }
        //---------------------------------
        } catch (Exception ex)  {}
    }


    //---try sends a SMS message ---
    private void try_sendSMS(String command) {

        String phoneNumber = PHONE_NUMBER;
        String password = PASSWORD;
        try {
        if (phoneNumber.length() > 0 && password.length() > 0)
        {
            sendSMS(phoneNumber, password + command);
        }   else {

            if (phoneNumber.length() == 0 && password.length() > 0)
                Toast.makeText(getBaseContext(),
                        Enter_Phone,
                        Toast.LENGTH_SHORT).show();
            else if (phoneNumber.length() > 0 && password.length() == 0)
                Toast.makeText(getBaseContext(),
                        Enter_Password,
                        Toast.LENGTH_SHORT).show();
            else

                Toast.makeText(getBaseContext(),
                        Enter_Phone_Password,
                        Toast.LENGTH_SHORT).show();

            // вызываем окно ввода настроек
            Intent intent = new Intent(mContext, SettingsApp.class); //SettingsActivity
            intent.putExtra(StartActivity.OBJECT_SETTING, object_setting);
            startActivity(intent);
        }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }


    //---sends a SMS message ---
    private void sendSMS(String phoneNumber, String message) {

        try {
        //----------------- таймер-сообщение
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setTitle(getString(R.string.do_command)) //"Выполнение команды")
                .setIcon(R.drawable.ic_launcher)
                .setMessage(getString(R.string.wait)) //"Подождите пожалуйста...")
                .setCancelable(false);

        final AlertDialog dlg = builder.create();

        dlg.show();

        final Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            public void run() {
                dlg.dismiss(); // when the task active then close the dialog
                timer.cancel(); // also just top the timer thread, otherwise,
                // you may receive a crash report
            }
        }, 3000); // через 3 секунд (3000 миллисекунд), the task will be active.
        //------------------------------------------



        String SENT = "COMMAND_SENT";
        String DELIVERED = "COMMAND_DELIVERED";

        PendingIntent sentPI = PendingIntent.getBroadcast(this, 0,
                new Intent(SENT), 0);

        PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
                new Intent(DELIVERED), 0);


        //---when the SMS has been sent---
        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context arg0, Intent arg1) {
                switch (getResultCode()) {
                    case Activity.RESULT_OK:
                        Toast.makeText(getBaseContext(), getString(R.string.command_sent), //"Команда отправлена",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                        Toast.makeText(getBaseContext(), "Generic failure",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_NO_SERVICE:
                        Toast.makeText(getBaseContext(), "No service",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_NULL_PDU:
                        Toast.makeText(getBaseContext(), "Null PDU",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_RADIO_OFF:
                        Toast.makeText(getBaseContext(), "Radio off",
                                Toast.LENGTH_SHORT).show();
                        break;
                }
            }
        }, new IntentFilter(SENT));


        //---when the SMS has been delivered---
        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context arg0, Intent arg1) {
                switch (getResultCode()) {
                    case Activity.RESULT_OK:
                        Toast.makeText(getBaseContext(), getString(R.string.command_delivered) , //"Команда доставлена",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case Activity.RESULT_CANCELED:
                        Toast.makeText(getBaseContext(), getString(R.string.command_not_delivered), //"Команда не доставлена",
                                Toast.LENGTH_SHORT).show();
                        break;
                }
            }
        }, new IntentFilter(DELIVERED));


        SmsManager sms = SmsManager.getDefault();
        sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        /*
        if (id == R.id.menu_otziv) {
            Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
                    "https://play.google.com/store/apps/details?id=" + getPackageName()));
            startActivity(marketIntent);
            return true;
        }

        if (id == R.id.menu_monitor_oko) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(server_url)));
            return true;
        }


        if (id == R.id.menu_about) {
            Intent intent = new Intent(MainActivity.this, AboutActivity.class);
            startActivity(intent);
            return true;
        }
        */

        if (id == R.id.menu_settings) {
            Intent intent = new Intent(mContext, SettingsApp.class); //SettingsActivity
            intent.putExtra(StartActivity.OBJECT_SETTING, object_setting);
            startActivity(intent);

            //getFragmentManager().beginTransaction()
                    //.replace(android.R.id.content, new SettingsApp()).commit();

            return true;
        }



        return super.onOptionsItemSelected(item);


    }

    /*********************************************************************************
     *
     *          FOR IP CLIENT
     *
     ********************************************************************************/
/*
    public static final Handler Parser = new Handler(){
        @Override
        public void handleMessage(Message msg)
        {
            //myTextView.setText("arg1 = " + msg.arg1 + "; arg2 = " + msg.arg2 + "; " + (String)msg.obj);
            if(msg.what == 1)
            {
                String data=(String)msg.obj;

                //Log.d(TAG, data);
                if (data.startsWith("{"))
                {
                    DoParsing(data);

                }

            }

        }
    };
*/
    //---try sends a Command throw internet
    private void try_send_to_server(String command, boolean close_socket) {

        if (IMEI.length() > 0 && PASSWORD.length() > 0)
        {
            //ClientThread.send_to_server(command);

            try {
                Intent intent1 = new Intent(ClientThread.CLIENT_BROADCAST_RECIEVE_COMMAND);
                intent1.putExtra("command", command);
                intent1.putExtra("imei", IMEI);
                intent1.putExtra("password", PASSWORD);
                if (close_socket) intent1.putExtra("close_socket", true);
                //intent1.putExtra(PARAM_DATA, CONNECT_NO);
                //MyService.mContext.sendBroadcast(intent1);
                LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent1);
            } catch (Exception e) {
                e.printStackTrace();
            }

        }   else {

            if (IMEI.length() == 0 && PASSWORD.length() > 0)
                Toast.makeText(getBaseContext(),
                        Enter_IMEI,
                        Toast.LENGTH_SHORT).show();
            else if (IMEI.length() > 0 && PASSWORD.length() == 0)
                Toast.makeText(getBaseContext(),
                        Enter_Password,
                        Toast.LENGTH_SHORT).show();
            else
                Toast.makeText(getBaseContext(),
                        Enter_IMEI_Password,
                        Toast.LENGTH_SHORT).show();

            // вызываем окно ввода настроек
            Intent intent = new Intent(mContext, SettingsApp.class); //SettingsActivity
            intent.putExtra(StartActivity.OBJECT_SETTING, object_setting);
            startActivity(intent);
        }


    }


    public int hex2decimal(String s) {
        String digits = "0123456789ABCDEF";
        s = s.toUpperCase();
        int val = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            int d = digits.indexOf(c);
            val = 16*val + d;
        }
        return val;
    }

    public  String hexToBin(String s) {
        return new BigInteger(s, 16).toString(2);
    }

    public String Bin_8bits(String state)
    {
        try {
            if (state.length()==1) {state="0000000".concat(state);}
            if (state.length()==2) {state="000000".concat(state);}
            if (state.length()==3) {state="00000".concat(state);}
            if (state.length()==4) {state="0000".concat(state);}
            if (state.length()==5) {state="000".concat(state);}
            if (state.length()==6) {state="00".concat(state);}
            if (state.length()==7) {state="0".concat(state);}
        }catch (Exception ex) {}
        return state;
    }

    private String Calc_T(int t)
    {
        String result="";
        try
        {
            if (t==128)
                result= "";
            else
            {
                if (t>125)
                    {t=(256-t); result="-"+String.valueOf(t) + "C";}
                else
                    result="+"+String.valueOf(t)+"C"; //Integer.toString(t);
            }
        }catch (Exception ex) {}

        return result;
    }

    private String Calc_RF_T(String input, int event_type, boolean row_data_alarm)
    {

        String result="";
        try
        {
            if (input.equals("0000")) return result; //no sensor

            if ( input.substring(2, 4).equals("ED") || input.substring(2, 4).equals("B5")  ) {
                if (event_type==1) return PANIKA; else return result; //alarm button event
            }
            else if (input.substring(3, 4).equals("A") || input.substring(3, 4).equals("E")) {
                    result = Calc_T(hex2decimal(input.substring(0, 2)));
            }else{

                //brelok exept PANIKA
                if (input.substring(3, 4).equals("D"))
                {
                    if (input.substring(2, 3).equals("B")) return ARM;
                    if (input.substring(2, 3).equals("7")) return DISARM;
                    if (input.substring(2, 3).equals("D")) return HOME;
                    return "";
                }

                String state=input.substring(2, 4);
                String tamper="", alarm="", battery="";
                //convert state from HEX to Binary
                try {
                    state=hexToBin(state);
                    state=Bin_8bits(state);
                    tamper=state.substring(0,1);
                    alarm=state.substring(1,2);
                    battery=state.substring(2,3);

                }catch (Exception ex) {}

                //analize alarm flag
                if (input.substring(3, 4).equals("1")){
                    //gerkon
                    if (alarm.equals("1")) result=NORMA; else result=TREVOGA;
                }
                else {
                    if ((alarm.equals("0") && event_type==2) || row_data_alarm) result=TREVOGA; else result=NORMA;
                }

                //analaize tamper flag
                if (tamper.equals("0")) {if (result.equals(NORMA)) result =VSKRYTIE_DATCHIKA; else result +=", "+VSKRYTIE_DATCHIKA;}

                //analaize battery flag
                if (battery.equals("0")) {if (result.equals(NORMA)) result=RAZRIAD_BATTAREYKI; else result +=", "+RAZRIAD_BATTAREYKI;}
            }


        }catch (Exception ex) {}

        return result;
    }

    private String Calc_Adress_Sensor (String value)
    {
        String result="";
        String config="";
        //0000A8A2 - 1-st BYTE from MSB: 3 bits - sensor type, 2 bits -metric, 2 bits - devision, 1 bit - sign
        //          2-nd, 3-th, 4-th - sensor value
        try {
            if (value.length()>7) {
                config = hexToBin(value.substring(0, 2));
                config = Bin_8bits(config);
                //state.substring(0,1);
                //state.substring(1,2);
                //state.substring(2,3);
                //state.substring(3,4);
                //state.substring(4,5);
                //state.substring(5,6);
                //state.substring(6,7);
                int devision=100;
                String metric="кг";
                String round="%.2f";
                if (config.substring(0,3).equals("000")) {
                    //WEIGHT SENSOR
                    if (config.substring(3,5).equals("00")) metric="кг";
                    if (config.substring(3,5).equals("01")) metric="ц";
                    if (config.substring(3,5).equals("10")) metric="т";
                    if (config.substring(3,5).equals("11")) metric="г";
                    if (config.substring(5,7).equals("00")) {devision=100; round="%.2f";}
                    if (config.substring(5,7).equals("01")) {devision=10; round="%.1f";}
                    if (config.substring(5,7).equals("10")) {devision=1; round="%.0f";}
                    if (config.substring(5,7).equals("11")) {devision=1000; round="%.3f";}
                    result = String.format(Locale.ENGLISH, round, (double) (hex2decimal(value.substring(2, 8))) / devision);
                    if (config.substring(7, 8).equals("1")) result = "-" + result;
                    result = " вес " + result + metric;
                }
            }
        }catch (Exception ex) {}
        return result;
    }

    private void DoSystem (String data){
        try {
            if (!"".equals(data)) {
                Play_Message();
                //-------------- System date
                StringBuilder msgDate = new StringBuilder("");
                Format formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
                msgDate.append(formatter.format(new Date()));

                //save event to log
                saveEvent("SYSTEM\n" + msgDate + "\n" + data); //↓↓


                //-------------вывод сообщения
                AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                builder.setTitle( object_name + "!") //"Cообщение от " HW getString(R.string.msg_from_device)
                        .setMessage(getString(R.string.time) + msgDate + "\n" + data)
                        .setIcon(R.drawable.ic_launcher)
                        .setCancelable(false)
                        .setNegativeButton("ОК",
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        dialog.cancel();
                                    }
                                }
                        );
                AlertDialog alert = builder.create();
                alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); //TYPE_SYSTEM_ALERT TYPE_TOAST
                alert.show();
            }
        } catch (Exception ex) {

        }
    }

    private void DoParsing(String request)
    {
        //int max_num_sensors=50; //максимальное количество сенсоров прибора

        try {
            /*
            * OKO-S2
             * {13227009840343,01,02,01F0,18,3.0.0,OKO-S2}
             * {866104020810332,F9,0B,05C8,1F,3.0.3,OKO-S2}
             * {866104020810332,FF,0F,0785,00,3.0.5,OKO-S2,31,,04,,}
             * Termo&Humidity {866104020810332,F9,0B,05C8,1F,3.0.3,OKO-S2,12.4,56.8}
             *
             *
            OKO-PRO
            {863591021960863,00F9,1647,2F202000,000A,17,1B80808080808080,0000CCF10000000019DA1AED0000B99B00000000000000000000000000000000,072C06D50000000000000FFA0FFA0DEC0FFE0FFE0FFE0FFE0FFE0FFE0FFE0FFE,1.3.2,OKO_PRO,15grn,0001976,,,,,,,000007,0000257B,,,,,,,,RF,0102037D25251303,80000000,80000001,80000003,80000005,880410000000,00000800,}
            {862631037827861,0227,02FF,230F0000,0106,14,8080808080808080,0000000000000000000000000000000000000000000000000000000000000000,0000023B0000000000000FFF0FFF0E290FFF0FFF0FFF0FFF0004000500020001,2.2.9,OKO-U2,,,,,,,,,,,,,,,,,,,,80005500,,,80005500,}
            {862631032969528,003F,0200,230F0000,0000,18,8080808080808080,0000000000000000000000000000000000000000000000000000000000000000,025902590000000000000FFF0FFF0DD90342033F034303430003000300040004,7.2.8,OKO-7S,,,,,,000007,,,,00000256,,,,,,,,RF,150A217D80801301,}
            {862631032969528,00F9,0200,230F0000,0000,15,0880808080808080,0000000000000000000000000000000000000000000000000000000000000000,025702570000000000000FFF0FFF0DDC033E033C033E033E0002000400040006,7.2.8,OKO-7S,,,,,,,,,000007,0000A8A2,,,,,,,,}
             */
            /* {863591021960863,00F9,5600,2F202000,0000,12,1A80808080808080,0000CCF10000000080CA1A7D0000B9DB00000000000000000000000000000000,072B06DE0000000000000FFB0FF90DEB0FFE0FFE0FFE0FFE0FFE0FFE0FFE0FFE,1.2.3,OKO-PRO,,,,,,,,,000007,}
             * {13227009840343,01,02,01F0,18,3.0.0,OKO-S2}
             * {866104020810332,F9,0B,05C8,1F,3.0.3,OKO-S2}
             * Termo7Humidity {866104020810332,F9,0B,05C8,1F,3.0.3,OKO-S2,12.4,56.8}
             *
             * {13227009840343,0036,0200,0F00,00B9,18,1918181819181818,CCF189FB000055FB18FA55FBA6FB000000000000000018EAEFABF1FB18EAF0BB,07690717000000000012001200120000,1.0.9,OKO-PRO}
             *OKO-U2
             *{863591021960863,00FF,0200,2F101000,0000,00,8080808080808080,0000000000000000000000000000000000000000000000000000000000000000,072D06E00000000000000FFB0FA40ABE0FFE0FFE0FFE0FFE0FFE0FFE0FFE0FFE,2.2.1_,OKO-U2,,}
             * {863591021960863,00FF,0200,2F101000,0000,00,8080808080808080,0000000000000000000000000000000000000000000000000000000000000000,072D06E00000000000000FFB0FA40ABE0FFE0FFE0FFE0FFE0FFE0FFE0FFE0FFE,2.2.1_,OKO-PRO,,}
             *
             * OKO-S2
             * {13227009840343,01,02,01F0,18,3.0.0,OKO-S2}
             * {866104020810332,F9,0B,05C8,1F,3.0.3,OKO-S2}
             * {866104020810332,FF,0F,0785,00,3.0.5,OKO-S2,31,,04,,}
             * Termo&Humidity {866104020810332,F9,0B,05C8,1F,3.0.3,OKO-S2,12.4,56.8}
             * */



            String[] requestParts = request.split(","); //data packet

            int num_fields=requestParts.length;

            int OKO_PRO_PROTOCOL=1;
            int OKO_S2_PROTOCOL=2;
            int OKO_NAVI_PROTOCOL=3;
            int oko_protocol=0;

            //***************************************************************************
            //проверка протокола ТСР от прибора OKO-PRO
            boolean imei_ok=false;
            try {
                imei_ok=requestParts[0].substring(1).equals(IMEI);
            } catch (Exception ex) {}

            //check if OKO-PRO protocol
            if (num_fields>=11) {
                try {
                    if (
                            (requestParts[10].substring(0, 6).equals("OKO-PR")) ||
                                    (requestParts[10].substring(0, 6).equals("OKO-U2")) ||
                                    (requestParts[10].substring(0, 6).equals("OKO-7S")) ||
                                    (requestParts[10].substring(0, 6).equals("OKO-BL"))
                            ) {
                        oko_protocol = OKO_PRO_PROTOCOL;
                    }
                } catch (Exception ex) {

                }
            }

            //check if OKO-S2 protocol
            if (num_fields>6) {
                try {
                    if (requestParts[6].substring(0, 6).equals("OKO-S2")) {
                        oko_protocol = OKO_S2_PROTOCOL;
                    }
                } catch (Exception ex) {

                }
            }


            if (imei_ok)
            {
                if (oko_protocol>0)
                {

                    //mainlayout.setVisibility(View.GONE);
                    //btn_restart_connection.setBackgroundColor(COLOR_GREEN);
                    btn_restart_connection.setBackgroundResource(R.drawable.btn_green);
                    //-------------- System date
                    StringBuilder msgDate = new StringBuilder("");
                    Format formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
                    msgDate.append(formatter.format(new Date()));



                    //IMEI
                    String device_code=requestParts[0].substring(1);

                    int event_code=200;


                    String est220="";
                    String lowbat="";
                    String tamper="";
                    String low_li_ion="";
                    String ohrana="";
                    String groups="";
                    String w_z1="";
                    String w_z2="";
                    String w_z3="";
                    String w_z4="";
                    String w_z5="";
                    String w_z6="";
                    String w_z7="";
                    String w_z8="";

                    String out1="";
                    String out2="";
                    String out3="";
                    String out4="";
                    String out5="";
                    String out6="";
                    String out7="";
                    String out8="";

                    int GSM=0;
                    int GSM_rssi=0;
                    String DS1820_1="";
                    String DS1820_2="";
                    String DS1820_3="";
                    String DS1820_4="";
                    String DS1820_5="";
                    String DS1820_6="";
                    String DS1820_7="";
                    String DS1820_8="";

                    String row_data_type="", row_data="";
                    Boolean row_data_alarm_1=false,row_data_alarm_2=false,row_data_alarm_3=false,row_data_alarm_4=false,row_data_alarm_5=false,row_data_alarm_6=false,row_data_alarm_7=false,row_data_alarm_8=false,row_data_alarm_9=false,row_data_alarm_10=false,row_data_alarm_11=false,row_data_alarm_12=false,row_data_alarm_13=false,row_data_alarm_14=false,row_data_alarm_15=false,row_data_alarm_16=false;
                    int event_type=0;

                    String rf_t_1="";
                    String rf_t_2="";
                    String rf_t_3="";
                    String rf_t_4="";
                    String rf_t_5="";
                    String rf_t_6="";
                    String rf_t_7="";
                    String rf_t_8="";
                    String rf_t_9="";
                    String rf_t_10="";
                    String rf_t_11="";
                    String rf_t_12="";
                    String rf_t_13="";
                    String rf_t_14="";
                    String rf_t_15="";
                    String rf_t_16="";

                    Double opora = 3.28;
                    String max_adc = "0FFF";
                    String power="";
                    String acc="";
                    String adc1="";
                    String adc2="";
                    String adc3="";
                    String ch0="";
                    String ch2="";
                    String ch3="";

                    //версия ПО
                    String version="";
                    //версия HW
                    String HW="";
                    //balanse
                    String balance="";
                    //counters
                    String counter_1="",counter_2="",counter_3="",counter_4="",counter_5="",counter_6="",counter_7="",counter_8="";
                    //adress sensors
                    String adress_sensor_1="",adress_sensor_2="",adress_sensor_3="",adress_sensor_4="",adress_sensor_5="",adress_sensor_6="",adress_sensor_7="",adress_sensor_8="";
                    //extension board
                    String row_socket="", row_board0="", row_board1="", row_board2="", row_board3="", row_board4="";
                    String in_ext0[]={"","","","","","","",""};
                    String in_ext1[]={"","","","","","","",""};
                    String in_ext2[]={"","","","","","","",""};
                    String in_ext3[]={"","","","","","","",""};
                    String in_ext4[]={"","","","","","","",""};
                    String out_ext0[]={"","","","","","","",""};
                    String out_ext1[]={"","","","","","","",""};
                    String out_ext2[]={"","","","","","","",""};
                    String out_ext3[]={"","","","","","","",""};
                    String out_ext4[]={"","","","","","","",""};

                    String socket_blk1[]={"","","","","","","",""};
                    String socket_blk2[]={"","","","","","","",""};
                    String socket_blk3[]={"","","","","","","",""};
                    String socket_blk4[]={"","","","","","","",""};


                    if (oko_protocol==OKO_S2_PROTOCOL){
                        //event
                        try {
                            event_code=300+hex2decimal(requestParts[1]);
                            //Integer outputDecimal = Integer.parseInt(requestParts[12], 16); // actual conversion of hex to decimal
                        } catch (Exception ex) {}

                        //состояние входов, выходов, охраны, 220
                        String state_input=requestParts[2];

                        //convert state from HEX to Binary
                        try {
                            state_input=hexToBin(state_input);
                            state_input=Bin_8bits(state_input);


                            ohrana=state_input.substring(1,2);
                            out2=state_input.substring(2,3);
                            out1=state_input.substring(3,4);
                            lowbat=state_input.substring(4,5);
                            est220=state_input.substring(5,6);
                            w_z2=state_input.substring(6,7);
                            w_z1=state_input.substring(7,8);
                        }catch (Exception ex) {}

                        // аналоговые показатели
                        power=String.format(Locale.ENGLISH,"%.1f",opora*10*(double)(hex2decimal(requestParts[3]))/(double)(hex2decimal(max_adc)));

                        //gsm
                        GSM_rssi=hex2decimal(requestParts[4]);

                        if (GSM_rssi>17)
                            GSM=3;
                        else
                        {
                            if (GSM_rssi>9) GSM=2; else {if (GSM_rssi>0) GSM=1; else GSM=0;}
                        }

                        //версия ПО
                        version=requestParts[5];

                        //версия HW
                        if (num_fields==7)
                            HW=requestParts[6].substring(0, requestParts[6].length()-1);
                        else
                            HW=requestParts[6];

                        //температура
                        String temperature="";
                        if (num_fields>7) temperature=requestParts[7];

                        //влажность
                        String humidity="";
                        if (num_fields>8)
                        {
                            if (num_fields==9)
                                humidity=requestParts[8].substring(0, requestParts[8].length()-1);
                            else
                                humidity=requestParts[8];
                        }

                        if (!temperature.equals("")) {

                            if (!temperature.substring(0,1).equals("-"))
                                temperature ="+".concat(temperature);
                            else
                                temperature ="".concat(temperature);
                            temperature = temperature.concat("C");
                            DS1820_1=temperature;
                        }

                        if (!humidity.equals("")) {
                            DS1820_1=temperature.concat(", H= ").concat(humidity).concat("%");
                            DS1820_1 = "T= " + DS1820_1;
                        }

                    }

                    if (oko_protocol==OKO_PRO_PROTOCOL) {

                        //event
                        String event=requestParts[1];
                        try {
                            event_code=300+hex2decimal(event);
                            //Integer outputDecimal = Integer.parseInt(requestParts[12], 16); // actual conversion of hex to decimal
                        } catch (Exception ex) {}

                        //состояние охраны
                        String group = requestParts[2].substring(2, 4);
                        if (hex2decimal(group) != 0) {
                            ohrana = "1";
                            //convert state from HEX to Binary
                            try {
                                group = hexToBin(group);
                                group = Bin_8bits(group);
                                if (group.substring(7, 8).equals("1")) groups = groups.concat("1,");
                                if (group.substring(6, 7).equals("1")) groups = groups.concat("2,");
                                if (group.substring(5, 6).equals("1")) groups = groups.concat("3,");
                                if (group.substring(4, 5).equals("1")) groups = groups.concat("4,");
                                if (group.substring(3, 4).equals("1")) groups = groups.concat("5,");
                                if (group.substring(2, 3).equals("1")) groups = groups.concat("6,");
                                if (group.substring(1, 2).equals("1")) groups = groups.concat("7,");
                                if (group.substring(0, 1).equals("1")) groups = groups.concat("8");
                            } catch (Exception ex) {
                            }

                        } else ohrana = "0";

                        //состояние входов
                        String state_input = requestParts[3].substring(2, 4);

                        //convert state from HEX to Binary
                        try {
                            state_input = hexToBin(state_input);
                            state_input = Bin_8bits(state_input);
                            w_z8 = state_input.substring(0, 1);
                            w_z7 = state_input.substring(1, 2);
                            w_z6 = state_input.substring(2, 3);
                            w_z5 = state_input.substring(3, 4);
                            w_z4 = state_input.substring(4, 5);
                            w_z3 = state_input.substring(5, 6);
                            w_z2 = state_input.substring(6, 7);
                            w_z1 = state_input.substring(7, 8);
                        } catch (Exception ex) {
                        }

                        try {
                            if (requestParts[3].length() == 8) {
                                //if KZ
                                state_input = requestParts[3].substring(6, 8);
                                state_input = hexToBin(state_input);
                                state_input = Bin_8bits(state_input);
                                if (state_input.substring(0, 1).equals("1")) w_z8 = "2";
                                if (state_input.substring(1, 2).equals("1")) w_z7 = "2";
                                if (state_input.substring(2, 3).equals("1")) w_z6 = "2";
                                if (state_input.substring(3, 4).equals("1")) w_z5 = "2";
                                if (state_input.substring(4, 5).equals("1")) w_z4 = "2";
                                if (state_input.substring(5, 6).equals("1")) w_z3 = "2";
                                if (state_input.substring(6, 7).equals("1")) w_z2 = "2";
                                if (state_input.substring(7, 8).equals("1")) w_z1 = "2";

                                //if OBRIV
                                state_input = requestParts[3].substring(4, 6);
                                state_input = hexToBin(state_input);
                                state_input = Bin_8bits(state_input);
                                if (state_input.substring(0, 1).equals("1")) w_z8 = "3";
                                if (state_input.substring(1, 2).equals("1")) w_z7 = "3";
                                if (state_input.substring(2, 3).equals("1")) w_z6 = "3";
                                if (state_input.substring(3, 4).equals("1")) w_z5 = "3";
                                if (state_input.substring(4, 5).equals("1")) w_z4 = "3";
                                if (state_input.substring(5, 6).equals("1")) w_z3 = "3";
                                if (state_input.substring(6, 7).equals("1")) w_z2 = "3";
                                if (state_input.substring(7, 8).equals("1")) w_z1 = "3";
                            }
                        } catch (Exception ex) {
                        }

                        //состояние 220, АКБ, тампер, литий-ион
                        String state = requestParts[3].substring(0, 2);

                        //convert state from HEX to Binary
                        try {
                            state = hexToBin(state);
                            state = Bin_8bits(state);
                            est220 = state.substring(5, 6);
                            lowbat = state.substring(4, 5);
                            tamper = state.substring(3, 4);
                            low_li_ion = state.substring(2, 3);
                        } catch (Exception ex) {
                        }

                        //состояние выходов
                        state = requestParts[4].substring(2, 4);

                        //convert state from HEX to Binary
                        try {
                            state = hexToBin(state);
                            state = Bin_8bits(state);
                            out8 = state.substring(0, 1);
                            out7 = state.substring(1, 2);
                            out6 = state.substring(2, 3);
                            out5 = state.substring(3, 4);
                            out4 = state.substring(4, 5);
                            out3 = state.substring(5, 6);
                            out2 = state.substring(6, 7);
                            out1 = state.substring(7, 8);
                        } catch (Exception ex) {
                        }


                        GSM_rssi = hex2decimal(requestParts[5]);

                        if (GSM_rssi > 17)
                            GSM = 3;
                        else {
                            if (GSM_rssi > 9) GSM = 2;
                            else {
                                if (GSM_rssi > 0) GSM = 1;
                                else GSM = 0;
                            }
                        }

                        //температура адресных датчиков
                        DS1820_1 = Calc_T(hex2decimal(requestParts[6].substring(0, 2)));
                        DS1820_2 = Calc_T(hex2decimal(requestParts[6].substring(2, 4)));
                        DS1820_3 = Calc_T(hex2decimal(requestParts[6].substring(4, 6)));
                        DS1820_4 = Calc_T(hex2decimal(requestParts[6].substring(6, 8)));
                        DS1820_5 = Calc_T(hex2decimal(requestParts[6].substring(8, 10)));
                        DS1820_6 = Calc_T(hex2decimal(requestParts[6].substring(10, 12)));
                        DS1820_7 = Calc_T(hex2decimal(requestParts[6].substring(12, 14)));
                        DS1820_8 = Calc_T(hex2decimal(requestParts[6].substring(14, 16)));


                        inputs_ok = true;

                        //row data
                        if (num_fields > 30) {
                            try {
                                row_data_type = requestParts[28];
                                row_data = requestParts[29];
                                if (row_data_type.equals("RF") && row_data.length() >= 16) {
                                    //RF,150A217D80801301
                                    if (
                                            row_data.substring(14, 16).equals("01") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_1 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("02") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_2 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("03") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_3 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("04") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_4 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("05") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_5 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("06") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_6 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("07") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_7 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("08") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_8 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("09") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_9 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("0A") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_10 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("0B") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_11 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("0C") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_12 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("0D") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_13 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("0E") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_14 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("0F") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_15 = true;
                                    }
                                    if (
                                            row_data.substring(14, 16).equals("10") &&  //sensor position
                                                    Bin_8bits(hexToBin(row_data.substring(6, 8))).substring(1, 2).equals("0") &&//alarm position
                                                    !row_data.substring(7, 8).equals("D") &&
                                                    !row_data.substring(6, 8).equals("B5")
                                            ) {
                                        row_data_alarm_16 = true;
                                    }
                                }

                            } catch (Exception ex) {
                            }

                        }


                        //события безпроводных датчиков
                        event_type = 0;
                        if (event_code == (364 + 0 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 0 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_1 = Calc_RF_T(requestParts[7].substring(0, 4), event_type, row_data_alarm_1);

                        event_type = 0;
                        if (event_code == (364 + 1 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 1 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_2 = Calc_RF_T(requestParts[7].substring(4, 8), event_type, row_data_alarm_2);

                        event_type = 0;
                        if (event_code == (364 + 2 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 2 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_3 = Calc_RF_T(requestParts[7].substring(8, 12), event_type, row_data_alarm_3);

                        event_type = 0;
                        if (event_code == (364 + 3 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 3 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_4 = Calc_RF_T(requestParts[7].substring(12, 16), event_type, row_data_alarm_4);

                        event_type = 0;
                        if (event_code == (364 + 4 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 4 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_5 = Calc_RF_T(requestParts[7].substring(16, 20), event_type, row_data_alarm_5);

                        event_type = 0;
                        if (event_code == (364 + 5 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 5 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_6 = Calc_RF_T(requestParts[7].substring(20, 24), event_type, row_data_alarm_6);

                        event_type = 0;
                        if (event_code == (364 + 6 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 6 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_7 = Calc_RF_T(requestParts[7].substring(24, 28), event_type, row_data_alarm_7);

                        event_type = 0;
                        if (event_code == (364 + 7 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 7 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_8 = Calc_RF_T(requestParts[7].substring(28, 32), event_type, row_data_alarm_8);

                        event_type = 0;
                        if (event_code == (364 + 8 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 8 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_9 = Calc_RF_T(requestParts[7].substring(32, 36), event_type, row_data_alarm_9);

                        event_type = 0;
                        if (event_code == (364 + 9 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 9 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_10 = Calc_RF_T(requestParts[7].substring(36, 40), event_type, row_data_alarm_10);

                        event_type = 0;
                        if (event_code == (364 + 10 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 10 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_11 = Calc_RF_T(requestParts[7].substring(40, 44), event_type, row_data_alarm_11);

                        event_type = 0;
                        if (event_code == (364 + 11 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 11 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_12 = Calc_RF_T(requestParts[7].substring(44, 48), event_type, row_data_alarm_12);

                        event_type = 0;
                        if (event_code == (364 + 12 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 12 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_13 = Calc_RF_T(requestParts[7].substring(48, 52), event_type, row_data_alarm_13);

                        event_type = 0;
                        if (event_code == (364 + 13 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 13 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_14 = Calc_RF_T(requestParts[7].substring(52, 56), event_type, row_data_alarm_14);

                        event_type = 0;
                        if (event_code == (364 + 14 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 14 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_15 = Calc_RF_T(requestParts[7].substring(56, 60), event_type, row_data_alarm_15);

                        event_type = 0;
                        if (event_code == (364 + 15 * 6)) {
                            event_type = 2;
                        } //alarm
                        if (event_code == (364 + 15 * 6 + 5)) {
                            event_type = 1;
                        } //button
                        rf_t_16 = Calc_RF_T(requestParts[7].substring(60, 64), event_type, row_data_alarm_16);

                        // аналоговые показатели

                        power = String.format(Locale.ENGLISH, "%.1f", opora * 10 * (double) (hex2decimal(requestParts[8].substring(0, 4))) / (double) (hex2decimal(max_adc)));
                        acc = String.format(Locale.ENGLISH, "%.1f", opora * 10 * (double) (hex2decimal(requestParts[8].substring(4, 8))) / (double) (hex2decimal(max_adc)));
                        adc1 = String.format(Locale.ENGLISH, "%.1f", opora * 10 * (double) (hex2decimal(requestParts[8].substring(8, 12))) / (double) (hex2decimal(max_adc)));
                        adc2 = String.format(Locale.ENGLISH, "%.1f", opora * 10 * (double) (hex2decimal(requestParts[8].substring(12, 16))) / (double) (hex2decimal(max_adc)));
                        adc3 = String.format(Locale.ENGLISH, "%.1f", opora * 10 * (double) (hex2decimal(requestParts[8].substring(16, 20))) / (double) (hex2decimal(max_adc)));
                        ch0 = String.format(Locale.ENGLISH, "%.1f", opora * 10 * (double) (hex2decimal(requestParts[8].substring(20, 24))) / (double) (hex2decimal(max_adc)));
                        ch2 = String.format(Locale.ENGLISH, "%.1f", opora * 10 * (double) (hex2decimal(requestParts[8].substring(24, 28))) / (double) (hex2decimal(max_adc)));
                        ch3 = String.format(Locale.ENGLISH, "%.1f", opora * 10 * (double) (hex2decimal(requestParts[8].substring(28, 32))) / (double) (hex2decimal(max_adc)));

                        //версия ПО
                        version = requestParts[9];

                        //версия HW
                        if (num_fields == 11)
                            HW = requestParts[10].substring(0, requestParts[10].length() - 1);
                        else
                            HW = requestParts[10];

                        //баланс
                        balance = "";
                        if (num_fields > 11) balance = requestParts[11];

                        //counters
                        if (num_fields > 20) {
                            counter_1 = requestParts[12];
                            counter_2 = requestParts[13];
                            counter_3 = requestParts[14];
                            counter_4 = requestParts[15];
                            counter_5 = requestParts[16];
                            counter_6 = requestParts[17];
                            counter_7 = requestParts[18];
                            counter_8 = requestParts[19];
                        }

                        //adress sensors
                        if (num_fields > 28) {
                            try {
                                adress_sensor_1 = Calc_Adress_Sensor(requestParts[20]);
                                adress_sensor_2 = Calc_Adress_Sensor(requestParts[21]);
                                adress_sensor_3 = Calc_Adress_Sensor(requestParts[22]);
                                adress_sensor_4 = Calc_Adress_Sensor(requestParts[23]);
                                adress_sensor_5 = Calc_Adress_Sensor(requestParts[24]);
                                adress_sensor_6 = Calc_Adress_Sensor(requestParts[25]);
                                adress_sensor_7 = Calc_Adress_Sensor(requestParts[26]);
                                adress_sensor_8 = Calc_Adress_Sensor(requestParts[27]);
                            } catch (Exception ex) {
                            }
                        }

                        //row data
                        //String row_data_type="", row_data="";
                        //if (num_fields>30){
                        //try {
                        //row_data_type=requestParts[28];
                        //row_data=requestParts[29];


                        //}catch (Exception ex) {}

                        //}

                        //extension board
                        if (num_fields > 36) {
                            try {
                                //00000800
                                row_socket = requestParts[35];

                                if (row_socket.length() >= 8) {
                                    try {

                                        //blk1
                                        state = hexToBin(row_socket.substring(0, 2));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 8; i++) {
                                            socket_blk1[i] = state.substring(7 - i, 8 - i);
                                        }

                                        //blk2
                                        state = hexToBin(row_socket.substring(2, 4));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 8; i++) {
                                            socket_blk2[i] = state.substring(7 - i, 8 - i);
                                        }

                                        //blk3
                                        state = hexToBin(row_socket.substring(4, 6));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 8; i++) {
                                            socket_blk3[i] = state.substring(7 - i, 8 - i);
                                        }

                                        //blk4
                                        state = hexToBin(row_socket.substring(6, 8));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 8; i++) {
                                            socket_blk4[i] = state.substring(7 - i, 8 - i);
                                        }

                                    } catch (Exception ex) {
                                    }
                                }

                            } catch (Exception ex) {
                            }
                        }


                        if (num_fields > 35) {
                            try {
                                //800055000000
                                row_board0 = requestParts[34];
                                //ext0
                                if (row_board0.length() >= 8) {
                                    try {

                                        //outputs state
                                        state = hexToBin(row_board0.substring(6, 8));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 8; i++) {
                                            out_ext0[i] = state.substring(7 - i, 8 - i);
                                        }

                                        //input1..4 state
                                        state = hexToBin(row_board0.substring(4, 6));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 4; i++) {
                                            if (state.substring(6 - i * 2, 8 - i * 2).equals("00"))
                                                in_ext0[i] = "0";
                                            if (state.substring(6 - i * 2, 8 - i * 2).equals("01"))
                                                in_ext0[i] = "1";
                                            if (state.substring(6 - i * 2, 8 - i * 2).equals("10"))
                                                in_ext0[i] = "2";
                                            if (state.substring(6 - i * 2, 8 - i * 2).equals("11"))
                                                in_ext0[i] = "3";
                                        }

                                        //input5..8 state
                                        state = hexToBin(row_board0.substring(2, 4));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 4; i++) {
                                            if (state.substring(6 - i * 2, 8 - i * 2).equals("00"))
                                                in_ext0[i + 4] = "0";
                                            if (state.substring(6 - i * 2, 8 - i * 2).equals("01"))
                                                in_ext0[i + 4] = "1";
                                            if (state.substring(6 - i * 2, 8 - i * 2).equals("10"))
                                                in_ext0[i + 4] = "2";
                                            if (state.substring(6 - i * 2, 8 - i * 2).equals("11"))
                                                in_ext0[i + 4] = "3";
                                        }

                                    } catch (Exception ex) {
                                    }
                                }

                            } catch (Exception ex) {
                            }
                        }

                        if (num_fields > 34) {
                            try {
                                //80005500
                                row_board1 = requestParts[30];
                                row_board2 = requestParts[31];
                                row_board3 = requestParts[32];
                                row_board4 = requestParts[33];

                                //ext1
                                if (row_board1.length() >= 8) {
                                    try {
                                        state = hexToBin(row_board1.substring(0, 2));
                                        state = Bin_8bits(state);
                                        String board_type = state.substring(6, 8);
                                        String input_2_zone = state.substring(2, 6);

                                        //outputs state
                                        state = hexToBin(row_board1.substring(6, 8));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 8; i++) {
                                            if ((board_type.equals("00") && (i < 4)) || board_type.equals("01")) {
                                                out_ext1[i] = state.substring(7 - i, 8 - i);
                                            }
                                        }

                                        //input1..4 state
                                        state = hexToBin(row_board1.substring(4, 6));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 4; i++) {
                                            if (board_type.equals("00") || board_type.equals("10")) {
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("00"))
                                                    in_ext1[i] = "0";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("01"))
                                                    in_ext1[i] = "1";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("10"))
                                                    in_ext1[i] = "2";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("11"))
                                                    in_ext1[i] = "3";
                                            }
                                        }

                                        //input5..8 state
                                        state = hexToBin(row_board1.substring(2, 4));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 4; i++) {
                                            if ((board_type.equals("00") && input_2_zone.substring(3 - i, 4 - i).equals("1")) || board_type.equals("10")) {
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("00"))
                                                    in_ext1[i + 4] = "0";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("01"))
                                                    in_ext1[i + 4] = "1";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("10"))
                                                    in_ext1[i + 4] = "2";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("11"))
                                                    in_ext1[i + 4] = "3";
                                            }
                                        }

                                    } catch (Exception ex) {
                                    }
                                }

                                //ext2
                                if (row_board2.length() >= 8) {
                                    try {
                                        state = hexToBin(row_board2.substring(0, 2));
                                        state = Bin_8bits(state);
                                        String board_type = state.substring(6, 8);
                                        String input_2_zone = state.substring(2, 6);

                                        //outputs state
                                        state = hexToBin(row_board2.substring(6, 8));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 8; i++) {
                                            if ((board_type.equals("00") && (i < 4)) || board_type.equals("01")) {
                                                out_ext2[i] = state.substring(7 - i, 8 - i);
                                            }
                                        }

                                        //input1..4 state
                                        state = hexToBin(row_board2.substring(4, 6));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 4; i++) {
                                            if (board_type.equals("00") || board_type.equals("10")) {
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("00"))
                                                    in_ext2[i] = "0";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("01"))
                                                    in_ext2[i] = "1";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("10"))
                                                    in_ext2[i] = "2";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("11"))
                                                    in_ext2[i] = "3";
                                            }
                                        }

                                        //input5..8 state
                                        state = hexToBin(row_board2.substring(2, 4));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 4; i++) {
                                            if ((board_type.equals("00") && input_2_zone.substring(3 - i, 4 - i).equals("1")) || board_type.equals("10")) {
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("00"))
                                                    in_ext2[i + 4] = "0";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("01"))
                                                    in_ext2[i + 4] = "1";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("10"))
                                                    in_ext2[i + 4] = "2";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("11"))
                                                    in_ext2[i + 4] = "3";
                                            }
                                        }

                                    } catch (Exception ex) {
                                    }
                                }

                                //ext3
                                if (row_board3.length() >= 8) {
                                    try {
                                        state = hexToBin(row_board3.substring(0, 2));
                                        state = Bin_8bits(state);
                                        String board_type = state.substring(6, 8);
                                        String input_2_zone = state.substring(2, 6);

                                        //outputs state
                                        state = hexToBin(row_board3.substring(6, 8));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 8; i++) {
                                            if ((board_type.equals("00") && (i < 4)) || board_type.equals("01")) {
                                                out_ext3[i] = state.substring(7 - i, 8 - i);
                                            }
                                        }

                                        //input1..4 state
                                        state = hexToBin(row_board3.substring(4, 6));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 4; i++) {
                                            if (board_type.equals("00") || board_type.equals("10")) {
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("00"))
                                                    in_ext3[i] = "0";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("01"))
                                                    in_ext3[i] = "1";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("10"))
                                                    in_ext3[i] = "2";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("11"))
                                                    in_ext3[i] = "3";
                                            }
                                        }

                                        //input5..8 state
                                        state = hexToBin(row_board3.substring(2, 4));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 4; i++) {
                                            if ((board_type.equals("00") && input_2_zone.substring(3 - i, 4 - i).equals("1")) || board_type.equals("10")) {
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("00"))
                                                    in_ext3[i + 4] = "0";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("01"))
                                                    in_ext3[i + 4] = "1";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("10"))
                                                    in_ext3[i + 4] = "2";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("11"))
                                                    in_ext3[i + 4] = "3";
                                            }
                                        }

                                    } catch (Exception ex) {
                                    }
                                }

                                //ext4
                                if (row_board4.length() >= 8) {
                                    try {
                                        state = hexToBin(row_board4.substring(0, 2));
                                        state = Bin_8bits(state);
                                        String board_type = state.substring(6, 8);
                                        String input_2_zone = state.substring(2, 6);

                                        //outputs state
                                        state = hexToBin(row_board4.substring(6, 8));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 8; i++) {
                                            if ((board_type.equals("00") && (i < 4)) || board_type.equals("01")) {
                                                out_ext4[i] = state.substring(7 - i, 8 - i);
                                            }
                                        }

                                        //input1..4 state
                                        state = hexToBin(row_board4.substring(4, 6));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 4; i++) {
                                            if (board_type.equals("00") || board_type.equals("10")) {
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("00"))
                                                    in_ext4[i] = "0";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("01"))
                                                    in_ext4[i] = "1";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("10"))
                                                    in_ext4[i] = "2";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("11"))
                                                    in_ext4[i] = "3";
                                            }
                                        }

                                        //input5..8 state
                                        state = hexToBin(row_board4.substring(2, 4));
                                        state = Bin_8bits(state);
                                        for (int i = 0; i < 4; i++) {
                                            if ((board_type.equals("00") && input_2_zone.substring(3 - i, 4 - i).equals("1")) || board_type.equals("10")) {
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("00"))
                                                    in_ext4[i + 4] = "0";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("01"))
                                                    in_ext4[i + 4] = "1";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("10"))
                                                    in_ext4[i + 4] = "2";
                                                if (state.substring(6 - i * 2, 8 - i * 2).equals("11"))
                                                    in_ext4[i + 4] = "3";
                                            }
                                        }

                                    } catch (Exception ex) {
                                    }
                                }


                            } catch (Exception ex) {
                            }
                        }

                    }

                    //отображаем значения на элементах интерфейса
                    btn_query.setText(update_time + msgDate);
                    String imageView_power = "imageView_power_";
                    textView_power.setText(state_220v);
                    imageView_power_on.setVisibility(View.INVISIBLE);
                    imageView_power_off.setVisibility(View.INVISIBLE);
                    imageView_power_.setVisibility(View.VISIBLE);

                    if (est220.equals("1")) {
                        imageView_power = "imageView_power_on";
                        textView_power.setText(state_220v + EST);
                        imageView_power_on.setVisibility(View.VISIBLE);
                        imageView_power_off.setVisibility(View.INVISIBLE);
                        imageView_power_.setVisibility(View.INVISIBLE);
                    }

                    if (est220.equals("0")) {
                        textView_power.setText(state_220v + NET);
                        imageView_power = "imageView_power_off";
                        imageView_power_off.setVisibility(View.VISIBLE);
                        imageView_power_on.setVisibility(View.INVISIBLE);
                        imageView_power_.setVisibility(View.INVISIBLE);
                    }

                    String imageView_arm = "imageView_arm_";
                    imageView_arm_on.setVisibility(View.INVISIBLE);
                    imageView_arm_off.setVisibility(View.INVISIBLE);
                    imageView_arm_.setVisibility(View.VISIBLE);

                    btn_arm.setText(state_arm );

                    if (ohrana.equals("1")) {
                        if ( groups.equals("1,2,3,4,5,6,7,8") || (oko_protocol!=OKO_PRO_PROTOCOL) ) {
                            btn_arm.setText(state_arm + VKL);
                        }
                        else
                        {
                            btn_arm.setText(state_arm + VKL + System.getProperty("line.separator") + GROUP + groups);
                        }

                        imageView_arm = "imageView_arm_on";
                        imageView_arm_on.setVisibility(View.VISIBLE);
                        imageView_arm_off.setVisibility(View.INVISIBLE);
                        imageView_arm_.setVisibility(View.INVISIBLE);

                    }

                    if (ohrana.equals("0"))  {
                        btn_arm.setText(state_arm + VYKL);
                        imageView_arm = "imageView_arm_off";
                        imageView_arm_off.setVisibility(View.VISIBLE);
                        imageView_arm_on.setVisibility(View.INVISIBLE);
                        imageView_arm_.setVisibility(View.INVISIBLE);

                    }

                    String imageView_GSM = "imageView_GSM_";
                    imageView_GSM_high.setVisibility(View.INVISIBLE);
                    imageView_GSM_medium.setVisibility(View.INVISIBLE);
                    imageView_GSM_low.setVisibility(View.INVISIBLE);
                    imageView_GSM_.setVisibility(View.VISIBLE);

                    textView_gsm.setText(gsm_level);
                    if (GSM==3) {
                        textView_gsm.setText(gsm_level + VYSOKIJ);
                        imageView_GSM = "imageView_GSM_high";
                        imageView_GSM_high.setVisibility(View.VISIBLE);
                        imageView_GSM_medium.setVisibility(View.INVISIBLE);
                        imageView_GSM_low.setVisibility(View.INVISIBLE);
                        imageView_GSM_.setVisibility(View.INVISIBLE);
                    }

                    if (GSM==2) {
                        textView_gsm.setText(gsm_level + SREDNIJ);
                        imageView_GSM = "imageView_GSM_medium";
                        imageView_GSM_high.setVisibility(View.INVISIBLE);
                        imageView_GSM_medium.setVisibility(View.VISIBLE);
                        imageView_GSM_low.setVisibility(View.INVISIBLE);
                        imageView_GSM_.setVisibility(View.INVISIBLE);
                    }

                    if (GSM==1) {
                        textView_gsm.setText(gsm_level + NIZKIJ);
                        imageView_GSM = "imageView_GSM_low";
                        imageView_GSM_high.setVisibility(View.INVISIBLE);
                        imageView_GSM_medium.setVisibility(View.INVISIBLE);
                        imageView_GSM_low.setVisibility(View.VISIBLE);
                        imageView_GSM_.setVisibility(View.INVISIBLE);
                    }


                    if (lowbat.equals("0") || low_li_ion.equals("0")) {
                        textView_power.setText(textView_power.getText() + ", " + RAZRYAD_AKKUM);

                    }


                    // inputs
                    String imageView_input = "imageView_termo_";


                    //String temp="1";
                    state_tamper = separation;
                    if (tamper.equals("1"))
                    {
                        state_tamper = separation + NORMA;
                    }

                    if (tamper.equals("0"))
                    {
                        state_tamper = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_TAMPER, false)) inputs_ok=false;
                    }
                    textView_tamper.setText(name_tamper + state_tamper);

                    state_input1 = separation;
                    if (w_z1.equals("0"))
                    {
                        state_input1 = separation + NORMA;
                    }

                    if (w_z1.equals("1"))
                    {
                        state_input1 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1, true)) inputs_ok=false;
                    }

                    if (w_z1.equals("2"))
                    {
                        state_input1 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1, true)) inputs_ok=false;
                    }

                    if (w_z1.equals("3"))
                    {
                        state_input1 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1, true)) inputs_ok=false;
                    }
                    if (!"".equals(counter_1)) state_input1 += ", "+counter_1;
                    textView_input1.setText(name_input1 + state_input1);

                    state_input2 = separation;
                    if (w_z2.equals("0"))
                    {
                        state_input2 = separation + NORMA;
                    }

                    if (w_z2.equals("1"))
                    {
                        state_input2 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2, true)) inputs_ok=false;
                    }
                    if (w_z2.equals("2"))
                    {
                        state_input2 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2, true)) inputs_ok=false;
                    }

                    if (w_z2.equals("3"))
                    {
                        state_input2 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2, true)) inputs_ok=false;
                    }
                    if (!"".equals(counter_2)) state_input2 += ", "+counter_2;
                    textView_input2.setText(name_input2 + state_input2);

                    state_input3 = separation;
                    if (w_z3.equals("0"))
                    {
                        state_input3 = separation + NORMA;
                    }

                    if (w_z3.equals("1"))
                    {
                        state_input3 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3, true)) inputs_ok=false;
                    }
                    if (w_z3.equals("2"))
                    {
                        state_input3 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3, true)) inputs_ok=false;
                    }

                    if (w_z3.equals("3"))
                    {
                        state_input3 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3, true)) inputs_ok=false;
                    }
                    if (!"".equals(counter_3)) state_input3 += ", "+counter_3;
                    textView_input3.setText(name_input3 + state_input3);

                    state_input4 = separation;
                    if (w_z4.equals("0"))
                    {
                        state_input4 = separation + NORMA;
                    }

                    if (w_z4.equals("1"))
                    {
                        state_input4 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4, true)) inputs_ok=false;
                    }
                    if (w_z4.equals("2"))
                    {
                        state_input4 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4, true)) inputs_ok=false;
                    }

                    if (w_z4.equals("3"))
                    {
                        state_input4 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4, true)) inputs_ok=false;
                    }
                    if (!"".equals(counter_4)) state_input4 += ", "+counter_4;
                    textView_input4.setText(name_input4 + state_input4);

                    state_input5 = separation;
                    if (w_z5.equals("0"))
                    {
                        state_input5 = separation + NORMA;
                    }

                    if (w_z5.equals("1"))
                    {
                        state_input5 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5, true)) inputs_ok=false;
                    }
                    if (w_z5.equals("2"))
                    {
                        state_input5 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5, true)) inputs_ok=false;
                    }

                    if (w_z5.equals("3"))
                    {
                        state_input5 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5, true)) inputs_ok=false;
                    }

                    if (!"".equals(counter_5)) state_input5 += ", "+counter_5;
                    textView_input5.setText(name_input5 + state_input5);


                    state_input6 = separation;
                    if (w_z6.equals("0"))
                    {
                        state_input6 = separation + NORMA;
                    }

                    if (w_z6.equals("1"))
                    {
                        state_input6 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6, true)) inputs_ok=false;
                    }
                    if (w_z6.equals("2"))
                    {
                        state_input6 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6, true)) inputs_ok=false;
                    }

                    if (w_z6.equals("3"))
                    {
                        state_input6 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6, true)) inputs_ok=false;
                    }
                    if (!"".equals(counter_6)) state_input6 += ", "+counter_6;
                    textView_input6.setText(name_input6 + state_input6);

                    state_input7 = separation;
                    if (w_z7.equals("0"))
                    {
                        state_input7 = separation + NORMA;
                    }

                    if (w_z7.equals("1"))
                    {
                        state_input7 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7, true)) inputs_ok=false;
                    }
                    if (w_z7.equals("2"))
                    {
                        state_input7 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7, true)) inputs_ok=false;
                    }

                    if (w_z7.equals("3"))
                    {
                        state_input7 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7, true)) inputs_ok=false;
                    }

                    if (!"".equals(counter_7)) state_input7 += ", "+counter_7;
                    textView_input7.setText(name_input7 + state_input7);


                    state_input8 = separation;
                    if (w_z8.equals("0"))
                    {
                        state_input8 = separation + NORMA;
                    }

                    if (w_z8.equals("1"))
                    {
                        state_input8 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8, true)) inputs_ok=false;
                    }
                    if (w_z8.equals("2"))
                    {
                        state_input8 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8, true)) inputs_ok=false;
                    }

                    if (w_z8.equals("3"))
                    {
                        state_input8 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8, true)) inputs_ok=false;
                    }
                    if (!"".equals(counter_8)) state_input8 += ", "+counter_8;
                    textView_input8.setText(name_input8 + state_input8);


                    //ext0
                    state_input1_ext0 = separation;
                    if (in_ext0[0].equals("0"))
                    {
                        state_input1_ext0 = separation + NORMA;
                    }
                    if (in_ext0[0].equals("1"))
                    {
                        state_input1_ext0 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[0].equals("2"))
                    {
                        state_input1_ext0 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[0].equals("3"))
                    {
                        state_input1_ext0 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT0, false)) inputs_ok=false;
                    }
                    textView_input1_ext0.setText(name_input1_ext0 + state_input1_ext0);

                    state_input2_ext0 = separation;
                    if (in_ext0[1].equals("0"))
                    {
                        state_input2_ext0 = separation + NORMA;
                    }
                    if (in_ext0[1].equals("1"))
                    {
                        state_input2_ext0 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[1].equals("2"))
                    {
                        state_input2_ext0 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[1].equals("3"))
                    {
                        state_input2_ext0 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT0, false)) inputs_ok=false;
                    }
                    textView_input2_ext0.setText(name_input2_ext0 + state_input2_ext0);

                    state_input3_ext0 = separation;
                    if (in_ext0[2].equals("0"))
                    {
                        state_input3_ext0 = separation + NORMA;
                    }
                    if (in_ext0[2].equals("1"))
                    {
                        state_input3_ext0 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[2].equals("2"))
                    {
                        state_input3_ext0 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[2].equals("3"))
                    {
                        state_input3_ext0 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT0, false)) inputs_ok=false;
                    }
                    textView_input3_ext0.setText(name_input3_ext0 + state_input3_ext0);

                    state_input4_ext0 = separation;
                    if (in_ext0[3].equals("0"))
                    {
                        state_input4_ext0 = separation + NORMA;
                    }
                    if (in_ext0[3].equals("1"))
                    {
                        state_input4_ext0 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[3].equals("2"))
                    {
                        state_input4_ext0 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[3].equals("3"))
                    {
                        state_input4_ext0 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT0, false)) inputs_ok=false;
                    }
                    textView_input4_ext0.setText(name_input4_ext0 + state_input4_ext0);

                    state_input5_ext0 = separation;
                    if (in_ext0[4].equals("0"))
                    {
                        state_input5_ext0 = separation + NORMA;
                    }
                    if (in_ext0[4].equals("1"))
                    {
                        state_input5_ext0 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[4].equals("2"))
                    {
                        state_input5_ext0 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[4].equals("3"))
                    {
                        state_input5_ext0 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT0, false)) inputs_ok=false;
                    }
                    textView_input5_ext0.setText(name_input5_ext0 + state_input5_ext0);

                    state_input6_ext0 = separation;
                    if (in_ext0[5].equals("0"))
                    {
                        state_input6_ext0 = separation + NORMA;
                    }
                    if (in_ext0[5].equals("1"))
                    {
                        state_input6_ext0 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[5].equals("2"))
                    {
                        state_input6_ext0 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[5].equals("3"))
                    {
                        state_input6_ext0 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT0, false)) inputs_ok=false;
                    }
                    textView_input6_ext0.setText(name_input6_ext0 + state_input6_ext0);

                    state_input7_ext0 = separation;
                    if (in_ext0[6].equals("0"))
                    {
                        state_input7_ext0 = separation + NORMA;
                    }
                    if (in_ext0[6].equals("1"))
                    {
                        state_input7_ext0 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[6].equals("2"))
                    {
                        state_input7_ext0 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[6].equals("3"))
                    {
                        state_input7_ext0 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT0, false)) inputs_ok=false;
                    }
                    textView_input7_ext0.setText(name_input7_ext0 + state_input7_ext0);

                    state_input8_ext0 = separation;
                    if (in_ext0[7].equals("0"))
                    {
                        state_input8_ext0 = separation + NORMA;
                    }
                    if (in_ext0[7].equals("1"))
                    {
                        state_input8_ext0 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[7].equals("2"))
                    {
                        state_input8_ext0 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT0, false)) inputs_ok=false;
                    }
                    if (in_ext0[7].equals("3"))
                    {
                        state_input8_ext0 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT0, false)) inputs_ok=false;
                    }
                    textView_input8_ext0.setText(name_input8_ext0 + state_input8_ext0);



                    //ext1
                    state_input1_ext1 = separation;
                    if (in_ext1[0].equals("0"))
                    {
                        state_input1_ext1 = separation + NORMA;
                    }
                    if (in_ext1[0].equals("1"))
                    {
                        state_input1_ext1 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[0].equals("2"))
                    {
                        state_input1_ext1 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[0].equals("3"))
                    {
                        state_input1_ext1 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT1, false)) inputs_ok=false;
                    }
                    textView_input1_ext1.setText(name_input1_ext1 + state_input1_ext1);

                    state_input2_ext1 = separation;
                    if (in_ext1[1].equals("0"))
                    {
                        state_input2_ext1 = separation + NORMA;
                    }
                    if (in_ext1[1].equals("1"))
                    {
                        state_input2_ext1 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[1].equals("2"))
                    {
                        state_input2_ext1 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[1].equals("3"))
                    {
                        state_input2_ext1 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT1, false)) inputs_ok=false;
                    }
                    textView_input2_ext1.setText(name_input2_ext1 + state_input2_ext1);

                    state_input3_ext1 = separation;
                    if (in_ext1[2].equals("0"))
                    {
                        state_input3_ext1 = separation + NORMA;
                    }
                    if (in_ext1[2].equals("1"))
                    {
                        state_input3_ext1 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[2].equals("2"))
                    {
                        state_input3_ext1 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[2].equals("3"))
                    {
                        state_input3_ext1 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT1, false)) inputs_ok=false;
                    }
                    textView_input3_ext1.setText(name_input3_ext1 + state_input3_ext1);

                    state_input4_ext1 = separation;
                    if (in_ext1[3].equals("0"))
                    {
                        state_input4_ext1 = separation + NORMA;
                    }
                    if (in_ext1[3].equals("1"))
                    {
                        state_input4_ext1 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[3].equals("2"))
                    {
                        state_input4_ext1 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[3].equals("3"))
                    {
                        state_input4_ext1 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT1, false)) inputs_ok=false;
                    }
                    textView_input4_ext1.setText(name_input4_ext1 + state_input4_ext1);

                    state_input5_ext1 = separation;
                    if (in_ext1[4].equals("0"))
                    {
                        state_input5_ext1 = separation + NORMA;
                    }
                    if (in_ext1[4].equals("1"))
                    {
                        state_input5_ext1 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[4].equals("2"))
                    {
                        state_input5_ext1 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[4].equals("3"))
                    {
                        state_input5_ext1 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT1, false)) inputs_ok=false;
                    }
                    textView_input5_ext1.setText(name_input5_ext1 + state_input5_ext1);

                    state_input6_ext1 = separation;
                    if (in_ext1[5].equals("0"))
                    {
                        state_input6_ext1 = separation + NORMA;
                    }
                    if (in_ext1[5].equals("1"))
                    {
                        state_input6_ext1 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[5].equals("2"))
                    {
                        state_input6_ext1 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[5].equals("3"))
                    {
                        state_input6_ext1 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT1, false)) inputs_ok=false;
                    }
                    textView_input6_ext1.setText(name_input6_ext1 + state_input6_ext1);

                    state_input7_ext1 = separation;
                    if (in_ext1[6].equals("0"))
                    {
                        state_input7_ext1 = separation + NORMA;
                    }
                    if (in_ext1[6].equals("1"))
                    {
                        state_input7_ext1 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[6].equals("2"))
                    {
                        state_input7_ext1 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[6].equals("3"))
                    {
                        state_input7_ext1 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT1, false)) inputs_ok=false;
                    }
                    textView_input7_ext1.setText(name_input7_ext1 + state_input7_ext1);

                    state_input8_ext1 = separation;
                    if (in_ext1[7].equals("0"))
                    {
                        state_input8_ext1 = separation + NORMA;
                    }
                    if (in_ext1[7].equals("1"))
                    {
                        state_input8_ext1 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[7].equals("2"))
                    {
                        state_input8_ext1 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT1, false)) inputs_ok=false;
                    }
                    if (in_ext1[7].equals("3"))
                    {
                        state_input8_ext1 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT1, false)) inputs_ok=false;
                    }
                    textView_input8_ext1.setText(name_input8_ext1 + state_input8_ext1);


                    //ext2
                    state_input1_ext2 = separation;
                    if (in_ext2[0].equals("0"))
                    {
                        state_input1_ext2 = separation + NORMA;
                    }
                    if (in_ext2[0].equals("1"))
                    {
                        state_input1_ext2 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[0].equals("2"))
                    {
                        state_input1_ext2 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[0].equals("3"))
                    {
                        state_input1_ext2 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT2, false)) inputs_ok=false;
                    }
                    textView_input1_ext2.setText(name_input1_ext2 + state_input1_ext2);

                    state_input2_ext2 = separation;
                    if (in_ext2[1].equals("0"))
                    {
                        state_input2_ext2 = separation + NORMA;
                    }
                    if (in_ext2[1].equals("1"))
                    {
                        state_input2_ext2 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[1].equals("2"))
                    {
                        state_input2_ext2 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[1].equals("3"))
                    {
                        state_input2_ext2 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT2, false)) inputs_ok=false;
                    }
                    textView_input2_ext2.setText(name_input2_ext2 + state_input2_ext2);

                    state_input3_ext2 = separation;
                    if (in_ext2[2].equals("0"))
                    {
                        state_input3_ext2 = separation + NORMA;
                    }
                    if (in_ext2[2].equals("1"))
                    {
                        state_input3_ext2 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[2].equals("2"))
                    {
                        state_input3_ext2 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[2].equals("3"))
                    {
                        state_input3_ext2 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT2, false)) inputs_ok=false;
                    }
                    textView_input3_ext2.setText(name_input3_ext2 + state_input3_ext2);

                    state_input4_ext2 = separation;
                    if (in_ext2[3].equals("0"))
                    {
                        state_input4_ext2 = separation + NORMA;
                    }
                    if (in_ext2[3].equals("1"))
                    {
                        state_input4_ext2 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[3].equals("2"))
                    {
                        state_input4_ext2 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[3].equals("3"))
                    {
                        state_input4_ext2 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT2, false)) inputs_ok=false;
                    }
                    textView_input4_ext2.setText(name_input4_ext2 + state_input4_ext2);

                    state_input5_ext2 = separation;
                    if (in_ext2[4].equals("0"))
                    {
                        state_input5_ext2 = separation + NORMA;
                    }
                    if (in_ext2[4].equals("1"))
                    {
                        state_input5_ext2 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[4].equals("2"))
                    {
                        state_input5_ext2 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[4].equals("3"))
                    {
                        state_input5_ext2 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT2, false)) inputs_ok=false;
                    }
                    textView_input5_ext2.setText(name_input5_ext2 + state_input5_ext2);

                    state_input6_ext2 = separation;
                    if (in_ext2[5].equals("0"))
                    {
                        state_input6_ext2 = separation + NORMA;
                    }
                    if (in_ext2[5].equals("1"))
                    {
                        state_input6_ext2 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[5].equals("2"))
                    {
                        state_input6_ext2 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[5].equals("3"))
                    {
                        state_input6_ext2 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT2, false)) inputs_ok=false;
                    }
                    textView_input6_ext2.setText(name_input6_ext2 + state_input6_ext2);

                    state_input7_ext2 = separation;
                    if (in_ext2[6].equals("0"))
                    {
                        state_input7_ext2 = separation + NORMA;
                    }
                    if (in_ext2[6].equals("1"))
                    {
                        state_input7_ext2 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[6].equals("2"))
                    {
                        state_input7_ext2 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[6].equals("3"))
                    {
                        state_input7_ext2 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT2, false)) inputs_ok=false;
                    }
                    textView_input7_ext2.setText(name_input7_ext2 + state_input7_ext2);

                    state_input8_ext2 = separation;
                    if (in_ext2[7].equals("0"))
                    {
                        state_input8_ext2 = separation + NORMA;
                    }
                    if (in_ext2[7].equals("1"))
                    {
                        state_input8_ext2 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[7].equals("2"))
                    {
                        state_input8_ext2 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT2, false)) inputs_ok=false;
                    }
                    if (in_ext2[7].equals("3"))
                    {
                        state_input8_ext2 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT2, false)) inputs_ok=false;
                    }
                    textView_input8_ext2.setText(name_input8_ext2 + state_input8_ext2);

                    //ext3
                    state_input1_ext3 = separation;
                    if (in_ext3[0].equals("0"))
                    {
                        state_input1_ext3 = separation + NORMA;
                    }
                    if (in_ext3[0].equals("1"))
                    {
                        state_input1_ext3 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[0].equals("2"))
                    {
                        state_input1_ext3 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[0].equals("3"))
                    {
                        state_input1_ext3 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT3, false)) inputs_ok=false;
                    }
                    textView_input1_ext3.setText(name_input1_ext3 + state_input1_ext3);

                    state_input2_ext3 = separation;
                    if (in_ext3[1].equals("0"))
                    {
                        state_input2_ext3 = separation + NORMA;
                    }
                    if (in_ext3[1].equals("1"))
                    {
                        state_input2_ext3 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[1].equals("2"))
                    {
                        state_input2_ext3 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[1].equals("3"))
                    {
                        state_input2_ext3 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT3, false)) inputs_ok=false;
                    }
                    textView_input2_ext3.setText(name_input2_ext3 + state_input2_ext3);

                    state_input3_ext3 = separation;
                    if (in_ext3[2].equals("0"))
                    {
                        state_input3_ext3 = separation + NORMA;
                    }
                    if (in_ext3[2].equals("1"))
                    {
                        state_input3_ext3 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[2].equals("2"))
                    {
                        state_input3_ext3 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[2].equals("3"))
                    {
                        state_input3_ext3 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT3, false)) inputs_ok=false;
                    }
                    textView_input3_ext3.setText(name_input3_ext3 + state_input3_ext3);

                    state_input4_ext3 = separation;
                    if (in_ext3[3].equals("0"))
                    {
                        state_input4_ext3 = separation + NORMA;
                    }
                    if (in_ext3[3].equals("1"))
                    {
                        state_input4_ext3 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[3].equals("2"))
                    {
                        state_input4_ext3 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[3].equals("3"))
                    {
                        state_input4_ext3 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT3, false)) inputs_ok=false;
                    }
                    textView_input4_ext3.setText(name_input4_ext3 + state_input4_ext3);

                    state_input5_ext3 = separation;
                    if (in_ext3[4].equals("0"))
                    {
                        state_input5_ext3 = separation + NORMA;
                    }
                    if (in_ext3[4].equals("1"))
                    {
                        state_input5_ext3 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[4].equals("2"))
                    {
                        state_input5_ext3 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[4].equals("3"))
                    {
                        state_input5_ext3 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT3, false)) inputs_ok=false;
                    }
                    textView_input5_ext3.setText(name_input5_ext3 + state_input5_ext3);

                    state_input6_ext3 = separation;
                    if (in_ext3[5].equals("0"))
                    {
                        state_input6_ext3 = separation + NORMA;
                    }
                    if (in_ext3[5].equals("1"))
                    {
                        state_input6_ext3 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[5].equals("2"))
                    {
                        state_input6_ext3 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[5].equals("3"))
                    {
                        state_input6_ext3 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT3, false)) inputs_ok=false;
                    }
                    textView_input6_ext3.setText(name_input6_ext3 + state_input6_ext3);

                    state_input7_ext3 = separation;
                    if (in_ext3[6].equals("0"))
                    {
                        state_input7_ext3 = separation + NORMA;
                    }
                    if (in_ext3[6].equals("1"))
                    {
                        state_input7_ext3 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[6].equals("2"))
                    {
                        state_input7_ext3 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[6].equals("3"))
                    {
                        state_input7_ext3 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT3, false)) inputs_ok=false;
                    }
                    textView_input7_ext3.setText(name_input7_ext3 + state_input7_ext3);

                    state_input8_ext3 = separation;
                    if (in_ext3[7].equals("0"))
                    {
                        state_input8_ext3 = separation + NORMA;
                    }
                    if (in_ext3[7].equals("1"))
                    {
                        state_input8_ext3 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[7].equals("2"))
                    {
                        state_input8_ext3 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT3, false)) inputs_ok=false;
                    }
                    if (in_ext3[7].equals("3"))
                    {
                        state_input8_ext3 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT3, false)) inputs_ok=false;
                    }
                    textView_input8_ext3.setText(name_input8_ext3 + state_input8_ext3);

                    //ext4
                    state_input1_ext4 = separation;
                    if (in_ext4[0].equals("0"))
                    {
                        state_input1_ext4 = separation + NORMA;
                    }
                    if (in_ext4[0].equals("1"))
                    {
                        state_input1_ext4 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[0].equals("2"))
                    {
                        state_input1_ext4 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[0].equals("3"))
                    {
                        state_input1_ext4 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I1_EXT4, false)) inputs_ok=false;
                    }
                    textView_input1_ext4.setText(name_input1_ext4 + state_input1_ext4);

                    state_input2_ext4 = separation;
                    if (in_ext4[1].equals("0"))
                    {
                        state_input2_ext4 = separation + NORMA;
                    }
                    if (in_ext4[1].equals("1"))
                    {
                        state_input2_ext4 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[1].equals("2"))
                    {
                        state_input2_ext4 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[1].equals("3"))
                    {
                        state_input2_ext4 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I2_EXT4, false)) inputs_ok=false;
                    }
                    textView_input2_ext4.setText(name_input2_ext4 + state_input2_ext4);

                    state_input3_ext4 = separation;
                    if (in_ext4[2].equals("0"))
                    {
                        state_input3_ext4 = separation + NORMA;
                    }
                    if (in_ext4[2].equals("1"))
                    {
                        state_input3_ext4 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[2].equals("2"))
                    {
                        state_input3_ext4 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[2].equals("3"))
                    {
                        state_input3_ext4 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I3_EXT4, false)) inputs_ok=false;
                    }
                    textView_input3_ext4.setText(name_input3_ext4 + state_input3_ext4);

                    state_input4_ext4 = separation;
                    if (in_ext4[3].equals("0"))
                    {
                        state_input4_ext4 = separation + NORMA;
                    }
                    if (in_ext4[3].equals("1"))
                    {
                        state_input4_ext4 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[3].equals("2"))
                    {
                        state_input4_ext4 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[3].equals("3"))
                    {
                        state_input4_ext4 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I4_EXT4, false)) inputs_ok=false;
                    }
                    textView_input4_ext4.setText(name_input4_ext4 + state_input4_ext4);

                    state_input5_ext4 = separation;
                    if (in_ext4[4].equals("0"))
                    {
                        state_input5_ext4 = separation + NORMA;
                    }
                    if (in_ext4[4].equals("1"))
                    {
                        state_input5_ext4 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[4].equals("2"))
                    {
                        state_input5_ext4 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[4].equals("3"))
                    {
                        state_input5_ext4 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I5_EXT4, false)) inputs_ok=false;
                    }
                    textView_input5_ext4.setText(name_input5_ext4 + state_input5_ext4);

                    state_input6_ext4 = separation;
                    if (in_ext4[5].equals("0"))
                    {
                        state_input6_ext4 = separation + NORMA;
                    }
                    if (in_ext4[5].equals("1"))
                    {
                        state_input6_ext4 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[5].equals("2"))
                    {
                        state_input6_ext4 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[5].equals("3"))
                    {
                        state_input6_ext4 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I6_EXT4, false)) inputs_ok=false;
                    }
                    textView_input6_ext4.setText(name_input6_ext4 + state_input6_ext4);

                    state_input7_ext4 = separation;
                    if (in_ext4[6].equals("0"))
                    {
                        state_input7_ext4 = separation + NORMA;
                    }
                    if (in_ext4[6].equals("1"))
                    {
                        state_input7_ext4 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[6].equals("2"))
                    {
                        state_input7_ext4 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[6].equals("3"))
                    {
                        state_input7_ext4 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I7_EXT4, false)) inputs_ok=false;
                    }
                    textView_input7_ext4.setText(name_input7_ext4 + state_input7_ext4);

                    state_input8_ext4 = separation;
                    if (in_ext4[7].equals("0"))
                    {
                        state_input8_ext4 = separation + NORMA;
                    }
                    if (in_ext4[7].equals("1"))
                    {
                        state_input8_ext4 = separation + TREVOGA;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[7].equals("2"))
                    {
                        state_input8_ext4 = separation + KZ;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT4, false)) inputs_ok=false;
                    }
                    if (in_ext4[7].equals("3"))
                    {
                        state_input8_ext4 = separation + OBRIV;
                        if (mSettings.getBoolean(APP_PREFERENCES_VIEW_I8_EXT4, false)) inputs_ok=false;
                    }
                    textView_input8_ext4.setText(name_input8_ext4 + state_input8_ext4);





                    //выводим состояние выходов
                    state_output1 = separation;
                    if (out1.equals("1"))
                    {
                        state_output1 = separation + OUTPUT_ON;
                    }
                    if (out1.equals("0"))
                    {
                        state_output1 = separation + OUTPUT_OFF;
                    }
                    btn_output1.setText(name_output1 + state_output1);

                    state_output2 = separation;
                    if (out2.equals("1"))
                    {
                        state_output2 = separation + OUTPUT_ON;
                    }
                    if (out2.equals("0"))
                    {
                        state_output2 = separation + OUTPUT_OFF;
                    }
                    btn_output2.setText(name_output2 + state_output2);

                    state_output3 = separation;
                    if (out3.equals("1"))
                    {
                        state_output3 = separation + OUTPUT_ON;
                    }
                    if (out3.equals("0"))
                    {
                        state_output3 = separation + OUTPUT_OFF;
                    }
                    btn_output3.setText(name_output3 + state_output3);

                    state_output4 = separation;
                    if (out4.equals("1"))
                    {
                        state_output4 = separation + OUTPUT_ON;
                    }
                    if (out4.equals("0"))
                    {
                        state_output4 = separation + OUTPUT_OFF;
                    }
                    btn_output4.setText(name_output4 + state_output4);

                    state_output5 = separation;
                    if (out5.equals("1"))
                    {
                        state_output5 = separation + OUTPUT_ON;
                    }
                    if (out5.equals("0"))
                    {
                        state_output5 = separation + OUTPUT_OFF;
                    }
                    btn_output5.setText(name_output5 + state_output5);

                    state_output6 = separation;
                    if (out6.equals("1"))
                    {
                        state_output6 = separation + OUTPUT_ON;
                    }
                    if (out6.equals("0"))
                    {
                        state_output6 = separation + OUTPUT_OFF;
                    }
                    btn_output6.setText(name_output6 + state_output6);

                    state_output7 = separation;
                    if (out7.equals("1"))
                    {
                        state_output7 = separation + OUTPUT_ON;
                    }
                    if (out7.equals("0"))
                    {
                        state_output7 = separation + OUTPUT_OFF;
                    }
                    btn_output7.setText(name_output7 + state_output7);

                    state_output8 = separation;
                    if (out8.equals("1"))
                    {
                        state_output8 = separation + OUTPUT_ON;
                    }
                    if (out8.equals("0"))
                    {
                        state_output8 = separation + OUTPUT_OFF;
                    }
                    btn_output8.setText(name_output8 + state_output8);

                    //ext0
                    state_output1_ext0 = separation;
                    if (out_ext0[0].equals("1")) state_output1_ext0 = separation + OUTPUT_ON;
                    if (out_ext0[0].equals("0")) state_output1_ext0 = separation + OUTPUT_OFF;
                    btn_output1_ext0.setText(name_output1_ext0 + state_output1_ext0);

                    state_output2_ext0 = separation;
                    if (out_ext0[1].equals("1")) state_output2_ext0 = separation + OUTPUT_ON;
                    if (out_ext0[1].equals("0")) state_output2_ext0 = separation + OUTPUT_OFF;
                    btn_output2_ext0.setText(name_output2_ext0 + state_output2_ext0);

                    state_output3_ext0 = separation;
                    if (out_ext0[2].equals("1")) state_output3_ext0 = separation + OUTPUT_ON;
                    if (out_ext0[2].equals("0")) state_output3_ext0 = separation + OUTPUT_OFF;
                    btn_output3_ext0.setText(name_output3_ext0 + state_output3_ext0);

                    state_output4_ext0 = separation;
                    if (out_ext0[3].equals("1")) state_output4_ext0 = separation + OUTPUT_ON;
                    if (out_ext0[3].equals("0")) state_output4_ext0 = separation + OUTPUT_OFF;
                    btn_output4_ext0.setText(name_output4_ext0 + state_output4_ext0);

                    state_output5_ext0 = separation;
                    if (out_ext0[4].equals("1")) state_output5_ext0 = separation + OUTPUT_ON;
                    if (out_ext0[4].equals("0")) state_output5_ext0 = separation + OUTPUT_OFF;
                    btn_output5_ext0.setText(name_output5_ext0 + state_output5_ext0);

                    state_output6_ext0 = separation;
                    if (out_ext0[5].equals("1")) state_output6_ext0 = separation + OUTPUT_ON;
                    if (out_ext0[5].equals("0")) state_output6_ext0 = separation + OUTPUT_OFF;
                    btn_output6_ext0.setText(name_output6_ext0 + state_output6_ext0);

                    state_output7_ext0 = separation;
                    if (out_ext0[6].equals("1")) state_output7_ext0 = separation + OUTPUT_ON;
                    if (out_ext0[6].equals("0")) state_output7_ext0 = separation + OUTPUT_OFF;
                    btn_output7_ext0.setText(name_output7_ext0 + state_output7_ext0);

                    state_output8_ext0 = separation;
                    if (out_ext0[7].equals("1")) state_output8_ext0 = separation + OUTPUT_ON;
                    if (out_ext0[7].equals("0")) state_output8_ext0 = separation + OUTPUT_OFF;
                    btn_output8_ext0.setText(name_output8_ext0 + state_output8_ext0);

                    //ext1
                    state_output1_ext1 = separation;
                    if (out_ext1[0].equals("1")) state_output1_ext1 = separation + OUTPUT_ON;
                    if (out_ext1[0].equals("0")) state_output1_ext1 = separation + OUTPUT_OFF;
                    btn_output1_ext1.setText(name_output1_ext1 + state_output1_ext1);

                    state_output2_ext1 = separation;
                    if (out_ext1[1].equals("1")) state_output2_ext1 = separation + OUTPUT_ON;
                    if (out_ext1[1].equals("0")) state_output2_ext1 = separation + OUTPUT_OFF;
                    btn_output2_ext1.setText(name_output2_ext1 + state_output2_ext1);

                    state_output3_ext1 = separation;
                    if (out_ext1[2].equals("1")) state_output3_ext1 = separation + OUTPUT_ON;
                    if (out_ext1[2].equals("0")) state_output3_ext1 = separation + OUTPUT_OFF;
                    btn_output3_ext1.setText(name_output3_ext1 + state_output3_ext1);

                    state_output4_ext1 = separation;
                    if (out_ext1[3].equals("1")) state_output4_ext1 = separation + OUTPUT_ON;
                    if (out_ext1[3].equals("0")) state_output4_ext1 = separation + OUTPUT_OFF;
                    btn_output4_ext1.setText(name_output4_ext1 + state_output4_ext1);

                    state_output5_ext1 = separation;
                    if (out_ext1[4].equals("1")) state_output5_ext1 = separation + OUTPUT_ON;
                    if (out_ext1[4].equals("0")) state_output5_ext1 = separation + OUTPUT_OFF;
                    btn_output5_ext1.setText(name_output5_ext1 + state_output5_ext1);

                    state_output6_ext1 = separation;
                    if (out_ext1[5].equals("1")) state_output6_ext1 = separation + OUTPUT_ON;
                    if (out_ext1[5].equals("0")) state_output6_ext1 = separation + OUTPUT_OFF;
                    btn_output6_ext1.setText(name_output6_ext1 + state_output6_ext1);

                    state_output7_ext1 = separation;
                    if (out_ext1[6].equals("1")) state_output7_ext1 = separation + OUTPUT_ON;
                    if (out_ext1[6].equals("0")) state_output7_ext1 = separation + OUTPUT_OFF;
                    btn_output7_ext1.setText(name_output7_ext1 + state_output7_ext1);

                    state_output8_ext1 = separation;
                    if (out_ext1[7].equals("1")) state_output8_ext1 = separation + OUTPUT_ON;
                    if (out_ext1[7].equals("0")) state_output8_ext1 = separation + OUTPUT_OFF;
                    btn_output8_ext1.setText(name_output8_ext1 + state_output8_ext1);

                    //ext2
                    state_output1_ext2 = separation;
                    if (out_ext2[0].equals("1")) state_output1_ext2 = separation + OUTPUT_ON;
                    if (out_ext2[0].equals("0")) state_output1_ext2 = separation + OUTPUT_OFF;
                    btn_output1_ext2.setText(name_output1_ext2 + state_output1_ext2);

                    state_output2_ext2 = separation;
                    if (out_ext2[1].equals("1")) state_output2_ext2 = separation + OUTPUT_ON;
                    if (out_ext2[1].equals("0")) state_output2_ext2 = separation + OUTPUT_OFF;
                    btn_output2_ext2.setText(name_output2_ext2 + state_output2_ext2);

                    state_output3_ext2 = separation;
                    if (out_ext2[2].equals("1")) state_output3_ext2 = separation + OUTPUT_ON;
                    if (out_ext2[2].equals("0")) state_output3_ext2 = separation + OUTPUT_OFF;
                    btn_output3_ext2.setText(name_output3_ext2 + state_output3_ext2);

                    state_output4_ext2 = separation;
                    if (out_ext2[3].equals("1")) state_output4_ext2 = separation + OUTPUT_ON;
                    if (out_ext2[3].equals("0")) state_output4_ext2 = separation + OUTPUT_OFF;
                    btn_output4_ext2.setText(name_output4_ext2 + state_output4_ext2);

                    state_output5_ext2 = separation;
                    if (out_ext2[4].equals("1")) state_output5_ext2 = separation + OUTPUT_ON;
                    if (out_ext2[4].equals("0")) state_output5_ext2 = separation + OUTPUT_OFF;
                    btn_output5_ext2.setText(name_output5_ext2 + state_output5_ext2);

                    state_output6_ext2 = separation;
                    if (out_ext2[5].equals("1")) state_output6_ext2 = separation + OUTPUT_ON;
                    if (out_ext2[5].equals("0")) state_output6_ext2 = separation + OUTPUT_OFF;
                    btn_output6_ext2.setText(name_output6_ext2 + state_output6_ext2);

                    state_output7_ext2 = separation;
                    if (out_ext2[6].equals("1")) state_output7_ext2 = separation + OUTPUT_ON;
                    if (out_ext2[6].equals("0")) state_output7_ext2 = separation + OUTPUT_OFF;
                    btn_output7_ext2.setText(name_output7_ext2 + state_output7_ext2);

                    state_output8_ext2 = separation;
                    if (out_ext2[7].equals("1")) state_output8_ext2 = separation + OUTPUT_ON;
                    if (out_ext2[7].equals("0")) state_output8_ext2 = separation + OUTPUT_OFF;
                    btn_output8_ext2.setText(name_output8_ext2 + state_output8_ext2);

                    //ext3
                    state_output1_ext3 = separation;
                    if (out_ext3[0].equals("1")) state_output1_ext3 = separation + OUTPUT_ON;
                    if (out_ext3[0].equals("0")) state_output1_ext3 = separation + OUTPUT_OFF;
                    btn_output1_ext3.setText(name_output1_ext3 + state_output1_ext3);

                    state_output2_ext3 = separation;
                    if (out_ext3[1].equals("1")) state_output2_ext3 = separation + OUTPUT_ON;
                    if (out_ext3[1].equals("0")) state_output2_ext3 = separation + OUTPUT_OFF;
                    btn_output2_ext3.setText(name_output2_ext3 + state_output2_ext3);

                    state_output3_ext3 = separation;
                    if (out_ext3[2].equals("1")) state_output3_ext3 = separation + OUTPUT_ON;
                    if (out_ext3[2].equals("0")) state_output3_ext3 = separation + OUTPUT_OFF;
                    btn_output3_ext3.setText(name_output3_ext3 + state_output3_ext3);

                    state_output4_ext3 = separation;
                    if (out_ext3[3].equals("1")) state_output4_ext3 = separation + OUTPUT_ON;
                    if (out_ext3[3].equals("0")) state_output4_ext3 = separation + OUTPUT_OFF;
                    btn_output4_ext3.setText(name_output4_ext3 + state_output4_ext3);

                    state_output5_ext3 = separation;
                    if (out_ext3[4].equals("1")) state_output5_ext3 = separation + OUTPUT_ON;
                    if (out_ext3[4].equals("0")) state_output5_ext3 = separation + OUTPUT_OFF;
                    btn_output5_ext3.setText(name_output5_ext3 + state_output5_ext3);

                    state_output6_ext3 = separation;
                    if (out_ext3[5].equals("1")) state_output6_ext3 = separation + OUTPUT_ON;
                    if (out_ext3[5].equals("0")) state_output6_ext3 = separation + OUTPUT_OFF;
                    btn_output6_ext3.setText(name_output6_ext3 + state_output6_ext3);

                    state_output7_ext3 = separation;
                    if (out_ext3[6].equals("1")) state_output7_ext3 = separation + OUTPUT_ON;
                    if (out_ext3[6].equals("0")) state_output7_ext3 = separation + OUTPUT_OFF;
                    btn_output7_ext3.setText(name_output7_ext3 + state_output7_ext3);

                    state_output8_ext3 = separation;
                    if (out_ext3[7].equals("1")) state_output8_ext3 = separation + OUTPUT_ON;
                    if (out_ext3[7].equals("0")) state_output8_ext3 = separation + OUTPUT_OFF;
                    btn_output8_ext3.setText(name_output8_ext3 + state_output8_ext3);

                    //ext4
                    state_output1_ext4 = separation;
                    if (out_ext4[0].equals("1")) state_output1_ext4 = separation + OUTPUT_ON;
                    if (out_ext4[0].equals("0")) state_output1_ext4 = separation + OUTPUT_OFF;
                    btn_output1_ext4.setText(name_output1_ext4 + state_output1_ext4);

                    state_output2_ext4 = separation;
                    if (out_ext4[1].equals("1")) state_output2_ext4 = separation + OUTPUT_ON;
                    if (out_ext4[1].equals("0")) state_output2_ext4 = separation + OUTPUT_OFF;
                    btn_output2_ext4.setText(name_output2_ext4 + state_output2_ext4);

                    state_output3_ext4 = separation;
                    if (out_ext4[2].equals("1")) state_output3_ext4 = separation + OUTPUT_ON;
                    if (out_ext4[2].equals("0")) state_output3_ext4 = separation + OUTPUT_OFF;
                    btn_output3_ext4.setText(name_output3_ext4 + state_output3_ext4);

                    state_output4_ext4 = separation;
                    if (out_ext4[3].equals("1")) state_output4_ext4 = separation + OUTPUT_ON;
                    if (out_ext4[3].equals("0")) state_output4_ext4 = separation + OUTPUT_OFF;
                    btn_output4_ext4.setText(name_output4_ext4 + state_output4_ext4);

                    state_output5_ext4 = separation;
                    if (out_ext4[4].equals("1")) state_output5_ext4 = separation + OUTPUT_ON;
                    if (out_ext4[4].equals("0")) state_output5_ext4 = separation + OUTPUT_OFF;
                    btn_output5_ext4.setText(name_output5_ext4 + state_output5_ext4);

                    state_output6_ext4 = separation;
                    if (out_ext4[5].equals("1")) state_output6_ext4 = separation + OUTPUT_ON;
                    if (out_ext4[5].equals("0")) state_output6_ext4 = separation + OUTPUT_OFF;
                    btn_output6_ext4.setText(name_output6_ext4 + state_output6_ext4);

                    state_output7_ext4 = separation;
                    if (out_ext4[6].equals("1")) state_output7_ext4 = separation + OUTPUT_ON;
                    if (out_ext4[6].equals("0")) state_output7_ext4 = separation + OUTPUT_OFF;
                    btn_output7_ext4.setText(name_output7_ext4 + state_output7_ext4);

                    state_output8_ext4 = separation;
                    if (out_ext4[7].equals("1")) state_output8_ext4 = separation + OUTPUT_ON;
                    if (out_ext4[7].equals("0")) state_output8_ext4 = separation + OUTPUT_OFF;
                    btn_output8_ext4.setText(name_output8_ext4 + state_output8_ext4);

                    //radio socket
                    //blk1
                    state_socket1_blk1 = separation;
                    if (socket_blk1[0].equals("1")) state_socket1_blk1 = separation + OUTPUT_ON;
                    if (socket_blk1[0].equals("0")) state_socket1_blk1 = separation + OUTPUT_OFF;
                    btn_socket1_blk1.setText(name_socket1_blk1 + state_socket1_blk1);

                    state_socket2_blk1 = separation;
                    if (socket_blk1[1].equals("1")) state_socket2_blk1 = separation + OUTPUT_ON;
                    if (socket_blk1[1].equals("0")) state_socket2_blk1 = separation + OUTPUT_OFF;
                    btn_socket2_blk1.setText(name_socket2_blk1 + state_socket2_blk1);

                    state_socket3_blk1 = separation;
                    if (socket_blk1[2].equals("1")) state_socket3_blk1 = separation + OUTPUT_ON;
                    if (socket_blk1[2].equals("0")) state_socket3_blk1 = separation + OUTPUT_OFF;
                    btn_socket3_blk1.setText(name_socket3_blk1 + state_socket3_blk1);

                    state_socket4_blk1 = separation;
                    if (socket_blk1[3].equals("1")) state_socket4_blk1 = separation + OUTPUT_ON;
                    if (socket_blk1[3].equals("0")) state_socket4_blk1 = separation + OUTPUT_OFF;
                    btn_socket4_blk1.setText(name_socket4_blk1 + state_socket4_blk1);

                    state_socket5_blk1 = separation;
                    if (socket_blk1[4].equals("1")) state_socket5_blk1 = separation + OUTPUT_ON;
                    if (socket_blk1[4].equals("0")) state_socket5_blk1 = separation + OUTPUT_OFF;
                    btn_socket5_blk1.setText(name_socket5_blk1 + state_socket5_blk1);

                    state_socket6_blk1 = separation;
                    if (socket_blk1[5].equals("1")) state_socket6_blk1 = separation + OUTPUT_ON;
                    if (socket_blk1[5].equals("0")) state_socket6_blk1 = separation + OUTPUT_OFF;
                    btn_socket6_blk1.setText(name_socket6_blk1 + state_socket6_blk1);

                    state_socket7_blk1 = separation;
                    if (socket_blk1[6].equals("1")) state_socket7_blk1 = separation + OUTPUT_ON;
                    if (socket_blk1[6].equals("0")) state_socket7_blk1 = separation + OUTPUT_OFF;
                    btn_socket7_blk1.setText(name_socket7_blk1 + state_socket7_blk1);

                    state_socket8_blk1 = separation;
                    if (socket_blk1[7].equals("1")) state_socket8_blk1 = separation + OUTPUT_ON;
                    if (socket_blk1[7].equals("0")) state_socket8_blk1 = separation + OUTPUT_OFF;
                    btn_socket8_blk1.setText(name_socket8_blk1 + state_socket8_blk1);


                    //blk2
                    state_socket1_blk2 = separation;
                    if (socket_blk2[0].equals("1")) state_socket1_blk2 = separation + OUTPUT_ON;
                    if (socket_blk2[0].equals("0")) state_socket1_blk2 = separation + OUTPUT_OFF;
                    btn_socket1_blk2.setText(name_socket1_blk2 + state_socket1_blk2);

                    state_socket2_blk2 = separation;
                    if (socket_blk2[1].equals("1")) state_socket2_blk2 = separation + OUTPUT_ON;
                    if (socket_blk2[1].equals("0")) state_socket2_blk2 = separation + OUTPUT_OFF;
                    btn_socket2_blk2.setText(name_socket2_blk2 + state_socket2_blk2);

                    state_socket3_blk2 = separation;
                    if (socket_blk2[2].equals("1")) state_socket3_blk2 = separation + OUTPUT_ON;
                    if (socket_blk2[2].equals("0")) state_socket3_blk2 = separation + OUTPUT_OFF;
                    btn_socket3_blk2.setText(name_socket3_blk2 + state_socket3_blk2);

                    state_socket4_blk2 = separation;
                    if (socket_blk2[3].equals("1")) state_socket4_blk2 = separation + OUTPUT_ON;
                    if (socket_blk2[3].equals("0")) state_socket4_blk2 = separation + OUTPUT_OFF;
                    btn_socket4_blk2.setText(name_socket4_blk2 + state_socket4_blk2);

                    state_socket5_blk2 = separation;
                    if (socket_blk2[4].equals("1")) state_socket5_blk2 = separation + OUTPUT_ON;
                    if (socket_blk2[4].equals("0")) state_socket5_blk2 = separation + OUTPUT_OFF;
                    btn_socket5_blk2.setText(name_socket5_blk2 + state_socket5_blk2);

                    state_socket6_blk2 = separation;
                    if (socket_blk2[5].equals("1")) state_socket6_blk2 = separation + OUTPUT_ON;
                    if (socket_blk2[5].equals("0")) state_socket6_blk2 = separation + OUTPUT_OFF;
                    btn_socket6_blk2.setText(name_socket6_blk2 + state_socket6_blk2);

                    state_socket7_blk2 = separation;
                    if (socket_blk2[6].equals("1")) state_socket7_blk2 = separation + OUTPUT_ON;
                    if (socket_blk2[6].equals("0")) state_socket7_blk2 = separation + OUTPUT_OFF;
                    btn_socket7_blk2.setText(name_socket7_blk2 + state_socket7_blk2);

                    state_socket8_blk2 = separation;
                    if (socket_blk2[7].equals("1")) state_socket8_blk2 = separation + OUTPUT_ON;
                    if (socket_blk2[7].equals("0")) state_socket8_blk2 = separation + OUTPUT_OFF;
                    btn_socket8_blk2.setText(name_socket8_blk2 + state_socket8_blk2);

                    //blk3
                    state_socket1_blk3 = separation;
                    if (socket_blk3[0].equals("1")) state_socket1_blk3 = separation + OUTPUT_ON;
                    if (socket_blk3[0].equals("0")) state_socket1_blk3 = separation + OUTPUT_OFF;
                    btn_socket1_blk3.setText(name_socket1_blk3 + state_socket1_blk3);

                    state_socket2_blk3 = separation;
                    if (socket_blk3[1].equals("1")) state_socket2_blk3 = separation + OUTPUT_ON;
                    if (socket_blk3[1].equals("0")) state_socket2_blk3 = separation + OUTPUT_OFF;
                    btn_socket2_blk3.setText(name_socket2_blk3 + state_socket2_blk3);

                    state_socket3_blk3 = separation;
                    if (socket_blk3[2].equals("1")) state_socket3_blk3 = separation + OUTPUT_ON;
                    if (socket_blk3[2].equals("0")) state_socket3_blk3 = separation + OUTPUT_OFF;
                    btn_socket3_blk3.setText(name_socket3_blk3 + state_socket3_blk3);

                    state_socket4_blk3 = separation;
                    if (socket_blk3[3].equals("1")) state_socket4_blk3 = separation + OUTPUT_ON;
                    if (socket_blk3[3].equals("0")) state_socket4_blk3 = separation + OUTPUT_OFF;
                    btn_socket4_blk3.setText(name_socket4_blk3 + state_socket4_blk3);

                    state_socket5_blk3 = separation;
                    if (socket_blk3[4].equals("1")) state_socket5_blk3 = separation + OUTPUT_ON;
                    if (socket_blk3[4].equals("0")) state_socket5_blk3 = separation + OUTPUT_OFF;
                    btn_socket5_blk3.setText(name_socket5_blk3 + state_socket5_blk3);

                    state_socket6_blk3 = separation;
                    if (socket_blk3[5].equals("1")) state_socket6_blk3 = separation + OUTPUT_ON;
                    if (socket_blk3[5].equals("0")) state_socket6_blk3 = separation + OUTPUT_OFF;
                    btn_socket6_blk3.setText(name_socket6_blk3 + state_socket6_blk3);

                    state_socket7_blk3 = separation;
                    if (socket_blk3[6].equals("1")) state_socket7_blk3 = separation + OUTPUT_ON;
                    if (socket_blk3[6].equals("0")) state_socket7_blk3 = separation + OUTPUT_OFF;
                    btn_socket7_blk3.setText(name_socket7_blk3 + state_socket7_blk3);

                    state_socket8_blk3 = separation;
                    if (socket_blk3[7].equals("1")) state_socket8_blk3 = separation + OUTPUT_ON;
                    if (socket_blk3[7].equals("0")) state_socket8_blk3 = separation + OUTPUT_OFF;
                    btn_socket8_blk3.setText(name_socket8_blk3 + state_socket8_blk3);

                    //blk4
                    state_socket1_blk4 = separation;
                    if (socket_blk4[0].equals("1")) state_socket1_blk4 = separation + OUTPUT_ON;
                    if (socket_blk4[0].equals("0")) state_socket1_blk4 = separation + OUTPUT_OFF;
                    btn_socket1_blk4.setText(name_socket1_blk4 + state_socket1_blk4);

                    state_socket2_blk4 = separation;
                    if (socket_blk4[1].equals("1")) state_socket2_blk4 = separation + OUTPUT_ON;
                    if (socket_blk4[1].equals("0")) state_socket2_blk4 = separation + OUTPUT_OFF;
                    btn_socket2_blk4.setText(name_socket2_blk4 + state_socket2_blk4);

                    state_socket3_blk4 = separation;
                    if (socket_blk4[2].equals("1")) state_socket3_blk4 = separation + OUTPUT_ON;
                    if (socket_blk4[2].equals("0")) state_socket3_blk4 = separation + OUTPUT_OFF;
                    btn_socket3_blk4.setText(name_socket3_blk4 + state_socket3_blk4);

                    state_socket4_blk4 = separation;
                    if (socket_blk4[3].equals("1")) state_socket4_blk4 = separation + OUTPUT_ON;
                    if (socket_blk4[3].equals("0")) state_socket4_blk4 = separation + OUTPUT_OFF;
                    btn_socket4_blk4.setText(name_socket4_blk4 + state_socket4_blk4);

                    state_socket5_blk4 = separation;
                    if (socket_blk4[4].equals("1")) state_socket5_blk4 = separation + OUTPUT_ON;
                    if (socket_blk4[4].equals("0")) state_socket5_blk4 = separation + OUTPUT_OFF;
                    btn_socket5_blk4.setText(name_socket5_blk4 + state_socket5_blk4);

                    state_socket6_blk4 = separation;
                    if (socket_blk4[5].equals("1")) state_socket6_blk4 = separation + OUTPUT_ON;
                    if (socket_blk4[5].equals("0")) state_socket6_blk4 = separation + OUTPUT_OFF;
                    btn_socket6_blk4.setText(name_socket6_blk4 + state_socket6_blk4);

                    state_socket7_blk4 = separation;
                    if (socket_blk4[6].equals("1")) state_socket7_blk4 = separation + OUTPUT_ON;
                    if (socket_blk4[6].equals("0")) state_socket7_blk4 = separation + OUTPUT_OFF;
                    btn_socket7_blk4.setText(name_socket7_blk4 + state_socket7_blk4);

                    state_socket8_blk4 = separation;
                    if (socket_blk4[7].equals("1")) state_socket8_blk4 = separation + OUTPUT_ON;
                    if (socket_blk4[7].equals("0")) state_socket8_blk4 = separation + OUTPUT_OFF;
                    btn_socket8_blk4.setText(name_socket8_blk4 + state_socket8_blk4);





                    //if(!"".equals(DS1820_1)){
                        state_termo1 = separation + DS1820_1+adress_sensor_1;
                        textView_termo1.setText(name_termo1 + state_termo1);
                    //}
                    //if(!"".equals(DS1820_2)){
                        state_termo2 = separation + DS1820_2+adress_sensor_2;
                        textView_termo2.setText(name_termo2 + state_termo2);
                    //}
                    //if(!"".equals(DS1820_3)){
                        state_termo3 = separation + DS1820_3+adress_sensor_3;
                        textView_termo3.setText(name_termo3 + state_termo3);
                    //}
                    //if(!"".equals(DS1820_4)){
                        state_termo4 = separation + DS1820_4+adress_sensor_4;
                        textView_termo4.setText(name_termo4 + state_termo4);
                    //}
                    //if(!"".equals(DS1820_5)){
                        state_termo5 = separation + DS1820_5+adress_sensor_5;
                        textView_termo5.setText(name_termo5 + state_termo5);
                    //}
                    //if(!"".equals(DS1820_6)){
                        state_termo6 = separation + DS1820_6+adress_sensor_6;
                        textView_termo6.setText(name_termo6 + state_termo6);
                    //}
                    //if(!"".equals(DS1820_7)){
                        state_termo7 = separation + DS1820_7+adress_sensor_7;
                        textView_termo7.setText(name_termo7 + state_termo7);
                    //}
                    //if(!"".equals(DS1820_8)){
                        state_termo8 = separation + DS1820_8+adress_sensor_8;
                        textView_termo8.setText(name_termo8 + state_termo8);
                    //}



                    state_controller = getString(R.string.state_controller) + HW + ", " + version;
                    textView_controller.setText(state_controller);


                    //radio sensors
                    //if(!"".equals(rf_t_1)){
                        state_radio1 = separation + rf_t_1;
                        textView_radio1.setText(name_radio1 + state_radio1);
                    //}
                    //if(!"".equals(rf_t_2)){
                        state_radio2 = separation + rf_t_2;
                        textView_radio2.setText(name_radio2 + state_radio2);
                    //}
                    //if(!"".equals(rf_t_3)){
                        state_radio3 = separation + rf_t_3;
                        textView_radio3.setText(name_radio3 + state_radio3);
                    //}
                    //if(!"".equals(rf_t_4)){
                        state_radio4 = separation + rf_t_4;
                        textView_radio4.setText(name_radio4 + state_radio4);
                    //}
                    //if(!"".equals(rf_t_5)){
                        state_radio5 = separation + rf_t_5;
                        textView_radio5.setText(name_radio5 + state_radio5);
                    //}
                    //if(!"".equals(rf_t_6)){
                        state_radio6 = separation + rf_t_6;
                        textView_radio6.setText(name_radio6 + state_radio6);
                    //}
                    //if(!"".equals(rf_t_7)){
                        state_radio7 = separation + rf_t_7;
                        textView_radio7.setText(name_radio7 + state_radio7);
                    //}
                    //if(!"".equals(rf_t_8)){
                        state_radio8 = separation + rf_t_8;
                        textView_radio8.setText(name_radio8 + state_radio8);
                    //}
                    //if(!"".equals(rf_t_9)){
                        state_radio9 = separation + rf_t_9;
                        textView_radio9.setText(name_radio9 + state_radio9);
                    //}
                    //if(!"".equals(rf_t_10)){
                        state_radio10 = separation + rf_t_10;
                        textView_radio10.setText(name_radio10 + state_radio10);
                    //}
                    //if(!"".equals(rf_t_11)){
                        state_radio11 = separation + rf_t_11;
                        textView_radio11.setText(name_radio11 + state_radio11);
                    //}
                    //if(!"".equals(rf_t_12)){
                        state_radio12 = separation + rf_t_12;
                        textView_radio12.setText(name_radio12 + state_radio12);
                    //}
                    //if(!"".equals(rf_t_13)){
                        state_radio13 = separation + rf_t_13;
                        textView_radio13.setText(name_radio13 + state_radio13);
                    //}
                    //if(!"".equals(rf_t_14)){
                        state_radio14 = separation + rf_t_14;
                        textView_radio14.setText(name_radio14 + state_radio14);
                    //}
                    //if(!"".equals(rf_t_15)){
                        state_radio15 = separation + rf_t_15;
                        textView_radio15.setText(name_radio15 + state_radio15);
                    //}
                    //if(!"".equals(rf_t_16)){
                        state_radio16 = separation + rf_t_16;
                        textView_radio16.setText(name_radio16 + state_radio16);
                    //}

                    colour_io();

                    if ( state_radio1.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R1, true)) inputs_ok=false;
                    if ( state_radio2.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R2, true)) inputs_ok=false;
                    if ( state_radio3.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R3, true)) inputs_ok=false;
                    if ( state_radio4.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R4, true)) inputs_ok=false;
                    if ( state_radio5.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R5, true)) inputs_ok=false;
                    if ( state_radio6.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R6, true)) inputs_ok=false;
                    if ( state_radio7.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R7, true)) inputs_ok=false;
                    if ( state_radio8.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R8, true)) inputs_ok=false;
                    if ( state_radio9.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R9, true)) inputs_ok=false;
                    if ( state_radio10.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R10, true)) inputs_ok=false;
                    if ( state_radio11.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R11, true)) inputs_ok=false;
                    if ( state_radio12.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R12, true)) inputs_ok=false;
                    if ( state_radio13.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R13, true)) inputs_ok=false;
                    if ( state_radio14.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R14, true)) inputs_ok=false;
                    if ( state_radio15.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R15, true)) inputs_ok=false;
                    if ( state_radio16.indexOf(TREVOGA)>-1 && mSettings.getBoolean(APP_PREFERENCES_VIEW_R16, true)) inputs_ok=false;



                    if (inputs_ok )
                    {
                        imageView_input = "imageView_input_norma";
                        imageView_input_trevoga.setVisibility(View.INVISIBLE);
                        imageView_input_norma.setVisibility(View.VISIBLE);
                        imageView_input_.setVisibility(View.INVISIBLE);
                    } else {
                        imageView_input = "imageView_input_trevoga";
                        imageView_input_trevoga.setVisibility(View.VISIBLE);
                        imageView_input_norma.setVisibility(View.INVISIBLE);
                        imageView_input_.setVisibility(View.INVISIBLE);
                    }

                    //------------------- сохраняем данные в файл
                    String query = btn_query.getText().toString();
                    String power_ = textView_power.getText().toString();
                    String arm = btn_arm.getText().toString();
                    String gsm = textView_gsm.getText().toString();
                    //String input1 = textView_input1.getText().toString();

                    SharedPreferences.Editor editor = mSettings.edit();

                    editor.putString(APP_PREFERENCES_QUERY, query);
                    editor.putString(APP_PREFERENCES_POWER, power_);
                    editor.putString(APP_PREFERENCES_ARM, arm);
                    editor.putString(APP_PREFERENCES_GSM, gsm);

                    editor.putString(APP_PREFERENCES_TAMPER, state_tamper);
                    editor.putString(APP_PREFERENCES_INPUT1, state_input1);
                    //editor.putString(APP_PREFERENCES_NAME_INPUT1, name_input1);
                    editor.putString(APP_PREFERENCES_INPUT2, state_input2);
                    //editor.putString(APP_PREFERENCES_NAME_INPUT2, name_input2);
                    editor.putString(APP_PREFERENCES_INPUT3, state_input3);
                    //editor.putString(APP_PREFERENCES_NAME_INPUT3, name_input3);
                    editor.putString(APP_PREFERENCES_INPUT4, state_input4);
                    //editor.putString(APP_PREFERENCES_NAME_INPUT4, name_input4);
                    editor.putString(APP_PREFERENCES_INPUT5, state_input5);
                    //editor.putString(APP_PREFERENCES_NAME_INPUT5, name_input5);
                    editor.putString(APP_PREFERENCES_INPUT6, state_input6);
                    //editor.putString(APP_PREFERENCES_NAME_INPUT6, name_input6);
                    editor.putString(APP_PREFERENCES_INPUT7, state_input7);
                    //editor.putString(APP_PREFERENCES_NAME_INPUT7, name_input7);
                    editor.putString(APP_PREFERENCES_INPUT8, state_input8);
                    //editor.putString(APP_PREFERENCES_NAME_INPUT8, name_input8);

                    //ext0
                    editor.putString(APP_PREFERENCES_INPUT1_EXT0, state_input1_ext0);
                    editor.putString(APP_PREFERENCES_INPUT2_EXT0, state_input2_ext0);
                    editor.putString(APP_PREFERENCES_INPUT3_EXT0, state_input3_ext0);
                    editor.putString(APP_PREFERENCES_INPUT4_EXT0, state_input4_ext0);
                    editor.putString(APP_PREFERENCES_INPUT5_EXT0, state_input5_ext0);
                    editor.putString(APP_PREFERENCES_INPUT6_EXT0, state_input6_ext0);
                    editor.putString(APP_PREFERENCES_INPUT7_EXT0, state_input7_ext0);
                    editor.putString(APP_PREFERENCES_INPUT8_EXT0, state_input8_ext0);

                    //ext1
                    editor.putString(APP_PREFERENCES_INPUT1_EXT1, state_input1_ext1);
                    editor.putString(APP_PREFERENCES_INPUT2_EXT1, state_input2_ext1);
                    editor.putString(APP_PREFERENCES_INPUT3_EXT1, state_input3_ext1);
                    editor.putString(APP_PREFERENCES_INPUT4_EXT1, state_input4_ext1);
                    editor.putString(APP_PREFERENCES_INPUT5_EXT1, state_input5_ext1);
                    editor.putString(APP_PREFERENCES_INPUT6_EXT1, state_input6_ext1);
                    editor.putString(APP_PREFERENCES_INPUT7_EXT1, state_input7_ext1);
                    editor.putString(APP_PREFERENCES_INPUT8_EXT1, state_input8_ext1);

                    editor.putString(APP_PREFERENCES_INPUT1_EXT2, state_input1_ext2);
                    editor.putString(APP_PREFERENCES_INPUT2_EXT2, state_input2_ext2);
                    editor.putString(APP_PREFERENCES_INPUT3_EXT2, state_input3_ext2);
                    editor.putString(APP_PREFERENCES_INPUT4_EXT2, state_input4_ext2);
                    editor.putString(APP_PREFERENCES_INPUT5_EXT2, state_input5_ext2);
                    editor.putString(APP_PREFERENCES_INPUT6_EXT2, state_input6_ext2);
                    editor.putString(APP_PREFERENCES_INPUT7_EXT2, state_input7_ext2);
                    editor.putString(APP_PREFERENCES_INPUT8_EXT2, state_input8_ext2);

                    editor.putString(APP_PREFERENCES_INPUT1_EXT3, state_input1_ext3);
                    editor.putString(APP_PREFERENCES_INPUT2_EXT3, state_input2_ext3);
                    editor.putString(APP_PREFERENCES_INPUT3_EXT3, state_input3_ext3);
                    editor.putString(APP_PREFERENCES_INPUT4_EXT3, state_input4_ext3);
                    editor.putString(APP_PREFERENCES_INPUT5_EXT3, state_input5_ext3);
                    editor.putString(APP_PREFERENCES_INPUT6_EXT3, state_input6_ext3);
                    editor.putString(APP_PREFERENCES_INPUT7_EXT3, state_input7_ext3);
                    editor.putString(APP_PREFERENCES_INPUT8_EXT3, state_input8_ext3);

                    editor.putString(APP_PREFERENCES_INPUT1_EXT4, state_input1_ext4);
                    editor.putString(APP_PREFERENCES_INPUT2_EXT4, state_input2_ext4);
                    editor.putString(APP_PREFERENCES_INPUT3_EXT4, state_input3_ext4);
                    editor.putString(APP_PREFERENCES_INPUT4_EXT4, state_input4_ext4);
                    editor.putString(APP_PREFERENCES_INPUT5_EXT4, state_input5_ext4);
                    editor.putString(APP_PREFERENCES_INPUT6_EXT4, state_input6_ext4);
                    editor.putString(APP_PREFERENCES_INPUT7_EXT4, state_input7_ext4);
                    editor.putString(APP_PREFERENCES_INPUT8_EXT4, state_input8_ext4);



                    editor.putString(APP_PREFERENCES_OUTPUT1, state_output1);
                    //editor.putString(APP_PREFERENCES_NAME_OUTPUT1, name_output1);
                    editor.putString(APP_PREFERENCES_OUTPUT2, state_output2);
                    //editor.putString(APP_PREFERENCES_NAME_OUTPUT2, name_output2);
                    editor.putString(APP_PREFERENCES_OUTPUT3, state_output3);
                    //editor.putString(APP_PREFERENCES_NAME_OUTPUT3, name_output3);
                    editor.putString(APP_PREFERENCES_OUTPUT4, state_output4);
                    //editor.putString(APP_PREFERENCES_NAME_OUTPUT4, name_output4);
                    editor.putString(APP_PREFERENCES_OUTPUT5, state_output5);
                    //editor.putString(APP_PREFERENCES_NAME_OUTPUT5, name_output5);
                    editor.putString(APP_PREFERENCES_OUTPUT6, state_output6);
                    //editor.putString(APP_PREFERENCES_NAME_OUTPUT6, name_output6);
                    editor.putString(APP_PREFERENCES_OUTPUT7, state_output7);
                    //editor.putString(APP_PREFERENCES_NAME_OUTPUT7, name_output7);
                    editor.putString(APP_PREFERENCES_OUTPUT8, state_output8);
                    //editor.putString(APP_PREFERENCES_NAME_OUTPUT8, name_output8);

                    //ext0
                    editor.putString(APP_PREFERENCES_OUTPUT1_EXT0, state_output1_ext0);
                    editor.putString(APP_PREFERENCES_OUTPUT2_EXT0, state_output2_ext0);
                    editor.putString(APP_PREFERENCES_OUTPUT3_EXT0, state_output3_ext0);
                    editor.putString(APP_PREFERENCES_OUTPUT4_EXT0, state_output4_ext0);
                    editor.putString(APP_PREFERENCES_OUTPUT5_EXT0, state_output5_ext0);
                    editor.putString(APP_PREFERENCES_OUTPUT6_EXT0, state_output6_ext0);
                    editor.putString(APP_PREFERENCES_OUTPUT7_EXT0, state_output7_ext0);
                    editor.putString(APP_PREFERENCES_OUTPUT8_EXT0, state_output8_ext0);

                    //ext1
                    editor.putString(APP_PREFERENCES_OUTPUT1_EXT1, state_output1_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT2_EXT1, state_output2_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT3_EXT1, state_output3_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT4_EXT1, state_output4_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT5_EXT1, state_output5_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT6_EXT1, state_output6_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT7_EXT1, state_output7_ext1);
                    editor.putString(APP_PREFERENCES_OUTPUT8_EXT1, state_output8_ext1);

                    //ext2
                    editor.putString(APP_PREFERENCES_OUTPUT1_EXT2, state_output1_ext2);
                    editor.putString(APP_PREFERENCES_OUTPUT2_EXT2, state_output2_ext2);
                    editor.putString(APP_PREFERENCES_OUTPUT3_EXT2, state_output3_ext2);
                    editor.putString(APP_PREFERENCES_OUTPUT4_EXT2, state_output4_ext2);
                    editor.putString(APP_PREFERENCES_OUTPUT5_EXT2, state_output5_ext2);
                    editor.putString(APP_PREFERENCES_OUTPUT6_EXT2, state_output6_ext2);
                    editor.putString(APP_PREFERENCES_OUTPUT7_EXT2, state_output7_ext2);
                    editor.putString(APP_PREFERENCES_OUTPUT8_EXT2, state_output8_ext2);

                    editor.putString(APP_PREFERENCES_OUTPUT1_EXT3, state_output1_ext3);
                    editor.putString(APP_PREFERENCES_OUTPUT2_EXT3, state_output2_ext3);
                    editor.putString(APP_PREFERENCES_OUTPUT3_EXT3, state_output3_ext3);
                    editor.putString(APP_PREFERENCES_OUTPUT4_EXT3, state_output4_ext3);
                    editor.putString(APP_PREFERENCES_OUTPUT5_EXT3, state_output5_ext3);
                    editor.putString(APP_PREFERENCES_OUTPUT6_EXT3, state_output6_ext3);
                    editor.putString(APP_PREFERENCES_OUTPUT7_EXT3, state_output7_ext3);
                    editor.putString(APP_PREFERENCES_OUTPUT8_EXT3, state_output8_ext3);

                    editor.putString(APP_PREFERENCES_OUTPUT1_EXT4, state_output1_ext4);
                    editor.putString(APP_PREFERENCES_OUTPUT2_EXT4, state_output2_ext4);
                    editor.putString(APP_PREFERENCES_OUTPUT3_EXT4, state_output3_ext4);
                    editor.putString(APP_PREFERENCES_OUTPUT4_EXT4, state_output4_ext4);
                    editor.putString(APP_PREFERENCES_OUTPUT5_EXT4, state_output5_ext4);
                    editor.putString(APP_PREFERENCES_OUTPUT6_EXT4, state_output6_ext4);
                    editor.putString(APP_PREFERENCES_OUTPUT7_EXT4, state_output7_ext4);
                    editor.putString(APP_PREFERENCES_OUTPUT8_EXT4, state_output8_ext4);

                    editor.putString(APP_PREFERENCES_SOCKET1_BLK1, state_socket1_blk1);
                    editor.putString(APP_PREFERENCES_SOCKET2_BLK1, state_socket2_blk1);
                    editor.putString(APP_PREFERENCES_SOCKET3_BLK1, state_socket3_blk1);
                    editor.putString(APP_PREFERENCES_SOCKET4_BLK1, state_socket4_blk1);
                    editor.putString(APP_PREFERENCES_SOCKET5_BLK1, state_socket5_blk1);
                    editor.putString(APP_PREFERENCES_SOCKET6_BLK1, state_socket6_blk1);
                    editor.putString(APP_PREFERENCES_SOCKET7_BLK1, state_socket7_blk1);
                    editor.putString(APP_PREFERENCES_SOCKET8_BLK1, state_socket8_blk1);

                    editor.putString(APP_PREFERENCES_SOCKET1_BLK2, state_socket1_blk2);
                    editor.putString(APP_PREFERENCES_SOCKET2_BLK2, state_socket2_blk2);
                    editor.putString(APP_PREFERENCES_SOCKET3_BLK2, state_socket3_blk2);
                    editor.putString(APP_PREFERENCES_SOCKET4_BLK2, state_socket4_blk2);
                    editor.putString(APP_PREFERENCES_SOCKET5_BLK2, state_socket5_blk2);
                    editor.putString(APP_PREFERENCES_SOCKET6_BLK2, state_socket6_blk2);
                    editor.putString(APP_PREFERENCES_SOCKET7_BLK2, state_socket7_blk2);
                    editor.putString(APP_PREFERENCES_SOCKET8_BLK2, state_socket8_blk2);

                    editor.putString(APP_PREFERENCES_SOCKET1_BLK3, state_socket1_blk3);
                    editor.putString(APP_PREFERENCES_SOCKET2_BLK3, state_socket2_blk3);
                    editor.putString(APP_PREFERENCES_SOCKET3_BLK3, state_socket3_blk3);
                    editor.putString(APP_PREFERENCES_SOCKET4_BLK3, state_socket4_blk3);
                    editor.putString(APP_PREFERENCES_SOCKET5_BLK3, state_socket5_blk3);
                    editor.putString(APP_PREFERENCES_SOCKET6_BLK3, state_socket6_blk3);
                    editor.putString(APP_PREFERENCES_SOCKET7_BLK3, state_socket7_blk3);
                    editor.putString(APP_PREFERENCES_SOCKET8_BLK3, state_socket8_blk3);

                    editor.putString(APP_PREFERENCES_SOCKET1_BLK4, state_socket1_blk4);
                    editor.putString(APP_PREFERENCES_SOCKET2_BLK4, state_socket2_blk4);
                    editor.putString(APP_PREFERENCES_SOCKET3_BLK4, state_socket3_blk4);
                    editor.putString(APP_PREFERENCES_SOCKET4_BLK4, state_socket4_blk4);
                    editor.putString(APP_PREFERENCES_SOCKET5_BLK4, state_socket5_blk4);
                    editor.putString(APP_PREFERENCES_SOCKET6_BLK4, state_socket6_blk4);
                    editor.putString(APP_PREFERENCES_SOCKET7_BLK4, state_socket7_blk4);
                    editor.putString(APP_PREFERENCES_SOCKET8_BLK4, state_socket8_blk4);




                    editor.putString(APP_PREFERENCES_IMAGE_VIEW_POWER, imageView_power);
                    editor.putString(APP_PREFERENCES_IMAGE_VIEW_ARM, imageView_arm);
                    editor.putString(APP_PREFERENCES_IMAGE_VIEW_GSM, imageView_GSM);
                    editor.putString(APP_PREFERENCES_IMAGE_VIEW_INPUT, imageView_input);

                    editor.putString(APP_PREFERENCES_TERMO1, state_termo1);
                    editor.putString(APP_PREFERENCES_TERMO2, state_termo2);
                    editor.putString(APP_PREFERENCES_TERMO3, state_termo3);
                    editor.putString(APP_PREFERENCES_TERMO4, state_termo4);
                    editor.putString(APP_PREFERENCES_TERMO5, state_termo5);
                    editor.putString(APP_PREFERENCES_TERMO6, state_termo6);
                    editor.putString(APP_PREFERENCES_TERMO7, state_termo7);
                    editor.putString(APP_PREFERENCES_TERMO8, state_termo8);

                    editor.putString(APP_PREFERENCES_CONTROLLER, state_controller);

                    editor.putString(APP_PREFERENCES_RADIO1, state_radio1);
                    editor.putString(APP_PREFERENCES_RADIO2, state_radio2);
                    editor.putString(APP_PREFERENCES_RADIO3, state_radio3);
                    editor.putString(APP_PREFERENCES_RADIO4, state_radio4);
                    editor.putString(APP_PREFERENCES_RADIO5, state_radio5);
                    editor.putString(APP_PREFERENCES_RADIO6, state_radio6);
                    editor.putString(APP_PREFERENCES_RADIO7, state_radio7);
                    editor.putString(APP_PREFERENCES_RADIO8, state_radio8);
                    editor.putString(APP_PREFERENCES_RADIO9, state_radio9);
                    editor.putString(APP_PREFERENCES_RADIO10, state_radio10);
                    editor.putString(APP_PREFERENCES_RADIO11, state_radio11);
                    editor.putString(APP_PREFERENCES_RADIO12, state_radio12);
                    editor.putString(APP_PREFERENCES_RADIO13, state_radio13);
                    editor.putString(APP_PREFERENCES_RADIO14, state_radio14);
                    editor.putString(APP_PREFERENCES_RADIO15, state_radio15);
                    editor.putString(APP_PREFERENCES_RADIO16, state_radio16);



                    //editor.apply();
                    editor.commit();




                    //проигрываем файл
                    if (
                                    event_code!=540 &&
                                    !(event_code>=548 && event_code<=552) &&
                                    !(event_code>=460 && event_code<=475) &&
                                    !(event_code>=350 && event_code<=357) &&
                                            !(event_code>=738 && event_code<=753) &&
                                            !(event_code>=882 && event_code<=945)
                            )
                    {

                        String msg="";
                        int sensor;

                        //события по проводным зонам

                        if ( event_code == 337 || event_code == 338 )
                        {
                            msg=textView_tamper.getText().toString();
                            if (event_code == 337 ) Play_Alarm(); else Play_Message();
                        }


                        sensor=0;
                        if ( event_code == 300+sensor*2 || event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor )
                        {
                            msg=textView_input1.getText().toString();
                            if (event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor ) Play_Alarm(); else Play_Message();
                        }

                        sensor=1;
                        if ( event_code == 300+sensor*2 || event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor )
                        {
                            msg=textView_input2.getText().toString();
                            if (event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor ) Play_Alarm(); else Play_Message();
                        }

                        sensor=2;
                        if ( event_code == 300+sensor*2 || event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor )
                        {
                            msg=textView_input3.getText().toString();
                            if (event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor ) Play_Alarm(); else Play_Message();
                        }

                        sensor=3;
                        if ( event_code == 300+sensor*2 || event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor )
                        {
                            msg=textView_input4.getText().toString();
                            if (event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor ) Play_Alarm(); else Play_Message();
                        }

                        sensor=4;
                        if ( event_code == 300+sensor*2 || event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor )
                        {
                            msg=textView_input5.getText().toString();
                            if (event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor ) Play_Alarm(); else Play_Message();
                        }

                        sensor=5;
                        if ( event_code == 300+sensor*2 || event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor )
                        {
                            msg=textView_input6.getText().toString();
                            if (event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor ) Play_Alarm(); else Play_Message();
                        }

                        sensor=6;
                        if ( event_code == 300+sensor*2 || event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor )
                        {
                            msg=textView_input7.getText().toString();
                            if (event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor ) Play_Alarm(); else Play_Message();
                        }

                        sensor=7;
                        if ( event_code == 300+sensor*2 || event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor )
                        {
                            msg=textView_input8.getText().toString();
                            if (event_code == 301+sensor*2 || event_code == 476+sensor*2 || event_code == 477+sensor*2 || event_code == 492+sensor ) Play_Alarm(); else Play_Message();
                        }

                        int extension=0;

                        //ext0
                        extension=0;
                        sensor=0;
                        if ( ((event_code>=(1020+sensor*4))&&(event_code<=(1023+sensor*4))) || (event_code == 987+sensor) )
                        {
                            msg=textView_input1_ext0.getText().toString();
                            if (event_code == (1020+sensor*4 ) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=1;
                        if ( ((event_code>=(1020+sensor*4))&&(event_code<=(1023+sensor*4))) || (event_code == 987+sensor) )
                        {
                            msg=textView_input2_ext0.getText().toString();
                            if (event_code == (1020+sensor*4 ) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=2;
                        if ( ((event_code>=(1020+sensor*4))&&(event_code<=(1023+sensor*4))) || (event_code == 987+sensor) )
                        {
                            msg=textView_input3_ext0.getText().toString();
                            if (event_code == (1020+sensor*4 ) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=3;
                        if ( ((event_code>=(1020+sensor*4))&&(event_code<=(1023+sensor*4))) || (event_code == 987+sensor) )
                        {
                            msg=textView_input4_ext0.getText().toString();
                            if (event_code == (1020+sensor*4 ) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=4;
                        if ( ((event_code>=(1020+sensor*4))&&(event_code<=(1023+sensor*4))) || (event_code == 987+sensor) )
                        {
                            msg=textView_input5_ext0.getText().toString();
                            if (event_code == (1020+sensor*4 ) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=5;
                        if ( ((event_code>=(1020+sensor*4))&&(event_code<=(1023+sensor*4))) || (event_code == 987+sensor) )
                        {
                            msg=textView_input6_ext0.getText().toString();
                            if (event_code == (1020+sensor*4 ) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=6;
                        if ( ((event_code>=(1020+sensor*4))&&(event_code<=(1023+sensor*4))) || (event_code == 987+sensor) )
                        {
                            msg=textView_input7_ext0.getText().toString();
                            if (event_code == (1020+sensor*4 ) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=7;
                        if ( ((event_code>=(1020+sensor*4))&&(event_code<=(1023+sensor*4))) || (event_code == 987+sensor) )
                        {
                            msg=textView_input8_ext0.getText().toString();
                            if (event_code == (1020+sensor*4 ) ) Play_Message(); else  Play_Alarm();
                        }



                        //ext1
                        extension=0;
                        sensor=0;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input1_ext1.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=1;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input2_ext1.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=2;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input3_ext1.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=3;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input4_ext1.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=4;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input5_ext1.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=5;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input6_ext1.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=6;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input7_ext1.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=7;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input8_ext1.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }

                        //ext2
                        extension=1;
                        sensor=0;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input1_ext2.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=1;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input2_ext2.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=2;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input3_ext2.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=3;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input4_ext2.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=4;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input5_ext2.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=5;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input6_ext2.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=6;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input7_ext2.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=7;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input8_ext2.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }

                        //ext3
                        extension=2;
                        sensor=0;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input1_ext3.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=1;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input2_ext3.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=2;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input3_ext3.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=3;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input4_ext3.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=4;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input5_ext3.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=5;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input6_ext3.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=6;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input7_ext3.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=7;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input8_ext3.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        //ext4
                        extension=3;
                        sensor=0;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input1_ext4.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=1;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input2_ext4.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=2;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input3_ext4.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=3;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input4_ext4.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=4;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input5_ext4.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=5;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input6_ext4.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=6;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input7_ext4.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }
                        sensor=7;
                        if ( ((event_code>=(754+sensor*4 + extension*4*8))&&(event_code<=(757+sensor*4+ extension*4*8)))  || (event_code == 946+sensor+extension*8) )
                        {
                            msg=textView_input8_ext4.getText().toString();
                            if (event_code == (754+sensor*4 + extension*4*8) ) Play_Message(); else  Play_Alarm();
                        }


                        //radio
                        sensor=0;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio1 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=1;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio2 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=2;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio3 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=3;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio4 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=4;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio5 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=5;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio6 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=6;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio7 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=7;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio8 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=8;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio9 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=9;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio10 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=10;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio11 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=11;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio12 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=12;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio13 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=13;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio14 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=14;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio15 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }
                        sensor=15;
                        if  (event_code>=(364+sensor*6) && event_code<(364+(sensor+1)*6) )
                        {
                            msg=name_radio16 + " - ";
                            if (event_code == (364+sensor*6) ) {Play_Alarm(); msg=msg+NARUSHENIE;}
                            if (event_code == (364+sensor*6+1) ) {Play_Message(); msg=msg+VOSSTANOVLENIE;}
                            if (event_code == (364+sensor*6+2) ) {Play_Alarm(); msg=msg+VSKRYTIE_DATCHIKA;}
                            if (event_code == (364+sensor*6+3) ) {Play_Message(); msg=msg+RAZRIAD_BATTAREYKI;}
                            if (event_code == (364+sensor*6+4) ) {Play_Message(); msg=msg+NET_TESTOVOGO_SIGNALA;}
                            if (event_code == (364+sensor*6+5) ) {Play_Alarm(); msg=msg+PANIKA;}
                        }




                        //события постановка/снятие охраны
                        if ( event_code == 332 || event_code ==  333 || event_code ==  324 )
                        {
                            msg=btn_arm.getText().toString();
                            Play_Message();
                        }

                        //события постановка/снятие охраны определенным способом
                        if ( event_code>=650 && event_code<=737 )
                        {
                            msg=btn_arm.getText().toString();
                            if (event_code >= 722) msg=msg+getString(R.string.by_brelok)+(event_code-722+1);
                                else
                            if (event_code >= 706) msg=msg + getString(R.string.by_brelok)+(event_code-706+1);
                                else
                            if (event_code >= 694) msg=msg+getString(R.string.by_key)+(event_code-694+1);
                                else
                            if (event_code >= 682) msg=msg+getString(R.string.by_key)+(event_code-682+1);
                                else
                            if (event_code >= 674) msg=msg+getString(R.string.by_vxod)+(event_code-674+1);
                                else
                            if (event_code >= 666) msg=msg+getString(R.string.by_vxod)+(event_code-666+1);
                                else
                            if (event_code >= 658) msg=msg+getString(R.string.by_owner)+(event_code-658+1);
                                else
                            if (event_code >= 650) msg=msg+getString(R.string.by_owner)+(event_code-650+1);

                            Play_Message();
                        }

                        //событие ошибка постановки на охрану
                        if ( (event_code == 535) //||
                                //(event_code>=492 && event_code<=515) ||
                                //(event_code>=946 && event_code<=977)
                                )
                        {
                            msg= getString(R.string.arm_failure);//"Ошибка при постановке на охрану! Проверьте датчики.";
                            Play_Alarm();
                        }



                        //событие снятие охраны под принуждением
                        if ( event_code == 536 )
                        {
                            msg=getString(R.string.disarm_force); //"Снятие охраны под принуждением";
                            Play_Alarm();
                        }

                        //событие FRAUD_DETECTION
                        if ( event_code == 537 )
                        {
                            msg=getString(R.string.fraud_detection); //"подбор кода управления";
                            Play_Alarm();
                        }


                        //события по питанию
                        if ( event_code == 334 || event_code ==  335 || event_code ==  336 || event_code ==  339 )
                        {
                            msg=textView_power.getText().toString();
                            Play_Message();
                        }

                        if ( event_code == 321 )
                        {
                            msg=getString(R.string.acc_on);
                            Play_Message();
                        }
                        if ( event_code == 322 )
                        {
                            msg=getString(R.string.acc_off);
                            Play_Message();
                        }
                        if ( event_code == 323)
                        {
                            msg=getString(R.string.acc_charged);
                            Play_Message();
                        }

                        //событие запрос состояния
                        if ( event_code == 554 )
                        {
                            //Play_Vibro(100);
                            //Play_Message();
                        }

                        //событие включение прибора
                        if ( event_code == 555 )
                        {
                            msg= getString(R.string.turn_on);//"Включение прибора";
                            Play_Message();
                        }

                        //событие TAMPER_KB1_ALARM_EVENT
                        if ( event_code == 326 )
                        {
                            msg=getString(R.string.kb1_connection_lost);
                            Play_Alarm();
                        }
                        if ( event_code == 327 )
                        {
                            msg=getString(R.string.kb2_connection_lost);
                            Play_Alarm();
                        }
                        if ( event_code == 328 )
                        {
                            msg=getString(R.string.kb1_tamper_trevoga);
                            Play_Alarm();
                        }
                        if ( event_code == 329 )
                        {
                            msg=getString(R.string.kb1_tamper_norma);
                            Play_Message();
                        }
                        if ( event_code == 330 )
                        {
                            msg=getString(R.string.kb2_tamper_trevoga);
                            Play_Alarm();
                        }
                        if ( event_code == 331 )
                        {
                            msg=getString(R.string.kb2_tamper_norma);
                            Play_Message();
                        }
                        //extension lost
                        if ( event_code == 320 )
                        {
                            msg=getString(R.string.ext0_connection_lost);
                            Play_Alarm();
                        }


                        //события по termo-1
                        if ( event_code == 342 )
                        {
                            msg=textView_termo1.getText().toString();
                            Play_Message();
                        }

                        //события по termo-2
                        if ( event_code == 343 )
                        {
                            msg=textView_termo2.getText().toString();
                            Play_Message();
                        }

                        //события по termo-3
                        if ( event_code == 344 )
                        {
                            msg=textView_termo3.getText().toString();
                            Play_Message();
                        }

                        //события по termo-4
                        if ( event_code == 345 )
                        {
                            msg=textView_termo4.getText().toString();
                            Play_Message();
                        }

                        //события по termo-5
                        if ( event_code == 346 )
                        {
                            msg=textView_termo5.getText().toString();
                            Play_Message();
                        }

                        //события по termo-6
                        if ( event_code == 347 )
                        {
                            msg=textView_termo6.getText().toString();
                            Play_Message();
                        }

                        //события по termo-7
                        if ( event_code == 348 )
                        {
                            msg=textView_termo7.getText().toString();
                            Play_Message();
                        }

                        //события по termo-8
                        if ( event_code == 349 )
                        {
                            msg=textView_termo8.getText().toString();
                            Play_Message();
                        }


                        if ( event_code == 358 )
                        {
                            msg=getString(R.string.ext1_connection_lost);
                            Play_Alarm();
                        }
                        if ( event_code == 359 )
                        {
                            msg=getString(R.string.ext2_connection_lost);
                            Play_Alarm();
                        }
                        if ( event_code == 360 )
                        {
                            msg=getString(R.string.ext3_connection_lost);
                            Play_Alarm();
                        }
                        if ( event_code == 361 )
                        {
                            msg=getString(R.string.ext4_connection_lost);
                            Play_Alarm();
                        }


                        if (!"".equals(msg)) {

                            //save event to log
                            saveEvent("\u2193\u2193\n" + msgDate + "\n" + msg);


                            //-------------вывод сообщения
                            AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                            builder.setTitle( getString(R.string.msg_from_device)+ object_name + "!") //"Cообщение от " HW
                                    .setMessage(getString(R.string.time) + msgDate + "\n" + msg)
                                    .setIcon(R.drawable.ic_launcher)
                                    .setCancelable(false)
                                    .setNegativeButton("ОК",
                                            new DialogInterface.OnClickListener() {
                                                public void onClick(DialogInterface dialog, int id) {
                                                    dialog.cancel();
                                                }
                                            }
                                    );
                            AlertDialog alert = builder.create();
                            alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); //TYPE_SYSTEM_ALERT TYPE_TOAST
                            alert.show();
                        } else {
                            //Play_Message();
                        }
                    }


                    //long curTime = System.currentTimeMillis();
                    //String date_insert = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(curTime);
                    String date_insert=msgDate.toString(); //receiving server time

                    /*
                    //формируем массив сенсоров
                    String[] sensor_id = new String[max_num_sensors]; //код сенсора
                    String[] sensor_data_value = new String[max_num_sensors]; //значение сенсора
                    int sensors_num=0; //текущее значение сенсоров
                    int temp1=0;
                    try {
                        sensor_id[sensors_num]="30";  sensor_data_value[sensors_num++]= ohrana ; //ohrana
                        if (! groups.equals("")) {sensor_id[sensors_num]="133";  sensor_data_value[sensors_num++]= groups ;}
                        sensor_id[sensors_num]="10";  sensor_data_value[sensors_num++]= est220 ;
                        if (lowbat.equals("0")) {lowbat="1"; sensor_id[sensors_num]="62";  sensor_data_value[sensors_num++]= lowbat;}
                        if (est220.equals("1"))
                        {sensor_id[sensors_num]="29";  sensor_data_value[sensors_num++]= power;}
                        else
                        {
                            sensor_id[sensors_num]="139";  sensor_data_value[sensors_num++]= acc;
                            sensor_id[sensors_num]="29";  sensor_data_value[sensors_num++]= power;
                        }
                        if (low_li_ion.equals("0")) {low_li_ion="1"; sensor_id[sensors_num]="143";  sensor_data_value[sensors_num++]= low_li_ion;}

                        sensor_id[sensors_num]="17";  sensor_data_value[sensors_num++]= w_z1;
                        sensor_id[sensors_num]="18";  sensor_data_value[sensors_num++]= w_z2;
                        sensor_id[sensors_num]="19";  sensor_data_value[sensors_num++]= w_z3;
                        sensor_id[sensors_num]="20";  sensor_data_value[sensors_num++]= w_z4;

                        if (HW.equals("OKO-PRO"))
                        {
                            sensor_id[sensors_num]="21";  sensor_data_value[sensors_num++]= w_z5;
                            sensor_id[sensors_num]="22";  sensor_data_value[sensors_num++]= w_z6;
                            sensor_id[sensors_num]="23";  sensor_data_value[sensors_num++]= w_z7;
                            sensor_id[sensors_num]="24";  sensor_data_value[sensors_num++]= w_z8;
                        }

                        sensor_id[sensors_num]="116";  sensor_data_value[sensors_num++]= tamper;

                        sensor_id[sensors_num]="14";  sensor_data_value[sensors_num++]= out1;
                        sensor_id[sensors_num]="15";  sensor_data_value[sensors_num++]= out2;
                        sensor_id[sensors_num]="16";  sensor_data_value[sensors_num++]= out3;
                        sensor_id[sensors_num]="134";  sensor_data_value[sensors_num++]= out4;

                        if (HW.equals("OKO-PRO"))
                        {
                            sensor_id[sensors_num]="135";  sensor_data_value[sensors_num++]= out5;
                            sensor_id[sensors_num]="136";  sensor_data_value[sensors_num++]= out6;
                            sensor_id[sensors_num]="137";  sensor_data_value[sensors_num++]= out7;
                            sensor_id[sensors_num]="138";  sensor_data_value[sensors_num++]= out8;
                        }

                        sensor_id[sensors_num]="27";  sensor_data_value[sensors_num++]= adc1;
                        sensor_id[sensors_num]="28";  sensor_data_value[sensors_num++]= adc2;
                        sensor_id[sensors_num]="141";  sensor_data_value[sensors_num++]= adc3;

                        sensor_id[sensors_num]="85";  sensor_data_value[sensors_num++]= " ";

                        if (! DS1820_1.equals("")) {sensor_id[sensors_num]="53";  sensor_data_value[sensors_num++]= DS1820_1 ;}
                        if (! DS1820_2.equals("")) {sensor_id[sensors_num]="54";  sensor_data_value[sensors_num++]= DS1820_2 ;}
                        if (! DS1820_3.equals("")) {sensor_id[sensors_num]="55";  sensor_data_value[sensors_num++]= DS1820_3 ;}
                        if (! DS1820_4.equals("")) {sensor_id[sensors_num]="56";  sensor_data_value[sensors_num++]= DS1820_4 ;}
                        if (! DS1820_5.equals("")) {sensor_id[sensors_num]="57";  sensor_data_value[sensors_num++]= DS1820_5 ;}
                        if (! DS1820_6.equals("")) {sensor_id[sensors_num]="97";  sensor_data_value[sensors_num++]= DS1820_6 ;}
                        if (! DS1820_7.equals("")) {sensor_id[sensors_num]="98";  sensor_data_value[sensors_num++]= DS1820_7 ;}
                        if (! DS1820_8.equals("")) {sensor_id[sensors_num]="99";  sensor_data_value[sensors_num++]= DS1820_8 ;}

                        sensor_id[sensors_num]="84";  sensor_data_value[sensors_num++]= " ";

                        if (! rf_t_1.equals("")) {sensor_id[sensors_num]="100";  sensor_data_value[sensors_num++]= rf_t_1 ;}
                        if (! rf_t_2.equals("")) {sensor_id[sensors_num]="101";  sensor_data_value[sensors_num++]= rf_t_2 ;}
                        if (! rf_t_3.equals("")) {sensor_id[sensors_num]="102";  sensor_data_value[sensors_num++]= rf_t_3 ;}
                        if (! rf_t_4.equals("")) {sensor_id[sensors_num]="103";  sensor_data_value[sensors_num++]= rf_t_4 ;}
                        if (! rf_t_5.equals("")) {sensor_id[sensors_num]="104";  sensor_data_value[sensors_num++]= rf_t_5 ;}
                        if (! rf_t_6.equals("")) {sensor_id[sensors_num]="105";  sensor_data_value[sensors_num++]= rf_t_6 ;}
                        if (! rf_t_7.equals("")) {sensor_id[sensors_num]="106";  sensor_data_value[sensors_num++]= rf_t_7 ;}
                        if (! rf_t_8.equals("")) {sensor_id[sensors_num]="107";  sensor_data_value[sensors_num++]= rf_t_8 ;}
                        if (! rf_t_9.equals("")) {sensor_id[sensors_num]="108";  sensor_data_value[sensors_num++]= rf_t_9 ;}
                        if (! rf_t_10.equals("")) {sensor_id[sensors_num]="109";  sensor_data_value[sensors_num++]= rf_t_10 ;}
                        if (! rf_t_11.equals("")) {sensor_id[sensors_num]="110";  sensor_data_value[sensors_num++]= rf_t_11 ;}
                        if (! rf_t_12.equals("")) {sensor_id[sensors_num]="111";  sensor_data_value[sensors_num++]= rf_t_12 ;}
                        if (! rf_t_13.equals("")) {sensor_id[sensors_num]="112";  sensor_data_value[sensors_num++]= rf_t_13 ;}
                        if (! rf_t_14.equals("")) {sensor_id[sensors_num]="113";  sensor_data_value[sensors_num++]= rf_t_14 ;}
                        if (! rf_t_15.equals("")) {sensor_id[sensors_num]="114";  sensor_data_value[sensors_num++]= rf_t_15 ;}
                        if (! rf_t_16.equals("")) {sensor_id[sensors_num]="115";  sensor_data_value[sensors_num++]= rf_t_16 ;}

                        sensor_id[sensors_num]="60";  sensor_data_value[sensors_num++]= Integer.toString(GSM);
                        sensor_id[sensors_num]="140";  sensor_data_value[sensors_num++]= Integer.toString(GSM_rssi);
                        if (! balance.equals("")) {sensor_id[sensors_num]="11";  sensor_data_value[sensors_num++]= balance ;}
                        if (! version.equals("")) {sensor_id[sensors_num]="12";  sensor_data_value[sensors_num++]= version ;}
                        if (! HW.equals("")) {sensor_id[sensors_num]="142";  sensor_data_value[sensors_num++]= HW;}



                    }catch (Exception ex) {}

                    */


                    //save to DataBase
                    /*
                    String query = "SELECT account_id FROM objects WHERE device_code = '" + device_code + "'";
                    // executing SELECT query
                    rs_r = statement.executeQuery(query);
                    int account_id=-1;
                    if (rs_r.next()) {
                        account_id = rs_r.getInt(1);
                        //System.out.println("FOR TEST: account_id equals " + account_id+'.');
                    }
                    try { rs_r.close(); } catch(SQLException se) {  }

                    if (account_id==-1){
                        //прибор не введен ни под одним аккаунтом

                        if (event_code==254 || event_code==554){
                            //если запрос данных, то сохраняем под аккаунтом демо
                            account_id=1;
                        }else{
                            done=1;
                            //return done;
                        }

                    }
                    */

                    /*
                    if (done!=1)
                    {
                        String sat="";
                        String lat_f="";
                        String lon_f="";
                        String speed_f="";
                        String azimut_f="";
                        String gps_val="";

                        //query = "INSERT INTO `events`(`insert_date`,`device_code`,`event_code`,`account_id`,`row_data`) VALUES ('" + date_insert + "','" + device_code + "','" +event_code + "','" + account_id + "','" + request[0] + "')";
                        query = "INSERT INTO `events`(`insert_date`,`device_code`,`sat_number`,`lat`,`lon`, `speed`, `azimut`,`gps_validity`,`event_code`,`account_id`,`row_data`) VALUES ('" + date_insert + "','" + device_code + "','" + sat+ "','"+ lat_f + "','" + lon_f + "','" + speed_f + "','" + azimut_f + "','" + gps_val + "','" +event_code + "','" + account_id + "','" + request[0] + "')";


                        try {

                            // executing UPDATE query
                            statement.executeUpdate(query,Statement.RETURN_GENERATED_KEYS);
                            long insert_id=0;
                            rs_r = statement.getGeneratedKeys();
                            if (rs_r.next()){
                                insert_id=rs_r.getInt(1);
                            }
                            rs_r.close();

                            //сохраняем массив сенсоров
                            for (int i = 0; i < sensors_num; i++){
                                query = "INSERT INTO `events_details`(`event_id`,`sensor_id`,`data_value`) VALUES ('" + insert_id + "','" + sensor_id[i] + "','" + sensor_data_value[i] + "')";
                                statement.executeUpdate(query);
                            }

                        } catch (SQLException sqlEx) {
                            sqlEx.printStackTrace();
                        }catch(Exception e){
                            //Handle errors for Class.forName
                            e.printStackTrace();
                        } finally {
                            //close connection ,stmt and resultset here
                            //Print_Log("Data Base connection closed.",true);
                            //try { con.close(); } catch(SQLException se) {  }
                            //try { stmt.close(); } catch(SQLException se) {  }
                            //try { rs.close(); } catch(SQLException se) {  }
                        }

                        done=2;


                    }
                    */



                }
            }
        } catch (Exception ex)  {}


    }

    public void Play_Vibro(final int len) {
        if (mSettings.getBoolean(APP_PREFERENCES_VIBRO, true)) {
            new Thread(new Runnable() {
                public void run() {
                    try {
                        Vibrator vibe;
                        vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
                        vibe.vibrate(len);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }).start();
        }

    }

    public void Play_Message() {
        Play_Vibro(100);
        if (mSettings.getBoolean(APP_PREFERENCES_SOUND, true)) {
            new Thread(new Runnable() {
                public void run() {
                    try {
                        MediaPlayer myMediaPlayer = null;
                        myMediaPlayer = MediaPlayer.create(mContext, R.raw.message);
                        myMediaPlayer.start();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }).start();
        }

    }

    public void Play_Alarm() {
        Play_Vibro(3000);
        if (mSettings.getBoolean(APP_PREFERENCES_SOUND, true)) {
            new Thread(new Runnable() {
                public void run() {
                    try {
                        MediaPlayer myMediaPlayer = null;
                        myMediaPlayer = MediaPlayer.create(mContext, R.raw.alarm_2);
                        myMediaPlayer.start();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }).start();

        }
    }

    public void Play_Key_Pressed() {
        Play_Vibro(100);
        if (mSettings.getBoolean(APP_PREFERENCES_SOUND, true)) {
            new Thread(new Runnable() {
                public void run() {
                    try {
                        MediaPlayer myMediaPlayer = null;
                        myMediaPlayer = MediaPlayer.create(mContext, R.raw.kiss);
                        myMediaPlayer.start();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }).start();

        }
    }

    public void Play_Fault_Pressed() {
        Play_Vibro(50);
        if (mSettings.getBoolean(APP_PREFERENCES_SOUND, true)) {
            new Thread(new Runnable() {
                public void run() {
                    try {
                        MediaPlayer myMediaPlayer = null;
                        myMediaPlayer = MediaPlayer.create(mContext, R.raw.fault);
                        myMediaPlayer.start();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }).start();
        }

    }



    public boolean saveEvent(String event) {

        SharedPreferences.Editor editor = mSettings.edit();
        int event_pointer = mSettings.getInt(EVENTS_ARRAY + "_pointer", 0);
        editor.putString(EVENTS_ARRAY + "_" + String.valueOf(event_pointer), event);
        event_pointer++;
        if (event_pointer>=MAX_EVENTS) event_pointer=0;
        editor.putInt(EVENTS_ARRAY + "_pointer", event_pointer);

        return editor.commit();
    }
}
