123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785 |
- var UseActiveX = 1;
- var USEIVS = 1;
- var TVS_VERSION = ((parseInt(readSetupByKey("SYS_BOARDID")) & 0xF000) == 0xD000 || (parseInt(readSetupByKey("SYS_BOARDID")) & 0xF000) == 0xE000) ? '1,6,57,124' : '1,6,57,118';
- var TN_CS_CONNECTED = 0x00000001;
- var TN_CS_STREAMED = 0x00000002;
- var TN_CS_DECODED = 0x00000004;
- var TN_CS_DISPLAYED = 0x00000008;
- var TN_CS_RECORDED = 0x00000010;
- var TN_SNC_CN_SERVER_UNREACHABLE = 10;
- var TN_SNC_CN_TOO_MANY_CONNECTION = 11;
- var TN_SNC_CN_PASSWORD_MISMATCH = 12;
- var TN_SNC_CN_CONNECTION_DISABLED = 13;
- var TN_SNC_CN_ID_NOT_EXIST = 14;
- var TN_SNC_CN_DOMAINNAME_UNKNOWN = 15;
- var TN_SNC_CN_PARAMETER_OUTOFRANGE = 16;
- var TN_SNC_CN_DUPLICATE_CONNECT = 17;
- var TN_SNC_CN_KEEPALIVE_FAILED = 18;
- var TN_SNC_CN_NO_AUTHORITY_OPERATION = 19;
- var TN_SNC_CN_OPERATION_FAILED = 20;
- var TN_ET_DI = 0;
- var TN_ET_VIDEOLOSS = 1;
- var TN_ET_MOTION = 2;
- var TN_ET_DO = 4;
- var TN_ET_RECORD = 5;
- var TN_ET_RESOLUTION = 6;
- var TN_ES_OFF = 0;
- var TN_ES_ON = 1;
- var TN_ET_OFF = 0;
- var TN_ET_SET = 1;
- var TN_ET_ERASE = 2;
- var TN_ET_APPLY = 3;
- var TN_ET_ERASEALL = 4;
- var TN_ET_SETALL = 5;
- var TN_MVD_PAUSE = 0;
- var TN_MVD_KEYFRAME = 1;
- var TN_MVD_LIVE = 2;
- var g_lChID = 0;
- var g_display = null;
- var g_lOsdID_VL = -1;
- var g_lOsdsysID = -1;
- var g_lOsdsysTime = -1;
- var g_ivs = null;
- const SUPPORT_DETECTION_CAM_4CH = 1;
- const NOT_SUPPORT_DETECTION_CAM_4CH = 0 ;
- var g_detection_4ch_support = NOT_SUPPORT_DETECTION_CAM_4CH;
- var g_detection_4ch_IDs = [0,0,0,0] ;
- var g_detection_4ch_Displays = [null ,null ,null ,null ];
- function tvs_init_detection_4ch(index , server_addr , port, id, password)
- {
- var max_resolution = parseInt(readSetupByKey("VID_TVS_DISPLAY_RES"));
-
- if(UseActiveX == 1){
- var agt = navigator.userAgent.toLowerCase();
- if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
- }
-
- if (UseActiveX == 1) {
- tvs_connect_detection_4ch(server_addr, port, id, password, index, max_resolution);
- }
- else{
- // setTimeout(function() { tvs_connect(server_addr, ori_port, id, password, sub, max_resolution); }, 0);
- }
- }
- function tvs_init(server_addr, port, id, password, sub)
- {
- var http_port = parseInt(readSetupByKey("NET_HTTPPORT"));
- var max_resolution = parseInt(readSetupByKey("VID_TVS_DISPLAY_RES"));
- var url = document.URL;
- var change_url;
- var change_port;
- var ori_port;
-
- if(UseActiveX == 1){
- var agt = navigator.userAgent.toLowerCase();
- if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
- }
- ori_port = port;
- change_url = url.split(":");
- if(typeof change_url[2] != "undefined")
- {
- change_port = change_url[2].split("/");
- if( typeof change_port[0] != "undefined")
- {
- if(parseInt(change_port[0]) >= parseInt(59000) && parseInt(change_port[0]) <= parseInt(59255))
- {
- if(http_port != change_port[0])
- {
- ori_port = parseInt(change_port[0]) - parseInt(1000);
- }
- }
- }
- }
-
- if(UseActiveX == 1){
- g_display = document.Tvs.GetDisplay();
- if(USEIVS == 1){
- g_ivs = document.Tvs.GetIVSControl();
- }
- }
- if (UseActiveX == 1) {
- tvs_connect(server_addr, ori_port, id, password, sub, max_resolution);
- }
- else{
- setTimeout(function() { tvs_connect(server_addr, ori_port, id, password, sub, max_resolution); }, 0);
- }
- }
- /*
- * max_resolution (tvs activeX object width/height)
- * 2 : 2056x1536
- * 5 : 1944x2592
- * 6 : 4096x3000
- * else : 800x600
- */
- function tvs_init2(server_addr, port, id, password, sub, max_resolution)
- {
- var http_port = parseInt(readSetupByKey("NET_HTTPPORT"));
- var url = document.URL;
- var change_url;
- var change_port;
- var ori_port;
-
- if(UseActiveX == 1){
- var agt = navigator.userAgent.toLowerCase();
- if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
- }
- ori_port = port;
- change_url = url.split(":");
- if(typeof change_url[2] != "undefined")
- {
- change_port = change_url[2].split("/");
- if( typeof change_port[0] != "undefined")
- {
- if(parseInt(change_port[0]) >= parseInt(59000) && parseInt(change_port[0]) <= parseInt(59255))
- {
- if(http_port != change_port[0])
- {
- ori_port = parseInt(change_port[0]) - parseInt(1000);
- }
- }
- }
- }
-
- if(UseActiveX == 1){
- g_display = document.Tvs.GetDisplay();
- if(USEIVS == 1){
- g_ivs = document.Tvs.GetIVSControl();
- }
- }
- if (UseActiveX == 1) {
- tvs_connect(server_addr, ori_port, id, password, sub, max_resolution);
- }
- else{
- setTimeout(function() { tvs_connect(server_addr, ori_port, id, password, sub, max_resolution); }, 0);
- }
- }
- function tvs_init_playback(server_addr, port, id, password, time)
- {
- var max_resolution = parseInt(readSetupByKey("VID_TVS_DISPLAY_RES"));
- var url = document.URL;
-
- if(UseActiveX == 1){
- var agt = navigator.userAgent.toLowerCase();
- if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
- }
- if(UseActiveX == 1){
- g_display = document.Tvs.GetDisplay();
- if(USEIVS == 1){
- g_ivs = document.Tvs.GetIVSControl();
- }
- }
-
- if (UseActiveX == 1) {
- tvs_connect_playback(server_addr, port, id, password, time, max_resolution);
- }
- else{
- setTimeout(function() { tvs_connect_playback(server_addr, port, id, password, time, max_resolution); }, 0);
- }
- }
- function tvs_term(sub)
- {
- if(UseActiveX == 1){
- var agt = navigator.userAgent.toLowerCase();
- if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
- }
- tvs_discon(sub);
- }
- function tvs_connect_detection_4ch(server_addr, port, id, password, index, max_resolution)
- {
- var disable_vsnm = parseInt(readSetupByKey("SYS_DISABLE_VSNM"));
- var uri_str = 'vsnm://';
-
- if(g_detection_4ch_IDs[index] > 0) {
- tvs_discon_detection_4ch(index);
- return ;
- }
- if(disable_vsnm == 1){
- if(document.URL.indexOf("https://") == -1){
- uri_str = 'rtsp://';
- port = parseInt(readSetupByKey("NET_RTSPPORT"));
- }
- else{
- uri_str = 'https://';
- port = parseInt(readSetupByKey("NET_HTTPSPORT"));
- }
- }
-
- if(index == 0){
- sAddress = uri_str + server_addr + ':' + port + '/video1';
- }
- else if(index == 1){
- sAddress = uri_str + server_addr + ':' + port + '/video2';
- }
- else if(index == 2){
- sAddress = uri_str + server_addr + ':' + port + '/video3';
- }
- else if(index == 3){
- sAddress = uri_str + server_addr + ':' + port + '/video4';
- }
- else if(index == 8){
- if (disable_vsnm == 1) {
- sAddress = uri_str + server_addr + ':' + port + '/quad';
- } else {
- sAddress = uri_str + server_addr + ':' + port + '/video5';
- }
- }
- else{
- sAddress = uri_str + server_addr + ':' + port + '/video1';
- }
- console.log("index : " + index + ", address : " + sAddress);
-
- if(0 == index) {
- document.Tvs4_0.SetLocalConfig(3,max_resolution);
- document.Tvs4_0.SetLocalConfig(9, -1); // Autoplay on
- document.Tvs4_0.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
-
- g_detection_4ch_IDs[index] = document.Tvs4_0.Connect(sAddress, id, password);
-
- document.Tvs4_0.SetMute(g_detection_4ch_IDs[index], 0);
- document.Tvs4_0.SetAutoReconnect(g_detection_4ch_IDs[index], -1);
- document.Tvs4_0.SetPTZControlSpeed(g_detection_4ch_IDs[index], 0, -1);
- document.Tvs4_0.SetPTZControlSpeed(g_detection_4ch_IDs[index], 1, -1);
- document.Tvs4_0.SetPTZControlSpeed(g_detection_4ch_IDs[index], 2, -1);
-
- g_detection_4ch_Displays[0] = document.Tvs4_0.GetDisplay();
- }
- else if(1 == index) {
- document.Tvs4_1.SetLocalConfig(3,max_resolution);
- document.Tvs4_1.SetLocalConfig(9, -1); // Autoplay on
- document.Tvs4_1.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
-
- g_detection_4ch_IDs[index] = document.Tvs4_1.Connect(sAddress, id, password);
-
- document.Tvs4_1.SetMute(g_detection_4ch_IDs[index], 0);
- document.Tvs4_1.SetAutoReconnect(g_detection_4ch_IDs[index], -1);
- document.Tvs4_1.SetPTZControlSpeed(g_detection_4ch_IDs[index], 0, -1);
- document.Tvs4_1.SetPTZControlSpeed(g_detection_4ch_IDs[index], 1, -1);
- document.Tvs4_1.SetPTZControlSpeed(g_detection_4ch_IDs[index], 2, -1);
- g_detection_4ch_Displays[1] = document.Tvs4_1.GetDisplay();
- }
- else if(2 == index) {
- document.Tvs4_2.SetLocalConfig(3,max_resolution);
- document.Tvs4_2.SetLocalConfig(9, -1); // Autoplay on
- document.Tvs4_2.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
-
- g_detection_4ch_IDs[index] = document.Tvs4_2.Connect(sAddress, id, password);
-
- document.Tvs4_2.SetMute(g_detection_4ch_IDs[index], 0);
- document.Tvs4_2.SetAutoReconnect(g_detection_4ch_IDs[index], -1);
- document.Tvs4_2.SetPTZControlSpeed(g_detection_4ch_IDs[index], 0, -1);
- document.Tvs4_2.SetPTZControlSpeed(g_detection_4ch_IDs[index], 1, -1);
- document.Tvs4_2.SetPTZControlSpeed(g_detection_4ch_IDs[index], 2, -1);
- g_detection_4ch_Displays[2] = document.Tvs4_2.GetDisplay();
- }
- else {
- document.Tvs4_3.SetLocalConfig(3,max_resolution);
- document.Tvs4_3.SetLocalConfig(9, -1); // Autoplay on
- document.Tvs4_3.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
-
- g_detection_4ch_IDs[index] = document.Tvs4_3.Connect(sAddress, id, password);
-
- document.Tvs4_3.SetMute(g_detection_4ch_IDs[index], 0);
- document.Tvs4_3.SetAutoReconnect(g_detection_4ch_IDs[index], -1);
- document.Tvs4_3.SetPTZControlSpeed(g_detection_4ch_IDs[index], 0, -1);
- document.Tvs4_3.SetPTZControlSpeed(g_detection_4ch_IDs[index], 1, -1);
- document.Tvs4_3.SetPTZControlSpeed(g_detection_4ch_IDs[index], 2, -1);
- g_detection_4ch_Displays[3] = document.Tvs4_3.GetDisplay();
- }
- }
- function tvs_connect(server_addr, port, id, password, sub, max_resolution)
- {
- var disable_vsnm = parseInt(readSetupByKey("SYS_DISABLE_VSNM"));
- var uri_str = 'vsnm://';
-
- if (g_lChID > 0)
- {
- tvs_discon(0);
- return;
- }
- if(disable_vsnm == 1){
- if(document.URL.indexOf("https://") == -1){
- uri_str = 'rtsp://';
- port = parseInt(readSetupByKey("NET_RTSPPORT"));
- }
- else{
- uri_str = 'https://';
- port = parseInt(readSetupByKey("NET_HTTPSPORT"));
- }
- }
-
- if($("[name=SYS_BOARDID]").val() == 0x1003 || $("[name=SYS_BOARDID]").val() == 0x1007){
- if(sub == 0){
- sAddress = uri_str + server_addr + ':' + port + '/video1+audio1';
- }
- else if(sub == 1){
- sAddress = uri_str + server_addr + ':' + port + '/video2';
- }
- else if(sub == 2){
- sAddress = uri_str + server_addr + ':' + port + '/video3';
- }
- else if(sub == 3){
- sAddress = uri_str + server_addr + ':' + port + '/video4';
- }
- else if(sub == 4){
- sAddress = uri_str + server_addr + ':' + port + '/video1s+audio1';
- }
- else if(sub == 5){
- sAddress = uri_str + server_addr + ':' + port + '/video2s';
- }
- else if(sub == 6){
- sAddress = uri_str + server_addr + ':' + port + '/video3s';
- }
- else if(sub == 7){
- sAddress = uri_str + server_addr + ':' + port + '/video4s';
- }
- else if(sub == 8){
- if (disable_vsnm == 1) {
- sAddress = uri_str + server_addr + ':' + port + '/quad';
- } else {
- sAddress = uri_str + server_addr + ':' + port + '/video5';
- }
- }
- }
- else if($("[name=SYS_BOARDID]").val() == 0xB001){ // A400 (4Ch + Quad Channel)
- if(sub == 0){
- sAddress = uri_str + server_addr + ':' + port + '/video1';
- }
- else if(sub == 1){
- sAddress = uri_str + server_addr + ':' + port + '/video2';
- }
- else if(sub == 2){
- sAddress = uri_str + server_addr + ':' + port + '/video3';
- }
- else if(sub == 3){
- sAddress = uri_str + server_addr + ':' + port + '/video4';
- }
- else if(sub == 4){
- sAddress = uri_str + server_addr + ':' + port + '/video1s';
- }
- else if(sub == 5){
- sAddress = uri_str + server_addr + ':' + port + '/video2s';
- }
- else if(sub == 6){
- sAddress = uri_str + server_addr + ':' + port + '/video3s';
- }
- else if(sub == 7){
- sAddress = uri_str + server_addr + ':' + port + '/video4s';
- }
- else if(sub == 8){
- if (disable_vsnm == 1) {
- sAddress = uri_str + server_addr + ':' + port + '/quad';
- } else {
- sAddress = uri_str + server_addr + ':' + port + '/video5';
- }
- }
- else if(sub == 9){
- if (disable_vsnm == 1) {
- sAddress = uri_str + server_addr + ':' + port + '/quads';
- } else {
- sAddress = uri_str + server_addr + ':' + port + '/video5s';
- }
- }
- else{
- sAddress = uri_str + server_addr + ':' + port + '/video1';
- }
- console.log("sub : " + sub + ", address : " + sAddress);
- }
- else{
- if(sub == 0){
- sAddress = uri_str + server_addr + ':' + port + '/video1+audio1';
- }
- else if(sub == 1){
- sAddress = uri_str + server_addr + ':' + port + '/video1s+audio1';
- }
- else if(sub == 2){
- sAddress = uri_str + server_addr + ':' + port + '/video1s2+audio1';
- }
- else if(sub == 3){
- sAddress = uri_str + server_addr + ':' + port + '/video1s3+audio1';
- }
- else{
- sAddress = uri_str + server_addr + ':' + port + '/video1+audio1';
- }
- }
- document.Tvs.SetLocalConfig(3,max_resolution);
- document.Tvs.SetLocalConfig(9, -1); // Autoplay on
- document.Tvs.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
- g_lChID = document.Tvs.Connect(sAddress, id, password);
- // if (!document.Tvs.Play(g_lChID))
- // {
- // return;
- // }
- document.Tvs.SetMute(g_lChID, 0);
- document.Tvs.SetAutoReconnect(g_lChID, -1);
- document.Tvs.SetPTZControlSpeed(g_lChID, 0, -1);
- document.Tvs.SetPTZControlSpeed(g_lChID, 1, -1);
- document.Tvs.SetPTZControlSpeed(g_lChID, 2, -1);
- // document.Tvs.DecodingOption(2) = 0;
- }
- function tvs_connect_playback(server_addr, port, id, password, time, max_resolution)
- {
- if (g_lChID > 0)
- {
- tvs_discon(0);
- return;
- }
- if($("[name=SYS_BOARDID]").val() == 0x1003 || $("[name=SYS_BOARDID]").val() == 0x1007){
- return;
- }
- else{
- sAddress = 'rtsp://' + server_addr + ':' + port + '/playback_' + time;
- }
- document.Tvs.SetLocalConfig(3,max_resolution);
- document.Tvs.SetLocalConfig(9, -1); // Autoplay on
- document.Tvs.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
- g_lChID = document.Tvs.Connect(sAddress, id, password);
- document.Tvs.SetMute(g_lChID, 0);
- document.Tvs.SetAutoReconnect(g_lChID, -1);
- }
- function tvs_SetBuffer_DirectionCam(buffer)
- {
- if(UseActiveX == 1){
- var agt = navigator.userAgent.toLowerCase();
- if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
- }
- if(buffer <= 0){
- if(SUPPORT_DETECTION_CAM_4CH == g_detection_4ch_support) {
- document.Tvs4_0.SetLocalConfig(7, 1); // Buffer
- document.Tvs4_1.SetLocalConfig(7, 1); // Buffer
- document.Tvs4_2.SetLocalConfig(7, 1); // Buffer
- document.Tvs4_3.SetLocalConfig(7, 1); // Buffer
- }
- }
- else if(buffer >= 90){
- if(SUPPORT_DETECTION_CAM_4CH == g_detection_4ch_support) {
- document.Tvs4_0.SetLocalConfig(7, 30); // Buffer
- document.Tvs4_1.SetLocalConfig(7, 30); // Buffer
- document.Tvs4_2.SetLocalConfig(7, 30); // Buffer
- document.Tvs4_3.SetLocalConfig(7, 30); // Buffer
- }
- }
- else{
- if(SUPPORT_DETECTION_CAM_4CH == g_detection_4ch_support) {
- document.Tvs4_0.SetLocalConfig(7, buffer/3); // Buffer
- document.Tvs4_1.SetLocalConfig(7, buffer/3); // Buffer
- document.Tvs4_2.SetLocalConfig(7, buffer/3); // Buffer
- document.Tvs4_3.SetLocalConfig(7, buffer/3); // Buffer
- }
- }
- }
- function tvs_SetBuffer(buffer)
- {
- if(UseActiveX == 1){
- var agt = navigator.userAgent.toLowerCase();
- if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
- }
- if(buffer <= 0){
- document.Tvs.SetLocalConfig(7, 1); // Buffer
- }
- else if(buffer >= 90){
- document.Tvs.SetLocalConfig(7, 30); // Buffer
- }
- else{
- document.Tvs.SetLocalConfig(7, buffer/3); // Buffer
- }
- }
- var g_lSession;
- function tvs_recstart(path)
- {
- g_lSession = document.Tvs.StartFileRecord(g_lChID, 1, path);
- if(g_lSession != 0){
- if(g_lSession == -2147024773){
- alert(GetLan(641));
- }
- else if(g_lSession == -2147024893){
- alert(GetLan(642));
- }
- else if(g_lSession == -2147024891){
- alert(GetLan(643));
- }
- else {
- alert(GetLan(644));
- }
- return -1;
- // alert('tvs_recstart' + g_lSession);
- }
- else{
- return 0;
- // alert('ok');
- }
- }
- function tvs_recstop()
- {
- document.Tvs.StopFileRecord(g_lChID);
- }
- function tvs_digitalzoom(ratio, nx, ny)
- {
- if (g_lChID > 0){
- if(UseActiveX == 1){
- g_display.SetDigitalZoom(g_lChID, ratio, nx, ny);
- }
- else{
- document.Tvs.SetDigitalZoom(g_lChID, ratio, nx, ny);
- }
- }
- }
- function tvs_setnewosd(sysid, time, position, idstr, width, height)
- {
- var x, y, w, h, f;
- if(sysid == 1){
- if(g_lOsdsysID >= 0){
- if(UseActiveX == 1){
- g_display.RemoveOsdArea(g_lOsdsysID);
- }
- else{
- document.Tvs.RemoveOsdArea(0);
- }
- g_lOsdsysID = -1;
- }
- x = width/60 *2;
- w = x + (width/3*2);
-
- if(position == 0){
- y = height - height/24 - height/12; // bottom
- }
- else{
- y = height/24; // top
- }
- h = y + height/12+4;
- f = width/36;
-
- if(UseActiveX == 1){
- g_lOsdsysID = g_display.AddOsdArea(g_lChID, x, y, w, h, 0);
- g_display.SetOsdFontSize(g_lOsdsysID, f);
- g_display.UpdateOsdArea(g_lOsdsysID, idstr);
- }
- else{
- g_lOsdsysID = 0;
- document.Tvs.UpdateOsdArea(g_lChID, 0, x, y, w, h, f, idstr, 0);
- }
- }
-
- if(time == 1){
- if(g_lOsdsysTime >= 0){
- if(UseActiveX == 1){
- g_display.RemoveOsdArea(g_lOsdsysTime);
- }
- else{
- document.Tvs.RemoveOsdArea(1);
- }
- g_lOsdsysTime = -1;
- }
-
- x = width - (width/60 *2) - (width/6) - 20;
- w = x + (width/3);
-
- if(position == 0){
- y = height - height/24 - height/12; // bottom
- }
- else{
- y = height/24; // top
- }
- h = y + height/12+4;
- f = width/36;
-
- if(UseActiveX == 1){
- g_lOsdsysTime = g_display.AddOsdArea(g_lChID, x, y, w, h, 0);
- g_display.SetOsdFontSize(g_lOsdsysTime, f);
- g_display.UpdateOsdArea(g_lOsdsysTime, '%SERVERTIME%');
- }
- else{
- g_lOsdsysTime = 1;
- document.Tvs.UpdateOsdArea(g_lChID, 1, x, y, w, h, f, '%SERVERTIME%', 0);
- }
- }
- }
- function tvs_setvideolossosd(x, y, w, h)
- {
- if(UseActiveX == 1){
- g_lOsdID_VL = g_display.AddOsdArea(g_lChID, x, y, w, h, 0);
- g_display.SetOsdFontSize(g_lOsdID_VL, 20);
- g_display.UpdateOsdArea(g_lOsdID_VL, 'Video Loss');
- }
- else{
- g_lOsdID_VL = 2;
- document.Tvs.UpdateOsdArea(g_lChID, 2, x, y, w, h, 20, 'Video Loss', 0);
- }
- }
- function tvs_clrvideolossosd()
- {
- if (g_lOsdID_VL >= 0)
- {
- if(UseActiveX == 1){
- g_display.RemoveOsdArea(g_lOsdID_VL);
- }
- else{
- document.Tvs.RemoveOsdArea(2);
- }
- g_lOsdID_VL = -1;
- }
- }
- function pause(msec) {
- var now = new Date();
- var exitTime = now.getTime() + (msec);
- while (true) {
- now = new Date();
- if (now.getTime() > exitTime) return;
- }
- }
- function tvs_discon_detection_4ch(index)
- {
- if(SUPPORT_DETECTION_CAM_4CH == g_detection_4ch_support) {
- if(index >= 0 && index < 4 ) {
- if(0 == index) {
- document.Tvs4_0.Pause(g_detection_4ch_IDs[index]);
- document.Tvs4_0.SetMute(g_detection_4ch_IDs[index], 1);
- document.Tvs4_0.Disconnect(g_detection_4ch_IDs[index]);
- g_detection_4ch_IDs[index] = 0;
- }
- else if(1 == index) {
- document.Tvs4_1.Pause(g_detection_4ch_IDs[index]);
- document.Tvs4_1.SetMute(g_detection_4ch_IDs[index], 1);
- document.Tvs4_1.Disconnect(g_detection_4ch_IDs[index]);
- g_detection_4ch_IDs[index] = 0;
- }
- else if(2 == index) {
- document.Tvs4_2.Pause(g_detection_4ch_IDs[index]);
- document.Tvs4_2.SetMute(g_detection_4ch_IDs[index], 1);
- document.Tvs4_2.Disconnect(g_detection_4ch_IDs[index]);
- g_detection_4ch_IDs[index] = 0;
- }
- else {
- document.Tvs4_3.Pause(g_detection_4ch_IDs[index]);
- document.Tvs4_3.SetMute(g_detection_4ch_IDs[index], 1);
- document.Tvs4_3.Disconnect(g_detection_4ch_IDs[index]);
- g_detection_4ch_IDs[index] = 0;
- }
- }
- // alert('disconnect ' + index );
- pause(500);
- }
- }
- function tvs_discon(sub)
- {
- if (g_lChID == 0)
- {
- return;
- }
- document.Tvs.Pause(g_lChID);
- document.Tvs.SetMute(g_lChID, 1);
- document.Tvs.Disconnect(g_lChID);
- g_lChID = 0;
- // alert('connected');
- pause(500);
- }
- /*
- function tvs_on_ChannelNotify(lChID, eNewState, eReason)
- {
- // alert('tvs_on_ChannelNofy');
- if (eNewState & TN_CS_CONNECTED)
- {
- // alert('connected');
- }
- else
- {
- // alert('disconnected(reason=' + eReason + ')');
- if (eReason >= TN_SNC_CN_SERVER_UNREACHABLE)
- {
- switch (eReason)
- {
- case TN_SNC_CN_SERVER_UNREACHABLE:
- // alert('Server is unreachable for connection');
- break;
- case TN_SNC_CN_TOO_MANY_CONNECTION:
- // alert('Too many connections on the server');
- break;
- case TN_SNC_CN_PASSWORD_MISMATCH:
- // alert('Password is incorrect');
- break;
- case TN_SNC_CN_CONNECTION_DISABLED:
- // alert('Server disabled the connection');
- break;
- case TN_SNC_CN_ID_NOT_EXIST:
- // alert('Login ID does not exist');
- break;
- case TN_SNC_CN_DOMAINNAME_UNKNOWN:
- // alert('Can not resolve the domain name');
- break;
- case TN_SNC_CN_PARAMETER_OUTOFRANGE:
- // alert('Invalid channels is one of this case');
- break;
- case TN_SNC_CN_DUPLICATE_CONNECT:
- // alert('Multiple connections to a channel are not allowed');
- break;
- case TN_SNC_CN_KEEPALIVE_FAILED:
- // alert('Disconnected due to keep alive timeout');
- break;
- case TN_SNC_CN_NO_AUTHORITY_OPERATION:
- // alert('No authority operation');
- break;
- case TN_SNC_CN_OPERATION_FAILED:
- // alert('General failure');
- break;
- }
- }
- }
- }
- function tvs_on_MouseEvent(lChID, lMsg, wParam, lParam)
- {
- }
- function tvs_on_ServerEvent(lChID, eEventType, nIndex, eEventStatus, vData, motion_img, record_img)
- {
- switch (eEventType)
- {
- case TN_ET_MOTION:
- if (eEventStatus)
- {
- document[motion_img].src = '/image/motion.jpg';
- }
- else
- {
- document[motion_img].src = '/image/null.jpg';
- }
- break;
- case TN_ET_RECORD:
- if (eEventStatus == 1)
- {
- document[record_img].src = '/image/rec_on.jpg';
- }
- else if (eEventStatus == -1)
- {
- document[record_img].src = '/image/rec_err.jpg';
- }
- else
- {
- document[record_img].src = '/image/null.jpg';
- }
- break;
- case TN_ET_VIDEOLOSS:
- if (eEventStatus)
- {
- // alert('Video Loss(1)');
- if (g_lOsdID_VL >= 0)
- {
- g_display.RemoveOsdArea(g_lOsdID_VL);
- g_lOsdID_VL = -1;
- }
- }
- else
- {
- // alert('Video Loss(0)');
- var rcVL = new Array(document.Tvs.width / 2 - 60, document.Tvs.height / 2 - 30, document.Tvs.width / 2 + 80, document.Tvs.height / 2 + 30);
-
- g_lOsdID_VL = g_display.AddOsdArea(g_lChID, rcVL[0], rcVL[1], rcVL[2], rcVL[3], 0);
- g_display.SetOsdFontSize(g_lOsdID_VL, 20);
- g_display.UpdateOsdArea(g_lOsdID_VL, 'Video Loss');
- }
- break;
- }
- }
- function tvs_ResetVLossOSD()
- {
- if (g_lOsdID_VL >= 0)
- {
- var rcVL = new Array(document.Tvs.width / 2 - 60, document.Tvs.height / 2 - 30, document.Tvs.width / 2 + 80, document.Tvs.height / 2 + 30);
- g_display.RemoveOsdArea(g_lOsdID_VL);
- g_lOsdID_VL = g_display.AddOsdArea(g_lChID, rcVL[0], rcVL[1], rcVL[2], rcVL[3], 0);
- g_display.SetOsdFontSize(g_lOsdID_VL, 20);
- g_display.UpdateOsdArea(g_lOsdID_VL, 'Video Loss');
- }
-
- }
- function tvs_on_ServerEventVLoss(lChID, eEventType, nIndex, eEventStatus, vData)
- {
- switch (eEventType)
- {
- case TN_ET_VIDEOLOSS:
- if (eEventStatus)
- {
- // alert('Video Loss1 - 1');
- if (g_lOsdID_VL >= 0)
- {
- g_display.RemoveOsdArea(g_lOsdID_VL);
- g_lOsdID_VL = -1;
- }
- }
- else
- {
- // alert('Video Loss0 - 1');
- var rcVL = new Array(document.Tvs.width / 2 - 60, document.Tvs.height / 2 - 30, document.Tvs.width / 2 + 80, document.Tvs.height / 2 + 30);
-
- g_lOsdID_VL = g_display.AddOsdArea(g_lChID, rcVL[0], rcVL[1], rcVL[2], rcVL[3], 0);
- g_display.SetOsdFontSize(g_lOsdID_VL, 20);
- g_display.UpdateOsdArea(g_lOsdID_VL, 'Video Loss');
- }
- break;
- }
- }
- function tvs_on_ServerEventVideo(lChID, eEventType, nIndex, eEventStatus, vData, vmotion_img)
- {
- switch (eEventType)
- {
- case TN_ET_MOTION:
- if (eEventStatus)
- {
- document[vmotion_img].src = '/image/motion.jpg';
- }
- else
- {
- document[vmotion_img].src = '/image/null.jpg';
- }
- break;
- }
- }
- function tvs_on_ServerEventView(lChID, eEventType, nIndex, eEventStatus, vData, sensor_img, alarm_img, sensor2_img, alarm2_img, sensor3_img, sensor4_img)
- {
- }
- function tvs_on_SystemNotify(lNotifyCode, vData)
- {
- }
- */
- function tvs_snapshot(fileName)
- {
- if (g_lChID == 0) return;
- // document.Tvs.Snapshot(g_lChID, true);
- document.Tvs.Snapshot(g_lChID, 0, false); // 0 = bmp, 1=jpg
- // document.Tvs.Snapshot(g_lChID, false); // 0 = bmp, 1=jpg
- document.Tvs.PreviewSnapshot(g_lChID);
- }
- function tvs_setDO(index, value)
- {
- if (g_lChID == 0) return;
- document.Tvs.SetDO(g_lChID, index, value);
- }
- function tvs_enable_talk(enable)
- {
- if (g_lChID == 0) return;
- if (enable)
- {
- document.Tvs.StartTalking(g_lChID);
- }
- else
- {
- document.Tvs.StopTalking(g_lChID);
- }
- }
- function tvs_set_motion_region_edit(set)
- {
- if (g_lChID == 0) return;
- document.Tvs.SetMotionRegionEdit(g_lChID, set, TN_MVD_KEYFRAME);
- }
- function tvs_set_motion_region_edit2(set,region)
- {
- if (g_lChID == 0) return;
- document.Tvs.SetMotionRegionEdit2(g_lChID, region,set,TN_MVD_LIVE);
- }
- function tvs_set_motion_region_edit2_detection_cam(channel,set,region)
- {
- if(channel >= 0 && channel < 4) {
- if(0 == g_detection_4ch_IDs[channel]) {
- return ;
- }
- if(0 == channel) {
- document.Tvs4_0.SetMotionRegionEdit2(g_detection_4ch_IDs[channel], region,set,TN_MVD_LIVE);
- }
- else if(1 == channel) {
- document.Tvs4_1.SetMotionRegionEdit2(g_detection_4ch_IDs[channel], region,set,TN_MVD_LIVE);
- }
- else if(2 == channel) {
- document.Tvs4_2.SetMotionRegionEdit2(g_detection_4ch_IDs[channel], region,set,TN_MVD_LIVE);
- }
- else {
- document.Tvs4_3.SetMotionRegionEdit2(g_detection_4ch_IDs[channel], region,set,TN_MVD_LIVE);
- }
- }
-
-
- }
- function tvs_set_scale_enable(mode,id)
- {
- if (g_lChID == 0) return;
- document.Tvs.SetScaleEnable(g_lChID, mode,id);
- }
- function tvs_set_scale_edit(id,x,y,w,h)
- {
- if (g_lChID == 0) return;
- document.Tvs.SetScaleEdit(g_lChID, id,x,y,w,h);
- }
- function tvs_get_scale_x(id)
- {
- if (g_lChID == 0) return 0;
- return document.Tvs.GetScaleX(g_lChID, id);
- }
- function tvs_get_scale_y(id)
- {
- if (g_lChID == 0) return 0;
- return document.Tvs.GetScaleY(g_lChID, id);
- }
- function tvs_get_scale_w(id)
- {
- if (g_lChID == 0) return 255;
- return document.Tvs.GetScaleWidth(g_lChID, id);
- }
- function tvs_get_scale_h(id)
- {
- if (g_lChID == 0) return 255;
- return document.Tvs.GetScaleheight(g_lChID, id);
- }
- function tvs_set_privacy_mask_region_edit(set,region)
- {
- if (g_lChID == 0) return;
- document.Tvs.SetPrivacyRegionEdit(g_lChID, region,set,TN_MVD_LIVE);
- }
- function tvs_set_privacy_mask_region_edit3(set,region)
- {
- if (g_lChID == 0) return;
- document.Tvs.SetPrivacyRegionEdit3(g_lChID, region,set,TN_MVD_LIVE);
- }
- function tvs_set_screen_calibration_mode(mode)
- {
- if (g_lChID == 0) return;
- setTimeout(function() { document.Tvs.SetScreenCalibrationMode(g_lChID, mode); }, 0);
-
- }
- function tvs_config_camera_module(code, down)
- {
- if (g_lChID == 0) return;
- document.Tvs.ConfigCameraModule(g_lChID, code, down);
- }
- function tvs_get_keepaspectratio()
- {
- if (g_lChID == 0) return true;
- return document.Tvs.KeepAspectRatio(g_lChID);
- }
- function tvs_set_fullscreen(mode)
- {
- if (g_lChID == 0) return;
- return document.Tvs.SetFullScreen(g_lChID, mode);
- }
- function tvs_get_width()
- {
- return document.Tvs.width;
- }
- function tvs_get_height()
- {
- return document.Tvs.height;
- }
- function tvs_set_width(w)
- {
- document.Tvs.width = w;
- }
- function tvs_set_height(h)
- {
- document.Tvs.height = h;
- }
- function tvs_set_width_detection_4ch(w)
- {
- if(SUPPORT_DETECTION_CAM_4CH == g_detection_4ch_support) {
- document.Tvs4_0.width = w ;
- document.Tvs4_1.width = w ;
- document.Tvs4_2.width = w ;
- document.Tvs4_3.width = w ;
- }
- }
- function tvs_set_height_detection_4ch(h)
- {
- if(SUPPORT_DETECTION_CAM_4CH == g_detection_4ch_support) {
- document.Tvs4_0.height = h ;
- document.Tvs4_1.height = h ;
- document.Tvs4_2.height = h ;
- document.Tvs4_3.height = h ;
- }
- }
- function tvs_get_width_detection_4ch(ch)
- {
- if(ch >= 0 && ch < 4) {
- if(0 == ch) {
- return document.Tvs4_0.width ;
- }
- else if(1 == ch) {
- return document.Tvs4_1.width ;
- }
- else if(2 == ch) {
- return document.Tvs4_2.width ;
- }
- else if(3 == ch) {
- return document.Tvs4_3.width ;
- }
- }
- return document.Tvs4_0.width ;
- }
- function tvs_get_height_detection_4ch(ch)
- {
- if(ch >= 0 && ch < 4) {
- if(0 == ch) {
- return document.Tvs4_0.height ;
- }
- else if(1 == ch) {
- return document.Tvs4_1.height ;
- }
- else if(2 == ch) {
- return document.Tvs4_2.height ;
- }
- else if(3 == ch) {
- return document.Tvs4_3.height ;
- }
- }
- return document.Tvs4_0.height ;
- }
- function tvs_get_location(path)
- {
- return document.Tvs.FindLocation(path);
- }
- function tvs_ivs_StartLineEdit()
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1){
- g_ivs.StartLineEdit(g_lChID);
- g_ivs.SetLineEditColor(g_lChID, 0x80FF0000);
- g_ivs.SetLineEditWidth(g_lChID, 0.8);
- }
- }
- function tvs_ivs_StopLineEdit()
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1)
- g_ivs.StopLineEdit(g_lChID);
- }
- function tvs_ivs_SetLineData2(x1, y1, x2, y2)
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1)
- g_ivs.SetLineData2(g_lChID, x1, y1, x2, y2);
- }
- function tvs_ivs_GetLineData2(n)
- {
- if (g_lChID == 0) return 0;
- if(USEIVS == 1)
- return g_ivs.GetLineData2(g_lChID, n);
- }
- function tvs_ivs_StartCellEdit()
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1){
- g_ivs.StartCellEdit(g_lChID);
- g_ivs.SetCellEditColor(g_lChID, 0xFF000000, 0x60FF8080);
- g_ivs.SetCellCount(g_lChID, 24, 32);
- }
- }
- function tvs_ivs_StopCellEdit()
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1)
- g_ivs.StopCellEdit(g_lChID);
- }
- function tvs_ivs_SetCellEditMode(b)
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1)
- g_ivs.SetCellEditMode(g_lChID, b);
- }
- function tvs_ivs_SetCellData2(str)
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1)
- g_ivs.SetCellData2(g_lChID, 24, 32, str);
- }
- function tvs_ivs_GetCellData2()
- {
- if (g_lChID == 0) return null;
- if(USEIVS == 1)
- return g_ivs.GetCellData2(g_lChID);
- }
- function tvs_ivs_StartIVSObjectDisplay()
- {
- if (g_lChID == 0) return null;
- if(USEIVS == 1)
- g_ivs.StartIVSObjectDisplay(g_lChID, 3, 0xFF000000, 0xFFFF0000, 0, 0);
- }
- function tvs_ivs_StopIVSObjectDisplay()
- {
- if (g_lChID == 0) return null;
- if(USEIVS == 1)
- g_ivs.StopIVSObjectDisplay(g_lChID);
- }
- function tvs_StatShowTrigger()
- {
- if (g_lChID == 0) return null;
- document.Tvs.StatShowTrigger();
- }
- var g_lChID2 = 0;
- function tvs2_connect(server_addr, port, id, password, sub)
- {
- var max_resolution = parseInt(readSetupByKey("VID_TVS_DISPLAY_RES"));
-
- if(UseActiveX == 1){
- var agt = navigator.userAgent.toLowerCase();
- if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
- }
- if (g_lChID2 > 0)
- {
- return;
- }
- if($("[name=SYS_BOARDID]").val() == 0x1003 || $("[name=SYS_BOARDID]").val() == 0x1007){
- if(sub == 0){
- sAddress = 'vsnm://' + server_addr + ':' + port + '//video1+audio1';
- }
- else if(sub == 1){
- sAddress = 'vsnm://' + server_addr + ':' + port + '//video2';
- }
- else if(sub == 2){
- sAddress = 'vsnm://' + server_addr + ':' + port + '//video3';
- }
- else if(sub == 3){
- sAddress = 'vsnm://' + server_addr + ':' + port + '//video4';
- }
- else if(sub == 4){
- sAddress = 'vsnm://' + server_addr + ':' + port + '//video1s+audio1';
- }
- else if(sub == 5){
- sAddress = 'vsnm://' + server_addr + ':' + port + '//video2s';
- }
- else if(sub == 6){
- sAddress = 'vsnm://' + server_addr + ':' + port + '//video3s';
- }
- else if(sub == 7){
- sAddress = 'vsnm://' + server_addr + ':' + port + '//video4s';
- }
- else if(sub == 8){
- sAddress = 'vsnm://' + server_addr + ':' + port + '//video5';
- }
- }
- else{
- if(sub == 0){
- sAddress = 'vsnm://' + server_addr + ':' + port + '//video1+audio1';
- }
- else if(sub == 1){
- sAddress = 'vsnm://' + server_addr + ':' + port + '//video1s+audio1';
- }
- else if(sub == 2){
- sAddress = 'vsnm://' + server_addr + ':' + port + '//video1s2+audio1';
- }
- else{
- sAddress = 'vsnm://' + server_addr + ':' + port + '//video1s3+audio1';
- }
- }
- document.Tvs2.SetLocalConfig(3,max_resolution);
- document.Tvs2.SetLocalConfig(9, -1); // Autoplay on
- document.Tvs2.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
- g_lChID2 = document.Tvs2.Connect(sAddress, id, password);
- // alert('after connect');
- // if (!document.Tvs2.Play(g_lChID))
- // {
- // return;
- // }
- document.Tvs2.SetMute(g_lChID2, 0);
- document.Tvs2.SetAutoReconnect(g_lChID2, -1);
- document.Tvs2.SetPTZControlSpeed(g_lChID2, 0, -1);
- document.Tvs2.SetPTZControlSpeed(g_lChID2, 1, -1);
- document.Tvs2.SetPTZControlSpeed(g_lChID2, 2, -1);
- // document.Tvs2.DecodingOption(2) = 0;
- }
- function tvs2_discon()
- {
- if(UseActiveX == 1){
- var agt = navigator.userAgent.toLowerCase();
- if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
- }
- if (g_lChID2 == 0)
- {
- return;
- }
- document.Tvs2.Pause(g_lChID2);
- document.Tvs2.SetMute(g_lChID2, 1);
- document.Tvs2.Disconnect(g_lChID2);
- g_lChID2 = 0;
- // alert('connected');
- pause(500);
- }
- function OnServerNotify() {
- }
- function OnFileRecordNotify() {
- }
- function tvs_ivs_SetLineEditEntryDirection(){
- if(g_lChID == 0) {
- return;
- }
- if(USEIVS == 1) {
- if(UseActiveX == 1) {
- g_ivs.SetLineEditEntryDirection(g_lChID, 1); // 방향을 지정함.
- }
- }
- }
- function tvs_ivs_GetLineEditEntryDirection(){
- if(g_lChID == 0) {
- return;
- }
- if(USEIVS == 1) {
- if(UseActiveX == 1) {
- return g_ivs.GetLineEditEntryDirection(g_lChID); // 방향을 지정함.
- }
- }
- }
- function tvs_ivs_StartPolygonEdit()
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1){
- g_ivs.StartPolygonEdit(g_lChID);
- }
- }
- function tvs_ivs_StopPolygonEdit()
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1){
- g_ivs.StopPolygonEdit(g_lChID);
- }
- }
- function tvs_ivs_SetPolygonData(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8)
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1) {
- g_ivs.SetPolygonData(g_lChID, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8);
- }
- }
- function tvs_ivs_SetPolygonData16(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8, x9, y9, x10, y10, x11, y11, x12, y12, x13, y13, x14, y14, x15, y15, x16, y16)
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1) {
- g_ivs.SetPolygonData16(g_lChID, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8, x9, y9, x10, y10, x11, y11, x12, y12, x13, y13, x14, y14, x15, y15, x16, y16)
- }
- }
- function tvs_ivs_GetPolygonX(n)
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1) {
- return g_ivs.GetPolygonDataX(g_lChID, n);
- }
- }
- function tvs_ivs_GetPolygonY(n)
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1) {
- return g_ivs.GetPolygonDataY(g_lChID, n);
- }
- }
- function tvs_ivs_imp_StartLineCrossEdit()
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1){
- g_ivs.StartLineCrossEdit(g_lChID);
- g_ivs.SetLineCrossConfig(g_lChID, 0, 0.8, 0xFFD01202);
- g_ivs.SetLineCrossConfig(g_lChID, 1, 0.8, 0xFFA35827);
- g_ivs.SetLineCrossConfig(g_lChID, 2, 0.8, 0xFFCEB87B);
- g_ivs.SetLineCrossConfig(g_lChID, 3, 0.8, 0xFF7CCC83);
- g_ivs.SetLineCrossConfig(g_lChID, 4, 0.8, 0xFF7EC4CB);
- g_ivs.SetLineCrossConfig(g_lChID, 5, 0.8, 0xFF7C93CC);
- g_ivs.SetLineCrossConfig(g_lChID, 6, 0.8, 0xFFC783A3);
- g_ivs.SetLineCrossConfig(g_lChID, 7, 0.8, 0xFF96A327);
- }
- }
- function tvs_ivs_imp_StopLineCrossEdit()
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1){
- g_ivs.StopLineCrossEdit(g_lChID);
- }
- }
- // num(0~7), mode(0(erase), 1(set))
- function tvs_ivs_imp_SetLineCrossEditMode(num, mode)
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1){
- g_ivs.SetLineCrossEditMode(g_lChID, num, mode);
- }
- }
- function tvs_ivs_imp_SetLineCrossData(startx1, starty1, endx1, endy1, startx2, starty2, endx2, endy2,
- startx3, starty3, endx3, endy3, startx4, starty4, endx4, endy4, startx5, starty5, endx5, endy5,
- startx6, starty6, endx6, endy6, startx7, starty7, endx7, endy7, startx8, starty8, endx8, endy8)
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1) {
- g_ivs.SetLineCrossData(g_lChID, startx1, starty1, endx1, endy1, startx2, starty2, endx2, endy2,
- startx3, starty3, endx3, endy3, startx4, starty4, endx4, endy4, startx5, starty5, endx5, endy5,
- startx6, starty6, endx6, endy6, startx7, starty7, endx7, endy7, startx8, starty8, endx8, endy8);
- }
- }
- function tvs_ivs_imp_GetLineCrossStartX(n)
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1) {
- return g_ivs.GetLineCrossStartX(g_lChID, n);
- }
- }
- function tvs_ivs_imp_GetLineCrossStartY(n)
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1) {
- return g_ivs.GetLineCrossStartY(g_lChID, n);
- }
- }
- function tvs_ivs_imp_GetLineCrossEndX(n)
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1) {
- return g_ivs.GetLineCrossEndX(g_lChID, n);
- }
- }
- function tvs_ivs_imp_GetLineCrossEndY(n)
- {
- if (g_lChID == 0) return;
- if(USEIVS == 1) {
- return g_ivs.GetLineCrossEndY(g_lChID, n);
- }
- }
- function tvs_ivs_imp_SetPolygonConfig(line_thickness, line_color, circle_diameter, circle_color_selected)
- {
- /*
- color : ARGB DWORD Value (Default : 0xFFFF0000)
- thickness : 1.0(Default)
- diameter : 1.0(Default)
- */
- if (g_lChID == 0) return;
- if(USEIVS == 1){
- g_ivs.SetPolygonConfig(g_lChID, line_thickness, line_color, circle_diameter, circle_color_selected);
- }
- }
- function tvs_ivs_imp_SetLineCrossConfig(line_num, line_thickness, line_color)
- {
- /*
- thickness : 1.0(Default)
- */
- if (g_lChID == 0) return;
- if(USEIVS == 1){
- g_ivs.SetLineCrossConfig(g_lChID, line_num, line_thickness, line_color);
- }
- }
- function tvs_HiRoi_SetROIMode(stream_index, region_index, mode)
- {
- // mode : off(0), set(1), erase(2), display(3)
- if(g_lChID == 0) return;
- if(stream_index < 0 || stream_index > 15) {
- return;
- }
- // if(region_index < 0 || region_index > 7) {
- if(region_index < 0 || region_index > 3) {
- return;
- }
- if(mode < 0 || mode > 3) {
- return;
- }
- document.Tvs.SetROIMode(g_lChID, stream_index, region_index, mode);
- }
- function tvs_HiRoi_SetROIDataWithMin(stream_index, region_index, x, y, w, h, min_w, min_h)
- {
- if(g_lChID == 0) return;
- if(stream_index < 0 || stream_index > 15) {
- return;
- }
- // if(region_index < 0 || region_index > 7) {
- if(region_index < 0 || region_index > 3) {
- return;
- }
- document.Tvs.SetROIDataWithMin(g_lChID, stream_index, region_index, x, y, w, h, min_w, min_h);
- }
- function tvs_HiRoi_SetROIData(stream_index, region_index, x, y, w, h)
- {
- if(g_lChID == 0) return;
- if(stream_index < 0 || stream_index > 15) {
- return;
- }
- // if(region_index < 0 || region_index > 7) {
- if(region_index < 0 || region_index > 3) {
- return;
- }
- document.Tvs.SetROIData(g_lChID, stream_index, region_index, x, y, w, h);
- }
- function tvs_HiRoi_GetROIStartX(stream_index, region_index)
- {
- if(g_lChID == 0) return;
- if(stream_index < 0 || stream_index > 15) {
- return;
- }
- // if(region_index < 0 || region_index > 7) {
- if(region_index < 0 || region_index > 3) {
- return;
- }
- return document.Tvs.GetROIStartX(g_lChID, stream_index, region_index);
- }
- function tvs_HiRoi_GetROIStartY(stream_index, region_index)
- {
- if(g_lChID == 0) return;
- if(stream_index < 0 || stream_index > 15) {
- return;
- }
- // if(region_index < 0 || region_index > 7) {
- if(region_index < 0 || region_index > 3) {
- return;
- }
- return document.Tvs.GetROIStartY(g_lChID, stream_index, region_index);
- }
- function tvs_HiRoi_GetROIWidth(stream_index, region_index)
- {
- if(g_lChID == 0) return;
- if(stream_index < 0 || stream_index > 15) {
- return;
- }
- // if(region_index < 0 || region_index > 7) {
- if(region_index < 0 || region_index > 3) {
- return;
- }
- return document.Tvs.GetROIWidth(g_lChID, stream_index, region_index);
- }
- function tvs_HiRoi_GetROIHeight(stream_index, region_index)
- {
- if(g_lChID == 0) return;
- if(stream_index < 0 || stream_index > 15) {
- return;
- }
- // if(region_index < 0 || region_index > 7) {
- if(region_index < 0 || region_index > 3) {
- return;
- }
- return document.Tvs.GetROIHeight(g_lChID, stream_index, region_index);
- }
- // x, y : 0 ~ 100
- function tvs_SetDrawCross(x, y, length, width, color)
- {
- if (g_lChID == 0) return;
- setTimeout(function() { g_display.SetDrawCross(g_lChID, x, y, length, width, color); }, 0);
- }
- function tvs_SetDrawCross_4Ch(ch_id, x, y, length, width, color)
- {
- // console.log("-- ch_id : " + ch_id + " x : "+ x + " y :" + y );
- if(UseActiveX == 1){
- if(null != g_detection_4ch_Displays[ch_id]) {
- g_detection_4ch_Displays[ch_id].SetDrawCross(g_detection_4ch_IDs[ch_id], x, y, length, width , color);
- // g_detection_4ch_Displays[ch_id].SetDrawCross(g_detection_4ch_IDs[ch_id], "cross.png", x, y, width );
- }
- }
- else {
- if(0 == ch_id) {
- document.Tvs4_0.SetDrawCross(g_detection_4ch_IDs[ch_id], x, y, length, width , color);
- }
- else if(1 == ch_id) {
- document.Tvs4_1.SetDrawCross(g_detection_4ch_IDs[ch_id], x, y, length, width , color);
- }
- else if(2 == ch_id) {
- document.Tvs4_2.SetDrawCross(g_detection_4ch_IDs[ch_id], x, y, length, width , color);
- }
- else {
- document.Tvs4_3.SetDrawCross(g_detection_4ch_IDs[ch_id], x, y, length, width , color);
- }
- }
- }
- function tvs_SetStraightLineMode(stream_index, region_index, mode, color, width)
- {
- // mode : off(0), set(1), erase(2), display(3)
- if(g_lChID == 0) {
- return;
- }
- if(stream_index < 0 || stream_index > 15) {
- return;
- }
- if(region_index < 0 || region_index > 7) {
- return;
- }
- if(mode < 0 || mode > 3) {
- return;
- }
- document.Tvs.SetStraightLineMode(g_lChID, stream_index, region_index, mode);
- document.Tvs.SetStraightLineColor(g_lChID, stream_index, region_index, color);
- document.Tvs.SetStraightLineWidth(g_lChID, stream_index, region_index, width);
- }
- function tvs_SetStraightLineData(stream_index, region_index, direction, position)
- {
- // direction : horizontal(0), vertical(1)
- if(g_lChID == 0) return;
- if(stream_index < 0 || stream_index > 15) {
- return;
- }
- if(region_index < 0 || region_index > 7) {
- return;
- }
- if(direction != 0 && direction != 1) {
- return;
- }
- if(position < 0) position = 0;
- if(position > 1000) position = 1000;
- document.Tvs.SetStraightLineData(g_lChID, stream_index, region_index, direction, position);
- }
- function tvs_GetStraightLineDirection(stream_index, region_index)
- {
- if(g_lChID == 0) return;
- if(stream_index < 0 || stream_index > 15) {
- return -1;
- }
- if(region_index < 0 || region_index > 7) {
- return -1;
- }
- return document.Tvs.GetStraightLineDirection(g_lChID, stream_index, region_index);
- }
- function tvs_GetStraightLinePosition(stream_index, region_index)
- {
- if(g_lChID == 0) return;
- if(stream_index < 0 || stream_index > 15) {
- return -1;
- }
- if(region_index < 0 || region_index > 7) {
- return -1;
- }
- return document.Tvs.GetStraightLinePosition(g_lChID, stream_index, region_index);
- }
- /* Polygon8 (TVS_VERSION >= 1,6,57,122) */
- // mode : 0(off), 1(edit), 2(erase), 3(display)
- // thick : float
- // color : hex
- function tvs_SetPolygon8Mode(stream_index, polygon_index, mode, thick, line_color, circle_color, circle_sel_color)
- {
- if (g_lChID == 0) return;
- document.Tvs.SetPolygon8Color(g_lChID, stream_index, polygon_index, line_color, circle_color, circle_sel_color);
- document.Tvs.SetPolygon8Thickness(g_lChID, stream_index, polygon_index, thick);
- return document.Tvs.SetPolygon8Mode(g_lChID, stream_index, polygon_index, mode);
- }
- function tvs_SetPolygon8Data(stream_index, polygon_index, x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7)
- {
- if (g_lChID == 0) return;
- return document.Tvs.SetPolygon8Data(g_lChID, stream_index, polygon_index, x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7);
- }
- function tvs_GetPolygon8DataX(stream_index, polygon_index, point_index)
- {
- if (g_lChID == 0) return;
- return document.Tvs.GetPolygon8DataX(g_lChID, stream_index, polygon_index, point_index);
- }
- function tvs_GetPolygon8DataY(stream_index, polygon_index, point_index)
- {
- if (g_lChID == 0) return;
- return document.Tvs.GetPolygon8DataY(g_lChID, stream_index, polygon_index, point_index);
- }
- /* Line (TVS_VERSION >= 1,6,57,122) */
- // mode : 0(off), 1(edit), 2(erase), 3(display)
- // thick : float
- // color : hex
- function tvs_SetLineMode(stream_index, line_index, mode, thick, color)
- {
- if (g_lChID == 0) return;
- document.Tvs.SetLineColor(g_lChID, stream_index, line_index, color);
- document.Tvs.SetLineThickness(g_lChID, stream_index, line_index, thick);
- return document.Tvs.SetLineMode(g_lChID, stream_index, line_index, mode);
- }
- // draw_arrow : 0(normal line), 1(arrow)
- function tvs_SetLineData(stream_index, line_index, draw_arrow, startx, starty, endx, endy)
- {
- if (g_lChID == 0) return;
- return document.Tvs.SetLineData(g_lChID, stream_index, line_index, draw_arrow, startx, starty, endx, endy);
- }
- // point_index : 0(start x), 1(end x)
- function tvs_GetLineDataX(stream_index, line_index, point_index)
- {
- if (g_lChID == 0) return;
- return document.Tvs.GetLineDataX(g_lChID, stream_index, line_index, point_index);
- }
- // point_index : 0(start y), 1(end y)
- function tvs_GetLineDataY(stream_index, line_index, point_index)
- {
- if (g_lChID == 0) return;
- return document.Tvs.GetLineDataY(g_lChID, stream_index, line_index, point_index);
- }
|