How to use this.startSim method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

App.js

Source:App.js Github

copy

Full Screen

...388 // rootNode: temp.batteryKey,389 // cycles: getPaths(temp.graph, temp.batteryKey)390 // }, () => {391 // if (this.state.isSimulating) {392 // this.startSim()393 // } else {394 // this.stopSim()395 // }396 // })397 // }398 // });399 // } catch (err) {400 // console.log(err)401 // }402 this.setState({403 isSimulating: !this.state.isSimulating,404 openDrawer: !this.state.openDrawer405 }, () => {406 if (this.state.isSimulating) {407 let circuit = createGraph();408 let listOfBatteries = [];409 App.listOfRefs._currentValue.forEach((element, index) => {410 if (!circuit.getNode(element._reactInternals.key)) {411 circuit.addNode(element._reactInternals.key, element);412 }413 if (element.state.type === "Battery") {414 listOfBatteries.push(circuit.getNode(element._reactInternals.key));415 }416 if (element.attachTo) {417 element.attachTo.forEach((attachedPart, key) => {418 if (attachedPart) {419 if (attachedPart.ref.state.type === "Breadboard") {420 attachedPart.ref.getConnectedComponents(attachedPart.id, element).forEach((connectedPart) => {421 if (!(connectedPart.id === "ground" || key === "ground")) {422 if (!circuit.getNode(connectedPart.ref._reactInternals.key))423 circuit.addNode(connectedPart.ref._reactInternals.key, connectedPart.ref);424 circuit.addLink(element._reactInternals.key, connectedPart.ref._reactInternals.key);425 }426 })427 } else if (!(attachedPart.id === "ground" || key === "ground")) {428 if (!circuit.getNode(attachedPart.ref._reactInternals.key))429 circuit.addNode(attachedPart.ref._reactInternals.key, attachedPart.ref);430 circuit.addLink(element._reactInternals.key, attachedPart.ref._reactInternals.key);431 }432 }433 });434 }435 });436 this.setState({437 circuit: circuit,438 cycles: getCircuits(circuit, listOfBatteries)439 }, () => {440 this.startSim();441 })442 } else {443 this.stopSim();444 }445 })446 };447 /**448 * Iterates through the cycles and calculates the voltage, resistance and current449 */450 startSim = () => {451 console.log("Starting simulation...");452 if (this.selectedPart) {453 this.unselectPart()454 }455 for (let cycle of this.state.cycles) {456 let voltage = this.state.circuit.getNode(cycle[0]).data.state.voltage;457 let totalResistance = 0;458 let buttonPass = true459 for (let i = 1; i < cycle.length; i++) {460 let node = this.state.circuit.getNode(cycle[i]);461 if (node.data.state.type === "Resistor") {462 totalResistance += this.getResistance(node.data);463 }464 if (node.data.state.isToggled === true) {465 buttonPass = false466 }467 if (node.data.state.isPressed === false) {468 buttonPass = false469 }470 }471 for (let i = 1; i < cycle.length; i++) {472 let node = this.state.circuit.getNode(cycle[i]);473 if (buttonPass) {474 this.setCurrent(node.data, voltage, totalResistance);475 } else {476 this.setCurrent(node.data, 0, 0);477 }478 }479 console.log(cycle)480 }481 }482 /**483 * Transveres the graph and sets the current to zero for all components484 */485 stopSim = () => {486 this.state.circuit.forEachNode((node) => {487 this.setCurrent(node.data, 0, 0)488 });489 console.log("Stopping simulation...")490 }491 handleShare = () => {492 // TODO handle Share493 console.log('Share clicked')494 };495 /**496 * Selects and highlights the part and displays the part's relevant information in the properties panel497 *498 * @param {Object} childData - Object containing the part's data499 */500 handlePartSelect = (childData) => {501 if (!childData.ref.state.isSelected) {502 this.setState({503 hideProperties: false,504 partData: childData505 });506 if (this.selectedPart) {507 this.selectedPart.ref.setState({isSelected: false});508 }509 childData.ref.setState({isSelected: true}, () => {510 this.selectedPart = childData;511 });512 } else {513 this.unselectPart();514 }515 }516 handlePartToggle = (childData) => {517 if (this.state.isSimulating) {518 // console.log(childData.ref)519 this.startSim()520 }521 }522 handlePartDown = (childData) => {523 if (this.state.isSimulating) {524 // console.log(childData.ref)525 this.startSim()526 }527 }528 /**529 * Updates the properties panel based on the Object given530 *531 * @param {Object} childData - Object containing the part's data532 */533 updatePropertiesPanel(childData) {534 this.setState({535 hideProperties: false,536 partData: childData537 });538 }539 /**...

