⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 synopsys for the students in order to guide them
💻 CS
📖 第 1 页 / 共 2 页
字号:
            }
            if (s.Equals("Bulb Off"))
            {
                BulbOff();


            }

            if (s.Equals("Speed Up"))
            {
                if (index < 4)
                    index++;
                fan = ar[index];
                PortAccess.Output(data,bulb|fan);
                
            }
            if (s.Equals("Speed Down"))
            {
                if (index > 0)
                    index--;
                fan = ar[index];
                PortAccess.Output(data, bulb | fan);
                
            }
            if (s.Equals("Fan Off"))
            {
                
                fan = 0;
                index = -1;
                PortAccess.Output(data, bulb | fan);
                
            }
            if (s.Equals("Fan On"))
            {

                fan = 1;
                index = 0;
                PortAccess.Output(data, bulb | fan);

            }
            
            
            if(s.Equals("Hori Clk"))
            {
                Hori_Clock();
            }
            if(s.Equals("Hori Anti"))
            {
                Hori_Anti();
            }
            if(s.Equals("Vert Clk"))
            {Verti_Clock();
            }
            if(s.Equals("Vert Anti"))
            {
                Verti_Anti();
            }
            if (s.Equals("Move"))
            {
                Move_Forward();
            }
            if (s.Equals("Stop"))
            {
                PortAccess.Output(control,255);
            }
            if (s.Equals("Both Clk"))
            {
                Both_Clock();
            }
            if (s.Equals("Both Anti"))
            {
                Both_Anti();
            }
            if (s.Equals("Top Anti Hori Clk"))
            {
                Top_Anti_Hori_Clk();
            }
            
            if (s.Equals("Top Clk Hori Anti"))
            {
                Top_Clk_Hori_Anti();
            }


        }
        private void oGsmModem_NewMessageReceived(ATSMS.NewMessageReceivedEventArgs e) 
        {
       
       // txtMsg.Text = "Message from " + e.MSISDN + ". Message - " + e.TextMessage ;
           // MessageBox.Show(e.TextMessage);
            Information.Message = e.TextMessage;
            Information.MobNo = e.MSISDN;
            Analyze();


        }
    
        void GetDetails()
        {
            int BattLevel = -1;
            string OwnNumber = "";

            cmdMdmRefresh.Text = "Please wait...";
            cmdMdmRefresh.Enabled = false;

            lblManufacturer.Enabled = false;
            lblModel.Enabled = false;
            lblRevision.Enabled = false;
            lblIMEI.Enabled = false;
            lblIMSI.Enabled = false;
            lblBattery.Enabled = false;
            lblOwnNum.Enabled = false;

            lblManufacturer.Text = "Reading... Please wait...";
            lblModel.Text = "Reading... Please wait...";
            lblRevision.Text = "Reading... Please wait...";
            lblIMEI.Text = "Reading... Please wait...";
            lblIMSI.Text = "Reading... Please wait...";
            lblBattery.Text = "Reading... Please wait...";
            lblOwnNum.Text = "Reading... Please wait...";

            System.Windows.Forms.Application.DoEvents();

            SetCommParameters();

            try
            {
                //Retrieve modem Manufacturer information
                lblManufacturer.Text = objSMS.Manufacturer;
            }
            catch (mCore.GeneralException ex)
            {
                MessageBox.Show(ex.Message, strMyAppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            lblManufacturer.Enabled = true;
            System.Windows.Forms.Application.DoEvents();

            try
            {
                //Retrieve modem Model information
                lblModel.Text = objSMS.Model;
            }
            catch (mCore.GeneralException ex)
            {
                MessageBox.Show(ex.Message, strMyAppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            lblModel.Enabled = true;
            System.Windows.Forms.Application.DoEvents();

            try
            {
                //Retrieve firmware Revision information
                lblRevision.Text = objSMS.Revision;
            }
            catch (mCore.GeneralException ex)
            {
                MessageBox.Show(ex.Message, strMyAppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            lblRevision.Enabled = true;
            System.Windows.Forms.Application.DoEvents();

            try
            {
                //Retrieve modem IMEI information
                lblIMEI.Text = objSMS.IMEI;
            }
            catch (mCore.GeneralException ex)
            {
                MessageBox.Show(ex.Message, strMyAppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            lblIMEI.Enabled = true;
            System.Windows.Forms.Application.DoEvents();

            try
            {
                //Retrieve IMSI information
                lblIMSI.Text = objSMS.IMSI;
            }
            catch (mCore.GeneralException ex)
            {
                MessageBox.Show(ex.Message, strMyAppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            lblIMSI.Enabled = true;
            System.Windows.Forms.Application.DoEvents();

            try
            {
                //Retrieve battery charge level
                //If battery charge level reading is not supported,
                //the property will return -1
                BattLevel = objSMS.BatteryLevel;
            }
            catch (mCore.GeneralException ex)
            {
                MessageBox.Show(ex.Message, strMyAppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (BattLevel > 0)
            {
                lblBattery.Text = BattLevel.ToString() + "%";
            }
            else
            {
                lblBattery.Text = "Unknown";
            }

            lblBattery.Enabled = true;
            System.Windows.Forms.Application.DoEvents();

            try
            {
                //Retrieve MSISDN of the SIM card used
                //If MSISDN reading is not supported,
                //the property will return blank string
                OwnNumber = objSMS.OwnNumber;
            }
            catch (mCore.GeneralException ex)
            {
                MessageBox.Show(ex.Message, strMyAppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (OwnNumber.Length > 0)
            {
                lblOwnNum.Text = OwnNumber;
            }
            else
            {
                lblOwnNum.Text = "Unknown";
            }

            lblOwnNum.Enabled = true;

            cmdMdmRefresh.Text = "Refresh";
            cmdMdmRefresh.Enabled = true;
        }

        private void cmdMdmRefresh_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                oGsmModem.Dial(txtPhoneNumber.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            oGsmModem.Answer();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            oGsmModem.HangUp();
            
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        int bulb = 0;
        int fan = 0;
        public int control = 890, data = 888, delay;
        private int[] ar = new int[] { 1, 2, 4, 8, 16 };
        int index = 0;

        void SpeedUp()
        {
            try
            {
//                label1.Text = index.ToString();
                fan = ar[index];
                PortAccess.Output(data, (bulb | fan));
                if ((index) < 5)
                    index++;
            }
            catch (Exception ex)
            {
            }
        }

        void SpeedDown()
        {
            try
            {
                //label1.Text = index.ToString();
                fan = ar[--index];
                PortAccess.Output(data, (bulb | fan));
                if (index < 0)
                    index = 0;
            }
            catch (Exception ex)
            {
            }

        }
        void BulbOn()
        {
            bulb = 32;
            PortAccess.Output(data, (bulb | fan));
        }
        void BulbOff()
        {
            bulb = 0;
            PortAccess.Output(data, (bulb | fan));
        }
        public class PortAccess
        {
            /* For sending to the ports */
            [DllImport("c:\\SmsDevice\\inpout32.dll", EntryPoint = "Out32")]
            public static extern void Output(int adress, int value);
            /* For receiving from the ports */
            [DllImport("c:\\SmsDevice\\inpout32.dll", EntryPoint = "Inp32")]
            public static extern int Input(int adress);
        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -