Пример #1
0
        void AnalogMeasurementHandler(AnalogData measurement)
        {
            //Tracer.Trace("TrackRoamerBrickProximityBoardService::PotMeasurementHandler() analogValue1=" + measurement.analogValue1);

            try
            {
                _state.MostRecentAnalogData = new AnalogDataDssSerializable()
                {
                    analogValue1 = measurement.analogValue1, TimeStamp = new DateTime(measurement.TimeStamp)
                };
                //
                // Inform subscribed services that the state has changed.
                //
                _submgrPort.Post(new submgr.Submit(_state, DsspActions.ReplaceRequest));

                UpdateAnalogData usd = new UpdateAnalogData();
                usd.Body = _state.MostRecentAnalogData;

                base.SendNotification <UpdateAnalogData>(_submgrPort, usd);
            }
            catch (Exception e)
            {
                _state.LinkState = "Error while receiving POT Data";
                LogError(e);
            }
        }
Пример #2
0
        /// <summary cref="IEncodeable.IsEqual(IEncodeable)" />
        public virtual bool IsEqual(IEncodeable encodeable)
        {
            if (Object.ReferenceEquals(this, encodeable))
            {
                return(true);
            }

            AnalogData value = encodeable as AnalogData;

            if (value == null)
            {
                return(false);
            }

            if (!Utils.IsEqual(m_data, value.m_data))
            {
                return(false);
            }
            if (!Utils.IsEqual(m_info, value.m_info))
            {
                return(false);
            }

            return(true);
        }
Пример #3
0
 /// <summary>
 /// Sets private members to default values.
 /// </summary>
 private void Initialize()
 {
     m_temperature    = new AnalogData();
     m_maxTemperature = new AnalogData();
     m_minTemperature = new AnalogData();
     m_pressure       = new AnalogData();
     m_cityName       = null;
 }
Пример #4
0
        /// <summary cref="Object.MemberwiseClone" />
        public new object MemberwiseClone()
        {
            AnalogData clone = (AnalogData)base.MemberwiseClone();

            clone.m_data = (float)Utils.Clone(this.m_data);
            clone.m_info = (EUInformation)Utils.Clone(this.m_info);

            return(clone);
        }
Пример #5
0
        private WeatherData GetNewValue(String name)

        {
            WeatherData             weatherInfo     = new WeatherData();
            OpenWeatherMapDataClass openWeatherData = apiRequests.GetWeatherDataByCity(name);

            if (openWeatherData != null)
            {
                EUInformation info_temp  = new EUInformation();
                EUInformation info_press = new EUInformation();


                info_press.DisplayName  = new String("Pa");
                info_press.Description  = new String("Pascal");
                info_press.NamespaceUri = new string("http://www.opcfoundation.org/UA/units/un/cefact");
                info_press.UnitId       = 4932940;


                info_temp.DisplayName  = new String("K");
                info_temp.Description  = new String("Kelvin");
                info_temp.NamespaceUri = new string("http://www.opcfoundation.org/UA/units/un/cefact");
                info_temp.UnitId       = 5259596;

                weatherInfo.CityName = new string(name);
                AnalogData temperature    = new AnalogData();
                AnalogData maxTemperature = new AnalogData();
                AnalogData minTemperature = new AnalogData();
                AnalogData pressure       = new AnalogData();

                maxTemperature.Data        = openWeatherData.Main.TempMax;
                maxTemperature.Info        = info_temp;
                weatherInfo.MaxTemperature = maxTemperature;
                minTemperature.Data        = openWeatherData.Main.TempMin;
                minTemperature.Info        = info_temp;
                weatherInfo.MinTemperature = minTemperature;
                temperature.Data           = openWeatherData.Main.Temp;
                temperature.Info           = info_temp;
                weatherInfo.Temperature    = temperature;
                pressure.Data        = openWeatherData.Main.Pressure;
                pressure.Info        = info_press;
                weatherInfo.Pressure = pressure;
            }
            //timer set on
            m_simulationTimer = new Timer(OnRaiseSystemEvents, null, 20000, 20000);

            return(weatherInfo);
        }
Пример #6
0
        private List <BaseVariableState> CreateChild(WeatherMapVariableState variable)
        {
            List <BaseVariableState> child = new List <BaseVariableState>();

            AnalogData info = new AnalogData();



            info = variable.Value.Temperature;

            AnalogVariableState childTemperatura = (AnalogVariableState)CreateVariableChild(null, "Temperature", "Temperature", new NodeId(VariableTypeIds.WeatherMapVariableType.Identifier, VariableTypeIds.WeatherMapVariableType.NamespaceIndex), new NodeId(DataTypeIds.AnalogData.Identifier, DataTypeIds.AnalogData.NamespaceIndex), ValueRanks.Scalar, info, null);

            variable.AddChild(childTemperatura);
            child.Add(childTemperatura);

            //info = null;

            info = variable.Value.Pressure;

            AnalogVariableState childPressure = (AnalogVariableState)CreateVariableChild(null, "Pressure", "Pressure", new NodeId(VariableTypeIds.WeatherMapVariableType.Identifier, VariableTypeIds.WeatherMapVariableType.NamespaceIndex), new NodeId(DataTypeIds.AnalogData.Identifier, DataTypeIds.AnalogData.NamespaceIndex), ValueRanks.Scalar, info, null);

            variable.AddChild(childPressure);
            child.Add(childPressure);

            // info = null;

            info = variable.Value.MaxTemperature;

            AnalogVariableState childMaxTemp = (AnalogVariableState)CreateVariableChild(null, "MaxTemperature", "MaxTemperature", new NodeId(VariableTypeIds.WeatherMapVariableType.Identifier, VariableTypeIds.WeatherMapVariableType.NamespaceIndex), new NodeId(DataTypeIds.AnalogData.Identifier, DataTypeIds.AnalogData.NamespaceIndex), ValueRanks.Scalar, info, null);

            variable.AddChild(childMaxTemp);
            child.Add(childMaxTemp);

            info = variable.Value.MinTemperature;

            AnalogVariableState childMinTemp = (AnalogVariableState)CreateVariableChild(null, "MinTemperature", "MinTemperature", new NodeId(VariableTypeIds.WeatherMapVariableType.Identifier, VariableTypeIds.WeatherMapVariableType.NamespaceIndex), new NodeId(DataTypeIds.AnalogData.Identifier, DataTypeIds.AnalogData.NamespaceIndex), ValueRanks.Scalar, info, null);

            variable.AddChild(childMinTemp);
            child.Add(childMinTemp);

            BaseVariableState childCity = CreateVariableChild(null, "City", "City", Opc.Ua.VariableTypeIds.BaseVariableType, Opc.Ua.DataTypeIds.String, ValueRanks.Scalar, null, new String(variable.Value.CityName));

            variable.AddChild(childCity);
            child.Add(childCity);
            return(child);
        }
Пример #7
0
        /// <summary>
        /// Возвращает информацию об аналогах по ID исходного товара
        /// </summary>
        /// <param name="goodsID"></param>
        /// <returns></returns>
        public static List <AnalogData> GetAnalogData(int goodsID)
        {
            var ads     = new List <AnalogData>();
            var analogs = Repository.Analogs.Where(x => x.OriginalGoodslD == goodsID).ToList();

            foreach (var analog in Repository.Analogs.Where(x => x.OriginalGoodslD == goodsID).ToList())
            {
                var        analogGoods = Repository.Goods.FirstOrDefault(x => x.ID == analog.AnalogGoodsID);
                AnalogData ad          = (analogGoods == null) ?
                                         new AnalogData()
                {
                    VandorCode = None, Producer = None, Relaince = NoneReliance
                } :
                new AnalogData()
                {
                    VandorCode = analogGoods.VendorCode,
                    Producer   = GetProducerName(analogGoods.ProducerID),
                    Relaince   = Convert.ToInt32(analog.Reliance)
                };
                ads.Add(ad);
            }
            return(ads);
        }
Пример #8
0
        private ServiceResult WriteWeatherData(string city, string measureOfTemperature)
        {
            WeatherData   insideData         = new WeatherData();
            AnalogData    insideTempData     = new AnalogData();
            AnalogData    insideMaxTempData  = new AnalogData();
            AnalogData    insideMinTempData  = new AnalogData();
            AnalogData    insidePressureData = new AnalogData();
            EUInformation info_press         = new EUInformation();
            EUInformation info_temp          = new EUInformation();

            lock (Lock)
            {
                if (city != null)
                {
                    double conversionFactor = 0;
                    info_press.DisplayName  = new String("Pa");
                    info_press.Description  = new String("Pascal");
                    info_press.NamespaceUri = new string("http://www.opcfoundation.org/UA/units/un/cefact");
                    info_press.UnitId       = 4932940;



                    switch (measureOfTemperature)
                    {
                    case "K":
                        Console.WriteLine("Unit of measurement for Temperature choosed: " + "Kelvin");
                        info_temp.DisplayName  = new String("K");
                        info_temp.Description  = new String("Kelvin");
                        info_temp.NamespaceUri = new string("http://www.opcfoundation.org/UA/units/un/cefact");
                        info_temp.UnitId       = 5259596;
                        break;

                    case "C":
                        Console.WriteLine("Unit of measurement for Temperature choosed: " + "Celsius");

                        info_temp.DisplayName  = new String("°C");
                        info_temp.Description  = new String("degree Celsius");
                        info_temp.NamespaceUri = new string("http://www.opcfoundation.org/UA/units/un/cefact");
                        info_temp.UnitId       = 4408652;



                        conversionFactor = 273.15;


                        break;

                    default:
                        Console.WriteLine("Unit of measurement for Temperature choosed: " + "Kelvin");
                        info_temp.DisplayName  = new String("K");
                        info_temp.Description  = new String("Kelvin");
                        info_temp.NamespaceUri = new string("http://www.opcfoundation.org/UA/units/un/cefact");
                        info_temp.UnitId       = 5259596;
                        break;
                    }

                    Console.WriteLine("mesure " + measureOfTemperature);
                    OpenWeatherMapDataClass openWeatherData = apiRequests.GetWeatherDataByCity(city.ToString());

                    if (openWeatherData != null)
                    {
                        insideMaxTempData.Data    = (float)(openWeatherData.Main.TempMax - conversionFactor);
                        insideMaxTempData.Info    = info_temp;
                        insideData.MaxTemperature = insideMaxTempData;



                        insideMinTempData.Data    = (float)(openWeatherData.Main.TempMin - conversionFactor);
                        insideMinTempData.Info    = info_temp;
                        insideData.MinTemperature = insideMinTempData;


                        insideTempData.Data    = (float)(openWeatherData.Main.Temp - conversionFactor);
                        insideTempData.Info    = info_temp;
                        insideData.Temperature = insideTempData;

                        insidePressureData.Data = openWeatherData.Main.Pressure;
                        insidePressureData.Info = info_press;
                        insideData.Pressure     = insidePressureData;

                        insideData.CityName = new string(city);



                        if (insideData != null)
                        {
                            openWeatherObject.CityName.Value         = new String(insideData.CityName);
                            openWeatherObject.WeatherData.Value      = insideData;
                            openWeatherObject.WeatherData.StatusCode = StatusCodes.Good;
                            openWeatherObject.WeatherData.Timestamp  = DateTime.UtcNow;
                            return(ServiceResult.Good);
                        }
                        else
                        {
                            return(StatusCodes.BadUnknownResponse);
                        }
                    }
                }
            }

            Console.WriteLine("INPUT ERROR: I can't get informations for this city or city is null: " + city);
            return(StatusCodes.BadAggregateInvalidInputs);
        }
