setYPosition() public method

public setYPosition ( int y ) : void
y int
return void
コード例 #1
0
        public void updateMachineStatus()
        {
            ns.Write(Encoding.ASCII.GetBytes(getStatusCommand), 0, getStatusCommand.Length);
            ns.Flush();

            byte[] data       = new byte[256];
            int    recv       = ns.Read(data, 0, data.Length);
            string stringData = Encoding.ASCII.GetString(data, 0, recv);

            string[] attributes = stringData.Split('_');

            if (stringData.Equals(""))
            {
                status.setCurrentState(MachineStatus.States.HALT);
                eStop();
            }

            // We override the machine's state without a validity check because the machine is holding the true state.
            // If the machine advances in state twice between updates, validation on this side will fail, so we use
            // the machine's reported value.
            MachineStatus.States state = (MachineStatus.States)Enum.Parse(typeof(MachineStatus.States), attributes[0]);
            status.setCurrentState(state);

            // We invert the arduino's optic sensor logic here - if arduino returned 0, the sensor is occluded
            // and an arrow is present.
            status.setFOptic(attributes[1] == "0");
            status.setROptic(attributes[2] == "0");

            status.setMoving(attributes[3] != "0");

            status.setXPosition(int.Parse(attributes[4]));
            status.setYPosition(int.Parse(attributes[5]));

            Console.WriteLine(stringData);
        }