コード例 #1
0
 /// <summary>
 /// Set the boolean value of a specified flag.
 /// </summary>
 /// <param name="flag"></param>
 /// <param name="state"></param>
 internal void SetFlagValue(DeviceStatusFlags flag, bool state)
 {
     if (state)
     {
         _value |= (int)flag;
     }
     else
     {
         _value &= ~(int)flag;
     }
 }
コード例 #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            int indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            EditorGUI.BeginProperty(position, label, property);

            GUI.Box(position, GUIContent.none);
            Rect line = new Rect(
                position.x,
                position.y + TopPadding,
                position.width,
                WearableConstants.SingleLineHeight);


            var          statusValueProp = property.FindPropertyRelative(StatusValuesField);
            DeviceStatus status          = statusValueProp.intValue;

            for (int i = 0; i < Flags.Length; i++)
            {
                DeviceStatusFlags flag = Flags[i];
                if (flag == DeviceStatusFlags.None ||
                    flag == DeviceStatusFlags.SensorServiceSuspended)
                {
                    continue;
                }

                using (new EditorGUI.DisabledScope(flag == DeviceStatusFlags.SensorServiceSuspended))
                {
                    bool value = EditorGUI.Toggle(
                        line,
                        flag.ToString(),
                        status.GetFlagValue(flag));

                    status.SetFlagValue(flag, value);
                }

                line.y += WearableConstants.SingleLineHeight;
            }
            statusValueProp.intValue = status;

            EditorGUI.EndProperty();
            property.serializedObject.ApplyModifiedProperties();
            EditorGUI.indentLevel = indent;
        }
コード例 #3
0
 /// <summary>
 /// Simulate the device status of the virtual device. Be aware that status is cleared upon connection.
 /// </summary>
 public void SetDeviceStatusFlagState(DeviceStatusFlags flag, bool state)
 {
     _dynamicDeviceInfo.deviceStatus.SetFlagValue(flag, state);
 }
コード例 #4
0
 /// <summary>
 /// Return the boolean value of a specified flag.
 /// </summary>
 /// <param name="flag"></param>
 /// <returns></returns>
 internal bool GetFlagValue(DeviceStatusFlags flag)
 {
     return((_value & (int)flag) != 0);
 }
コード例 #5
0
ファイル: SetConfiguration.cs プロジェクト: intvsteve/VINTage
 /// <summary>
 /// Creates an instance of the SetConfiguration command.
 /// </summary>
 /// <param name="statusFlags">The device configuration flags to set.</param>
 /// <returns>A new instance of the command.</returns>
 public static SetConfiguration Create(DeviceStatusFlags statusFlags)
 {
     return(new SetConfiguration(statusFlags));
 }
コード例 #6
0
ファイル: SetConfiguration.cs プロジェクト: intvsteve/VINTage
 private SetConfiguration(DeviceStatusFlags statusFlags)
     : base(ProtocolCommandId.SetConfiguration, DefaultResponseTimeout, statusFlags.Lo.ToConfigurationFlags(), statusFlags.Hi.GetLowBits(), statusFlags.Hi.GetHighBits())
 {
 }
コード例 #7
0
            protected override int ConvertDeviceStatusFlagsToValue(DeviceStatusFlags currentConfiguration)
            {
                var value = (int)(currentConfiguration & FeatureFlagsMask).Lo;

                return(value);
            }
コード例 #8
0
            public static DeviceStatusFlags CreateFlagsMask(int forFlags)
            {
                var flagsMask = new DeviceStatusFlags((DeviceStatusFlagsLo)forFlags, (DeviceStatusFlagsHi)forFlags);

                return(flagsMask);
            }
