The snippet of code in the KFlop loading the data to KFlop is this -
Code: Select all
double *d2 = (double *)&persist.UserData[TRIGGER_POS_VAR];
if(ReadBit(PROBE_OFFSETS_REQUEST))
{
GetFixtureIndex(&FixtureIndex);
persist.UserData[PROBE_OFFSET] = FixtureIndex;
printf("Fixture:%d\n", persist.UserData[PROBE_OFFSET]);
GetOriginOffset(&OriginOffsetX, FixtureIndex, X);
d2[0] = OriginOffsetX;
GetOriginOffset(&OriginOffsetY, FixtureIndex, Y);
d2[1] = OriginOffsetY;
GetOriginOffset(&OriginOffsetZ, FixtureIndex, Z);
d2[2] = OriginOffsetZ;
printf("OriginOffset:X%f, Y%f, Z%f\n", d2[0], d2[1], d2[2]);
GetAxisOffset(&AxisOffsetX, X);
d2[3] = AxisOffsetX;
GetAxisOffset(&AxisOffsetY, Y);
d2[4] = AxisOffsetY;
GetAxisOffset(&AxisOffsetZ, Z);
d2[5] = AxisOffsetZ;
printf("AxisOffset:X%f, Y%f, Z%f\n", d2[3], d2[4], d2[5]);
ClearBit(PROBE_OFFSETS_REQUEST);
SetBit(PROBE_OFFSETS_COMPLETE);
}
Code: Select all
Fixture:2
OriginOffset:X-0.500000, Y0.500000, Z0.500000
AxisOffset:X0.250000, Y0.000000, Z0.000000
Code: Select all
OffsetInUse = KM.GetUserData(UserDataProbeOffset);
OffsetFixtureX = KM.GetUserDataDouble(UserDataProbeOffsetFixture / 2);
textBox_debug.AppendText(Convert.ToString(KM.GetUserDataDouble(UserDataProbeOffsetFixture / 2)));
textBox_debug.AppendText(Convert.ToString(KM.GetUserDataDouble((UserDataProbeOffsetFixture / 2) + 1)));
OffsetFixtureY = 99.99;
OffsetGlobalX = KM.GetUserDataDouble(UserDataProbeOffsetGlobal / 2);
RefreshOffsetsText();
The fixture offset displays ok. The RefreshOffsetsText() function takes the values loaded into the relevant variables and updates them in my app, I've only added the output to the textbox to try and debug things.
(as a side note, it's probably worth adding a note to the documentation that when using doubles in UserData with dotNet, you have to divide the index by two compared with the index you use in the KFlop)