n4af / TR4W

TRLOG 4 Windows free amateur radio logging application
GNU General Public License v3.0
19 stars 6 forks source link

SendParameterToNetwork should not send all parameters #610

Closed ny4i closed 1 year ago

ny4i commented 2 years ago

During set for Field Day, I clicked To Network (which calls SendParameterToNetwork in uOption). I discovered this sends all the options to the other stations. This is not optimal. For example, COMPUTER ID is sent to the others which is bad. There should be code added to exclude certain fields. A good way to do it would be to add this to the command array to indicate if the parameter should be sent to the network and only send those.

ny4i commented 2 years ago

Here is the code.

procedure SendParameterToNetwork();
var
  Row                                   : integer;
begin
  if NetSocket = 0 then Exit;
  Row := ListView_GetNextItem(SettingshLV, -1, LVNI_SELECTED);
  if CommandsFilter <> cfCol then
    if CFGCA[IndexArray[Row + 1]].crJ = 2 then Exit;

  Windows.ZeroMemory(@ParameterToNetwork.pnCommand, SizeOf(ParameterToNetwork.pnCommand) + SizeOf(ParameterToNetwork.pnValue));
{(*}
  ParameterToNetwork.pnCommand[0] := Char(ListView_GetItemText(SettingshLV, Row, COMMAND_FIELD, @ParameterToNetwork.pnCommand[1], SizeOf(ParameterToNetwork.pnCommand)));
  ParameterToNetwork.pnValue[0]   := Char(ListView_GetItemText(SettingshLV, Row, VALUE_FIELD,   @ParameterToNetwork.pnValue[1],   SizeOf(ParameterToNetwork.pnValue)));
{*)}
  SendToNet(ParameterToNetwork, SizeOf(ParameterToNetwork));
end;

By adding another flag to the CFGRecord such as crNetwork, then only those items with a value of 1 would be sent to network.

Here is CFGRecord (line 84 in uCFG):

CFGRecord = record
    {(*}
    {04}crCommand : PChar;
    {04}crAddress : Pointer;

    {02}crMin     : Word;
    {02}crMax     : Word;

    {01}crS       : CFGStatus;
    {01}crA       : Byte;//additional proc
    {01}crC       : Byte;//1-write to CFG file,
    {01}crP       : Byte;//Procedure 0-no proc,

    {01}crJ       : Byte;//0-edit, 1 -edit+restart, 2-readonly,3-message(ro)
    {01}crKind    : CFGKind;
    {01}cfFunc    : CFGFunc;
    {01}crType    : CFGType;
    {*)}
   end;
ny4i commented 1 year ago

As described above, added crNetwork to each command. If crNetwork NOT = 0, we send the command to the network. Also, in the Config dialog, the description adds Sent to Network or NOT sent to Network as the case may be. The debug log will also show if the SendParameterToNetwork function exists early due to crNetwork = 0 (if DEBUG or TRACE is set).

This has to be tested yet as I have not setup a second instance yet.

Look at the CFGCA array around line 332 in uCFG for the parameters set to 0 or 1. crNetwork is at the end of each command declaration.