コード例 #1
0
 private void Validate(OutputReport output)
 {
     if (output.WorkX > 9999.999m || output.WorkX < -9999.999m)
     {
         throw new Exception("X value out of range");
     }
     if (output.WorkY > 9999.999m || output.WorkY < -9999.999m)
     {
         throw new Exception("Y value out of range");
     }
     if (output.WorkZ > 9999.999m || output.WorkZ < -9999.999m)
     {
         throw new Exception("Z value out of range");
     }
 }
コード例 #2
0
        public void Write(OutputReport output)
        {
            Validate(output);
            var workXBytes                = GetBytes(output.WorkX);
            var workYBytes                = GetBytes(output.WorkY);
            var workZBytes                = GetBytes(output.WorkZ);
            var machineXBytes             = GetBytes(output.MachineX);
            var machineYBytes             = GetBytes(output.MachineY);
            var machineZBytes             = GetBytes(output.MachineZ);
            var feedrateOverrideBytes     = GetBytes(output.FeedrateOverride);
            var spindleSpeedOverrideBytes = GetBytes(output.SpindleSpeedOverride);
            var feedrateBytes             = GetBytes(output.Feedrate);
            var spindleSpeedBytes         = GetBytes(output.SpindleSpeed);

            outputDevice.WriteFeature(new byte[] { 0x06, 0xFE, 0xFD, 0xFF, workXBytes[1], workXBytes[0], workXBytes[3], workXBytes[2] });
            outputDevice.WriteFeature(new byte[] { 0x06, workYBytes[1], workYBytes[0], workYBytes[3], workYBytes[2], workZBytes[1], workZBytes[0], workZBytes[3] });
            outputDevice.WriteFeature(new byte[] { 0x06, workZBytes[2], machineXBytes[1], machineXBytes[0], machineXBytes[3], machineXBytes[2], machineYBytes[1], machineYBytes[0] });
            outputDevice.WriteFeature(new byte[] { 0x06, machineYBytes[3], machineYBytes[2], machineZBytes[1], machineZBytes[0], machineZBytes[3], machineZBytes[2], feedrateOverrideBytes[1] });
            outputDevice.WriteFeature(new byte[] { 0x06, feedrateOverrideBytes[0], spindleSpeedOverrideBytes[1], spindleSpeedOverrideBytes[0], feedrateBytes[1], feedrateBytes[0], spindleSpeedBytes[1], spindleSpeedBytes[0] });
            outputDevice.WriteFeature(new byte[] { 0x06, (byte)((byte)output.StepMultiplier | (byte)output.ScreenGlyph), (byte)output.Misc, 0x00, 0x00, 0x00, 0x00, 0x00 });
        }