Esempio n. 1
0
        private void ChooseBackgroundImage()
        {
            StatusBits eStatusBit = !selected ? StatusBits.eStatusBitsNone : StatusBits.eStatusBitsSelected;

            eStatusBit |= !cancelled ? StatusBits.eStatusBitsNone : StatusBits.eStatusBitsCancelled;
            eStatusBit |= !Enabled ? StatusBits.eStatusBitsNone : StatusBits.eStatusBitsEnabled;
            int imgIndex = 0;

            switch ((int)eStatusBit)
            {
            case 0:
                imgIndex = 4;
                break;

            case 1:
                imgIndex = 2;
                break;

            case 2:
                imgIndex = 4;
                break;

            case 3:
                imgIndex = 0;
                break;

            case 4:
                imgIndex = 0;
                break;

            case 5:
                imgIndex = 2;
                break;

            case 6:
                imgIndex = 0;
                break;

            case 7:
                imgIndex = 0;
                break;

            default:
                imgIndex = 0;
                break;
            }
            this.BackgroundImage = BackImage[imgIndex];
        }
Esempio n. 2
0
 public Task <bool> WriteStringAsync(string symbolicAddress, string value, DateTime dateTime, StatusBits status)
 {
     return(Task.FromResult(false));
 }
Esempio n. 3
0
        public async Task <bool> WriteNumericAsync(string symbolicAddress, double value, DateTime dateTime, StatusBits status)
        {
            var request = new RestRequest("sensors", Method.PUT);

            request.AddQueryParameter("sensorName", symbolicAddress);
            request.AddQueryParameter("value", value.ToString(CultureInfo.InvariantCulture));

            try
            {
                var response = await _restClient.ExecuteTaskAsync <SensorPayload>(request);

                return(response.IsSuccessful);
            }
            catch (Exception e)
            {
                _logger.Error($"Error while setting value for symbolic address '{symbolicAddress}': " + e.Message);
            }

            return(false);
        }
Esempio n. 4
0
 public Task <bool> WriteNumericAsync(string symbolicAddress, double value, DateTime dateTime, StatusBits statusBits)
 {
     throw new NotImplementedException();
 }
        public async Task <bool> WriteNumericAsync(string symbolicAddress, double value, DateTime dateTime, StatusBits status)
        {
            var sensorPayload = new SensorPayload()
            {
                Value = value, LastChangeDateTime = dateTime
            };
            var payloadString = JsonConvert.SerializeObject(sensorPayload);

            var message = new MqttApplicationMessageBuilder()
                          .WithTopic(symbolicAddress)
                          .WithPayload(payloadString)
                          .WithExactlyOnceQoS()
                          .WithRetainFlag()
                          .Build();

            try
            {
                await _mqttClient.PublishAsync(message);

                return(true);
            }
            catch (Exception e)
            {
                _logger.Error("Error while submitting value: " + e.Message);
            }

            return(false);
        }
        public Task <bool> WriteNumericAsync(string symbolicAddress, double value, DateTime dateTime, StatusBits status)
        {
            _logger.DeepDebug($"WriteString '{symbolicAddress}'");

            _subscriptions[symbolicAddress] = value;
            return(Task.FromResult(true));
        }
        /// <summary>
        /// Is called when the numeric value of a variable is set.
        /// </summary>
        public Task <bool> WriteNumericAsync(string symbolicAddress, double value, DateTime dateTime, StatusBits statusBits)
        {
            if (symbolicAddress == "Latitude")
            {
                latitude = value;
                return(Task.FromResult(true));
            }

            if (symbolicAddress == "Longitude")
            {
                longitude = value;
                return(Task.FromResult(true));
            }
            //writing values is not allowed
            return(Task.FromResult(false));
        }
Esempio n. 8
0
 /// <summary>
 /// This method is called by zenon, when the numeric/boolean value of a variable is set.
 /// </summary>
 /// <param name="symbolicAddress"></param>
 /// <param name="value"></param>
 /// <param name="dateTime"></param>
 /// <param name="status"></param>
 /// <returns></returns>
 public Task <bool> WriteNumericAsync(string symbolicAddress, double value, DateTime dateTime, StatusBits status)
 {
     _logger.DeepDebug($"WriteNumeric '{symbolicAddress}'");
     Console.WriteLine($"Numeric variable changed and the new value is: {value}");
     _subscriptions[symbolicAddress] = value;
     return(Task.FromResult(true));
 }