replace globals in krcam.cpp with struct. Pass pointer to Java