Full Screen

Full Screen

view.js

Source:view.js Github

copy

Full Screen

1import Simulation from "./simulation";2var stateNames = ['MAINE','NEW_HAMPSHIRE','DELAWARE','DIST._OF_COLUMBIA','nowhere','nowhere','nowhere',3 'SOUTH_CAROLINA','NEBRASKA','WASHINGTON','NEW_MEXICO','nowhere','SOUTH_DAKOTA','TEXAS','CALIFORNIA','KENTUCKY',4 'OHIO','ALABAMA','GEORGIA','WISCONSIN','ARKANSAS','OREGON','PENNSYLVANIA','MISSISSIPPI','COLORADO','UTAH',5 'OKLAHOMA','TENNESSEE','WEST_VIRGINIA','NEW_YORK','INDIANA','KANSAS','NEVADA','ILLINOIS','VERMONT','CONNECTICUT',6 'MONTANA','MINNESOTA','MARYLAND','HAWAII','ARIZONA','RHODE_ISLAND','MISSOURI','NORTH_CAROLINA','VIRGINIA','WYOMING',7 'LOUISIANA','MICHIGAN','MASSACHUSETTS','IDAHO','FLORIDA','ALASKA','nowhere','NEW_JERSEY','NORTH_DAKOTA','IOWA'];8class View{9 constructor(data){10 this.createMap();11 this.createLegend();12 this.createForm();13 this.data = data;14 // console.log(data);15 this.sim = new Simulation(data,document);16 this.start = document.getElementById('start');17 this.startSim = this.startSim.bind(this);18 this.start.addEventListener('click',this.startSim);19 this.add = document.getElementById('add');20 this.addLock = this.addLock.bind(this);21 this.add.addEventListener('click',this.addLock);22 this.removeLock = this.removeLock.bind(this);23 this.reset = document.getElementById('reset');24 this.startOver = this.startOver.bind(this);25 this.reset.addEventListener('click',this.startOver);26 this.pause = document.getElementById('pause');27 this.pauseSim = this.pauseSim.bind(this);28 this.pause.addEventListener('click',this.pauseSim);29 this.unpause = document.getElementById('unpause');30 this.unpauseSim = this.unpauseSim.bind(this);31 this.unpause.addEventListener('click',this.unpauseSim);32 let that = this;33 setTimeout(function(){34 const tooltip = d3.select(`body`)35 .append('div')36 .attr('class','tooltip-donut')37 .style('position','absolute')38 .style('opacity','0')39 .html('initial');40 var states = d3.selectAll('.state');41 states.on('mouseover',function(){42 // console.log(this.id);43 var state = that.sim.states[this.id];44 // var state = 45 d3.select(this).transition()46 .duration(50)47 .attr('opacity','.85');48 tooltip.transition()49 .duration(50)50 .style('opacity','1');51 tooltip.html(`${state.name.split("_").join(" ")}<br>52 Population: ${state.population}<br>53 Infected: ${state.infected}<br>54 Percentage: ${Math.ceil(state.percent * 100)}%<br>55 ${state.allow_lockdown ? `${state.lockdown ? 'Under Lockdown' : 'Lockdown Lifted'}` : `No Lockdown Protocol`}`)56 .style("left", (event.pageX + 10) + "px")57 .style("top", (event.pageY - 15) + "px");58 })59 .on('mouseout', function () {60 d3.select(this).transition()61 .duration('50')62 .attr('opacity', '1');63 tooltip.transition()64 .duration('50')65 .style("opacity", 0);66 });67 },2000) //time for map to load68 }69 createMap(){70 var margin = { top:0,left:0,right:0,bottom:0},71 width = 880 - margin.top - margin.bottom,72 height = 500 - margin.left - margin.right;73 var svg = d3.select('#map')74 .append('svg')75 .attr('width',width + margin.left + margin.right)76 .attr('height',height + margin.top + margin.bottom);77 var url = d3.json('https://cdn.jsdelivr.net/npm/@d3ts/us-atlas@1/states-10m.json');78 var g = svg.append('g');79 var projection = d3.geoAlbersUsa().scale(1000);//.translate([width/2,height/2]);80 var path = d3.geoPath().projection(projection);81 let i = -1;82 url.then(function(data) {83 var states = topojson.feature(data,data.objects.states).features;84 g.selectAll('path')85 .data(states)86 .enter().append('path')87 .attr('id',function(){88 i += 1;89 return stateNames[i];90 })91 .attr('class','state')92 .attr('d',path);93 })94 }95 createLegend(){96 var svg = d3.select("#legend").append('svg').attr('width','800').attr('height','80');97 var keys = ['0%','10%','20%','30%','40%','50%','60%','70%','80%','90%','100%'];98 var color = ['lightcyan','paleturquoise','mediumturquoise','darkturquoise','cadetblue','lightcoral','salmon','red','firebrick','darkred','purple'];99 var size = 40100 svg.selectAll("mydots")101 .data(keys)102 .enter()103 .append("rect")104 .attr("y", 30)105 .attr("x", function(d,i){ return size*5 + i*(size+2)}) // 100 is where the first dot appears. 25 is the distance between dots106 .attr("width", size)107 .attr("height", 15)108 .style("fill", function(d,i){ return color[i]})109 110 // Add one dot in the legend for each name.111 svg.selectAll("mylabels")112 .data(keys)113 .enter()114 .append("text")115 .attr("y", 20 + size)116 .attr("x", function(d,i){ return i*(size+2) + (size*5)}) // 100 is where the first dot appears. 25 is the distance between dots117 .style("fill", function(d,i){ return color[i]})118 .text(function(d,i){ return keys[i]})119 .attr("text-anchor", "left")120 .style("alignment-baseline", "middle")121 svg.append('text')122 .attr('x',size*5)123 .attr('y',20)124 .style('fill','white')125 .text('% of population infected');126 127 // var svg = d3.select("#legend").append('svg').attr('width','450').attr('height','300');128 // svg.append("circle").attr("cx",200).attr("cy",130).attr("r", 6).style("fill", "lightcyan")129 // svg.append("circle").attr("cx",200).attr("cy",160).attr("r", 6).style("fill", "paleturquoise")130 // svg.append("circle").attr("cx",200).attr("cy",190).attr("r", 6).style("fill", "mediumturquoise")131 // svg.append("circle").attr("cx",200).attr("cy",220).attr("r", 6).style("fill", "darkturquoise")132 // svg.append("circle").attr("cx",200).attr("cy",250).attr("r", 6).style("fill", "cadetblue")133 // svg.append("circle").attr("cx",260).attr("cy",130).attr("r", 6).style("fill", "lightcoral")134 // svg.append("circle").attr("cx",260).attr("cy",160).attr("r", 6).style("fill", "salmon")135 // svg.append("circle").attr("cx",260).attr("cy",190).attr("r", 6).style("fill", "red")136 // svg.append("circle").attr("cx",260).attr("cy",220).attr("r", 6).style("fill", "firebrick")137 // svg.append("circle").attr("cx",260).attr("cy",250).attr("r", 6).style("fill", "darkred")138 // svg.append("circle").attr("cx",260).attr("cy",280).attr("r", 6).style("fill", "purple")139 // svg.append("text").attr("x", 220).attr("y", 130).text("0%").style("font-size", "15px").attr("alignment-baseline","middle")140 // svg.append("text").attr("x", 220).attr("y", 160).text("10%").style("font-size", "15px").attr("alignment-baseline","middle")141 // svg.append("text").attr("x", 220).attr("y", 190).text("20%").style("font-size", "15px").attr("alignment-baseline","middle")142 // svg.append("text").attr("x", 220).attr("y", 220).text("30%").style("font-size", "15px").attr("alignment-baseline","middle")143 // svg.append("text").attr("x", 220).attr("y", 250).text("40%").style("font-size", "15px").attr("alignment-baseline","middle")144 // svg.append("text").attr("x", 280).attr("y", 130).text("50%").style("font-size", "15px").attr("alignment-baseline","middle")145 // svg.append("text").attr("x", 280).attr("y", 160).text("60%").style("font-size", "15px").attr("alignment-baseline","middle")146 // svg.append("text").attr("x", 280).attr("y", 190).text("70%").style("font-size", "15px").attr("alignment-baseline","middle")147 // svg.append("text").attr("x", 280).attr("y", 220).text("80%").style("font-size", "15px").attr("alignment-baseline","middle")148 // svg.append("text").attr("x", 280).attr("y", 250).text("90%").style("font-size", "15px").attr("alignment-baseline","middle")149 // svg.append("text").attr("x", 280).attr("y", 280).text("100%").style("font-size", "15px").attr("alignment-baseline","middle")150 }151 createForm(){152 var drop = document.getElementById('location');153 var lock = document.getElementById('lockdowns');154 var names = stateNames.slice(0).sort();155 names.forEach(name => {156 if(name !== "nowhere"){157 var opt = document.createElement('option');158 opt.textContent = name.split("_").join(" ");159 opt.value = name;160 drop.appendChild(opt);161 162 var state = document.createElement('option');163 state.textContent = name.split("_").join(" ");164 state.value = name;165 lock.appendChild(state);166 }167 })168 }169 startSim(e){170 var location = document.getElementById('location');171 var r_number = document.getElementById('r-number');172 var recover = document.getElementById('recovery-number');173 if(location.value === "" || r_number.value < 0 || r_number > 100 || recover < 0 || recover > 1){174 alert("Invalid Input(s)");175 e.preventDefault();176 }else{177 this.start.style.display = 'none';178 this.pause.style.display = 'block';179 var locks = document.getElementById('state-info');180 locks.style.display = 'none';181 this.sim.simulate();182 }183 }184 addLock(e){ //events adding elements to html reload dom which triggers reload sequence185 var location = document.getElementById('lockdowns');186 if(location.value === ''){187 alert("You must choose a state");188 e.preventDefault();189 }else{190 var lock = document.getElementById('lock-limit');191 var lift = document.getElementById('lift-limit');192 var list = document.getElementById('lockdown-states');193 var states = list.getElementsByTagName('button');194 var free = true;195 for (let i = 0; i< states.length;i++){196 if(states[i].value === location.value){197 alert("This state has already been added.")198 free = false;199 e.preventDefault();200 break;201 }202 }203 if(free){204 // debugger;205 if(lock.value < lift.value){206 // debugger;207 alert("Invalid Limits");208 e.preventDefault();209 }else{210 // debugger;211 e.preventDefault(); //to prevent page from reloading212 this.sim.addLockdown();213 var new_state = document.createElement('button');214 new_state.setAttribute('value',location.value);215 new_state.setAttribute('class','lockeddown');216 new_state.style.border = '1px solid white';217 new_state.style.borderRadius = '3px';218 new_state.style.margin = '2px';219 var content = `${location.value.split('_').join(" ")}<br>Lockdown: ${lock.value}<br>Lift: ${lift.value}`;220 new_state.innerHTML = content;221 list.appendChild(new_state);222 // debugger;223 new_state.addEventListener('click',this.removeLock);224 // debugger;225 }226 }227 }228 }229 removeLock(e){230 var place = e.target;231 var location = place.value;232 place.remove();233 this.sim.removeLock(location);234 }235 startOver(e){236 this.sim.reset();237 }238 pauseSim(e){239 this.pause.style.display = 'none';240 this.unpause.style.display = 'block';241 this.sim.pauseSim();242 }243 unpauseSim(e){244 this.unpause.style.display = 'none';245 this.pause.style.display = 'block';246 this.sim.startSim();247 }248}...

Full Screen

Full Screen

SIR.js

Source:SIR.js Github

copy

Full Screen

...201 if (202 this.state.infectiousPopulation > 0.01 &&203 this.state.isPaused === false204 ) {205 this.startSim();206 }207 }, 100);208 };209 render() {210 let options = {211 options: {212 responsive: true,213 scales: {214 yAxes: [215 {216 ticks: {217 beginAtZero: true,218 },219 },220 ],221 },222 },223 };224 let data = {225 labels: this.state.dayData,226 datasets: [227 {228 id: 1,229 label: "Susceptible",230 data: this.state.susceptibleData,231 backgroundColor: ["rgba(30, 30, 255, 0.2)"],232 borderColor: ["rgba(30,30,255,0.5)"],233 },234 {235 id: 2,236 label: "Infected",237 data: this.state.infectedData,238 backgroundColor: ["rgba(255, 30, 30, 0.2)"],239 borderColor: ["rgba(255,30,30,0.5)"],240 },241 {242 id: 3,243 label: "Recovered",244 data: this.state.recoveredData,245 backgroundColor: ["rgba(200,200,200,0.2)"],246 },247 ],248 };249 return (250 <div>251 <Container>252 <Row>253 <Col className="col-8">254 <Line datasetIdKey="id" data={data} options={options} />255 </Col>256 <Col>257 <TooltipIcon />258 <Row>259 <ButtonGroup>260 <Button261 color="success"262 onClick={async () => {263 await this.setState({ isPaused: false });264 this.startSim();265 }}266 >267 Play <FontAwesomeIcon className="ml" icon={faPlay} />268 </Button>269 <Button270 color="danger"271 onClick={() => {272 this.setState({ isPaused: true });273 }}274 >275 Pause <FontAwesomeIcon icon={faPause} />276 </Button>277 <Button onClick={this.initializeChart}>Reset</Button>278 </ButtonGroup>...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...135 componentDidMount(){136 const canvas = document.getElementById('testgame');137 const ctx = canvas.getContext('2d');138 //document.addEventListener('keydown' ,this.handleInput);139 this.startSim();140 }141 parseMove(){142 }143 144 intersectRect(r1, r2) {145 return !(r2.left > r1.right || 146 r2.right < r1.left || 147 r2.top > r1.bottom ||148 r2.bottom < r1.top);149 }150 gameLoop(color, ants, stopAfterRun){151 if(stopAfterRun){152 return;153 }...

Full Screen

Full Screen

simulator2.js

Source:simulator2.js Github

copy

Full Screen

1function simulator()2{ 3 //chicken related variables4 //DEFAULT VALUES5 this.flockSize = 250;6 this.repelRadius = 0.012;//0.0157 this.attractRadius = 0.03;8 this.radiusVariation = 0.002;9 this.speedVariation = 0.0000;10 this.speed = 0.0006;11 this.drawRadii = false;12 this.drawAttractors = true;13 this.running = false;14 15 //16 //17 //simulation related variables18 this._iter_interval = null;19 this._draw_interval = null;20 this.flock = [];//array holding all chickens. like a hen house.21 this.attractors = [];22 this._usingBoundry = false;23 this._sim_log = "";24 this.simContext = null;25 this.myPatch = null;26 27 this.startSim = function( flockSize, repelRadius, attractRadius, radiusVariation,speed,speedVariation)28 {29 this.stopSim();//this should be first30 if(!this.flock || this.flock.length == 0)31 this.initSim( flockSize,repelRadius, attractRadius, radiusVariation,speed, speedVariation);32 this._draw_interval = setInterval( drawEm, 50, this);33 this._iter_interval = setInterval ( iterateFunc, 20,this);34 this.running = true;35 }36 this.stopSim = function()37 {38 if( this._iter_interval){39 clearInterval( this._iter_interval);40 }41 if( this._draw_interval){42 clearInterval( this._draw_interval);43 }44 this.running = false;45 }46//this makes a new canvas or attatches the drawing to a canvas47 this.attatchToCanvas = function( aCanvas)48 {49 if( !aCanvas)50 {51 aCanvas = document.createElement("canvas");52 aCanvas.width = aCanvas.height = 600;//window.innerHeight -24;53 document.body.appendChild( aCanvas);54 this.simContext = aCanvas.getContext("2d");55 }56 else57 {58 this.simContext = aCanvas.getContext("2d");59 }60 //this.simContext = Z.getContext("2d");61 return aCanvas;62 }63 this.initSim = function( flockSize,repelRadius, attractRadius, radiusVariation,speed, speedVariation)64 {65 if( flockSize)66 this.flockSize = flockSize;67 if(repelRadius)68 this.repelRadius = repelRadius;69 if(attractRadius)70 this.attractRadius = attractRadius;71 if(radiusVariation)72 this.radiusVariation = radiusVariation;73 if(speedVariation)74 this.speedVariation = speedVariation;75 if(speed)76 this.speed = speed;77 if( !this.myPatch){78 var patchesEmpty = new patchArray(100,100);79 this.attachBoundry( patchesEmpty);80 }81 this.flock = [];82 this.attractors = [];83 //84 // POPULATE THE FLOCK85 while( this.flock.length > this.flockSize){86 this.flock.pop();87 } 88 while( this.flock.length < this.flockSize){89 if(this._usingBoundry){90 var x = Math.random();91 var y = Math.random();92 while( !this.myPatch.isInBounds(x,y) )93 {94 x += 1/41;95 y += 1/71;96 x = x % 1;97 y = y % 1;98 }99 this.flock.push( new chicken( x, y, this.attractRadius + Math.random() * this.radiusVariation, this.repelRadius + Math.random() * this.radiusVariation, this.speed + Math.random() * this.speedVariation, this) );100 }101 else102 {103 this.flock.push(104 new chicken( Math.random(), Math.random(), this.attractRadius + Math.random() * this.radiusVariation, this.repelRadius + Math.random() * this.radiusVariation, this.speed + Math.random() * this.speedVariation, this) );105 }106 }107 flock = this.flock;108 //109 //add some attractors110 this.attractors.push( new attractor( 0.1,0.5, -1,0.3) );111 //this.attractors.push( new attractor( 0.5,0.6, 0.05,0.2) );112 //this.attractors.push( new attractor( 1.5,0.6, 0.005,2) );113 114 attractors = this.attractors;115 }116 117 this.isMoveGood = function( aChik)118 {119 //var _displayRatio = 1;120 //boundry image121 if( this._usingBoundry)122 {123 var lox = (aChik.pos.x + aChik.pos.vx * aChik.speed) ;124 var loy = (aChik.pos.y + aChik.pos.vy * aChik.speed) ; 125 if( this.myPatch.isInBounds(lox,loy) == 0 ){126 return false;127 }128 }129 //walls130 if( aChik.pos.x + aChik.pos.vx * aChik.speed < 0 ) {131 return false;132 }133 else if( aChik.pos.x + aChik.pos.vx * aChik.speed > 1 ) {134 return false;135 }136 if( aChik.pos.y + aChik.pos.vy * aChik.speed < 0 ) {137 return false;138 }139 else if( aChik.pos.y + aChik.pos.vy * aChik.speed > 1 ) {140 return false;141 }142 return true 143 }144 145 this.attachBoundry = function( patchIn )146 {147 this.myPatch = patchIn;148 this._usingBoundry = true;149 }150}151function iterateFunc( simu)152{153 154 // move em around155 for( i in simu.flock)156 {157 var bird = simu.flock[i];158 bird.applyForces();159 }160 simu.myPatch.cleanHood();161 for( i in simu.flock)162 {163 var bird = simu.flock[i];164 bird.move();165 }166}167function drawEm( simu)168{169 //simu._sim_log = "drawer called";170 if( ! simu.simContext){171 //simu._sim_log = "0rawer called, no simContext specified";172 return;173 }174 var X = simu.simContext;175 var Wid = X.canvas.width;176 var Hei = X.canvas.height;177 178 X.clearRect( 0,0, Wid, Hei);179 180 //bird color181 X.fillStyle = 'red';182 183 for( i in simu.flock)184 {185 var bird = simu.flock[i];186 var bx = bird.pos.x;187 var by = bird.pos.y;188 //draw bird189 X.strokeStyle = "green";190 X.beginPath();191 X.moveTo(bx*Wid, by * Hei);192 X.arc(bx*Wid,by*Hei, 4 , 0 , __twopi, true);193 X.fill();194 if(simu.drawRadii)195 {196 X.strokeStyle = "green";197 X.moveTo( bx * Wid + bird.r_attract * Wid, by*Hei); 198 X.arc(bx*Wid, by*Hei, bird.r_attract * Wid , 0 , __twopi, true);199 X.stroke();200 X.closePath()201 X.beginPath();202 X.strokeStyle = "tan";203 X.moveTo( bx * Wid + bird.r_repel * Wid, by*Hei); 204 X.arc(bx*Wid, by*Hei, bird.r_repel * Wid , 0 , __twopi, true);205 X.stroke();206 }207 X.closePath();208 }209 210 211 for( i in simu.attractors)212 {213 var atr = simu.attractors[i];214 //draw the center 215 if(atr.force > 0 )216 X.fillStyle = "rgba(255, 0, 0, 1.0)";217 else218 X.fillStyle = "rgba(0,0,255, 1.0)";219 X.fillRect (atr.pos.x * Wid , atr.pos.y*Hei, 10, 10) ;220 //draw the ring of influence221 if( simu.drawAttractors && atr.force !=0)222 {223 if(atr.force > 0 )224 X.fillStyle = "rgba(255, 0, 0, 0.1)";225 else226 X.fillStyle = "rgba(0,0,255, 0.1)";227 X.beginPath();228 X.strokeStyle = "red";229 X.moveTo( atr.pos.x * Wid + atr.radius * Wid, atr.pos.y*Hei); 230 X.arc(atr.pos.x*Wid,atr.pos.y*Hei, atr.radius * Wid , 0 , __twopi, true); 231 X.stroke();232 X.fill();233 X.closePath();234 }235 }236 237}...

Full Screen

Full Screen

driver.js

Source:driver.js Github

copy

Full Screen

...34 this.opts.bundleId = await extractBundleId(this.opts.app);35 }36 // start sim, or use running sim37 log.info('starting simlator (if not booted)');38 this.sim = await this.startSim();39 this.wda = new WebDriverAgent({40 udid: this.sim.udid,41 platformVersion: this.opts.platformVersion,42 host: this.opts.host,43 agentPath: this.opts.agentPath44 });45 await this.wda.launch(sessionId);46 log.info("Installing the app");47 // TODO don't re-install (need to check if version numbers match)?48 await installApp(this.sim.udid, this.opts.app);49 log.info("Launching the app");50 await this.launchApp(this.sim.udid, this.opts.bundleId);51 this.proxyReqRes = this.wda.proxyReqRes.bind(this.wda);52 this.jwpProxyActive = true;...

Full Screen

Full Screen

SimControl.js

Source:SimControl.js Github

copy

Full Screen

1import React, { Component } from 'react';2import StreamingPageManager from './../StreamingPageManager';3import GenericParameterLabel from './displaycomponents/GenericParameterLabel';4import NumericInput from './displaycomponents/NumericInput';5import createSocket from '../shared/socket';6let socket = createSocket();7class Simulator_Control extends Component {8 constructor (props) {9 super(props);10 this.render = this.render;11 this.state = {12 streamManager: new StreamingPageManager(),13 selectedPin: '4'14 };15 this.labels = [16 {label: 'BMS Faults', value: `Power ${props.route.L} BMS Faults`, hex: 'true'},17 {label: 'Temp State', value: `Power ${props.route.L} BMS Temp State`},18 {label: 'Charger State', value: `Power ${props.route.L} BMS Charger State`},19 {label: 'Num Temp Sensors', value: `Power ${props.route.L} BMS Num Temp Sensors`},20 {label: 'Highest Sensor Value', value: `Power ${props.route.L} BMS Highest Sensor Value`},21 {label: 'Average Temp', value: `Power ${props.route.L} BMS Average Temp`},22 {label: 'Highest Sensor Index', value: `Power ${props.route.L} BMS Highest Sensor Index`},23 {label: 'Pack Current', value: `Power ${props.route.L} BMS Battery Current`},24 {label: 'Charge Current', value: `Power ${props.route.L} BMS Charging Current`},25 {label: 'State of Charge', value: `Power ${props.route.L} BMS State of Charge`}26 ];27 }28 componentDidMount () {29 var _this = this;30 this._isMounted = true;31 }32 componentWillUnmount () {33 this._isMounted = false;34 }35 // example of command36 startSim (e) {37 e.preventDefault();38 socket.emit(`PySim:StartSim`);39 }40 pauseSim (e) {41 e.preventDefault();42 socket.emit(`PySim:PauseSim`);43 }44 resumeSim (e) {45 e.preventDefault();46 socket.emit(`PySim:ResumeSim`);47 }48 stopSim (e) {49 e.preventDefault();50 socket.emit(`PySim:StopSim`);51 }52 startLogging (e) {53 e.preventDefault();54 socket.emit(`PySim:StartLogging`);55 }56 stopLogging (e) {57 e.preventDefault();58 socket.emit(`PySim:StopLogging`);59 }60 startPush (e) {61 e.preventDefault();62 socket.emit(`PySim:StartPusher`);63 }64 resetSim (e) {65 e.preventDefault();66 socket.emit(`PySim:ResetSim`);67 }68 resetFcu (e) {69 e.preventDefault();70 socket.emit(`PySim:ResetFcu`, null);71 }72 render () {73 var _this = this;74 var buttonClasses = 'btn btn-primary ' + ((this.state.developmentMode) ? '' : 'disabled');75 let borderStyle = {border: '2px solid black', borderRadius: '10px', padding: '10px', width: '50%'};76 return (77 <div>78 <h2>Sim Control Interface</h2>79 <div className="row">80 <div className="col-sm-5">81 <h3 className="section-title">Playback Controls</h3>82 <button className="btn btn-success" onClick={_this.startSim.bind(this)} style={{margin: 10}}>Start Simulator</button>83 <button type="button" className="btn btn-warning" onClick={this.pauseSim.bind(this)} style={{margin: 10}}>Pause Simulator</button>84 <button type="button" className="btn btn-primary" onClick={this.resumeSim.bind(this)} style={{margin: 10}}>Resume Simulator</button>85 <button type="button" className="btn btn-danger" onClick={this.stopSim.bind(this)} style={{margin: 10}}>Stop Simulator</button><br />86 </div>87 </div>88 </div>89 );90 }91}...

Full Screen

Full Screen

simulation.js

Source:simulation.js Github

copy

Full Screen

1(function () {2 var app = angular.module('simulation', []);3 app.controller('SimulationController', function(){4 var _this = this;5 _this.socket = io();6 _this.begin = begin;7 _this.previous = previous;8 _this.next = next;9 _this.startSim = false;10 _this.socket.on(DRAW_MAP, function (msg) {11 console.log(DRAW_MAP+' request: '+msg);12 showResults(msg);13 });14 _this.socket.on(SHOW_DATA, function (msg){15 // console.log(SHOW_DATA+' request: '+msg);16 showData(msg);17 });18 19 _this.socket.on(SHOW_ADD_DATA, function (msg){20 // console.log(SHOW_DATA+' request: '+msg);21 showData(msg);22 });23 _this.socket.on(I1_CHART, function (msg){24 console.log(I1_CHART+' request');25 addIndicator1Chart(msg);26 });27 if (_this.time === undefined) _this.time = 0;28 function begin(){29 _this.socket.emit(INITIALIZE);30 _this.startSim = true;31 _this.time = 0;32 }33 function previous(){34 _this.socket.emit(PREVIOUS,_this.time);35 _this.time = _this.time - 1;36 }37 function next(){38 _this.socket.emit(NEXT,_this.time);39 _this.time = _this.time + 1;40 }41 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Appium Xcuitest Driver', function() {2 it('should start and stop a simulator', async function() {3 await this.startSim();4 await this.stopSim();5 });6});7describe('Appium Xcuitest Driver', function() {8 it('should start and stop a simulator', async function() {9 await this.startSim();10 await this.stopSim();11 });12});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const { startSimulator } = require('appium-xcuitest-driver/lib/simulator-management.js');3async function main () {4 await driver.init({5 });6 const udid = await driver.sessionCapabilities().then((caps) => caps.udid);7 const sim = await startSimulator(udid);8 await sim.run();9}10main();11> const { startSimulator } = require('appium-xcuitest-driver/lib/simulator-management.js');12> const { getSimulator } = require('appium-ios-simulator');13> const sim = await startSimulator('F8C8F3E3-1C0C-4C3B-8E0C-9E9D4E7C1B4C');14> const sim = await getSimulator('F8C8F3E3-1C0C-4C3B-8E0C-9E9D4E7C1B4C');15> await sim.run();16> await sim.shutdown();

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const { startSimulator } = require('appium-xcuitest-driver');3const { simctl } = require('appium-ios-simulator');4const sim = await simctl.createDevice('iPhone X', '11.2');5const udid = sim.udid;6const device = await startSimulator(udid);7await driver.init({

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My Test', function() {2 it('should do something', function() {3 this.startSim();4 });5});6class XCUITestDriver extends BaseDriver {7 async startSim() {8 console.log('Sim started');9 }10}11class BaseDriver {12 constructor() {13 this.startSim = this.startSim.bind(this);14 }15 async startSim() {16 throw new errors.NotYetImplementedError();17 }18}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { XCUITestDriver } from 'appium-xcuitest-driver';2import { BaseDriver } from 'appium-base-driver';3import { EventEmitter } from 'events';4let driver = new XCUITestDriver();5let baseDriver = new BaseDriver();6let eventEmitter = new EventEmitter();7let appiumXcuitestDriver = new XCUITestDriver();8appiumXcuitestDriver.startSim();9baseDriver.startSim();10eventEmitter.startSim();11driver.startSim();12driver.startSim();13baseDriver.startSim();14eventEmitter.startSim();15driver.startSim();16appiumXcuitestDriver.startSim();17baseDriver.startSim();18eventEmitter.startSim();19driver.startSim();20appiumXcuitestDriver.startSim();21baseDriver.startSim();22eventEmitter.startSim();

Full Screen

Using AI Code Generation

copy

Full Screen

1const XCUITestDriver = require('appium-xcuitest-driver');2class MyCustomDriver extends XCUITestDriver {3 constructor(opts) {4 super(opts);5 }6 async startSim() {7 return await XCUITestDriver.prototype.startSim.apply(this, arguments);8 }9 async stopSim() {10 return await XCUITestDriver.prototype.stopSim.apply(this, arguments);11 }12}13Error: The driver instance has not yet been started; please run start() first!14const XCUITestDriver = require('appium-xcuitest-driver');15class MyCustomDriver extends XCUITestDriver {16 constructor(opts) {17 super(opts);18 }19 async startSim() {20 return await this.startSim.apply(this, arguments);21 }22 async stopSim() {23 return await this.stopSim.apply(this, arguments);24 }25}26const XCUITestDriver = require('appium-xcuitest-driver');27class MyCustomDriver extends XCUITestDriver {28 constructor(opts) {29 super(opts);30 }31 async startSim() {32 return await super.startSim.apply(this, arguments);33 }34 async stopSim() {35 return await super.stopSim.apply(this, arguments);36 }37}38Error: The driver instance has not yet been started; please run start() first!

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

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

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful