Esempio n. 1
0
        private bool ReadValuesFromAddress(TypesCommands tc, byte length_data, byte[] begin_address, byte[] answer_bytes, int index_begin_address = 0)
        {
            byte[] data = null;

            switch (tc)
            {
            case TypesCommands.tc2K:
                data    = new byte[3];
                data[0] = 0x2;
                data[1] = begin_address[index_begin_address];
                data[2] = length_data;
                break;

            case TypesCommands.tc512K:
                data    = new byte[5];
                data[0] = length_data;
                for (int i = 0; i < 4; i++)
                {
                    data[1 + i] = begin_address[i];
                }
                break;
            }

            MakeCommand(data, (byte)data.Length, 0xF, (byte)tc);

            for (int i = 0; i < 5; i++)
            {
                if (SendCommand(ref answer_bytes, READVALUES_CMD_ANSWER_SIZE + length_data))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 2
0
        protected void TypesCommand_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            //command_executer_id = -1;
            //command_executer_parameter = null;
            int Position = TypesCommand.SelectedItemPosition;

            selected_type_command_name = Resources.GetStringArray(Resource.Array.commands_types_array)[Position];

            string command_type_array_item_port       = GetString(Resource.String.command_type_array_item_port);
            string command_type_array_item_controller = GetString(Resource.String.command_type_array_item_controller);
            string command_type_array_item_transfer   = GetString(Resource.String.command_type_array_item_transit);

            //if (AbstractSettingsManage.Command != null)
            //{
            //    switch (AbstractSettingsManage.Command.TypeCommand)
            //    {
            //        case TypesCommands.Port:
            //            command_type_array_item_port = GetString(Resource.String.command_type_array_item_port);
            //            if (selected_type_command_name != command_type_array_item_port)
            //            {
            //                return;
            //            }
            //            break;
            //        case TypesCommands.Controller:
            //            if (selected_type_command_name != command_type_array_item_controller)
            //            {
            //                return;
            //            }
            //            break;
            //        case TypesCommands.Exit:
            //            if (selected_type_command_name != command_type_array_item_transfer)
            //            {
            //                return;
            //            }
            //            break;
            //    }
            //}

            Log.Debug(TAG, $"TypesCommand_ItemSelected({selected_type_command_name}) - Position:{Position}");
            CommandConfigForm.RemoveAllViews();

            if (selected_type_command_name == command_type_array_item_port)
            {
                SelectedTypeCommand         = TypesCommands.Port;
                about_selected_command.Text = GetString(Resource.String.about_selected_command_port_title);

                CommandConfigFormBody = LayoutInflater.Inflate(Resource.Layout.FormPortCommand, CommandConfigForm, false) as LinearLayoutCompat;

                AppCompatSpinner Controllers = CommandConfigFormBody.FindViewById <AppCompatSpinner>(Resource.Id.spinnerControllerPortCommand);
                AppCompatSpinner Ports       = CommandConfigFormBody.FindViewById <AppCompatSpinner>(Resource.Id.spinnerPortCommand);
                AppCompatSpinner States      = CommandConfigFormBody.FindViewById <AppCompatSpinner>(Resource.Id.spinnerStateCommand);

                SettingsManageKit = new SettingsManagePort(this, Controllers, Ports, States);
            }
            else if (selected_type_command_name == command_type_array_item_controller)
            {
                SelectedTypeCommand         = TypesCommands.Controller;
                about_selected_command.Text = GetString(Resource.String.about_selected_command_controller_title);

                CommandConfigFormBody = LayoutInflater.Inflate(Resource.Layout.FormControllerCommand, CommandConfigForm, false) as LinearLayoutCompat;

                AppCompatSpinner Controllers = CommandConfigFormBody.FindViewById <AppCompatSpinner>(Resource.Id.spinnerControllerCommand);
                EditText         CommandText = CommandConfigFormBody.FindViewById <EditText>(Resource.Id.editTextParametrControllerCommand);

                SettingsManageKit = new SettingsManageController(this, Controllers, CommandText);
            }
            else if (selected_type_command_name == command_type_array_item_transfer)
            {
                SelectedTypeCommand         = TypesCommands.Exit;
                about_selected_command.Text = GetString(Resource.String.about_selected_command_transit_title);

                CommandConfigFormBody = LayoutInflater.Inflate(Resource.Layout.FormTransferCommand, CommandConfigForm, false) as LinearLayoutCompat;

                AppCompatSpinner Scriptes = CommandConfigFormBody.FindViewById <AppCompatSpinner>(Resource.Id.spinnerCommandScript);
                AppCompatSpinner Steps    = CommandConfigFormBody.FindViewById <AppCompatSpinner>(Resource.Id.spinnerCommandStepScript);

                SettingsManageKit = new SettingsManageTransfer(this, Scriptes, Steps);
            }
            else
            {
            }

            CommandConfigForm.AddView(CommandConfigFormBody);
        }
Esempio n. 3
0
        private bool ReadValuesFromAddress(TypesCommands tc, byte length_data, byte[] begin_address, byte[] answer_bytes, int index_begin_address = 0)
        {
            byte[] data = null;

            switch (tc)
            {
                case TypesCommands.tc2K:
                    data = new byte[3];
                    data[0] = 0x2;
                    data[1] = begin_address[index_begin_address];
                    data[2] = length_data;
                    break;
                case TypesCommands.tc512K:
                    data = new byte[5];
                    data[0] = length_data;
                    for (int i = 0; i < 4; i++)
                    {
                        data[1 + i] = begin_address[i];
                    }
                    break;
            }

            MakeCommand(data, (byte)data.Length, 0xF, (byte)tc);

            for (int i = 0; i < 5; i++)
            {
                if (SendCommand(ref answer_bytes, READVALUES_CMD_ANSWER_SIZE + length_data))
                {
                    return true;
                }
            }

            return false;
        }