package com.cisdi.data.AMETEKSurfaceVision;

import com.cisdi.data.AMETEKSurfaceVision.gateway.SurfaceVisionConstants;
import java.util.Map;

import com.cisdi.data.sdk.gateway.message.SocketMessage;
import com.cisdi.data.sdk.procotol.SocketProtocol;
import com.cisdi.data.sdk.procotol.base.ProtocolBase;
import com.cisdi.data.sdk.procotol.message.SocketReturnMessage;
import com.cisdi.data.sdk.vo.DecodeVo;
import com.cisdi.data.sdk.vo.ReturnVo;

/**
 * 表检仪协议发送给平台的数据编解码
 *
 * @author tzz
 */
public class AMETEKSurfaceVisionSocketProtocol extends ProtocolBase implements SocketProtocol {
    @SuppressWarnings("unchecked")
    @Override
    public DecodeVo deCode(SocketMessage message) {
        DecodeVo vo = new DecodeVo();

        Object object = message.getPropsMap().get(SurfaceVisionConstants.S_V_SEND_PLATFORM_DATA);

        Map<String, Object> map = (Map<String, Object>)object;

        vo.setData(map);
        return vo;
    }

    @Override
    public SocketReturnMessage enCode(ReturnVo returnVo) {
        SocketReturnMessage message = new SocketReturnMessage();
        message.setDeviceId(returnVo.getDeviceId());
        message.setMsgId(returnVo.getMsgId());
        message.setMsgKey(returnVo.getMsgKey());
        message.getPropsMap().put(SurfaceVisionConstants.S_V_SEND_DATA, returnVo.getValue());
        return message;
    }
}
