Exemple #1
0
		public StepsData(TrioDeviceInformation devInfo)
		{
			this.trioDevInfo = devInfo;
			this.lastCommand = LastCommandSent.NO_COMMAND_SENT;
			this.ClearData();
		}
Exemple #2
0
		public async Task<byte[]> getReadCurrentHourCommand()
		{
			await Task.Run(() =>
			{
				this._readCurrentHourCommandRawData = new byte[READ_CURRENT_HOUR_SIZE];
				byte[] commandPrefix = BitConverter.GetBytes(COMMAND_PREFIX);
				byte[] commandID = BitConverter.GetBytes(COMMAND_ID_READ_CURRENT_HOUR);
				Buffer.BlockCopy(commandPrefix, INDEX_ZERO, this._readCurrentHourCommandRawData, INDEX_ZERO, 1);
				Buffer.BlockCopy(commandID, INDEX_ZERO, this._readCurrentHourCommandRawData, INDEX_ZERO + 1, 1);

			});
			lastCommand = LastCommandSent.CURRENT_HOUR_COMMAND;
			return this._readCurrentHourCommandRawData;
		}
Exemple #3
0
		public async Task<byte[]> getReadHourRangeCommand(DateTime stepDate, int startHour, int endHour)
		{
			await Task.Run(() =>
			{
				this._readHourRangeCommandRawData = new byte[READ_HOUR_RANGE_SIZE];
				byte[] commandPrefix = BitConverter.GetBytes(COMMAND_PREFIX);
				byte[] commandID = BitConverter.GetBytes(COMMAND_ID_READ_HOUR_RANGE);
				byte[] year = BitConverter.GetBytes(stepDate.Year | 0xC0);
				byte[] month = BitConverter.GetBytes(stepDate.Month | 0xC0);
				byte[] day = BitConverter.GetBytes(stepDate.Day | 0xC0);
				byte[] start = BitConverter.GetBytes(startHour | 0xC0);
				byte[] end = BitConverter.GetBytes(endHour | 0xC0);
				Buffer.BlockCopy(commandPrefix, INDEX_ZERO, this._readHourRangeCommandRawData, INDEX_ZERO, 1);
				Buffer.BlockCopy(commandID, INDEX_ZERO, this._readHourRangeCommandRawData, INDEX_ZERO + 1, 1);
				Buffer.BlockCopy(year, INDEX_ZERO, this._readHourRangeCommandRawData, INDEX_ZERO + 2, 1);
				Buffer.BlockCopy(month, INDEX_ZERO, this._readHourRangeCommandRawData, INDEX_ZERO + 3, 1);
				Buffer.BlockCopy(day, INDEX_ZERO, this._readHourRangeCommandRawData, INDEX_ZERO + 4, 1);
				Buffer.BlockCopy(start,INDEX_ZERO, this._readHourRangeCommandRawData, INDEX_ZERO + 5, 1);
				Buffer.BlockCopy(end, INDEX_ZERO, this._readHourRangeCommandRawData, INDEX_ZERO + 6, 1);
			});
			lastCommand = LastCommandSent.HOUR_RANGE_COMMAND;
			return this._readHourRangeCommandRawData;
		}
Exemple #4
0
        override protected void SendCommand(ArduinoCommand command, ExecutionArguments xargs)
        {
            var timeDiff = (DateTime.Now.Ticks - LastCommandSentOn) / TimeSpan.TicksPerMillisecond;

            if (UseRepeatCommand && _repeatCommand != null && LastCommandSent != null && LastCommandSent.Equals(command) && timeDiff < RepeatInterval)
            {
                base.SendCommand(_repeatCommand, xargs);
                LastCommandSent = command;
            }
            else
            {
                base.SendCommand(command, xargs);
            }
        }