public void AsyncReceiveData(KObject data) { GoDataSet dataset = (GoDataSet)data; for (UInt32 i = 0; i < dataset.Count; i++) { GoDataMsg dataObj = (GoDataMsg)dataset.Get(i); switch (dataObj.MessageType) { case GoDataMessageType.Stamp: { GoStampMsg stampMsg = (GoStampMsg)dataObj; for (UInt32 j = 0; j < stampMsg.Count; j++) { GoStamp stamp = stampMsg.Get(j); getStamp.FrameIndex = stamp.FrameIndex; getStamp.Timestamp = stamp.Timestamp; getStamp.Encoder = stamp.Encoder; get_stamp_FrameIndex.Add(stamp.FrameIndex); get_stamp_TimeStamp.Add(stamp.Timestamp); get_stamp_EncoderValue.Add(stamp.Encoder); } dataReceivedFlag.Stamp = 1; } break; case GoDataMessageType.Measurement: { GoMeasurementMsg measurementMsg = (GoMeasurementMsg)dataObj; for (UInt32 k = 0; k < measurementMsg.Count; k++) { GoMeasurementData measurementData = measurementMsg.Get(k); getMeasurement.Id = measurementMsg.Id; getMeasurement.value = measurementData.Value; getMeasurement.decison = measurementData.Decision; get_measurementMsg_Id.Add(measurementMsg.Id); get_measurementMsg_Value.Add(measurementData.Value); get_measurementMsg_Decison.Add(measurementData.Decision); } dataReceivedFlag.Measurement = 1; } break; case GoDataMessageType.Alignment: { GoAlignMsg dataItem = (GoAlignMsg)dataSet.Get(i); if (dataItem.Status == KStatus.Ok) { calibrationSuccessfulBl = true; } else { calibrationSuccessfulBl = false; } } break; } } }
public void onData(KObject data) { GoDataSet dataSet = (GoDataSet)data; //var dataWithID = new Dictionary<string, string>(); for (UInt32 i = 0; i < dataSet.Count; i++) { GoDataMsg dataObj = (GoDataMsg)dataSet.Get(i); switch (dataObj.MessageType) { case GoDataMessageType.Stamp: { GoStampMsg stampMsg = (GoStampMsg)dataObj; for (UInt32 j = 0; j < stampMsg.Count; j++) { GoStamp stamp = stampMsg.Get(j); //Console.WriteLine("Frame Index = {0}", stamp.FrameIndex); //Console.WriteLine("Time Stamp = {0}", stamp.Timestamp); //Console.WriteLine("Encoder Value = {0}", stamp.Encoder); } } break; case GoDataMessageType.Measurement: { GoMeasurementMsg measurementMsg = (GoMeasurementMsg)dataObj; for (UInt32 k = 0; k < measurementMsg.Count; ++k) { GoMeasurementData measurementData = measurementMsg.Get(k); //Console.WriteLine("ID: {0}", measurementMsg.Id); //Console.WriteLine("Value: {0}", measurementData.Value); //Console.WriteLine("Decision: {0}", measurementData.Decision); //dataWithID.Add(measurementMsg.Id.ToString(), measurementData.Value.ToString()); } } break; } } Publish(new LMIData()); //TODO Data Shell }
static int Main(string[] args) { try { KApiLib.Construct(); GoSdkLib.Construct(); GoSystem system = new GoSystem(); GoSensor sensor; KIpAddress ipAddress = KIpAddress.Parse(Constants.SENSOR_IP); GoDataSet dataSet = new GoDataSet(); sensor = system.FindSensorByIpAddress(ipAddress); sensor.Connect(); system.EnableData(true); system.Start(); // refer to SetupMeasurement.cs for setting up of the measurement tools dataSet = system.ReceiveData(30000000); for (UInt32 i = 0; i < dataSet.Count; i++) { GoDataMsg dataObj = (GoDataMsg)dataSet.Get(i); switch (dataObj.MessageType) { case GoDataMessageType.Stamp: { GoStampMsg stampMsg = (GoStampMsg)dataObj; for (UInt32 j = 0; j < stampMsg.Count; j++) { GoStamp stamp = stampMsg.Get(j); Console.WriteLine("Frame Index = {0}", stamp.FrameIndex); Console.WriteLine("Time Stamp = {0}", stamp.Timestamp); Console.WriteLine("Encoder Value = {0}", stamp.Encoder); } } break; case GoDataMessageType.Measurement: { GoMeasurementMsg measurementMsg = (GoMeasurementMsg)dataObj; for (UInt32 k = 0; k < measurementMsg.Count; ++k) { GoMeasurementData measurementData = measurementMsg.Get(k); Console.WriteLine("ID: {0}", measurementMsg.Id); Console.WriteLine("Value: {0}", measurementData.Value); Console.WriteLine("Decision: {0}", measurementData.Decision); } } break; } } system.Stop(); } catch (KException ex) { Console.WriteLine("Error: {0}", ex.Status); } // wait for ESC key Console.WriteLine("\nPress ENTER to continue"); do { System.Threading.Thread.Sleep(100); } while (Console.Read() != (int)ConsoleKey.Enter); return(1); }