ckittel / PrtgSharp

PrtgSharp - A Library to help create well-formed PRTG XML responses
MIT License
2 stars 2 forks source link

decimalmode #1

Open mitch2k opened 5 years ago

mitch2k commented 5 years ago

Hi,

first of all thanks for this great library!

I was wondering how I can add the DecimalMode property

Currently this: new Channel("Total MDisk Capacity", 1.112706E+15, new[] { ValueUnitProperty.BytesDisk}),

Results in 1012,00021163095 TByte, but I want it like 1012,00 TByte

Thanks!!

Mitch

mitch2k commented 4 years ago

Hi @ckittel , is this something you could help me out with? Thanks!

ckittel commented 4 years ago

Been a while since I've used PRTG. BytesDisk was always in bytes, but the UI could convert to another unit (a more "reasonable" unit), but it required the data to come in as bytes. Check how you are displaying it in the UI.

Otherwise, not sure if I can help anymore. No longer have access to a PRTG instance :(

mitch2k commented 4 years ago

Hi @ckittel , Thanks for the reply. Basically my problem is that I can't set the channel to Float/Decimalmode. I'm looking at this: https://github.com/ckittel/PrtgSharp/blob/96a61ce3c29585d460a22606a41b9d99ae2ac96f/PrtgSharp/ChannelProperties/Optional/ValueDataTypeProperty.cs

Reading the code, it seems that I need to set ValueDataTypeProperty to 1 to mark it as a float.

public static ValueDataTypeProperty Float => new ValueDataTypeProperty("1");

But this is not working and is giving me a protection level error: channels.Add( new Channel(Convert.ToString(item["Name"]) + " Voltage", Convert.ToInt32 (item["ReadingVolts"]), new[] { ValueUnitProperty.Custom, new CustomValueUnitProperty("V"), new ValueDataTypeProperty("1") } ) );

So I guess I'm doing it wrong?