mirror of https://bitbucket.org/ausocean/av.git
psi: using HasLocation or HasTime instead of ChkLocation or ChkTime
This commit is contained in:
parent
21dd2f4b70
commit
cf4c44f4d5
|
@ -54,7 +54,7 @@ func ChkTime(p []byte) error {
|
||||||
|
|
||||||
// ChkLocation takes a psi as a byte slice and checks to see if it has a location descriptor
|
// ChkLocation takes a psi as a byte slice and checks to see if it has a location descriptor
|
||||||
// - if so return nil, otherwise return error
|
// - if so return nil, otherwise return error
|
||||||
func ChkLocation(p []byte) error {
|
func HasLocation(p []byte) error {
|
||||||
if p[locationTagIndx] != locationDescTag {
|
if p[locationTagIndx] != locationDescTag {
|
||||||
return errors.New("PSI does not contain a location descriptor, cannot update")
|
return errors.New("PSI does not contain a location descriptor, cannot update")
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ func UpdateTime(d []byte, t uint64) error {
|
||||||
// TimeOf takes a byte slice representation of a psi-pmt and extracts it's
|
// TimeOf takes a byte slice representation of a psi-pmt and extracts it's
|
||||||
// timestamp, returning as a uint64 if it exists, otherwise returning 0 and nil
|
// timestamp, returning as a uint64 if it exists, otherwise returning 0 and nil
|
||||||
// if it does not exist
|
// if it does not exist
|
||||||
func TimeOf(p []byte) (t uint64, err error) {
|
func TimeFrom(p []byte) (t uint64, err error) {
|
||||||
err = ChkTime(p)
|
err = ChkTime(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
@ -96,8 +96,8 @@ func TimeOf(p []byte) (t uint64, err error) {
|
||||||
// TimeOf takes a byte slice representation of a psi-pmt and extracts it's
|
// TimeOf takes a byte slice representation of a psi-pmt and extracts it's
|
||||||
// timestamp, returning as a uint64 if it exists, otherwise returning 0 and nil
|
// timestamp, returning as a uint64 if it exists, otherwise returning 0 and nil
|
||||||
// if it does not exist
|
// if it does not exist
|
||||||
func LocationOf(p []byte) (g string, err error) {
|
func LocationFrom(p []byte) (g string, err error) {
|
||||||
err = ChkLocation(p)
|
err = HasLocation(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ func LocationStrBytes(l string) (out []byte) {
|
||||||
// descriptor and attempts to update the location data value with the passed string.
|
// descriptor and attempts to update the location data value with the passed string.
|
||||||
// If the psi does not contain a location descriptor, and error is returned.
|
// If the psi does not contain a location descriptor, and error is returned.
|
||||||
func UpdateLocation(d []byte, s string) error {
|
func UpdateLocation(d []byte, s string) error {
|
||||||
err := ChkLocation(d)
|
err := HasLocation(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,7 +231,7 @@ func TestTimeUpdate(t *testing.T) {
|
||||||
|
|
||||||
// TestTimeGet tsts to see if we can correctly get the timestamp from a pmt
|
// TestTimeGet tsts to see if we can correctly get the timestamp from a pmt
|
||||||
func TestTimeGet(t *testing.T) {
|
func TestTimeGet(t *testing.T) {
|
||||||
s, err := TimeOf(pmtTimeBytes1)
|
s, err := TimeFrom(pmtTimeBytes1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Getting timestamp failed with err: %v", err)
|
t.Errorf("Getting timestamp failed with err: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ func TestLocationGet(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error for TestLocationGet UpdateLocation(pb, locationTstStr1): %v", err)
|
t.Errorf("Error for TestLocationGet UpdateLocation(pb, locationTstStr1): %v", err)
|
||||||
}
|
}
|
||||||
g, err := LocationOf(pb)
|
g, err := LocationFrom(pb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error for TestLocationGet LocationOf(pb): %v", err)
|
t.Errorf("Error for TestLocationGet LocationOf(pb): %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue