public static int getIdx(this ProtocolOp caller)
 {
     if (CManager.IsRS232)
     {
         return(caller.RS232.Idx);
     }
     else if (CManager.IsCAN)
     {
         return(caller.CAN.Idx);
     }
     return(-1);
 }
 public static string getCmd(this ProtocolOp caller)
 {
     if (CManager.IsRS232)
     {
         return(caller.RS232.Cmd.ToString());
     }
     else if (CManager.IsCAN)
     {
         return(caller.CAN.Cmd);
     }
     return(null);
 }
예제 #3
0
 public static byte[] MakePacket(ProtocolOp op, bool isGet, bool isFloat, string data = "0", int nodeId = 127)
 {
     byte[] result = null;
     if (Globals.IsCAN)
     {
         result = MakeCANPacket(nodeId, op.CAN.Cmd, op.CAN.Idx, isGet, isFloat, data);
     }
     else if (Globals.IsRS232)
     {
         result = MakeRS232Packet(op.RS232.Cmd, op.RS232.Idx, data, isGet, isFloat);
     }
     return(result);
 }
        public static Abs_UC_DataType Create(ProtocolOp protocolOp)
        {
            switch (protocolOp.UIDefaultType.Type)
            {
            case E_DB_UI_Type.FLOAT_GET_SET:
                return(new UC_FloatGetSet());

            case E_DB_UI_Type.BOOL_GET_SET:
                return(new UC_BoolGetSet());

            case E_DB_UI_Type.FLOAT_GET:
                return(new UC_FloatGet());

            case E_DB_UI_Type.BOOL_GET:
                return(new UC_BoolGet());
            }
            return(null);
        }
예제 #5
0
        private bool Add()
        {
            try {
                ProtocolOp Op = new ProtocolOp();

                int    CANidx = int.Parse(CANIdx.Text);
                string cancmd = CANcmd.Text.Trim();
                int    key    = Utils.MakeKey(cancmd, CANidx);

                var CAN = new ProtocolOpCAN()
                {
                    Cmd = CANcmd.Text,
                    Idx = int.Parse(CANIdx.Text)
                };
                var RS232 = new ProtocolOpRS232()
                {
                    Cmd = int.Parse(RS232cmd.Text),
                    Idx = int.Parse(RS232Idx.Text)
                };


                var DataType = combo_dataType.SelectedValue as ProtocolOpDataType;

                Op = new ProtocolOp()
                {
                    CAN       = CAN,
                    CmdName   = cmdName.Text,
                    CmdUIName = cmdUIName.Text,
                    DataType  = DataType,
                    RS232     = RS232
                };
                using (var context = new MCContext()) {
                    context.ProtocolOps.Add(Op);
                    context.SaveChanges();
                }
            } catch (Exception e) {
                return(Consts.FAIL);
            }
            return(Consts.PASS);
        }
예제 #6
0
 public Message(ProtocolOp op, byte[] data)
 {
     this.Operation = op;
     this.Data      = data;
 }
 public static bool IsFloat(this ProtocolOp caller)
 {
     return(caller.DataType.Key == E_DATA_Type.FLOAT);
 }
예제 #8
0
파일: Message.cs 프로젝트: jfiuza/nsspi
 public Message(ProtocolOp op, byte[] data)
 {
     this.Operation = op;
     this.Data = data;
 }