OSDN Git Service

mbed.jsの更新
[mimic/MiMicSDK.git] / misc / MiMicVM / mbed.js / mimic / mbed.AnalogIn.js
index ea52cac..ff28b76 100644 (file)
@@ -38,21 +38,26 @@ var MI=MiMicJS;
  * @return {mbedJS.AnalogIn}\r
  * @example\r
  */\r
-var CLASS=function DigitalIn(i_mcu,i_params,i_handler)\r
+var CLASS=function AnalogIn(i_mcu,i_params,i_handler)\r
 {\r
-       var _t=this;\r
-       _t._mcu=i_mcu;\r
-       _t._lc=CLASS;\r
-       if(MI.isGenerator(i_handler)){_t._gen=i_handler;}\r
-       else if(i_handler){_t._event=i_handler}\r
-       function cb(j)\r
-       {\r
-               _t._oid=j.result[0];\r
-               if(_t._event.onNew){_t._event.onNew();}\r
-               if(_t._gen){_t._gen.next(_t);}\r
-               _t._lc=null;\r
-       }\r
-       return _t._mcu.rpc(_t.RPC_NS+":_new1",i_params,cb);\r
+       try{\r
+               var _t=this;\r
+               _t._mcu=i_mcu;\r
+               _t._lc=CLASS;\r
+               if(MI.isGenerator(i_handler)){_t._gen=i_handler;}\r
+               else if(i_handler){_t._event=i_handler}\r
+               function cb(j)\r
+               {\r
+                       _t._oid=j.result[0];\r
+                       if(_t._event.onNew){_t._event.onNew();}\r
+                       if(_t._gen){_t._gen.next(_t);}\r
+                       _t._lc=null;\r
+               }\r
+               MI.assertInt(i_params);         \r
+               return _t._mcu.rpc(_t.RPC_NS+":_new1",i_params,cb);\r
+       }catch(e){\r
+               throw new MI.MiMicException(e);\r
+       }       \r
 }\r
 CLASS.prototype=\r
 {\r
@@ -72,9 +77,14 @@ CLASS.prototype=
         * Generatorモードのときに使用する関数です。\r
         * Generatorモードの時は、yieldと併用してnew AnalogIn()の完了を待ちます。\r
         */\r
-       waitForNew:function AnalogIn_waitForNew(){\r
-               if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);}\r
-               this._lc=CLASS.waitForNew;\r
+       waitForNew:function AnalogIn_waitForNew()\r
+       {\r
+               try{\r
+                       if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);}\r
+                       this._lc=CLASS.waitForNew;\r
+               }catch(e){\r
+                       throw new MI.MiMicException(e);\r
+               }\r
        },\r
        /**\r
         * @name mbedJS.AnalogIn#read\r
@@ -88,43 +98,51 @@ CLASS.prototype=
         */\r
        read:function AnalogIn_read()\r
        {\r
-               var _t=this;\r
-               if(this._gen && this._lc){throw new MI.MiMicException(MI.Error.NG_YIELD_NOT_COMPLETED);}\r
-               _t._lc=CLASS.read;\r
-               return _t._mcu.rpc(_t.RPC_NS+":read_fx",_t._oid,\r
-               function (j)\r
-               {\r
-                       var v=j.result[0]/10000;\r
-                       if(_t._event.onRead){_t._event.onRead(v);}\r
-                       if(_t._gen){_t._gen.next(v);}\r
-                        _t._lc=null;\r
-               }\r
-               );\r
+               try{\r
+                       var _t=this;\r
+                       if(this._gen && this._lc){throw new MI.MiMicException(MI.Error.NG_YIELD_NOT_COMPLETED);}\r
+                       _t._lc=CLASS.read;\r
+                       return _t._mcu.rpc(_t.RPC_NS+":read_fx",_t._oid,\r
+                       function (j)\r
+                       {\r
+                               var v=j.result[0]/10000;\r
+                               if(_t._event.onRead){_t._event.onRead(v);}\r
+                               if(_t._gen){_t._gen.next(v);}\r
+                                _t._lc=null;\r
+                       }\r
+                       );\r
+               }catch(e){\r
+                       throw new MI.MiMicException(e);\r
+               }                       \r
        },\r
        /**\r
         * @name mbedJS.AnalogIn#read_u16\r
         * @function\r
         * ピンから値を読み込みます。\r
-        * 関数の完了時にonReadイベントが発生します。\r
+        * 関数の完了時にonRead_u16イベントが発生します。\r
         * Generatorモードの時は、yieldと併用して完了を待機できます。\r
         * @return {int|int}\r
         * <p>Callbackモードの時はRPCメソッドのインデクスを返します。</p>\r
         * <p>Generatorモードの時はピンの値を返します。</p>\r
         */\r
-       read_u16:function AnalogIn_read_u16(i_value)\r
+       read_u16:function AnalogIn_read_u16()\r
        {\r
-               var _t=this;\r
-               if(this._gen && this._lc){throw new MI.MiMicException(MI.Error.NG_YIELD_NOT_COMPLETED);}\r
-               _t._lc=CLASS.read_u16;\r
-               return _t._mcu.rpc(_t.RPC_NS+":read_u16",_t._oid,\r
-               function (j)\r
-               {\r
-                       var v=j.result[0];\r
-                       if(_t._event.onRead_u16){_t._event.onRead_u16(v);}\r
-                       if(_t._gen){_t._gen.next(v);}\r
-                        _t._lc=null;\r
-               }\r
-               );\r
+               try{\r
+                       var _t=this;\r
+                       if(this._gen && this._lc){throw new MI.MiMicException(MI.Error.NG_YIELD_NOT_COMPLETED);}\r
+                       _t._lc=CLASS.read_u16;\r
+                       return _t._mcu.rpc(_t.RPC_NS+":read_u16",_t._oid,\r
+                       function (j)\r
+                       {\r
+                               var v=j.result[0];\r
+                               if(_t._event.onRead_u16){_t._event.onRead_u16(v);}\r
+                               if(_t._gen){_t._gen.next(v);}\r
+                                _t._lc=null;\r
+                       }\r
+                       );\r
+               }catch(e){\r
+                       throw new MI.MiMicException(e);\r
+               }                       \r
        }       \r
 }\r
 NS.AnalogIn=CLASS;\r