Beispiel #1
0
        public SetCommand(List <ME_Trigger> commands, Dictionary <string, string> lang_dic, ArrayList ME_List, GlobalSettings gs,
                          Arduino arduino, string com_port, NewMotion Motion, int var_num, int board_ver86)
        {
            InitializeComponent();
            this.cmd_lang_dic  = lang_dic;
            this.global_cmd    = commands;
            this.ME_Motionlist = ME_List;
            this.gs            = gs;
            this.arduino       = arduino;
            this.com_port      = com_port;
            this.Motion        = Motion;
            this.var_num       = var_num;
            this.board_ver86   = board_ver86;
            for (int i = 0; i < commands.Count; i++)
            {
                local_cmd.Add(commands[i].Copy());
                cmd_num = cmd_num + 1;
                string[] row     = { cmd_num.ToString(), commands[i].name };
                var      cmdItem = new ListViewItem(row);
                CmdListView.Items.Add(cmdItem);
            }
            if (CmdListView.Items.Count > 0)
            {
                CmdListView.Items[0].Selected = true;
            }
            else
            {
                MotionConfig.Enabled = false;
            }

            accLXText.Name       = "0";
            accHXText.Name       = "1";
            accLYText.Name       = "2";
            accHYText.Name       = "3";
            accLZText.Name       = "4";
            accHZText.Name       = "5";
            accDurationText.Name = "6";

            initGSpins();
            initAnalog();
            ps2DATCombo.Text      = gs.ps2pins[0];
            ps2CMDCombo.Text      = gs.ps2pins[1];
            ps2ATTCombo.Text      = gs.ps2pins[2];
            ps2CLKCombo.Text      = gs.ps2pins[3];
            ESP8266CHPDCombo.Text = gs.esp8266_chpd;

            for (int i = 0; i < ME_Motionlist.Count; i++)
            {
                ME_Motion m = (ME_Motion)ME_Motionlist[i];
                if (m.trigger_index != -1 && global_cmd[m.trigger_index].used && !used_element.Contains(m))
                {
                    used_element.Add(m);
                    tmp_element.Add(m.Copy());
                }
                for (int j = 0; j < m.Events.Count; j++)
                {
                    if (m.Events[j] is ME_If mif)
                    {
                        if (mif.left_var >= var_num + 58 && global_cmd[mif.left_var - var_num - 58].used && !used_element.Contains(mif))
                        {
                            used_element.Add(mif);
                            tmp_element.Add(mif.Copy());
                        }
                    }
                }
            }
            applyLang();
        }