Search in sources :

Example 11 with UpdateMsgType

use of org.thingsboard.server.gen.edge.v1.UpdateMsgType in project thingsboard by thingsboard.

the class EdgeGrpcSession method processEntityMessage.

private DownlinkMsg processEntityMessage(EdgeEvent edgeEvent, EdgeEventActionType action) {
    UpdateMsgType msgType = getResponseMsgType(edgeEvent.getAction());
    log.trace("Executing processEntityMessage, edgeEvent [{}], action [{}], msgType [{}]", edgeEvent, action, msgType);
    switch(edgeEvent.getType()) {
        case DEVICE:
            return ctx.getDeviceProcessor().processDeviceToEdge(edge, edgeEvent, msgType, action);
        case DEVICE_PROFILE:
            return ctx.getDeviceProfileProcessor().processDeviceProfileToEdge(edgeEvent, msgType, action);
        case ASSET:
            return ctx.getAssetProcessor().processAssetToEdge(edge, edgeEvent, msgType, action);
        case ENTITY_VIEW:
            return ctx.getEntityViewProcessor().processEntityViewToEdge(edge, edgeEvent, msgType, action);
        case DASHBOARD:
            return ctx.getDashboardProcessor().processDashboardToEdge(edge, edgeEvent, msgType, action);
        case CUSTOMER:
            return ctx.getCustomerProcessor().processCustomerToEdge(edgeEvent, msgType, action);
        case RULE_CHAIN:
            return ctx.getRuleChainProcessor().processRuleChainToEdge(edge, edgeEvent, msgType, action);
        case RULE_CHAIN_METADATA:
            return ctx.getRuleChainProcessor().processRuleChainMetadataToEdge(edgeEvent, msgType, this.edgeVersion);
        case ALARM:
            return ctx.getAlarmProcessor().processAlarmToEdge(edge, edgeEvent, msgType, action);
        case USER:
            return ctx.getUserProcessor().processUserToEdge(edge, edgeEvent, msgType, action);
        case RELATION:
            return ctx.getRelationProcessor().processRelationToEdge(edgeEvent, msgType);
        case WIDGETS_BUNDLE:
            return ctx.getWidgetBundleProcessor().processWidgetsBundleToEdge(edgeEvent, msgType, action);
        case WIDGET_TYPE:
            return ctx.getWidgetTypeProcessor().processWidgetTypeToEdge(edgeEvent, msgType, action);
        case ADMIN_SETTINGS:
            return ctx.getAdminSettingsProcessor().processAdminSettingsToEdge(edgeEvent);
        default:
            log.warn("Unsupported edge event type [{}]", edgeEvent);
            return null;
    }
}
Also used : UpdateMsgType(org.thingsboard.server.gen.edge.v1.UpdateMsgType)

Example 12 with UpdateMsgType

use of org.thingsboard.server.gen.edge.v1.UpdateMsgType in project thingsboard by thingsboard.

the class WidgetTypeEdgeProcessor method processWidgetTypeToEdge.

public DownlinkMsg processWidgetTypeToEdge(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType edgeEdgeEventActionType) {
    WidgetTypeId widgetTypeId = new WidgetTypeId(edgeEvent.getEntityId());
    DownlinkMsg downlinkMsg = null;
    switch(edgeEdgeEventActionType) {
        case ADDED:
        case UPDATED:
            WidgetTypeDetails widgetTypeDetails = widgetTypeService.findWidgetTypeDetailsById(edgeEvent.getTenantId(), widgetTypeId);
            if (widgetTypeDetails != null) {
                WidgetTypeUpdateMsg widgetTypeUpdateMsg = widgetTypeMsgConstructor.constructWidgetTypeUpdateMsg(msgType, widgetTypeDetails);
                downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addWidgetTypeUpdateMsg(widgetTypeUpdateMsg).build();
            }
            break;
        case DELETED:
            WidgetTypeUpdateMsg widgetTypeUpdateMsg = widgetTypeMsgConstructor.constructWidgetTypeDeleteMsg(widgetTypeId);
            downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addWidgetTypeUpdateMsg(widgetTypeUpdateMsg).build();
            break;
    }
    return downlinkMsg;
}
Also used : WidgetTypeUpdateMsg(org.thingsboard.server.gen.edge.v1.WidgetTypeUpdateMsg) DownlinkMsg(org.thingsboard.server.gen.edge.v1.DownlinkMsg) WidgetTypeId(org.thingsboard.server.common.data.id.WidgetTypeId) WidgetTypeDetails(org.thingsboard.server.common.data.widget.WidgetTypeDetails)

