Esempio n. 1
0
        private void SetCommand_for_OC_Cmds(string cmdId, int idx, string description = null)
        {
            int key = Utils.MakeKey(cmdId, idx);

            if (description == null)
            {
                description = cmdId;
            }
            var uiItem = new VM_FloatGetSet()
            {
                Description = description,
                CmdSend     = new RelayCommand(e => {
                    byte[] packageSet = Utils.MakePacket(NodeId, cmdId, idx, false, true, ((VM_FloatGetSet)dicSignals[key]).ValueFloatSet.ToString());
                    byte[] packageGet = Utils.MakePacket(NodeId, cmdId, idx, true, true, "0");
                    //todo comunicationManager write
                    //CAN_Common.Write(packageSet);
                    //CAN_Common.Write(packageGet);
                })
            };

            dicSignals[key] = uiItem;
            OC_Cmds.Add(uiItem);
            setFloatListener(key);
            _keepRefreshed.Add(makeGetFloatPacket(cmdId, idx));
        }
        public static Abs_VM_UIItem TaskFactory(int key)
        {
            if (key == -1)
            {
                return(null);
            }
            var protocolOp = Consts.Keys.getProtocolOp(key);

            var           dtype  = protocolOp.UIDefaultType.Type;
            Abs_VM_UIItem result = null;

            switch (dtype)
            {
            case E_DB_UI_Type.INT_GET_SET:
                result = new VM_IntGetSet();
                break;

            case E_DB_UI_Type.INT_GET:
                result = new VM_IntGet();
                break;

            case E_DB_UI_Type.FLOAT_GET:
                result = new VM_FloatGet();
                break;

            case E_DB_UI_Type.FLOAT_GET_SET:
                result = new VM_FloatGetSet();
                break;
            }
            if (result == null)
            {
                Debugger.Break();
            }
            if (result != null)
            {
                result._protocolOp = protocolOp;
            }
            return(result);
        }