Esempio n. 1
0
        public void GetContinuousModeDataCount()
        {
            uint queue_id = jbc_api.StartContinuousMode(station_id);

            int count = jbc_api.GetContinuousModeDataCount(station_id, queue_id);

            Debug.WriteLine("STATION ID:" + station_id + " COUNT: " + count);

            jbc_api.StopContinuousMode(station_id, queue_id);
        }
		private void tick()
		{
			//Dim start As ULong = Environment.TickCount
			//Getting all the continuous mode data transmisions pending in the queue, just advancing the queue to get the last value and
			//counting how many transmisions have been done. We only desired one value every timer tick and it is also desired to check
			//the sequence number returned by the API with the real transmision counts to check data lose.
			int transmisionTickCounter = 0;
			JBC_Connect.stContinuousModeData ports = null;
			int countInTick = JBC.GetContinuousModeDataCount(ID, continuousmodeQueueId);
			for (var i = 0; i <= countInTick - 1; i++)
			{
				ports = JBC.GetContinuousModeNextData(ID, continuousmodeQueueId);
				transmisionTickCounter++;
			}
			
			//plotting LAST data if there's any
			if (transmisionTickCounter > 0)
			{
				//plotting the result of ports in the labels
				int portNum = 0;
				for (int cnt = 0; cnt <= ports.data.Length - 1; cnt++)
				{
					if (ports.data[cnt].port == Port.NUM_1)
					{
						portNum = 1;
					}
					if (ports.data[cnt].port == Port.NUM_2)
					{
						portNum = 2;
					}
					if (ports.data[cnt].port == Port.NUM_3)
					{
						portNum = 3;
					}
					if (ports.data[cnt].port == Port.NUM_4)
					{
						portNum = 4;
					}
					this.Controls.Find("lblTemp" + portNum.ToString(), true)[0].Text = ports.data[cnt].temperature.ToCelsius.ToString() + " ºC";
					this.Controls.Find("lblPwr" + portNum.ToString(), true)[0].Text = (ports.data[cnt].power / 10).ToString() + " %";
					this.Controls.Find("lblStatus" + portNum.ToString(), true)[0].Text = ports.data[0].status.ToString();
				}
				
				//plotting the counts
				lblSeq.Text = "Sequence: " + ports.sequence.ToString();
			}
			
			//udating the number of recieved transmisions
			lblTrans.Text = "trans. in tick: " + transmisionTickCounter.ToString();
			
			//restarting the timer
			//Console.WriteLine("AppLoop: " & Environment.TickCount - start)
			tmr.Start();
		}