Beispiel #1
0
        static DrugPacks packs; // = new DrugPack(3, new PackRate("1:2:10"));

        #endregion Fields

        #region Methods

        static void Main(string[] args)
        {
            packs = new DrugPacks( new PackRate("1:2:10"));
            Console.WriteLine(packs.PackRate);
            Console.WriteLine(packs.PackRate[0].ToString());
            Console.WriteLine(packs.PackRate[1].ToString());
            Console.WriteLine(packs.PackRate[2].ToString());
            Console.ReadKey();
            packs.Add(0, new DrugBox("000", 0));
            packs.Add(0, new DrugBox("000", 0));
            packs.Add(0, new DrugBox("000", 0));
            packs.Add(0, new DrugBox("000", 0));
            packs.Add(0, new DrugBox("000", 0));
            packs.Add(0, new DrugBox("000", 0));
            packs.Add(0, new DrugBox("000", 0));
            packs.Add(0, new DrugBox("000", 0));
            packs.Add(0, new DrugBox("000", 0));
            packs.Add(0, new DrugBox("000", 0));
            packs.Add(0, new DrugBox("000", 0));
        }
Beispiel #2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            this.btnStart.Enabled = false;

            packs = new DrugPacks(new PackRate(this.cmbPackRate.Text));

            #region 准备串行端口
            if (this.cmbPort1st.Text != string.Empty) ports["1st"].PortName = this.cmbPort1st.Text;
            if (this.cmbPort2nd.Text != string.Empty) ports["2nd"].PortName = this.cmbPort2nd.Text;
            if (this.cmbPort3rd.Text != string.Empty) ports["3rd"].PortName = this.cmbPort3rd.Text;
            foreach (SerialPort port in ports.Values)
            {
                if (port.PortName != string.Empty)
                {
                    port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
                    port.Open();
                }
            }
            #endregion
        }