Example 13 with UpdateMsgType

use of org.thingsboard.server.gen.edge.v1.UpdateMsgType in project thingsboard by thingsboard.

the class DashboardEdgeProcessor method processDashboardToEdge.

public DownlinkMsg processDashboardToEdge(Edge edge, EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType action) {
    DashboardId dashboardId = new DashboardId(edgeEvent.getEntityId());
    DownlinkMsg downlinkMsg = null;
    switch(action) {
        case ADDED:
        case UPDATED:
        case ASSIGNED_TO_EDGE:
        case ASSIGNED_TO_CUSTOMER:
        case UNASSIGNED_FROM_CUSTOMER:
            Dashboard dashboard = dashboardService.findDashboardById(edgeEvent.getTenantId(), dashboardId);
            if (dashboard != null) {
                CustomerId customerId = null;
                if (!edge.getCustomerId().isNullUid() && dashboard.isAssignedToCustomer(edge.getCustomerId())) {
                    customerId = edge.getCustomerId();
                }
                DashboardUpdateMsg dashboardUpdateMsg = dashboardMsgConstructor.constructDashboardUpdatedMsg(msgType, dashboard, customerId);
                downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addDashboardUpdateMsg(dashboardUpdateMsg).build();
            }
            break;
        case DELETED:
        case UNASSIGNED_FROM_EDGE:
            DashboardUpdateMsg dashboardUpdateMsg = dashboardMsgConstructor.constructDashboardDeleteMsg(dashboardId);
            downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addDashboardUpdateMsg(dashboardUpdateMsg).build();
            break;
    }
    return downlinkMsg;
}
Also used : DownlinkMsg(org.thingsboard.server.gen.edge.v1.DownlinkMsg) Dashboard(org.thingsboard.server.common.data.Dashboard) DashboardId(org.thingsboard.server.common.data.id.DashboardId) CustomerId(org.thingsboard.server.common.data.id.CustomerId) DashboardUpdateMsg(org.thingsboard.server.gen.edge.v1.DashboardUpdateMsg)

Example 14 with UpdateMsgType

use of org.thingsboard.server.gen.edge.v1.UpdateMsgType in project thingsboard by thingsboard.

the class DeviceProfileEdgeProcessor method processDeviceProfileToEdge.

public DownlinkMsg processDeviceProfileToEdge(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType action) {
    DeviceProfileId deviceProfileId = new DeviceProfileId(edgeEvent.getEntityId());
    DownlinkMsg downlinkMsg = null;
    switch(action) {
        case ADDED:
        case UPDATED:
            DeviceProfile deviceProfile = deviceProfileService.findDeviceProfileById(edgeEvent.getTenantId(), deviceProfileId);
            if (deviceProfile != null) {
                DeviceProfileUpdateMsg deviceProfileUpdateMsg = deviceProfileMsgConstructor.constructDeviceProfileUpdatedMsg(msgType, deviceProfile);
                downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addDeviceProfileUpdateMsg(deviceProfileUpdateMsg).build();
            }
            break;
        case DELETED:
            DeviceProfileUpdateMsg deviceProfileUpdateMsg = deviceProfileMsgConstructor.constructDeviceProfileDeleteMsg(deviceProfileId);
            downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addDeviceProfileUpdateMsg(deviceProfileUpdateMsg).build();
            break;
    }
    return downlinkMsg;
}
Also used : DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) DeviceProfileUpdateMsg(org.thingsboard.server.gen.edge.v1.DeviceProfileUpdateMsg) DownlinkMsg(org.thingsboard.server.gen.edge.v1.DownlinkMsg) DeviceProfileId(org.thingsboard.server.common.data.id.DeviceProfileId)

