예제 #1
0
        public void Send()
        {
            int Temp = 0;

            cRelayHi = Prod.mf.Sections.SectionHi();
            cRelayLo = Prod.mf.Sections.SectionLo();

            if (Prod.mf.Sections.SwitchOn(Switches.Auto))
            {
                // send target rate
                Temp       = (int)(Prod.TargetUPM() * 100.0);
                cRateSetHi = (byte)(Temp >> 8);
                cRateSetLo = (byte)Temp;
            }
            else
            {
                // send manual rate factor
                Temp       = (int)(Prod.ManualRateFactor * 100.0);
                cRateSetHi = (byte)(Temp >> 8);
                cRateSetLo = (byte)Temp;
            }

            Temp       = (int)(Prod.FlowCal * 100.0);
            cFlowCalHi = (byte)(Temp >> 8);
            cFlowCalLo = (byte)Temp;

            // command byte
            cCommand = 0;
            if (Prod.EraseApplied)
            {
                cCommand |= 0b00000001;
            }
            Prod.EraseApplied = false;

            switch (Prod.ValveType)
            {
            case 1:
                cCommand &= 0b11111011;     // clear bit 2
                cCommand |= 0b00000010;     // set bit 1
                break;

            case 2:
                cCommand |= 0b00000100;     // set bit 2
                cCommand &= 0b11111101;     // clear bit 1
                break;

            case 3:
                cCommand |= 0b00000110;     // set bit 2 and 1
                break;

            default:
                cCommand &= 0b11111001;     // clear bit 2 and 1
                break;
            }

            if (Prod.SimulationType != SimType.None)
            {
                cCommand |= 0b00001000;
            }
            else
            {
                cCommand &= 0b11110111;
            }

            if (Prod.UseVCN)
            {
                cCommand |= 0b00010000;
            }
            else
            {
                cCommand &= 0b11101111;
            }

            if (Prod.mf.Sections.SwitchOn(Switches.Auto))
            {
                cCommand |= 0b00100000;
            }

            if (Prod.SimulationType == SimType.VirtualNano)
            {
                Prod.VirtualNano.ReceiveSerial(Data());
            }
            else
            {
                Prod.mf.SendSerial(Data());
                Prod.mf.UDPnetwork.SendUDPMessage(Data());
            }
        }