コード例 #1
0
        /// <summary>
        /// Test whether the given connection is a link with monochromator controller
        /// </summary>
        /// <param name="connection">Connection</param>
        /// <returns>true if connection is a link with monochromator controller, false otherwise</returns>
        private static bool IsMonochromator(SerialConnection connection)
        {
            // Ping controller
            connection.Send((uint)PacketHeader.Ping);

            // Parse response
            var responseAsBytes = connection.Read(sizeof(PacketHeader));
            var response        = BitConverter.ToUInt32(responseAsBytes);

            return(response == PingResponse);
        }
コード例 #2
0
        /// <summary>
        /// Wait calibration end
        /// </summary>
        /// <param name="controller">Controller connection</param>
        private static void WaitEndFlag(SerialConnection controller)
        {
            var response = (CalibratePacketHeader)BitConverter.ToUInt32(controller.Read(sizeof(CalibratePacketHeader)));

            switch (response)
            {
            case CalibratePacketHeader.Start:
            case CalibratePacketHeader.InvalidArguments:
                throw new InvalidOperationException($"Invalid header received: {response}");

            case CalibratePacketHeader.End:
                break;

            default:
                throw new UnknownEnumValueException <CalibratePacketHeader>(response);
            }
        }