Пример #9
0
    // Update is called once per frame
    void Update()
    {
        // update the trackers only once per frame
        if (lastAnalogUpdateFrame != Time.frameCount)
        {
            updateAnalogs();
            lastAnalogUpdateFrame = Time.frameCount;
        }
        analogData = (AnalogData)Marshal.PtrToStructure(analogDataPointer, typeof(AnalogData));


        float speedThisFrame = speed * Time.deltaTime * (float)analogData.state;

        if (movementType == MovementType.TRANSLATE)
        {
            Vector3 position = transform.localPosition;
            if (axis == Axis.X)
            {
                position.x += speedThisFrame;
            }
            else if (axis == Axis.Y)
            {
                position.y += speedThisFrame;
            }
            else if (axis == Axis.Z)
            {
                position.z += speedThisFrame;
            }
            else
            {
                position.x += speedThisFrame;
                position.y += speedThisFrame;
                position.z += speedThisFrame;
            }

            transform.localPosition = position;
        }
        else if (movementType == MovementType.ROTATE)
        {
            Quaternion newRotation = Quaternion.identity;
            Vector3    newAngles   = newRotation.eulerAngles;

            if (axis == Axis.X)
            {
                newAngles.x += speedThisFrame;
            }
            else if (axis == Axis.Y)
            {
                newAngles.y += speedThisFrame;
            }
            else if (axis == Axis.Z)
            {
                newAngles.z += speedThisFrame;
            }
            else
            {
                newAngles.x += speedThisFrame;
                newAngles.y += speedThisFrame;
                newAngles.z += speedThisFrame;
            }

            if (newAngles.x > 360)
            {
                newAngles.x %= 360;
            }

            if (newAngles.y > 360)
            {
                newAngles.y %= 360;
            }

            if (newAngles.z > 360)
            {
                newAngles.z %= 360;
            }

            newRotation.eulerAngles = newAngles;


            Quaternion rotation = transform.localRotation;
            rotation = rotation * newRotation;
            transform.localRotation = rotation;
        }
        else
        {
            Vector3 scale = transform.localScale;
            if (axis == Axis.X)
            {
                scale.x += speedThisFrame;
            }
            else if (axis == Axis.Y)
            {
                scale.y += speedThisFrame;
            }
            else if (axis == Axis.Z)
            {
                scale.z += speedThisFrame;
            }
            else
            {
                scale.x += speedThisFrame;
                scale.y += speedThisFrame;
                scale.z += speedThisFrame;
            }

            transform.localScale = scale;
        }
    }
