How to use sendCommand method in Cypress

Best JavaScript code snippet using cypress

preload.js

Source:preload.js Github

copy

Full Screen

...15			});16		});17	}18	this.logIn = (fingerprint) => {19		return sendCommand("logIn", {20			fingerprint21		});22	}23	this.logInAndRestore = (fingerprint, filePath) => {24		return sendCommand("logInAndRestore", {25			fingerprint,26			filePath27		});28	}29	this.logInAndSkip = (fingerprint) => {30		return sendCommand("logInAndSkip", {31			fingerprint32		});33	}34	this.getPublicKeys = () => {35		return sendCommand("getPublicKeys", {});36	}37	this.getPrivateKey = (fingerprint) => {38		return sendCommand("getPrivateKey", {39			fingerprint40		});41	}42	this.generateMnemonic = () => {43		return sendCommand("generateMnemonic", {});44	}45	this.addKey = (mnemonic, type = "new_wallet") => {46		return sendCommand("addKey", {47			mnemonic,48			type49		});50	}51	this.deleteKey = (fingerprint) => {52		return sendCommand("deleteKey", {53			fingerprint54		});55	}56	this.deleteAllKeys = () => {57		return sendCommand("deleteAllKeys", {});58	}59	this.getSyncStatus = () => {60		return sendCommand("getSyncStatus", {});61	}62	this.getHeightInfo = () => {63		return sendCommand("getHeightInfo", {});64	}65	this.farmBlock = (address) => {66		return sendCommand("farmBlock", {67			address68		});69	}70	this.getWallets = () => {71		return sendCommand("getWallets", {});72	}73	this.getWalletBalance = (walletId) => {74		return sendCommand("getWalletBalance", {75			walletId76		});77	}78	this.getTransaction = (walletId, transactionId) => {79		return sendCommand("getTransaction", {80			walletId,81			transactionId82		});83	}84	this.getTransactions = (walletId, limit) => {85		return sendCommand("getTransactions", {86			walletId,87			limit88		});89	}90	this.getAddress = (walletId) => {91		return sendCommand("getAddress", {92			walletId93		});94	}95	this.getNextAddress = (walletId) => {96		return sendCommand("getNextAddress", {97			walletId98		});99	}100	this.sendTransaction = (walletId, amount, address, fee) => {101		return sendCommand("sendTransaction", {102			walletId,103			amount,104			address,105			fee106		});107	}108	this.sendTransactionRaw = (walletId, amount, address, fee) => {109		return sendCommand("sendTransactionRaw", {110			walletId,111			amount,112			address,113			fee114		});115	}116	this.createBackup = (filePath) => {117		return sendCommand("createBackup", {118			filePath119		});120	}121	this.addressToPuzzleHash = (address) => {122		return sendCommand("addressToPuzzleHash", {123			address124		});125	}126	this.puzzleHashToAddress = (puzzleHash) => {127		return sendCommand("puzzleHashToAddress", {128			puzzleHash129		});130	}131	this.getCoinInfo = (parentCoinInfo, puzzleHash, amount) => {132		return sendCommand("getCoinInfo", {133			parentCoinInfo,134			puzzleHash,135			amount136		});137	}138}139function Connections() {140	const sendCommand = (command, args) => {141		return new Promise(async (resolve, reject) => {142			let token = Math.random().toString(36).substr(2) + Math.random().toString(36).substr(2);143			ipcRenderer.on(`response-connections-${token}`, (event, response) => resolve(response));144			ipcRenderer.on(`response-connections-${token}-err`, (event, response) => reject(response));145			ipcRenderer.send("connections", {146				command,147				args,148				token149			});150		});151	}152	this.getConnections = () => {153		return sendCommand("getConnections", {});154	}155	this.openConnection = (host, port) => {156		return sendCommand("openConnection", {157			host,158			port159		});160	}161	this.closeConnection = (nodeId) => {162		return sendCommand("closeConnection", {163			nodeId164		});165	}166	this.stopNode = () => {167		return sendCommand("stopNode", {});168	}169}170function FullNode() {171	const sendCommand = (command, args) => {172		return new Promise(async (resolve, reject) => {173			let token = Math.random().toString(36).substr(2) + Math.random().toString(36).substr(2);174			ipcRenderer.on(`response-fullnode-${token}`, (event, response) => resolve(response));175			ipcRenderer.on(`response-fullnode-${token}-err`, (event, response) => reject(response));176			ipcRenderer.send("fullnode", {177				command,178				args,179				token180			});181		});182	}183	this.getBlockchainState = () => {184		return sendCommand("getBlockchainState", {});185	}186	this.getNetworkSpace = (newerBlockHeaderHash, olderBlockHeaderHash) => {187		return sendCommand("getNetworkSpace", {188			newerBlockHeaderHash,189			olderBlockHeaderHash190		});191	}192	this.getBlocks = (start, end, excludeHeaderHash) => {193		return sendCommand("getBlocks", {194			start,195			end,196			excludeHeaderHash197		});198	}199	this.getBlock = (headerHash) => {200		return sendCommand("getBlock", {201			headerHash202		});203	}204	this.getBlockRecordByHeight = (height) => {205		return sendCommand("getBlockRecordByHeight", {206			height207		});208	}209	this.getBlockRecord = (hash) => {210		return sendCommand("getBlockRecord", {211			hash212		});213	}214	this.getUnfinishedBlockHeaders = (height) => {215		return sendCommand("getUnfinishedBlockHeaders", {216			height217		});218	}219	this.getUnspentCoins = (puzzleHash, startHeight, endHeight) => {220		return sendCommand("getUnspentCoins", {221			puzzleHash,222			startHeight,223			endHeight224		});225	}226	this.getCoinRecordByName = (name) => {227		return sendCommand("getCoinRecordByName", {228			name229		});230	}231	this.getAdditionsAndRemovals = (hash) => {232		return sendCommand("getAdditionsAndRemovals", {233			hash234		});235	}236	this.getNetworkInfo = () => {237		return sendCommand("getNetworkInfo", {});238	}239	this.addressToPuzzleHash = (address) => {240		return sendCommand("addressToPuzzleHash", {241			address242		});243	}244	this.puzzleHashToAddress = (puzzleHash) => {245		return sendCommand("puzzleHashToAddress", {246			puzzleHash247		});248	}249	this.getCoinInfo = (parentCoinInfo, puzzleHash, amount) => {250		return sendCommand("getCoinInfo", {251			parentCoinInfo,252			puzzleHash,253			amount254		});255	}256}257const execute = (command) => {258	return new Promise(async (resolve, reject) => {259		cli(command, (error, stdout, stderr) => {260	    	if(stderr != "") {261	    		reject(stderr);262	    	} else {263		        resolve(stdout);264		    }...

Full Screen

Full Screen

grpc-mobile.spec.js

Source:grpc-mobile.spec.js Github

copy

Full Screen

...141    it('should not crash', async () => {142      await grpc.restartLnd();143    });144  });145  describe('sendCommand()', () => {146    it('should handle string error mesage', async () => {147      LndReactModuleStub.sendCommand.returns(Promise.reject('some-message'));148      await expect(149        grpc.sendCommand('GetInfo'),150        'to be rejected with error satisfying',151        /some-message/152      );153    });154    it('should handle error object', async () => {155      LndReactModuleStub.sendCommand.rejects(new Error('some-message'));156      await expect(157        grpc.sendCommand('GetInfo'),158        'to be rejected with error satisfying',159        /some-message/160      );161    });162    it('should work for GetInfo (without body)', async () => {163      LndReactModuleStub.sendCommand.resolves({164        data: grpc._serializeResponse('GetInfo'),165      });166      await grpc.sendCommand('GetInfo');167      expect(LndReactModuleStub.sendCommand, 'was called with', 'GetInfo', '');168    });169    it('should work for GetInfo (lowercase)', async () => {170      LndReactModuleStub.sendCommand.resolves({171        data: grpc._serializeResponse('GetInfo'),172      });173      await grpc.sendCommand('getInfo');174      expect(LndReactModuleStub.sendCommand, 'was called with', 'GetInfo', '');175    });176    it('should work for SendCoins (with body)', async () => {177      LndReactModuleStub.sendCommand.resolves({178        data: grpc._serializeResponse('SendCoins'),179      });180      await grpc.sendCommand('SendCoins', {181        addr: 'some-address',182        amount: 42,183      });184      expect(185        LndReactModuleStub.sendCommand,186        'was called with',187        'SendCoins',188        'Cgxzb21lLWFkZHJlc3MQKg=='189      );190    });191    it('should work for ListChannels', async () => {192      LndReactModuleStub.sendCommand.resolves({193        data: grpc._serializeResponse('ListChannels'),194      });195      await grpc.sendCommand('ListChannels');196      expect(LndReactModuleStub.sendCommand, 'was called once');197    });198    it('should work for PendingChannels', async () => {199      LndReactModuleStub.sendCommand.resolves({200        data: grpc._serializeResponse('PendingChannels'),201      });202      await grpc.sendCommand('PendingChannels');203      expect(LndReactModuleStub.sendCommand, 'was called once');204    });205    it('should work for ClosedChannels', async () => {206      LndReactModuleStub.sendCommand.resolves({207        data: grpc._serializeResponse('ClosedChannels'),208      });209      await grpc.sendCommand('ClosedChannels');210      expect(LndReactModuleStub.sendCommand, 'was called once');211    });212    it('should work for ListPeers', async () => {213      LndReactModuleStub.sendCommand.resolves({214        data: grpc._serializeResponse('ListPeers'),215      });216      await grpc.sendCommand('ListPeers');217      expect(LndReactModuleStub.sendCommand, 'was called once');218    });219    it('should work for ConnectPeer', async () => {220      LndReactModuleStub.sendCommand.resolves({221        data: grpc._serializeResponse('ConnectPeer'),222      });223      await grpc.sendCommand('ConnectPeer');224      expect(LndReactModuleStub.sendCommand, 'was called once');225    });226    it('should work for AddInvoice', async () => {227      LndReactModuleStub.sendCommand.resolves({228        data: grpc._serializeResponse('AddInvoice'),229      });230      await grpc.sendCommand('AddInvoice');231      expect(LndReactModuleStub.sendCommand, 'was called once');232    });233    it('should work for DecodePayReq', async () => {234      LndReactModuleStub.sendCommand.resolves({235        data: grpc._serializeResponse('DecodePayReq'),236      });237      await grpc.sendCommand('DecodePayReq');238      expect(LndReactModuleStub.sendCommand, 'was called once');239    });240    it('should work for QueryRoutes', async () => {241      LndReactModuleStub.sendCommand.resolves({242        data: grpc._serializeResponse('QueryRoutes'),243      });244      await grpc.sendCommand('QueryRoutes');245      expect(LndReactModuleStub.sendCommand, 'was called once');246    });247    it('should work for GetTransactions', async () => {248      LndReactModuleStub.sendCommand.resolves({249        data: grpc._serializeResponse('GetTransactions'),250      });251      await grpc.sendCommand('GetTransactions');252      expect(LndReactModuleStub.sendCommand, 'was called once');253    });254    it('should work for ListInvoices', async () => {255      LndReactModuleStub.sendCommand.resolves({256        data: grpc._serializeResponse('ListInvoices'),257      });258      await grpc.sendCommand('ListInvoices');259      expect(LndReactModuleStub.sendCommand, 'was called once');260    });261    it('should work for ListPayments', async () => {262      LndReactModuleStub.sendCommand.resolves({263        data: grpc._serializeResponse('ListPayments'),264      });265      await grpc.sendCommand('ListPayments');266      expect(LndReactModuleStub.sendCommand, 'was called once');267    });268    it('should work for WalletBalance', async () => {269      LndReactModuleStub.sendCommand.resolves({270        data: grpc._serializeResponse('WalletBalance'),271      });272      await grpc.sendCommand('WalletBalance');273      expect(LndReactModuleStub.sendCommand, 'was called once');274    });275    it('should work for ChannelBalance', async () => {276      LndReactModuleStub.sendCommand.resolves({277        data: grpc._serializeResponse('ChannelBalance'),278      });279      await grpc.sendCommand('ChannelBalance');280      expect(LndReactModuleStub.sendCommand, 'was called once');281    });282    it('should work for NewAddress', async () => {283      LndReactModuleStub.sendCommand.resolves({284        data: grpc._serializeResponse('NewAddress'),285      });286      await grpc.sendCommand('NewAddress');287      expect(LndReactModuleStub.sendCommand, 'was called once');288    });289    it('should work for StopDaemon', async () => {290      LndReactModuleStub.sendCommand.resolves({291        data: grpc._serializeResponse('StopDaemon'),292      });293      await grpc.sendCommand('StopDaemon');294      expect(LndReactModuleStub.sendCommand, 'was called once');295    });296  });297  describe('sendStreamCommand()', () => {298    it('should work for OpenChannel (unidirectional stream)', done => {299      grpc._lndEvent.addListener.yieldsAsync({300        streamId: '1',301        event: 'data',302        data: grpc._serializeResponse('OpenChannel'),303      });304      const stream = grpc.sendStreamCommand('OpenChannel', {305        nodePubkey: Buffer.from('FFFF', 'hex'),306        localFundingAmount: 42,307      });...

Full Screen

Full Screen

ar_receiver.js

Source:ar_receiver.js Github

copy

Full Screen

...4        this.log = null;5    }6    async sendCommand (method, command, value, retryCount=0,param=null) {7        const _sendCommand = (method, command, value, param) => {8            return sendCommand(method, 'receiver', command, value, param);9        };10        let result = await _sendCommand(method, command, value, param);11        if (result.code == -1){12            console.log('code -1');13            throw new Error(result.message);14        }15        if ( result.code != 0 && retryCount > 0){16            return new Promise((resolve)=> {17                setTimeout(async () => {18                    await this.sendCommand(method, command, value, retryCount--, param);19                    resolve();20                });21            });22        }else{23            return result;24        }25    }26    powerOn (retryCount=0) {27        return this.sendCommand('POST', 'power', { value: '1'}, retryCount);28    }29    powerOff (retryCount=0) {30        return this.sendCommand('POST', 'power', { value: '0'}, retryCount);31    }32    setFrequency (value, retryCount=0){33        const frequency = (value / 1000000);34        return this.sendCommand('POST', 'frequency', { value: frequency}, retryCount);35    }36    addStepFrequency (value, retryCount=0) {37        return this.sendCommand('POST', 'frequency', { step: value}, retryCount);38    }39    setTime (value, retryCount) {40        const timeStr = value.format('YYMMDDHHmm');41        return this.sendCommand('POST', 'time', { value: timeStr}, retryCount);42    }43    setVolume (value, retryCount=0){44        return this.sendCommand('POST', 'volume', { value: value }, retryCount);45    }46    setReceiverStateNotification(value, retryCount=0){47        return this.sendCommand('POST', 'receiver_state_notification', { value: value }, retryCount);48    }49    setLevelSquelch (value, retryCount=0){50        return this.sendCommand('POST', 'level_squelch', { value: value }, retryCount);51    }52    setDigitalDataOutput (value, retryCount=0){53        return this.sendCommand('POST', 'digital_data_output', { value: value }, retryCount);54    }55    setFrequencyStepAdjust (value,retryCount=0){56        return this.sendCommand('POST', 'frequency_step_adjust', { value: value }, retryCount);57    }58    selectVFO (value, retryCount=0) {59        return this.sendCommand('POST', 'vfo', { value: value },retryCount);60    }61    setFrequencyStep (value, retryCount=0){62        return this.sendCommand('POST', 'frequency_step', { value: value }, retryCount);63    }64    setDemodulateMode (value, retryCount=0){65        let setModeCode = '';66        switch (value){67        case 'AUTO':68            setModeCode = '000';69            break;70        case 'DSTR':71            setModeCode = '010';72            break;73        case 'YAES':74            setModeCode = '020';75            break;76        case 'ALIN':77            setModeCode = '030';78            break;79        case 'D_CR':80            setModeCode = '040';81            break;82        case 'P_25':83            setModeCode = '050';84            break;85        case 'DPMR':86            setModeCode = '060';87            break;88        case 'DMR':89            setModeCode = '070';90            break;91        case 'T_DM':92            setModeCode = '080';93            break;94        case 'T_TC':95            setModeCode = '090';96            break;97        case 'FM':98            setModeCode = '0F0';99            break;100        case 'AM':101            setModeCode = '0F1';102            break;103        case 'SAH':104            setModeCode = '0F2';105            break;106        case 'SAL':107            setModeCode = '0F3';108            break;109        case 'USB':110            setModeCode = '0F4';111            break;112        case 'LSB':113            setModeCode = '0F5';114            break;115        case 'CW':116            setModeCode = '0F6';117            break;118        default:119        }120        return this.sendCommand('POST', 'demodulate_mode', { value: setModeCode }, retryCount);121    }122    setIFbandwidth (value, retryCount=0) {123        return this.sendCommand('POST', 'ifbandwidth', { value: value }, retryCount);124    }125    getVolume (retryCount=0) {126        return this.sendCommand('GET', 'volume', null, retryCount);127    }128    getVFO (retryCount=0) {129        return this.sendCommand('GET', 'vfo', null,retryCount);130    }131    getLevelSquelch (retryCount=0) {132        return this.sendCommand('GET', 'level_squelch', null, retryCount);133    }134    setCTCSS (value, retryCount=0) {135        return this.sendCommand('POST', 'ctcss', { value: value }, retryCount);136    }137    getCTCSS (retryCount=0) {138        return this.sendCommand('GET', 'ctcss', null, retryCount);139    }140    setCTCSSFrequency (value, retryCount=0) {141        return this.sendCommand('POST', 'ctcss_frequency', { value: value }, retryCount);142    }143    getCTCSSFrequency (retryCount=0) {144        return this.sendCommand('GET', 'ctcss_frequency', null, retryCount);145    }146    setDCS (value, retryCount=0) {147        return this.sendCommand('POST', 'dcs', { value: value }, retryCount);148    }149    getDCS (retryCount=0) {150        return this.sendCommand('GET', 'dcs', null, retryCount);151    }152    setDCSCode (value, retryCount=0) {153        return this.sendCommand('POST', 'dcs_code', { value: value }, retryCount);154    }155    getDCSCode (retryCount=0) {156        return this.sendCommand('GET', 'dcs_code', null, retryCount);157    }158    setDCREncryptionCode (value, retryCount=0) {159        return this.sendCommand('POST', 'dcr_encryption_code', { value: value }, retryCount);160    }161    getDCREncryptionCode (retryCount=0) {162        return this.sendCommand('GET', 'dcr_encryption_code', null, retryCount);163    }164    setTTCSlot (value, retryCount=0) {165        return this.sendCommand('POST', 'ttcslot', { value: value }, retryCount);166    }167    getTTCSlot (retryCount=0) {168        return this.sendCommand('GET', 'ttcslot', null, retryCount);169    }170	getDigitalDataOutput (retryCount=0) {171        return this.sendCommand('GET', 'digital_data_output', null, retryCount);172    }173    getSpectrumSpan (retryCount=0) {174        return this.sendCommand('GET', 'spectrum_span', null,retryCount);175    }176    getSpectrumCenter (retryCount=0) {177        return this.sendCommand('GET', 'spectrum_center', null, retryCount);178    }179    getReceiverState (retryCount=0) {180        return this.sendCommand('GET', 'receiver_state', null, retryCount);181    }182    getSpectrumData (retryCount=0) {183        return this.sendCommand('GET', 'spectrum_data', null,retryCount);184    }185    getSmeter(retryCount=0) {186        return this.sendCommand('GET', 'smeter', null, retryCount);187    }188    getFrequencyStepAdjust (retryCount=0) {189        return this.sendCommand('GET', 'frequency_step_adjust', null, retryCount);190    }191    getDigitalAdditionalInfo (retryCount=0) {192        return this.sendCommand('GET', 'digital_additional_info', null, retryCount);193    }194    getIFbandwidth (retryCount=0) {195        return this.sendCommand('GET', 'ifbandwidth', null, retryCount);196    }197    isSquelchOpened (smeter) {198        let squelchState = smeter.substr(3,1);199                let squelchOpened = false;200                if ( squelchState == '0') {201                    squelchOpened = false;202                } else {203                    squelchOpened = true;204                }205                return squelchOpened;206    }207    parseSmeter(smeter){208        let value = smeter.substr(0,3);209        let smeterValue = Number(value);...

Full Screen

Full Screen

library.js

Source:library.js Github

copy

Full Screen

...74                console.log(data)75            });76    }7778    sendCommand(commandId) {79        $.ajax({80            type: 'POST',81            url: '/sendCommand',82            data: { commandCode: commandId, droneId: this.id }83        })84            .done(function (response) {85                console.log(response)86            })87            .fail(function (data) {88                console.log(data)89            });90    }9192    startVideoFeed() {93        this.videoSocket.disconnect();94        this.videoSocket.activateStream();95    }9697    stopVideoFeed() {98        this.videoSocket.disconnect();99    }100101    setPosition(lat, lng, alt) {102        this.posMark.setPosition({ lat: lat, lng: lng, alt: alt });103        this.lat = lat;104        this.lng = lng;105        this.alt = alt;106    }107108    addPoint(marker) {109        var pointId = Drone.createPointID(marker);110        var pointData = new PointData(marker, DEFAULT_SPEED, DEFAULT_ALTITUDE);111        this.locationToPointDataMap.set(pointId, pointData);112        return pointId;113    }114115    static createPointID(marker) {116        return marker.getPosition().lat() + "" + marker.getPosition().lng();117    }118119    getPointDataJSON() {120        var result = '[';121        this.locationToPointDataMap.forEach(function (pointData) {122            result += '{"lat":"' + pointData.marker.getPosition().lat() + '",' +123                '"lng":"' + pointData.marker.getPosition().lng() + '",' +124                '"speed":' + pointData.speed + ',' +125                '"height":' + pointData.height + ',' +126                '"action":' + pointData.action + '},';127        });128        return result.substring(0, result.length - 1) + ']';129    }130131    getPointDataForID(key) {132        return this.locationToPointDataMap.get(key);133    }134135    removePoint(key) {136        this.locationToPointDataMap.get(key).marker.setMap(null);137        this.locationToPointDataMap.delete(key);138    }139140    hidePoints() {141        this.locationToPointDataMap.forEach(function (pointData) {142            pointData.marker.setMap(null);143        });144    }145146    showPoints() {147        this.locationToPointDataMap.forEach(function (pointData) {148            pointData.marker.setMap(WORLD_MAP);149        });150    }151152    removePoints() {153        this.hidePoints();154        this.locationToPointDataMap = new Map();155        this.labelCounter = 0;156    }157158    getNextLabelIndex() { 159        return ++this.labelCounter + "";160    }161}162163164class PointData {165    constructor(marker, speed, height) {166        this.marker = marker;167        this.speed = speed;168        this.height = height;169        this.action = 0;170    }171}172173174const addMarker = function (location) {175    if (SELECTED_DRONE == null || SELECTED_DRONE == undefined) {176        return;177    }178179    var marker = new google.maps.Marker({180        position: location,181        draggable: true,182        label: SELECTED_DRONE.getNextLabelIndex(),183        map: WORLD_MAP184    });185186    var pointId = SELECTED_DRONE.addPoint(marker);187188    var contentString = renderMapPointDataComponent(pointId, DEFAULT_ALTITUDE, DEFAULT_SPEED);189190    var infowindow = new google.maps.InfoWindow({191        content: contentString192    });193194    marker.addListener('click', function (event) {195        infowindow.open(WORLD_MAP, marker);196    });197198    marker.addListener('dragend', function (event) {199        marker.setPosition(event.latLng);200    });201}202203204205const initializeDronesControls = function (id) {206    $("input[id='mStart" + id + "']").click(function () {207        SELECTED_DRONE.startMission();208    });209    $("input[id*='mCancel" + id + "']").click(function () {210        SELECTED_DRONE.sendCommand(CommandType.CANCEL_MISSION);211        SELECTED_DRONE.removePoints();212    });213    $("input[id*='mRTL" + id + "']").click(function () {214        SELECTED_DRONE.sendCommand(CommandType.RETURN_TO_LAUNCH);215    });216    $("input[id*='fActivate" + id + "']").click(function () {217        SELECTED_DRONE.sendCommand(CommandType.ACTIVATE_FUNCTION);218    });219    $("input[id*='fArm" + id + "']").click(function () {220        SELECTED_DRONE.sendCommand(CommandType.ARM);221    });222    $("input[id*='fDisarm" + id + "']").click(function () {223        SELECTED_DRONE.sendCommand(CommandType.DISARM);224    });225    $("input[id*='fKill" + id + "']").click(function () {226        SELECTED_DRONE.sendCommand(CommandType.KILL);227    });228229    $("input[id*='cameraUP" + id + "']").click(function () {230        SELECTED_DRONE.sendCommand(CommandType.CAMERA_UP);231    });232233    $("input[id*='cameraDOWN" + id + "']").click(function () {234        SELECTED_DRONE.sendCommand(CommandType.CAMERA_DOWN);235    });236237    $("input[id*='btnF" + id + "']").click(function () {238        SELECTED_DRONE.sendCommand(CommandType.FORWARD);239    });240241    $("input[id*='btnMvL" + id + "']").click(function () {242        SELECTED_DRONE.sendCommand(CommandType.MLEFT);243    });244245    $("input[id*='btnMvR" + id + "']").click(function () {246        SELECTED_DRONE.sendCommand(CommandType.MRIGHT);247    });248249    $("input[id*='btnCncl" + id + "']").click(function () {250        SELECTED_DRONE.sendCommand(CommandType.CANCEL_XMOVE);251    });252253    $("input[id*='btnB" + id + "']").click(function () {254        SELECTED_DRONE.sendCommand(CommandType.BACKWARD);255    });256257    $("input[id*='btnU" + id + "']").click(function () {258        SELECTED_DRONE.sendCommand(CommandType.UP);259    });260261    $("input[id*='btnStopZ" + id + "']").click(function () {262        SELECTED_DRONE.sendCommand(CommandType.CANCEL_ZMOVE);263    });264265    $("input[id*='btnD" + id + "']").click(function () {266        SELECTED_DRONE.sendCommand(CommandType.DOWN);267    });268269    $("input[id*='btnRL" + id + "']").click(function () {270        SELECTED_DRONE.sendCommand(CommandType.RLEFT);271    });272273    $("input[id*='btnRR" + id + "']").click(function () {274        SELECTED_DRONE.sendCommand(CommandType.RRIGHT);275    });276277    $("input[id*='btnRLEFT45" + id + "']").click(function () {278        SELECTED_DRONE.sendCommand(CommandType.RLEFT45);279    });280281    $("input[id*='btnRLEFT90" + id + "']").click(function () {282        SELECTED_DRONE.sendCommand(CommandType.RLEFT90);283    });284285    $("input[id*='btnRRIGHT45" + id + "']").click(function () {286        SELECTED_DRONE.sendCommand(CommandType.RRIGHT45);287    });288289    $("input[id*='btnRRIGHT90" + id + "']").click(function () {290        SELECTED_DRONE.sendCommand(CommandType.RRIGHT90);291    });292}293294const CommandType = {295    START_MISSION: 14,296    CANCEL_MISSION: 6,297    FORWARD: 11,298    MLEFT: 15,299    MRIGHT: 16,300    CANCEL_XMOVE: 12,301    CANCEL_ZMOVE: 13,302    UP: 1,303    RLEFT: 2,304    RRIGHT: 3,305    BACKWARD: 4,306    DOWN: 5,307    RETURN_TO_LAUNCH: 7,308    ACTIVATE_FUNCTION: 8,309    ARM: 9,310    KILL: 17,311    CAMERA_UP: 22,312    CAMERA_DOWN: 23,313    DISARM: 10,314    RLEFT45: 18,315    RLEFT90: 19,316    RRIGHT45: 20,317    RRIGHT90: 21,318}319320const executeKeyboardCommand = function (event) {321    switch (event.key) {322        case 'w':323            SELECTED_DRONE.sendCommand(CommandType.FORWARD);324            break;325        case 's':326            SELECTED_DRONE.sendCommand(CommandType.BACKWARD);327            break;328        case 'a':329            SELECTED_DRONE.sendCommand(CommandType.RLEFT);330            break;331        case 'd':332            SELECTED_DRONE.sendCommand(CommandType.RRIGHT);333            break;334335        case '4':336            SELECTED_DRONE.sendCommand(CommandType.MLEFT);337            break;338        case '6':339            SELECTED_DRONE.sendCommand(CommandType.MRIGHT);340            break;341        case '8':342            SELECTED_DRONE.sendCommand(CommandType.UP);343            break;344        case '2':345            SELECTED_DRONE.sendCommand(CommandType.DOWN);346            break;347        case '5':348            SELECTED_DRONE.sendCommand(CommandType.CANCEL_XMOVE);349            SELECTED_DRONE.sendCommand(CommandType.CANCEL_ZMOVE);350            break;351352        case 'r':353            SELECTED_DRONE.sendCommand(CommandType.CAMERA_UP);354            break;355        case 'f':356            SELECTED_DRONE.sendCommand(CommandType.CAMERA_DOWN);357            break;358    }359}360361const removePoint = function (form) {362    SELECTED_DRONE.removePoint(form["key"].value);363}364365366const updatePointValue = function (form) {367    var pointData = SELECTED_DRONE.getPointDataForID(form["key"].value);368    pointData.speed = form["speed"].value;369    pointData.height = form["height"].value;370    pointData.action = form["action"].value;
...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...19                var jsonContent = JSON.parse(chunk);20                var chan = intent.slots.Channel.value;21                var id = chan.toLowerCase();22                console.log("BODY: " + jsonContent[id]);23                sendCommand("/roku/launch/"+jsonContent[id],null,function(){24                    response.tellWithCard("Launching "+intent.slots.Channel.value);25                });26                //return jsonContent;27            });28    });29}30var AlexaRoku = function () {31    AlexaSkill.call(this, APP_ID);32};33AlexaRoku.prototype = Object.create(AlexaSkill.prototype);34AlexaRoku.prototype.constructor = AlexaRoku;35function sendCommand(path,body,callback) {36    var opt = {37        host:serverinfo.host,38        port:serverinfo.port,39        path: path,40        method: 'POST',41        headers: {'Authorization': serverinfo.pass},42    };43    var req = http.request(opt, function(res) {44        callback();45        res.setEncoding('utf8');46        res.on('data', function (chunk) {47            console.log('Response: ' + chunk);48        });49    });50    if (body) req.write(body);51    req.end();52}53//need to adjust responses to respond with name of roku device being used, ie "Going Home on Upstairs Roku"54AlexaRoku.prototype.intentHandlers = {55    Home: function (intent, session, response) {56        sendCommand("/roku/keypress/home",null,function() {57            response.tellWithCard("Going Home");58        });59    },60    PlayChannel: function (intent, session, response) {61        getChannels(intent, session, response);62    },63    RokuSearch: function (intent, session, response) {64        var query = intent.slots.Search.value;65        var searchString = querystring.stringify({title : query});66        console.log("Show searched for = "+intent.slots.Search.value);67        sendCommand("/roku/search/browse?"+searchString,null,function() {68            response.tellWithCard("Searching for "+intent.slots.Search.value);69        });70    },71    BloombergTV: function (intent, session, response) {72        sendCommand("/roku/launch/54000",null,function() {73            response.tellWithCard("Launching Bloomberg News");74        });75    },76    History: function (intent, session, response) {77        sendCommand("/roku/launch/35059",null,function() {78            response.tellWithCard("Launching The History Channel");79        });80    },81    Amazon: function (intent, session, response) {82        sendCommand("/roku/launch/13",null,function() {83            response.tellWithCard("Launching Amazon");84        });85    },86    WatchESPN: function (intent, session, response) {87        sendCommand("/roku/launch/34376",null,function() {88            response.tellWithCard("OK, let's watch some sports");89        });90    },91    CNNGo: function (intent, session, response) {92        sendCommand("/roku/launch/65978",null,function() {93            response.tellWithCard("Launching CNN News");94        });95    },96    Select: function (intent, session, response) {97        sendCommand("/roku/keypress/select",null,function() {98            response.tellWithCard("Ok");99        });100    },101    Back: function (intent, session, response) {102        sendCommand("/roku/keypress/back",null,function() {103            response.tellWithCard("Going Back");104        });105    },106    TV: function (intent, session, response) {107        sendCommand("/roku/keypress/inputtuner",null,function() {108            response.tellWithCard("TV");109        });110    },111    YouTube: function (intent, session, response) {112        sendCommand("/roku/launch/837",null,function() {113            response.tellWithCard("Launching YouTube");114        });115    116    },117    FX: function (intent, session, response) {118        sendCommand("/roku/launch/47389",null,function() {119            response.tellWithCard("Launching FX");120        });121    122    },123    btngo: function (intent, session, response) {124        sendCommand("/roku/launch/66258",null,function() {125            response.tellWithCard("Launching The Big Ten Network");126        });127    128    },129    Rewind: function (intent, session, response) {130        sendCommand("/roku/keypress/rewind",null,function() {131            response.tellWithCard("Rewinding");132        });133    134    },135    Fastforward: function (intent, session, response) {136        sendCommand("/roku/keypress/fastforward",null,function() {137            response.tellWithCard("Fast forwarding");138        });139    140    },141    Instantreplay: function (intent, session, response) {142        sendCommand("/roku/keypress/instantreplay",null,function() {143            response.tellWithCard("Instant Replay");144        });145    146    },147    Up: function (intent, session, response) {148        sendCommand("/roku/keypress/Up",null,function() {149            response.tellWithCard("Up");150        });151    },152    UpTwo: function (intent, session, response) {153        sendCommand("/roku/keypress/Up",null,function() {});154        sendCommand("/roku/keypress/Up",null,function() {155            response.tellWithCard("Up Two");156        });157    },158    UpThree: function (intent, session, response) {159        sendCommand("/roku/keypress/Up",null,function() {});160        sendCommand("/roku/keypress/Up",null,function() {});161        sendCommand("/roku/keypress/Up",null,function() {162            response.tellWithCard("Up Three");163        });164    },165    Down: function (intent, session, response) {166        sendCommand("/roku/keypress/Down",null,function() {167            response.tellWithCard("Down");168        });169    },170    DownTwo: function (intent, session, response) {171        sendCommand("/roku/keypress/Down",null,function() {});172        sendCommand("/roku/keypress/Down",null,function() {173            response.tellWithCard("Down Two");174        });175    },176    DownThree: function (intent, session, response) {177        sendCommand("/roku/keypress/Down",null,function() {});178        sendCommand("/roku/keypress/Down",null,function() {});179        sendCommand("/roku/keypress/Down",null,function() {180            response.tellWithCard("Down Three");181        });182    },183    PowerOn: function (intent, session, response) {184        sendCommand("/roku/keypress/poweron",null,function() {185            response.tellWithCard("OK, fasten your seat belts.  Here comes the fun");186        });187    },188    PowerOff: function (intent, session, response) {189        sendCommand("/roku/keypress/poweroff",null,function() {190            response.tellWithCard("OK, I turned off the Roku TV");191        });192    },193    Left: function (intent, session, response) {194        sendCommand("/roku/keypress/Left",null,function() {195            response.tellWithCard("Left");196        });197    },198    LeftTwo: function (intent, session, response) {199        sendCommand("/roku/keypress/Left",null,function() {});200        sendCommand("/roku/keypress/Left",null,function() {201            response.tellWithCard("Left Two");202        });203    },204    LeftThree: function (intent, session, response) {205        sendCommand("/roku/keypress/Left",null,function() {});206        sendCommand("/roku/keypress/Left",null,function() {});207        sendCommand("/roku/keypress/Left",null,function() {208            response.tellWithCard("Left Three");209        });210    }, 211    Right: function (intent, session, response) {212        sendCommand("/roku/keypress/right",null,function() {213            response.tellWithCard("Right");214        });215    },216    RightTwo: function (intent, session, response) {217        sendCommand("/roku/keypress/right",null,function() {});218        sendCommand("/roku/keypress/right",null,function() {219            response.tellWithCard("Right Two");220        });221    },222    RightThree: function (intent, session, response) {223        sendCommand("/roku/keypress/right",null,function() {});224        sendCommand("/roku/keypress/right",null,function() {});225        sendCommand("/roku/keypress/right",null,function() {226            response.tellWithCard("Right Three");227        });228    },229    Type: function (intent, session, response) {230        sendCommand("/roku/type",intent.slots.Text.value,function() {231            response.tellWithCard("Typing text: "+intent.slots.Text.value,"Roku","Typing text: "+intent.slots.Text.value);232        });233    },234    VolumeUp: function (intent, session, response) {235        sendCommand("/roku/keypress/VolumeUp",null,function() {236            response.tellWithCard("Ok, turning it up");237        });238    },239    VolumeDown: function (intent, session, response) {240        sendCommand("/roku/keypress/VolumeDown",null,function() {241            response.tellWithCard("Ok, turning it down");242        });243    },244    Mute: function (intent, session, response) {245        sendCommand("/roku/keypress/VolumeMute",null,function() {246            response.tellWithCard("Muted");247        });248    },249    PlayPause: function (intent, session, response) {250        sendCommand("/roku/keypress/play",null,function() {251            response.tell("OK");252        });253    },254    SearchRoku: function (intent, session, response) {255        sendCommand("/roku/searchroku",intent.slots.Text.value,function() {256            response.tellWithCard("Playing: "+intent.slots.Text.value,"Roku","Playing: "+intent.slots.Text.value);257        });258    },259    Search: function (intent, session, response) {260        sendCommand("/roku/search",intent.slots.Text.value,function() {261            response.tellWithCard("Typing: "+intent.slots.Text.value,"Roku","Playing: "+intent.slots.Text.value);262        });263    },264    HelpIntent: function (intent, session, response) {265        response.tell("No help available at this time.");266    }267};268exports.handler = function (event, context) {269    var roku = new AlexaRoku();270    roku.execute(event, context);...

Full Screen

Full Screen

driver_frontend.js

Source:driver_frontend.js Github

copy

Full Screen

...62                freq = ("00000000000" + (parseInt(f*1e6 ).toString())).slice(-11); // Nifty, eh ?63            }64            if (freq.indexOf("N") > -1) { // detect "NaN" in the string65                console.warn("Invalid VFO spec");66                lm.sendCommand((vfo == 'A' ||  vfo == 'a') ? 'FA;' : 'FB;');67            } else {68                //console.log("VFO" + vfo + ": " + freq);69                lm.sendCommand(((vfo == 'A' ||  vfo == 'a') ? 'FA' : 'FB') + freq + ';');70            }71            lm.sendCommand('BN;'); // Refresh band number (radio does not send it automatically)72        };73        this.getVFO = function(vfo) {74            if (vfo == 'a' || vfo == 'A') {75                lm.sendCommand('FA;');76            } else {77                lm.sendCommand('FB;');78            }79        }80        this.getMode = function () {81            lm.sendCommand('MD;');82        }83        this.setMode = function (code) {84            lm.sendCommand('MD' + code + ';');85        }86        /**87         * Returns a list of all modes supported by the radio88         */89        this.getModes = function() {90            return ["LSB", "USB", "CW", "FM", "AM", "DATA", "CW-REV", "DATA-REV"];91        }92        /**93         * if key = true, they transmit94         */95        this.ptt = function(key) {96            var cmd = (key) ? 'TX;' : 'RX;';97            lm.sendCommand(cmd);98        }99        /**100         * Get the SMeter reading101         */102        this.getSmeter = function() {103            lm.sendCommand('SM;')104        }105        /*********106         *   End of common radio API107         */108        // All commands below are fully free and depend on109        // the instrument's capabilities110        this.startTextStream = function () {111            this.textPoller = setInterval(this.queryTB.bind(this), 700);112            return true;113        }114        this.stopTextStream = function () {115            if (typeof this.textPoller != 'undefined') {116                clearInterval(this.textPoller);117            }118            return true;119        }120        this.sendText = function (text) {121            lm.sendCommand('KY ' + text + ';');122        }123        this.queryTB = function () {124            lm.sendCommand('TB;');125        }126        this.screen = function (n) {127            lm.sendCommand('S:' + n);128        }129        this.getRequestedPower = function () {130            lm.sendCommand('PC;');131        }132        this.setSubmode = function (submode) {133            var submodes = {134                "DATA A": "0",135                "AFSK A": "1",136                "FSK D": "2",137                "PSK D": "3"138            };139            lm.sendCommand('DT' + submodes[submode] + ';');140        }141        this.tune = function(tuning) {142            if (tuning) {143                lm.sendCommand('MN023;MP001;MN255;'); // Bypass ATU144                lm.sendCommand('SWH16;'); // TUNE keypress145            } else {146                lm.sendCommand('SWH16;'); // TUNE keypress147                lm.sendCommand(';;;MN023;MP002;MN255;'); // Enable ATU148            }149        }150        this.memoryChannel = function(mem) {151            var s = ("000" + mem).slice(-3);152            lm.sendCommand('MC' + s + ';');153        }154        this.setPower = function (p) {155            var pwr = ("000" + (parseInt(p).toString())).slice(-3); // Nifty, eh ?156            if (pwr.indexOf("N") > -1) { // detect "NaN" in the pwr157                lm.sendCommand('PC;');158            } else {159                console.log('PC' + pwr + ';');160                lm.sendCommand('PC' + pwr + ';');161            }162        }163        this.setCP = function (cmp) {164            var cp = ("000" + cmp).slice(-3);165            lm.sendCommand('CP' + cp + ';');166        }167        this.setAG = function (ag) {168            var gain = ("000" + ag).slice(-3);169            lm.sendCommand('AG' + gain + ';');170        }171        this.setMG = function (mg) {172            var gain = ("000" + mg).slice(-3);173            lm.sendCommand('MG' + gain + ';');174        }175        this.setRG = function (rg) {176            // Need to translate "-60 to 0" into "190 to 250"177            lm.sendCommand('RG' + (rg + 250) + ';');178        }179        this.setBW = function (bw) { // Bandwidth in kHz (0 to 4.0)180            var bandwidth = ("0000" + Math.floor(bw * 100)).slice(-4);181            lm.sendCommand('BW' + bandwidth + ';');182        }183        this.setCT = function (ct) { // Center frequency184            var center = ("0000" + Math.floor(ct * 1000)).slice(-4);185            lm.sendCommand('IS ' + center + ';'); // Note the space!186        }187        this.setRptOfs = function(o) {188            var ofs = ("000" + (parseInt(o/20).toString())).slice(-3);189            lm.sendCommand('MN007;MP' + ofs + ';MN255;');190        }191        this.setBand = function (band) {192            // We use a band number in meters (with a "m"), this function translates into the KX3 values:193            var bands = {194                "160": "00",195                "80": "01",196                "60": "02",197                "40": "03",198                "30": "04",199                "20": "05",200                "17": "06",201                "15": "07",202                "12": "08",203                "10": "09",204                "6": "10",205                "2": "16"206            };207            var bandcode = bands[band];208            if (typeof (bandcode) != 'undefined') {209                lm.sendCommand('BN' + bandcode + ';');210            }211        }212        console.log('Started Elecraft link manager driver..');213    };...

Full Screen

Full Screen

PoliceTheme.js

Source:PoliceTheme.js Github

copy

Full Screen

1import ColorPriority from '../enums/ColorPriority';2import LedThemeBase from './LedThemeBase';3export default class PoliceTheme extends LedThemeBase {4  constructor(commandBufferFilter) {5    super();6    if(commandBufferFilter == null) throw new Exception('Command buffer required for the theme');7    this.colorPriority = ColorPriority.Brightness;8    this._commandBufferFilter = commandBufferFilter;9    this._period = 0;10    this._redColor = [255, 0, 0];11    this._blueColor = [0, 0, 255];12    this._colorDuration = 400; // ms13  }14  stop() {15    super.stop();16    this._commandBufferFilter.setCommand(() => Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', [0,0,0]));17  }18  async update() {19    if(this.active) {20      await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', this._redColor);21      await this._sleep(128);22    }23    if(this.active) {24      await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', this._blueColor);25      await this._sleep(128);26    }27  }28  // T329  // async update() {30  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetOneLEDInRGB', [0b00000111, ...this._redColor]);31  //   await this._sleep(150);32  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', [0,0,0])33  //   await this._sleep(100);34  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetOneLEDInRGB', [0b00000111, ...this._redColor]);35  //   await this._sleep(150);36  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', [0,0,0])37  //   await this._sleep(100);38  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetOneLEDInRGB', [0b00000111, ...this._redColor]);39  //   await this._sleep(150);40  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetOneLEDInRGB', [0b00111000, ...this._blueColor]);41  //   await this._sleep(150);42  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', [0,0,0])43  //   await this._sleep(100);44  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetOneLEDInRGB', [0b00111000, ...this._blueColor]);45  //   await this._sleep(150);46  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', [0,0,0])47  //   await this._sleep(100);48  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetOneLEDInRGB', [0b00111000, ...this._blueColor]);49  //   await this._sleep(150);50  // }51  // T252  // async update() {53  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', this._redColor);54  //   await this._sleep(200);55  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', [0,0,0]);56  //   await this._sleep(100);57  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', this._redColor);58  //   await this._sleep(200);59  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', [0,0,0]);60  //   await this._sleep(100);61  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', this._blueColor);62  //   await this._sleep(200);63  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', [0,0,0]);64  //   await this._sleep(100);65  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', this._blueColor);66  //   await this._sleep(200);67  //   await Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', [0,0,0]);68  //   await this._sleep(100);69  // }70  // T171  // async update() {72  //   this._commandBufferFilter.setCommand(() => Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', this._redColor));73  //   await this._sleep(this._colorDuration);74  //   this._commandBufferFilter.setCommand(() => Moduware.v0.API.Module.SendCommand(Moduware.Arguments.uuid, 'SetRGB', this._blueColor));75  //   await this._sleep(this._colorDuration);76  // }...

Full Screen

Full Screen

Commands.js

Source:Commands.js Github

copy

Full Screen

...58  text-align: center;59  padding: 2rem;60  color: black;61}`;62function sendCommand(command) {63  return function() {64    console.log(`Sending the command ${command}`);65    socket.emit('command', command);66  };67}68const amount = 100;69const Commands = () => (70  <CommandGrid>71    <button className="rotate" onClick={sendCommand('ccw 90')}>72      <span className="symbol">rotate CCW</span> 90°73    </button>74    <button onClick={sendCommand(`forward ${amount}`)}>75      <span className="symbol">↑</span> forward {amount}cm76    </button>77    <button className="rotate" onClick={sendCommand('cw 15')}>78      <span className="symbol">rotate CW</span> 15°79    </button>80    <button onClick={sendCommand(`left ${amount}`)}>81      <span className="symbol">←</span> left {amount}cm82    </button>83    <div className="center">84      <button className="takeoff" onClick={sendCommand('takeoff')}>85        Take Off86      </button>87      <button className="land" onClick={sendCommand('land')}>88        Land89      </button>90      <button className="emergency" onClick={sendCommand('emergency')}>91        <h2>SHUT DOWN</h2>92      </button>93    </div>94    <button onClick={sendCommand(`right ${amount}`)}>95      <span className="symbol">→</span>96      right {amount}cm97    </button>98    <button className="height" onClick={sendCommand(`up ${amount}`)}>99      <span className="symbol">⤒ up</span> {amount}cm100    </button>101    <button onClick={sendCommand(`back ${amount}`)}>102      <span className="symbol">↓</span> back {amount}cm103    </button>104    <button className="height" onClick={sendCommand(`down ${amount}`)}>105      <span className="symbol">⤓ down</span> {amount}cm106    </button>107    <button onClick={sendCommand('flip l')}>Flip Left</button>108    <button onClick={sendCommand('flip f')}>Flip Forward</button>109    <button onClick={sendCommand('flip r')}>Flip Right</button>110    <button onClick={sendCommand('command')}>reconnect</button>111    <button onClick={sendCommand('flip b')}>Flip Back</button>112    <button onClick={sendCommand('battery?')}>battery </button>113  </CommandGrid>114);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('sendCommand', (command, ...args) => {2  cy.window().then((win) => {3    win.postMessage({ type: 'FROM_CYPRESS', command, args }, '*')4  })5})6import './test'7describe('My Test', () => {8  it('Test', () => {9    cy.sendCommand('setResolution', 1920, 1080)10  })11})12const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin')13module.exports = (on, config) => {14  addMatchImageSnapshotPlugin(on, config)15  on('task', {16    log(message) {17      console.log(message)18    },19    table(message) {20      console.table(message)21    },22  })23  on('before:browser:launch', (browser, launchOptions) => {24    if (browser.name === 'chrome' && browser.isHeadless) {25      launchOptions.args.push('--window-size=1920,1080')26    }27  })28}29const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin')30module.exports = (on, config) => {31  addMatchImageSnapshotPlugin(on, config)32  on('task', {33    log(message) {34      console.log(message)35    },36    table(message) {37      console.table(message)38    },39  })40  on('before:browser:launch', (browser, launchOptions) => {41    if (browser.name === 'chrome' && browser.isHeadless) {42      launchOptions.args.push('--window-size=1920,1080')43    }44  })45}46const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin')47module.exports = (on, config) => {48  addMatchImageSnapshotPlugin(on, config)49  on('task', {50    log(message) {51      console.log(message)52    },53    table(message) {54      console.table(message)55    },

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2  it('Does not do much!', () => {3    expect(true).to.equal(true)4  })5})6Cypress.Commands.add('sendCommand', (command) => {7  cy.window().then((win) => {8    win.postMessage({ type: 'command', command: command }, '*')9  })10})11module.exports = (on, config) => {12  on('task', {13    log(message) {14      console.log(message)15    },16  })17}18import './commands'19{20  "env": {21  },22  "reporterOptions": {

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('sendCommand', (command, ...args) => {2  cy.document().then((doc) => {3    doc.defaultView.postMessage(4      { type: 'FROM_CYPRESS', command, args },5  })6})7Cypress.on('window:before:load', (win) => {8  win.addEventListener('message', (event) => {9    if (event.data.type !== 'FROM_CYPRESS') {10    }11    const { command, args } = event.data12    Cypress.Commands.add(command, (...args) => {13    })14  })15})16Cypress.Commands.add('sendCommand', (command, ...args) => {17  cy.document().then((doc) => {18    doc.defaultView.postMessage(19      { type: 'FROM_CYPRESS', command, args },20  })21})22Cypress.Commands.add('sendCommand', (command, ...args) => {23  cy.document().then((doc) => {24    doc.defaultView.postMessage(25      { type: 'FROM_CYPRESS', command, args },26  })27})28Cypress.Commands.add('sendCommand', (command, ...args) => {29  cy.document().then((doc) => {30    doc.defaultView.postMessage(31      { type: 'FROM_CYPRESS', command, args },32  })33})34Cypress.Commands.add('sendCommand', (command, ...args) => {35  cy.document().then((doc) => {36    doc.defaultView.postMessage(37      { type: 'FROM_CYPRESS', command, args },38  })39})40Cypress.Commands.add('sendCommand', (command, ...args) => {41  cy.document().then((doc) => {42    doc.defaultView.postMessage(43      { type: 'FROM_CYPRESS', command, args },44  })45})46Cypress.Commands.add('sendCommand', (command, ...args) => {47  cy.document().then((doc) => {48    doc.defaultView.postMessage(49      { type: 'FROM_CYPRESS', command, args },

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.server();2cy.route('POST', '/_api/v1/commands').as('sendCommand');3cy.wait('@sendCommand').then(function(xhr) {4  expect(xhr.status).to.equal(200);5  expect(xhr.responseBody).to.have.property('name', 'sendCommand');6});7cy.wait('@sendCommand').then(function(xhr) {8  expect(xhr.status).to.equal(200);9  expect(xhr.responseBody).to.have.property('name', 'sendCommand');10});11cy.wait('@sendCommand').then(function(xhr) {12  expect(xhr.status).to.equal(200);13  expect(xhr.responseBody).to.have.property('name', 'sendCommand');14});15cy.wait('@sendCommand').then(function(xhr) {16  expect(xhr.status).to.equal(200);17  expect(xhr.responseBody).to.have.property('name', 'sendCommand');18});19cy.wait('@sendCommand').then(function(xhr) {20  expect(xhr.status).to.equal(200);21  expect(xhr.responseBody).to.have.property('name', 'sendCommand');22});23cy.wait('@sendCommand').then(function(xhr) {24  expect(xhr.status).to.equal(200);25  expect(xhr.responseBody).to.have.property('name', 'sendCommand');26});27cy.wait('@sendCommand').then(function(xhr) {28  expect(xhr.status).to.equal(200);29  expect(xhr.responseBody).to.have.property('name', 'sendCommand');30});31cy.wait('@sendCommand').then(function(xhr) {32  expect(xhr.status).to.equal(200);33  expect(xhr.responseBody).to.have.property('name', 'sendCommand');34});35cy.wait('@sendCommand').then(function(xhr) {36  expect(xhr.status).to.equal(200);37  expect(xhr.responseBody).to.have.property('name', 'sendCommand');38});39cy.wait('@sendCommand').then(function(xhr) {40  expect(xhr.status).to.equal(200);41  expect(xhr.responseBody).to.have.property('name', 'sendCommand

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful