Esempio n. 1
0
    void OnGUI()
    {
        float oldValue = newValue;

        newValue = LabelSlider(new Rect(xPos, yPos, xSize, ySize), newValue, fontSize, fontColor);

        // store action trace
        if (newValue != oldValue &&
            GameState.Singleton.TimeUsed - prevTime > timeDelta)
        {
            ParamChange pch = new ParamChange(
                GameState.Singleton.TimeUsed,
                ptype,
                entity,
                newValue);
            Debug.Log(pch.ToString());
            GameState.Singleton.actionTrace.Add(pch);

            prevTime = GameState.Singleton.TimeUsed;
        }

        foreach (MonoBehaviour p in paramArray)
        {
            if (p == null)
            {
                continue;
            }
            SetParameter(ptype, p, newValue);
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Adds components to be manipulated.
    /// Needs to be in Start so every object has been added to scene already.
    /// </summary>
    void Start()
    {
        newValue = (paramMax - paramMin) / 2;
        //Debug.Log("[ParameterSliderSelect] initializing value: " + newValue);

        GameObject[] objs = GameObject.FindGameObjectsWithTag(entity);
        Debug.Log("[ParameterSliderSelect] objects found: ");
        foreach (GameObject o in objs)
        {
//            Debug.Log("[ParameterSliderSelect] object " + o.name);
//            Debug.Log("[ParameterSliderSelect] parameter type " + ptype);
            if (ptype == ParamType.BULLET_SIZE ||
                ptype == ParamType.BULLET_SPEED ||
                ptype == ParamType.FIRERATE)
            {
                paramArray.AddRange(o.GetComponents <Shoot>());
            }
            else if (
                ptype == ParamType.MOVE_DRAG ||
                ptype == ParamType.MOVE_FORCE)
            {
                paramArray.AddRange(o.GetComponents <MoveByKeyForce>());
            }
        }

        ParamChange pch = new ParamChange(
            GameState.Singleton.TimeUsed,
            ptype,
            entity,
            newValue);

        GameState.Singleton.actionTrace.Add(pch);
    }
Esempio n. 3
0
        /// <summary>
        ///
        ///  |Advise Mask        |Description                                        |int value(lParam)|
        ///  |:-----------------:|:-------------------------------------------------:|:---------------:|
        ///  |DisplaySetting     | Display settings have changed                     |  1              |
        ///  |ExternalStart      | Acquisition has been started externall            |  1048608        |
        ///  |CalibrationChange  | A calibration parameter has changed               |  4              |
        ///  |AcquireStart       | Acquisition has been started                      |  134217728      |
        ///  |AcquireDone        | Acquisition has been stopped                      | -2147483648     |
        ///  |DataChange         | Data has been changes (occurs after AcquireClear) |  67108864       |
        ///  |HardwareError      | Hardware error                                    |  2097152        |
        ///  |HardwareChange     | Hardware setting has changed                      |  268435456      |
        ///  |HardwareAttention  | Hardware is requesting attention                  |  16777216       |
        ///  |DeviceUpdate       | Device settings have been updated                 |  8388608        |
        ///  |SampleChangerSet   | Sample changer set                                |  1073741824     |
        ///  |SampleChangeAdvance| Sample changer advanced                           |  4194304        |

        /// </summary>
        /// <param name="message">DeviceMessages type from CanberraDeviceAccessLib</param>
        /// <param name="wParam">The first parameter of information associated with the message.</param>
        /// <param name="lParam">The second parameter of information associated with the message</param>
        private void DeviceMessagesHandler(int message, int wParam, int lParam)
        {
            string response     = "";
            bool   isForCalling = true;

            try
            {
                if ((int)AdviseMessageMasks.amAcquireDone == lParam && !IsPaused)
                {
                    //if (Math.Abs(Counts - ElapsedRealTime) >= 10) return;
                    if (ElapsedRealTime < 10)
                    {
                        return;
                    }

                    Report.Notify(new DetectorMessage(Codes.INFO_DET_ACQ_DONE)); //$"Has got message AcquireDone."));
                    response = "Acquire has done";
                    Status   = DetectorStatus.ready;
                    if (AcquisitionStartDateTime.HasValue)
                    {
                        CurrentMeasurement.DateTimeStart  = AcquisitionStartDateTime;
                        CurrentMeasurement.DateTimeFinish = AcquisitionStartDateTime.Value.AddSeconds(ElapsedRealTime);
                    }
                    AcquireDone?.Invoke(this);
                }

                if ((int)AdviseMessageMasks.amAcquireStart == lParam)
                {
                    Report.Notify(new DetectorMessage(Codes.INFO_DET_ACQ_START)); //$"Has got message amAcquireStart."));
                    response = "Acquire has start";
                    Status   = DetectorStatus.busy;
                    AcquireStart?.Invoke(this);
                }

                if ((int)AdviseMessageMasks.amHardwareError == lParam)
                {
                    Status       = DetectorStatus.error;
                    ErrorMessage = $"{_device.Message((MessageCodes)lParam)}";
                    response     = ErrorMessage;
                    Report.Notify(new DetectorMessage(Codes.ERR_DET_ACQ_HRDW)
                    {
                        DetailedText = ErrorMessage
                    });
                    HardwareError?.Invoke(this);
                }
                if ((int)AdviseMessageMasks.amAcquisitionParamChange == lParam)
                {
                    response     = "Device ready to use!";
                    isForCalling = false;
                    ParamChange?.Invoke(this);
                }

                if (isForCalling)
                {
                    AcquiringStatusChanged?.Invoke(this, new DetectorEventsArgs {
                        Message = response, AcquireMessageParam = lParam, Name = this.Name, Status = this.Status
                    });
                }
            }
            catch (Exception ex)
            {
                Report.Notify(new DetectorMessage(Codes.ERR_DET_MSG_UNREG)
                {
                    DetailedText = ex.ToString()
                });
            }
        }
Esempio n. 4
0
 protected void OnParamChange(bool lineAccelChange, bool lineDecelChange, bool lineSpeedChange, bool pivotAccelChange, bool pivotDecelChange, bool pivotSpeedChange)
 {
     ParamChange?.Invoke(lineAccelChange, lineDecelChange, lineSpeedChange, pivotAccelChange, pivotDecelChange, pivotSpeedChange);
 }