Names Default To Here( 1 ); Clear Log(); Clear Globals(); Clear Symbols(); If( Host is( "Windows" ), , Throw() ); // (jmp for windows only) // --------------------------------------------------------------------- Include( "j2f_Include.jsl" ); // Contains WINAPI & j2fAPI definitions // june 2020 version (c) 2020 Franco Anzani - SixSigmaIn Team snc Include( "j2f_Demo_msg.jsl" ); // Contains this demo txt messages Title = Concat( " availble in j2Friend :", _$crlf, _$crlf, "private : processed by a single Client only,", _$crlf, "public : processed by all active Clients,", _$crlf, "common : as public for active Clients with same class only.", _$crlf, _$crlf, "This code (video) tests (shows) the difference of a private vs a common message for Excel Clients." ); // // ----------------------------------------------------------------------- iLed_1 = 1; // first Custom.Client // do not change iExcel_1 = 2; // first COM.App.Client // do not change iExcel_2 = 3; // second COM.App.Client ( Same Class of iExcel_1 Client ) // do not change Test_Clients = 3; // do not change // // Stress Test Options --------------------------------------------- Test_max_ISize = 100; // 500; // loop size Test_show_MsgBox = 1; // show msgbox Test_show_res = 1; // show info to log during test Test_COM_App_hidden = 0; // hide COM.Apps or not Test_Add_Clients = 0; // additional Custom App Clients try 0, 1 or more // ----------------------------------------------------------------------- ID_MSG_common_Excel =0; ID_MSG_common_Excel = iExcel_1; // <----- rem this line to restore UnitTest msg to this Client as private // // // - Start Host --------------------------------------------- If( Init_message( Title ) == 2, Stop() ); meHost = Create_Me(); If( meHost == _%false, Throw() ); // set jsl (jmp) as host , exit on error // // - Create random data --------------------------------------------- Col_Data = J( Test_max_ISize, 1, Random Integer( 0, 2147483647 ) ); rnd_dt = New Table( "Temp", New Column( "J_Data", Numeric, Continuous, Set Values( Col_Data ) ), New Column( "J_Mod_8", Numeric, Continuous, Formula( Modulo( :Name( "J_Data" ), 8 ) ) ) ); // // - Start Clients ---------------------------- j2f_clients = Test_Clients + Test_Add_Clients; // do not change i_Els = Char( Test_max_ISize ); If( Test_COM_App_hidden, c_mode = _$as_hide, c_mode = _$as_view ); If( test_show_MsgBox, MessageBox_fn( Concat( "The table with ", i_Els, " Random Data is ready. Now Press Ok to start a Custom.No.COM.App as Client" ), _%bt_Ok ) ); New_Client( meHost, iLed_1, "mte_led.exe", _$as_custom, _$as_view ); // ComApp = "excel.application"; If( test_show_MsgBox, MessageBox_fn( Concat( "Now Press Ok to start two COM.App as Clients (", ComApp, " ", c_mode, ")" ), _%bt_Ok ) ); New_Client( meHost, iExcel_1, "mte_CRT.exe", ComApp, c_mode ); New_Client( meHost, iExcel_2, "mte_CRT.exe", ComApp, c_mode ); // If( Test_Add_Clients > 0, If( test_show_MsgBox, MessageBox_fn( Concat( "Press Ok to start ", Char( Test_Add_Clients ), " additional Excel Apps as Clients." ), _%bt_Ok ) ); For( CLoop = Test_Clients + 1, CLoop <= j2f_clients, cLoop++, New_Client( meHost, CLoop, "mte_CRT.exe", ComApp, c_mode ) ); ); // // - Start Value MOD 8 Stress Test ----------------------------------- If( test_show_MsgBox, If( ID_MSG_common_Excel, u_msg = Concat( "a private msg to Custom.Led and a unique common message to ", Char( j2f_clients - 1 ), " Excel.Clients, for ", i_Els, " times." ), u_msg = Concat( i_Els, " private messages for each of the ", Char( j2f_clients ), " Clients." ) ); MessageBox_fn( Concat( "Press Ok to start Mod 8 Unit Test using ", u_msg ), _%bt_Ok ); ); // Print( Concat( "Start MOD 8 Stress Test (", i_Els, " times)", _$crlf ) ); waitTime = 0; bt = HP Time(); For( iLoop = 1, iLoop <= Test_max_ISize, iLoop++, rnd = Col_Data[iLoop]; // To_UnitTest_Loop( iLed_1, iloop, rnd, Test_show_res ); // If( ID_MSG_common_Excel, To_UnitTest_Loop( ID_MSG_common_Excel, iloop, rnd, Test_show_res, _%msg_common ), For( CLoop = 2, CLoop <= j2f_clients, cLoop++, To_UnitTest_Loop( Cloop, iloop, rnd, Test_show_res ) ) ); Wait( waitTime ); ); //- evaluate time required -------------------------------------------- et = HP Time(); rt = (et - bt) / 1000; Print( Concat( _$crlf, "Required Time (sec) : ", Char( rt / 1000 ) ) ); Print( Concat( _$crlf, "End MOD 8 Stress Test ------------------" ) ); // // - Show COM Clients, if necessary ------------------------------ If( Test_COM_App_hidden, For( CLoop = 2, CLoop <= j2f_clients, cLoop++, To_Client_Show( CLoop, _$mtE_c_show ) ) ); // - Check for data errors If( test_show_MsgBox, MessageBox_fn( "Check for [syncronized data] errors in Loop threads, using Client's MOD function", _%bt_Ok ) ); Print( Concat( _$crlf, "Start Check Error Test" ) ); // x_code = Concat( "With ", _$ObjApp, _$crlf, ".Range(", _$dq, "B1:B", i_Els, _$dq, ").FormulaR1C1 = ", _$dq, "=MOD(RC[-1],8)", _$dq, _$crlf, "End With" ); To_Client_As_Client_Code( iExcel_1, x_code ); To_Client_As_Client_Code( iExcel_2, x_code ); // If( test_show_MsgBox, MessageBox_fn( "Get Client Data for comparison with original JMP data.", _%bt_Ok ) ); cX_Data = Get_Client_as_Numeric_Column( iExcel_1, "A1:A" || i_Els ); rnd_dt << New Column( "X1_Data", Numeric, Continuous, Set Values( cX_Data ) ); cX_Data = Get_Client_as_Numeric_Column( iExcel_1, "B1:B" || i_Els ); rnd_dt << New Column( "X1_Mod_8", Numeric, Continuous, Set Values( cX_Data ) ); // cX_Data = Get_Client_as_Numeric_Column( iExcel_2, "A1:A" || i_Els ); rnd_dt << New Column( "X2_Data", Numeric, Continuous, Set Values( cX_Data ) ); cX_Data = Get_Client_as_Numeric_Column( iExcel_2, "B1:B" || i_Els ); rnd_dt << New Column( "X2_Mod_8", Numeric, Continuous, Set Values( cX_Data ) ); // rnd_dt << New Column( "X1_Check", Numeric, Continuous, Formula( :Name( "X1_Data" ) == :Name( "J_Data" ) ) ); rnd_dt << New Column( "X1_Check8", Numeric, Continuous, Formula( :Name( "X1_Mod_8" ) == :Name( "J_Mod_8" ) ) ); // rnd_dt << New Column( "X2_Check", Numeric, Continuous, Formula( :Name( "X2_Data" ) == :Name( "J_Data" ) ) ); rnd_dt << New Column( "X2_Check8", Numeric, Continuous, Formula( :Name( "X2_Mod_8" ) == :Name( "J_Mod_8" ) ) ); // // - Check Error --------------------------------------------- Test_Error = 0; x1_Sum = Col Sum( :X1_Check ); x1_Sum8 = Col Sum( :X1_Check8 ); x2_Sum = Col Sum( :X2_Check ); x2_Sum8 = Col Sum( :X2_Check8 ); If( x1_Sum != Test_max_ISize | x1_Sum8 != Test_max_ISize, test_Error += 1; MessageBox_fn( Char( (Test_max_ISize - x1_sum) + (Test_max_ISize - x1_sum8) ) || " Errors processing Excel_1", _%bt_Ok ); ); If( x2_Sum != Test_max_ISize | x2_Sum8 != Test_max_ISize, test_Error += 1; MessageBox_fn( Char( (Test_max_ISize - x2_sum) + (Test_max_ISize - x2_sum8) ) || " Errors processing Excel_2", _%bt_Ok ); ); If( test_Error, Print( Concat( "Errors found in ", Char( test_Error ), " Client(s)." ) ), Print( "No Errors found." ); // - Show info about host and Client Processes --------------------------------------------- If( test_show_MsgBox, MessageBox_fn( Concat( "No Errors found.", _$crlf, "Now some info about Host and Client Processes" ), _%bt_Ok ) ); To_Client_As_vbs_codeFile( iExcel_1, _$nul_obj, j2F_Example_path || "j2f_Stress_processes.vbs" ); ); // // - Close / Release Clients ------------------------------------------ For( CLoop = 1, CLoop <= j2f_clients, cLoop++, Client_Close( CLoop ) ); Print( _$crlf || "COM Client(s) released and Custom Client(s) closed." ); If( MessageBox_fn( "Press Ok to closedown COM Clients and JMP Table or Cancel to leave them open ..", _%bt_OkCancel ) == 1, For( CLoop = 2, CLoop <= j2f_clients, cLoop++, Client_CloseDown( CLoop ) ); Close( rnd_dt, NoSave ); ); // Final_message( "Excel 2013[32] +No.COM.Custom.App[32]", 3 ); // 1 or 3 //