private void button1_Click(object sender, EventArgs e) { byte commandAddr = (byte)((comboBox1.Text == "X轴") ? 0x00 : 0x01); bool pos = (comboBox2.Text == "正向") ? true : false; CmdMove ci = new CmdMove(); addrc = ci.GetOneStepCmd(commandAddr, pos); richTextBox1.Text = DataChange.byteToHexStr(addrc); }
public void GetOneStepCmdTest() { //AA 06 01 B0 00 01 B6 //AA 06 01 B0 00 81 36 CmdMove cf = new CmdMove(); byte[] ret = cf.GetOneStepCmd(0x00, true); Assert.AreEqual(ret.Count(), 7); Assert.AreEqual(ret[6], 0xB6); Assert.AreEqual(ret[0], 0xAA); Assert.AreEqual(ret[1], 0x06); Assert.AreEqual(ret[2], 0x01); Assert.AreEqual(ret[3], 0xB0); byte[] ret1 = cf.GetOneStepCmd(0x00, false); Assert.AreEqual(ret1.Count(), 7); Assert.AreEqual(ret1[6], 0x36); Assert.AreEqual(ret1[0], 0xAA); Assert.AreEqual(ret1[1], 0x06); Assert.AreEqual(ret1[2], 0x01); Assert.AreEqual(ret1[3], 0xB0); }