I am trying to get the progress indicator bar from my package to the user interface. I am failing badly. I created an mini code that mimics my main code. Here I keep track of a paralleltable.
Some how I need to take the value of the progress indicator out from the loop and package to the interface.
Here is the main code:
Get[FileNameJoin[{NotebookDirectory[EvaluationNotebook[]],
"DummyPackage.wl"}]];
Panel[DynamicModule[{np = 100, nd = 30, Res1 = 1.0,
Res2 = ProgressIndicator[0]},
Column[{Style["Random", "Function"] ,
Row[{"Digits ", InputField[Dynamic[nd]]}, Spacer[5]],
Row[{"Precision ", InputField[Dynamic[np]]}, Spacer[5]],
(*Button[Style["Inputs",Green,Bold],Res2=ProgressIndicator[0]],*)
Button[
Style["Calculate", Green, Bold], {Res2 = ProgressIndicator[0],
Res = DummyPackage`myDummyF[nd, np]; Res1 = Res[[1]];
Res2 = Res[[2]];}, Method -> "Queued"],
Row[{Style["Result ", 12, Red],
InputField[Dynamic[Res1], FieldSize -> 30, Enabled -> False]},
Spacer[15]],
Row[{Style["Progress ", 12, Red], Dynamic[Res2]}, Spacer[15]],
Button[Style["Save", Green, Bold],
NotebookSave[EvaluationNotebook[], Interactive -> True]]
}],
Initialization :> (
Get[FileNameJoin[{NotebookDirectory[EvaluationNotebook[]],
"DummyPackage.wl"}]];)]]
And the package :
BeginPackage["DummyPackage`"]
LaunchKernels[$ProcessorCount];
myDummyF[nd_,np_]:=Module[{mat,mat2,aI,dl,d=0,tr=0},
ns=200;
mat=SetAccuracy[RandomReal[{-100,100},ns],nd];
mat2=SetAccuracy[RandomReal[{-200,200},ns],nd];
aI=ConstantArray[0,np];
SetSharedVariable[d,tr];
ParallelEvaluate[dl = 0];
Monitor[aI=ParallelTable[If[Mod[dl++, Ceiling[nd/75]] == 0, d += Ceiling[nd/75]];
If[iC==np,d==np];
aI=SetAccuracy[mat.(mat2/iC^0.5),nd]
,{iC,np},DistributedContexts-> {"DummyPackage`"}];,tr=(d/np);];
aInum=Apply[Plus,(aI/np)];
Return[{aInum,ProgressIndicator[tr]}]];
SetAttributes[{myDummyF},{ReadProtected,Protected,Locked}];
EndPackage[];
>