Пример #10
0
        public static async Task <bool> FillAnalogData(DateTime DateStart, DateTime DateEnd, List <string> Types)
        {
            DiagDBEntities diagDB = new DiagDBEntities();

            for (int gg = 1; gg <= 10; gg++)
            {
                if (gg == 8)
                {
                    continue;
                }
                try
                {
                    EDSClass.Disconnect();
                }
                catch { }
                EDSClass.Connect();

                Logger.Info(string.Format("GG{0}", gg));
                List <PuskStopPoint> points = (from p in diagDB.PuskStopPoints
                                               where p.gg == gg && p.analog == true && Types.Contains(p.pointType)
                                               select p).ToList();
                List <AnalogData> existData = (from a in diagDB.AnalogDatas
                                               where
                                               a.gg == gg && Types.Contains(a.pointType) &&
                                               a.Date >= DateStart && a.Date <= DateEnd
                                               select a).ToList();
                Dictionary <string, string> pointsDict = new Dictionary <string, string>();
                foreach (String type in Types)
                {
                    try
                    {
                        PuskStopPoint pt = (from p in diagDB.PuskStopPoints where p.gg == gg && p.pointType == type select p).First();
                        pointsDict.Add(type, pt.point);
                    }
                    catch
                    {
                        pointsDict.Add(type, "");
                    }
                }

                List <PuskStopInfo> data = (
                    from d in diagDB.PuskStopInfoes
                    where d.TimeOn <= DateEnd && d.TimeOff >= DateStart &&
                    d.GG == gg && d.TypeData.Contains("GG_RUN")
                    select d).ToList();


                foreach (PuskStopInfo ggRec in data)
                {
                    Logger.Info(String.Format("GG {0} {1} -{2}", gg, ggRec.TimeOn, ggRec.TimeOff));
                    foreach (string type in Types)
                    {
                        if (string.IsNullOrEmpty(pointsDict[type]))
                        {
                            continue;
                        }
                        foreach (DateTime dt in new DateTime[] { ggRec.TimeOn, ggRec.TimeOff })
                        {
                            IEnumerable <AnalogData> datas = (from a in existData where a.Date == dt && a.pointType == type select a);
                            AnalogData dat = null;
                            if (datas.Count() == 0)
                            {
                                dat = new AnalogData();
                                diagDB.AnalogDatas.Add(dat);
                                dat.pointType = type;
                                dat.gg        = gg;
                                dat.Date      = dt;
                                dat.value     = await EDSClass.getValFromServer(pointsDict[type], dt);
                            }
                            else
                            {
                                dat = datas.First();
                            }
                        }
                    }
                    diagDB.SaveChanges();
                }


                DateTime date = DateTime.Parse(DateStart.ToString("dd.MM.yyyy HH:00"));
                while (date <= DateEnd)
                {
                    Logger.Info(String.Format("GG {0} {1} ", gg, date));
                    if (gg == 5 && date < DateTime.Parse("01.06.2019"))
                    {
                        date = DateTime.Parse("01.06.2019");
                        continue;
                    }
                    if (gg == 3 && date < DateTime.Parse("07.05.2020"))
                    {
                        date = DateTime.Parse("07.05.2020");
                        continue;
                    }
                    if (gg == 1 && date < DateTime.Parse("21.04.2021"))
                    {
                        date = DateTime.Parse("21.04.2020");
                        continue;
                    }
                    foreach (string type in Types)
                    {
                        if (string.IsNullOrEmpty(pointsDict[type]))
                        {
                            continue;
                        }

                        IEnumerable <AnalogData> datas = (from a in existData where a.Date == date && a.pointType == type select a);
                        AnalogData dat = null;
                        if (datas.Count() == 0)
                        {
                            dat = new AnalogData();
                            diagDB.AnalogDatas.Add(dat);
                            dat.pointType = type;
                            dat.gg        = gg;
                            dat.Date      = date;
                            dat.value     = await EDSClass.getValFromServer(pointsDict[type], date);
                        }
                        else
                        {
                            dat = datas.First();
                        }
                    }
                    date = date.AddHours(3);
                }
            }
            return(true);
        }
Пример #11
0
 public GamePadTriggerBinding(string alias, Trigger trigger, AnalogEvent aEvent, AnalogData aData, AnalogBindingDelegate aDel)
     : base(alias, aEvent, aData, aDel)
 {
     Trigger = trigger;
 }
Пример #12
0
 public GamePadTriggerBinding(string alias, Trigger trigger, AnalogEvent aEvent, AnalogData aData)
     : this(alias, trigger, aEvent, aData, null)
 {
 }
