public static JhiTestResult SendAndReceiveDuringSleepTest() { //should be manual test int output = -1; Console.Write("Installing App " + eventServiceWithTimeoutAppID + "... "); jhi.Install(eventServiceWithTimeoutAppID, eventServiceWithTimeoutAppPath); Console.WriteLine("Success. " + DateTime.Now); Console.Write("Creating session... "); JhiSession eventsSession; jhi.CreateSession(eventServiceWithTimeoutAppID, JHI_SESSION_FLAGS.None, null, out eventsSession); Console.WriteLine("Success. " + DateTime.Now); #region sendAndReceice finish during sleep Console.Write("Setting PC to go to CS for 25 seconds in 2 seconds from now. " + DateTime.Now); WinTools.setConnectedStandby(2000, 25000, false); Console.Write("Starting send and receive for 10 seconds... " + DateTime.Now); output = -1; Byte[] x = new Byte[] { 10 }; // +/- seconds Byte[] y = new Byte[3]; jhi.SendAndRecv2(eventsSession, 40, x, ref y, out output); Console.WriteLine("output = " + output + " " + DateTime.Now); if (output != 0) { return(JhiTestResult.Failed); } #endregion #region sendAndReceice finish after sleep Console.Write("Setting PC to go to CS for 10 seconds in 2 seconds from now. " + DateTime.Now); WinTools.setConnectedStandby(2000, 10000, false); Console.Write("Starting send and receive for 35 seconds... " + DateTime.Now); output = -1; Byte[] x2 = new Byte[] { 35 }; // +/- seconds Byte[] y2 = new Byte[3]; jhi.SendAndRecv2(eventsSession, 40, x2, ref y2, out output); Console.WriteLine("output = " + output + " " + DateTime.Now); if (output != 0) { return(JhiTestResult.Failed); } #endregion return(JhiTestResult.Succeeded); }
public static JhiTestResult eventDuringSleepTest() { invoked = false; Console.Write("Installing App " + eventServiceWithTimeoutAppID + "... "); jhi.Install(eventServiceWithTimeoutAppID, eventServiceWithTimeoutAppPath); Console.WriteLine("Success. " + DateTime.Now); Console.Write("Creating session... "); JhiSession eventsSession; jhi.CreateSession(eventServiceWithTimeoutAppID, JHI_SESSION_FLAGS.None, null, out eventsSession); Console.WriteLine("Success. " + DateTime.Now); Console.Write("Registering for events... "); jhi.RegisterEvents(eventsSession, callbackFun); Console.WriteLine("Success. " + DateTime.Now); #region event receice during sleep //Console.WriteLine("Success. " + DateTime.Now); Console.Write("Starting send and receive... " + DateTime.Now); int output; Byte[] x = new Byte[] { 15 }; // used as seconds to before event Byte[] y = new Byte[3]; jhi.SendAndRecv2(eventsSession, 20, x, ref y, out output); Console.WriteLine("Success. " + DateTime.Now); Console.WriteLine("An event should be raised in 15 seconds " + DateTime.Now); Console.Write("Setting PC to go to CS for 30 seconds. " + DateTime.Now); WinTools.setConnectedStandby(0, 30000, true); for (int i = 0; i < 150; i++) { Thread.Sleep(100); if (invoked) { Console.WriteLine("Event raised! - success. " + DateTime.Now); break; } } if (!invoked) { Console.WriteLine("Event not received!"); return(JhiTestResult.Failed); } invoked = false; #endregion #region event receice after sleep //Console.WriteLine("Success. " + DateTime.Now); Console.Write("Starting send and receive... " + DateTime.Now); int output2; Byte[] x2 = new Byte[] { 35 }; // used as seconds to before event Byte[] y2 = new Byte[3]; jhi.SendAndRecv2(eventsSession, 20, x2, ref y2, out output2); Console.WriteLine("Success. " + DateTime.Now); Console.WriteLine("An event should be raised in 35 seconds. " + DateTime.Now); Console.Write("Setting PC to go to CS for 15 seconds. " + DateTime.Now); WinTools.setConnectedStandby(0, 30000, true); #endregion for (int i = 0; i < 150; i++) { Thread.Sleep(100); if (invoked) { Console.WriteLine("Event raised! - success. " + DateTime.Now); break; } } return(bool_To_JhiTestResult(invoked)); }