Hello,
I'm in the process of creating a cool interface with your DLL. So far so good but I come across bugs that confuse me and it seems I didn't really get the FSUIPC conversation.
An example, let say I have an object holding Offsets as it :
public class FsVar {
public string Name { get; set; } public int Offset { get; set; } public int OffsetLength { get; set; } public string OffsetType { get; set; }
public int BitIndex{ get; set; } public Offset<BitArray> OffsetBitArray { get; set; }
public int ColdAndDarkDefault { get; set; } public string Value { get { if (OffsetType == "BIT") return (OffsetBitArray.Value[bitIndex]) ? "1" : "0"; return "" } set { if (OffsetType == "BIT") OffsetBitArray.Value[bitIndex] = (value == "1");
return; } } }
My program :
public class MainProgram {
public List<FsVar> FsVarList { get; set; }
MainProgram() {
FSUIPCConnection.Open();
FsVarList = new List<FsVar>(); FsVarList = FsVarGetFromCsv();
//So now I have a list of FsVar, I instantiate the Offset<BitArray> of these
foreach (var item in FsVarList) { switch (item.OffsetType) {
case "BIT":
item.OffsetBitArray = new Offset<BitArray>(item.Offset, item.OffsetLength);
break;
} }
//Register the offsets ?
FSUIPCConnection.Process();
//Now I set default values to the offset
foreach (var item in FsVarList) { item.Value = item.ColdAndDarkDefault.ToString(); }
//Each offset has now is default value, so I send this to FS ProcessAction();
}
}
My problem is at the end when I set the default values. To me FsVarList has all the objects correctly set and just calling ProcessAction(); will update corresponding Offset in FS.
This is actually somewhat true, but by testing I figured out not all values where correctly sent to FS, what I had to do to insure proper setting of EACH value is that :
foreach (var item in FsVarList) { item.Value = item.ColdAndDarkDefault.ToString();
ProcessAction(); }
There is approx 250 values in the list (Project Magenta pmSystems Offsets), can you explain me the difference between these two functions behind the scene in your DLL and in FSUIPC :
// Kind of work but some values are not sent to FS as it should
public void ColdAndDarkStateSet() { foreach (var item in FsVarList) { item.Value = item.ColdAndDarkDefault.ToString(); } ProcessAction();
}
// Seems to work on every hit
public void ColdAndDarkStateSet() { foreach (var item in FsVarList) { item.Value = item.ColdAndDarkDefault.ToString();
ProcessAction(); }
}
Of course the one thate work seems slower to run and has i read in your documentation ProcessAction(); should only be used only when necessary. The logic of the first function seemed right to me.
Is it possible that in between the settings of each of the offset values in my FsVarList and the call to ProcessAction(); the other concurrently running application (Project Magenta pmSystems) has set different values to these offset ?
In fact, each setting of every offset should be considered immediately followed by a ProcessAction(); ?
Is that right ?
Thank you