dimanche 8 juillet 2018

How to implement byte command class


I'm looking for a guide regarding best practices to implement my class.
My case:
I want to create a class for controlling PTZ cameras. The command is sent through the network as a byte[] to the camera. There are 2 protocols with different commands and values, so I will create a class for each protocol.

Is it best to create a byte[] for each command and list them in the class and change the values based on the user input. For example:

byte[] up ={ 0xff, 0x12, 0x03, .... }
byte[] down ={ 0xf0, 0x1a, 0x03, .... }
byte[] left ={ 0xaf, 0x10, 0x03, .... }
byte[] right ={ 0xff, 0x02, 0x06, .... }
void setUpValue(byte speed)
{ 
    up[3]=speed;
}

or do I dynamically create the byte[] based on the user request?

Aucun commentaire:

Enregistrer un commentaire