Пример #13
0
        // Update is called once per frame
        void Update()
        {
            // update the trackers only once per frame
            if (lastAnalogUpdateFrame != Time.frameCount)
            {
                UpdateAnalogs();
                lastAnalogUpdateFrame = Time.frameCount;
            }
            analogData = (AnalogData)Marshal.PtrToStructure(analogDataPointer, typeof(AnalogData));

            if (analogData.state != lastAnalogState)
            {
                lastAnalogState = (float)analogData.state;

                VREvent e = new VREvent(eventName);
                e.AddData("EventType", "AnalogUpdate");
                e.AddData("AnalogValue", (float)analogData.state);
                pendingEvents.Add(e);

                if (applyUpdatesToGameObject)
                {
                    float speedThisFrame = speed * Time.deltaTime * (float)analogData.state;

                    if (movementType == MovementType.TRANSLATE)
                    {
                        Vector3 position = transform.localPosition;
                        if (axis == Axis.X)
                        {
                            position.x += speedThisFrame;
                        }
                        else if (axis == Axis.Y)
                        {
                            position.y += speedThisFrame;
                        }
                        else if (axis == Axis.Z)
                        {
                            position.z += speedThisFrame;
                        }
                        else
                        {
                            position.x += speedThisFrame;
                            position.y += speedThisFrame;
                            position.z += speedThisFrame;
                        }

                        transform.localPosition = position;
                    }
                    else if (movementType == MovementType.ROTATE)
                    {
                        Quaternion newRotation = Quaternion.identity;
                        Vector3    newAngles   = newRotation.eulerAngles;

                        if (axis == Axis.X)
                        {
                            newAngles.x += speedThisFrame;
                        }
                        else if (axis == Axis.Y)
                        {
                            newAngles.y += speedThisFrame;
                        }
                        else if (axis == Axis.Z)
                        {
                            newAngles.z += speedThisFrame;
                        }
                        else
                        {
                            newAngles.x += speedThisFrame;
                            newAngles.y += speedThisFrame;
                            newAngles.z += speedThisFrame;
                        }

                        if (newAngles.x > 360)
                        {
                            newAngles.x %= 360;
                        }

                        if (newAngles.y > 360)
                        {
                            newAngles.y %= 360;
                        }

                        if (newAngles.z > 360)
                        {
                            newAngles.z %= 360;
                        }

                        newRotation.eulerAngles = newAngles;


                        Quaternion rotation = transform.localRotation;
                        rotation = rotation * newRotation;
                        transform.localRotation = rotation;
                    }
                    else if (movementType == MovementType.SCALE)
                    {
                        Vector3 scale = transform.localScale;
                        if (axis == Axis.X)
                        {
                            scale.x += speedThisFrame;
                        }
                        else if (axis == Axis.Y)
                        {
                            scale.y += speedThisFrame;
                        }
                        else if (axis == Axis.Z)
                        {
                            scale.z += speedThisFrame;
                        }
                        else
                        {
                            scale.x += speedThisFrame;
                            scale.y += speedThisFrame;
                            scale.z += speedThisFrame;
                        }

                        transform.localScale = scale;
                    }
                }
            }
        }
 public GamePadThumbStickBinding(string alias, ThumbStick tStick, AnalogEvent aEvent, AnalogData aData, AnalogBindingDelegate aDel)
     : base(alias, aEvent, aData, aDel)
 {
     Stick = tStick;
 }
