Compare commits

...

3 Commits

  1. 12
      ui/amqp_test.go
  2. 6
      yabl/init.go
  3. 9
      yabl/strings.go

@ -33,6 +33,18 @@ func TestNewAmqp(t *testing.T) {
client.Consume(event)
event = &yabl.Event{
Tag: &tag,
Field: &field,
ActionName: &action,
Object: nil,
//unit: 3,
Updated: &now,
Value: nil,
}
client.Consume(event)
client.Stop()
})

@ -12,7 +12,7 @@ func (c *converter) initialize() {
{length: 10, setter: cpe.setPresentCurrent, name: FPresentCurrent},
{length: 11, setter: cpe.setPresentVoltage, name: FPresentVoltage},
}
c.protocolMap[key] = &action{fields: fields, interval: 50, name: PCpuPresentEnergy, object: cpe}
c.protocolMap[key] = &action{fields: fields, interval: 1000, name: PCpuPresentEnergy, object: cpe}
}
c.cpuPeripheryInstance = &CpuPeriphery{unit: 0}
@ -94,7 +94,7 @@ func (c *converter) initialize() {
{length: 11, setter: ppe.setVoltageAfter, name: FVoltageAfter},
{length: 10, setter: ppe.setPresentCurrent, name: FPresentCurrent},
}
c.protocolMap[key] = &action{fields: fields, interval: 50, name: PPuPresentEnergy, object: ppe}
c.protocolMap[key] = &action{fields: fields, interval: 1000, name: PPuPresentEnergy, object: ppe}
}
for i := uint(1); i <= CONNECTOR_COUNT; i++ {
@ -349,7 +349,7 @@ func (c *converter) initialize() {
{length: 10, setter: cpe.setPresentCurrent, name: FPresentCurrent},
{length: 8, setter: cpe.setConnectedOut, name: FConnectedOut},
}
c.protocolMap[key] = &action{fields: fields, interval: 500, name: PConverterPresentEnergy, object: cpe}
c.protocolMap[key] = &action{fields: fields, interval: 1000, name: PConverterPresentEnergy, object: cpe}
}
for i := uint(1); i < CONVERTERS_MAX; i++ {

@ -217,19 +217,24 @@ func (c ConnectedOut8bitType) String() string {
}
func (u *Event) MarshalJSON() ([]byte, error) {
var val *string
if u.Value != nil {
s := fmt.Sprintf("%v", u.Value)
val = &s
}
return json.Marshal(struct {
Host *string
Unit uint
ActionName *AName
Field *FName
Updated *time.Time
Value string
Value *string `json:"Value,omitempty"`
}{
Host: u.Tag,
Unit: u.GetUnitId(),
ActionName: u.ActionName,
Field: u.Field,
Updated: u.Updated,
Value: fmt.Sprintf("%v", u.Value),
Value: val,
})
}

Loading…
Cancel
Save