public Form1() { InitializeComponent(); sys_option option = new sys_option() { PortName = "COM4" }; s = SerialService.CreateInstance(option); s.Receive_Result += S_Receive_Result; s.Event_Msg += S_Event_Msg; s.Init(); foreach (var item in Enum.GetValues(typeof(Torque.Common.Common.TorqueUnit))) { this.ddl_unit.Items.Add(new { name = item.ToString(), code = Convert.ToInt32(item) }); } this.ddl_unit.DisplayMember = "name"; this.ddl_unit.ValueMember = "code"; }
public static SerialService CreateInstance(sys_option serial_option) { lock (Singleton_Lock) { if (_Singleton == null) { _Singleton = new SerialService(); _Singleton._sys_serial = serial_option; } } return(_Singleton); }