コード例 #9
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            int indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            EditorGUI.BeginProperty(position, label, property);
            Rect line = new Rect(
                position.x,
                position.y,
                position.width,
                WearableEditorConstants.SINGLE_LINE_HEIGHT);

            // Device Status
            EditorGUI.LabelField(line, DEVICE_STATUS_HEADING);
            line.y += WearableEditorConstants.SINGLE_LINE_HEIGHT;

            Rect box = new Rect(
                line.x,
                line.y,
                line.width,
                line.height * (WearableConstants.DEVICE_STATUS_FLAGS.Length - 2));                 // Flag count less "None" and "Suspended"

            GUI.Box(box, GUIContent.none);

            var          statusValueProp = property.FindPropertyRelative(STATUS_VALUES_FIELD);
            DeviceStatus status          = statusValueProp.intValue;

            for (int i = 0; i < WearableConstants.DEVICE_STATUS_FLAGS.Length; i++)
            {
                DeviceStatusFlags flag = WearableConstants.DEVICE_STATUS_FLAGS[i];
                if (flag == DeviceStatusFlags.None ||
                    flag == DeviceStatusFlags.SensorServiceSuspended)
                {
                    continue;
                }

                using (new EditorGUI.DisabledScope(flag == DeviceStatusFlags.SensorServiceSuspended))
                {
                    bool value = EditorGUI.Toggle(
                        line,
                        flag.ToString(),
                        status.GetFlagValue(flag));

                    status.SetFlagValue(flag, value);
                }

                line.y += WearableEditorConstants.SINGLE_LINE_HEIGHT;
            }
            statusValueProp.intValue = status;


            // Transmission period
            // No-op

            // ANR header
            line.y += WearableEditorConstants.SINGLE_LINE_HEIGHT * 0.5f;
            EditorGUI.LabelField(line, ANR_HEADING);
            line.y += WearableEditorConstants.SINGLE_LINE_HEIGHT;
            box     = new Rect(
                line.x,
                line.y,
                line.width,
                WearableEditorConstants.SINGLE_LINE_HEIGHT * (WearableConstants.ACTIVE_NOISE_REDUCTION_MODES.Length + 1));
            GUI.Box(box, GUIContent.none);


            // ANR current mode (read-only)
            using (new EditorGUI.DisabledScope(true))
            {
                var anrModeProperty = property.FindPropertyRelative(CURRENT_ANR_MODE_FIELD);
                var anrMode         = (ActiveNoiseReductionMode)anrModeProperty.intValue;
                EditorGUI.LabelField(line, CURRENT_ANR_MODE_LABEL, anrMode.ToString());
                line.y += WearableEditorConstants.SINGLE_LINE_HEIGHT;
            }

            // ANR available modes
            EditorGUI.LabelField(line, AVAILABLE_ANR_MODES_HEADING);
            line.y += WearableEditorConstants.SINGLE_LINE_HEIGHT;

            EditorGUI.indentLevel++;
            var availableAnrModesProperty = property.FindPropertyRelative(AVAILABLE_ANR_MODES_FIELD);
            int oldAnrModes = availableAnrModesProperty.intValue;
            int newAnrModes = 0;

            for (int i = 0; i < WearableConstants.ACTIVE_NOISE_REDUCTION_MODES.Length; i++)
            {
                ActiveNoiseReductionMode mode = WearableConstants.ACTIVE_NOISE_REDUCTION_MODES[i];

                if (mode == ActiveNoiseReductionMode.Invalid)
                {
                    continue;
                }

                int  flag     = (1 << (int)mode);
                bool selected = EditorGUI.Toggle(line, mode.ToString(), (flag & oldAnrModes) != 0);
                line.y += WearableEditorConstants.SINGLE_LINE_HEIGHT;
                if (selected)
                {
                    newAnrModes |= flag;
                }
            }

            EditorGUI.indentLevel--;

            if (newAnrModes != oldAnrModes)
            {
                availableAnrModesProperty.intValue = newAnrModes;
            }

            // CNC header
            line.y += WearableEditorConstants.SINGLE_LINE_HEIGHT * 0.5f;
            EditorGUI.LabelField(line, CNC_HEADING);
            line.y += WearableEditorConstants.SINGLE_LINE_HEIGHT;
            box     = new Rect(
                line.x,
                line.y,
                line.width,
                WearableEditorConstants.SINGLE_LINE_HEIGHT * 3);
            GUI.Box(box, GUIContent.none);

            using (new EditorGUI.DisabledScope(true))
            {
                // CNC Level (read-only)
                var cncLevelProperty = property.FindPropertyRelative(CNC_LEVEL_FIELD);
                EditorGUI.LabelField(line, CNC_LEVEL_LABEL_TEXT, cncLevelProperty.intValue.ToString());
                line.y += WearableEditorConstants.SINGLE_LINE_HEIGHT;

                // CNC Enabled (read-only)
                var cncEnabledProperty = property.FindPropertyRelative(CNC_ENABLED_FIELD);
                EditorGUI.Toggle(line, CNC_ENABLED_LABEL, cncEnabledProperty.boolValue);
                line.y += WearableEditorConstants.SINGLE_LINE_HEIGHT;
            }

            // Total CNC levels
            var totalCncLevelsProperty = property.FindPropertyRelative(TOTAL_CNC_LEVELS_FIELD);

            EditorGUI.PropertyField(line, totalCncLevelsProperty, _totalCncLevelsLabel);
            line.y += WearableEditorConstants.SINGLE_LINE_HEIGHT;
            if (totalCncLevelsProperty.intValue < 0)
            {
                totalCncLevelsProperty.intValue = 0;
            }

            EditorGUI.EndProperty();
            property.serializedObject.ApplyModifiedProperties();
            EditorGUI.indentLevel = indent;
        }
