Blame view

view/edit_mems.html 5.84 KB
cf76164e6   Ting Chan   20190709
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
  <?php
  	//include('cfg/file_name.php');
      $open_mems = '/home/pi/Desktop/vAlert/bin/memsCalData';
      shell_exec("sudo chmod 777 ".$open_mems);
  	$nn = 0;
  	$handle = @fopen($open_mems, "r");
          while(($data = fgets($handle,1000)) != false){
                  $output = explode(" ", $data);
                  if($output[0] == "A_AXIS_OFFSET"){
                          $A_AXIS_OFFSET=$output[1];
                  }
                  if($output[0] == "B_AXIS_OFFSET"){
                          $B_AXIS_OFFSET=$output[1];
                  }
                  if($output[0] == "C_AXIS_OFFSET"){
                          $C_AXIS_OFFSET=$output[1];
                  }
                  if($output[0] == "D_AXIS_OFFSET"){
                          $D_AXIS_OFFSET=$output[1];
                  }
                  if($output[0] == "A_AXIS_1G"){
                          $A_AXIS_1G=$output[1];
                  }                
                  if($output[0] == "B_AXIS_1G"){
                          $B_AXIS_1G=$output[1];
                  }
                  if($output[0] == "C_AXIS_1G"){
                          $C_AXIS_1G=$output[1];
                  }
                  if($output[0] == "D_AXIS_1G"){
                          $D_AXIS_1G=$output[1];
                  }
  
          }
  	if($_SESSION['account'] == 'sanlien'){
  		$action = 'php/change_mems.php';
  	}
  
  ?>				
  					<main class="mn-inner">
  						<div class="row">	
  						<div class="card">
                              <div class="card-content">
                                  <span class="card-title">MEMS</span><br>
                                  <div class="row">
                                      <form class="col s12" id="msform" action='<?php echo $action; ?>' method="post">
  										
                                          <div class="row" >
  
  											<div class="input-field col s12">
                                                  <input type="text" name="A_AXIS_OFFSET" value="<?php echo $A_AXIS_OFFSET;?>" placeholder='A_AXIS_OFFSET'/>
                                                  <label for="first_name">A_AXIS_OFFSET</label>
                                              </div>
  											<div class="input-field col s12">
                                                  <input type="text" name="B_AXIS_OFFSET" value="<?php echo $B_AXIS_OFFSET;?>" placeholder='B_AXIS_OFFSET'/>
                                                  <label for="first_name">B_AXIS_OFFSET</label>
                                              </div>
  											<div class="input-field col s12">
                                                  <input type="text" name="C_AXIS_OFFSET" value="<?php echo $C_AXIS_OFFSET;?>" placeholder='C_AXIS_OFFSET'/>
                                                  <label for="first_name">C_AXIS_OFFSET</label>
                                              </div>
  											<div class="input-field col s12">
                                                  <input type="text" name="D_AXIS_OFFSET" value="<?php echo $D_AXIS_OFFSET;?>" placeholder='D_AXIS_OFFSET'/>
                                                  <label for="first_name">D_AXIS_OFFSET</label>
                                              </div>
  											<div class="input-field col s12">
                                                  <input type="text" name="A_AXIS_1G" value="<?php echo $A_AXIS_1G;?>" placeholder='A_AXIS_1G'/>
                                                  <label for="first_name">A_AXIS_1G</label>
                                              </div>
  											<div class="input-field col s12">
                                                  <input type="text" name="B_AXIS_1G" value="<?php echo $B_AXIS_1G;?>" placeholder='B_AXIS_1G'/>
                                                  <label for="first_name">B_AXIS_1G</label>
                                              </div>
  											<div class="input-field col s12">
                                                  <input type="text" name="C_AXIS_1G" value="<?php echo $C_AXIS_1G;?>" placeholder='C_AXIS_1G'/>
                                                  <label for="first_name">C_AXIS_1G</label>
                                              </div>
  											<div class="input-field col s12">
                                                  <input type="text" name="D_AXIS_1G" value="<?php echo $D_AXIS_1G;?>" placeholder='D_AXIS_1G'/>
                                                  <label for="first_name">D_AXIS_1G</label>
                                              </div>
  											
  											
                                          </div>
  										<a class="waves-effect waves-light btn m-b-xs update"><?=UPDATE?></a>
  											
                                      </form>
                                  </div>  
                              </div>
                          </div>
  						</div>
  						
  					</main>
  				</div>
  			
          <div class="left-sidebar-hover"></div>
          
          <!-- Javascripts -->
          <script src="assets/plugins/jquery/jquery-2.2.0.min.js"></script>
          <script src="assets/plugins/materialize/js/materialize.min.js"></script>
          <script src="assets/plugins/material-preloader/js/materialPreloader.min.js"></script>
          <script src="assets/plugins/jquery-blockui/jquery.blockui.js"></script>
          <script src="assets/plugins/select2/js/select2.min.js"></script>
          <script src="assets/js/alpha.min.js"></script>
          <script src="assets/js/pages/form-select2.js"></script>
          <script>
  			$('.update').click(function(){
  				$.ajax( {
  					  type: "POST",
  					  url: $('#msform').attr( 'action' ),
  					  data: $('#msform').serialize(),
  					  success: function( response ) {
  						if(response == '1'){
  							alert('Success !');
  							location.href='index.php?item=edit_mems';
  						}else{
  							alert('Error !');
  						}
  					  }
  				});
  			})
  		</script>
      </body>
  </html>