Example 15 with UpdateMsgType

use of org.thingsboard.server.gen.edge.v1.UpdateMsgType in project thingsboard by thingsboard.

the class EntityViewMsgConstructor method constructEntityViewUpdatedMsg.

public EntityViewUpdateMsg constructEntityViewUpdatedMsg(UpdateMsgType msgType, EntityView entityView, CustomerId customerId) {
    EdgeEntityType entityType;
    switch(entityView.getEntityId().getEntityType()) {
        case DEVICE:
            entityType = EdgeEntityType.DEVICE;
            break;
        case ASSET:
            entityType = EdgeEntityType.ASSET;
            break;
        default:
            throw new RuntimeException("Unsupported entity type [" + entityView.getEntityId().getEntityType() + "]");
    }
    EntityViewUpdateMsg.Builder builder = EntityViewUpdateMsg.newBuilder().setMsgType(msgType).setIdMSB(entityView.getId().getId().getMostSignificantBits()).setIdLSB(entityView.getId().getId().getLeastSignificantBits()).setName(entityView.getName()).setType(entityView.getType()).setEntityIdMSB(entityView.getEntityId().getId().getMostSignificantBits()).setEntityIdLSB(entityView.getEntityId().getId().getLeastSignificantBits()).setEntityType(entityType);
    if (customerId != null) {
        builder.setCustomerIdMSB(customerId.getId().getMostSignificantBits());
        builder.setCustomerIdLSB(customerId.getId().getLeastSignificantBits());
    }
    if (entityView.getAdditionalInfo() != null) {
        builder.setAdditionalInfo(JacksonUtil.toString(entityView.getAdditionalInfo()));
    }
    return builder.build();
}
Also used : EntityViewUpdateMsg(org.thingsboard.server.gen.edge.v1.EntityViewUpdateMsg) EdgeEntityType(org.thingsboard.server.gen.edge.v1.EdgeEntityType)

Aggregations

DownlinkMsg (org.thingsboard.server.gen.edge.v1.DownlinkMsg)12 CustomerId (org.thingsboard.server.common.data.id.CustomerId)6 AssetId (org.thingsboard.server.common.data.id.AssetId)2 DeviceId (org.thingsboard.server.common.data.id.DeviceId)2 EntityViewId (org.thingsboard.server.common.data.id.EntityViewId)2 RuleChainId (org.thingsboard.server.common.data.id.RuleChainId)2 RuleChain (org.thingsboard.server.common.data.rule.RuleChain)2 AlarmUpdateMsg (org.thingsboard.server.gen.edge.v1.AlarmUpdateMsg)2 EntityViewUpdateMsg (org.thingsboard.server.gen.edge.v1.EntityViewUpdateMsg)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Customer (org.thingsboard.server.common.data.Customer)1 Dashboard (org.thingsboard.server.common.data.Dashboard)1 Device (org.thingsboard.server.common.data.Device)1 DeviceProfile (org.thingsboard.server.common.data.DeviceProfile)1 EntityView (org.thingsboard.server.common.data.EntityView)1 User (org.thingsboard.server.common.data.User)1 Alarm (org.thingsboard.server.common.data.alarm.Alarm)1 Asset (org.thingsboard.server.common.data.asset.Asset)1 AlarmId (org.thingsboard.server.common.data.id.AlarmId)1 DashboardId (org.thingsboard.server.common.data.id.DashboardId)1