Пример #15
0
        // =================================================================================================================

        #region DataReadyPort handlers

        /// <summary>
        /// This handler is activated by empty Recv messages coming to internal DataReadyPort.
        /// The data comes here from pmFrameCompleteHandler
        /// This is our opportunity to purge stale data from the queues.
        /// The data posted to Responses port is then picked up by ProximityBoardCcrServiceCommander:SonarDataHandler() and others,
        /// to be later passed to TrackRoamerBrickProximityBoard.
        /// </summary>
        /// <param name="recv"></param>
        private void DataHandler(Recv recv)
        {
            /*
             * if(_sonarDatas.Count > 1 || _directionDatas.Count > 1 || _accelDatas.Count > 1 || _proxDatas.Count > 1 || _parkingSensorsDatas.Count > 1)
             * {
             *  // for debugging, log if queues get more than 1 piece of each data type:
             *  Tracer.Trace("ProximityBoardManager: DataHandler()  sonars: " + _sonarDatas.Count + "  compass: "******"  accels: " + _accelDatas.Count + "  proxs: " + _proxDatas.Count + "  parking: " + _parkingSensorsDatas.Count);
             * }
             */

            if (_sonarDatas.Count > 0)
            {
                SonarData sonarData = null;

                lock (_sonarDatas)
                {
                    while (_sonarDatas.Count > 0)
                    {
                        sonarData = _sonarDatas.Last();
                        _sonarDatas.Clear();
                    }
                }

                if (sonarData != null)
                {
                    MeasurementsPort.Post(sonarData);
                }
            }

            if (_directionDatas.Count > 0)
            {
                DirectionData directionData = null;

                lock (_directionDatas)
                {
                    while (_directionDatas.Count > 0)
                    {
                        directionData = _directionDatas.Last();
                        _directionDatas.Clear();
                    }
                }

                if (directionData != null)
                {
                    MeasurementsPort.Post(directionData);
                }
            }

            if (_accelDatas.Count > 0)
            {
                AccelerometerData accelerometerData = null;

                lock (_accelDatas)
                {
                    while (_accelDatas.Count > 0)
                    {
                        accelerometerData = _accelDatas.Last();
                        _accelDatas.Clear();
                    }
                }

                if (accelerometerData != null)
                {
                    MeasurementsPort.Post(accelerometerData);
                }
            }

            if (_proxiDatas.Count > 0)
            {
                ProximityData proximityData = null;

                lock (_proxiDatas)
                {
                    while (_proxiDatas.Count > 0)
                    {
                        proximityData = _proxiDatas.Last();
                        _proxiDatas.Clear();
                    }
                }

                if (proximityData != null)
                {
                    MeasurementsPort.Post(proximityData);
                }
            }

            if (_parkingSensorsDatas.Count > 0)
            {
                ParkingSensorData psiData = null;

                lock (_parkingSensorsDatas)
                {
                    while (_parkingSensorsDatas.Count > 0)
                    {
                        psiData = _parkingSensorsDatas.Last();
                        _parkingSensorsDatas.Clear();
                    }
                }

                if (psiData != null)
                {
                    MeasurementsPort.Post(psiData);
                }
            }

            //Tracer.Trace("AnalogData:  current=" + AnalogValue1 + "    prev=" + AnalogValue1Prev);

            // and last but not least - post AnalogData - only if any of the values changed:
            if (AnalogValue1 != AnalogValue1Prev)
            {
                AnalogValue1Prev = AnalogValue1;
                AnalogData analogData = new AnalogData()
                {
                    analogValue1 = AnalogValue1,
                    TimeStamp    = DateTime.Now.Ticks
                };
                MeasurementsPort.Post(analogData);
            }
        }
Пример #16
0
 protected AnalogBinding(string alias, AnalogEvent aEvent, AnalogData aData)
     : base(alias)
 {
     AnalogEvent = aEvent;
     AnalogData  = aData;
 }
        void AnalogMeasurementHandler(AnalogData measurement)
        {
            //Tracer.Trace("TrackRoamerBrickProximityBoardService::PotMeasurementHandler() analogValue1=" + measurement.analogValue1);

            try
            {
                _state.MostRecentAnalogData = new AnalogDataDssSerializable() { analogValue1 = measurement.analogValue1, TimeStamp = new DateTime(measurement.TimeStamp) };
                //
                // Inform subscribed services that the state has changed.
                //
                _submgrPort.Post(new submgr.Submit(_state, DsspActions.ReplaceRequest));

                UpdateAnalogData usd = new UpdateAnalogData();
                usd.Body = _state.MostRecentAnalogData;

                base.SendNotification<UpdateAnalogData>(_submgrPort, usd);
            }
            catch (Exception e)
            {
                _state.LinkState = "Error while receiving POT Data";
                LogError(e);
            }
        }
        void AnalogDataHandler(AnalogData analogData)
        {
            //Tracer.Trace("ProximityBoardCcrServiceCommander::AnalogDataHandler()");

            _pbCommanderDataEventsPort.Post(analogData);
        }
Пример #19
0
 protected AnalogBinding(string alias, AnalogEvent aEvent, AnalogData aData, AnalogBindingDelegate aDel)
     : this(alias, aEvent, aData)
 {
     Callback = aDel;
 }
Пример #20
0
        /// Creates a new variable.
        /// </summary>


        /// <summary>
        /// Creates a new variable.
        /// </summary>
        ///
        private BaseVariableState CreateVariableChild(NodeState parent, string path, string name, NodeId typeDefinitionId, NodeId dataType, int valueRank, AnalogData valueAnalog, String cityName)
        {
            if (cityName == null)
            {
                AnalogVariableState variable = new AnalogVariableState(parent);


                variable.SymbolicName     = name;
                variable.ReferenceTypeId  = ReferenceTypes.Organizes;
                variable.TypeDefinitionId = typeDefinitionId;
                variable.NodeId           = new NodeId(path, NamespaceIndex);
                variable.BrowseName       = new QualifiedName(path, NamespaceIndex);
                variable.DisplayName      = new LocalizedText("en", name);
                variable.WriteMask        = AttributeWriteMask.DisplayName | AttributeWriteMask.Description;
                variable.UserWriteMask    = AttributeWriteMask.DisplayName | AttributeWriteMask.Description;
                variable.Description      = new String("Information about weather for" + variable.SymbolicName.ToString());

                variable.DataType        = dataType;
                variable.ValueRank       = valueRank;
                variable.AccessLevel     = AccessLevels.CurrentReadOrWrite;
                variable.UserAccessLevel = AccessLevels.CurrentRead;
                variable.Historizing     = true;

                variable.Value = valueAnalog;


                if (variable.Value != null)
                {
                    variable.StatusCode = StatusCodes.Good;
                }
                else
                {
                    variable.StatusCode = StatusCodes.Bad;
                }
                variable.Timestamp = DateTime.UtcNow;

                if (valueRank == ValueRanks.OneDimension)
                {
                    variable.ArrayDimensions = new ReadOnlyList <uint>(new List <uint> {
                        0
                    });
                }
                else if (valueRank == ValueRanks.TwoDimensions)
                {
                    variable.ArrayDimensions = new ReadOnlyList <uint>(new List <uint> {
                        0, 0
                    });
                }

                if (parent != null)
                {
                    parent.AddChild(variable);
                }


                return(variable);
            }
            else
            {
                BaseVariableState variable = new BaseDataVariableState <String>(parent);

                variable.SymbolicName     = name;
                variable.ReferenceTypeId  = ReferenceTypes.Organizes;
                variable.TypeDefinitionId = Opc.Ua.VariableTypeIds.BaseVariableType;;
                variable.NodeId           = new NodeId(path, NamespaceIndex);
                variable.BrowseName       = new QualifiedName(path, NamespaceIndex);
                variable.DisplayName      = new LocalizedText("en", name);
                variable.WriteMask        = AttributeWriteMask.DisplayName | AttributeWriteMask.Description;
                variable.UserWriteMask    = AttributeWriteMask.DisplayName | AttributeWriteMask.Description;
                variable.Description      = new String("Information about weather for" + variable.SymbolicName.ToString());

                variable.DataType        = dataType;
                variable.ValueRank       = valueRank;
                variable.AccessLevel     = AccessLevels.CurrentReadOrWrite;
                variable.UserAccessLevel = AccessLevels.CurrentRead;
                variable.Historizing     = true;
                Console.WriteLine(cityName);
                variable.Value = cityName.ToString();


                if (variable.Value != null)
                {
                    variable.StatusCode = StatusCodes.Good;
                }
                else
                {
                    variable.StatusCode = StatusCodes.Bad;
                }
                variable.Timestamp = DateTime.UtcNow;

                if (valueRank == ValueRanks.OneDimension)
                {
                    variable.ArrayDimensions = new ReadOnlyList <uint>(new List <uint> {
                        0
                    });
                }
                else if (valueRank == ValueRanks.TwoDimensions)
                {
                    variable.ArrayDimensions = new ReadOnlyList <uint>(new List <uint> {
                        0, 0
                    });
                }

                if (parent != null)
                {
                    parent.AddChild(variable);
                }


                return(variable);
            }
        }
 public GamePadThumbStickBinding(string alias, ThumbStick tStick, AnalogEvent aEvent, AnalogData aData)
     : this(alias, tStick, aEvent, aData, null)
 {
 }