コード例 #10
0
ファイル: DeviceViewModel.cs プロジェクト: intvsteve/VINTage
        private bool ErrorHandler(DeviceStatusFlags deviceStatusFlags, ProtocolCommandId commandId, string errorMessage, System.Exception exception)
        {
            bool handled        = false;
            var  title          = string.Empty;
            var  messageFormat  = string.Empty;
            var  showMessageBox = false;

            switch (commandId)
            {
            case ProtocolCommandId.SetConfiguration:
                handled        = true;
                showMessageBox = handled;
                switch (deviceStatusFlags.Lo)
                {
                case DeviceStatusFlagsLo.IntellivisionIIStatusMask:
                    title         = Resources.Strings.SetConfigurationCommand_IntellivisionII_Failed_Title;
                    messageFormat = Resources.Strings.SetConfigurationCommand_IntellivisionII_Failed_Message_Format;
                    break;

                case DeviceStatusFlagsLo.EcsStatusMask:
                    title         = Resources.Strings.SetConfigurationCommand_Ecs_Failed_Title;
                    messageFormat = Resources.Strings.SetConfigurationCommand_Ecs_Failed_Message_Format;
                    break;

                case DeviceStatusFlagsLo.ShowTitleScreenMask:
                    title         = Resources.Strings.SetConfigurationCommand_ShowTitleScreen_Failed_Title;
                    messageFormat = Resources.Strings.SetConfigurationCommand_ShowTitleScreen_Failed_Message_Format;
                    break;

                case DeviceStatusFlagsLo.SaveMenuPositionMask:
                    title         = Resources.Strings.SetConfigurationCommand_SaveMenuPosition_Failed_Title;
                    messageFormat = Resources.Strings.SetConfigurationCommand_SaveMenuPosition_Failed_Message_Format;
                    break;

                case DeviceStatusFlagsLo.BackgroundGC:
                    title         = Resources.Strings.SetConfigurationCommand_BackgroundGC_Failed_Title;
                    messageFormat = Resources.Strings.SetConfigurationCommand_BackgroundGC_Failed_Message_Format;
                    break;

                case DeviceStatusFlagsLo.Keyclicks:
                    title         = Resources.Strings.SetConfigurationCommand_Keyclicks_Failed_Title;
                    messageFormat = Resources.Strings.SetConfigurationCommand_Keyclicks_Failed_Message_Format;
                    break;

                case DeviceStatusFlagsLo.ZeroRamBeforeLoad:
                    title         = Resources.Strings.SetConfigurationCommand_RandomizeLtoFlashRam_Failed_Title;
                    messageFormat = Resources.Strings.SetConfigurationCommand_RandomizeLtoFlashRam_Failed_Message_Format;
                    break;
                }
                break;

            case ProtocolCommandId.DownloadCrashLog:
                handled        = true;
                showMessageBox = handled;
                title          = Resources.Strings.GetErrorAndCrashLogs_Failed_Title;
                messageFormat  = Resources.Strings.GetErrorAndCrashLogs_Failed_Message_Format;
                break;

            case ProtocolCommandId.UnknownCommand:
                handled = true;
                var application = SingleInstanceApplication.Instance;
                if ((application != null) && (application.MainWindow != null))
                {
                    var portName = "<null>";
                    if ((Device != null) && (Device.Port != null))
                    {
                        portName = Device.Port.Name;
                    }
                    var message = string.Format(CultureInfo.CurrentCulture, Resources.Strings.DeviceValidation_Failed_Message_Format, portName);
                    var dialog  = INTV.Shared.View.ReportDialog.Create(Resources.Strings.DeviceValidation_Failed_Title, message);
                    dialog.ReportText                = errorMessage;
                    dialog.ShowSendEmailButton       = false;
                    dialog.ShowCopyToClipboardButton = false;
                    dialog.BeginInvokeDialog(Resources.Strings.OK, null);
                }
                break;

            default:
                break;
            }
            if (showMessageBox && handled)
            {
                var message = string.Format(CultureInfo.CurrentCulture, messageFormat, errorMessage);
                OSMessageBox.Show(message, title, SingleInstanceApplication.SharedSettings.ShowDetailedErrors ? exception : null, (r) => { });
            }
            return(handled);
        }