/// <summary> /// 转换类型---shorot--list<int>根据需要读取个数返回泛型表--西门子专用 /// </summary> /// <param name="Name"></param> /// <param name="format"></param> /// <returns></returns> public List <int> Mitsubishi_to_Index_numerical(string Name, int id, numerical_format format, int Index, IPLC_interface pLC_Interface, int DB) //转换类型---shorot--string { List <int> data = new List <int>(); //初始化数据表 for (int i = 0; i < Index + 1; i++) { switch (format) { case numerical_format.BCD_16_Bit: case numerical_format.Binary_16_Bit: case numerical_format.Hex_16_Bit: case numerical_format.Signed_16_Bit: case numerical_format.Unsigned_16_Bit: data.Add(pLC_Interface.PLC_read_D_register(Name, (id + (i * 2)).ToString(), format).ToInt32()); //获取读取到的数据添加到泛型表 break; case numerical_format.Binary_32_Bit: case numerical_format.Float_32_Bit: case numerical_format.Hex_32_Bit: case numerical_format.Signed_32_Bit: case numerical_format.Unsigned_32_Bit: case numerical_format.BCD_32_Bit: data.Add(pLC_Interface.PLC_read_D_register(Name, (id + (i * 4)).ToString(), format).ToInt32()); //获取读取到的数据添加到泛型表 break; } } return(data);//返回数据 }
private void Button_write_select(string Name, IPLC_interface pLC_Interface, Button_base Button)//按照按钮模式写入 { //string[] Data = Button_Class(Button); switch (Name) { case "Set_as_on": //设置常ON if (Button.Command) { pLC_Interface.PLC_write_M_bit(Button.PLC_Contact, Button.PLC_Address, Button_state.ON); //写入常ON } else { pLC_Interface.PLC_write_M_bit(Button.PLC_Contact, Button.PLC_Address, Button_state.ON); //写入常ON } break; case "Set_as_off": //设置常OFF if (Button.Command) { pLC_Interface.PLC_write_M_bit(Button.PLC_Contact, Button.PLC_Address, Button_state.Off); //写入常Off } else { pLC_Interface.PLC_write_M_bit(Button.PLC_Contact, Button.PLC_Address, Button_state.Off); //写入常Off } break; case "selector_witch": if (Button.Command) { List <bool> data = pLC_Interface.PLC_read_M_bit(Button.PLC_Contact, Button.PLC_Address); //先读取要写入的状态 pLC_Interface.PLC_write_M_bit(Button.PLC_Contact, Button.PLC_Address, data[0] == true ? Button_state.Off : Button_state.ON); //根据要写入的状态进行取反 } else { List <bool> data = pLC_Interface.PLC_read_M_bit(Button.PLC_Contact, Button.PLC_Address); //先读取要写入的状态 pLC_Interface.PLC_write_M_bit(Button.PLC_Contact, Button.PLC_Address, data[0] == true ? Button_state.Off : Button_state.ON); //根据要写入的状态进行取反 } break; case "Regression": if (Button.Command) { pLC_Interface.PLC_write_M_bit(Button.PLC_Contact, Button.PLC_Address, Button_state.ON); //先写入ON--后用事件复位-off } else { pLC_Interface.PLC_write_M_bit(Button.PLC_Contact, Button.PLC_Address, Button_state.ON); //先写入ON--后用事件复位-off } state = true; //标志位 break; case "复归型_Off": if (Button.Command) { pLC_Interface.PLC_write_M_bit(Button.PLC_Contact, Button.PLC_Address, Button_state.Off); //先写入ON--后用事件复位-off } else { pLC_Interface.PLC_write_M_bit(Button.PLC_Contact, Button.PLC_Address, Button_state.Off); //先写入ON--后用事件复位-off } state = false; //标志位 break; } }