func (sm *SMA) Diagnose() {
	fmt.Printf("  IP:             %s\n", sm.device.Address())
	fmt.Printf("  Serial:         %d\n", sm.device.SerialNumber())
	fmt.Printf("  EnergyMeter:    %v\n", sm.device.IsEnergyMeter())
	fmt.Printf("\n")

	if name, err := sm.device.GetDeviceName(); err == nil {
		fmt.Printf("  Name: %s\n", name)
	}

	if devClass, err := sm.device.GetDeviceClass(); err == nil {
		fmt.Printf("  Device Class: 0x%X\n", devClass)
	}
	fmt.Printf("\n")

	if values, err := sm.device.GetValues(); err == nil {
		keys := make([]string, 0, len(values))
		keyLength := 0
		for k := range values {
			keys = append(keys, k)
			if len(k) > keyLength {
				keyLength = len(k)
			}
		}
		sort.Strings(keys)

		for _, k := range keys {
			fmt.Printf("  %s:%s %v %s\n", k, strings.Repeat(" ", keyLength-len(k)), values[k], sm.device.GetValueInfo(k).Unit)
		}
	}
}
// Diagnose implements the api.Diagnosis interface
Diagnose implements the api.Diagnosis interface
// Diagnose implements the api . Diagnosis interface
func (sm *SMA) Diagnose() {
	fmt.Printf("  IP:             %s\n", sm.device.Address())
	fmt.Printf("  Serial:         %d\n", sm.device.SerialNumber())
	fmt.Printf("  EnergyMeter:    %v\n", sm.device.IsEnergyMeter())
	fmt.Printf("\n")
	if name, err := sm.device.GetDeviceName(); err == nil {
		fmt.Printf("  Name: %s\n", name)
	}
	if devClass, err := sm.device.GetDeviceClass(); err == nil {
		fmt.Printf("  Device Class: 0x%X\n", devClass)
	}
	fmt.Printf("\n")
	if values, err := sm.device.GetValues(); err == nil {
		keys := make([]string, 0, len(values))
		keyLength := 0
		for k := range values {
			keys = append(keys, k)
			if len(k) > keyLength {
				keyLength = len(k)
			}
		}
		sort.Strings(keys)
		for _, k := range keys {
			fmt.Printf("  %s:%s %v %s\n", k, strings.Repeat(" ", keyLength-len(k)), values[k], sm.device.GetValueInfo(k).Unit)
		}
	}
}
func ( sm * SMA ) Diagnose ( ) { fmt . Printf ( " \n " , sm . device . Address ( ) ) fmt . Printf ( " \n " , sm . device . SerialNumber ( ) ) fmt . Printf ( " \n " , sm . device . IsEnergyMeter ( ) ) fmt . Printf ( " \n " ) if name , err := sm . device . GetDeviceName ( ) ; err == nil { fmt . Printf ( " \n " , name ) } if devClass , err := sm . device . GetDeviceClass ( ) ; err == nil { fmt . Printf ( " \n " , devClass ) } fmt . Printf ( " \n " ) if values , err := sm . device . GetValues ( ) ; err == nil { keys := make ( [ ] string , 0 , len ( values ) ) keyLength := 0 for k := range values { keys = append ( keys , k ) if len ( k ) > keyLength { keyLength = len ( k ) } } sort . Strings ( keys ) for _ , k := range keys { fmt . Printf ( " \n " , k , strings . Repeat ( " " , keyLength - len ( k ) ) , values [ k ] , sm . device . GetValueInfo ( k ) . Unit ) } } }
Diagnose implements the api.Diagnosis interface
Diagnose implements the api . Diagnosis interface