<<Label_Name>>End Loop Label_Name;

本文介绍了PL/SQL中的三种循环结构:FOR循环、WHILE循环和无限LOOP循环,并通过具体实例展示了如何使用这些循环进行迭代操作。

语法:

    [<<Label_Nme>>]

   Loop

      Continue [Label_Name] ....

      Exit  [Label_Name]...

     --statement

   End Loop [Label_Name];

   [<<Label_Name>>]

   For ... Loop

      Continue [Label_Name] ....

      Exit  [Label_Name]...

    --statement

  End Loop [Label_Name];

 [<<Label_Name>>]

  While ..Loop

      Continue [Label_Name] ....

      Exit  [Label_Name]...

   --statement 

 End Loop [Label_Name];

例1:

SQL> Declare

  2    i Number:=0;
  3  Begin
  4    For i In 1..10 Loop
  5      dbms_output.put_line(i);
  6    End Loop For循环结束;
  7  End;
  8  /
1
2
3
4
5
6
7
8
9
10
PL/SQL procedure successfully completed

例2:

SQL> Declare
  2    i Number:=0;
  3  Begin
  4    While i<10 Loop
  5      i:=i+1;
  6      dbms_output.put_line(i);
  7    End Loop while循环结束;
  8  End;
  9  /
1
2
3
4
5
6
7
8
9
10
PL/SQL procedure successfully completed

例3:

SQL> Declare
  2    i Number:=0;
  3  Begin
  4    Loop
  5      i:=i+1;
  6      dbms_output.put_line(i);
  7      Exit When i>=10;
  8    End Loop loop循环结束;
  9  End;
 10  /
1
2
3
4
5
6
7
8
9
10
PL/SQL procedure successfully completed

<lib> <name>createVolumeDP</name> <code>runlib:checkdplicense| runlib:makecachewarnings| clearversion:PagePool| domethodsstop:91| jumpif:$v.canbecompressed:!=:true:SKIP2| goto:sizeopt| stop| label:SKIP2| goto:size| stop| </code> </lib>这是一个xml我想找到<xml> <title>Create Volume</title> <helpcontextid>CreateVolume</helpcontextid> <width>800</width> <height>630</height> <windowtype>single</windowtype> <icon>12</icon> <firstcard></firstcard> <createobject>volume</createobject> <createdefaultname>yes</createdefaultname> <finishnowcaption>Create Now</finishnowcaption> <requireconfigstore>true</requireconfigstore> <vars> <var> <name>basename</name> <type>String</type> </var> <var> <name>skipdisks</name> <type>String</type> </var> <var> <name>fromcmm</name> <type>boolean</type> <value>false</value> </var> <var> <name>fromload</name> <type>boolean</type> <value>false</value> </var> <var> <name>sourcesecure</name> <type>boolean</type> <value>false</value> </var> <var> <name>runmap</name> <type>boolean</type> <value>false</value> </var> <var> <name>runnewmap</name> <type>boolean</type> <value>false</value> </var> <var> <name>linkerran</name> <type>boolean</type> <value>false</value> </var> <var> <name>mapran</name> <type>boolean</type> <value>false</value> </var> <var> <name>diskgroupid</name> <type>int</type> </var> <var> <name>pagepoolindex</name> <type>int</type> </var> <var> <name>importTemplate</name> <type>object</type> </var> <var> <name>CopyReplaySchedules</name> <type>boolean</type> <value>false</value> </var> <var> <name>convertToBlocks</name> <type>boolean</type> <value>false</value> </var> <var> <name>volumetoduplicate</name> <type>object</type> </var> <var> <name>columnList</name> <type>string</type> <value>DiskFolderName:COLUMN_HEAD_DISK_FOLDER:180|redundancy:COLUMN_HEAD_REDUNDANCY:180|DataPageSizeDisplay:COLUMN_HEAD_DATAPAGE_SIZE:180|status:COLUMN_HEAD_STATUS:100</value> </var> <var> <name>lastcard</name> <type>String</type> </var> <var> <name>pageclassmode</name> <value>0</value> </var> <var> <name>sizewarning</name> <type>string</type> </var> <var> <name>sizewarning2</name> <type>string</type> </var> <var> <name>SystemReadCacheWarning</name> <type>string</type> </var> <var> <name>SystemWriteCacheWarning</name> <type>string</type> </var> <var> <name>tier1writable</name> <type>string</type> <value></value> </var> <var> <name>tier2writable</name> <type>string</type> <value></value> </var> <var> <name>tier3writable</name> <type>string</type> <value></value> </var> <var> <name>tier1replay</name> <type>string</type> <value></value> </var> <var> <name>tier2replay</name> <type>string</type> <value></value> </var> <var> <name>tier3replay</name> <type>string</type> <value></value> </var> <var> <name>selectedtemplate</name> <type>string</type> <value></value> </var> <var> <name>selectedTemplateName</name> <type>string2</type> <value><None></value> </var> <var> <name>NONE</name> <type>string2</type> <value><None></value> </var> <var> <name>dpColumns</name> <type>string</type> <value>blank::25:false:false:0:::Cost|raidlevellabel:COLUMN_HEAD_RAID_LEVEL:90|DiskSpeedZone:COLUMN_HEAD_DISK_TRACKS_USED:100|selectedwritable:COLUMN_HEAD_WRITABLE_DATA:90:false:false:11:true:false|selectedhistorical:COLUMN_HEAD_REPLAY_DATA:80:false:false:11:true:false|</value> </var> <var> <name>userProfilesFound</name> <type>boolean</type> <value>false</value> </var> <var> <name>ReplayTemplateVector</name> <type>vector</type> </var> <var> <name>SelectedTemplatesVector</name> <type>vector</type> </var> <var> <name>selectedReplayProfilesStr</name> <type>string</type> <value></value> </var> <var> <name>comma</name> <type>string</type> <value>, </value> </var> <var> <name>labelValue1</name> <type>string</type> <value>Storage Profile:</value> </var> <var> <name>labelValue2</name> <type>string</type> <value>RAID Types:</value> </var> <var> <name>labelValue3</name> <type>string</type> <value>Storage Tier:</value> </var> <var> <name>storageLabel1</name> <type>string</type> <value>Storage Profile:</value> </var> <var> <name>storageLabel2</name> <type>string</type> <value></value> </var> <var> <name>storageValue1</name> <type>string</type> <value></value> </var> <var> <name>storageValue2</name> <type>string</type> <value></value> </var> <var> <name>storageTierText</name> <type>string</type> <value>Select the RAID and Storage Tier settings for this volume:</value> </var> <var> <name>textValue1</name> <type>string</type> <value>Select the RAID and Storage Tier settings for this volume:</value> </var> <var> <name>textValue2</name> <type>string</type> <value>Select the Storage Tier setting for this volume:</value> </var> <var> <name>defaultServer</name> <type>object</type> </var> <var> <name>colon</name> <type>string</type> <value>:</value> </var> <var> <name>dataoptimization</name> <type>boolean</type> <value>false</value> </var> <var> <name>canbecompressed</name> <type>boolean</type> <value>false</value> </var> <var> <name>compressionLabelString</name> <type>string</type> <value>Compression Enabled:</value> </var> <var> <name>compressionLabel</name> <type>string</type> <value></value> </var> <var> <name>compressionValue</name> <type>string</type> <value></value> </var> </vars> <cards> <card> <id>diskfolder</id> <region>diskfolder</region> <regionstart>diskfolder</regionstart> <url>wiz/eng/html/questions/CreateVolume/Disks.htm</url> <tab>2</tab> <contextid>1</contextid> <code>setattr:$v.lastcard:diskfolder</code> <buttons> <menuitem> <defaultlabel>Continue</defaultlabel> <labelkey>3001</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>runlib:selectdisk</actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>redundancy</id> <region>redundancy</region> <regionstart>redundancy</regionstart> <url>wiz/eng/html/questions/CreateVolume/Redundancy.htm</url> <tab>1</tab> <contextid>1</contextid> <code>setattr:$v.lastcard:redundancy</code> <buttons> <menuitem> <defaultlabel>Non-Redundant</defaultlabel> <labelkey>0498</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>setattr:$v.diskFailureProtection:0| setattr:$v.dfPagepoolVector:nonredundantPagepools| setattr:$p.primetype:non-redundant| setattr:$p.diskFailureProtection:0| setattr:$v.storageTierText:$v.textValue2| runlib:checkNonRedundant| </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> <menuitem> <defaultlabel>Redundant</defaultlabel> <labelkey>0499</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>setattr:$v.diskFailureProtection:1| setattr:$v.dfPagepoolVector:redundantPagepools| setattr:$p.primetype:redundant| setattr:$p.diskFailureProtection:1| setattr:$v.storageTierText:$v.textValue1| runlib:checkRedundant| </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>selectpagepool</id> <region>selectpagepool</region> <regionstart>selectpagepool</regionstart> <url>wiz/eng/html/questions/CreateVolume/SelectPagepool.htm</url> <contextid>1</contextid> <code>setattr:$v.lastcard:selectpagepool</code> <buttons> <menuitem> <defaultlabel>Continue</defaultlabel> <labelkey>3001</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>runlib:selectPagepool|</actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>bpwait</id> <region>bpwait</region> <regionstart>bpwait</regionstart> <url>wiz/eng/html/questions/bpwait2.htm</url> <tab>1</tab> <contextid>1</contextid> <donecode>stopif:$w.doneEventSuccess:=:false| runbackground:postsave| </donecode> </card> <card> <id>pagepooldown</id> <region>pagepooldown</region> <regionstart>pagepooldown</regionstart> <url>wiz/eng/html/questions/CreateVolume/PagepoolDown.htm</url> <tab>1</tab> <contextid>1</contextid> <buttons> <menuitem> <defaultlabel>Close</defaultlabel> <labelkey>0112</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>return</actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> <menuitem> <defaultlabel>Retry</defaultlabel> <labelkey>3021</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>goto:diskfolder</actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>pagepooldown2</id> <region>pagepooldown2</region> <regionstart>pagepooldown2</regionstart> <url>wiz/eng/html/questions/CreateVolume/PagepoolDown.htm</url> <tab>1</tab> <contextid>1</contextid> <hideback>true</hideback> <buttons> <menuitem> <defaultlabel>Close</defaultlabel> <labelkey>0112</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>return</actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>size</id> <region>size</region> <regionstart>size</regionstart> <url>wiz/eng/html/questions/CreateVolume/DynamicSize.htm</url> <tab>1</tab> <contextid>1</contextid> <code>domethodsstop:85| jumpif:$u.DPPrompt:!=:true:CHECKCACHE| stop| label:CHECKCACHE| jumpif:$u.cacheprompt:!=:true:SKIP| stop| label:SKIP| goto:sizenoadvance| stop| </code> <buttons> <menuitem> <defaultlabel>Advanced</defaultlabel> <labelkey>3020</labelkey> <defaulttooltip>Change advanced settings for this Volume</defaulttooltip> <tooltipkey>3263</tooltipkey> <imagekey>0112</imagekey> <actioncommand>domethodsstop:13| refresh| jumpif:$m.expandsize:igt:$w.MaxVolBlockCount:TOOBIG| jumpif:$m.expandsize:ilt:$m.DataPageSize:TOOSMALL| goto:dp| stop| label:TOOBIG| getmsg:3269:$v.emsg:$w.MaxVolSizeStr| msgbox:$v.emsg:$w.title:E| stop| label:TOOSMALL| getmsg:3268:$v.sizeMsg:$m.minsize| msgbox:$v.sizeMsg:$w.title:W| stop| </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> <menuitem> <defaultlabel>Continue</defaultlabel> <labelkey>3001</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>domethodsstop:13| refresh| jumpif:$m.expandsize:igt:$w.MaxVolBlockCount:TOOBIG| jumpif:$m.expandsize:ilt:$m.DataPageSize:TOOSMALL| runlib:checkprogression| goto:replay| stop| label:TOOBIG| concat:The maximum size of a Volume is~:$w.MaxVolSizeStr:$v.emsg| concat:$v.emsg:.:$v.emsg| msgbox:$v.emsg:$w.title:E| stop| label:TOOSMALL| getmsg:3268:$v.sizeMsg:$m.minsize| msgbox:$v.sizeMsg:$w.title:W| stop| </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>sizeopt</id> <region>size</region> <regionstart>size</regionstart> <url>wiz/eng/html/questions/CreateVolume/DynamicSizeOpt.htm</url> <tab>1</tab> <contextid>1</contextid> <code>domethodsstop:85| jumpif:$u.DPPrompt:!=:true:CHECKCACHE| stop| label:CHECKCACHE| jumpif:$u.cacheprompt:!=:true:SKIP| stop| label:SKIP| goto:sizenoadvanceopt| stop| </code> <buttons> <menuitem> <defaultlabel>Advanced</defaultlabel> <labelkey>3020</labelkey> <defaulttooltip>Change advanced settings for this Volume</defaulttooltip> <tooltipkey>3263</tooltipkey> <imagekey>0112</imagekey> <actioncommand>domethodsstop:13| refresh| jumpif:$m.expandsize:igt:$w.MaxVolBlockCount:TOOBIG| jumpif:$m.expandsize:ilt:$m.DataPageSize:TOOSMALL| goto:dp| stop| label:TOOBIG| getmsg:3269:$v.emsg:$w.MaxVolSizeStr| msgbox:$v.emsg:$w.title:E| stop| label:TOOSMALL| getmsg:3268:$v.sizeMsg:$m.minsize| msgbox:$v.sizeMsg:$w.title:W| stop| </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> <menuitem> <defaultlabel>Continue</defaultlabel> <labelkey>3001</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>domethodsstop:13| refresh| jumpif:$m.expandsize:igt:$w.MaxVolBlockCount:TOOBIG| jumpif:$m.expandsize:ilt:$m.DataPageSize:TOOSMALL| runlib:checkprogression| goto:replay| stop| label:TOOBIG| concat:The maximum size of a Volume is~:$w.MaxVolSizeStr:$v.emsg| concat:$v.emsg:.:$v.emsg| msgbox:$v.emsg:$w.title:E| stop| label:TOOSMALL| getmsg:3268:$v.sizeMsg:$m.minsize| msgbox:$v.sizeMsg:$w.title:W| stop| </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>sizenoadvance</id> <region>size</region> <regionstart>size</regionstart> <url>wiz/eng/html/questions/CreateVolume/DynamicSize.htm</url> <tab>1</tab> <contextid>1</contextid> <code></code> <buttons> <menuitem> <defaultlabel>Continue</defaultlabel> <labelkey>3001</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand> copy:$m:$q| domethodsstop:13| refresh| jumpnull:$i:OKCOPY| jumpif:$i.type:!=:wizvar:OKCOPY| jumpif:$i.CopyVolume:=:false:OKCOPY| jumpif:$m.expandsize:igt=:$q.expandsize:OKCOPY| msgbox:The destination volume cannot be smaller than the source volume.:$w.title:E| stop| label:OKCOPY| jumpif:$m.expandsize:igt:$w.MaxVolBlockCount:TOOBIG| jumpif:$m.expandsize:ilt:$m.DataPageSize:TOOSMALL| runlib:checkprogression| goto:replay| stop| label:TOOBIG| concat:The maximum size of a Volume is~:$w.MaxVolSizeStr:$v.emsg| concat:$v.emsg:.:$v.emsg| msgbox:$v.emsg:$w.title:E| stop| label:TOOSMALL| getmsg:3268:$v.sizeMsg:$m.minsize| msgbox:$v.sizeMsg:$w.title:W| stop| </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>sizenoadvanceopt</id> <region>size</region> <regionstart>size</regionstart> <url>wiz/eng/html/questions/CreateVolume/DynamicSizeOpt.htm</url> <tab>1</tab> <contextid>1</contextid> <code></code> <buttons> <menuitem> <defaultlabel>Continue</defaultlabel> <labelkey>3001</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand> copy:$m:$q| domethodsstop:13| refresh| jumpnull:$i:OKCOPY| jumpif:$i.type:!=:wizvar:OKCOPY| jumpif:$i.CopyVolume:=:false:OKCOPY| jumpif:$m.expandsize:igt=:$q.expandsize:OKCOPY| msgbox:The destination volume cannot be smaller than the source volume.:$w.title:E| stop| label:OKCOPY| jumpif:$m.expandsize:igt:$w.MaxVolBlockCount:TOOBIG| jumpif:$m.expandsize:ilt:$m.DataPageSize:TOOSMALL| runlib:checkprogression| goto:replay| stop| label:TOOBIG| concat:The maximum size of a Volume is~:$w.MaxVolSizeStr:$v.emsg| concat:$v.emsg:.:$v.emsg| msgbox:$v.emsg:$w.title:E| stop| label:TOOSMALL| getmsg:3268:$v.sizeMsg:$m.minsize| msgbox:$v.sizeMsg:$w.title:W| stop| </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>dp</id> <region>dp</region> <regionstart>dp</regionstart> <url>wiz/eng/html/questions/CreateVolume/DataProgression.htm</url> <tab>1</tab> <contextid>1</contextid> <code>stopif:$u.DPPrompt:=:true| goto:advancedoptions| stop| </code> <buttons> <menuitem> <defaultlabel>Continue</defaultlabel> <labelkey>3001</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>runlib:checkprogression| goto:advancedoptions| </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>advancedoptions</id> <region>advancedoptions</region> <regionstart>advancedoptions</regionstart> <url>wiz/eng/html/questions/CreateVolume/AdvancedOptions.htm</url> <tab>2</tab> <contextid>1</contextid> <code>jumpif:$v.SystemReadCacheWarning:!=::TWO| jumpif:$v.SystemWriteCacheWarning:!=::TWO| stopif:$u.cacheprompt:=:true| goto:replay| stop| label:TWO| goto:advancedoptions2| </code> <buttons> <menuitem> <defaultlabel>Continue</defaultlabel> <labelkey>3001</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>setattrint:$m.RCacheRAStatus:$m.RCacheStatus| goto:replay| </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>advancedoptions2</id> <region>advancedoptions2</region> <regionstart>advancedoptions2</regionstart> <url>wiz/eng/html/questions/CreateVolume/AdvancedOptions2.htm</url> <tab>2</tab> <contextid>1</contextid> <code>stopif:$u.cacheprompt:=:true| goto:replay </code> <buttons> <menuitem> <defaultlabel>Continue</defaultlabel> <labelkey>3001</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>setattrint:$m.RCacheRAStatus:$m.RCacheStatus| goto:replay </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>replay</id> <region>replay</region> <regionstart>replay</regionstart> <url>wiz/eng/html/questions/CreateVolume/TemplateSelection.htm</url> <tab>1</tab> <contextid>1</contextid> <code>jumpnull:$l:LICENSED| jumpif:$l.Enabled^13:=:1:LICENSED| goto:save| stop| label:LICENSED| jumpif:$u.ReplayOption:i=:1:CONTINUE| jumpif:$u.ReplayOption:i=:0:SAVE| jumpif:$u.ReplayOption:i=:2:SAVE| jump:CONTINUE| label:SAVE| goto:save| stop| label:CONTINUE| </code> <buttons> <menuitem> <defaultlabel>Continue</defaultlabel> <labelkey>3001</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>goto:save| </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>save</id> <region>save</region> <regionstart>save</regionstart> <url>wiz/eng/html/questions/CreateVolume/Save.htm</url> <adminurl>wiz/eng/html/questions/CreateVolume/SaveAdmin.htm</adminurl> <tab>1</tab> <contextid>1</contextid> <code></code> <buttons> <menuitem> <defaultlabel>Continue</defaultlabel> <labelkey>3001</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>jumpif:$w.userprivlevel:i=:5:ADMIN| jumpif:$m.parentobjectid:i!=:0:NOTROOT| getmsg:3397:$v.PrivWarning| msgbox:$v.PrivWarning:$w.title:W| stop| label:NOTROOT| label:ADMIN| setattr:$v.sizewarning:| setattr:$v.sizewarning2:| jumpif:$m.expandsize:ilt:4294967297:NONE| setattr:$v.sizewarning:Warning - Some operating systems do not support volumes greater than 2 TB.| setattr:$v.sizewarning2:Please verify that the server operating system supports volumes of this size.| label:NONE| jumpif:$v.skipfinish:=:true:SKIPFINISH| domethodsstop:$u:5| runlib:fixstoragelabels| runlib:fixcompressionlabels| goto:finish| stop| label:SKIPFINISH| return:$m:CREATE| stop| </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> <card> <id>finish</id> <region>finish</region> <regionstart>finish</regionstart> <url>wiz/eng/html/questions/CreateVolume/FinishDP.htm</url> <tab>1</tab> <contextid>1</contextid> <code></code> <buttons> <menuitem> <defaultlabel>Create Now</defaultlabel> <labelkey>3002</labelkey> <defaulttooltip></defaulttooltip> <tooltipkey>-1</tooltipkey> <imagekey>0112</imagekey> <actioncommand>runlib:afterCreateVolumeDP| </actioncommand> <itemstate>ENABLED</itemstate> <sticky>0</sticky> <stickystate>0</stickystate> <priv>3</priv> </menuitem> </buttons> </card> </cards> <instructions> <lib> <name>start</name> <event>start</event> <code>setsize:800:630| runlib:setprimingdefaults| setattr:$v.diskgroupid:$u.diskgroupid| runlib:checktitle| jumpnull:$i:CONTINUE| jumpif:$i.type:!=:wizvar:CONTINUE| setobject:$i.sourcevolumeobject:$o| jumpnull:$o:CONTINUE| getstop:$o| setattr:$v.skiplinker:YES| setattr:$v.ExactDuplicate:$i.ExactDuplicate| setattr:$v.CopyVolume:$i.CopyVolume| setattr:$v.CopyReplaySchedules:$i.CopyReplaySchedules| setattr:$v.fromcmm:true| jumpif:$o.isSecure:=:false:NOSED| setattr:$v.sourcesecure:true| label:NOSED| setattr:$v.diskgroupid:$o.diskgroupid| runlib:checkduplicate| jumpif:$i.ExactDuplicate:=:true:EXACT| setattr:$m.name:$i.duplicatesname| jump:FINISH| label:EXACT| setattr:$m.name:$i.duplicatesname| setattr:$m.notes:$i.notes| setattr:$m.parentobjectid:$i.duplicatefolder| jumpif:$v.CopyReplaySchedules:!=:true:NOREPLAY| domethodsstop:$o:45| setattrobject:$v.importTemplate:$o.snapshotprofile| label:NOREPLAY| runlib:save| end| label:CONTINUE| jumpif:$v.InitialBlockCount:=::CONTINUE2| jumpif:$v.InitialBlockCount:=:0:CONTINUE2| // must be from Load/Restore VolumeFromExternalDevice| setattr:$v.fromload:true| setattr:$v.newname:$v.InitialDiskName| trim:$v.newname:64| jumpif:$v.newname:=::EMPTYNAME| setattr:$m.name:$v.newname| label:EMPTYNAME| setattr:$m.expandsize:$v.InitialBlockCount| setattr:$v.convertToBlocks:true| domethodsstop:$m:14| jumpif:$m.name:!=::FINISH| label:CONTINUE2| jumpif:$v.newname:=::EMPTYNAME2| setattr:$m.name:$v.newname| jump:FINISH| label:EMPTYNAME2| setattr:$v.basename:$u.VolumeBaseName| domethodsstop:15|//generate name| label:FINISH| getstop:$s| getstop:$u| setattr:$v.diskgroupid:$u.diskgroupid| runlib:fillreplayvectors| runlib:checkInput| runlib:setparent| runlib:setfirstcard| end| </code> </lib> <lib> <name>fillreplayvectors</name> <code>retrievetable:PITCRuleGroup:$g| vectorset:$g:$v.ReplayTemplateVector| jumpif:$v.fromcmm:=:true:SKIP| jumpif:$v.fromload:=:true:SKIP| jumpif:$u.ReplayOption:i=:0:SKIP| domethodsstop:$u:3| label:SKIP| </code> </lib> <lib> <name>setprimingdefaults</name> <code>setattr:$v.diskFailureProtection:1| setattr:$v.dfPagepoolVector:redundantPagepools| setattr:$p.primetype:redundant| setattr:$p.diskFailureProtection:1| </code> </lib> <lib> <name>setfirstcard</name> <code>jumpif:$v.skipdisks:=:YES:SKIPDF| jumpif:$u.diskgroupidprompt:=:true:DF| label:SKIPDF| jumpif:$u.redundantonly:=:false:REDUNDANCY| jump:RUNWIZARD| label:DF| setattr:$w.firstcard:diskfolder| stop| label:REDUNDANCY| setattr:$w.firstcard:redundancy| stop| label:RUNWIZARD| setattr:$w.firstcard:diskfolder| setattr:$v.diskFailureProtection:1| setattr:$v.dfPagepoolVector:redundantPagepools| setattr:$p.primetype:redundant| setattr:$p.diskFailureProtection:1| runlib:checkRedundant| stop| </code> </lib> <lib> <name>gotodiskfolder</name> <code>jumpif:$v.skipdisks:=:YES:SKIP| jumpif:$u.diskgroupidprompt:=:false:SKIP| goto:diskfolder| stop| label:SKIP| runlib:gotoredundancy| stop| </code> </lib> <lib> <name>gotoredundancy</name> <code>jumpif:$u.redundantonly:=:true:SKIP| goto:redundancy| stop| label:SKIP| setattr:$v.diskFailureProtection:1| setattr:$p.diskFailureProtection:1| runlib:checkRedundant| stop| </code> </lib> <lib> <name>checktitle</name> <code>setattr:$w.replacetitle:Create Volume| </code> </lib> <lib> <name>checkInput</name> <code>jumpnull:$i:INULL| jumpif:$i.type:=:diskfolder:DF| jumpif:$i.type:=:server:SERVER| label:INULL| jumpif:$u.AutoMap:=:true:MAP| jump:CONTINUE| label:SERVER| setattr:$v.runmap:true| setattr:$v.serverid:$i.objectid| jumpif:$u.AutoMap:=:true:MAP| jump:CONTINUE| label:DF| setattr:$v.diskgroupid:$i.objectid| setattr:$v.skipdisks:YES| jumpif:$u.AutoMap:=:true:MAP| jump:DONE| label:MAP| jumpif:$s.NewMappingEnabled:=:true:NEWMAP| jumpif:$u.DefaultServer:i=:0:CONTINUE| setattr:$v.runmap:true| setattr:$v.serverid:$u.DefaultServer| jumpif:$v.skipdisks:=:YES:DONE| jump:CONTINUE| label:NEWMAP| jumpif:$u.DefaultServer:=::CONTINUE| jumpif:$u.DefaultServer:=:0:CONTINUE| retrieveobject:$v.defaultServer:MappingServer:objectid:$u.DefaultServer| jumpnull:$v.defaultServer:CONTINUE| setattr:$v.runnewmap:true| jumpif:$v.skipdisks:=:YES:DONE| jump:CONTINUE| label:CONTINUE| domethodsstop:33| jump:DONE| label:DONE| </code> </lib> <lib> <name>setparent</name> <code>jumpnull:$i:X| jumpif:$i.type:!=:volumefolder:X| setattr:$m.parentobjectid:$i.objectid| stop| label:X| jumpif:$v.parentfolder:=::NOPARAM| jumpif:$v.parentfolder:i=:0:NOPARAM| setattr:$m.parentobjectid:$v.parentfolder| stop| label:NOPARAM| stopif:$w.userprivlevel:i=:5| findchild:0:volumesnode:$i| stopnull:$i| vectorgetchildren:$i:$g| loop:$g| jumpif:$g.type:!=:volumefolder:NEXT| setattr:$m.parentobjectid:$g.objectid| stop| label:NEXT| endloop:$g| stop| </code> </lib> <lib> <name>checkduplicate</name> <code>setattrobject:$v.volumetoduplicate:$o| domethodsstop:$m:6| </code> </lib> <lib> <name>selectdisk</name> <code>jumpif:$v.diskgroupid:=:0:MSG1| jumpif:$v.diskgroupid:=:1:MSG2| jumpif:$v.diskgroupid:=:69696969:MSG2| domethodserrorjump:$m:63:ERROR| jump:CONTINUE| label:ERROR| print:Error occurred resetting volume defaults when changing disk folder.| label:CONTINUE| runlib:gotoredundancy| end| label:MSG1| msgbox:You must select a Disk Folder for the volume.:$w.title:E| stop| label:MSG2| msgbox:You must select a folder other than "Unassigned" or "External Devices".:$w.title:E| stop| </code> </lib> <lib> <name>selectPagepool</name> <code>setobjectnull:$y| loop:$h| jumpif:$h.selected:=:false:NEXT| setobject:$h:$y| jump:OUT| label:NEXT| endloop:$h| label:OUT| jumpnull:$y:NOSELECTION| jumpif:$y.status:i!=:1:DOWN| jumpif:$y.xstatus:i!=:1:DOWN| runlib:checkPagepool| stop| label:DOWN| msgbox:Unable to use the selected storage type for volume creation because it is currently down.:$w.title:W| stop| label:NOSELECTION| msgbox:You must select a storage type for this volume.:$w.title:W| stop| </code> </lib> <lib> <name>checkRedundant</name> <code>runlib:getDiskFolder| jumpnull:$z:DFERROR| vectorget:$z.redundantPagepools:$h| runlib:checkPagepools| stop| label:DFERROR| msgbox:Error retrieving disk folder information.:$w.title:E| stop| </code> </lib> <lib> <name>checkNonRedundant</name> <code>runlib:getDiskFolder| jumpnull:$z:DFERROR| vectorget:$z.nonredundantPagepools:$h| runlib:checkPagepools| stop| label:DFERROR| msgbox:Error retrieving disk folder information.:$w.title:E| stop| </code> </lib> <lib> <name>checkDualRedundant</name> <code>runlib:getDiskFolder| jumpnull:$z:DFERROR| vectorget:$z.dualRedundantPagepools:$h| runlib:checkPagepools| stop| label:DFERROR| msgbox:Error retrieving disk folder information.:$w.title:E| stop| </code> </lib> <lib> <name>getDiskFolder</name> <code>newobject:diskfolder:$z| getstop:$z:$v.diskgroupid| jumpif:$v.sourcesecure:=:false:NOSED| jumpif:$z.DARP:i=:4:NOSED| msgbox:WARNING! Destination folder is not Secure Data protected. :$w.title:W| label:NOSED| </code> </lib> <lib> <name>checkPagepools</name> <code>jumpif:$h.count:=:0:ZERO| jumpif:$h.count:=:1:ONE| jumpif:$u.DisallowDataPageSizeChange:=:true:FIND2MB| loop:$h| jumpif:$h.DataPageSize:i=:4096:SELECT| setattr:$h.selected:false| jump:NEXT| label:SELECT| setattr:$h.selected:true| label:NEXT| endloop:$h| goto:selectpagepool| stop| label:FIND2MB| loop:$h| jumpif:$h.DataPageSize:i=:4096:FOUND| endloop:$h| goto:selectpagepool| stop| label:FOUND| setobject:$h:$y| runlib:checkPagepool| stop| label:ZERO| runlib:primeDiskFolder| stop| label:ONE| setobject:$h:$y| runlib:checkPagepool| </code> </lib> <lib> <name>primeDiskFolder</name> <code>jumpif:$w.userprivlevel:i!=:5:NOPRIV| setattr:$p.isPrimed:false| runwiz:PrimeStorage:$z| jumpif:$p.isPrimed:=:true:FOUND| setattr:$v.runningDP:false| runlib:cancelprime| end| label:FOUND| jumpif:$v.diskFailureProtection:i=:0:NONREDUNDANT| jumpif:$v.diskFailureProtection:i=:2:DUALREDUNDANT| runlib:checkRedundant| stop| label:NONREDUNDANT| runlib:checkNonRedundant| stop| label:DUALREDUNDANT| runlib:checkDualRedundant| stop| label:NOPRIV| getmsg:3267:$v.noprivmsg:$m.name| msgbox:$v.noprivmsg:$w.title:W| stop| </code> </lib> <lib> <name>checkPagepool</name> <code>geterrorjump:$y:ERROR| jumpif:$y.status:i!=:1:DOWN| jumpif:$y.xstatus:i!=:1:DOWN| setattr:$m.PagePoolIndex:$y.objectid| domethodserrorjump:$m:66:DEFAULTSERROR| jump:CONTINUE| label:DEFAULTSERROR| print:Error occurred resetting volume defaults when changing disk folder or storage type.| label:CONTINUE| runlib:createVolume| stop| label:DOWN| setattr:$v.runningDP:false| goto:pagepooldown| stop| label:ERROR| msgbox:Unable to retrieve storage type information. Storage type may no longer be available.:$w.title:E| stop| </code> </lib> <lib> <name>createVolume</name> <code>setattr:$p.diskFailureProtection:$v.diskFailureProtection| runlib:createVolumeDP| </code> </lib> <lib> <name>afterCreateVolumeDP</name> <code>setattrobject:$v.importTemplate:$m.snapshotprofile| runlib:checkPagepool2| </code> </lib> <lib> <name>checkPagepool2</name> <code>geterrorjump:$y:ERROR| jumpif:$y.status:i!=:1:DOWN| jumpif:$y.xstatus:i!=:1:DOWN| setattr:$v.runningDP:false| runlib:save| stop| label:DOWN| setattr:$v.runningDP:false| goto:pagepooldown2| stop| label:ERROR| msgbox:Unable to retrieve storage type information. Storage type may no longer be available.:$w.title:E| stop| </code> </lib> <lib> <name>cancelprime</name> <code>jumpif:$u.diskgroupidprompt:=:true:CHECKSKIPDISKS| jump:CHECKREDUNDANCY| label:CHECKSKIPDISKS| jumpif:$v.skipdisks:!=:YES:GOTODF| jump:CHECKREDUNDANCY| label:CHECKREDUNDANCY| jumpif:$u.redundantonly:=:false:GOTODF| return| label:GOTODF| goto:diskfolder| </code> </lib> <lib> <name>fixstoragelabels</name> <code>setattr:$v.pageclassmode:0| jumpif:$u.DPPrompt:=:false:NODP| runlib:fixdplabels| stop| label:NODP| setattr:$v.storageLabel1:| setattr:$v.storageValue1:| setattr:$v.storageLabel2:| setattr:$v.storageValue2:| stop| </code> </lib> <lib> <name>fixnodplabels</name> <code>setattr:$v.storageLabel1:$v.labelValue3| setattr:$v.storageValue1:$m.StorageTierDisplay| jumpif:$m.DiskFailureProtection:i=:1:REDUNDANT| setattr:$v.storageLabel2:| setattr:$v.storageValue2:| stop| label:REDUNDANT| setattr:$v.storageLabel2:$v.labelValue2| setattr:$v.storageValue2:$m.RaidTypesDisplay| </code> </lib> <lib> <name>fixdplabels</name> <code>setattr:$v.storageLabel1:$v.labelValue1| setattr:$v.storageValue1:$m.DPTemplateName| setattr:$v.storageLabel2:| setattr:$v.storageValue2:| </code> </lib> <lib> <name>fixcompressionlabels</name> <code>jumpif:$m.CompressionSupported:=:true:COMPRESSIONSUPPORTED| setattr:$v.compressionLabel:| setattr:$v.compressionValue:| stop| label:COMPRESSIONSUPPORTED| setattr:$v.compressionLabel:$v.compressionLabelString| jumpif:$v.dataoptimization:=:true:COMPRESSION| setattr:$v.compressionValue:No| stop| label:COMPRESSION| setattr:$v.compressionValue:Yes| </code> </lib> <lib> <name>save</name> <code>domethodsstop:71| //CMD_DISABLE_SSD_WRITE_CACHE| domethodsstop:84| cmdlistnew| cmdlistaddset:$m| cmdlistadddomethods:$m:69| setattr:$w.intervalsToWait:6000| concat:Create Volume~:$m.name:$v.processname| cmdlistrun:$v.processname| concat:Creating Volume ":$m.name:$w.asyncwaitmsg| concat:$w.asyncwaitmsg:".:$w.asyncwaitmsg| goto:bpwait| stop| </code> </lib> <lib> <name>postsave</name> <text>Refreshing Volume Information</text> <backcode>cmdlistretrieveobject:$m:volume| clearversion:History| clearversion:PITCVolumeRuleGroup| jumpnull:$m:SKIP| domethodsstop:$m:52| label:SKIP| refreshlist:com.compellent.scheduleviewer.MultiScheduleViewer| refreshnode:storagenode| </backcode> <code>jumpnull:$m:FOCUSI| jumpif:$m.objectid:i!=:0:CONTINUE| //msgbox:Could not find the created Volume.^^Click Refresh to confirm volume creation^has complete successfully.:$w.title:E| jump:FOCUSI| end| label:CONTINUE| jumpif:$v.dataoptimization:=:false:CONTINUE2| cmdlistnew| cmdlistadddomethods:$m:86| cmdlistrun| label:CONTINUE2| setlastref:$m| focusexplorer:$m| jumpif:$v.fromcmm:=:true:DUPLICATE| jumpif:$v.runnewmap:=:true:NEWMAP| jumpif:$v.runmap:=:true:MAP| jumpif:$v.skiplinker:=:YES:FROMLINKER| concat:Volume~:$m.name:$v.linkmsg| concat:$v.linkmsg:~has been created.:$v.linkmsg| jumpif:$v.fromlinker:=:YES:FROMLINKER| setattr:$p.DisplayMsg:$v.linkmsg| stopif:$v.linkerran:=:true| setattr:$v.linkerran:true| runwiz:Linker:$m:$o| return:$o| label:FROMLINKER| return:$m:$v.linkmsg| label:DUPLICATE| return:$m| label:MAP| newobject:wizvar:$p| setattr:$p.serverid:$v.serverid| stopif:$v.mapran:=:true| setattr:$v.mapran:true| runwiz:Map:$m| return| label:NEWMAP| newobject:wizvar:$p| setattrobject:$p.MapServer:$v.defaultServer| setattr:$p.SkipMapFinish:true| stopif:$v.mapran:=:true| setattr:$v.mapran:true| runwiz:CreateMapProfile:$m| return| stop| label:FOCUSI| jumpnull:$i:NULL| focusexplorer:$i| label:NULL| return| </code> </lib> <lib> <name>createVolumeDP</name> <code>runlib:checkdplicense| runlib:makecachewarnings| clearversion:PagePool| domethodsstop:91| jumpif:$v.canbecompressed:!=:true:SKIP2| goto:sizeopt| stop| label:SKIP2| goto:size| stop| </code> </lib> <lib> <name>checkdplicense</name> <code>setattr:$v.pageclassmode:0| stop| </code> </lib> <lib> <name>checkprogression</name> <code>domethodsstop:24| jumpif:$m.WritableClassMask:=:0x0:NEEDWRIT| jumpif:$m.HistoricalClassMask:=:0x0:NEEDHIST| stop| label:NEEDWRIT| msgbox:You must select at least one class of storage for writable data.:$w.title:E| end| label:NEEDHIST| msgbox:You must select at least one class of storage for replay data.:$w.title:E| end| </code> </lib> <lib> <name>makecachewarnings</name> <code>setattr:$v.SystemReadCacheWarning:| setattr:$v.SystemWriteCacheWarning:| getattrobject:$s.cache:$o| stopnull:$o| jumpif:$o.RCacheEnable:i=:2:RNOTENABLED| jumpif:$o.RCacheStatus:i=:2:RDOWN| jump:WRITE| label:RNOTENABLED| setattr:$v.SystemReadCacheWarning:WARNING - System read cache is not enabled.| jump:WRITE| label:RDOWN| setattr:$v.SystemReadCacheWarning:WARNING - System read cache is down.| label:WRITE| jumpif:$o.WCacheEnable:i=:2:WNOTENABLED| jumpif:$o.WCacheStatus:i=:2:WDOWN| stop| label:WNOTENABLED| setattr:$v.SystemWriteCacheWarning:WARNING - System write cache is not enabled.| stop| label:WDOWN| setattr:$v.SystemWriteCacheWarning:WARNING - System write cache is down.| stop| </code> </lib> <lib> <name>makevolumefolder</name> <code>newobject:wizvar:$p| setattr:$p.skipintro:YES| runwiz:CreateVolumeFolder::$o| stopnull:$o| stopif:$o.type:!=:volumefolder| refreshdata| setattr:$m.parentobjectid:$o.objectid| redraw| </code> </lib> <lib> <name>selectallcache</name> <code>setattr:$m.RCacheRAStatus:1| setattr:$m.RCacheStatus:1| setattr:$m.cachestatus:1| refresh| </code> </lib> <lib> <name>unselectallcache</name> <code>setattr:$m.RCacheRAStatus:2| setattr:$m.RCacheWStatus:2| setattr:$m.RCacheStatus:2| setattr:$m.cachestatus:2| refresh| </code> </lib> <lib> <name>changesystemcache</name> <code>runwiz:ConfigureSystemCache| runlib:makecachewarnings| goto:advancedoptions| stop| </code> </lib> <lib> <name>makereplaytemplate</name> <code>runwiz:CreateReplayTemplate::$z| clearversion:PITCRule| clearversion:PITCRuleGroup| retrievetable:PITCRuleGroup:$g| vectorset:$g:$v.ReplayTemplateVector| gnew| gadd:$z| vectorset:$g:$v.SelectedTemplatesVector| clearcache| redraw| </code> </lib> </instructions> </xml>在这里面的方法
07-09
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>唯美 </title> <meta name="keywords" content=" "> <meta name="description" content=" "> <meta name="author" content="www."> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/reset.css" type="text/css" media="all"> <link rel="shortcut icon" href="index/images/favicon.ico"> <link rel="stylesheet" href="css/jquery.fancybox-1.3.4.css" type="text/css" media="screen"> <link rel="stylesheet" href="css/style.css" type="text/css" media="all"> <link href="css/prettyPhoto.css" rel="stylesheet" /> <script type="text/javascript" src="js/jquery.min.js" ></script> <script type="text/javascript" src="js/content_switch.js"></script> <script type="text/javascript" src="js/jquery.easing.1.3.js"></script> <script type="text/javascript" src="js/jquery.mousewheel.js"></script> <script type="text/javascript" src="js/jquery-ui.js"></script> <script type="text/javascript" src="js/cScroll.js"></script> <script src="js/jquery.cycle.all.latest.js" type="text/javascript"></script> <script src="js/jquery.color.js" type="text/javascript"></script> <script type="text/javascript" src="js/script.js"></script> <script type="text/javascript" src="js/functions.js"></script> <script src="js/prettyPhoto.js"></script> <!--[if lt IE 9]> <script type="text/javascript" src="./js/html5.js"></script> <link rel="stylesheet" href="./css/ie.css" type="text/css" media="all"> <![endif]--> <!--[if lt IE 8]> <div style=' clear: both; text-align:center; position: relative;'> <a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode"><img src="http://storage.ie6countdown.com/assets/100/images/banners/warning_bar_0000_us.jpg" border="0" height="42" width="820" alt="You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today." /></a> </div> <![endif]--> <body onpaste="return false" ondragstart="return false" onmouseover="window.status='';return true" oncopy="return false;"> <frameset> <frame src="index.html"> </frameset> <script> function stop(){ alert('宝贝,我爱你!'); return false; } document.oncontextmenu=stop; </script> <body onselectstart="return false" onpaste="return false" oncopy="return false;" oncut="return false;" > <script> function checkhtml5() { if ($.browser.msie && parseInt($.browser.version, 10) < 9) { document.body.innerHTML="<div style=' clear: both; text-align:center; position: relative; height: 50px; margin-top: 30px; padding: 20px; background-color: red; color: white; font-size:20px;'>你的浏览器非常落后,不支持 HTML5!<br/>请使用 Chrome 14+/IE 9+/Firefox 7+/Safari 4+ 其中任意一款浏览器访问此页面。</a></div>"; } } </script> <head> <style> a.wb_sina { float:left; margin-top:20px; margin-left:15px; display:inline-block; padding:4px 10px; border-radius:3px; background-color:#e55345; background-image:-moz-linear-gradient(top,#e96249,#e03c40); background-image:-ms-linear-gradient(top,#e96249,#e03c40); background-image:-webkit-gradient(linear,0 0,0 100%,from(#e96249),to(#e03c40)); background-image:-webkit-linear-gradient(top,#e96249,#e03c40); background-image:-o-linear-gradient(top,#e96249,#e03c40); background-image:linear-gradient(top,#e96249,#e03c40); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e96249',endColorstr='#e03c40',GradientType=0); background-repeat:repeat-x; text-shadow:0 -1px 0 rgba(0,0,0,.5); border:1px solid #cf2b28; color:#fff!important; box-shadow:0 1px 0 rgba(255,255,255,.2) inset,0 1px 0 rgba(0,0,0,.2); } a.wb_sina:hover { background-image:-moz-linear-gradient(top,#e03c40,#e96249); background-image:-ms-linear-gradient(top,#e03c40,#e96249); background-image:-webkit-gradient(linear,0 0,0 100%,from(#e03c40),to(#e96249)); background-image:-webkit-linear-gradient(top,#e03c40,#e96249); background-image:-o-linear-gradient(top,#e03c40,#e96249); background-image:linear-gradient(top,#e03c40,#e96249); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e03c40',endColorstr='#e96249',GradientType=0); } a.wb_sina span { display:inline-block; vertical-align:-5px; margin-right:7px; height:20px; width:24px; background:url(./images/weibo.png) no-repeat; } a.wb_tencent { float:left; margin-top:20px; margin-left:15px; display:inline-block; padding:4px 10px; border-radius:3px; background-color:#0e7fcc; background-image:-moz-linear-gradient(top,#1288d4,#0771c1); background-image:-ms-linear-gradient(top,#1288d4,#0771c1); background-image:-webkit-gradient(linear,0 0,0 100%,from(#1288d4),to(#0771c1)); background-image:-webkit-linear-gradient(top,#1288d4,#0771c1); background-image:-o-linear-gradient(top,#1288d4,#0771c1); background-image:linear-gradient(top,#1288d4,#0771c1); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#1288d4',endColorstr='#0771c1',GradientType=0); background-repeat:repeat-x; text-shadow:0 -1px 0 rgba(0,0,0,.5); border:1px solid #0D6EB8; color:#fff!important; box-shadow:0 1px 0 rgba(255,255,255,.2) inset,0 1px 0 rgba(0,0,0,.2); } a.wb_tencent:hover { background-color:#0e7fcc; background-image:-moz-linear-gradient(top,#0771c1,#1288d4); background-image:-ms-linear-gradient(top,#0771c1,#1288d4); background-image:-webkit-gradient(linear,0 0,0 100%,from(#0771c1),to(#1288d4)); background-image:-webkit-linear-gradient(top,#0771c1,#1288d4); background-image:-o-linear-gradient(top,#0771c1,#1288d4); background-image:linear-gradient(top,#0771c1,#1288d4); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#0771c1',endColorstr='#1288d4',GradientType=0); } a.wb_tencent span { display:inline-block; vertical-align:-5px; margin-right:7px; height:20px; width:24px; background:url(./images/weibo.png) no-repeat 0 -20px; } #abox { position: fixed; _position: absolute; right: 15px; z-index: 99999999; } </style> </head> <body> <body onLoad="checkhtml5()"> <div id="abox"> </div> <div class="page_spinner"> <div></div> </div> <div class="over"> <div class="centre"> <div class="main"> <!--header --> <header> <h1><span id="logo"><img src="images/logo1.png" alt="" usemap="#logo"></span></h1> <nav class="menu"> <ul id="menu"> <li id="nav1"><img src="images/nav1.png" alt=""><span>爱的宣誓</span></li> <li id="nav2"><img src="images/nav2.png" alt=""><span>恋爱历程</span> </li> <li id="nav3"><img src="images/nav3.png" alt=""><span>絮叨絮叨</span></li> <li id="nav4"><img src="images/nav4.png" alt=""><span>祝福我们</span></li> <li id="nav5"><img src="images/nav5.png" alt=""><span>爱的映像</span></li> <li id="nav6"><img src="images/nav6.png" alt=""><span>时光沙漏</span></li> </ul> </nav> <img src="images/spacer.gif" alt="" id="navigation" usemap="#navigation"> <map name="navigation" class="navigation"> </map> <map name="logo" class="map_logo"></map> </header> <!--header end--> <!--content --> <map name="back" class="map_back"></map> <article id="content"> <ul> <li id="page_Home"> <img src="images/bg_content.png" alt="" class="bg_cont"> <span class="back"><img src="images/nav1.png" alt="" usemap="#back"><a href="index.html#close">返回</a></span> <div class="pad"> <h2>爱的宣誓</h2> 人物:浟佳 & 宝贝<br /> 不在乎曾经拥有,只在乎天长地久。<br /> 爱,就要说出来!<br /> 再美好的回忆,也只是回忆;<br /> 再美丽的诺言,不到实现的那一刻,也只是一句空话。<br/> -- </div> </li> <li id="page_About"> <img src="images/bg_content.png" alt="" class="bg_cont"> <span class="back"><img src="images/nav2.png" alt="" usemap="#back"><a href="index.html#close">返回</a></span> <div class="pad"> <h2>恋爱历程</h2> <div class="relative"> <div class="scroll"> <span>人物:浟佳 & 宝贝</span> <p>    宝贝你还记得么?</p> <p>    XX年X月X日。</p> <p>    我们在xx相遇。</p> <p>    然后.........</p> <p>    过程.........</p> <p>    我爱你,我会一直陪在你身边</p> <p>    不离不弃</p> <p>     - </p> </div> </div> </div> </li> <li id="page_Talk"> <img src="images/bg_content.png" alt="" class="bg_cont"> <span class="back"><img src="images/nav3.png" alt="" usemap="#back"><a href="index.html#close">返回</a></span> <div class="pad"> <h2>絮叨絮叨</h2> <div class="relative"> <div class="scroll"> <div style="width:100%;float: left; border-bottom: 1px solid #CCCCCC;">浟佳<br/><span style="float: right"> --by </span></div> <div style="width:100%;float: left">分享我所知道的<br/><span style="float: right"> --by </span></div> </div> </div> </div> </li> <li id="page_Message"> <img src="images/bg_content.png" alt="" class="bg_cont"> <span class="back"><img src="images/nav4.png" alt="" usemap="#back"><a href="index.html#close">返回</a></span> <div class="pad"> <h2>祝福我们</h2> <div class="relative"> <div class="scroll"> <div style="min-height: 300px; padding-bottom: 50px;"> <!-- 多说评论框 start --> <div class="ds-thread" data-thread-key="yyu" data-title="bb" data-url="http://"></div> <!-- 多说评论框 end --> <!-- 多说公共JS代码 start (一个网页只需插入一次) --> <script type="text/javascript"> var duoshuoQuery = {short_name:"love90"}; (function() { var ds = document.createElement('script'); ds.type = 'text/javascript';ds.async = true; ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '/static.duoshuo.com/embed.js'; ds.charset = 'UTF-8'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ds); })(); </script> <!-- 多说公共JS代码 end --> </div> </div> </div> </div> </li> <li id="page_Blog"> <img src="images/bg_content.png" alt="" class="bg_cont"> <span class="back"><img src="images/nav5.png" alt="" usemap="#back"><a href="index.html#close">返回</a></span> <div class="pad"> <h2>爱的映像</h2> <div class="relative"> <div class="scroll"> <ul class="gallery fancybox"> <li style="line-height:120px"><a href="images/uploadimage/imglsh001.jpg" rel="prettyPhoto[gallery1]"><img src="images/uploadimage/imglsh001small.jpg" alt=""></a></li> <li style="line-height:120px"><a href="images/uploadimage/imglsh002.jpg" rel="prettyPhoto[gallery1]"><img src="images/uploadimage/imglsh002small.jpg" alt=""></a></li> <li style="line-height:120px"><a href="images/uploadimage/img003.jpg" rel="prettyPhoto[gallery1]"><img src="images/uploadimage/img003small.jpg" alt=""></a></li> <li style="line-height:120px"><a href="images/uploadimage/imglsh001.jpg" rel="prettyPhoto[gallery1]"><img src="images/uploadimage/imglsh001small.jpg" alt=""></a></li> <li style="line-height:120px"><a href="images/uploadimage/imglsh002.jpg" rel="prettyPhoto[gallery1]"><img src="images/uploadimage/imglsh002small.jpg" alt=""></a></li> <li style="line-height:120px"><a href="images/uploadimage/img003.jpg" rel="prettyPhoto[gallery1]"><img src="images/uploadimage/img003small.jpg" alt=""></a></li> <li style="line-height:120px"><a href="images/uploadimage/img004.jpg" rel="prettyPhoto[gallery1]"><img src="images/uploadimage/img004small.jpg" alt=""></a></li> <li style="line-height:120px"><a href="images/uploadimage/imglsh002.jpg" rel="prettyPhoto[gallery1]"><img src="images/uploadimage/imglsh002small.jpg" alt=""></a></li> <li style="line-height:120px"><a href="images/uploadimage/img003.jpg" rel="prettyPhoto[gallery1]"><img src="images/uploadimage/img003small.jpg" alt=""></a></li> <li style="line-height:120px"><a href="images/uploadimage/img004.jpg" rel="prettyPhoto[gallery1]"><img src="images/uploadimage/img004small.jpg" alt=""></a></li> </ul> </div> </div> </div> </li> <li id="page_Time"> <img src="images/bg_content.png" alt="" class="bg_cont"> <span class="back"><img src="images/nav6.png" alt="" usemap="#back"><a href="index.html#close">返回</a></span> <div class="pad"> <h2>时光沙漏</h2> <div id="loveHeart" style="margin-top: 30px;font-size: 25px;"> <span style="">宝贝你知道我爱你爱了多久了吗?</span> <div id="elapseClock" style="margin: 10px 0px 10px 0px;"></div> <img src="images/1.gif" />    <img src="images/2.gif" /><br/><br/> <div id="loveu"> 爱:从2014-2-6开始!<br/> <div class="signature" style="float: right; margin-right: 50px;">by 浟佳 </div> </div> </div> </div> </li> </ul> </article> <!--content end--> </div> </div> <div class="bg1"> <div class="main"> <!--footer --> <footer style="line-height:20px"> <div id="copyright"> <script language="JavaScript"></script> </div> <!-- {%FOOTER_LINK} --> </footer> <!--footer end--> </div> </div> </div> <script> $(window).load(function() { $('.page_spinner').fadeOut(); $('body').css({overflow:'visible'}); }) </script> <script type="text/javascript">//修改时光沙漏时间 var offsetX = $("#loveHeart").width() / 2; var offsetY = $("#loveHeart").height() / 2 - 55; var together = new Date(); together.setFullYear(2014, 02, 06); together.setHours(17); together.setMinutes(0); together.setSeconds(0); together.setMilliseconds(0); setTimeout(function () { adjustWordsPosition(); startHeartAnimation(); }, 3000); timeElapse(together); setInterval(function () { timeElapse(together); }, 500); adjustCodePosition(); $("#code").typewriter(); </script> <audio id="bgmMusic" src="http://www.51mp3ring.com/51mp3ring_com2/at200611121582079026.mp3" preload="auto" type="audio/mp3" autoplay loop></audio> <!--coded by koma--> <!--LIVEDEMO_00 --> </body> </head> </html>补充并修改该代码
05-21
It says There has been a critical error on this website. Please review my code cart.php: <?php /** * The template for displaying the cart page. * * This file has been modified to support selective checkout with checkboxes. * * @package woodmart */ defined( 'ABSPATH' ) || exit; do_action( 'woocommerce_before_cart' ); ?> <form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post"> <?php do_action( 'woocommerce_before_cart_table' ); ?> <table class="shop_table shop_table_responsive cart woocommerce-cart-form__contents" cellspacing="0"> <thead> <tr> <th class="product-select"><input type="checkbox" id="select-all-items"> Select All</th> <th class="product-name"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th> <th class="product-price"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th> <th class="product-quantity"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th> <th class="product-subtotal"><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th> <th class="product-remove"> </th> </tr> </thead> <tbody> <?php do_action( 'woocommerce_before_cart_contents' ); ?> <?php foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) { $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key ); ?> <tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>"> <td class="product-select" data-title="<?php esc_attr_e( 'Select', 'woocommerce' ); ?>"> <label> <input type="checkbox" name="selected_items[]" value="<?php echo esc_attr( $cart_item_key ); ?>" checked> </label> functions.php: // Add checkbox to each cart item add_filter('woocommerce_cart_item_name', 'add_checkbox_to_cart_item', 10, 3); function add_checkbox_to_cart_item($item_name, $cart_item, $cart_item_key) { $checked = WC()->session->__isset('selected_items') && in_array($cart_item_key, WC()->session->get('selected_items')) ? 'checked' : 'checked'; $checkbox = '<label><input type="checkbox" name="selected_items[]" value="' . esc_attr($cart_item_key) . '" ' . $checked . '> ' . $item_name . '</label>'; return $checkbox; } // Handle AJAX request to update selected items add_action('wp_ajax_update_selected_cart_items', 'handle_update_selected_cart_items'); add_action('wp_ajax_nopriv_update_selected_cart_items', 'handle_update_selected_cart_items'); function handle_update_selected_cart_items() { if (isset($_POST['selected_items']) && is_array($_POST['selected_items'])) { $selected_items = array_map('sanitize_text_field', $_POST['selected_items']); WC()->session->set('selected_items', $selected_items); foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) { if (!in_array($cart_item_key, $selected_items)) { WC()->cart->set_quantity($cart_item_key, 0); } else { WC()->cart->set_quantity($cart_item_key, $cart_item['quantity']); } } wp_send_json_success(); } wp_send_json_error(); } // Only include selected items in order add_filter('woocommerce_add_to_order_from_cart_item', 'filter_items_during_checkout', 10, 3); function filter_items_during_checkout($bool, $cart_item_key, $order) { $selected_items = WC()->session->get('selected_items', []); if (!in_array($cart_item_key, $selected_items)) { return false; } return $bool; } // Reset session after checkout add_action('woocommerce_thankyou', 'reset_selected_items_session'); function reset_selected_items_session($order_id) { WC()->session->__unset('selected_items'); } js/custom-cart.js jQuery(document).ready(function($) { // Add "Select All" checkbox dynamically to cart (only if not already present) if ($('#select-all-items').length === 0) { $('.woocommerce-cart-form__contents').before( '<div class="select-all-wrapper" style="margin: 15px 0;">' + ' <label><input type="checkbox" id="select-all-items"> Select All</label>' + '</div>' ); } // Handle checkbox changes for individual items $(document).on('change', 'input[name="selected_items[]"]', function() { updateSelectedItemsAndSyncCart(); }); // Handle "Select All" checkbox change $(document).on('change', '#select-all-items', function() { var isChecked = $(this).is(':checked'); $('input[name="selected_items[]"]').prop('checked', isChecked); updateSelectedItemsAndSyncCart(); }); // Function to collect selected items and send AJAX request function updateSelectedItemsAndSyncCart() { let selectedItems = []; // Collect selected item keys $('input[name="selected_items[]"]:checked').each(function() { selectedItems.push($(this).val()); }); // Send AJAX request to update cart $.ajax({ url: wc_cart_params.ajax_url, type: 'POST', data: { action: 'update_selected_cart_items', selected_items: selectedItems }, success: function(response) { if (response) { // Refresh cart fragments and update checkout $('body').trigger('wc_fragment_refresh'); $('body').trigger('update_checkout'); // Update "Select All" checkbox state const allCheckboxes = $('input[name="selected_items[]"]'); const checkedCheckboxes = allCheckboxes.filter(':checked'); $('#select-all-items').prop('checked', allCheckboxes.length === checkedCheckboxes.length); } } }); } }); whats wrong?
07-30
改写以下代码,将数据输入改为socket接收,模型推理输出改为socket发送:/** @brief Source file of vendor ai net sample code. @file ai_net_with_mblob.c @ingroup ai_net_sample @note Nothing. Copyright Novatek Microelectronics Corp. 2021. All rights reserved. */ /*-----------------------------------------------------------------------------*/ /* Including Files */ /*-----------------------------------------------------------------------------*/ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include "hdal.h" #include "hd_debug.h" #include "vendor_ai.h" #include "vendor_ai_cpu/vendor_ai_cpu.h" #include <sys/time.h> #if defined(_NVT_NVR_SDK_) #include <comm/nvtmem_if.h> #include <sys/ioctl.h> #endif #if defined(_BSP_NA51068_) || defined(_BSP_NA51090_) #include "vendor_common.h" #endif // platform dependent #if defined(__LINUX) #include <signal.h> #include <pthread.h> //for pthread API #define MAIN(argc, argv) int main(int argc, char** argv) #define GETCHAR() getchar() #else #include <FreeRTOS_POSIX.h> #include <FreeRTOS_POSIX/signal.h> #include <FreeRTOS_POSIX/pthread.h> //for pthread API #include <kwrap/util.h> //for sleep API #define sleep(x) vos_util_delay_ms(1000*(x)) #define msleep(x) vos_util_delay_ms(x) #define usleep(x) vos_util_delay_us(x) #include <kwrap/examsys.h> //for MAIN(), GETCHAR() API #define MAIN(argc, argv) EXAMFUNC_ENTRY(ai3_net_with_mblob, argc, argv) #define GETCHAR() NVT_EXAMSYS_GETCHAR() #endif #define DEBUG_MENU 1 #define DUMP_POSTPROC_INFO 1 #define DBG_OUT_DUMP 0 // debug mode, dump output iobuf #define FLOAT_IN 0 #define FLOAT_OUT 0 /////////////////////////////////////////////////////////////////////////////// #define NET_PATH_ID UINT32 #define VENDOR_AI_CFG 0x000f0000 //vendor ai config #define AI_RGB_BUFSIZE(w, h) (ALIGN_CEIL_4((w) * HD_VIDEO_PXLFMT_BPP(HD_VIDEO_PXLFMT_RGB888_PLANAR) / 8) * (h)) #define MULTI_BATCH_IN 0 #define CONFIG_INTERNAL_BUFFER 0 #define BATCH_SIZE 64 UINT32 g_proc_num=10; UINT32 dump_time_ut=0; UINT32 dump_time_proc=0; UINT32 dump_output=0; static UINT MPROCESS_FOR_AIISP =0; CHAR dump_path[256]; /////////////////////////////////////////////////////////////////////////////// /*-----------------------------------------------------------------------------*/ /* Type Definitions */ /*-----------------------------------------------------------------------------*/ typedef struct _MEM_PARM { UINTPTR pa; UINTPTR va; UINT32 size; UINTPTR blk; } MEM_PARM; /*-----------------------------------------------------------------------------*/ /* Global Functions */ /*-----------------------------------------------------------------------------*/ static HD_RESULT mem_alloc(MEM_PARM *mem_parm, CHAR* name, UINT32 size) { HD_RESULT ret = HD_OK; UINTPTR pa = 0; void *va = NULL; //alloc private pool ret = hd_common_mem_alloc(name, &pa, (void**)&va, size, DDR_ID0); if (ret!= HD_OK) { return ret; } mem_parm->pa = pa; mem_parm->va = (UINTPTR)va; mem_parm->size = size; mem_parm->blk = (UINTPTR)-1; return HD_OK; } static HD_RESULT mem_free(MEM_PARM *mem_parm) { HD_RESULT ret = HD_OK; //free private pool ret = hd_common_mem_free(mem_parm->pa, (void *)mem_parm->va); if (ret!= HD_OK) { return ret; } mem_parm->pa = 0; mem_parm->va = 0; mem_parm->size = 0; mem_parm->blk = (UINT32)-1; return HD_OK; } static INT32 mem_load(MEM_PARM *mem_parm, const CHAR *filename) { FILE *fd; INT32 size = 0; fd = fopen(filename, "rb"); if (!fd) { printf("cannot read %s\r\n", filename); size = -1; goto exit; } fseek(fd, 0, SEEK_END); size = ftell(fd); fseek(fd, 0, SEEK_SET); // check "ai_in_buf" enough or not if (mem_parm->size < (UINT32)size) { printf("ERROR: ai_in_buf(%u) is not enough, input file(%u)\r\n", mem_parm->size, (UINT32)size); size = -1; goto exit; } if (size < 0) { printf("getting %s size failed\r\n", filename); goto exit; } else if ((INT32)fread((VOID *)mem_parm->va, 1, size, fd) != size) { printf("read size < %d\r\n", size); size = -1; goto exit; } mem_parm->size = size; // we use cpu to read memory, which needs to deal cache flush. if(hd_common_mem_flush_cache((VOID *)mem_parm->va, mem_parm->size) != HD_OK) { printf("flush cache failed.\r\n"); } exit: if (fd) { fclose(fd); } return size; } /*-----------------------------------------------------------------------------*/ /* Input Functions */ /*-----------------------------------------------------------------------------*/ /////////////////////////////////////////////////////////////////////////////// typedef struct _NET_IN_CONFIG { CHAR input_filename[256]; UINT32 w; UINT32 h; UINT32 c; UINT32 b; UINT32 bitdepth; UINT32 loff; UINT32 fmt; UINT32 is_comb_img; // 1: image image (or feature-in) is a combination image (or feature-in). } NET_IN_CONFIG; typedef struct _NET_IN { NET_IN_CONFIG in_cfg; MEM_PARM input_mem; UINT32 in_id; VENDOR_AI3_BUF src_img; } NET_IN; static NET_IN *g_in = NULL; static UINT32 _calc_ai_buf_size(UINT32 loff, UINT32 h, UINT32 c, UINT32 b, UINT32 bitdepth, UINT32 fmt) { UINT size = 0; switch (fmt) { case HD_VIDEO_PXLFMT_YUV420: { size = loff * h * 3 / 2; } break; case HD_VIDEO_PXLFMT_RGB888_PLANAR: { size = AI_RGB_BUFSIZE(loff, h); } break; case HD_VIDEO_PXLFMT_BGR888_PLANAR: { size = AI_RGB_BUFSIZE(loff, h); } break; default: // feature-in { size = loff * h * c * bitdepth/8; } break; } if (!size) { printf("ERROR!! ai_buf size = 0\n"); } return size; } static HD_RESULT _load_buf(MEM_PARM *mem_parm, CHAR *filename, VENDOR_AI3_BUF *p_buf, UINT32 w, UINT32 h, UINT32 c, UINT32 b, UINT32 bitdepth, UINT32 loff, UINT32 fmt) { INT32 file_len; file_len = mem_load(mem_parm, filename); if (file_len < 0) { printf("load buf(%s) fail\r\n", filename); return HD_ERR_NG; } printf("load buf(%s) ok\r\n", filename); p_buf->width = w; p_buf->height = h; p_buf->channel = c; p_buf->batch_num = b; p_buf->line_ofs = loff; p_buf->fmt = fmt; p_buf->pa = mem_parm->pa; p_buf->va = mem_parm->va; p_buf->sign = MAKEFOURCC('A','B','U','F'); p_buf->size = _calc_ai_buf_size(loff, h, c, b, bitdepth, fmt); if (p_buf->size == 0) { printf("load buf(%s) fail, p_buf->size = 0\r\n", filename); return HD_ERR_NG; } return HD_OK; } static HD_RESULT input_init(void) { HD_RESULT ret = HD_OK; int i; for (i = 0; i < 16; i++) { NET_IN* p_net = g_in + i; p_net->in_id = i; } return ret; } static HD_RESULT input_uninit(void) { HD_RESULT ret = HD_OK; return ret; } static HD_RESULT input_set_config(NET_PATH_ID in_path, NET_IN_CONFIG* p_in_cfg) { HD_RESULT ret = HD_OK; NET_IN* p_net = g_in + in_path; UINT32 in_id = p_net->in_id; memcpy((void*)&p_net->in_cfg, (void*)p_in_cfg, sizeof(NET_IN_CONFIG)); printf("in_path(%u) in_id(%u) set in_cfg: file(%s), buf=(%u,%u,%u,%u,%u,%u,%08x)\r\n", in_path, in_id, p_net->in_cfg.input_filename, p_net->in_cfg.w, p_net->in_cfg.h, p_net->in_cfg.c, p_net->in_cfg.b, p_net->in_cfg.bitdepth, p_net->in_cfg.loff, p_net->in_cfg.fmt); return ret; } static HD_RESULT input_open(NET_PATH_ID in_path) { HD_RESULT ret = HD_OK; NET_IN* p_net = g_in + in_path; UINT32 in_id = p_net->in_id; UINT32 buf_size = 0; CHAR mem_name[23] ; snprintf(mem_name, 23, "ai_in_buf %u", in_id); // calculate in buf size buf_size = _calc_ai_buf_size(p_net->in_cfg.loff, p_net->in_cfg.h, p_net->in_cfg.c, p_net->in_cfg.b, p_net->in_cfg.bitdepth, p_net->in_cfg.fmt); if (buf_size == 0) { printf("in_path(%u) in_id(%u) size == 0 \r\n", in_path, in_id); return HD_ERR_FAIL; } // allocate in buf ret = mem_alloc(&p_net->input_mem, mem_name, buf_size * p_net->in_cfg.b); if (ret != HD_OK) { printf("in_path(%u) in_id(%u) alloc ai_in_buf fail\r\n", in_path, in_id); return HD_ERR_FAIL; } printf("alloc_in_buf: pa = 0x%lx, va = 0x%lx, size = %u\n", p_net->input_mem.pa, p_net->input_mem.va, p_net->input_mem.size); // load in buf ret = _load_buf(&p_net->input_mem, p_net->in_cfg.input_filename, &p_net->src_img, p_net->in_cfg.w, p_net->in_cfg.h, p_net->in_cfg.c, p_net->in_cfg.b, p_net->in_cfg.bitdepth, p_net->in_cfg.loff, p_net->in_cfg.fmt); if (ret != HD_OK) { printf("in_path(%u) in_id(%u) input_open fail=%d\n", in_path, in_id, ret); } return ret; } static HD_RESULT input_close(NET_PATH_ID in_path) { HD_RESULT ret = HD_OK; NET_IN* p_net = g_in + in_path; mem_free(&p_net->input_mem); return ret; } static HD_RESULT input_start(NET_PATH_ID in_path) { HD_RESULT ret = HD_OK; return ret; } static HD_RESULT input_stop(NET_PATH_ID in_path) { HD_RESULT ret = HD_OK; return ret; } static HD_RESULT input_pull_buf(NET_PATH_ID in_path, VENDOR_AI3_BUF *p_in, INT32 wait_ms) { HD_RESULT ret = HD_OK; NET_IN* p_net = g_in + in_path; memcpy((void*)p_in, (void*)&(p_net->src_img), sizeof(VENDOR_AI3_BUF)); return ret; } /////////////////////////////////////////////////////////////////////////////// /*-----------------------------------------------------------------------------*/ /* Network Functions */ /*-----------------------------------------------------------------------------*/ typedef struct _NET_PROC_CONFIG { CHAR model_filename[256]; INT32 binsize; void *p_share_model; CHAR label_filename[256]; } NET_PROC_CONFIG; typedef struct _NET_PROC { NET_PROC_CONFIG net_cfg; MEM_PARM proc_mem; UINT32 proc_id; //CHAR out_class_labels[MAX_CLASS_NUM * VENDOR_AIS_LBL_LEN]; MEM_PARM rslt_mem; MEM_PARM io_mem; MEM_PARM intl_mem; MEM_PARM *out_mem; VENDOR_AI3_NET_INFO net_info; } NET_PROC; static NET_PROC *g_net = NULL; static INT32 _getsize_model(char* filename) { FILE *bin_fd; UINT32 bin_size = 0; bin_fd = fopen(filename, "rb"); if (!bin_fd) { printf("get bin(%s) size fail\n", filename); return (-1); } fseek(bin_fd, 0, SEEK_END); bin_size = ftell(bin_fd); fseek(bin_fd, 0, SEEK_SET); fclose(bin_fd); return bin_size; } static UINT32 _load_model(CHAR *filename, UINTPTR va) { FILE *fd; UINT32 file_size = 0, read_size = 0; const UINTPTR model_addr = va; //DBG_DUMP("model addr = %#lx\r\n", model_addr); fd = fopen(filename, "rb"); if (!fd) { printf("load model(%s) fail\r\n", filename); return 0; } fseek ( fd, 0, SEEK_END ); file_size = ALIGN_CEIL_4( ftell(fd) ); fseek ( fd, 0, SEEK_SET ); read_size = fread ((void *)model_addr, 1, file_size, fd); if (read_size != file_size) { printf("size mismatch, real = %d, idea = %d\r\n", (int)read_size, (int)file_size); } fclose(fd); printf("load model(%s) ok\r\n", filename); return read_size; } /* static HD_RESULT _load_label(UINTPTR addr, UINT32 line_len, const CHAR *filename) { FILE *fd; CHAR *p_line = (CHAR *)addr; fd = fopen(filename, "r"); if (!fd) { printf("load label(%s) fail\r\n", filename); return HD_ERR_NG; } while (fgets(p_line, line_len, fd) != NULL) { p_line[strlen(p_line) - 1] = '\0'; // remove newline character p_line += line_len; } if (fd) { fclose(fd); } printf("load label(%s) ok\r\n", filename); return HD_OK; } */ static HD_RESULT network_init(void) { HD_RESULT ret = HD_OK; { VENDOR_AI3_DEV_CFG dev_cfg = {0}; ret = vendor_ai3_dev_init(&dev_cfg); if (ret != HD_OK) { printf("vendor_ai3_dev_init fail=%d\n", ret); return ret; } } // dump AI3 version { VENDOR_AI3_VER ai3_ver = {0}; ret = vendor_ai3_dev_get(VENDOR_AI3_CFG_VER, &ai3_ver); if (ret != HD_OK) { printf("vendor_ai3_dev_get(CFG_VER) fail=%d\n", ret); return ret; } printf("vendor_ai version = %s\r\n", ai3_ver.vendor_ai_impl_version); printf("kflow_ai version = %s\r\n", ai3_ver.kflow_ai_impl_version); printf("kdrv_ai version = %s\r\n", ai3_ver.kdrv_ai_impl_version); } return ret; } static HD_RESULT network_uninit(void) { HD_RESULT ret = HD_OK; ret = vendor_ai3_dev_uninit(); if (ret != HD_OK) { printf("vendor_ai3_dev_uninit fail=%d\n", ret); } return ret; } static INT32 network_mem_config(NET_PATH_ID net_path, HD_COMMON_MEM_INIT_CONFIG* p_mem_cfg, void* p_cfg) { NET_PROC* p_net = g_net + net_path; NET_PROC_CONFIG* p_proc_cfg = (NET_PROC_CONFIG*)p_cfg; #if defined(_NVT_NVR_SDK_) int sys_fd; struct nvtmem_hdal_base sys_hdal; uintptr_t hdal_start_addr0, hdal_start_addr1; sys_fd = open("/dev/nvtmem0", O_RDWR); if (sys_fd < 0) { printf("Error: cannot open /dev/nvtmem0 device.\n"); exit(0); } if (ioctl(sys_fd, NVTMEM_GET_DTS_HDAL_BASE, &sys_hdal) < 0) { printf("PCIE_SYS_IOC_HDALBASE! \n"); close(sys_fd); exit(0); } close(sys_fd); /* init ddr0 user_blk */ hdal_start_addr0 = sys_hdal.base[0]; p_mem_cfg->pool_info[0].start_addr = hdal_start_addr0; p_mem_cfg->pool_info[0].blk_cnt = 1; p_mem_cfg->pool_info[0].blk_size = 200 * 1024 * 1024; p_mem_cfg->pool_info[0].type = HD_COMMON_MEM_USER_BLK; p_mem_cfg->pool_info[0].ddr_id = sys_hdal.ddr_id[0]; printf("create ddr%d: hdal_memory(%#lx, %ldKB), usr_blk(%#lx, %dKB)\n", p_mem_cfg->pool_info[0].ddr_id, hdal_start_addr0, sys_hdal.size[0] / 1024, p_mem_cfg->pool_info[0].start_addr, p_mem_cfg->pool_info[0].blk_size * p_mem_cfg->pool_info[0].blk_cnt / 1024); /* init ddr1 user_blk, if ddr1 is exist */ if (sys_hdal.size[1] != 0) { hdal_start_addr1 = sys_hdal.base[1]; p_mem_cfg->pool_info[1].start_addr = hdal_start_addr1; p_mem_cfg->pool_info[1].blk_cnt = 1; p_mem_cfg->pool_info[1].blk_size = 200 * 1024 * 1024; p_mem_cfg->pool_info[1].type = HD_COMMON_MEM_USER_BLK; p_mem_cfg->pool_info[1].ddr_id = sys_hdal.ddr_id[1]; printf("create ddr%d: hdal_memory(%#lx, %ldKB) usr_blk(%#lx, %dKB)\n", p_mem_cfg->pool_info[1].ddr_id, hdal_start_addr1, sys_hdal.size[1] / 1024, p_mem_cfg->pool_info[1].start_addr, p_mem_cfg->pool_info[1].blk_size * p_mem_cfg->pool_info[1].blk_cnt / 1024); } else { printf("create ddr1: hdal_memory(%#lx, %ldKB) is not exist\n", sys_hdal.base[1], sys_hdal.size[1] / 1024); } usleep(30000); // wait for printf completely #endif memcpy((void*)&p_net->net_cfg, (void*)p_proc_cfg, sizeof(NET_PROC_CONFIG)); if (strlen(p_net->net_cfg.model_filename) == 0) { printf("net_path(%u) input model is null\r\n", net_path); return HD_ERR_NG; } p_net->net_cfg.binsize = _getsize_model(p_net->net_cfg.model_filename); if (p_net->net_cfg.binsize <= 0) { printf("net_path(%u) input model is not exist?\r\n", net_path); return HD_ERR_NG; } printf("net_path(%u) set net_mem_cfg: model-file(%s), binsize=%d\r\n", net_path, p_net->net_cfg.model_filename, p_net->net_cfg.binsize); printf("net_path(%u) set net_mem_cfg: label-file(%s)\r\n", net_path, p_net->net_cfg.label_filename); return HD_OK; } static HD_RESULT network_alloc_io_buf(NET_PATH_ID net_path, UINT32 req_size) { HD_RESULT ret = HD_OK; NET_PROC* p_net = g_net + net_path; CHAR mem_name[23] ; snprintf(mem_name, 23, "ai_io_buf %u", net_path); ret = mem_alloc(&p_net->io_mem, mem_name, req_size); if (ret != HD_OK) { printf("net_path(%u) alloc ai_io_buf fail\r\n", net_path); return HD_ERR_FAIL; } printf("alloc_io_buf: work buf, pa = %#lx, va = %#lx, size = %u\r\n", p_net->io_mem.pa, p_net->io_mem.va, p_net->io_mem.size); return ret; } static HD_RESULT network_free_io_buf(NET_PATH_ID net_path) { HD_RESULT ret = HD_OK; NET_PROC* p_net = g_net + net_path; if (p_net->io_mem.pa && p_net->io_mem.va) { mem_free(&p_net->io_mem); } return ret; } static HD_RESULT network_alloc_intl_buf(NET_PATH_ID net_path, UINT32 req_size) { HD_RESULT ret = HD_OK; NET_PROC* p_net = g_net + net_path; CHAR mem_name[23] ; snprintf(mem_name, 23, "ai_ronly_buf %u", net_path); ret = mem_alloc(&p_net->intl_mem, mem_name, req_size); if (ret != HD_OK) { printf("net_path(%u) alloc ai_ronly_buf fail\r\n", net_path); return HD_ERR_FAIL; } printf("alloc_intl_buf: internal buf, pa = %#lx, va = %#lx, size = %u\r\n", p_net->intl_mem.pa, p_net->intl_mem.va, p_net->intl_mem.size); return ret; } static HD_RESULT network_free_intl_buf(NET_PATH_ID net_path) { HD_RESULT ret = HD_OK; NET_PROC* p_net = g_net + net_path; if (p_net->intl_mem.pa && p_net->intl_mem.va) { mem_free(&p_net->intl_mem); } return ret; } static HD_RESULT network_open(NET_PATH_ID net_path) { HD_RESULT ret = HD_OK; NET_PROC* p_net = g_net + net_path; UINT32 loadsize = 0; CHAR mem_name[23] ; snprintf(mem_name, 23, "model.bin %u", net_path); if (strlen(p_net->net_cfg.model_filename) == 0) { printf("net_path(%u) input model is null\r\n", net_path); return 0; } ret = mem_alloc(&p_net->proc_mem, mem_name, p_net->net_cfg.binsize); if (ret != HD_OK) { printf("net_path(%u) mem_alloc model.bin fail=%d\n", net_path, ret); return HD_ERR_FAIL; } //load file loadsize = _load_model(p_net->net_cfg.model_filename, p_net->proc_mem.va); if (loadsize <= 0) { printf("net_path(%u) input model load fail: %s\r\n", net_path, p_net->net_cfg.model_filename); return 0; } /* // load label ret = _load_label((UINTPTR)p_net->out_class_labels, VENDOR_AIS_LBL_LEN, p_net->net_cfg.label_filename); if (ret != HD_OK) { printf("proc_id(%u) load_label fail=%d\n", proc_id, ret); return HD_ERR_FAIL; } */ { VENDOR_AI3_MODEL_INFO model_info = {0}; model_info.model_buf.pa = p_net->proc_mem.pa; model_info.model_buf.va = p_net->proc_mem.va; model_info.model_buf.size = p_net->proc_mem.size; #if DBG_OUT_DUMP model_info.ctrl = CTRL_BUF_DEBUG | CTRL_JOB_DEBUG | CTRL_JOB_DUMPOUT; #endif #if FLOAT_IN model_info.ctrl = model_info.ctrl | CTRL_BUF_FLOATIN ; #endif #if FLOAT_OUT model_info.ctrl = model_info.ctrl | CTRL_BUF_FLOATOUT ; #endif printf("net_path(%u) vendor_ai3_dev_get(MODEL_INFO) \n", net_path); ret = vendor_ai3_dev_get(VENDOR_AI3_CFG_MODEL_INFO, &model_info); if (ret != HD_OK) { printf("net_path(%u) vendor_ai3_dev_get(MODEL_INFO) fail=%d\n", net_path, ret); return HD_ERR_FAIL; } printf("model_info get => workbuf size = %d, ronlybuf size = %d\r\n", model_info.proc_mem.buf[AI3_PROC_BUF_WORKBUF].size, model_info.proc_mem.buf[AI3_PROC_BUF_RONLYBUF].size); // alloc WORKBUF/RONLYBUF ret = network_alloc_intl_buf(net_path, model_info.proc_mem.buf[AI3_PROC_BUF_RONLYBUF].size); if (ret != HD_OK) { printf("net_path(%u) alloc ronlybuf fail=%d\n", net_path, ret); return HD_ERR_FAIL; } ret = network_alloc_io_buf(net_path, model_info.proc_mem.buf[AI3_PROC_BUF_WORKBUF].size); if (ret != HD_OK) { printf("net_path(%u) alloc workbuf fail=%d\n", net_path, ret); return HD_ERR_FAIL; } } // call open() { VENDOR_AI3_PROC_CFG proc_cfg = {0}; proc_cfg.model_buf.pa = p_net->proc_mem.pa; proc_cfg.model_buf.va = p_net->proc_mem.va; proc_cfg.model_buf.size = p_net->proc_mem.size; proc_cfg.proc_mem.buf[AI3_PROC_BUF_RONLYBUF].pa = p_net->intl_mem.pa; proc_cfg.proc_mem.buf[AI3_PROC_BUF_RONLYBUF].va = p_net->intl_mem.va; proc_cfg.proc_mem.buf[AI3_PROC_BUF_RONLYBUF].size = p_net->intl_mem.size; proc_cfg.proc_mem.buf[AI3_PROC_BUF_WORKBUF].pa = p_net->io_mem.pa; proc_cfg.proc_mem.buf[AI3_PROC_BUF_WORKBUF].va = p_net->io_mem.va; proc_cfg.proc_mem.buf[AI3_PROC_BUF_WORKBUF].size = p_net->io_mem.size; proc_cfg.plugin[AI3_PLUGIN_CPU] = vendor_ai_cpu1_get_engine(); #if DBG_OUT_DUMP proc_cfg.ctrl = CTRL_BUF_DEBUG | CTRL_JOB_DEBUG | CTRL_JOB_DUMPOUT; #endif #if FLOAT_IN proc_cfg.ctrl = proc_cfg.ctrl | CTRL_BUF_FLOATIN ; #endif #if FLOAT_OUT proc_cfg.ctrl = proc_cfg.ctrl | CTRL_BUF_FLOATOUT ; #endif ret = vendor_ai3_net_open(&p_net->proc_id, &proc_cfg, &p_net->net_info); if (ret != HD_OK) { printf("net_path(%u) vendor_ai3_net_open() fail=%d\n", net_path, ret); return HD_ERR_FAIL; } else { printf("net_path(%u) open success => get proc_id(%u)\r\n", net_path, p_net->proc_id); } } return ret; } static HD_RESULT network_close(NET_PATH_ID net_path) { HD_RESULT ret = HD_OK; NET_PROC* p_net = g_net + net_path; UINT32 proc_id = p_net->proc_id; UINT32 i ; // close ret = vendor_ai3_net_close(proc_id); if (ret != HD_OK) { printf("net_path(%u), proc_id(%u) vendor_ai3_net_close fail=%d\n", net_path, proc_id, ret); return HD_ERR_FAIL; } if ((ret = network_free_intl_buf(net_path)) != HD_OK) return ret; if ((ret = network_free_io_buf(net_path)) != HD_OK) return ret; mem_free(&p_net->proc_mem); for (i = 0 ; i < p_net->net_info.out_buf_cnt; i++){ if(p_net->out_mem && p_net->out_mem[i].va) mem_free(&p_net->out_mem[i]); } if(p_net->out_mem) free(p_net->out_mem) ; return ret; } #if DUMP_POSTPROC_INFO static HD_RESULT network_dump_ai_buf(VENDOR_AI3_BUF *p_outbuf) { HD_RESULT ret = HD_OK; printf(" sign(0x%x) pa(0x%lx) va(0x%lx) sz(%u) w(%u) h(%u) ch(%u) batch_num(%u)\n", p_outbuf->sign, p_outbuf->pa, p_outbuf->va, p_outbuf->size, p_outbuf->width, p_outbuf->height, p_outbuf->channel, p_outbuf->batch_num); printf(" l_ofs(%llu) c_ofs(%llu) b_ofs(%llu) t_ofs(%llu) layout(%s) name(%s) scale_ratio(%.6f)\n", p_outbuf->line_ofs, p_outbuf->channel_ofs, p_outbuf->batch_ofs, p_outbuf->time_ofs, p_outbuf->layout, p_outbuf->name, p_outbuf->scale_ratio); // parsing pixel format switch (AI_PXLFMT_TYPE(p_outbuf->fmt)) { case HD_VIDEO_PXLFMT_AI_UINT8: case HD_VIDEO_PXLFMT_AI_SINT8: case HD_VIDEO_PXLFMT_AI_UINT16: case HD_VIDEO_PXLFMT_AI_SINT16: case HD_VIDEO_PXLFMT_AI_UINT32: case HD_VIDEO_PXLFMT_AI_SINT32: case HD_VIDEO_PXLFMT_AI_FLOAT32: { INT8 bitdepth = HD_VIDEO_PXLFMT_BITS(p_outbuf->fmt); INT8 int_bits = HD_VIDEO_PXLFMT_INT(p_outbuf->fmt); INT8 frac_bits = HD_VIDEO_PXLFMT_FRAC(p_outbuf->fmt); printf(" fmt(0x%x) bits(%u) int(%u) frac(%u)\n", p_outbuf->fmt, bitdepth, int_bits, frac_bits); } break; default: switch ((UINT32)p_outbuf->fmt) { case HD_VIDEO_PXLFMT_BGR888_PLANAR: { printf(" fmt(0x%x), BGR888_PLANAR\n", p_outbuf->fmt); } break; case HD_VIDEO_PXLFMT_YUV420: { printf(" fmt(0x%x), YUV420\n", p_outbuf->fmt); } break; case HD_VIDEO_PXLFMT_Y8: { printf(" fmt(0x%x), Y8 only\n", p_outbuf->fmt); } break; case HD_VIDEO_PXLFMT_UV: { printf(" fmt(0x%x), UV only\n", p_outbuf->fmt); } break; case 0: { printf(" fmt(0x%x), AI BUF\n", p_outbuf->fmt); } break; default: printf("unknown pxlfmt(0x%x)\n", p_outbuf->fmt); break; } } printf("\n"); return ret; } /* static INT32 mem_save(MEM_PARM *mem_parm, const CHAR *filename) { FILE *fd; UINT32 size = 0; fd = fopen(filename, "wb"); if (!fd) { printf("ERR: cannot open %s for write!\r\n", filename); return -1; } size = (INT32)fwrite((VOID *)mem_parm->va, 1, mem_parm->size, fd); if (size != mem_parm->size) { printf("ERR: write %s with size %ld < wanted %ld?\r\n", filename, size, mem_parm->size); } else { printf("write %s with %ld bytes.\r\n", filename, mem_parm->size); } if (fd) { fclose(fd); } return size; } */ #endif /////////////////////////////////////////////////////////////////////////////// typedef struct _VIDEO_LIVEVIEW { // (1) input NET_IN_CONFIG net_in_cfg; NET_PATH_ID in_path; // (2) network NET_PROC_CONFIG net_proc_cfg; NET_PATH_ID net_path; pthread_t proc_thread_id; UINT32 proc_start; UINT32 proc_exit; UINT32 proc_oneshot; UINT32 input_blob_num; } VIDEO_LIVEVIEW; static HD_RESULT init_module(void) { HD_RESULT ret; if ((ret = input_init()) != HD_OK) return ret; if ((ret = network_init()) != HD_OK) return ret; return HD_OK; } static HD_RESULT open_module(VIDEO_LIVEVIEW *p_stream) { HD_RESULT ret; //if ((ret = input_open(p_stream->in_path)) != HD_OK) // return ret; if ((ret = network_open(p_stream->net_path)) != HD_OK) return ret; return HD_OK; } static HD_RESULT close_module(VIDEO_LIVEVIEW *p_stream) { HD_RESULT ret; //if ((ret = input_close(p_stream->in_path)) != HD_OK) // return ret; if ((ret = network_close(p_stream->net_path)) != HD_OK) return ret; return HD_OK; } static HD_RESULT exit_module(void) { HD_RESULT ret; if ((ret = input_uninit()) != HD_OK) return ret; if ((ret = network_uninit()) != HD_OK) return ret; return HD_OK; } static HD_RESULT perf_begin(void) { vendor_ai3_dev_perf_begin(VENDOR_AI3_PERF_ID_TIME_UT); return HD_OK; } static HD_RESULT perf_end(void) { UINT32 i; VENDOR_AI3_PERF_TIME_UT perf_time_ut = {0}; vendor_ai3_dev_perf_end(VENDOR_AI3_PERF_ID_TIME_UT, &perf_time_ut); printf("\r\n ************* util-per-proc() *************\r\n"); for (i=0; i<perf_time_ut.core_count; i++) { printf("%8s: time(us) = %6d, util(%%) = %6.2f\r\n", perf_time_ut.core[i].name, perf_time_ut.core[i].time, ((float)perf_time_ut.core[i].util)/100); } return HD_OK; } /////////////////////////////////////////////////////////////////////////////// static VOID *network_user_thread(VOID *arg); static HD_RESULT set_buf_by_in_path_list(VIDEO_LIVEVIEW *p_stream) { HD_RESULT ret = HD_OK; NET_PATH_ID net_path = p_stream->net_path; NET_PROC* p_net = g_net + net_path; VENDOR_AI3_NET_INFO net_info = p_net->net_info; VENDOR_AI3_BUF in_buf = {0}; VENDOR_AI3_BUF tmp_buf = {0}; UINT32 proc_id = p_net->proc_id; UINT32 i = 0, idx = 0, k = 0; UINT32 in_buf_cnt = 0; UINT32 *in_path_list = NULL; /* get in path list */ in_path_list = p_net->net_info.in_path_list; in_buf_cnt = net_info.in_buf_cnt; for (i = 0; i < in_buf_cnt; i++) { /* get in buf (by in path list) */ ret = vendor_ai3_net_get(proc_id, in_path_list[i], &tmp_buf); if (HD_OK != ret) { printf("net_path(%u), proc_id(%u) get in buf fail, i(%d), in_path(0x%x)\n",net_path, proc_id, i, in_path_list[i]); goto exit; } if (dump_output) { // dump in buf printf("dump_in_buf: path_id: 0x%x\n", in_path_list[i]); ret = network_dump_ai_buf(&tmp_buf); if (HD_OK != ret) { printf("net_path(%u), proc_id(%u) dump in buf fail !!\n", net_path, proc_id); goto exit; }} } for (i = 0; i < p_stream->input_blob_num; i++) { NET_IN* p_in = g_in + i; /* load input bin */ ret = input_pull_buf((p_stream->in_path + i), &in_buf, 0); if (HD_OK != ret) { printf("in_path(%u) pull input fail !!\n", (p_stream->in_path + i)); goto exit; } if (p_in->in_cfg.is_comb_img == 0) { for(k =1 ; k < in_buf.batch_num; k++) { UINTPTR dst_va = in_buf.va + (k * in_buf.size); memcpy((VOID*)dst_va , (VOID*)in_buf.va, in_buf.size); hd_common_mem_flush_cache((VOID *)dst_va, in_buf.size); } } //printf(" path_%d(0x%x) pa(0x%lx) va(0x%lx) size(%u)\n", idx, in_path_list[idx], in_buf.pa, in_buf.va, in_buf.size); ret = vendor_ai3_net_set(proc_id, in_path_list[idx], &in_buf); if (HD_OK != ret) { printf("proc_id(%u)push input fail !! i(%u)\n", proc_id, i); goto exit; } idx++; } exit: return ret; } static HD_RESULT set_buf_by_out_path_list(NET_PATH_ID net_path) { HD_RESULT ret = HD_OK; NET_PROC* p_net = g_net + net_path; UINT32 proc_id = p_net->proc_id; UINT32 i; VENDOR_AI3_BUF ai_buf = {0}; /* get out buf */ for (i = 0; i < p_net->net_info.out_buf_cnt; i++) { // get out buf (by out path list) ret = vendor_ai3_net_get(proc_id, p_net->net_info.out_path_list[i], &ai_buf); if (HD_OK != ret) { printf("proc_id(%u) get out buf fail, i(%d), out_path(0x%x)\n", proc_id, i, p_net->net_info.out_path_list[i]); goto exit; } if (ai_buf.size > p_net->out_mem[i].size){ printf("output size %u < ai_buf.size %u\r\n", p_net->out_mem[i].size, ai_buf.size); goto exit; } ai_buf.va = p_net->out_mem[i].va ; ai_buf.pa = p_net->out_mem[i].pa ; ai_buf.size = p_net->out_mem[i].size ; #if FLOAT_OUT ai_buf.fmt = HD_VIDEO_PXLFMT_AI_FLOAT32; #endif ret = vendor_ai3_net_set(proc_id, p_net->net_info.out_path_list[i], &ai_buf); if (HD_OK != ret) { printf("proc_id(%u)set output buf fail !! (%u)\n", proc_id, i); goto exit; } } exit: return ret; } #if (1) static uintptr_t get_post_buf(uint32_t size) { uintptr_t buf = (uintptr_t)malloc(size); return buf; } static VOID release_post_buf(VOID *ptr) { if (ptr) { free(ptr); } return; } #endif #if(1) static HD_RESULT network_dump_out_buf(NET_PATH_ID net_path, VENDOR_AI3_BUF *p_outbuf, UINT32 id) { HD_RESULT ret = HD_OK; //NET_PROC *p_net = g_net + net_path; //INT32 i; //AI_NET_ACCURACY_PARM parm = {0}; //AI_NET_SHAPE shape = {p_outbuf->batch_num, p_outbuf->channel, 1, 1, 1}; //INT32 size = shape.num * shape.channels * shape.height * shape.width; UINT32 length = p_outbuf->batch_num * p_outbuf->channel * p_outbuf->height * p_outbuf->width; FLOAT *p_outbuf_float = (FLOAT *)get_post_buf(length * sizeof(FLOAT)); ret = vendor_ai_cpu_util_fixed2float((VOID *)p_outbuf->va, p_outbuf->fmt, p_outbuf_float, p_outbuf->scale_ratio, length, p_outbuf->zero_point); printf("id:%d size:%d name:%s\n", id, length, p_outbuf->name); #if (1) // save output float bin CHAR out_float_path[256] = {0}; sprintf(out_float_path, "%s/float_%s.bin", dump_path, p_outbuf->name); printf("out_float_path: %s\n", out_float_path); FILE* fp_out = NULL; if ((fp_out = fopen(out_float_path, "wb+")) == NULL) { printf("fopen fail\n"); } else { fwrite((VOID *)p_outbuf_float, sizeof(FLOAT), length, fp_out); //fwrite((VOID *)layer_buffer[i].va, sizeof(INT16), length, fp_out); } if(fp_out){ fclose(fp_out); } // save output fixed bin CHAR out_fixed_path[256] = {0}; sprintf(out_fixed_path, "%s/fixed_%s.bin", dump_path, p_outbuf->name); printf("out_fixed_path: %s\n", out_fixed_path); FILE* fp_out1 = NULL; if ((fp_out1 = fopen(out_fixed_path, "wb+")) == NULL) { printf("fopen fail\n"); } else { //fwrite((VOID *)p_outbuf_float, sizeof(FLOAT), length, fp_out1); fwrite((VOID *)p_outbuf->va, sizeof(INT16), length, fp_out1); } if(fp_out1){ fclose(fp_out1); } #endif /* INT32 *p_idx = (INT32 *)get_post_buf(p_outbuf->channel * sizeof(INT32)); AI_NET_OUTPUT_CLASSS *p_classes = (AI_NET_OUTPUT_CLASSS *)get_post_buf(p_outbuf->batch_num * TOP_N * sizeof(AI_NET_OUTPUT_CLASSS)); parm.in_addr = (uintptr_t)p_outbuf_float; parm.classes = p_classes; parm.shape = shape; parm.top_n = TOP_N; parm.class_idx = p_idx; ret = ai_net_accuracy_process(&parm); printf("Classification Results:\r\n"); for (i = 0; i < parm.top_n; i++) { printf("%d. no=%d, label=%s, score=%f\r\n", i + 1, parm.classes[i].no, &p_net->out_class_labels[parm.classes[i].no * LABEL_LEN], parm.classes[i].score); } */ release_post_buf(p_outbuf_float); //release_post_buf(p_idx); //release_post_buf(p_classes); return ret; } #endif static HD_RESULT get_buf_by_out_path_list(NET_PATH_ID net_path) { HD_RESULT ret = HD_OK; NET_PROC* p_net = g_net + net_path; UINT32 proc_id = p_net->proc_id; UINT32 i; VENDOR_AI3_BUF ai_buf = {0}; printf("########### p_net->net_info.out_buf_cnt %d \r\n",p_net->net_info.out_buf_cnt); /* get out buf */ for (i = 0; i < p_net->net_info.out_buf_cnt; i++) { // get out buf (by out path list) ret = vendor_ai3_net_get(proc_id, p_net->net_info.out_path_list[i], &ai_buf); if (HD_OK != ret) { printf("net_path(%u), proc_id(%u) get out buf fail, i(%d), out_path(0x%x)\n", net_path, proc_id, i, p_net->net_info.out_path_list[i]); goto exit; } #if DUMP_POSTPROC_INFO { //CHAR dump_path[23]; // dump out buf if (hd_common_mem_flush_cache((VOID *)ai_buf.va, ai_buf.size) != HD_OK) { printf("flush cache failed.\r\n"); } printf("dump_out_buf: path_id: 0x%x\n", p_net->net_info.out_path_list[i]); ret = network_dump_ai_buf(&ai_buf); if (HD_OK != ret) { printf("net_path(%u) dump out buf fail !!\n", net_path); goto exit; } //snprintf(dump_path, 23, "%s.bin", ai_buf.name); //printf(" DUMP out_buf (%u): %s va = %lx\n", i, dump_path,(ULONG)p_net->out_mem[i].va); //mem_save(&p_net->out_mem[i], dump_path); ret = network_dump_out_buf(net_path, &ai_buf, i); } #endif } exit: return ret; } static HD_RESULT allocate_buf_by_out_path_list(NET_PATH_ID net_path) { HD_RESULT ret = HD_OK; NET_PROC* p_net = g_net + net_path; UINT32 proc_id = p_net->proc_id; UINT32 i; VENDOR_AI3_BUF ai_buf = {0}; CHAR mem_name[23] ; /* get out path list */ p_net->out_mem = (MEM_PARM *)malloc(sizeof(MEM_PARM) * p_net->net_info.out_buf_cnt); memset(p_net->out_mem, 0, sizeof(MEM_PARM) * p_net->net_info.out_buf_cnt); /* get out buf */ for (i = 0; i < p_net->net_info.out_buf_cnt; i++) { // get out buf (by out path list) ret = vendor_ai3_net_get(proc_id, p_net->net_info.out_path_list[i], &ai_buf); if (HD_OK != ret) { printf("proc_id(%u) get out buf fail, i(%d), out_path(0x%x)\n", proc_id, i, p_net->net_info.out_path_list[i]); goto exit; } // // allocate in buf #if FLOAT_OUT ai_buf.size = ai_buf.width * ai_buf.height * ai_buf.channel * ai_buf.batch_num *sizeof(float) ; #endif snprintf(mem_name, 23, "output_buf %u", i); ret = mem_alloc(&p_net->out_mem[i], mem_name, ai_buf.size); if (ret != HD_OK) { printf("proc_id(%u) alloc ai_in_buf fail\r\n", proc_id); goto exit; } printf("alloc_outbuf: pa = 0x%lx, va = 0x%lx, size = %u\n", p_net->out_mem[i].pa, p_net->out_mem[i].va, p_net->out_mem[i].size); } return ret; exit: for (i = 0 ; i < p_net->net_info.out_buf_cnt; i++){ if(p_net->out_mem && p_net->out_mem[i].va) mem_free(&p_net->out_mem[i]); } if(p_net->out_mem) free(p_net->out_mem) ; return ret; } static HD_RESULT network_user_start(VIDEO_LIVEVIEW *p_stream) { HD_RESULT ret = HD_OK; NET_PROC* p_net = g_net + p_stream->net_path; UINT32 proc_id = p_net->proc_id; p_stream->proc_start = 0; p_stream->proc_exit = 0; p_stream->proc_oneshot = 0; ret = vendor_ai3_net_start(proc_id); if (HD_OK != ret) { printf("net_path(%u), proc_id(%u) vendor_ai3_net_start fail !!\n", p_stream->net_path, proc_id); } ret = pthread_create(&p_stream->proc_thread_id, NULL, network_user_thread, (VOID*)(p_stream)); if (ret < 0) { return HD_ERR_FAIL; } p_stream->proc_start = 1; p_stream->proc_exit = 0; p_stream->proc_oneshot = 0; return ret; } static HD_RESULT network_user_oneshot(VIDEO_LIVEVIEW *p_stream) { HD_RESULT ret = HD_OK; p_stream->proc_oneshot = 1; return ret; } static HD_RESULT network_user_stop(VIDEO_LIVEVIEW *p_stream) { HD_RESULT ret = HD_OK; NET_PROC* p_net = g_net + p_stream->net_path; UINT32 proc_id = p_net->proc_id; p_stream->proc_exit = 1; if (p_stream->proc_thread_id) { pthread_join(p_stream->proc_thread_id, NULL); } //stop: should be call after last time proc ret = vendor_ai3_net_stop(proc_id); if (HD_OK != ret) { printf("net_path(%u), proc_id(%u) vendor_ai3_net_stop fail !!\n", p_stream->net_path, proc_id); } return ret; } static VOID *network_user_thread(VOID *arg) { HD_RESULT ret = HD_OK; VIDEO_LIVEVIEW *p_stream = (VIDEO_LIVEVIEW*)arg; NET_PROC* p_net = g_net + p_stream->net_path; UINT32 proc_id = p_net->proc_id; static struct timeval tstart, tend; static UINT64 cur_time = 0; static UINT64 all_time = 0; static float mean_time = 0; UINT32 count=0; printf("\r\n"); while (p_stream->proc_start == 0) sleep(1); printf("\r\n"); while (p_stream->proc_exit == 0) { if (p_stream->proc_oneshot) { p_stream->proc_oneshot = 0; for (count=0;count<g_proc_num;count++) { // set buf by in_path_list ret = set_buf_by_in_path_list(p_stream); if (HD_OK != ret) { printf("net_path(%u), proc_id(%u) set in_buf fail(%d) !!\n", p_stream->net_path, proc_id, ret); goto skip; } ret = set_buf_by_out_path_list(p_stream->net_path); if (HD_OK != ret) { printf("net_path(%u), proc_id(%u) set in_buf fail(%d) !!\n", p_stream->net_path, proc_id, ret); goto skip; } // do net proc gettimeofday(&tstart, NULL); if(dump_time_ut){ perf_begin(); } ret = vendor_ai3_net_proc(proc_id); if(dump_time_ut){ perf_end(); } gettimeofday(&tend, NULL); if (HD_OK != ret) { printf("net_path(%u), proc_id(%u) proc fail !!\n", p_stream->net_path, proc_id); goto skip; } //count++; cur_time = (UINT64)(tend.tv_sec - tstart.tv_sec) * 1000000 + (tend.tv_usec - tstart.tv_usec); if(count>0){ all_time+=cur_time; mean_time=all_time/(float)(count); if (dump_time_proc){ printf("count %d cur time(us): %lld all time(us): %lld mean time(us): %f \r\n",count,cur_time,all_time,mean_time); } } // printf("net_path(%u), proc_id(%u) oneshot done!\n", p_stream->net_path, proc_id); // get buf by out_path_list if (dump_output) { /* code */ ret = get_buf_by_out_path_list(p_stream->net_path); if (HD_OK != ret) { printf("net_path(%u), proc_id(%u) get out_buf fail(%d) !!\n", p_stream->net_path, proc_id, ret); goto skip; } } } printf("count %d cur time(us): %lld all time(us): %lld mean time(us): %f \r\n",count,cur_time,all_time,mean_time); } usleep(100); } skip: return 0; } /*-----------------------------------------------------------------------------*/ /* Interface Functions */ /*-----------------------------------------------------------------------------*/ MAIN(argc, argv) { VIDEO_LIVEVIEW stream[1] = {0}; HD_COMMON_MEM_INIT_CONFIG mem_cfg = {0}; HD_RESULT ret; INT key; UINT32 j; INT32 idx; #if FLOAT_IN stream[0].input_blob_num = 1; //net_in NET_IN_CONFIG in_cfg = { .input_filename = "/mnt/sd/jpg/float32.bin", .w = 74, .h = 1, .c = 40, .b = 1, .bitdepth = 32, .loff = 296, .fmt = HD_VIDEO_PXLFMT_AI_FLOAT32, .is_comb_img = 1, }; NET_IN_CONFIG in_cfg2 = { .input_filename = "NULL", .w = 0, .h = 0, .c = 0, .b = 0, .bitdepth = 0, .loff = 0, .fmt = 0, .is_comb_img = 0, }; //net proc NET_PROC_CONFIG net_cfg = { .model_filename = "/mnt/sd/para/nvt_model_float32.bin", .label_filename = "/mnt/sd/accuracy/labels.txt" }; #elif MULTI_BATCH_IN /* multi-blob with multi-batch */ stream[0].input_blob_num = 2; //net_in NET_IN_CONFIG in_cfg = { .input_filename = "/mnt/sd/jpg/mblob_mbatch_0.yuv", .w = 12, .h = 12, .c = 2, .b = 8, .bitdepth = 8, .loff = 12, .fmt = HD_VIDEO_PXLFMT_YUV420, .is_comb_img = 1, }; NET_IN_CONFIG in_cfg2 = { .input_filename = "/mnt/sd/jpg/mblob_mbatch_1.bin", .w = 1, .h = 1, .c = 5, .b = 8, .bitdepth = 16, .loff = 2, .fmt = 0xA2101000, .is_comb_img = 1, }; //net proc NET_PROC_CONFIG net_cfg = { .model_filename = "/mnt/sd/para/nvt_model_mblob_mbatch.bin", .label_filename = "/mnt/sd/accuracy/labels.txt" }; #else stream[0].input_blob_num = 3; //net_in NET_IN_CONFIG in_cfg1 = { .input_filename = "/mnt/sd/jpg/mblob.bin", .w = 224, .h = 224, .c = 2, .b = 1, .bitdepth = 8, .loff = 224, .fmt = HD_VIDEO_PXLFMT_YUV420, .is_comb_img = 0, }; NET_IN_CONFIG in_cfg2 = { .input_filename = "/mnt/sd/jpg/mblob.bin", .w = 224, .h = 224, .c = 2, .b = 1, .bitdepth = 8, .loff = 224, .fmt = HD_VIDEO_PXLFMT_YUV420, .is_comb_img = 0, }; NET_IN_CONFIG in_cfg3 = { .input_filename = "/mnt/sd/jpg/mblob.bin", .w = 224, .h = 224, .c = 2, .b = 1, .bitdepth = 8, .loff = 224, .fmt = HD_VIDEO_PXLFMT_YUV420, .is_comb_img = 0, }; //net proc NET_PROC_CONFIG net_cfg = { .model_filename = "/mnt/sd/para/nvt_model_mblob.bin", .label_filename = "/mnt/sd/accuracy/labels.txt" }; #endif // End of #if MULTI_BATCH_IN if(argc < 4){ printf("usage : ai3_net_with_mblob (proc_num) (model_path) (input_blob_num)\n"); printf("usage : (MPROCESS_FOR_AIISP)\n"); printf("usage : (dump_time_UT)\n"); printf("usage : (dump_time_proc)\n"); printf("usage : (dump_output)\n"); printf("usage : (dump_path)\n"); printf("usage : (input_data_path1) (input_w) (input_h) (input_c) (input_b) (input_bitdepth) (input_loff) (input_fmt_10) (input_is_comb_img)\n"); printf("usage : (input_data_path2) (input_w) (input_h) (input_c) (input_b) (input_bitdepth) (input_loff) (input_fmt_10) (input_is_comb_img)\n"); printf("usage : (input_data_path2) (input_w) (input_h) (input_c) (input_b) (input_bitdepth) (input_loff) (input_fmt_10) (input_is_comb_img)\n"); return -1; } printf("\r\n\r\n"); idx = 1; UINT32 proc_num = 0; UINT32 input_blob_num = 0; { if (argc > idx) { sscanf(argv[idx++], "%d", &proc_num); printf("proc_num: %d\n", proc_num); g_proc_num=proc_num; } if (argc > idx) { sscanf(argv[idx++], "%s", net_cfg.model_filename); printf("net_cfg.model_filename: %s\n", net_cfg.model_filename); } if (argc > idx) { sscanf(argv[idx++], "%d", &input_blob_num); printf("input_blob_num: %d\n", input_blob_num); stream[0].input_blob_num=input_blob_num; } if (argc > idx) { sscanf(argv[idx++], "%d", &MPROCESS_FOR_AIISP); printf("MPROCESS_FOR_AIISP : %d\n", MPROCESS_FOR_AIISP); } if (argc > idx) { sscanf(argv[idx++], "%d", &dump_time_ut); printf("dump_time_ut: %d\n", dump_time_ut); } if (argc > idx) { sscanf(argv[idx++], "%d", &dump_time_proc); printf("dump_time_proc: %d\n", dump_time_proc); } if (argc > idx) { sscanf(argv[idx++], "%d", &dump_output); printf("dump_output: %d\n", dump_output); } if (argc > idx) { sscanf(argv[idx++], "%s", dump_path); printf("dump_path: %s\n", dump_path); } if (argc > idx) { sscanf(argv[idx++], "%s", in_cfg1.input_filename); printf("in_cfg1.input_filename: %s\n", in_cfg1.input_filename); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg1.w)); printf("(in_cfg1.w): %d\n", (in_cfg1.w)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg1.h)); printf("(in_cfg1.h): %d\n", (in_cfg1.h)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg1.c)); printf("(in_cfg1.c): %d\n", (in_cfg1.c)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg1.b)); printf("(in_cfg1.b): %d\n", (in_cfg1.b)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg1.bitdepth)); printf("(in_cfg1.bitdepth): %d\n", (in_cfg1.bitdepth)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg1.loff)); printf("(in_cfg1.loff): %d\n", (in_cfg1.loff)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg1.fmt)); printf("(in_cfg1.fmt): %d\n", (in_cfg1.fmt)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg1.is_comb_img)); printf("(in_cfg1.is_comb_img): %d\n", (in_cfg1.is_comb_img)); } if (argc > idx) { sscanf(argv[idx++], "%s", in_cfg2.input_filename); printf("in_cfg2.input_filename: %s\n", in_cfg2.input_filename); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg2.w)); printf("(in_cfg2.w): %d\n", (in_cfg2.w)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg2.h)); printf("(in_cfg2.h): %d\n", (in_cfg2.h)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg2.c)); printf("(in_cfg2.c): %d\n", (in_cfg2.c)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg2.b)); printf("(in_cfg2.b): %d\n", (in_cfg2.b)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg2.bitdepth)); printf("(in_cfg2.bitdepth): %d\n", (in_cfg2.bitdepth)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg2.loff)); printf("(in_cfg2.loff): %d\n", (in_cfg2.loff)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg2.fmt)); printf("(in_cfg2.fmt): %d\n", (in_cfg2.fmt)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg2.is_comb_img)); printf("(in_cfg2.is_comb_img): %d\n", (in_cfg2.is_comb_img)); } // cfg3 if (argc > idx) { sscanf(argv[idx++], "%s", in_cfg3.input_filename); printf("in_cfg3.input_filename: %s\n", in_cfg3.input_filename); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg3.w)); printf("(in_cfg3.w): %d\n", (in_cfg3.w)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg3.h)); printf("(in_cfg3.h): %d\n", (in_cfg3.h)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg3.c)); printf("(in_cfg3.c): %d\n", (in_cfg3.c)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg3.b)); printf("(in_cfg3.b): %d\n", (in_cfg3.b)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg3.bitdepth)); printf("(in_cfg3.bitdepth): %d\n", (in_cfg3.bitdepth)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg3.loff)); printf("(in_cfg3.loff): %d\n", (in_cfg3.loff)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg3.fmt)); printf("(in_cfg3.fmt): %d\n", (in_cfg3.fmt)); } if (argc > idx) { sscanf(argv[idx++], "%d", &(in_cfg3.is_comb_img)); printf("(in_cfg3.is_comb_img): %d\n", (in_cfg3.is_comb_img)); } } // malloc for g_in & g_net g_in = (NET_IN *)malloc(sizeof(NET_IN)*16); g_net = (NET_PROC *)malloc(sizeof(NET_PROC)*16); if ((g_in == NULL) || (g_net == NULL)) { printf("fail to malloc g_in/g_net\n"); goto exit; } stream[0].in_path = 0; stream[0].net_path = 0; // init hdal if(MPROCESS_FOR_AIISP){ ret = hd_common_init(1); // multi-process for aiisp }else{ ret = hd_common_init(0); } //this is no longer need in 690 /* #if defined(_BSP_NS02201_) || defined(_BSP_NS02302_) // set project config for AI hd_common_sysconfig(0, (1<<16), 0, VENDOR_AI_CFG); //enable AI engine #endif */ // init mem { // config common pool network_mem_config(stream[0].net_path, &mem_cfg, &net_cfg); } #if defined(_BSP_NS02201_) || defined(_BSP_NS02302_) if(MPROCESS_FOR_AIISP){ ret = hd_common_mem_init(NULL); // multi-process for aiisp }else{ ret = hd_common_mem_init(&mem_cfg); } if (HD_OK != ret) { printf("hd_common_mem_init err: %d\r\n", ret); goto exit; } #endif // init all modules ret = init_module(); if (ret != HD_OK) { printf("init fail=%d\n", ret); goto exit; } // set open config for (j=0; j < stream[0].input_blob_num; j++) { if (j == 0) { ret = input_set_config((stream[0].in_path + j), &in_cfg1); } else if (j == 1) { ret = input_set_config((stream[0].in_path + j), &in_cfg2); } else if (j == 2) { ret = input_set_config((stream[0].in_path + j), &in_cfg3); } if (HD_OK != ret) { printf("in_path(%u) input_set_config fail=%d\n", (stream[0].in_path + j), ret); goto exit; } } // open video_liveview modules for(j=0; j < stream[0].input_blob_num; j++) { ret = input_open((stream[0].in_path + j)); if (ret != HD_OK) { printf("in_path(%u) input open fail=%d\n", (stream[0].in_path + j), ret); goto exit; } } ret = open_module(&stream[0]); if (ret != HD_OK) { printf("open fail=%d\n", ret); goto exit; } // start input_start(stream[0].in_path); network_user_start(&stream[0]); allocate_buf_by_out_path_list(stream[0].net_path); do { printf("Enter q to exit, r to run once\n"); key = GETCHAR(); if (key == 'r') { // run once network_user_oneshot(&stream[0]); continue; } if (key == 'q' || key == 0x3) { break; } } while(1); // stop input_stop(stream[0].in_path); network_user_stop(&stream[0]); exit: // close video_liveview modules ret = close_module(&stream[0]); if (ret != HD_OK) { printf("close fail=%d\n", ret); } for(j=0; j < stream[0].input_blob_num; j++) { ret = input_close((stream[0].in_path + j)); if (ret != HD_OK) { printf("in_path(%u) input close fail=%d\n", (stream[0].in_path + j), ret); goto exit; } } // uninit all modules ret = exit_module(); if (ret != HD_OK) { printf("exit fail=%d\n", ret); } #if defined(_BSP_NS02201_) || defined(_BSP_NS02302_) // uninit memory ret = hd_common_mem_uninit(); if (ret != HD_OK) { printf("mem fail=%d\n", ret); } #endif // uninit hdal ret = hd_common_uninit(); if (ret != HD_OK) { printf("common fail=%d\n", ret); } // free g_in & g_net if (g_in) free(g_in); if (g_net) free(g_net); return ret; }
最新发布
11-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值