コード例 #1
0
ファイル: Form1.cs プロジェクト: dspp779/MIRLE_LED
        private void btnSetTime_Click(object sender, System.EventArgs e)
        {
            InitComm();
            int nRet;

            byte[]   byTimeInfo = new byte[7];
            DateTime curTime;

            curTime       = DateTime.Now;
            byTimeInfo[0] = Convert.ToByte(curTime.Second);
            byTimeInfo[1] = Convert.ToByte(curTime.Minute);
            byTimeInfo[2] = Convert.ToByte(curTime.Hour);
            byTimeInfo[3] = Convert.ToByte(curTime.DayOfWeek);
            byTimeInfo[4] = Convert.ToByte(curTime.Day);
            byTimeInfo[5] = Convert.ToByte(curTime.Month);
            byTimeInfo[6] = Convert.ToByte(curTime.Year - 2000);

            if (m_nCommType == 1)              //網口
            {
                nRet = CP5200.CP5200_Net_SetTime(Convert.ToByte(m_cmbCardID.SelectedIndex + 1), byTimeInfo);
            }
            else             //串口
            {
                nRet = CP5200.CP5200_RS232_SetTime(Convert.ToByte(m_cmbCardID.SelectedIndex + 1), byTimeInfo);
            }

            if (nRet >= 0)
            {
                MessageBox.Show("Successful");
            }
            else
            {
                MessageBox.Show("Fail");
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: bitembassy/bitcoin-ticker
        private void btnSetTime_Click(object sender, EventArgs e)
        {
            int ret = 0;

            byte[]   byTime = new byte[7];
            DateTime curTime;

            curTime   = DateTime.Now;
            byTime[0] = Convert.ToByte(curTime.Second);
            byTime[1] = Convert.ToByte(curTime.Minute);
            byTime[2] = Convert.ToByte(curTime.Hour);
            byTime[3] = Convert.ToByte(curTime.DayOfWeek);
            byTime[4] = Convert.ToByte(curTime.Day);
            byTime[5] = Convert.ToByte(curTime.Month);
            byTime[6] = Convert.ToByte(curTime.Year - 2000);

            if (1 == InitComm())
            {
                if (0 == m_nCommType)
                {
                    ret = CP5200.CP5200_RS232_SetTime(Convert.ToByte(m_nCardID), byTime);
                }
                else
                {
                    ret = CP5200.CP5200_Net_SetTime(Convert.ToByte(m_nCardID), byTime);
                }

                if (0 <= ret)
                {
                    MessageBox.Show("Successful");
                }
                else
                {
                    MessageBox.Show("Fail");
                }
            }
        }