So the first of the .Net questions is here.
What are the options for reading specific bits?
I can access the bits via KM_MainStatus.BitsState, but obviously that involves knowing the exact word and bit I'd like to check. That would be manageable if the bits were fixed, but they're not likely to be.
I have also found the KM_IO class, but documentation is a bit thin, and my guesses at filling in the blanks has so far not produced any result.
Is there any chance of a code snippet on how to check a bit status (I'm currently wanting to check bit 6)?
Also is there likely to be any performance/communication hit by using KM_IO instead of the MainStatus?
For this I'm only looking at monitoring two or three bits, but I will also be looking at being able to set a virtual bit or two as well.
Getting a bit status
Moderators: TomKerekes, dynomotion
Re: Getting a bit status
And figured it out. After peeking my way through the various definitions, I found the IO_TYPE enum, which was the key. I thought I could get away with just entering a number directly into the GetIO() function, but it's got to be done via an enum.
For reference, this is the basic code needed to check bit 6-
For reference, this is the basic code needed to check bit 6-
Code: Select all
try
{
KM_MainStatus MainStatus = KM.GetStatus(false); // we already have a lock
KM.ReleaseToken();
KM_IO InOut = KM.GetIO(6, IO_TYPE.DIGITAL_IN, "InputPin");
if(InOut.GetDigitalValue())
{
textBlock_status_2.Text = "false";
} else
{
textBlock_status_2.Text = "true";
}
}