InovanceMotionCard.cs 286 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using TeamAAS;
  6. using TeamAAS.Global.Devices;
  7. using TeamAAS.Motion.Models;
  8. using System.Runtime.InteropServices;
  9. namespace TeamAAS.Motion.Motions
  10. {
  11. /// <summary>
  12. /// 汇川 IMC60G 运动控制卡(对接 IMC_Library_x64.dll)。
  13. /// 流程层用索引 API;调试层用 <see cref="InovanceAxis"/>。
  14. /// </summary>
  15. public class InovanceMotionCard : IMotionCard, IMasterFollowHost, IMotionSafetyHost, IMotionIoHost
  16. {
  17. private const short StopSmooth = 0;
  18. private const short StopAbrupt = 1;
  19. private const uint EcatMasterOp = 6;
  20. private readonly MotionDeviceConfig _cfg;
  21. private readonly object _sync = new object();
  22. private readonly MasterFollowSession _follow = new MasterFollowSession();
  23. private readonly MotionSafetyGuard _guard;
  24. private short _card;
  25. private int _axisCount;
  26. private IAxis[] _axes = Array.Empty<IAxis>();
  27. private Dictionary<int, IAxis> _axisMap = new Dictionary<int, IAxis>();
  28. private Dictionary<int, InovanceAxis> _hwAxes = new Dictionary<int, InovanceAxis>();
  29. private Dictionary<int, MotionAxisConfig> _axisCfgs = new Dictionary<int, MotionAxisConfig>();
  30. private bool _crdReady;
  31. private int _crdDim;
  32. private int _ecatDiCnt;
  33. private int _ecatDoCnt;
  34. public string Name => _cfg.Name;
  35. public bool IsConnected { get; private set; }
  36. public int AxisCount => _axisCount;
  37. public bool IsEstopActive => _guard.EstopActive;
  38. public bool IsStopActive => _guard.StopActive;
  39. internal MotionDeviceConfig DeviceConfig => _cfg;
  40. public event EventHandler<MotionConnectionStateChangedEventArgs> ConnectionStateChanged;
  41. public event EventHandler<MotionErrorEventArgs> ErrorOccurred;
  42. public event EventHandler SafetyChanged;
  43. public InovanceMotionCard(MotionDeviceConfig cfg)
  44. {
  45. _cfg = cfg ?? new MotionDeviceConfig();
  46. _card = (short)_cfg.BoardIndex;
  47. _axisCount = Math.Max(1, _cfg.AxisCount);
  48. RebuildAxes();
  49. _guard = new MotionSafetyGuard(
  50. () => _cfg,
  51. ReadDI,
  52. OnSafetyEstopRise,
  53. OnSafetyEstopHold,
  54. OnSafetyStopRise);
  55. _guard.Changed += (_, __) =>
  56. {
  57. try { SafetyChanged?.Invoke(this, EventArgs.Empty); }
  58. catch { }
  59. };
  60. }
  61. public bool AllowEnable(out string reason) => _guard.AllowEnable(out reason);
  62. public bool AllowMotion(out string reason) => _guard.AllowMotion(out reason);
  63. private bool RejectEnable()
  64. {
  65. if (_guard.AllowEnable(out var reason)) return false;
  66. RaiseError(reason);
  67. return true;
  68. }
  69. private bool RejectMotion()
  70. {
  71. if (_guard.AllowMotion(out var reason)) return false;
  72. RaiseError(reason);
  73. return true;
  74. }
  75. private void OnSafetyEstopRise()
  76. {
  77. if (!IsConnected) return;
  78. EmergencyStop();
  79. }
  80. private void OnSafetyEstopHold()
  81. {
  82. if (!IsConnected) return;
  83. lock (_sync)
  84. {
  85. if (!IsConnected) return;
  86. foreach (var hw in _hwAxes.Values)
  87. {
  88. try { Imc60.IMC_ServoOff(_card, (short)hw.AxisNo, 1); }
  89. catch { }
  90. }
  91. }
  92. }
  93. private void OnSafetyStopRise()
  94. {
  95. if (!IsConnected) return;
  96. Stop(-1);
  97. }
  98. public bool Open()
  99. {
  100. lock (_sync)
  101. {
  102. if (IsConnected) return true;
  103. try
  104. {
  105. uint ret = Imc60.IMC_OpenCard(_card);
  106. if (!Ok(ret, "开卡")) return false;
  107. ParseConfigPaths(out var deviceCfg, out var systemCfg);
  108. if (!string.IsNullOrEmpty(deviceCfg))
  109. {
  110. if (!File.Exists(deviceCfg))
  111. {
  112. RaiseError("设备配置不存在: " + deviceCfg);
  113. return FailOpen();
  114. }
  115. if (!Ok(Imc60.IMC_DownLoadDeviceConfig(_card, deviceCfg), "下载设备配置"))
  116. return FailOpen();
  117. }
  118. short masterCfg = 0;
  119. Imc60.IMC_GetMasterCfgXml(_card, ref masterCfg);
  120. if ((masterCfg & 0x1) != 0)
  121. {
  122. uint sts = 0;
  123. Imc60.IMC_GetEcatMasterSts(_card, ref sts);
  124. if (sts != EcatMasterOp)
  125. {
  126. if (!Ok(Imc60.IMC_ScanCardEcat(_card), "EtherCAT0 扫描"))
  127. return FailOpen();
  128. }
  129. if (!string.IsNullOrEmpty(systemCfg))
  130. {
  131. if (!File.Exists(systemCfg))
  132. {
  133. RaiseError("系统配置不存在: " + systemCfg);
  134. return FailOpen();
  135. }
  136. if (!Ok(Imc60.IMC_DownLoadSystemConfig(_card, systemCfg), "下载系统配置"))
  137. return FailOpen();
  138. }
  139. }
  140. if ((masterCfg & 0x2) != 0)
  141. {
  142. uint sts = 0;
  143. Imc60.IMC_H_GetEcatMasterSts(_card, ref sts);
  144. if (sts != EcatMasterOp)
  145. {
  146. if (!Ok(Imc60.IMC_H_ScanCardEcat(_card), "EtherCAT1 扫描"))
  147. return FailOpen();
  148. }
  149. }
  150. bool userAxes = _cfg.Axes != null && _cfg.Axes.Count > 0;
  151. var info = new Imc60.TMasterInfo();
  152. bool haveInfo = Imc60.IMC_GetEcatMasterInfo(_card, ref info) == Imc60.EXE_SUCCESS;
  153. if (haveInfo)
  154. {
  155. _ecatDiCnt = Math.Max(0, (int)info.diCnt);
  156. _ecatDoCnt = Math.Max(0, (int)info.doCnt);
  157. }
  158. if (!userAxes)
  159. {
  160. if (haveInfo && info.axisCnt > 0)
  161. _axisCount = info.axisCnt;
  162. else
  163. _axisCount = Math.Max(1, _cfg.AxisCount);
  164. }
  165. RebuildAxes();
  166. ApplyAxisBonds();
  167. ApplySafetyLimits();
  168. foreach (var hw in _hwAxes.Values)
  169. {
  170. Imc60.IMC_SetAxMvPara(_card, (short)hw.AxisNo, hw.Velocity, hw.Acceleration, hw.Deceleration);
  171. Imc60.IMC_SetAxStopDec(_card, (short)hw.AxisNo, hw.Deceleration, hw.Deceleration * 4);
  172. }
  173. IsConnected = true;
  174. }
  175. catch (DllNotFoundException)
  176. {
  177. RaiseError("未找到 IMC_Library_x64.dll,请放到程序运行目录");
  178. return false;
  179. }
  180. catch (Exception ex)
  181. {
  182. RaiseError("开卡异常: " + ex.Message);
  183. return FailOpen();
  184. }
  185. }
  186. _guard.Start();
  187. ConnectionStateChanged?.Invoke(this, new MotionConnectionStateChangedEventArgs(true));
  188. return true;
  189. }
  190. public void Close()
  191. {
  192. _guard.Stop();
  193. lock (_sync)
  194. {
  195. if (!IsConnected) return;
  196. try
  197. {
  198. foreach (var hw in _hwAxes.Values)
  199. Imc60.IMC_ServoOff(_card, (short)hw.AxisNo, 1);
  200. if (_crdReady)
  201. {
  202. Imc60.IMC_CrdStop(_card, 0, StopAbrupt);
  203. Imc60.IMC_CrdDeleteMtSys(_card, 0);
  204. _crdReady = false;
  205. }
  206. Imc60.IMC_DelEcatComm(_card);
  207. Imc60.IMC_CloseCard(_card);
  208. }
  209. catch { }
  210. _follow.Clear();
  211. IsConnected = false;
  212. }
  213. ConnectionStateChanged?.Invoke(this, new MotionConnectionStateChangedEventArgs(false));
  214. }
  215. void IMasterFollowHost.BeginSoloMasterFollow(int masterAxisNo, IEnumerable<IAxis> slaves)
  216. => _follow.Begin(masterAxisNo, slaves);
  217. void IMasterFollowHost.ReleaseMasterFollow() => _follow.Release();
  218. IDisposable IMasterFollowHost.SuspendFollowRelease() => _follow.Suspend();
  219. private void ReleaseFollowIfIndependent(int axis)
  220. {
  221. if (_follow.Suspended || _follow.IsReleasing) return;
  222. if (axis >= 0 && TryCombined(axis, out _)) return;
  223. _follow.Release();
  224. }
  225. public bool SetEnable(int axis, bool enable)
  226. {
  227. if (enable && RejectEnable()) return false;
  228. if (!IsConnected) return false;
  229. lock (_sync)
  230. {
  231. if (axis < 0)
  232. {
  233. bool ok = true;
  234. foreach (var hw in _hwAxes.Values)
  235. {
  236. if (enable)
  237. Imc60.IMC_ClrAxSts(_card, (short)hw.AxisNo, 1);
  238. uint r = enable
  239. ? Imc60.IMC_ServoOn(_card, (short)hw.AxisNo, 1)
  240. : Imc60.IMC_ServoOff(_card, (short)hw.AxisNo, 1);
  241. if (!Ok(r, enable ? $"轴{hw.AxisNo}使能" : $"轴{hw.AxisNo}下使能"))
  242. ok = false;
  243. }
  244. return ok;
  245. }
  246. if (TryCombined(axis, out var combined))
  247. {
  248. if (enable) combined.Enable(); else combined.Disable();
  249. return true;
  250. }
  251. if (!IsHardware(axis)) return false;
  252. if (enable)
  253. Imc60.IMC_ClrAxSts(_card, (short)axis, 1);
  254. uint ret = enable
  255. ? Imc60.IMC_ServoOn(_card, (short)axis, 1)
  256. : Imc60.IMC_ServoOff(_card, (short)axis, 1);
  257. return Ok(ret, enable ? $"轴{axis}使能" : $"轴{axis}下使能");
  258. }
  259. }
  260. public bool Home(int axis, int mode = 0)
  261. {
  262. if (RejectMotion()) return false;
  263. if (!IsConnected || !IsValidAxis(axis)) return false;
  264. lock (_sync)
  265. {
  266. if (TryCombined(axis, out var combined))
  267. {
  268. combined.Home((HomeMode)mode);
  269. return true;
  270. }
  271. ReleaseFollowIfIndependent(axis);
  272. if (!_hwAxes.TryGetValue(axis, out var a)) return false;
  273. var para = new Imc60.THomingPara
  274. {
  275. homeMethod = MapHomeMethod(mode),
  276. highVel = ToUInt(Math.Abs(a.Velocity)),
  277. lowVel = ToUInt(Math.Abs(a.Velocity) * 0.2),
  278. acc = ToUInt(Math.Max(1, a.Acceleration)),
  279. offset = 0
  280. };
  281. if (!Ok(Imc60.IMC_StartHoming(_card, (short)axis, ref para), $"轴{axis}回零"))
  282. return false;
  283. a.MarkHoming();
  284. return true;
  285. }
  286. }
  287. public bool IsHomed(int axis)
  288. {
  289. if (!IsValidAxis(axis)) return false;
  290. RefreshHomeFlag(axis);
  291. return _axisMap[axis].IsHomed;
  292. }
  293. public bool MoveAbsolute(int axis, double position, double velocity)
  294. {
  295. if (RejectMotion()) return false;
  296. if (!IsConnected || !IsValidAxis(axis)) return false;
  297. lock (_sync)
  298. {
  299. if (TryCombined(axis, out var combined))
  300. {
  301. combined.Velocity = velocity;
  302. combined.MoveTo(position);
  303. return true;
  304. }
  305. ReleaseFollowIfIndependent(axis);
  306. position = ClampAxisPosition(axis, position);
  307. velocity = Math.Abs(ClampAxisVelocity(axis, velocity));
  308. if (!ApplyMovePara(axis, velocity)) return false;
  309. return Ok(Imc60.IMC_StartPtpMove(_card, (short)axis, position, 0), $"轴{axis}绝对定位");
  310. }
  311. }
  312. public bool MoveRelative(int axis, double distance, double velocity)
  313. {
  314. if (RejectMotion()) return false;
  315. if (!IsConnected || !IsValidAxis(axis)) return false;
  316. lock (_sync)
  317. {
  318. if (TryCombined(axis, out var combined))
  319. {
  320. combined.Velocity = velocity;
  321. combined.MoveBy(distance);
  322. return true;
  323. }
  324. ReleaseFollowIfIndependent(axis);
  325. double current = ReadPrfPos(axis);
  326. double target = ClampAxisPosition(axis, current + distance);
  327. velocity = Math.Abs(ClampAxisVelocity(axis, velocity));
  328. if (!ApplyMovePara(axis, velocity)) return false;
  329. return Ok(Imc60.IMC_StartPtpMove(_card, (short)axis, target, 0), $"轴{axis}相对定位");
  330. }
  331. }
  332. public bool JogStart(int axis, int direction, double velocity)
  333. {
  334. if (RejectMotion()) return false;
  335. if (!IsConnected || !IsValidAxis(axis)) return false;
  336. lock (_sync)
  337. {
  338. double vel = (direction >= 0 ? 1 : -1) * Math.Abs(velocity);
  339. if (TryCombined(axis, out var combined))
  340. {
  341. combined.Jog(vel);
  342. return true;
  343. }
  344. ReleaseFollowIfIndependent(axis);
  345. vel = ClampAxisJog(axis, vel, ReadPrfPos(axis));
  346. if (Math.Abs(vel) < 1e-9)
  347. return Stop(axis);
  348. if (!ApplyMovePara(axis, Math.Abs(vel))) return false;
  349. if (_hwAxes.TryGetValue(axis, out var hw))
  350. hw.MarkJogging(true);
  351. return Ok(Imc60.IMC_StartJogMove(_card, (short)axis, vel), $"轴{axis}点动");
  352. }
  353. }
  354. public bool JogStop(int axis) => Stop(axis);
  355. public bool Stop(int axis = -1)
  356. {
  357. if (!IsConnected) return false;
  358. lock (_sync)
  359. {
  360. if (axis < 0)
  361. {
  362. _follow.Release();
  363. bool ok = true;
  364. foreach (var hw in _hwAxes.Values)
  365. {
  366. hw.AbortHome();
  367. if (!Ok(Imc60.IMC_StopMove(_card, (short)hw.AxisNo, StopSmooth), $"轴{hw.AxisNo}停止"))
  368. ok = false;
  369. hw.MarkJogging(false);
  370. }
  371. return ok;
  372. }
  373. if (TryCombined(axis, out var combined))
  374. {
  375. combined.Stop();
  376. return true;
  377. }
  378. ReleaseFollowIfIndependent(axis);
  379. if (!IsHardware(axis)) return false;
  380. if (_hwAxes.TryGetValue(axis, out var a))
  381. {
  382. a.AbortHome();
  383. a.MarkJogging(false);
  384. }
  385. return Ok(Imc60.IMC_StopMove(_card, (short)axis, StopSmooth), $"轴{axis}停止");
  386. }
  387. }
  388. public AxisStatus GetAxisStatus(int axis)
  389. {
  390. if (!IsValidAxis(axis)) return null;
  391. var logical = _axisMap[axis];
  392. if (logical is CombinedMotionAxis)
  393. {
  394. return new AxisStatus
  395. {
  396. Index = axis,
  397. Name = logical.Name,
  398. Position = logical.ActualPosition,
  399. Velocity = logical.ActualVelocity,
  400. IsMoving = logical.IsMoving,
  401. IsHomed = logical.IsHomed,
  402. IsEnabled = logical.IsEnabled
  403. };
  404. }
  405. RefreshHomeFlag(axis);
  406. if (logical is InovanceAxis inv)
  407. inv.SyncState();
  408. int sts = ReadSts(axis);
  409. return new AxisStatus
  410. {
  411. Index = axis,
  412. Name = logical.Name,
  413. Position = ReadEncPos(axis),
  414. Velocity = ReadEncVel(axis),
  415. IsMoving = logical.IsMoving,
  416. IsHomed = logical.IsHomed,
  417. IsEnabled = logical.IsEnabled,
  418. PositiveLimit = Has(sts, Imc60.AX_POSLMT_BIT) || Has(sts, Imc60.AX_SOFT_POSLMT_BIT),
  419. NegativeLimit = Has(sts, Imc60.AX_NEGLMT_BIT) || Has(sts, Imc60.AX_SOFT_NEGLMT_BIT),
  420. Alarm = Has(sts, Imc60.AX_ALARM_BIT) || Has(sts, Imc60.AX_UNLINK_BIT) || Has(sts, Imc60.AX_ERRPOS_BIT)
  421. };
  422. }
  423. public List<AxisStatus> GetAllAxisStatus()
  424. {
  425. var list = new List<AxisStatus>(_axes.Length);
  426. foreach (var a in _axes)
  427. list.Add(GetAxisStatus(a.AxisNo));
  428. return list;
  429. }
  430. public IAxis GetAxis(int axisNo)
  431. {
  432. if (!IsValidAxis(axisNo))
  433. throw new ArgumentOutOfRangeException(nameof(axisNo), "轴号超出范围");
  434. return _axisMap[axisNo];
  435. }
  436. public IList<IAxis> GetAxes() => _axes.ToList();
  437. public bool MoveLinear(double[] targetPositions, double velocity)
  438. {
  439. if (RejectMotion()) return false;
  440. if (!IsConnected || targetPositions == null || targetPositions.Length < 2) return false;
  441. lock (_sync)
  442. {
  443. _follow.Release();
  444. int dim = targetPositions.Length >= 3 ? 3 : 2;
  445. velocity = ClampInterpVelocity(velocity, dim);
  446. if (!EnsureCrd(dim)) return false;
  447. if (!PrepareCrd(velocity)) return false;
  448. if (dim >= 3)
  449. {
  450. var ends = new[]
  451. {
  452. ClampAxisPosition(0, targetPositions[0]),
  453. ClampAxisPosition(1, targetPositions[1]),
  454. ClampAxisPosition(2, targetPositions[2])
  455. };
  456. if (!Ok(Imc60.IMC_CrdLineXYZ(_card, 0, ends), "插补直线XYZ")) return false;
  457. }
  458. else
  459. {
  460. var ends = new[]
  461. {
  462. ClampAxisPosition(0, targetPositions[0]),
  463. ClampAxisPosition(1, targetPositions[1])
  464. };
  465. if (!Ok(Imc60.IMC_CrdLineXY(_card, 0, ends), "插补直线XY")) return false;
  466. }
  467. return Ok(Imc60.IMC_CrdStart(_card, 0), "启动插补");
  468. }
  469. }
  470. public bool MoveArc(double[] centerPoint, double[] targetPositions, double velocity)
  471. {
  472. if (RejectMotion()) return false;
  473. if (!IsConnected || centerPoint == null || targetPositions == null) return false;
  474. if (centerPoint.Length < 2 || targetPositions.Length < 2) return false;
  475. lock (_sync)
  476. {
  477. _follow.Release();
  478. velocity = ClampInterpVelocity(velocity, 2);
  479. if (!EnsureCrd(2)) return false;
  480. if (!PrepareCrd(velocity)) return false;
  481. var center = new[] { centerPoint[0], centerPoint[1] };
  482. var ends = new[]
  483. {
  484. ClampAxisPosition(0, targetPositions[0]),
  485. ClampAxisPosition(1, targetPositions[1])
  486. };
  487. if (!Ok(Imc60.IMC_CrdArcCenterXYPlane(_card, 0, center, ends, 0), "插补圆弧")) return false;
  488. return Ok(Imc60.IMC_CrdStart(_card, 0), "启动插补");
  489. }
  490. }
  491. public bool EmergencyStop()
  492. {
  493. if (!IsConnected) return false;
  494. lock (_sync)
  495. {
  496. _follow.Clear();
  497. Imc60.IMC_CrdStop(_card, 0, StopAbrupt);
  498. bool ok = true;
  499. foreach (var hw in _hwAxes.Values)
  500. {
  501. hw.AbortHome();
  502. if (!Ok(Imc60.IMC_StopMove(_card, (short)hw.AxisNo, StopAbrupt), $"轴{hw.AxisNo}急停"))
  503. ok = false;
  504. hw.MarkJogging(false);
  505. }
  506. return ok;
  507. }
  508. }
  509. public bool CanSimulateDi => false;
  510. public int GetDiCount(MotionIoBank bank)
  511. {
  512. if (bank == MotionIoBank.EtherCat)
  513. return _ecatDiCnt > 0 ? _ecatDiCnt : Math.Max(0, _cfg.InputCount);
  514. int n = _cfg.LocalInputCount > 0 ? _cfg.LocalInputCount : 16;
  515. return n;
  516. }
  517. public int GetDoCount(MotionIoBank bank)
  518. {
  519. if (bank == MotionIoBank.EtherCat)
  520. return _ecatDoCnt > 0 ? _ecatDoCnt : Math.Max(0, _cfg.OutputCount);
  521. int n = _cfg.LocalOutputCount > 0 ? _cfg.LocalOutputCount : 16;
  522. return n;
  523. }
  524. public bool ReadDI(int portIndex) => ReadDI(MotionIoBank.Local, portIndex);
  525. public bool ReadDI(MotionIoBank bank, int index)
  526. {
  527. if (!IsConnected || index < 0) return false;
  528. short v = 0;
  529. uint ret = bank == MotionIoBank.EtherCat
  530. ? Imc60.IMC_GetEcatDiBit(_card, (short)index, ref v)
  531. : Imc60.IMC_GetLocalDiBit(_card, (short)index, ref v);
  532. return ret == Imc60.EXE_SUCCESS && v != 0;
  533. }
  534. public bool ReadDO(MotionIoBank bank, int index)
  535. {
  536. if (!IsConnected || index < 0) return false;
  537. short v = 0;
  538. uint ret = bank == MotionIoBank.EtherCat
  539. ? Imc60.IMC_GetEcatDoBit(_card, (short)index, ref v)
  540. : Imc60.IMC_GetLocalDoBit(_card, (short)index, ref v);
  541. return ret == Imc60.EXE_SUCCESS && v != 0;
  542. }
  543. public bool WriteDO(int portIndex, bool value) => WriteDO(MotionIoBank.Local, portIndex, value);
  544. public bool WriteDO(MotionIoBank bank, int index, bool value)
  545. {
  546. if (!IsConnected || index < 0) return false;
  547. short bit = (short)(value ? 1 : 0);
  548. uint ret = bank == MotionIoBank.EtherCat
  549. ? Imc60.IMC_SetEcatDoBit(_card, (short)index, bit)
  550. : Imc60.IMC_SetLocalDoBit(_card, (short)index, bit);
  551. return Ok(ret, bank == MotionIoBank.EtherCat ? $"写 EtherCAT DO{index}" : $"写本地 DO{index}");
  552. }
  553. public bool WriteDI(MotionIoBank bank, int index, bool value) => false;
  554. internal bool ApplyMovePara(int axis, double velocity)
  555. {
  556. if (!_hwAxes.TryGetValue(axis, out var a)) return false;
  557. if (velocity > 0) a.Velocity = velocity;
  558. return Ok(Imc60.IMC_SetAxMvPara(_card, (short)axis, a.Velocity, a.Acceleration, a.Deceleration), $"轴{axis}运动参数");
  559. }
  560. internal bool HardwareSetEnable(int axis, bool enable)
  561. {
  562. if (enable && RejectEnable()) return false;
  563. if (!IsConnected || !_hwAxes.ContainsKey(axis)) return false;
  564. lock (_sync)
  565. {
  566. if (enable)
  567. Imc60.IMC_ClrAxSts(_card, (short)axis, 1);
  568. uint ret = enable
  569. ? Imc60.IMC_ServoOn(_card, (short)axis, 1)
  570. : Imc60.IMC_ServoOff(_card, (short)axis, 1);
  571. return Ok(ret, enable ? $"轴{axis}使能" : $"轴{axis}下使能");
  572. }
  573. }
  574. internal bool HardwareMoveAbsolute(int axis, double position, double velocity)
  575. {
  576. if (RejectMotion()) return false;
  577. if (!IsConnected || !_hwAxes.ContainsKey(axis)) return false;
  578. lock (_sync)
  579. {
  580. position = ClampAxisPosition(axis, position);
  581. velocity = Math.Abs(ClampAxisVelocity(axis, velocity));
  582. if (!ApplyMovePara(axis, velocity)) return false;
  583. return Ok(Imc60.IMC_StartPtpMove(_card, (short)axis, position, 0), $"轴{axis}绝对定位");
  584. }
  585. }
  586. internal bool HardwareMoveRelative(int axis, double distance, double velocity)
  587. {
  588. if (RejectMotion()) return false;
  589. if (!IsConnected || !_hwAxes.ContainsKey(axis)) return false;
  590. lock (_sync)
  591. {
  592. double target = ClampAxisPosition(axis, ReadPrfPos(axis) + distance);
  593. velocity = Math.Abs(ClampAxisVelocity(axis, velocity));
  594. if (!ApplyMovePara(axis, velocity)) return false;
  595. return Ok(Imc60.IMC_StartPtpMove(_card, (short)axis, target, 0), $"轴{axis}相对定位");
  596. }
  597. }
  598. internal bool HardwareJog(int axis, double velocity)
  599. {
  600. if (RejectMotion()) return false;
  601. if (!IsConnected || !_hwAxes.TryGetValue(axis, out var hw)) return false;
  602. lock (_sync)
  603. {
  604. velocity = ClampAxisJog(axis, velocity, ReadPrfPos(axis));
  605. if (Math.Abs(velocity) < 1e-9)
  606. {
  607. hw.MarkJogging(false);
  608. return Ok(Imc60.IMC_StopMove(_card, (short)axis, StopSmooth), $"轴{axis}停止");
  609. }
  610. if (!ApplyMovePara(axis, Math.Abs(velocity))) return false;
  611. hw.MarkJogging(true);
  612. return Ok(Imc60.IMC_StartJogMove(_card, (short)axis, velocity), $"轴{axis}点动");
  613. }
  614. }
  615. internal bool HardwareStop(int axis)
  616. {
  617. if (!IsConnected || !_hwAxes.TryGetValue(axis, out var hw)) return false;
  618. lock (_sync)
  619. {
  620. hw.AbortHome();
  621. hw.MarkJogging(false);
  622. return Ok(Imc60.IMC_StopMove(_card, (short)axis, StopSmooth), $"轴{axis}停止");
  623. }
  624. }
  625. internal bool HardwareHome(int axis, int mode)
  626. {
  627. if (RejectMotion()) return false;
  628. if (!IsConnected || !_hwAxes.TryGetValue(axis, out var a)) return false;
  629. lock (_sync)
  630. {
  631. var para = new Imc60.THomingPara
  632. {
  633. homeMethod = MapHomeMethod(mode),
  634. highVel = ToUInt(Math.Abs(a.Velocity)),
  635. lowVel = ToUInt(Math.Abs(a.Velocity) * 0.2),
  636. acc = ToUInt(Math.Max(1, a.Acceleration)),
  637. offset = 0
  638. };
  639. if (!Ok(Imc60.IMC_StartHoming(_card, (short)axis, ref para), $"轴{axis}回零"))
  640. return false;
  641. a.MarkHoming();
  642. return true;
  643. }
  644. }
  645. internal bool SetCurrentPosition(int axis, double position)
  646. => Ok(Imc60.IMC_SetAxCurPos(_card, (short)axis, position), $"轴{axis}位置清零");
  647. internal int ReadSts(int axis)
  648. {
  649. var arr = new int[1];
  650. return Imc60.IMC_GetAxSts(_card, (short)axis, arr, 1) == Imc60.EXE_SUCCESS ? arr[0] : 0;
  651. }
  652. internal double ReadEncPos(int axis)
  653. {
  654. var arr = new double[1];
  655. return Imc60.IMC_GetAxEncPos(_card, (short)axis, arr, 1) == Imc60.EXE_SUCCESS ? arr[0] : 0;
  656. }
  657. internal double ReadPrfPos(int axis)
  658. {
  659. var arr = new double[1];
  660. return Imc60.IMC_GetAxPrfPos(_card, (short)axis, arr, 1) == Imc60.EXE_SUCCESS ? arr[0] : 0;
  661. }
  662. internal double ReadEncVel(int axis)
  663. {
  664. var arr = new double[1];
  665. return Imc60.IMC_GetAxEncVel(_card, (short)axis, arr, 1) == Imc60.EXE_SUCCESS ? arr[0] : 0;
  666. }
  667. internal short ReadHomeStatus(int axis)
  668. {
  669. short sts = 0;
  670. Imc60.IMC_GetHomingStatus(_card, (short)axis, ref sts);
  671. return sts;
  672. }
  673. internal void FinishHome(int axis)
  674. {
  675. Imc60.IMC_FinishHoming(_card, (short)axis);
  676. }
  677. internal void RefreshHomeFlag(int axis)
  678. {
  679. if (!IsConnected) return;
  680. if (_hwAxes.TryGetValue(axis, out var hw))
  681. hw.PollHome(this);
  682. }
  683. private bool PrepareCrd(double velocity)
  684. {
  685. double acc = Math.Max(100, Math.Abs(velocity) * 5);
  686. if (!Ok(Imc60.IMC_CrdClrData(_card, 0), "清空插补缓冲")) return false;
  687. if (!Ok(Imc60.IMC_CrdSetIncMode(_card, 0, 0), "插补绝对模式")) return false;
  688. if (!Ok(Imc60.IMC_CrdSetTrajVel(_card, 0, velocity), "插补速度")) return false;
  689. return Ok(Imc60.IMC_CrdSetTrajAccAndDec(_card, 0, acc, acc), "插补加减速");
  690. }
  691. private bool EnsureCrd(int dim)
  692. {
  693. dim = Math.Max(2, Math.Min(3, dim));
  694. if (_hwAxes.Count < dim) return false;
  695. if (_crdReady && _crdDim == dim) return true;
  696. if (_crdReady)
  697. {
  698. Imc60.IMC_CrdStop(_card, 0, StopAbrupt);
  699. Imc60.IMC_CrdDeleteMtSys(_card, 0);
  700. _crdReady = false;
  701. }
  702. var mask = new short[3];
  703. mask[0] = 0;
  704. mask[1] = 1;
  705. mask[2] = (short)(dim > 2 ? 2 : -1);
  706. var hw = _hwAxes.Values.FirstOrDefault();
  707. double eStopDec = Math.Max(1000, hw != null ? hw.Deceleration * 4 : 1000);
  708. if (!Ok(Imc60.IMC_CrdSetMtSys(_card, 0, mask, 100, eStopDec), "建立插补坐标系"))
  709. return false;
  710. _crdDim = dim;
  711. _crdReady = true;
  712. return true;
  713. }
  714. public void ReloadFromConfig()
  715. {
  716. lock (_sync)
  717. {
  718. RebuildAxes();
  719. if (IsConnected)
  720. {
  721. ApplyAxisBonds();
  722. ApplySafetyLimits();
  723. }
  724. }
  725. }
  726. private void ApplyAxisBonds()
  727. {
  728. var cfgs = MotionAxisCatalog.GetEffective(_cfg);
  729. foreach (var cfg in cfgs)
  730. {
  731. short axType;
  732. short ch = (short)Math.Max(0, cfg.OutputChannel);
  733. switch (cfg.Kind)
  734. {
  735. case MotionAxisKind.Physical:
  736. axType = 1;
  737. break;
  738. default:
  739. axType = -1;
  740. ch = 0;
  741. break;
  742. }
  743. Ok(Imc60.IMC_SetAxBondCfg(_card, (short)cfg.AxisNo, axType, ch),
  744. $"轴{cfg.AxisNo}绑定({cfg.KindText})");
  745. }
  746. }
  747. internal MotionAxisConfig GetAxisConfig(int axisNo)
  748. {
  749. if (_axisCfgs.TryGetValue(axisNo, out var cfg) && cfg != null)
  750. return cfg;
  751. return new MotionAxisConfig { AxisNo = axisNo };
  752. }
  753. internal double ClampAxisPosition(int axis, double position)
  754. => GetAxisConfig(axis).ClampPosition(position);
  755. internal double ClampAxisVelocity(int axis, double velocity)
  756. => GetAxisConfig(axis).ClampVelocity(velocity);
  757. internal double ClampAxisJog(int axis, double velocity, double currentPosition)
  758. => GetAxisConfig(axis).ClampJog(velocity, currentPosition);
  759. private double ClampInterpVelocity(double velocity, int dim)
  760. {
  761. velocity = Math.Abs(velocity);
  762. int n = Math.Max(1, dim);
  763. for (int i = 0; i < n; i++)
  764. velocity = Math.Abs(ClampAxisVelocity(i, velocity));
  765. return velocity;
  766. }
  767. private void ApplySafetyLimits()
  768. {
  769. foreach (var cfg in MotionAxisCatalog.GetEffective(_cfg))
  770. {
  771. short en = (short)(cfg.SoftLimitEnabled ? 1 : 0);
  772. if (cfg.SoftLimitEnabled)
  773. {
  774. int pos = (int)Math.Round(Math.Max(cfg.SoftLimitNeg, cfg.SoftLimitPos));
  775. int neg = (int)Math.Round(Math.Min(cfg.SoftLimitNeg, cfg.SoftLimitPos));
  776. Ok(Imc60.IMC_SetAxSoftLimit(_card, (short)cfg.AxisNo, pos, neg),
  777. $"轴{cfg.AxisNo}软限位");
  778. }
  779. Ok(Imc60.IMC_SetAxSoftLmtsCheck(_card, (short)cfg.AxisNo, en),
  780. $"轴{cfg.AxisNo}软限位检查");
  781. if (cfg.MaxVelocity <= 0) continue;
  782. var para = new Imc60.TMtPara
  783. {
  784. bgVel = 0,
  785. maxVel = cfg.MaxVelocity,
  786. maxAcc = Math.Max(1, cfg.Acceleration),
  787. maxDec = Math.Max(1, cfg.Deceleration),
  788. maxJerk = Math.Max(1, cfg.Jerk),
  789. stopDec = Math.Max(1, cfg.Deceleration),
  790. eStopDec = Math.Max(1, cfg.Deceleration * 4)
  791. };
  792. Ok(Imc60.IMC_SetAxMaxMtPara(_card, (short)cfg.AxisNo, ref para),
  793. $"轴{cfg.AxisNo}最高速度");
  794. }
  795. }
  796. private void RebuildAxes()
  797. {
  798. _follow.Clear();
  799. var oldHw = _hwAxes;
  800. var cfgs = MotionAxisCatalog.GetEffective(_cfg);
  801. _axisCfgs = new Dictionary<int, MotionAxisConfig>();
  802. _hwAxes = new Dictionary<int, InovanceAxis>();
  803. _axisMap = new Dictionary<int, IAxis>();
  804. var view = new List<IAxis>(cfgs.Count);
  805. foreach (var cfg in cfgs)
  806. {
  807. var axis = new InovanceAxis(this, cfg.AxisNo)
  808. {
  809. Name = string.IsNullOrWhiteSpace(cfg.Name) ? $"Axis-{cfg.AxisNo}" : cfg.Name,
  810. Velocity = cfg.Velocity,
  811. Acceleration = cfg.Acceleration,
  812. Deceleration = cfg.Deceleration,
  813. Jerk = cfg.Jerk
  814. };
  815. if (oldHw != null && oldHw.TryGetValue(cfg.AxisNo, out var prev))
  816. {
  817. axis.Name = string.IsNullOrWhiteSpace(cfg.Name) ? prev.Name : cfg.Name;
  818. axis.Velocity = cfg.Velocity > 0 ? cfg.Velocity : prev.Velocity;
  819. axis.Acceleration = cfg.Acceleration > 0 ? cfg.Acceleration : prev.Acceleration;
  820. axis.Deceleration = cfg.Deceleration > 0 ? cfg.Deceleration : prev.Deceleration;
  821. axis.Jerk = cfg.Jerk > 0 ? cfg.Jerk : prev.Jerk;
  822. }
  823. _hwAxes[cfg.AxisNo] = axis;
  824. _axisMap[cfg.AxisNo] = axis;
  825. _axisCfgs[cfg.AxisNo] = cfg;
  826. }
  827. foreach (var cfg in cfgs)
  828. {
  829. if (cfg.IsGrouped && _hwAxes.TryGetValue(cfg.AxisNo, out var master))
  830. {
  831. var combined = new CombinedMotionAxis(this, cfg, master, no =>
  832. _hwAxes.TryGetValue(no, out var a) ? a : null);
  833. _axisMap[cfg.AxisNo] = combined;
  834. view.Add(combined);
  835. }
  836. else if (_axisMap.TryGetValue(cfg.AxisNo, out var hw))
  837. {
  838. view.Add(hw);
  839. }
  840. }
  841. _axes = view.ToArray();
  842. _axisCount = _axes.Length;
  843. }
  844. private bool TryCombined(int axis, out CombinedMotionAxis combined)
  845. {
  846. combined = null;
  847. if (_axisMap.TryGetValue(axis, out var a) && a is CombinedMotionAxis c)
  848. {
  849. combined = c;
  850. return true;
  851. }
  852. return false;
  853. }
  854. private bool IsHardware(int axis) => _hwAxes.ContainsKey(axis);
  855. private void ParseConfigPaths(out string deviceCfg, out string systemCfg)
  856. {
  857. deviceCfg = "";
  858. systemCfg = "";
  859. var raw = _cfg.ConnectionString?.Trim();
  860. if (string.IsNullOrEmpty(raw)) return;
  861. var parts = raw.Split(new[] { '|', ';' }, StringSplitOptions.RemoveEmptyEntries);
  862. if (parts.Length > 0) deviceCfg = ResolvePath(parts[0].Trim());
  863. if (parts.Length > 1) systemCfg = ResolvePath(parts[1].Trim());
  864. }
  865. private static string ResolvePath(string path)
  866. {
  867. if (string.IsNullOrWhiteSpace(path)) return "";
  868. path = path.Trim().Trim('"');
  869. if (File.Exists(path)) return Path.GetFullPath(path);
  870. var baseDir = AppDomain.CurrentDomain.BaseDirectory ?? "";
  871. var combined = Path.Combine(baseDir, path);
  872. if (File.Exists(combined)) return Path.GetFullPath(combined);
  873. var inConfig = Path.Combine(baseDir, "Config", path);
  874. if (File.Exists(inConfig)) return Path.GetFullPath(inConfig);
  875. return Path.IsPathRooted(path) ? path : Path.GetFullPath(combined);
  876. }
  877. private static short MapHomeMethod(int mode)
  878. {
  879. if (mode > 3) return (short)mode;
  880. switch ((HomeMode)mode)
  881. {
  882. case HomeMode.LimitSwitch: return (short)Imc60.HOME_NLIMT;
  883. case HomeMode.HomeSwitch: return (short)Imc60.HOME_NHOME_FEDGE;
  884. case HomeMode.ZPhase: return (short)Imc60.HOME_NEGZINDEX;
  885. default: return (short)Imc60.HOME_NLIMT_ZINDEX;
  886. }
  887. }
  888. private static uint ToUInt(double v) => (uint)Math.Max(1, Math.Min(uint.MaxValue, v));
  889. private static bool Has(int sts, uint bit) => (sts & (int)bit) != 0;
  890. private bool IsValidAxis(int axis) => _axisMap.ContainsKey(axis);
  891. private bool Ok(uint ret, string what)
  892. {
  893. if (ret == Imc60.EXE_SUCCESS) return true;
  894. RaiseError($"{what}失败 (0x{ret:X8})");
  895. return false;
  896. }
  897. private bool FailOpen()
  898. {
  899. try { Imc60.IMC_DelEcatComm(_card); } catch { }
  900. try { Imc60.IMC_CloseCard(_card); } catch { }
  901. IsConnected = false;
  902. return false;
  903. }
  904. private void RaiseError(string message)
  905. {
  906. try { AppLogger.Error(message, null, nameof(InovanceMotionCard)); } catch { }
  907. ErrorOccurred?.Invoke(this, new MotionErrorEventArgs(message));
  908. }
  909. }
  910. /// <summary>汇川卡单轴门面:实时读 SDK 状态,指令转发到卡。</summary>
  911. public class InovanceAxis : IAxis
  912. {
  913. private readonly InovanceMotionCard _card;
  914. private bool _homed;
  915. private bool _homing;
  916. private bool _jogging;
  917. private AxisState _lastState = AxisState.Off;
  918. public int AxisNo { get; }
  919. public string Name { get; set; }
  920. public double Velocity { get; set; } = 100;
  921. public double Acceleration { get; set; } = 500;
  922. public double Deceleration { get; set; } = 500;
  923. public double Jerk { get; set; } = 1000;
  924. public AxisState State
  925. {
  926. get
  927. {
  928. if (!_card.IsConnected) return AxisState.Off;
  929. int sts = _card.ReadSts(AxisNo);
  930. if ((sts & (int)Imc60.AX_ALARM_BIT) != 0 || (sts & (int)Imc60.AX_UNLINK_BIT) != 0)
  931. return AxisState.Error;
  932. if ((sts & (int)Imc60.AX_SVON_BIT) == 0) return AxisState.Off;
  933. if (_homing) return AxisState.Homing;
  934. if (_jogging) return AxisState.ContinuousMotion;
  935. if ((sts & (int)Imc60.AX_BUSY_BIT) != 0) return AxisState.DiscreteMotion;
  936. return AxisState.StandStill;
  937. }
  938. }
  939. public bool IsEnabled => _card.IsConnected && (_card.ReadSts(AxisNo) & (int)Imc60.AX_SVON_BIT) != 0;
  940. public bool IsMoving => _card.IsConnected && ((_card.ReadSts(AxisNo) & (int)Imc60.AX_BUSY_BIT) != 0 || _jogging || _homing);
  941. public bool IsHomed => _homed;
  942. public double CommandPosition => _card.IsConnected ? _card.ReadPrfPos(AxisNo) : 0;
  943. public double ActualPosition => _card.IsConnected ? _card.ReadEncPos(AxisNo) : 0;
  944. public double ActualVelocity => _card.IsConnected ? _card.ReadEncVel(AxisNo) : 0;
  945. public event EventHandler<AxisMotionEventArgs> MotionStarted;
  946. public event EventHandler<AxisMotionEventArgs> MotionCompleted;
  947. public event EventHandler<AxisStateChangedEventArgs> StateChanged;
  948. public event EventHandler<AxisErrorEventArgs> ErrorOccurred;
  949. public InovanceAxis(InovanceMotionCard card, int axisNo)
  950. {
  951. _card = card;
  952. AxisNo = axisNo;
  953. Name = $"Axis-{axisNo}";
  954. }
  955. internal void MarkHoming()
  956. {
  957. _homing = true;
  958. _homed = false;
  959. NotifyState();
  960. }
  961. internal void MarkJogging(bool on)
  962. {
  963. _jogging = on;
  964. NotifyState();
  965. }
  966. internal void AbortHome()
  967. {
  968. if (!_homing) return;
  969. try { _card.FinishHome(AxisNo); } catch { }
  970. _homing = false;
  971. NotifyState();
  972. }
  973. internal void PollHome(InovanceMotionCard card)
  974. {
  975. if (!_homing) return;
  976. short hs = card.ReadHomeStatus(AxisNo);
  977. if (hs == Imc60.HOME_IN_PROGRESS || hs == Imc60.HOME_INTERRUPTED_OR_NOT_START)
  978. return;
  979. if (hs == Imc60.HOME_SUCESS || hs == Imc60.HOME_ATTAINED_BUT_NOT_REACH)
  980. {
  981. card.FinishHome(AxisNo);
  982. _homing = false;
  983. _homed = true;
  984. NotifyState();
  985. MotionCompleted?.Invoke(this, new AxisMotionEventArgs(AxisNo, 0, ActualPosition));
  986. return;
  987. }
  988. card.FinishHome(AxisNo);
  989. _homing = false;
  990. NotifyState();
  991. OnError($"回零失败 (状态 {hs})");
  992. }
  993. public void Enable()
  994. {
  995. if (!_card.AllowEnable(out var reason))
  996. {
  997. ErrorOccurred?.Invoke(this, new AxisErrorEventArgs(AxisNo, reason));
  998. return;
  999. }
  1000. if (!_card.SetEnable(AxisNo, true))
  1001. ErrorOccurred?.Invoke(this, new AxisErrorEventArgs(AxisNo, "使能失败"));
  1002. NotifyState();
  1003. }
  1004. public void Disable()
  1005. {
  1006. _jogging = false;
  1007. AbortHome();
  1008. _card.Stop(AxisNo);
  1009. if (!_card.SetEnable(AxisNo, false))
  1010. ErrorOccurred?.Invoke(this, new AxisErrorEventArgs(AxisNo, "下使能失败"));
  1011. NotifyState();
  1012. }
  1013. public void MoveTo(double position)
  1014. {
  1015. if (!_card.IsConnected) { OnError("运动卡未连接"); return; }
  1016. if (!_card.AllowMotion(out var reason)) { OnError(reason); return; }
  1017. if (!IsEnabled) { OnError("轴未使能,无法运动"); return; }
  1018. if (_card.MoveAbsolute(AxisNo, position, Velocity))
  1019. {
  1020. NotifyState();
  1021. MotionStarted?.Invoke(this, new AxisMotionEventArgs(AxisNo, position, ActualPosition));
  1022. }
  1023. else
  1024. OnError("绝对定位失败");
  1025. }
  1026. public void MoveBy(double distance)
  1027. {
  1028. if (!_card.IsConnected) { OnError("运动卡未连接"); return; }
  1029. if (!_card.AllowMotion(out var reason)) { OnError(reason); return; }
  1030. if (!IsEnabled) { OnError("轴未使能,无法运动"); return; }
  1031. if (_card.MoveRelative(AxisNo, distance, Velocity))
  1032. {
  1033. NotifyState();
  1034. MotionStarted?.Invoke(this, new AxisMotionEventArgs(AxisNo, ActualPosition + distance, ActualPosition));
  1035. }
  1036. else
  1037. OnError("相对定位失败");
  1038. }
  1039. public void Jog(double velocity)
  1040. {
  1041. if (!_card.IsConnected) { OnError("运动卡未连接"); return; }
  1042. if (!_card.AllowMotion(out var reason)) { OnError(reason); return; }
  1043. if (!IsEnabled) { OnError("轴未使能,无法点动"); return; }
  1044. int dir = velocity >= 0 ? 1 : -1;
  1045. if (_card.JogStart(AxisNo, dir, Math.Abs(velocity)))
  1046. {
  1047. NotifyState();
  1048. MotionStarted?.Invoke(this, new AxisMotionEventArgs(AxisNo, double.NaN, ActualPosition));
  1049. }
  1050. else
  1051. OnError("点动失败");
  1052. }
  1053. public void Stop()
  1054. {
  1055. AbortHome();
  1056. _jogging = false;
  1057. _card.Stop(AxisNo);
  1058. NotifyState();
  1059. MotionCompleted?.Invoke(this, new AxisMotionEventArgs(AxisNo, CommandPosition, ActualPosition));
  1060. }
  1061. public void Home(HomeMode mode = HomeMode.Default)
  1062. {
  1063. if (!_card.IsConnected) { OnError("运动卡未连接"); return; }
  1064. if (!_card.AllowMotion(out var reason)) { OnError(reason); return; }
  1065. if (!IsEnabled) { OnError("轴未使能,无法回零"); return; }
  1066. if (_card.Home(AxisNo, (int)mode))
  1067. {
  1068. NotifyState();
  1069. MotionStarted?.Invoke(this, new AxisMotionEventArgs(AxisNo, 0, ActualPosition));
  1070. }
  1071. else
  1072. OnError("回零失败");
  1073. }
  1074. public void SetPosition(double position)
  1075. {
  1076. if (!_card.SetCurrentPosition(AxisNo, position))
  1077. OnError("设置当前位置失败");
  1078. }
  1079. public void SetMotionParams(MotionParams parameters)
  1080. {
  1081. if (parameters == null) return;
  1082. Velocity = parameters.Velocity;
  1083. Acceleration = parameters.Acceleration;
  1084. Deceleration = parameters.Deceleration;
  1085. Jerk = parameters.Jerk;
  1086. _card.ApplyMovePara(AxisNo, Velocity);
  1087. }
  1088. private void OnError(string message) => ErrorOccurred?.Invoke(this, new AxisErrorEventArgs(AxisNo, message));
  1089. internal void SyncState() => NotifyState();
  1090. private void NotifyState()
  1091. {
  1092. var now = State;
  1093. if (now == _lastState) return;
  1094. var old = _lastState;
  1095. _lastState = now;
  1096. StateChanged?.Invoke(this, new AxisStateChangedEventArgs(AxisNo, old, now));
  1097. }
  1098. }
  1099. public class Imc60
  1100. {
  1101. #region STATIC
  1102. public const string Imc60ApiDllName = "IMC_Library_x64.dll";
  1103. #endregion
  1104. #region FUNCTION RETURN DEFINE
  1105. public const uint EXE_SUCCESS = 0x00000000;
  1106. public const uint ERR_HANDLE = 0xFFFFFFFF;
  1107. #endregion
  1108. /// @brief 主站信息结构体
  1109. [StructLayout(LayoutKind.Sequential)]
  1110. public struct TMasterInfo
  1111. {
  1112. public UInt32 cycleTime; // 规划周期
  1113. public Int16 sysHwCfg; // 系统类型: 0: Ecat+端子板, 1 Ecat, 2: 端子板
  1114. public Int16 aliasMode; // 别名模式: 0 未开启, 1 开启
  1115. public Int16 pdoLen; // pdo总长度
  1116. public Int16 slaveCnt; // 从站个数
  1117. public Int16 axisCnt; // 轴个数
  1118. public Int16 dioModuleCnt; // dio模块个数
  1119. public Int16 aioModuleCnt; // aio模块个数
  1120. public Int16 regModuleCnt; // reg模块个数
  1121. public Int16 diCnt; // di数量
  1122. public Int16 doCnt; // do数量
  1123. public Int16 aiCnt; // ai,AD数量
  1124. public Int16 aoCnt; // ao, DA数量
  1125. public Int16 regInCnt; // reg输入数量
  1126. public Int16 regOutCnt; // reg输出数量
  1127. public Int16 encCnt; // enc通道数量
  1128. public Int16 align;
  1129. };
  1130. /// @brief 从站信息结构体
  1131. [StructLayout(LayoutKind.Sequential)]
  1132. public struct TSlaveInfo
  1133. {
  1134. public Int16 devType; // 设备类型
  1135. public UInt32 vendorId; // 设备ID
  1136. public UInt32 productCode; // 产品编码
  1137. public UInt32 revisionNo; // 版本号
  1138. public Int16 axChn; // 从站起始通道号
  1139. public Int16 axisCnt; // 当前从站轴数
  1140. public Int16 actStation; // 当前从站对应的实际站号
  1141. public UInt32 aliasNo; // 别名
  1142. public UInt32 align;
  1143. };
  1144. /// @brief PdoEntry结构体
  1145. [StructLayout(LayoutKind.Sequential)]
  1146. public struct TPdoEntry
  1147. {
  1148. public UInt16 Index; // 索引
  1149. public Byte SubIndex; // 子索引
  1150. public Byte DevType; // entry类型
  1151. public Int16 BitOfs; // 位偏移
  1152. public UInt32 BitLen; // 位长度
  1153. };
  1154. /// @brief 回零参数结构体
  1155. [StructLayout(LayoutKind.Sequential)]
  1156. public struct THomingPara
  1157. {
  1158. public Int16 homeMethod; // 回原点方法
  1159. public UInt32 highVel; // 高速搜索减速点速度 pulse/s
  1160. public UInt32 lowVel; // 搜索原点低 pulse/s
  1161. public UInt32 acc; // 加速度 pulse/s^2
  1162. public Int32 offset; // 回原点后的零点偏执 pulse
  1163. };
  1164. /// @brief 多维位置比较数据结构体
  1165. [StructLayout(LayoutKind.Sequential)]
  1166. public struct TMultiCmpData
  1167. {
  1168. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
  1169. public Int32[] compareData; // 比较的位置
  1170. };
  1171. /// @brief 规划运动限制参数结构体
  1172. [StructLayout(LayoutKind.Sequential)]
  1173. public struct TMtPara
  1174. {
  1175. public double bgVel; // 起始速度值 unit/s
  1176. public double maxVel; // 最大速度 unit/s
  1177. public double maxAcc; // 最大加速度 unit/s^2
  1178. public double maxDec; // 最大减速度 unit/s^2
  1179. public double maxJerk; // 最大加加速度 unit/s^3
  1180. public double stopDec; // 平滑停止减速度 unit/s^2
  1181. public double eStopDec; // 急停减速度 unit/s^2
  1182. };
  1183. /// @brief 轴属性配置结构体
  1184. [StructLayout(LayoutKind.Sequential)]
  1185. public struct TAxAttriPara
  1186. {
  1187. public Int16 arrivalBand; // 到位误差 pulse
  1188. public UInt16 arrivalTime; // 到位保持时间 周期
  1189. public Int32 errorLmt; // 最大跟随误差 pulse
  1190. public Int32 softPosLimitPos; // 软正限位 pulse
  1191. public Int32 softNegLimitPos; // 软负限位 pulse
  1192. };
  1193. /// @brief 轴安全检查配置结构体
  1194. [StructLayout(LayoutKind.Sequential)]
  1195. public struct TAxCheckEn
  1196. {
  1197. public Int16 alarmEn; // 报警是否有效标志
  1198. public Int16 softLmtEn; // 软限位是否有效标志
  1199. public Int16 hwLmtEn; // 硬限位是否有效标志
  1200. public Int16 errorLmtEn; // 跟随误差是否检查标志
  1201. };
  1202. /// @brief 插补高级参数结构体
  1203. [StructLayout(LayoutKind.Sequential)]
  1204. public struct TCrdAdvParam
  1205. {
  1206. public Int16 userVelMode; // 用户速度规划模式: 0 系统前瞻速度规划, 1 用户设定速度规划(默认: 0)
  1207. public Int16 transMode; // 过渡模式 0: 无过渡 1: 圆弧过渡 (默认:1)
  1208. public Int16 noDataProtect; // 数据断流保护: 0不保护, 1保护 (默认: 1)
  1209. public Int16 circAccChangeEn; // 圆弧变加速使能: 0不变加速, 1变加速 (默认: 0)
  1210. public Int16 noCoplaneCircOptm; // 异面圆弧优化: 0不开启, 1开启
  1211. public double turnCoef; // 拐弯系数:[0.01,100](默认:1.0)
  1212. public double tol; // 插补精度:[0,1e9](默认:0 , 单位取决于设置的当量)
  1213. };
  1214. /// @brief 电子齿轮参数结构体
  1215. [StructLayout(LayoutKind.Sequential)]
  1216. public struct TGearParam
  1217. {
  1218. public Int32 masterScale; // 主轴齿数: (0,intMax]
  1219. public Int32 slaveScale; // 从轴齿数: [intMin,0) || (0,intMax]
  1220. public Int16 masterNo; // 主轴轴号: [0,63]
  1221. public Int16 masterType; // 主轴类型: 0 轴规划, 1 轴编码器, 10 端子板编码器, 11 EtherCAT编码器
  1222. public Int16 dirMode; // 方向模式: 0 跟随方向不限制, 1 正向绝对位置跟随, 2 负向绝对位置跟随, 3 正向相对位置跟随, 4 负向相对位置跟随
  1223. public Int32 masterSlopeDis; // 主轴离合区:[0,intMax], 0表示没有加速过程,直接跟随
  1224. };
  1225. /// @brief 表补偿参数结构体
  1226. public struct TTableCompParam
  1227. {
  1228. public Int16 tableId; // 表索引:[0,0]
  1229. public Int16 dimension; // 补偿维数:{1,2,3}
  1230. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
  1231. public Int16[] srcAxNo; // 参考轴号:[0,63],数组有效的元素与补偿维数有关,如补偿维数=1,仅用到srcAxNo[0], 下同
  1232. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
  1233. public Int16[] srcType; // 参考轴类型:0 轴规划, 1 轴编码器
  1234. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
  1235. public Int32[] startPos; // 补偿起始位置:[intMin,intMax]
  1236. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
  1237. public Int32[] count; // 补偿点个数:[2,40000] (有效的元素的乘积不得超过40000,且各不小于2)
  1238. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
  1239. public Int32[] step; // 补偿间隔:[1,intMax]
  1240. };
  1241. /// @brief 采样配置参数结构体
  1242. [StructLayout(LayoutKind.Sequential)]
  1243. public struct TSamplePara
  1244. {
  1245. public Int16 interval; // 采样时间间隔
  1246. public Int16 trigType; // 触发采样类型: 0 立即 1 延时 2 本地di 3 ECAT di
  1247. public Int16 delay; // 延时时间 单位:周期
  1248. public Int16 diNo; // di输入号
  1249. public Int16 diLevel; // di的触发输入值 0或1
  1250. };
  1251. /// @brief 事件配置参数结构体
  1252. ///
  1253. #region Event
  1254. [StructLayout(LayoutKind.Sequential)]
  1255. public struct TEvent
  1256. {
  1257. public Int16 type; //事件类型
  1258. public Int16 index; //事件变量索引
  1259. public UInt32 loop; //事件最大允许触发次数
  1260. public double value; //设置比较值
  1261. public Int16 condition; //事件条件
  1262. };
  1263. [StructLayout(LayoutKind.Sequential)]
  1264. public struct TTaskCrdStart
  1265. {
  1266. public Int16 crdNo;
  1267. };
  1268. [StructLayout(LayoutKind.Sequential)]
  1269. public struct TTaskStartPtp
  1270. {
  1271. public Int16 axNo;
  1272. public Int16 posType;
  1273. public double tgtPos;
  1274. };
  1275. [StructLayout(LayoutKind.Sequential)]
  1276. public struct TTaskStartJog
  1277. {
  1278. public Int16 axNo;
  1279. public double tgtVel;
  1280. };
  1281. [StructLayout(LayoutKind.Sequential)]
  1282. public struct TTaskStartGear
  1283. {
  1284. public Int16 axNo;
  1285. };
  1286. [StructLayout(LayoutKind.Sequential)]
  1287. public struct TTaskStartPt
  1288. {
  1289. public Int16 sysNo;
  1290. };
  1291. [StructLayout(LayoutKind.Sequential)]
  1292. public struct TTaskStartPvt
  1293. {
  1294. public Int16 axNum;
  1295. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
  1296. public Int16[] axArray;
  1297. };
  1298. [StructLayout(LayoutKind.Sequential)]
  1299. public struct TTaskUpdatePtpMvPara
  1300. {
  1301. public Int16 axNo;
  1302. public double tgtVel;
  1303. public double tgtAcc;
  1304. public double tgtDec;
  1305. };
  1306. [StructLayout(LayoutKind.Sequential)]
  1307. public struct TTaskUpdateJogMvPara
  1308. {
  1309. public Int16 axNo;
  1310. public double tgtVel;
  1311. public double tgtAcc;
  1312. public double tgtDec;
  1313. };
  1314. [StructLayout(LayoutKind.Sequential)]
  1315. public struct TTaskUpdatePtpTgtPos
  1316. {
  1317. public Int16 axNo;
  1318. public double tgtPos;
  1319. };
  1320. [StructLayout(LayoutKind.Sequential)]
  1321. public struct TTaskSetEcatDoBit
  1322. {
  1323. public Int16 doNo;
  1324. public Int16 value;
  1325. };
  1326. [StructLayout(LayoutKind.Sequential)]
  1327. public struct TTaskSetEcatGrpDo
  1328. {
  1329. public Int16 groupNo;
  1330. public Int16 value;
  1331. };
  1332. [StructLayout(LayoutKind.Sequential)]
  1333. public struct TTaskSetEcatDoBitInverse
  1334. {
  1335. public Int16 doIndex;
  1336. public Int16 value;
  1337. public Int16 inverseTime;
  1338. };
  1339. [StructLayout(LayoutKind.Sequential)]
  1340. public struct TTaskSetEcatDaVal
  1341. {
  1342. public Int16 daIndex;
  1343. public Int16 value;
  1344. };
  1345. [StructLayout(LayoutKind.Sequential)]
  1346. public struct TTaskStopMove
  1347. {
  1348. public Int16 axNo;
  1349. public Int16 stopType;
  1350. };
  1351. [StructLayout(LayoutKind.Sequential)]
  1352. public struct TTaskPulseDo
  1353. {
  1354. public Int16 taskPulseDoIndex;
  1355. public Int16 firstLevel;
  1356. public Int32 highLevelTime;
  1357. public Int32 lowLevelTime;
  1358. public Int16 pulseNum;
  1359. };
  1360. [StructLayout(LayoutKind.Sequential)]
  1361. public struct UTask
  1362. {
  1363. public TTaskCrdStart taskCrdStart;
  1364. public TTaskStartPtp taskStartPtp;
  1365. public TTaskStartJog taskStartJog;
  1366. public TTaskStartGear taskStartGear;
  1367. public TTaskStartPt taskStartPt;
  1368. public TTaskStartPvt taskStartPvt;
  1369. public TTaskUpdatePtpMvPara taskUpdatePtpMvPara;
  1370. public TTaskUpdateJogMvPara taskUpdateJogMvPara;
  1371. public TTaskSetEcatDoBit taskSetEcatDoBit;
  1372. public TTaskSetEcatGrpDo taskSetEcatGrpDo;
  1373. public TTaskSetEcatDoBitInverse taskSetEcatDoBitInverse;
  1374. public TTaskSetEcatDaVal taskSetEcatDaVal;
  1375. public TTaskUpdatePtpTgtPos taskUpdatePtpTgtPos;
  1376. public TTaskPulseDo taskPulseDo;
  1377. public TTaskStopMove taskStopMove;
  1378. };
  1379. #endregion
  1380. /// @defgroup EcatDef EtherCAT相关宏定义
  1381. /// @brief EtherCAT相关宏定义
  1382. #region
  1383. /// @defgroup MasterSts 主站状态码
  1384. /// @brief 板卡ECAT主站状态定义
  1385. #region
  1386. public const uint EC_MASTER_IDLE = (0); ///< EtherCat主站尚未初始化
  1387. public const uint EC_MASTER_INIT = (1); ///< EtherCat主站初始化
  1388. public const uint EC_MASTER_SCAN_SLAVE = (2); ///< EtherCat主站正在扫描从站设备
  1389. public const uint EC_MASTER_SCAN_SLAVE_END = (3); ///< EtherCat主站扫描从站设备结束
  1390. public const uint EC_MASTER_SCAN_MODULES = (4); ///< EtherCat主站正在扫描从站设备MODULES
  1391. public const uint EC_MASTER_SCAN_MODULES_END = (5); ///< EtherCat主站扫描从站设备MODULES结束
  1392. public const uint EC_MASTER_OP = (6); ///< EtherCat主站进入OP状态
  1393. public const uint EC_MASTER_ERR = (7); ///< EtherCat主站链路状态有错误
  1394. #endregion
  1395. /// @defgroup SlaveSts 从站状态码
  1396. /// @brief 板卡EtherCAT从站状态定义
  1397. #region
  1398. public const uint EC_SLAVE_STATE_UNKNOWN = (0x00); ///< EtherCat从站在未知状态
  1399. public const uint EC_SLAVE_STATE_INIT = (0x01); ///< EtherCat从站在初始状态
  1400. public const uint EC_SLAVE_STATE_PREOP = (0x02); ///< EtherCat从站在PREOP状态
  1401. public const uint EC_SLAVE_STATE_BOOT = (0x03); ///< EtherCat从站在BOOT状态
  1402. public const uint EC_SLAVE_STATE_SAFEOP = (0x04); ///< EtherCat从站在SAVEOP状态
  1403. public const uint EC_SLAVE_STATE_OP = (0x08); ///< EtherCat从站在OP状态
  1404. public const uint EC_SLAVE_STATE_ACK_ERR = (0x10); ///< EtherCat从站有错误
  1405. #endregion
  1406. /// @defgroup EcatError 协议栈错误码
  1407. /// @brief 协议栈错误码EcatErrorCode定义
  1408. #region
  1409. public const uint ERROR_CODE_NO_SUCH_SLAVE = (0x0003); ///< 配置阶段, 没有这个从站, 处理方法: 检查从站是否掉线, 重新扫描配置
  1410. public const uint ERROR_CODE_INVALID_PDO = (0x0004); ///< 配置阶段, 非法PDO, 处理方法: 检查从站厂家是否更新xml配置文件, 与汇川默认配置不一致
  1411. public const uint ERROR_CODE_INVALID_SDO = (0x0005); ///< 配置阶段, 非法SDO, 处理方法: 检查从站厂家是否更新xml配置文件, 与汇川默认配置不一致
  1412. public const uint ERROR_CODE_INVALID_ENTRY = (0x0006); ///< 配置阶段, 非法ENTRY, 处理方法: 检查从站厂家是否更新xml配置文件, 与汇川默认配置不一致
  1413. public const uint ERROR_CODE_PASECFGFAIL = (0x000D); ///< 解析XML设备配置失败, 处理方法: 设备配置文件已经被破坏, 重新扫描配置
  1414. public const uint ERROR_CODE_CFGREGISTFAIL = (0x0015); ///< 配置reg失败, 处理方法: 检查从站厂家是否更新xml配置文件, 与汇川默认配置不一致
  1415. public const uint ERROR_CODE_CFGDIFFONLINE = (0x0016); ///< 在线从站与配置不一致, 处理方法: 检查从站是否掉线, 重新扫描配置
  1416. public const uint ERROR_CODE_AXIS_NUM_BEYOND = (0x0017); ///< 轴配置数量超过板卡最大支持轴数;
  1417. public const uint ERROR_CODE_SLAVE_OFFLINE = (0x001a); ///< 从站掉线错误, 高8位为从站号, 即bit[15:8]-轴号, 处理方法: 检查从高8位数字开始从站是否掉线, 或者重新扫描配置
  1418. public const uint ERROR_CODE_SDOBF_NONECAT = (0x001b); ///< SDO缓冲区收到非ECAT帧错误, 处理方法: 检查线路是否接错, 是否有其他非Ethercat设备接入
  1419. public const uint ERROR_CODE_PORT0_NOTLINK = (0x001c); ///< 端口未接ECAT设备错误, 处理方法: 检查板卡端线路是否正常接线, 是否接线不可靠
  1420. public const uint ERROR_CODE_SET_CYCLETIME_PARA_ERR = (0x001e); ///< 设置周期时间参数错误, 处理方法: 错误的DC时钟配置, 只支持125us, 250us, 500us, 125us, 1000us, 2000us, 4000us, 8000us周期
  1421. public const uint ERROR_CODE_COE_SDO_INIT_ERR = (0x001f); ///< 在初始化阶段coe配置错误, 处理方法: 检查从站厂家是否更新xml配置文件, 与汇川默认配置不一致; 或者可能例如RTU模块配置错误
  1422. public const uint ERROR_CODE_SLAVE_STATE_ERR = (0x0020); ///< 从站状态错误, 高8位为轴号, 即bit[15:8]-轴号, 处理方法: 检查从高8位数字从站状态, 检查从站设备异常原因
  1423. public const uint ERROR_CODE_SLAVE_SII_ERR = (0x0037); ///< E2ROM 信息有误, 处理方法: 一般为从站保存的e2rom信息有误, 可以使用twincat确认并联系厂家
  1424. public const uint ERROR_CODE_SLAVE_NUM_BEYOND = (0x003b); ///< 从站在线超过最大64个站
  1425. #endregion
  1426. /// @defgroup AbortCode SDO访问舍弃码
  1427. /// @brief 以下宏定义针对IIMC_GetEcatSdo, IMC_SetEcatSdo函数
  1428. #region
  1429. public const uint ABORT_CODE1 = (0x05030000); ///< 从站Toggle bit 没有变化
  1430. public const uint ABORT_CODE2 = (0x05040000); ///< SDO 访问超时
  1431. public const uint ABORT_CODE3 = (0x05040001); ///< 客户端/服务器 命令非法或未知
  1432. public const uint ABORT_CODE4 = (0x05040005); ///< 内存溢出
  1433. public const uint ABORT_CODE5 = (0x06010000); ///< 不支持访问该对象
  1434. public const uint ABORT_CODE6 = (0x06010001); ///< 尝试去读一个只写对象
  1435. public const uint ABORT_CODE7 = (0x06010002); ///< 尝试去写一个只读对象
  1436. public const uint ABORT_CODE8 = (0x06020000); ///< 对象字典中不存在该对象
  1437. public const uint ABORT_CODE9 = (0x06040041); ///< 该对象不能映射成PDO
  1438. public const uint ABORT_CODE10 = (0x06040042); ///< 对象映射成PDO超出 PDO长度
  1439. public const uint ABORT_CODE11 = (0x06040043); ///< 通用参数非法
  1440. public const uint ABORT_CODE12 = (0x06040047); ///< 设备内不兼容
  1441. public const uint ABORT_CODE13 = (0x06060000); ///< 由于硬件原因访问失败
  1442. public const uint ABORT_CODE14 = (0x06070010); ///< 数据类型不匹配, 长度参数
  1443. public const uint ABORT_CODE15 = (0x06070012); ///< 数据类型不匹配, 长度太大
  1444. public const uint ABORT_CODE16 = (0x06070013); ///< 数据类型不匹配, 长度太小
  1445. public const uint ABORT_CODE17 = (0x06090011); ///< 该对象子索引不存在
  1446. public const uint ABORT_CODE18 = (0x06090030); ///< 参数超出范围
  1447. public const uint ABORT_CODE19 = (0x06090031); ///< 参数超出范围太大
  1448. public const uint ABORT_CODE20 = (0x06090032); ///< 参数超出范围太小
  1449. public const uint ABORT_CODE21 = (0x06090036); ///< 最大值小于最小值
  1450. public const uint ABORT_CODE22 = (0x08000000); ///< 一般错误
  1451. public const uint ABORT_CODE23 = (0x08000020); ///< 数据不能被传输或被保存
  1452. public const uint ABORT_CODE24 = (0x08000021); ///< 数据不能被传输或被保存由于本地控制
  1453. public const uint ABORT_CODE25 = (0x08000022); ///< 数据不能被传输或被保存由于当前状态
  1454. public const uint ABORT_CODE26 = (0x08000023); ///< 缺乏对象字典或者对象字典创建失败
  1455. #endregion
  1456. /// @defgroup ServoOpMode 伺服操作模式定义
  1457. /// @brief 定义了伺服402协议中的控制模式
  1458. #region
  1459. public const Int16 TQ_OP_MODE = (4); ///< TQ模式
  1460. public const Int16 HM_OP_MODE = (6); ///< 回零模式
  1461. public const Int16 CSP_OP_MODE = (8); ///< CSP模式
  1462. public const Int16 CSV_OP_MODE = (9); ///< CSV模式
  1463. public const Int16 CST_OP_MODE = (10); ///< CST模式
  1464. #endregion
  1465. /// @defgroup EcatHomingMethod 402回零方法定义
  1466. /// @brief 定义了伺服402回零模式的回零方法类型
  1467. #region
  1468. public const uint HOME_NLIMT_ZINDEX = (1); ///< 负限位+Z信号
  1469. public const uint HOME_PLIMT_ZINDEX = (2); ///< 正限位+Z信号
  1470. public const uint HOME_PHOME_FEDGE_ZINDEX = (3); ///< 正原点开关下降沿+Z信号
  1471. public const uint HOME_PHOME_REDGE_ZINDEX = (4); ///< 正原点开关上升沿+Z信号
  1472. public const uint HOME_NHOME_FEDGE_ZINDEX = (5); ///< 负原点开关下降沿+Z信号
  1473. public const uint HOME_NHOME_REDGE_ZINDEX = (6); ///< 负原点开关上升沿+Z信号
  1474. public const uint HOME_PLIMT_PHOME_FEDGE_ZINDEX = (7); ///< 正限位+正原点开关下降沿+Z信号
  1475. public const uint HOME_PLIMT_PHOME_REDGE_ZINDEX = (8); ///< 正限位+正原点开关上升沿+Z信号
  1476. public const uint HOME_PLIMT_NHOME_REDGE_ZINDEX = (9); ///< 正限位+负原点开关上升沿+Z信号
  1477. public const uint HOME_PLIMT_NHOME_FEDGE_ZINDEX = (10); ///< 正限位+负原点开关下降沿+Z信号
  1478. public const uint HOME_NLIMT_NHOME_FEDGE_ZINDEX = (11); ///< 负限位+负原点开关下降沿+Z信号
  1479. public const uint HOME_NLIMT_NHOME_REDGE_ZINDEX = (12); ///< 负限位+负原点开关上升沿+Z信号
  1480. public const uint HOME_NLIMT_PHOME_REDGE_ZINDEX = (13); ///< 负限位+正原点开关上升沿+Z信号
  1481. public const uint HOME_NLIMT_PHOME_FEDGE_ZINDEX = (14); ///< 负限位+正原点开关下降沿+Z信号
  1482. public const uint HOME_NLIMT = (17); ///< 负限位
  1483. public const uint HOME_PLIMT = (18); ///< 正限位
  1484. public const uint HOME_PHOME_FEDGE = (19); ///< 正原点开关下降沿
  1485. public const uint HOME_PHOME_REDGE = (20); ///< 正原点开关上升沿
  1486. public const uint HOME_NHOME_FEDGE = (21); ///< 负原点开关下降沿
  1487. public const uint HOME_NHOME_REDGE = (22); ///< 负原点开关上升沿
  1488. public const uint HOME_PLIMT_PHOME_FEDGE = (23); ///< 正限位+正原点开关下降沿
  1489. public const uint HOME_PLIMT_PHOME_REDGE = (24); ///< 正限位+正原点开关上升沿
  1490. public const uint HOME_PLIMT_NHOME_REDGE = (25); ///< 正限位+负原点开关上升沿
  1491. public const uint HOME_PLIMT_NHOME_FEDGE = (26); ///< 正限位+负原点开关下降沿
  1492. public const uint HOME_NLIMT_NHOME_FEDGE = (27); ///< 负限位+负原点开关下降沿
  1493. public const uint HOME_NLIMT_NHOME_REDGE = (28); ///< 负限位+负原点开关上升沿
  1494. public const uint HOME_NLIMT_PHOME_REDGE = (29); ///< 负限位+正原点开关上升沿
  1495. public const uint HOME_NLIMT_PHOME_FEDGE = (30); ///< 负限位+正原点开关下降沿
  1496. public const uint HOME_NEGZINDEX = (33); ///< 负向Z信号
  1497. public const uint HOME_POSZINDEX = (34); ///< 正向Z信号
  1498. public const uint HOME_CURRENT_POS = (35); ///< 当前位置
  1499. #endregion
  1500. /// @defgroup EcatHomingSts 402回零状态定义
  1501. /// @brief 定义了伺服402回零模式下的工作状态
  1502. #region
  1503. public const Int16 HOME_IN_PROGRESS = (0); ///< 正在回零中
  1504. public const Int16 HOME_INTERRUPTED_OR_NOT_START = (1); ///< 回零中断或者没有开始启动
  1505. public const Int16 HOME_ATTAINED_BUT_NOT_REACH = (2); ///< 回零结束, 但没有到设定的目标位置
  1506. public const Int16 HOME_SUCESS = (3); ///< 回零成功
  1507. public const Int16 HOME_ERR_VEL_NOT_ZERO = (4); ///< 回零中发生错误, 同时速度不为0
  1508. public const Int16 HOME_ERR_VEL_ZERO = (5); ///< 回零中发生错误, 同时速度为0
  1509. #endregion
  1510. /// @defgroup CSPHomingMethod CSP回零方法定义
  1511. /// @brief 定义了板卡CSP回零模式的回零方法
  1512. #region
  1513. public const Int32 HOMING_ECAT_CSP_METHOD_NONE = (-1); ///< 非回零模式
  1514. public const Int32 HOMING_ECAT_CSP_METHOD_DI = (0); ///< DI回零方式
  1515. public const Int32 HOMING_ECAT_CSP_METHOD_INDEX = (1); ///< Index回零方式
  1516. public const Int32 HOMING_ECAT_CSP_METHOD_LIMIT_INDEX = (2); ///< 限位+Index回零方式
  1517. public const Int32 HOMING_ECAT_CSP_METHOD_LIMIT_DI = (3); ///< 限位+Di回零方式
  1518. #endregion
  1519. /// @defgroup CSPHomingSts CSP回零状态定义
  1520. /// @brief 定义了板卡CSP回零模式下的工作状态
  1521. #region
  1522. public const Int16 HOME_CSP_STS_RUNING = (0x01); ///< CSP回零中
  1523. public const Int16 HOME_CSP_STS_STOPPING = (0x02); ///< CSP回零停止中
  1524. public const Int16 HOME_CSP_STS_STOPPED = (0x03); ///< CSP回零已停止
  1525. public const Int16 HOME_CSP_STS_FINISH = (0x04); ///< CSP回零已完成
  1526. public const Int16 HOME_CSP_STS_ERROR = (0x05); ///< CSP回零错误
  1527. #endregion
  1528. #endregion
  1529. /// @defgroup CardSysDef 板卡系统相关宏定义
  1530. #region
  1531. /// @defgroup CardResType 资源类型宏定义
  1532. /// @brief 以下宏定义针对IMC_GetResCount函数
  1533. #region
  1534. public const uint MC_ECAT_DO = (0); ///< ecat的通用do
  1535. public const uint MC_LOCAL_DO = (1); ///< localBus的通用do
  1536. public const uint MC_ECAT_DI = (11); ///< ecat的通用DI
  1537. public const uint MC_ECAT_AD = (12); ///< ecat的通用AD
  1538. public const uint MC_ECAT_DA = (13); ///< ecat的通用DA
  1539. public const uint MC_ECAT_AXIS = (15); ///< ecat的通用AXIS
  1540. public const uint MC_ECAT_REG_IN = (16); ///< ecat的通用RegIn
  1541. public const uint MC_ECAT_REG_OUT = (17); ///< ecat的通用RegOut
  1542. public const uint MC_ECAT_ENC = (18); ///< ecat的通用RegOut
  1543. public const uint MC_AXIS = (30); ///< 板卡最大轴数
  1544. public const uint MC_PROFILE = (31); ///< 板卡规划轴数
  1545. public const uint MC_CRD_MAX_CNT = (60); ///< 坐标系最大个数
  1546. public const uint MC_CRD_BUF_LEN = (61); ///< 坐标系缓冲区长度
  1547. #endregion
  1548. /// @defgroup CardVersionType 板卡系统版本类型定义
  1549. /// @brief 以下宏定义针对IMC_GetImcCardVersion函数
  1550. #region
  1551. public const uint SOFT_VERSION = (0); // 总软件版本
  1552. public const uint DSP_VERSION = (1); // HAL2软件版本
  1553. public const uint ARM_VERSION = (2); // ARM软件版本
  1554. public const uint API_VERSION = (3); // API软件版本
  1555. public const uint FPGA_VERSION = (4); // FPGA固件版本
  1556. public const uint DSP2_VERSION = (5); // HAL3固件版本
  1557. public const uint LOCAL_VERSION = (6); // 端子板固件版本
  1558. public const uint OS_ARM_VERSION = (11); // ARM系统版本
  1559. public const uint LIB_DSP_VERSION = (12); // LibInfo软件版本
  1560. public const uint LIB_ECAT_BOARD_APP_VERSION = (20); // 协议栈软件版本1
  1561. public const uint LIB_ECAT_APP_VERSION = (21); // 协议栈软件版本2
  1562. public const uint LIB_ECAT_VERSION = (22); // 协议栈软件版本3
  1563. public const uint LIB_ECAT_PARSER_ENI_VERSION = (23); // 协议栈软件版本4
  1564. #endregion
  1565. #endregion
  1566. /// @defgroup AxDiStopType 轴DI停止类型定义
  1567. /// @brief 以下宏定义针对IMC_SetAxStopTrigPara、IMC_GetAxStopTrigPara函数
  1568. #region
  1569. public const uint CNST_DI_STOP_TYPE_ECATDI = (0); ///< EcatDI停止类型
  1570. public const uint CNST_DI_STOP_TYPE_PROBLE1_RF = (1); ///< 探针1上升沿或下降沿停止
  1571. public const uint CNST_DI_STOP_TYPE_PROBLE1_R = (2); ///< 探针1上升沿停止
  1572. public const uint CNST_DI_STOP_TYPE_PROBLE1_F = (3); ///< 探针1下降沿停止
  1573. #endregion
  1574. /// @defgroup AxStsBit 轴状态位定义
  1575. /// @brief 以下宏定义针对IMC_GetAxSts函数
  1576. #region
  1577. public const uint AX_ALARM_BIT = (0x00000001); ///< 轴驱动报警
  1578. public const uint AX_SVON_BIT = (0x00000002); ///< 伺服使能
  1579. public const uint AX_BUSY_BIT = (0x00000004); ///< 轴忙状态
  1580. public const uint AX_ARRIVE_BIT = (0x00000008); ///< 轴到位状态
  1581. public const uint AX_POSLMT_BIT = (0x00000010); ///< 正硬限位报警
  1582. public const uint AX_NEGLMT_BIT = (0x00000020); ///< 负硬限位报警
  1583. public const uint AX_SOFT_POSLMT_BIT = (0x00000040); ///< 正软限位报警
  1584. public const uint AX_SOFT_NEGLMT_BIT = (0x00000080); ///< 负软限位报警
  1585. public const uint AX_ERRPOS_BIT = (0x00000100); ///< 轴位置误差越限标志
  1586. public const uint AX_EMG_STOP_BIT = (0x00000200); ///< 运动急停标志
  1587. public const uint AX_ECAT_BIT = (0x00000400); ///< 总线轴标志
  1588. public const uint AX_SW_ABNOR_BIT = (0x00000800); ///< 轴异常报警=(龙门);
  1589. public const uint AX_WARING_BIT = (0x00001000); ///< 轴警告
  1590. public const uint AX_HM_BIT = (0x00002000); ///< 原点信号状态
  1591. public const uint AX_UNLINK_BIT = (0x00004000); ///< 轴掉线状态
  1592. public const uint AX_ECAT_TGTREACH_BIT = (0x00008000); ///< 状态字里的到位状态
  1593. #endregion
  1594. /******************采集数据类型 定义***************************/
  1595. // 单轴数据类型
  1596. public const Int16 SAMPLE_ADDRESS_TYPE_AX_PRF_POS = (0x01); ///< 轴规划位置
  1597. public const Int16 SAMPLE_ADDRESS_TYPE_AX_ENC_POS = (0x02); ///< 轴编码器位置
  1598. public const Int16 SAMPLE_ADDRESS_TYPE_AX_PRF_VEL = (0x03); ///< 轴规划速度
  1599. public const Int16 SAMPLE_ADDRESS_TYPE_AX_ENC_VEL = (0x04); ///< 轴编码器速度
  1600. public const Int16 SAMPLE_ADDRESS_TYPE_AX_PRF_ACC = (0x05); ///< 轴规划加速度
  1601. public const Int16 SAMPLE_ADDRESS_TYPE_AX_ENC_ACC = (0x06); ///< 轴编码器加速度
  1602. public const Int16 SAMPLE_ADDRESS_TYPE_PRF_POS = (0x07); ///< 规划位置
  1603. public const Int16 SAMPLE_ADDRESS_TYPE_PRF_CMPPOS = (0x08); ///< 比较位置
  1604. public const Int16 SAMPLE_ADDRESS_TYPE_AX_TORQ = (0x0a); ///< 轴扭矩
  1605. public const Int16 SAMPLE_ADDRESS_TYPE_AX_STS = (0x0b); ///< 轴状态
  1606. // 资源信号数据类型
  1607. public const Int16 SAMPLE_ADDRESS_TYPE_ECAT_DI = (0x30); ///< ECAT通用DI
  1608. public const Int16 SAMPLE_ADDRESS_TYPE_ECAT_DO = (0x31); ///< ECAT通用DO
  1609. public const Int16 SAMPLE_ADDRESS_TYPE_LOCAL_DI = (0x32); ///< 端子板DI
  1610. public const Int16 SAMPLE_ADDRESS_TYPE_LOCAL_DO = (0x33); ///< 端子板DO
  1611. public const Int16 SAMPLE_ADDRESS_TYPE_ECAT_AD = (0x34); ///< ECAT AD
  1612. public const Int16 SAMPLE_ADDRESS_TYPE_ECAT_DA = (0x35); ///< ECAT DA
  1613. // 总线对象字典采集
  1614. public const Int16 SAMPLE_ADDRESS_TYPE_RXPDO_2 = (0x40); ///< pdo通用, 2字节, 写
  1615. public const Int16 SAMPLE_ADDRESS_TYPE_RXPDO_4 = (0x41); ///< pdo通用, 4字节, 写
  1616. public const Int16 SAMPLE_ADDRESS_TYPE_6040 = (0x42); ///< 控制字
  1617. public const Int16 SAMPLE_ADDRESS_TYPE_607a = (0x43); ///< 目标位置
  1618. public const Int16 SAMPLE_ADDRESS_TYPE_60ff = (0x44); ///< 目标速度
  1619. public const Int16 SAMPLE_ADDRESS_TYPE_6071 = (0x45); ///< 目标力矩
  1620. public const Int16 SAMPLE_ADDRESS_TYPE_6060 = (0x46); ///< 模式控制
  1621. public const Int16 SAMPLE_ADDRESS_TYPE_60fe = (0x47); ///< 数字量输出
  1622. public const Int16 SAMPLE_ADDRESS_TYPE_60b8 = (0x48); ///< 探针控制字
  1623. public const Int16 SAMPLE_ADDRESS_TYPE_TXPDO_2 = (0x50); ///< pdo通用, 2字节, 读
  1624. public const Int16 SAMPLE_ADDRESS_TYPE_TXPDO_4 = (0x51); ///< pdo通用, 4字节, 读
  1625. public const Int16 SAMPLE_ADDRESS_TYPE_6041 = (0x52); ///< 状态字
  1626. public const Int16 SAMPLE_ADDRESS_TYPE_6064 = (0x53); ///< 实际位置
  1627. public const Int16 SAMPLE_ADDRESS_TYPE_606c = (0x54); ///< 实际速度
  1628. public const Int16 SAMPLE_ADDRESS_TYPE_6077 = (0x55); ///< 实际力矩
  1629. public const Int16 SAMPLE_ADDRESS_TYPE_60f4 = (0x56); ///< 跟随误差
  1630. public const Int16 SAMPLE_ADDRESS_TYPE_603f = (0x57); ///< 错误码
  1631. public const Int16 SAMPLE_ADDRESS_TYPE_60fd = (0x58); ///< 数字量输入
  1632. public const Int16 SAMPLE_ADDRESS_TYPE_60b9 = (0x59); ///< 探针状态字
  1633. public const Int16 SAMPLE_ADDRESS_TYPE_60ba = (0x60); ///< 探针位置1
  1634. public const Int16 SAMPLE_ADDRESS_TYPE_60bb = (0x61); ///< 探针位置2
  1635. // 插补数据类型
  1636. public const Int16 SAMPLE_ADDRESS_TYPE_CRD_POSX = (0x100); ///< 插补坐标系, X轴位置
  1637. public const Int16 SAMPLE_ADDRESS_TYPE_CRD_POSY = (0x101); ///< 插补坐标系, Y轴位置
  1638. public const Int16 SAMPLE_ADDRESS_TYPE_CRD_POSZ = (0x102); ///< 插补坐标系, Z轴位置
  1639. public const Int16 SAMPLE_ADDRESS_TYPE_CRD_VEL = (0x110); ///< 插补坐标系, 合成速度
  1640. // 采集触发类型
  1641. public const Int16 SAMPLE_TRIG_IMMEDIATE = (0); ///< 立即采集
  1642. public const Int16 SAMPLE_TRIG_DELAY = (1); ///< 延时采集
  1643. public const Int16 SAMPLE_TRIG_LOCAL_DI = (2); ///< 本地DI触发
  1644. public const Int16 SAMPLE_TRIG_ECAT_DI = (3); ///< ECAT 的DI 触发
  1645. //事件类型定义
  1646. public const Int16 EVENT_TYPE_PRFPOS = (1);
  1647. public const Int16 EVENT_TYPE_PRFVEL = (2);
  1648. public const Int16 EVENT_TYPE_ENCPOS = (3);
  1649. public const Int16 EVENT_TYPE_ENCVEL = (4);
  1650. public const Int16 EVENT_TYPE_CRDPOS_X = (5);
  1651. public const Int16 EVENT_TYPE_CRDPOS_Y = (6);
  1652. public const Int16 EVENT_TYPE_CRDPOS_Z = (7);
  1653. public const Int16 EVENT_TYPE_CRDVEL = (8);
  1654. public const Int16 EVENT_TYPE_AXSTS_ALARM = (9);
  1655. public const Int16 EVENT_TYPE_AXSTS_SVON = (10);
  1656. public const Int16 EVENT_TYPE_AXSTS_BUSY = (11);
  1657. public const Int16 EVENT_TYPE_AXSTS_ARRIVE = (12);
  1658. public const Int16 EVENT_TYPE_AXSTS_POSLMT = (13);
  1659. public const Int16 EVENT_TYPE_AXSTS_NEGLMT = (14);
  1660. public const Int16 EVENT_TYPE_AXSTS_SOFT_POSLMT = (15);
  1661. public const Int16 EVENT_TYPE_AXSTS_SOFT_NEGLMT = (16);
  1662. public const Int16 EVENT_TYPE_AXSTS_ERRPOS = (17);
  1663. public const Int16 EVENT_TYPE_AXSTS_EMGSTOP = (18);
  1664. public const Int16 EVENT_TYPE_AXSTS_ECAT = (19);
  1665. public const Int16 EVENT_TYPE_AXSTS_SW_ABNOR = (20);
  1666. public const Int16 EVENT_TYPE_AXSTS_WARING = (21);
  1667. public const Int16 EVENT_TYPE_AXSTS_HM = (22);
  1668. public const Int16 EVENT_TYPE_AXSTS_UNLINK = (23);
  1669. public const Int16 EVENT_TYPE_AXSTS_TGTREACH = (24);
  1670. public const Int16 EVENT_TYPE_CRDSTS = (25);
  1671. public const Int16 EVENT_TYPE_CRDID = (26);
  1672. public const Int16 EVENT_TYPE_DI = (27);
  1673. public const Int16 EVENT_TYPE_AD = (28);
  1674. public const Int16 EVENT_TYPE_GLOBALVAL = (29);
  1675. //事件条件定义
  1676. public const Int16 EVENT_CONDITION_EQ = (1); ///< 变量值等于设定值
  1677. public const Int16 EVENT_CONDITION_NE = (2); ///< 变量值不等于设定值
  1678. public const Int16 EVENT_CONDITION_GT = (3); ///< 变量值大于设定值
  1679. public const Int16 EVENT_CONDITION_LT = (4); ///< 变量值小于设定值
  1680. public const Int16 EVENT_CONDITION_CHANGE_TO = (5); ///< 变量值改变为设定值
  1681. public const Int16 EVENT_CONDITION_CHANGE = (6); ///< 变量值改变
  1682. public const Int16 EVENT_CONDITION_UP = (7); ///< 变量值增大
  1683. public const Int16 EVENT_CONDITION_DOWN = (8); ///< 变量值减小
  1684. public const Int16 EVENT_CONDITION_REMAIN_AT = (9); ///< 变量值保持为设定值
  1685. public const Int16 EVENT_CONDITION_REMAIN = (10); ///< 变量值保持不变
  1686. public const Int16 EVENT_CONDITION_CROSS_POSITIVE = (11); ///< 变量值正向穿越设定值
  1687. public const Int16 EVENT_CONDITION_CROSS_NEGATIVE = (12); ///< 变量值负向穿越设定值
  1688. //事件功能中任务类型定义
  1689. public const Int16 TASK_TYPE_CRDSTART = (1);
  1690. public const Int16 TASK_TYPE_STARTPTPMOVE = (2);
  1691. public const Int16 TASK_TYPE_STARTJOGMOVE = (3);
  1692. public const Int16 TASK_TYPE_STARTGEARMOVE = (4);
  1693. public const Int16 TASK_TYPE_STARTPTMOVE = (5);
  1694. public const Int16 TASK_TYPE_STARTPVTMOVE = (6);
  1695. public const Int16 TASK_TYPE_UPDATEPTPMOVEPARA = (7);
  1696. public const Int16 TASK_TYPE_UPDATEJOGMOVEPARA = (8);
  1697. public const Int16 TASK_TYPE_SETECATDOBIT = (9);
  1698. public const Int16 TASK_TYPE_SETECATGRPDO = (10);
  1699. public const Int16 TASK_TYPE_SETECATDOBITINVERSE = (11);
  1700. public const Int16 TASK_TYPE_SETECATDAVAL = (12);
  1701. public const Int16 TASK_TYPE_UPDATEPTPTGTPOS = (13);
  1702. public const Int16 TASK_TYPE_PLUSEDO = (14);
  1703. public const Int16 TASK_TYPE_STOPMOVE = (15);
  1704. ///@defgroup CardBasic CardBasic
  1705. ///@brief 板卡基本操作
  1706. #region CardBasic
  1707. ///@defgroup CardOpen CardOpen
  1708. ///@brief 板卡开启与关闭
  1709. #region CardOpen
  1710. /// @brief 获取板卡数量
  1711. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetCardsNum", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1712. public static extern UInt32 IMC_GetCardsNum(ref Int16 pCardsNum, Int16[] pCardIndexArray);
  1713. /// @brief 按卡号开启控制卡
  1714. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_OpenCard", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1715. public static extern UInt32 IMC_OpenCard(Int16 cardIndex);
  1716. /// @brief 按卡号关闭控制卡
  1717. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CloseCard", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1718. public static extern UInt32 IMC_CloseCard(Int16 cardIndex);
  1719. #endregion
  1720. ///@defgroup CardConfigFile CardConfigFile
  1721. ///@brief 板卡配置文件操作
  1722. #region CardConfigFile
  1723. /// @brief 上传控制卡的设备配置文件(包括主站使能, 规划周期, EtherCAT对象以及偏置等), 上传文件的路径在设定目录下
  1724. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpLoadDeviceConfig", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1725. public static extern UInt32 IMC_UpLoadDeviceConfig(Int16 cardIndex, string pathName);
  1726. /// @brief 下载控制器的设备配置文件(包括主站使能, 规划周期, EtherCAT对象以及偏置等), 下载文件的路径在设定目录下
  1727. /// @attention 当次下载下去之后, 非立即生效, 需要调用扫描板卡指令才能生效
  1728. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_DownLoadDeviceConfig", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1729. public static extern UInt32 IMC_DownLoadDeviceConfig(Int16 cardIndex, string pathName);
  1730. /// @brief 下载控制器的系统配置文件(包括轴映射、轴运动参数、IO取反滤波等硬件信号配置参数)
  1731. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_DownLoadSystemConfig", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1732. public static extern UInt32 IMC_DownLoadSystemConfig(Int16 cardIndex, string pathName);
  1733. #endregion
  1734. #endregion
  1735. ///@defgroup CardSysConfig CardSysConfig
  1736. ///@brief 板卡系统配置相关函数
  1737. #region CardSysConfig
  1738. ///@defgroup EmgConfig EmgConfig
  1739. ///@brief 急停参数配置函数
  1740. #region EmgConfig
  1741. /// @brief 设置停止信号的滤波系数
  1742. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEmgFilter", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1743. public static extern UInt32 IMC_SetEmgFilter(Int16 cardIndex, Int16 filter);
  1744. /// @brief 获取停止信号的滤波系数
  1745. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEmgFilter", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1746. public static extern UInt32 IMC_GetEmgFilter(Int16 cardIndex, ref Int16 pFilter);
  1747. /// @brief 设置急停信号触发的电平取反
  1748. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEmgTrigLevelInv", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1749. public static extern UInt32 IMC_SetEmgTrigLevelInv(Int16 cardIndex, Int16 inverse);
  1750. /// @brief 获取急停信号触发的电平取反
  1751. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEmgTrigLevelInv", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1752. public static extern UInt32 IMC_GetEmgTrigLevelInv(Int16 cardIndex, ref Int16 pInverse);
  1753. /// @brief 获取急停状态
  1754. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEmgSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1755. public static extern UInt32 IMC_GetEmgSts(Int16 cardIndex, ref Int16 pSts);
  1756. /// @brief 设置急停时是否复位所有 DO 输出的开关使能
  1757. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEmgDoResetFlag", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1758. public static extern UInt32 IMC_SetEmgDoResetFlag(Int16 cardIndex, Int16 enable);
  1759. /// @brief 读取急停时是否复位所有 DO 输出的开关使能
  1760. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEmgDoResetFlag", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1761. public static extern UInt32 IMC_GetEmgDoResetFlag(Int16 cardIndex, ref Int16 pEnable);
  1762. /// @brief 设置是否忽略板卡的ECAT连接状态
  1763. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatLinkStsIgnore", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1764. public static extern UInt32 IMC_SetEcatLinkStsIgnore(Int16 cardIndex, Int16 flag);
  1765. #endregion
  1766. ///@defgroup Watchdog Watchdog
  1767. ///@brief 看门狗参数配置函数
  1768. #region Watchdog
  1769. /// @brief 设置看门狗, 在报警时, 进行急停动作。主要用于检查应用层软件是否卡死。
  1770. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_OpenWatchDog", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1771. public static extern UInt32 IMC_OpenWatchDog(Int16 cardIndex, Int32 feedTime);
  1772. /// @brief 喂看门狗操作
  1773. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_FeedWatchDog", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1774. public static extern UInt32 IMC_FeedWatchDog(Int16 cardIndex);
  1775. /// @brief 关闭看门狗检查
  1776. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CloseWatchDog", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1777. public static extern UInt32 IMC_CloseWatchDog(Int16 cardIndex);
  1778. #endregion
  1779. ///@defgroup CardTimeInfo CardTimeInfo
  1780. ///@brief 板卡内部时钟信息
  1781. #region CardTimeInfo
  1782. /// @brief 获取板卡的CPU负载
  1783. /// @warning 建议负载率不要超过60%
  1784. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetCalcLoadRatio", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1785. public static extern UInt32 IMC_GetCalcLoadRatio(Int16 cardIndex, ref double pLoadRatio);
  1786. /// @brief 根据Type类型, 获取板卡对应的固件版本
  1787. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetVersion", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1788. public static extern UInt32 IMC_GetVersion(Int16 cardIndex, Int16 type, Int16[] pVersion);
  1789. #endregion
  1790. ///@defgroup CardMasterInfo CardMasterInfo
  1791. ///@brief 板卡主站配置信息
  1792. #region CardMasterInfo
  1793. /// @brief 获取主站启用配置, 从xml配置文件获取
  1794. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetMasterCfgXml", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1795. public static extern UInt32 IMC_GetMasterCfgXml(Int16 cardIndex, ref Int16 pHwCfg);
  1796. /// @brief 获取板卡的网口硬件连接状态
  1797. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetHwPortLinkSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1798. public static extern UInt32 IMC_GetHwPortLinkSts(Int16 cardIndex, ref Int16 pLinkSts);
  1799. /// @brief 获取板卡的网口硬件连接状态,Ex指令
  1800. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetHwPortLinkStsEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1801. public static extern UInt32 IMC_GetHwPortLinkStsEx(Int16 cardIndex, ref Int16 pLinkSts);
  1802. #endregion
  1803. ///@defgroup CardReset CardReset
  1804. ///@brief 板卡复位功能
  1805. #region CardReset
  1806. /// @brief 复位控制卡系统参数
  1807. /// @details 控制卡规划层软件资源复位
  1808. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ResetSysPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1809. public static extern UInt32 IMC_ResetSysPara(Int16 cardIndex);
  1810. #endregion
  1811. ///@defgroup UserCode UserCode
  1812. ///@brief 用户配置
  1813. #region UserCode
  1814. /// @brief 设置用户密码
  1815. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_WriteUserCode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1816. public static extern UInt32 IMC_WriteUserCode(Int16 cardIndex, Byte[] pCode, Int16 len);
  1817. /// @brief 检验设置的用户密码
  1818. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CheckUserCode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1819. public static extern UInt32 IMC_CheckUserCode(Int16 cardIndex, Byte[] pCode, Int16 len);
  1820. /// @brief 写入用户数据
  1821. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_WriteUserData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1822. public static extern UInt32 IMC_WriteUserData(Int16 cardIndex, Int16 offset, Byte[] pData, Int16 len);
  1823. /// @brief 读取用户数据
  1824. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ReadUserData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1825. public static extern UInt32 IMC_ReadUserData(Int16 cardIndex, Int16 offset, Byte[] pData, Int16 len);
  1826. #endregion
  1827. #endregion
  1828. ///@defgroup EtherCAT EtherCAT
  1829. ///@brief 板卡ECAT功能
  1830. #region EtherCAT
  1831. ///@defgroup EcatInit EcatInit
  1832. ///@brief 板卡ECAT初始化功能
  1833. #region EcatInit
  1834. /// @brief 初始化板卡通讯, 主站进入OP状态
  1835. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_InitEcatComm", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1836. public static extern UInt32 IMC_InitEcatComm(Int16 cardIndex);
  1837. /// @brief 开启板卡通讯, 获取EtherCAT总线资源, 建立主站与各从站之间的通讯
  1838. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartEcatComm", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1839. public static extern UInt32 IMC_StartEcatComm(Int16 cardIndex);
  1840. /// @brief 关闭板卡通讯, 主站退出OP状态
  1841. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_DelEcatComm", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1842. public static extern UInt32 IMC_DelEcatComm(Int16 cardIndex);
  1843. /// @brief 初始化总线, 直到主站进入OP状态, 随后扫描EtherCAT总线资源, 并建立主站与各从站之间的通讯 (该函数会阻塞在EtherCAT的总线扫描同步阶段)
  1844. /// @warning 该指令阻塞执行
  1845. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ScanCardEcat", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1846. public static extern UInt32 IMC_ScanCardEcat(Int16 cardIndex, Int16 waitTime = 40);
  1847. #endregion
  1848. ///@defgroup EcatInfo EcatInfo
  1849. ///@brief 板卡ECAT主站信息获取函数
  1850. #region EcatInfo
  1851. /// @brief 获取EtherCAT主站的状态
  1852. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatMasterSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1853. public static extern UInt32 IMC_GetEcatMasterSts(Int16 cardIndex, ref UInt32 pStatus);
  1854. /// @brief 获取EtherCAT协议栈通讯错误码
  1855. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatErrCode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1856. public static extern UInt32 IMC_GetEcatErrCode(Int16 cardIndex, ref UInt32 pErrCode);
  1857. /// @brief 获取EtherCAT主站的状态,Ex指令
  1858. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatMasterStsEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1859. public static extern UInt32 IMC_GetEcatMasterStsEx(Int16 cardIndex, ref UInt32 pStatus);
  1860. /// @brief 获取EtherCAT协议栈通讯错误码,Ex指令
  1861. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatErrCodeEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1862. public static extern UInt32 IMC_GetEcatErrCodeEx(Int16 cardIndex, ref UInt32 pErrCode);
  1863. /// @brief 获取EtherCAT从站当前通讯阶段INIT、PreOP、SafeOp、OP
  1864. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlaveSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1865. public static extern UInt32 IMC_GetEcatSlaveSts(Int16 cardIndex, Int16 slave, ref Int16 pCurStatus, ref Int16 pReqStatus, ref Int16 pErrCode);
  1866. /// @brief 获取EtherCAT主站信息(包含通讯周期, 从站个数, 资源数量等)
  1867. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatMasterInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1868. public static extern UInt32 IMC_GetEcatMasterInfo(Int16 cardIndex, ref TMasterInfo ptMasterInfo);
  1869. /// @brief 获取EtherCAT从站信息(包含设备类型, 对应轴号, 从站别名等)
  1870. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlaveInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1871. public static extern UInt32 IMC_GetEcatSlaveInfo(Int16 cardIndex, Int16 slave, ref TSlaveInfo ptSlaveInfo);
  1872. /// @brief 获取从站连接状态
  1873. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlaveOpSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1874. public static extern UInt32 IMC_GetEcatSlaveOpSts(Int16 cardIndex, ref UInt16 pSts, UInt32[] pMask);
  1875. #endregion
  1876. ///@defgroup EcatPDO EcatPDO
  1877. ///@brief 板卡ECAT主站PDO功能
  1878. #region EcatPDO
  1879. /// @brief 根据站号读取EtherCAT从站的PDO数据
  1880. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlavePdoData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1881. public static extern UInt32 IMC_GetEcatSlavePdoData(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData);
  1882. /// @brief 根据站号写入EtherCAT从站的PDO数据, 仅支持非轴从站, 非DIO, AIO, RegInOut类型Pdo
  1883. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatSlavePdoData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1884. public static extern UInt32 IMC_SetEcatSlavePdoData(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData);
  1885. /// @brief 根据轴号获取EtherCAT从站的PDO数据
  1886. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxPdoData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1887. public static extern UInt32 IMC_GetEcatAxPdoData(Int16 cardIndex, Int16 axNo, UInt16 index, Byte[] pData);
  1888. /// @brief 根据轴号写入EtherCAT从站的PDO数据
  1889. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxPdoData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1890. public static extern UInt32 IMC_SetEcatAxPdoData(Int16 cardIndex, Int16 axNo, UInt16 index, Byte[] pData);
  1891. /// @brief 根据索引和子索引读取从站的PdoEntry结构体信息
  1892. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlavePdoEntry", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1893. public static extern UInt32 IMC_GetEcatSlavePdoEntry(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, ref TPdoEntry ptPdoEntry);
  1894. #endregion
  1895. ///@defgroup EcatSDO EcatSDO
  1896. ///@brief 板卡ECAT主站SDO功能
  1897. #region EcatSDO
  1898. /// @brief 根据站号获取EtherCAT从站的SDO数据
  1899. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlaveSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1900. public static extern UInt32 IMC_GetEcatSlaveSdo(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pResultSize, ref UInt32 pAbortCode);
  1901. /// @brief 根据站号写入EtherCAT从站的SDO数据
  1902. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatSlaveSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1903. public static extern UInt32 IMC_SetEcatSlaveSdo(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pAbortCode);
  1904. /// @brief 根据轴号获取EtherCAT从站的SDO数据
  1905. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1906. public static extern UInt32 IMC_GetEcatAxSdo(Int16 cardIndex, Int16 axNo, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pResultSize, ref UInt32 pAbortCode);
  1907. /// @brief 根据轴号写入EtherCAT从站的SDO数据
  1908. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1909. public static extern UInt32 IMC_SetEcatAxSdo(Int16 cardIndex, Int16 axNo, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pAbortCode);
  1910. #endregion
  1911. ///@defgroup EcatAxisMap EcatAxisMap
  1912. ///@brief 板卡ECAT主站轴映射功能
  1913. #region EcatAxisMap
  1914. /// @brief 根据轴号获取轴所在从站的站号以及Slot号
  1915. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxStation", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1916. public static extern UInt32 IMC_GetEcatAxStation(Int16 cardIndex, Int16 axNo, ref Int16 pSlave, ref Int16 pSlotIndex);
  1917. /// @brief 根据从站号以及Slot号获取对应的轴通道号
  1918. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlaveAxChn", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1919. public static extern UInt32 IMC_GetEcatSlaveAxChn(Int16 cardIndex, Int16 slave, Int16 slotIndex, ref Int16 pAxChn);
  1920. #endregion
  1921. ///@defgroup EcatAlias EcatAlias
  1922. ///@brief 板卡ECAT从站别名功能
  1923. #region EcatAlias
  1924. /// @brief 根据从站别名获取从站的SDO数据
  1925. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAliasSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1926. public static extern UInt32 IMC_GetEcatAliasSdo(Int16 cardIndex, UInt32 aliasNo, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pResultSize, ref UInt32 pAbortCode);
  1927. /// @brief 根据从站别名设定从站的SDO数据
  1928. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAliasSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1929. public static extern UInt32 IMC_SetEcatAliasSdo(Int16 cardIndex, UInt32 aliasNo, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pAbortCode);
  1930. /// @brief 设置EtherCAT的DO输出状态保持, 断线后复位总线保持上一次状态
  1931. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatDoStsHold", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1932. public static extern UInt32 IMC_SetEcatDoStsHold(Int16 cardIndex, Int16 isHold);
  1933. #endregion
  1934. /// @brief 获取EtherCAT的DI输入状态, 按16bits为一组进行获取
  1935. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1936. public static extern UInt32 IMC_GetEcatDi(Int16 cardIndex, Int16 packIndex, UInt16[] pValue, Int16 packCnt);
  1937. /// @brief 设置EtherCAT的DO输出状态, 按16bits为一组进行设置
  1938. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1939. public static extern UInt32 IMC_SetEcatDo(Int16 cardIndex, Int16 packIndex, UInt16[] pValue, Int16 packCnt);
  1940. /// @brief 获取EtherCAT的DO输出状态, 按16bits为一组进行获取
  1941. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1942. public static extern UInt32 IMC_GetEcatDo(Int16 cardIndex, Int16 packIndex, UInt16[] pValue, Int16 packCnt);
  1943. /// @brief 获取EtherCAT的DI输入状态, 按位进行获取
  1944. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatDiBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1945. public static extern UInt32 IMC_GetEcatDiBit(Int16 cardIndex, Int16 diIndex, ref Int16 pValue);
  1946. /// @brief 获取EtherCAT的DO输出状态, 按位进行获取
  1947. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatDoBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1948. public static extern UInt32 IMC_GetEcatDoBit(Int16 cardIndex, Int16 doIndex, ref Int16 pValue);
  1949. /// @brief 设置EtherCAT的DO输出状态, 按位进行设置
  1950. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatDoBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1951. public static extern UInt32 IMC_SetEcatDoBit(Int16 cardIndex, Int16 doIndex, Int16 value);
  1952. /// @brief 设置EtherCAT的DO输出状态以及生效延时, 按位进行设置
  1953. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatDoBitInverse", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1954. public static extern UInt32 IMC_SetEcatDoBitInverse(Int16 cardIndex, Int16 doIndex, Int16 value, Int16 inverseTime);
  1955. #endregion
  1956. ///@defgroup EcatAD EcatAD
  1957. ///@brief 板卡ECAT主站AD/DA/Reg32寄存器功能
  1958. #region EcatAD
  1959. /// @brief 根据通道号获取EtherCAT对应通道的AD值
  1960. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAdVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1961. public static extern UInt32 IMC_GetEcatAdVal(Int16 cardIndex, Int16 adIndex, ref Int16 pValue);
  1962. /// @brief 根据通道号设置EtherCAT对应通道的DA值
  1963. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatDaVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1964. public static extern UInt32 IMC_SetEcatDaVal(Int16 cardIndex, Int16 daIndex, Int16 Value);
  1965. /// @brief 根据通道号获取EtherCAT对应通道的DA值
  1966. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatDaVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1967. public static extern UInt32 IMC_GetEcatDaVal(Int16 cardIndex, Int16 daIndex, ref Int16 pValue);
  1968. /// @brief 根据通道号获取EtherCAT对应通道的RegIn值
  1969. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatRegInVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1970. public static extern UInt32 IMC_GetEcatRegInVal(Int16 cardIndex, Int16 regIndex, ref float pValue);
  1971. /// @brief 根据通道号设置EtherCAT对应通道的RegOut值
  1972. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatRegOutVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1973. public static extern UInt32 IMC_SetEcatRegOutVal(Int16 cardIndex, Int16 regIndex, float Value);
  1974. /// @brief 根据通道号获取EtherCAT对应通道的RegOut值
  1975. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatRegOutVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1976. public static extern UInt32 IMC_GetEcatRegOutVal(Int16 cardIndex, Int16 regIndex, ref float pValue);
  1977. /// @brief 根据通道号获取EtherCAT对应通道的AD值
  1978. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAd", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1979. public static extern UInt32 IMC_GetEcatAd(Int16 cardIndex, Int16 adIndex, Int16[] pValueArray, Int16 count);
  1980. /// @brief 根据通道号设置EtherCAT对应通道的DA值
  1981. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatDa", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1982. public static extern UInt32 IMC_SetEcatDa(Int16 cardIndex, Int16 daIndex, Int16[] pValueArray, Int16 count);
  1983. /// @brief 根据通道号获取EtherCAT对应通道的DA值
  1984. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatDa", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1985. public static extern UInt32 IMC_GetEcatDa(Int16 cardIndex, Int16 daIndex, Int16[] pValueArray, Int16 count);
  1986. /// @brief 根据通道号获取EtherCAT对应通道的RegIn值
  1987. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatRegIn", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1988. public static extern UInt32 IMC_GetEcatRegIn(Int16 cardIndex, Int16 regIndex, float[] pValueArray, Int16 count);
  1989. /// @brief 根据通道号设置EtherCAT对应通道的RegOut值
  1990. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatRegOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1991. public static extern UInt32 IMC_SetEcatRegOut(Int16 cardIndex, Int16 regIndex, float[] pValueArray, Int16 count);
  1992. /// @brief 根据通道号获取EtherCAT对应通道的RegOut值
  1993. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatRegOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  1994. public static extern UInt32 IMC_GetEcatRegOut(Int16 cardIndex, Int16 regIndex, float[] pValueArray, Int16 count);
  1995. #endregion
  1996. ///@defgroup EcatEnc EcatEnc
  1997. ///@brief 板卡ECAT主站Enc资源操作
  1998. #region EcatEnc
  1999. /// @brief 设置Ecat编码器计数方向
  2000. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatEncDir", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2001. public static extern UInt32 IMC_SetEcatEncDir(Int16 cardIndex, Int16 encIndex, Int16[] pDirArray, Int16 count = 1);
  2002. /// @brief 读取Ecat编码器计数方向
  2003. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatEncDir", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2004. public static extern UInt32 IMC_GetEcatEncDir(Int16 cardIndex, Int16 encIndex, Int16[] pDirArray, Int16 count = 1);
  2005. /// @brief 设置Ecat编码器值
  2006. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatEncPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2007. public static extern UInt32 IMC_SetEcatEncPos(Int16 cardIndex, Int16 encIndex, Int32[] pEncPosArray, Int16 count = 1);
  2008. /// @brief 读取Ecat编码器值
  2009. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatEncPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2010. public static extern UInt32 IMC_GetEcatEncPos(Int16 cardIndex, Int16 encIndex, Int32[] pEncPosArray, Int16 count = 1);
  2011. /// @brief 读取Ecat编码器原始值(PDO原始编码数据)
  2012. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatEncPosRaw", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2013. public static extern UInt32 IMC_GetEcatEncPosRaw(Int16 cardIndex, Int16 encIndex, Int32[] pEncPosArray, Int16 count = 1);
  2014. /// @brief 读取Ecat编码器速度
  2015. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatEncVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2016. public static extern UInt32 IMC_GetEcatEncVel(Int16 cardIndex, Int16 encIndex, Int32[] pEncVelArray, Int16 count = 1);
  2017. #endregion
  2018. ///@defgroup EcatAxis EcatAxis
  2019. ///@brief 板卡ECAT相关函数
  2020. #region EcatAxis
  2021. ///@defgroup EcatAxisPDO EcatAxisPDO
  2022. ///@brief 板卡ECAT轴PDO功能
  2023. #region EcatAxisPDO
  2024. /// @brief 设置EtherCAT类型轴控制模式0x6060
  2025. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2026. public static extern UInt32 IMC_SetEcatAxMode(Int16 cardIndex, Int16 axNo, Int16 ctrlMode);
  2027. /// @brief 读取EtherCAT类型轴控制模式
  2028. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2029. public static extern UInt32 IMC_GetEcatAxMode(Int16 cardIndex, Int16 axNo, ref Int16 pCtrlMode);
  2030. /// @brief 获取EtherCAT类型轴的对应的数字量输入,pdo必须配置0x60fd
  2031. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2032. public static extern UInt32 IMC_GetEcatAxDi(Int16 cardIndex, Int16 axNo, ref UInt32 pDiVal);
  2033. /// @brief 设置EtherCAT类型轴的对应的数字量输出,pdo必须配置0x60fe:01
  2034. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2035. public static extern UInt32 IMC_SetEcatAxDo(Int16 cardIndex, Int16 axNo, UInt32 doVal);
  2036. /// @brief 获取EtherCAT类型轴的对应的数字量输输出,pdo必须配置0x60fe:01
  2037. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2038. public static extern UInt32 IMC_GetEcatAxDo(Int16 cardIndex, Int16 axNo, ref UInt32 pDoVal);
  2039. /// @brief 获取EtherCAT类型轴的对应的错误码,pdo必须配置0x603f
  2040. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxErrCode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2041. public static extern UInt32 IMC_GetEcatAxErrCode(Int16 cardIndex, Int16 axNo, ref UInt16 pErrCode);
  2042. /// @brief 设置EtherCAT类型轴的最大速度限制,pdo必须配置0x607f
  2043. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxMaxVelLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2044. public static extern UInt32 IMC_SetEcatAxMaxVelLmt(Int16 cardIndex, Int16 axNo, UInt32 maxVel);
  2045. /// @brief 获取EtherCAT类型轴的最大速度限制,pdo必须配置0x607f
  2046. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxMaxVelLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2047. public static extern UInt32 IMC_GetEcatAxMaxVelLmt(Int16 cardIndex, Int16 axNo, ref UInt32 pMaxVel);
  2048. /// @brief 设置 EtherCAT 类型轴的对应的正向力矩限制,pdo必须配置0x60e0
  2049. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxPosTorqLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2050. public static extern UInt32 IMC_SetEcatAxPosTorqLmt(Int16 cardIndex, Int16 axNo, UInt16 posTorqLmt);
  2051. /// @brief 获取 EtherCAT 类型轴的对应的正向力矩限制,pdo必须配置0x60e0
  2052. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxPosTorqLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2053. public static extern UInt32 IMC_GetEcatAxPosTorqLmt(Int16 cardIndex, Int16 axNo, ref UInt16 pPosTorqLmt);
  2054. /// @brief 设置 EtherCAT 类型轴的对应的负向力矩限制,pdo必须配置0x60e1
  2055. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxNegTorqLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2056. public static extern UInt32 IMC_SetEcatAxNegTorqLmt(Int16 cardIndex, Int16 axNo, UInt16 negTorqLmt);
  2057. /// @brief 获取 EtherCAT 类型轴的对应的负向力矩限制,pdo必须配置0x60e1
  2058. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxNegTorqLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2059. public static extern UInt32 IMC_GetEcatAxNegTorqLmt(Int16 cardIndex, Int16 axNo, ref UInt16 pNegTorqLmt);
  2060. /// @brief 设置 EtherCAT 类型轴的最大力矩限制,pdo必须配置0x6072
  2061. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxMaxTorqLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2062. public static extern UInt32 IMC_SetEcatAxMaxTorqLmt(Int16 cardIndex, Int16 axNo, UInt16 maxTorqLmt);
  2063. /// @brief 获取 EtherCAT 类型轴的最大力矩限制,pdo必须配置0x6072
  2064. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxMaxTorqLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2065. public static extern UInt32 IMC_GetEcatAxMaxTorqLmt(Int16 cardIndex, Int16 axNo, ref UInt16 pMaxTorqLmt);
  2066. #endregion
  2067. ///@defgroup EcatAxisThreshold EcatAxisThreshold
  2068. ///@brief 板卡ECAT轴急停保持参数配置函数
  2069. #region EcatAxisThreshold
  2070. /// @brief 设置EtherCAT轴使能控制延时时间, 主要用于特殊场合, 使能控制字输出, 驱动器寻相后, 才能给出使能状态字
  2071. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxOnThreshold", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2072. public static extern UInt32 IMC_SetEcatAxOnThreshold(Int16 cardIndex, Int16 axNo, UInt16 waitPeriod);
  2073. /// @brief 获取EtherCAT轴使能控制延时时间
  2074. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxOnThreshold", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2075. public static extern UInt32 IMC_GetEcatAxOnThreshold(Int16 cardIndex, Int16 axNo, ref UInt16 pWaitPeriod);
  2076. #endregion
  2077. ///@defgroup EcatAxisCSV EcatAxisCSV
  2078. ///@brief 板卡ECAT轴CSV模式功能
  2079. #region EcatAxisCSV
  2080. /// @brief 启动 CSV 速度规划
  2081. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartEcatAxCsvPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2082. public static extern UInt32 IMC_StartEcatAxCsvPrf(Int16 cardIndex, Int16 axNo, Int32 tgtVel, Int32 acc, Int16 prfType);
  2083. /// @brief 更新 CSV 速度规划的目标速度
  2084. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdateEcatAxCsvPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2085. public static extern UInt32 IMC_UpdateEcatAxCsvPrf(Int16 cardIndex, Int16 axNo, Int32 tgtVel);
  2086. /// @brief 获取 CSV 速度规划的状态
  2087. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxCsvPrfSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2088. public static extern UInt32 IMC_GetEcatAxCsvPrfSts(Int16 cardIndex, Int16 axNo, ref Int16 pStatus);
  2089. #endregion
  2090. ///@defgroup EcatAxisCST EcatAxisCST
  2091. ///@brief 板卡ECAT轴CST模式功能
  2092. #region EcatAxisCST
  2093. /// @brief 启动 CST 线性转矩规划
  2094. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartEcatAxTorqPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2095. public static extern UInt32 IMC_StartEcatAxTorqPrf(Int16 cardIndex, Int16 axNo, Int16 tgtTorq, Int16 time);
  2096. /// @brief 获取 EtherCAT 类型轴的实际转矩, 根据count值可一次获取多个轴的扭矩
  2097. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxActTorq", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2098. public static extern UInt32 IMC_GetEcatAxActTorq(Int16 cardIndex, Int16 axNo, Int16[] pActTorqArray, Int16 count = 1);
  2099. /// @brief 设置 EtherCAT 类型轴的对应的转矩斜坡值
  2100. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxTorqSlope", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2101. public static extern UInt32 IMC_SetEcatAxTorqSlope(Int16 cardIndex, Int16 axNo, UInt32 torqSlope);
  2102. /// @brief 获取 EtherCAT 类型轴的对应的转矩斜坡值
  2103. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxTorqSlope", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2104. public static extern UInt32 IMC_GetEcatAxTorqSlope(Int16 cardIndex, Int16 axNo, ref UInt32 pTorqSlope);
  2105. /// @brief 设置 EtherCAT 类型轴的对应的目标转矩
  2106. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxTgtTorq", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2107. public static extern UInt32 IMC_SetEcatAxTgtTorq(Int16 cardIndex, Int16 axNo, Int16 tgtTorq);
  2108. /// @brief 获取 EtherCAT 类型轴的对应的目标转矩
  2109. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxTgtTorq", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2110. public static extern UInt32 IMC_GetEcatAxTgtTorq(Int16 cardIndex, Int16 axNo, ref Int16 pTgtTorq);
  2111. #endregion
  2112. ///@defgroup EcatAxisCapt EcatAxisCapt
  2113. ///@brief 板卡ECAT轴捕获功能功能
  2114. #region EcatAxisCapt
  2115. /// @brief 设置 EtherCAT 类型轴的位置捕获类型
  2116. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxCapt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2117. public static extern UInt32 IMC_SetEcatAxCapt(Int16 cardIndex, Int16 axNo, Int16 trigType, Int16 edge);
  2118. /// @brief 获取 EtherCAT 类型轴的位置捕获类型
  2119. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxCapt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2120. public static extern UInt32 IMC_GetEcatAxCapt(Int16 cardIndex, Int16 axNo, ref Int16 pTrigType, ref Int16 pEdge);
  2121. /// @brief 获取 EtherCAT 类型轴的位置捕获状态
  2122. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxCaptStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2123. public static extern UInt32 IMC_GetEcatAxCaptStatus(Int16 cardIndex, Int16 axNo, ref Int16 pSts, ref Int32 pPosVal, ref Int32 pNegVal);
  2124. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxProbeFun", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2125. public static extern UInt32 IMC_SetEcatAxProbeFun(Int16 cardIndex, Int16 axNo, Int16 probeFun);
  2126. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxProbeFun", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2127. public static extern UInt32 IMC_GetEcatAxProbeFun(Int16 cardIndex, Int16 axNo, ref Int16 pProbeFun);
  2128. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxProbeSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2129. public static extern UInt32 IMC_GetEcatAxProbeSts(Int16 cardIndex, Int16 axNo, ref Int16 pProbeSts, ref Int32 pProbe1Pos, ref Int32 pProbe1Neg, ref Int32 pProbe2Pos, ref Int32 pProbe2Neg);
  2130. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxProbeContinousCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2131. public static extern UInt32 IMC_SetEcatAxProbeContinousCount(Int16 cardIndex, Int16 axNo, Int16[] pCountArray);
  2132. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxProbeContinousCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2133. public static extern UInt32 IMC_GetEcatAxProbeContinousCount(Int16 cardIndex, Int16 axNo, Int16[] pCountArray, Int16[] pTrigArray, Int16[] pRestArray);
  2134. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxProbeContinousData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2135. public static extern UInt32 IMC_GetEcatAxProbeContinousData(Int16 cardIndex, Int16 axNo, Int16 probeType, Int32[] pPosArray, Int16 count);
  2136. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxProbeContinousTable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2137. public static extern UInt32 IMC_SetEcatAxProbeContinousTable(Int16 cardIndex, Int16 axNo, Int16 tableIndex);
  2138. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxProbeContinousTable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2139. public static extern UInt32 IMC_GetEcatAxProbeContinousTable(Int16 cardIndex, Int16 axNo, ref Int16 pTableIndex);
  2140. /// @brief 清除 EtherCAT 类型轴的连续位置捕获状态
  2141. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClrEcatAxCaptStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2142. public static extern UInt32 IMC_ClrEcatAxCaptStatus(Int16 cardIndex, Int16 axNo);
  2143. #endregion
  2144. #endregion
  2145. ///@defgroup HEcatFunc HEcatFunc
  2146. ///@brief H主站函数
  2147. #region HEcatFunc
  2148. ///@defgroup H-MasterCfg H-MasterCfg
  2149. ///@brief H主站系统配置函数
  2150. #region H
  2151. /// @brief 获取板卡的CPU负载
  2152. /// @warning 建议负载率不要超过60%
  2153. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetCalcLoadRatio", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2154. public static extern UInt32 IMC_H_GetCalcLoadRatio(Int16 cardIndex, ref double pLoadRatio);
  2155. /// @brief 复位控制卡系统参数
  2156. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_ResetSysPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2157. public static extern UInt32 IMC_H_ResetSysPara(Int16 cardIndex);
  2158. #endregion
  2159. ///@defgroup H-EtherCAT H-EtherCAT
  2160. ///@brief 板卡H主站功能
  2161. #region H
  2162. /// @brief 初始化板卡通讯, 主站进入OP状态
  2163. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_InitEcatComm", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2164. public static extern UInt32 IMC_H_InitEcatComm(Int16 cardIndex);
  2165. /// @brief 开启板卡通讯, 初始化EtherCAT总线资源, 建立主站与各从站之间的通讯
  2166. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_StartEcatComm", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2167. public static extern UInt32 IMC_H_StartEcatComm(Int16 cardIndex);
  2168. /// @brief 关闭板卡通讯, 主站退出OP状态
  2169. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_DelEcatComm", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2170. public static extern UInt32 IMC_H_DelEcatComm(Int16 cardIndex);
  2171. /// @brief 初始化总线, 直到主站进入OP状态, 随后扫描EtherCAT总线资源, 并建立主站与各从站之间的通讯 (该函数会阻塞在EtherCAT的总线扫描同步阶段)
  2172. /// @warning 该指令阻塞执行
  2173. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_ScanCardEcat", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2174. public static extern UInt32 IMC_H_ScanCardEcat(Int16 cardIndex, Int16 waitTime = 40);
  2175. /// @brief 获取EtherCAT主站的状态
  2176. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatMasterSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2177. public static extern UInt32 IMC_H_GetEcatMasterSts(Int16 cardIndex, ref UInt32 pStatus);
  2178. /// @brief 获取EtherCAT协议栈通讯错误码
  2179. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatErrCode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2180. public static extern UInt32 IMC_H_GetEcatErrCode(Int16 cardIndex, ref UInt32 pErrCode);
  2181. /// @brief 获取EtherCAT主站的状态,Ex指令
  2182. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatMasterStsEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2183. public static extern UInt32 IMC_H_GetEcatMasterStsEx(Int16 cardIndex, ref UInt32 pStatus);
  2184. /// @brief 获取EtherCAT协议栈通讯错误码,Ex指令
  2185. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatErrCodeEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2186. public static extern UInt32 IMC_H_GetEcatErrCodeEx(Int16 cardIndex, ref UInt32 pErrCode);
  2187. /// @brief 获取EtherCAT从站当前通讯阶段, INIT, PerOP, SafeOP, OP
  2188. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatSlaveSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2189. public static extern UInt32 IMC_H_GetEcatSlaveSts(Int16 cardIndex, Int16 slave, ref Int16 pCurStatus, ref Int16 pReqStatus, ref Int16 pErrCode);
  2190. /// @brief 获取EtherCAT主站信息(包含通讯周期, 从站个数, 资源数量等)
  2191. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatMasterInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2192. public static extern UInt32 IMC_H_GetEcatMasterInfo(Int16 cardIndex, ref TMasterInfo ptMasterInfo);
  2193. /// @brief 获取EtherCAT从站信息(包含设备类型, 对应轴号, 从站别名等)
  2194. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatSlaveInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2195. public static extern UInt32 IMC_H_GetEcatSlaveInfo(Int16 cardIndex, Int16 slave, ref TSlaveInfo ptSlaveInfo);
  2196. /// @brief 根据站号读取EtherCAT从站的PDO数据
  2197. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatSlavePdoData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2198. public static extern UInt32 IMC_H_GetEcatSlavePdoData(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData);
  2199. /// @brief 根据站号写入EtherCAT从站的PDO数据
  2200. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatSlavePdoData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2201. public static extern UInt32 IMC_H_SetEcatSlavePdoData(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData);
  2202. /// @brief 根据站号获取EtherCAT从站的SDO数据
  2203. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatSlaveSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2204. public static extern UInt32 IMC_H_GetEcatSlaveSdo(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pResultSize, ref UInt32 pAbortCode);
  2205. /// @brief 根据站号写入EtherCAT从站的SDO数据
  2206. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatSlaveSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2207. public static extern UInt32 IMC_H_SetEcatSlaveSdo(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pAbortCode);
  2208. /// @brief 获取EtherCAT的DI输入状态, 按16bits为一组进行获取
  2209. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2210. public static extern UInt32 IMC_H_GetEcatDi(Int16 cardIndex, Int16 packIndex, UInt16[] pValue, Int16 packCnt);
  2211. /// @brief 设置EtherCAT的DO输出状态, 按16bits为一组进行设置
  2212. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2213. public static extern UInt32 IMC_H_SetEcatDo(Int16 cardIndex, Int16 packIndex, UInt16[] pValue, Int16 packCnt);
  2214. /// @brief 获取EtherCAT的DO输出状态, 按16bits为一组进行获取
  2215. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2216. public static extern UInt32 IMC_H_GetEcatDo(Int16 cardIndex, Int16 packIndex, UInt16[] pValue, Int16 packCnt);
  2217. /// @brief 获取EtherCAT的DI输入状态, 按位进行获取
  2218. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatDiBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2219. public static extern UInt32 IMC_H_GetEcatDiBit(Int16 cardIndex, Int16 diIndex, ref Int16 pValue);
  2220. /// @brief 获取EtherCAT的DO输出状态, 按位进行获取
  2221. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatDoBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2222. public static extern UInt32 IMC_H_GetEcatDoBit(Int16 cardIndex, Int16 doIndex, ref Int16 pValue);
  2223. /// @brief 设置EtherCAT的DO输出状态, 按位进行设置
  2224. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatDoBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2225. public static extern UInt32 IMC_H_SetEcatDoBit(Int16 cardIndex, Int16 doIndex, Int16 value);
  2226. /// @brief 根据通道号获取EtherCAT对应通道的AD值
  2227. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatAdVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2228. public static extern UInt32 IMC_H_GetEcatAdVal(Int16 cardIndex, Int16 adIndex, ref Int16 pValue);
  2229. /// @brief 根据通道号设置EtherCAT对应通道的DA值
  2230. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatDaVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2231. public static extern UInt32 IMC_H_SetEcatDaVal(Int16 cardIndex, Int16 daIndex, Int16 Value);
  2232. /// @brief 根据通道号获取EtherCAT对应通道的DA值
  2233. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatDaVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2234. public static extern UInt32 IMC_H_GetEcatDaVal(Int16 cardIndex, Int16 daIndex, ref Int16 pValue);
  2235. /// @brief 根据通道号获取EtherCAT对应通道的RegIn值
  2236. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatRegInVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2237. public static extern UInt32 IMC_H_GetEcatRegInVal(Int16 cardIndex, Int16 regIndex, ref float pValue);
  2238. /// @brief 根据通道号设置EtherCAT对应通道的RegOut值
  2239. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatRegOutVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2240. public static extern UInt32 IMC_H_SetEcatRegOutVal(Int16 cardIndex, Int16 regIndex, float Value);
  2241. /// @brief 根据通道号获取EtherCAT对应通道的RegOut值
  2242. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatRegOutVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2243. public static extern UInt32 IMC_H_GetEcatRegOutVal(Int16 cardIndex, Int16 regIndex, ref float pValue);
  2244. /// @brief 根据通道号获取EtherCAT对应通道的AD值
  2245. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatAd", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2246. public static extern UInt32 IMC_H_GetEcatAd(Int16 cardIndex, Int16 adIndex, Int16[] pValueArray, Int16 count);
  2247. /// @brief 根据通道号设置EtherCAT对应通道的DA值
  2248. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatDa", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2249. public static extern UInt32 IMC_H_SetEcatDa(Int16 cardIndex, Int16 daIndex, Int16[] pValueArray, Int16 count);
  2250. /// @brief 根据通道号获取EtherCAT对应通道的DA值
  2251. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatDa", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2252. public static extern UInt32 IMC_H_GetEcatDa(Int16 cardIndex, Int16 daIndex, Int16[] pValueArray, Int16 count);
  2253. /// @brief 根据通道号获取EtherCAT对应通道的RegIn值
  2254. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatRegIn", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2255. public static extern UInt32 IMC_H_GetEcatRegIn(Int16 cardIndex, Int16 regIndex, float[] pValueArray, Int16 count);
  2256. /// @brief 根据通道号设置EtherCAT对应通道的RegOut值
  2257. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatRegOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2258. public static extern UInt32 IMC_H_SetEcatRegOut(Int16 cardIndex, Int16 regIndex, float[] pValueArray, Int16 count);
  2259. /// @brief 根据通道号获取EtherCAT对应通道的RegOut值
  2260. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatRegOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2261. public static extern UInt32 IMC_H_GetEcatRegOut(Int16 cardIndex, Int16 regIndex, float[] pValueArray, Int16 count);
  2262. #endregion
  2263. #endregion
  2264. ///@defgroup LocalBus LocalBus
  2265. ///@brief 板卡端子板功能
  2266. #region LocalBus
  2267. ///@defgroup LocalInfo LocalInfo
  2268. ///@brief 板卡端子板信息获取
  2269. #region LocalInfo
  2270. /// @brief 获取端子板的工作状态
  2271. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalBoardWorkSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2272. public static extern UInt32 IMC_GetLocalBoardWorkSts(Int16 cardIndex, ref Int16 pValue);
  2273. #endregion
  2274. ///@defgroup LocalParam LocalParam
  2275. ///@brief 板卡端子板参数设置
  2276. #region LocalParam
  2277. /// @brief 设置端子板 DI 滤波时间
  2278. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalDiFilterTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2279. public static extern UInt32 IMC_SetLocalDiFilterTime(Int16 cardIndex, UInt16 filterTime);
  2280. /// @brief 读取端子板 DI 滤波时间
  2281. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalDiFilterTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2282. public static extern UInt32 IMC_GetLocalDiFilterTime(Int16 cardIndex, ref UInt16 pFilterTime);
  2283. /// @brief 设置端子板编码器滤波参数
  2284. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalEncFilterPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2285. public static extern UInt32 IMC_SetLocalEncFilterPara(Int16 cardIndex, Int16 filterDepth, Int16 filterCoef);
  2286. /// @brief 读取端子板编码器滤波参数
  2287. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalEncFilterPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2288. public static extern UInt32 IMC_GetLocalEncFilterPara(Int16 cardIndex, ref Int16 pFilterDepth, ref Int16 pFilterCoef);
  2289. /// @brief 设置端子板编码器计数方向
  2290. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalEncDir", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2291. public static extern UInt32 IMC_SetLocalEncDir(Int16 cardIndex, Int16 encIndex, Int16[] pDirArray, Int16 count = 1);
  2292. /// @brief 读取端子板编码器计数方向
  2293. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalEncDir", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2294. public static extern UInt32 IMC_GetLocalEncDir(Int16 cardIndex, Int16 encIndex, Int16[] pDirArray, Int16 count = 1);
  2295. #endregion
  2296. ///@defgroup LocalDIO LocalDIO
  2297. ///@brief 板卡端子板IO操作
  2298. #region LocalDIO
  2299. /// @brief 获取本地 DI 值
  2300. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2301. public static extern UInt32 IMC_GetLocalDi(Int16 cardIndex, ref Int16 pValue);
  2302. /// @brief 设置本地 DO 值
  2303. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2304. public static extern UInt32 IMC_SetLocalDo(Int16 cardIndex, Int16 value);
  2305. /// @brief 读取本地 DO 值
  2306. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2307. public static extern UInt32 IMC_GetLocalDo(Int16 cardIndex, ref Int16 pValue);
  2308. #endregion
  2309. /// @brief 按位获取本地第 diIndex 个 DI 值
  2310. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalDiBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2311. public static extern UInt32 IMC_GetLocalDiBit(Int16 cardIndex, Int16 diIndex, ref Int16 pValue);
  2312. /// @brief 按位设置本地第 doIndex 个 DO 值
  2313. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalDoBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2314. public static extern UInt32 IMC_SetLocalDoBit(Int16 cardIndex, Int16 doIndex, Int16 value);
  2315. /// @brief 按位设置本地第 doIndex 个 DO 值
  2316. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalDoBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2317. public static extern UInt32 IMC_GetLocalDoBit(Int16 cardIndex, Int16 doIndex, ref Int16 pValue);
  2318. /// @brief 按位脉冲输出本地第 doIndex 个 DO
  2319. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalDoBitPulse", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2320. public static extern UInt32 IMC_SetLocalDoBitPulse(Int16 cardIndex, Int16 doIndex, Int16 enable, UInt16 highLevelTime, UInt16 lowLevelTime, Int16 pulseNum, Int16 firstLevel);
  2321. ///@defgroup LocalEnc LocalEnc
  2322. ///@brief 板卡端子板编码器操作
  2323. #region LocalEnc
  2324. /// @brief 设置编码器值
  2325. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalEncPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2326. public static extern UInt32 IMC_SetLocalEncPos(Int16 cardIndex, Int16 encIndex, Int32 encPos);
  2327. /// @brief 读取编码器值
  2328. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalEncPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2329. public static extern UInt32 IMC_GetLocalEncPos(Int16 cardIndex, Int16 encIndex, Int32[] pEncPosArray, Int16 count = 1);
  2330. /// @brief 读取编码器速度
  2331. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalEncVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2332. public static extern UInt32 IMC_GetLocalEncVel(Int16 cardIndex, Int16 encIndex, Int32[] pEncVelArray, Int16 count = 1);
  2333. #endregion
  2334. ///@defgroup LocalCapt LocalCapt
  2335. ///@brief 板卡端子板捕获功能
  2336. #region LocalCapt
  2337. /// @brief 设置端子板编码器位置捕获模式, 配置捕获参数
  2338. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCaptMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2339. public static extern UInt32 IMC_SetLocalCaptMode(Int16 cardIndex, Int16 encIndex, Int16 trigType, Int16 edge);
  2340. /// @brief 获取端子板编码器位置捕获模式配置参数
  2341. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCaptMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2342. public static extern UInt32 IMC_GetLocalCaptMode(Int16 cardIndex, Int16 encIndex, ref Int16 pTrigType, ref Int16 pEdge);
  2343. /// @brief 获取端子板编码器位置捕获状态
  2344. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCaptStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2345. public static extern UInt32 IMC_GetLocalCaptStatus(Int16 cardIndex, Int16 encIndex, ref Int16 pSts, ref Int32 pPosVal, ref Int32 pNegVal);
  2346. /// @brief 设置端子板编码器连续位置捕获模式, 配置连续捕获参数
  2347. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCaptRepeatMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2348. public static extern UInt32 IMC_SetLocalCaptRepeatMode(Int16 cardIndex, Int16 encIndex, Int16 trigType, Int16 edge, Int16 captCount);
  2349. /// @brief 设置端子板编码器连续位置捕获模式配置参数
  2350. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCaptRepeatMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2351. public static extern UInt32 IMC_GetLocalCaptRepeatMode(Int16 cardIndex, Int16 encIndex, ref Int16 pTrigType, ref Int16 pEdge, ref Int16 pCaptCount);
  2352. /// @brief 获取端子板编码器连续位置捕获状态
  2353. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCaptRepeatStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2354. public static extern UInt32 IMC_GetLocalCaptRepeatStatus(Int16 cardIndex, Int16 encIndex, ref Int16 pCaptSts, ref Int16 pCaptCount);
  2355. /// @brief 获取端子板编码器连续位置捕获位置
  2356. /// @attention 双沿沿捕获时, 开辟存储数组长度应为 IMC_SetLocalCaptRepeatMode 设置 的 captCount 的 2 倍
  2357. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCaptRepeatPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2358. public static extern UInt32 IMC_GetLocalCaptRepeatPos(Int16 cardIndex, Int16 encIndex, Int16 startNo, Int16 count, Int32[] pCaptPosArray);
  2359. #endregion
  2360. ///@defgroup LocalPWM LocalPWM
  2361. ///@brief 板卡端子板PWM功能
  2362. #region LocalPWM
  2363. /// @brief 设置端子板PWM的输出参数
  2364. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalPwmPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2365. public static extern UInt32 IMC_SetLocalPwmPara(Int16 cardIndex, Int16 chn, Int32 frequency, double dutyRatio);
  2366. /// @brief 获取端子板PWM的输出参数
  2367. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalPwmPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2368. public static extern UInt32 IMC_GetLocalPwmPara(Int16 cardIndex, Int16 chn, ref Int32 pFrequency, ref double pDutyRatio);
  2369. /// @brief 设置端子板PWM的输出频率
  2370. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalPwmFrq", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2371. public static extern UInt32 IMC_SetLocalPwmFrq(Int16 cardIndex, Int16 chn, Int32 frequency);
  2372. /// @brief 设置端子板PWM的输出占空比
  2373. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalPwmDuty", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2374. public static extern UInt32 IMC_SetLocalPwmDuty(Int16 cardIndex, Int16 chn, double dutyRatio);
  2375. /// @brief 设置端子板PWM输出的开关及延时时间
  2376. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalPwmOnOffDelay", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2377. public static extern UInt32 IMC_SetLocalPwmOnOffDelay(Int16 cardIndex, Int16 chn, Int16 onOff, UInt16 delay);
  2378. #endregion
  2379. ///@defgroup LocalCompare LocalCompare
  2380. ///@brief 板卡端子板位置比较功能
  2381. #region LocalCompare
  2382. /// @brief 设置端子板位置比较输出源的配置
  2383. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpSrcCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2384. public static extern UInt32 IMC_SetLocalCmpSrcCfg(Int16 cardIndex, Int16 chn, Int16 compSrc);
  2385. /// @brief 设置端子板比较物理信号输出的配置
  2386. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpOutputCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2387. public static extern UInt32 IMC_SetLocalCmpOutputCfg(Int16 cardIndex, Int16 chn, Int16 ctrlMode, Int16 stLevel, Int16 outputType, UInt16 pulseWidth);
  2388. /// @brief 设置端子板比较数据的类型
  2389. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpDataType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2390. public static extern UInt32 IMC_SetLocalCmpDataType(Int16 cardIndex, Int16 chn, Int16 type);
  2391. /// @brief 获取端子板比较数据的类型
  2392. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCmpDataType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2393. public static extern UInt32 IMC_GetLocalCmpDataType(Int16 cardIndex, Int16 chn, ref Int16 pType);
  2394. /// @brief 设置端子板位置比较的位置类型
  2395. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpPosType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2396. public static extern UInt32 IMC_SetLocalCmpPosType(Int16 cardIndex, Int16 chn, Int16 type);
  2397. /// @brief 获取端子板位置比较的位置类型
  2398. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCmpPosType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2399. public static extern UInt32 IMC_GetLocalCmpPosType(Int16 cardIndex, Int16 chn, ref Int16 pType);
  2400. /// @brief 设置本地输出 EX-O bit0 ~ 3 位位置比较输出类型
  2401. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalGpoType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2402. public static extern UInt32 IMC_SetLocalGpoType(Int16 cardIndex, Int16 doIndex, Int16 type);
  2403. /// @brief 获取本地输出 EX-O bit0 ~ 3 位位置比较输出类型配置
  2404. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalGpoType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2405. public static extern UInt32 IMC_GetLocalGpoType(Int16 cardIndex, Int16 doIndex, ref Int16 pType);
  2406. /// @brief 获取端子板位置比较的状态
  2407. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCmpSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2408. public static extern UInt32 IMC_GetLocalCmpSts(Int16 cardIndex, Int16 chn, ref Int16 pCmpSts, ref Int32 pCmpCount);
  2409. /// @brief 设置端子板手动输出脉冲或电平
  2410. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpManualOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2411. public static extern UInt32 IMC_SetLocalCmpManualOut(Int16 cardIndex, Int16 chn, Int16 outval);
  2412. /// @brief 设置端子板多脉冲手动输出
  2413. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpManualMultiOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2414. public static extern UInt32 IMC_SetLocalCmpManualMultiOut(Int16 cardIndex, Int16 chn, UInt16 pulseNum, UInt16 pulseCycle);
  2415. /// @brief 设置端子板等间距线性比较输出
  2416. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpLinearOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2417. public static extern UInt32 IMC_SetLocalCmpLinearOut(Int16 cardIndex, Int16 chn, Int32 intrvalLen, Int32 cmpCount);
  2418. /// @brief 停止端子板比较输出
  2419. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopLocalCmpOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2420. public static extern UInt32 IMC_StopLocalCmpOut(Int16 cardIndex, Int16 chn);
  2421. /// @brief 启动端子板比较输出
  2422. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartLocalCmpOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2423. public static extern UInt32 IMC_StartLocalCmpOut(Int16 cardIndex, Int16 chn);
  2424. /// @brief 设置端子板一维位置比较输出数据
  2425. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2426. public static extern UInt32 IMC_SetLocalCmpData(Int16 cardIndex, Int16 chn, Int16 compCount, Int32[] pPosBufArray);
  2427. #endregion
  2428. ///@defgroup LocalMultCompare LocalMultCompare
  2429. ///@brief 板卡端子板多维位置比较功能
  2430. #region LocalMultCompare
  2431. /// @brief 设置端子板位置比较输出源的配置
  2432. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalMultiCmpSrcCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2433. public static extern UInt32 IMC_SetLocalMultiCmpSrcCfg(Int16 cardIndex, Int16 chn, Int16 dimension, Int16[] pCompSrcArray);
  2434. /// @brief 设置端子板比较物理信号输出的配置
  2435. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalMultiCmpOutputCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2436. public static extern UInt32 IMC_SetLocalMultiCmpOutputCfg(Int16 cardIndex, Int16 chn, Int16 stLevel, Int16 outputType, UInt16 pulseWidth);
  2437. /// @brief 获取端子板位置比较的状态
  2438. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalMultiCmpSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2439. public static extern UInt32 IMC_GetLocalMultiCmpSts(Int16 cardIndex, Int16 chn, ref Int16 pCmpSts, ref Int32 pCmpCount);
  2440. /// @brief 设置端子板比较数据的类型
  2441. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalMultiCmpDataType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2442. public static extern UInt32 IMC_SetLocalMultiCmpDataType(Int16 cardIndex, Int16 chn, Int16 type);
  2443. /// @brief 获取端子板比较数据的类型
  2444. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalMultiCmpDataType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2445. public static extern UInt32 IMC_GetLocalMultiCmpDataType(Int16 cardIndex, Int16 chn, ref Int16 pType);
  2446. /// @brief 设置端子板多维位置比较参数
  2447. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalMultiCmpPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2448. public static extern UInt32 IMC_SetLocalMultiCmpPara(Int16 cardIndex, Int16 chn, UInt16 syncDeltaPos, Int16 outPinType);
  2449. /// @brief 获取端子板多维位置比较参数
  2450. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalMultiCmpPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2451. public static extern UInt32 IMC_GetLocalMultiCmpPara(Int16 cardIndex, Int16 chn, ref UInt16 pSyncDeltaPos, ref Int16 pOutPinType);
  2452. /// @brief 设置多维比较位置点
  2453. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalMultiCmpData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2454. public static extern UInt32 IMC_SetLocalMultiCmpData(Int16 cardIndex, Int16 chn, TMultiCmpData[] pComparaDataArray, Int16 count);
  2455. /// @brief 启动端子板比较输出
  2456. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartLocalMultiCmpOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2457. public static extern UInt32 IMC_StartLocalMultiCmpOut(Int16 cardIndex, Int16 chn);
  2458. /// @brief 停止端子板比较输出
  2459. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopLocalMultiCmpOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2460. public static extern UInt32 IMC_StopLocalMultiCmpOut(Int16 cardIndex, Int16 chn);
  2461. #endregion
  2462. ///@defgroup LocalPSO LocalPSO
  2463. ///@brief 板卡端子板PSO功能
  2464. #region LocalPSO
  2465. /// @brief 设置端子板PSO功能参数
  2466. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalPSOPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2467. public static extern UInt32 IMC_SetLocalPSOPara(Int16 cardIndex, Int16 chn, Int16 dimension, Int16 pinType, Int16[] pPsoPosIndexArray, UInt16 outPlsWidth, Int32 syncDeltaPos);
  2468. /// @brief 获取端子板PSO功能参数配置
  2469. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalPSOPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2470. public static extern UInt32 IMC_GetLocalPSOPara(Int16 cardIndex, Int16 chn, ref Int16 pDimension, ref Int16 pPinType, Int16[] pPsoPosIndexArray, ref UInt16 pOutPlsWidth, ref Int32 pSyncDeltaPos);
  2471. /// @brief 设置PSO基频
  2472. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalPSOBaseFrq", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2473. public static extern UInt32 IMC_SetLocalPSOBaseFrq(Int16 cardIndex, Int16 chn, Int16 baseFrq);
  2474. /// @brief 获取PSO基频
  2475. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalPSOBaseFrq", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2476. public static extern UInt32 IMC_GetLocalPSOBaseFrq(Int16 cardIndex, Int16 chn, ref Int16 pBaseFrq);
  2477. /// @brief 启动PSO输出
  2478. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartLocalPSO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2479. public static extern UInt32 IMC_StartLocalPSO(Int16 cardIndex, Int16 chn);
  2480. /// @brief 停止PSO输出
  2481. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopLocalPSO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2482. public static extern UInt32 IMC_StopLocalPSO(Int16 cardIndex, Int16 chn);
  2483. /// @brief 获取PSO输出状态
  2484. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalPSOSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2485. public static extern UInt32 IMC_GetLocalPSOSts(Int16 cardIndex, Int16 chn, ref Int16 pSts, ref UInt16 pPsoCount);
  2486. #endregion
  2487. #endregion
  2488. ///@defgroup Axis Axis
  2489. ///@brief 板卡轴操作相关函数
  2490. #region Axis
  2491. ///@defgroup AxisConfig AxisConfig
  2492. ///@brief 板卡轴配置函数
  2493. #region AxisConfig
  2494. /// @brief 设置轴激活状态
  2495. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxActive", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2496. public static extern UInt32 IMC_SetAxActive(Int16 cardIndex, Int16 axNo, Int16 active);
  2497. /// @brief 读取轴激活状态
  2498. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxActive", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2499. public static extern UInt32 IMC_GetAxActive(Int16 cardIndex, Int16 axNo, ref Int16 pActive);
  2500. /// @brief 设置控制器单轴安全运行参数
  2501. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxMaxMtPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2502. public static extern UInt32 IMC_SetAxMaxMtPara(Int16 cardIndex, Int16 axNo, ref TMtPara pMtPara);
  2503. /// @brief 读取控制器单轴安全运行参数
  2504. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxMaxMtPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2505. public static extern UInt32 IMC_GetAxMaxMtPara(Int16 cardIndex, Int16 axNo, ref TMtPara pMtPara);
  2506. /// @brief 设置轴当量参数
  2507. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxEquiv", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2508. public static extern UInt32 IMC_SetAxEquiv(Int16 cardIndex, Int16 axNo, double[] pAxEquArray, Int16 count = 1);
  2509. /// @brief 获取轴当量参数
  2510. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEquiv", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2511. public static extern UInt32 IMC_GetAxEquiv(Int16 cardIndex, Int16 axNo, double[] pAxEquArray, Int16 count = 1);
  2512. /// @brief 设置轴输出绑定
  2513. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxBondCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2514. public static extern UInt32 IMC_SetAxBondCfg(Int16 cardIndex, Int16 axNo, Int16 axType, Int16 outputChn);
  2515. /// @brief 获取轴输出绑定
  2516. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxBondCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2517. public static extern UInt32 IMC_GetAxBondCfg(Int16 cardIndex, Int16 axNo, ref Int16 pAxType, ref Int16 pOutputChn);
  2518. /// @brief 复位轴绑定状态, 让所有轴恢复到虚轴状态
  2519. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ResetAxBondCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2520. public static extern UInt32 IMC_ResetAxBondCfg(Int16 cardIndex);
  2521. /// @brief 设置轴属性参数, 包含软限位、到位误差、最大跟随误差
  2522. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxAttriPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2523. public static extern UInt32 IMC_SetAxAttriPara(Int16 cardIndex, Int16 axNo, ref TAxAttriPara pAxAttriPara);
  2524. /// @brief 获取轴属性参数, 包含软限位、到位误差、最大跟随误差
  2525. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxAttriPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2526. public static extern UInt32 IMC_GetAxAttriPara(Int16 cardIndex, Int16 axNo, ref TAxAttriPara pAxAttriPara);
  2527. /// @brief 设置轴软限位
  2528. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxSoftLimit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2529. public static extern UInt32 IMC_SetAxSoftLimit(Int16 cardIndex, Int16 axNo, Int32 positive, Int32 negative);
  2530. /// @brief 获取轴软限位
  2531. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxSoftLimit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2532. public static extern UInt32 IMC_GetAxSoftLimit(Int16 cardIndex, Int16 axNo, ref Int32 pPositive, ref Int32 pNegative);
  2533. /// @brief 设置轴到位检查参数
  2534. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxArrivalBand", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2535. public static extern UInt32 IMC_SetAxArrivalBand(Int16 cardIndex, Int16 axNo, Int16 arrivalBand, UInt16 arrivalTime);
  2536. /// @brief 获取轴到位检查参数
  2537. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxArrivalBand", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2538. public static extern UInt32 IMC_GetAxArrivalBand(Int16 cardIndex, Int16 axNo, ref Int16 pArrivalBand, ref UInt16 pArrivalTime);
  2539. /// @brief 设置轴最大跟随误差
  2540. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxErrorPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2541. public static extern UInt32 IMC_SetAxErrorPos(Int16 cardIndex, Int16 axNo, Int32 errorPos);
  2542. /// @brief 获取轴最大跟随误差
  2543. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxErrorPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2544. public static extern UInt32 IMC_GetAxErrorPos(Int16 cardIndex, Int16 axNo, ref Int32 pErrorPos);
  2545. /// @brief 设置轴反向间隙补偿
  2546. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxBacklash", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2547. public static extern UInt32 IMC_SetAxBacklash(Int16 cardIndex, Int16 axNo, Int32 wholeCmpVal, Int32 cmpVel, Int16 cmpDir);
  2548. /// @brief 获取轴反向间隙补偿
  2549. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxBacklash", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2550. public static extern UInt32 IMC_GetAxBacklash(Int16 cardIndex, Int16 axNo, ref Int32 pWholeCmpVal, ref Int32 pCmpVel, ref Int16 pCmpDir);
  2551. /// @brief 设置轴安全检查使能综合配置
  2552. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxSafeCheck", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2553. public static extern UInt32 IMC_SetAxSafeCheck(Int16 cardIndex, Int16 axNo, ref TAxCheckEn pAxCheckEn);
  2554. /// @brief 获取轴安全检查使能综合配置
  2555. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxSafeCheck", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2556. public static extern UInt32 IMC_GetAxSafeCheck(Int16 cardIndex, Int16 axNo, ref TAxCheckEn pAxCheckEn);
  2557. /// @brief 设置轴报警检查使能配置
  2558. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxAlarmCheck", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2559. public static extern UInt32 IMC_SetAxAlarmCheck(Int16 cardIndex, Int16 axNo, Int16 enable, Int16 count = 1);
  2560. /// @brief 设置轴软限位检查使能配置
  2561. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxSoftLmtsCheck", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2562. public static extern UInt32 IMC_SetAxSoftLmtsCheck(Int16 cardIndex, Int16 axNo, Int16 enable, Int16 count = 1);
  2563. /// @brief 设置轴硬限位检查使能配置
  2564. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetHwLmtsCheck", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2565. public static extern UInt32 IMC_SetHwLmtsCheck(Int16 cardIndex, Int16 axNo, Int16 enable, Int16 count = 1);
  2566. /// @brief 设置轴跟随误差位检查使能配置
  2567. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxErrPosCheck", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2568. public static extern UInt32 IMC_SetAxErrPosCheck(Int16 cardIndex, Int16 axNo, Int16 enable, Int16 count = 1);
  2569. /// @brief 设定轴停止的平滑停止减速度和急停减速度
  2570. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxStopDec", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2571. public static extern UInt32 IMC_SetAxStopDec(Int16 cardIndex, Int16 axNo, double decSmoothStop, double decAbruptStop);
  2572. /// @brief 获取轴停止的平滑停止减速度和急停减速度
  2573. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxStopDec", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2574. public static extern UInt32 IMC_GetAxStopDec(Int16 cardIndex, Int16 axNo, ref double pDecSmoothStop, ref double pDecAbruptStop);
  2575. /// @brief 设定轴急停减速限制时间
  2576. /// @details 急停时根据当前速度和设定的急停减速度计算停止时间, 若超过设定的限制时间, 则按照当前限制时间重新计算减速度, 否则按照设定的减速度执行
  2577. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxEmgMaxDecLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2578. public static extern UInt32 IMC_SetAxEmgMaxDecLmt(Int16 cardIndex, Int16 axNo, UInt16 decLmtTime);
  2579. /// @brief 获取轴急停减速限制时间
  2580. /// @details 急停时根据当前速度和设定的急停减速度计算停止时间, 若超过设定的限制时间, 则按照当前限制时间重新计算加速度, 否则按照设定的加速度执行
  2581. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEmgMaxDecLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2582. public static extern UInt32 IMC_GetAxEmgMaxDecLmt(Int16 cardIndex, Int16 axNo, ref UInt16 pDecLmtTime);
  2583. /// @brief 设置轴的结束速度
  2584. /// @details 点位运动时,运动规划结束速度可以不为0,注意合理设置结束速度值,运动规划完成后,结束速度直接突跳速度为0,可能引起机台抖动
  2585. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxEndVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2586. public static extern UInt32 IMC_SetAxEndVel(Int16 cardIndex, Int16 axNo, double endVel);
  2587. /// @brief 获取轴的结束速度设定
  2588. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEndVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2589. public static extern UInt32 IMC_GetAxEndVel(Int16 cardIndex, Int16 axNo, ref double pEndVel);
  2590. /// @brief 设置圆形软限位参数
  2591. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ArcZoneLmtSetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2592. public static extern UInt32 IMC_ArcZoneLmtSetParam(Int16 cardIndex, Int16[] pAxNoArray, Int32[] pCenterArray, Int32 radius, Int16 sourceType);
  2593. /// @brief 获取圆形软限位参数
  2594. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ArcZoneLmtGetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2595. public static extern UInt32 IMC_ArcZoneLmtGetParam(Int16 cardIndex, Int16[] pAxNoArray, Int32[] pCenterArray, ref Int32 pRadius, ref Int16 pSourceType);
  2596. /// @brief 使能圆形软限位
  2597. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ArcZoneLmtEnable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2598. public static extern UInt32 IMC_ArcZoneLmtEnable(Int16 cardIndex, Int16 enable);
  2599. /// @brief 设置分段软限位参数
  2600. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SegLmtSetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2601. public static extern UInt32 IMC_SegLmtSetParam(Int16 cardIndex, Int16[] pAxNoArray, Int16 sourceType, Int32[] pPointXArray, Int32[] pPointYArray, Int16 pointCount, Int16 yLmtDir);
  2602. /// @brief 获取分段软限位参数
  2603. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SegLmtGetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2604. public static extern UInt32 IMC_SegLmtGetParam(Int16 cardIndex, Int16[] pAxNoArray, ref Int16 pSourceType, Int32[] pPointXArray, Int32[] pPointYArray, ref Int16 pPointCount, ref Int16 pYLmtDir);
  2605. /// @brief 使能分段软限位
  2606. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SegLmtEnable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2607. public static extern UInt32 IMC_SegLmtEnable(Int16 cardIndex, Int16 enable);
  2608. #endregion
  2609. ///@defgroup AxisStatus AxisStatus
  2610. ///@brief 轴状态监控
  2611. #region AxisStatus
  2612. /// @brief 获取轴规划模式, 该值中包含单轴模式和多轴模式的信息
  2613. /// @todo 是否取消单轴多轴状态分区, 底层需要做修改
  2614. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxPrfMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2615. public static extern UInt32 IMC_GetAxPrfMode(Int16 cardIndex, Int16 axNo, Int16[] pPrfModeArray, Int16 count = 1);
  2616. /// @brief 获取轴状态
  2617. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2618. public static extern UInt32 IMC_GetAxSts(Int16 cardIndex, Int16 axNo, Int32[] pAxStsArray, Int16 count = 1);
  2619. /// @brief 清除轴的错误状态, 当发生报警时, 需要调用该指令进行清除, 但如果实际物理报警还在, 则无法清除
  2620. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClrAxSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2621. public static extern UInt32 IMC_ClrAxSts(Int16 cardIndex, Int16 axNo, Int16 count = 1);
  2622. /// @brief 获取轴规划位置
  2623. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxPrfPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2624. public static extern UInt32 IMC_GetAxPrfPos(Int16 cardIndex, Int16 axNo, double[] pPrfPosArray, Int16 count = 1);
  2625. /// @brief 获取轴规划速度
  2626. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxPrfVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2627. public static extern UInt32 IMC_GetAxPrfVel(Int16 cardIndex, Int16 axNo, double[] pPrfVelArray, Int16 count = 1);
  2628. /// @brief 获取轴规划加速度
  2629. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxPrfAcc", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2630. public static extern UInt32 IMC_GetAxPrfAcc(Int16 cardIndex, Int16 axNo, double[] pPrfAccArray, Int16 count = 1);
  2631. /// @brief 获取轴编码器反馈位置
  2632. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEncPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2633. public static extern UInt32 IMC_GetAxEncPos(Int16 cardIndex, Int16 axNo, double[] pEncPosArray, Int16 count = 1);
  2634. /// @brief 获取轴编码器反馈速度
  2635. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEncVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2636. public static extern UInt32 IMC_GetAxEncVel(Int16 cardIndex, Int16 axNo, double[] pEncVelArray, Int16 count = 1);
  2637. /// @brief 获取轴编码器反馈加速度
  2638. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEncAcc", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2639. public static extern UInt32 IMC_GetAxEncAcc(Int16 cardIndex, Int16 axNo, double[] pEncAccArray, Int16 count = 1);
  2640. /// @brief 获取指定轴是否均已到位的状态
  2641. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetMultiAxArrivalSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2642. public static extern UInt32 IMC_GetMultiAxArrivalSts(Int16 cardIndex, UInt32 axMask, ref Int16 pSts, Int16 groupNo);
  2643. /// @brief 获取轴反向间隙差值
  2644. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxBacklashCmpVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2645. public static extern UInt32 IMC_GetAxBacklashCmpVal(Int16 cardIndex, Int16 axNo, ref Int32 pCmpVal);
  2646. /// @brief 获取轴规划位置(32位整形指令)
  2647. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxPrfPos32", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2648. public static extern UInt32 IMC_GetAxPrfPos32(Int16 cardIndex, Int16 axNo, Int32[] pPrfPosArray, Int16 count = 1);
  2649. /// @brief 获取轴编码器反馈位置(32位整形指令)
  2650. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEncPos32", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2651. public static extern UInt32 IMC_GetAxEncPos32(Int16 cardIndex, Int16 axNo, Int32[] pEncPosArray, Int16 count = 1);
  2652. /// @brief 获取轴规划位置(脉冲位置指令)
  2653. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPrfPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2654. public static extern UInt32 IMC_GetPrfPos(Int16 cardIndex, Int16 axNo, double[] pPrfPosArray, Int16 count = 1);
  2655. /// @brief 获取轴编码器原点位置
  2656. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxOrgEncPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2657. public static extern UInt32 IMC_GetAxOrgEncPos(Int16 cardIndex, Int16 axNo, Int32[] pOrgEncPosArray, Int16 count = 1);
  2658. /// @brief 获取轴停止原因
  2659. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxStopReason", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2660. public static extern UInt32 IMC_GetAxStopReason(Int16 cardIndex, Int16 axNo, Int16[] pAxStopReason, Int16 count = 1);
  2661. /// @brief 获取轴状态(Ex指令)
  2662. /// @todo 补充ex类型指令描述
  2663. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxStsEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2664. public static extern UInt32 IMC_GetAxStsEx(Int16 cardIndex, Int16 axNo, Int32[] pAxStsArray, Int16 count = 1);
  2665. /// @brief 获取轴规划位置(Ex指令)
  2666. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxPrfPosEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2667. public static extern UInt32 IMC_GetAxPrfPosEx(Int16 cardIndex, Int16 axNo, double[] pPrfPosArray, Int16 count = 1);
  2668. /// @brief 获取轴编码器反馈位置(Ex指令)
  2669. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEncPosEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2670. public static extern UInt32 IMC_GetAxEncPosEx(Int16 cardIndex, Int16 axNo, double[] pEncPosArray, Int16 count = 1);
  2671. /// @brief 获取 EtherCAT 类型轴的实际转矩, 根据count值可一次获取多个轴的扭矩(Ex类型指令)
  2672. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxActTorqEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2673. public static extern UInt32 IMC_GetAxActTorqEx(Int16 cardIndex, Int16 axNo, Int16[] pActTorqArray, Int16 count = 1);
  2674. #endregion
  2675. ///@defgroup AxisControl AxisControl
  2676. ///@brief 轴功能控制
  2677. #region AxisControl
  2678. /// @brief 使能伺服
  2679. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ServoOn", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2680. public static extern UInt32 IMC_ServoOn(Int16 cardIndex, Int16 axNo, Int16 count = 1);
  2681. /// @brief 关闭伺服
  2682. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ServoOff", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2683. public static extern UInt32 IMC_ServoOff(Int16 cardIndex, Int16 axNo, Int16 count = 1);
  2684. /// @brief 停止单轴轴运动
  2685. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2686. public static extern UInt32 IMC_StopMove(Int16 cardIndex, Int16 axNo, Int16 stopType);
  2687. /// @brief 按位停止单轴轴运动
  2688. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopMoveBits", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2689. public static extern UInt32 IMC_StopMoveBits(Int16 cardIndex, UInt32 axMask, UInt32 stopTypeBits);
  2690. /// @brief 设置轴的触发停止参数
  2691. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxStopTrigPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2692. public static extern UInt32 IMC_SetAxStopTrigPara(Int16 cardIndex, Int16 axNo, Int16 uselessFlag, Int16 bitNo, Int16 stopType, Int16 diType);
  2693. /// @brief 获取轴的触发停止参数
  2694. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxStopTrigPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2695. public static extern UInt32 IMC_GetAxStopTrigPara(Int16 cardIndex, Int16 axNo, ref Int16 pUselessFlag, ref Int16 pBitNo, ref Int16 pStopType, ref Int16 pDiType);
  2696. /// @brief 设置当前轴位置为用户指定位置
  2697. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxCurPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2698. public static extern UInt32 IMC_SetAxCurPos(Int16 cardIndex, Int16 axNo, double setPos);
  2699. /// @brief 同步轴位置, 将轴的规划位置与编码器位置同步
  2700. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SyncAxPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2701. public static extern UInt32 IMC_SyncAxPos(Int16 cardIndex, Int16 axNo);
  2702. #endregion
  2703. #endregion
  2704. ///@defgroup MotionControl MotionControl
  2705. ///@brief 板卡运动模式
  2706. #region MotionControl
  2707. ///@defgroup MotionPara MotionPara
  2708. ///@brief 全局运动参数相关接口
  2709. #region MotionPara
  2710. /// @brief 设置单轴运动参数
  2711. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxMvPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2712. public static extern UInt32 IMC_SetAxMvPara(Int16 cardIndex, Int16 axNo, double vel, double acc, double dec);
  2713. /// @brief 获取单轴运动参数
  2714. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxMvPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2715. public static extern UInt32 IMC_GetAxMvPara(Int16 cardIndex, Int16 axNo, ref double pVel, ref double pAcc, ref double pDec);
  2716. /// @brief 设定单轴速度规划类型
  2717. /// @details ratio 越大, 则 S 越接近 T 型速度规划, 冲击也越大; 反之, ratio 越小, 则规划越平顺, 冲击越小
  2718. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxVelType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2719. public static extern UInt32 IMC_SetAxVelType(Int16 cardIndex, Int16 axNo, Int16 velType, double ratio);
  2720. /// @brief 获取单轴速度规划类型
  2721. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxVelType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2722. public static extern UInt32 IMC_GetAxVelType(Int16 cardIndex, Int16 axNo, ref Int16 pVelType, ref double pRatio);
  2723. #endregion
  2724. ///@defgroup BasicMotion BasicMotion
  2725. ///@brief 基础运动功能
  2726. #region BasicMotion
  2727. ///@defgroup EcatAxisHoming EcatAxisHoming
  2728. ///@brief 板卡ECAT轴402回零功能功能
  2729. #region EcatAxisHoming
  2730. /// @brief 设置EtherCAT类型轴402回零参数
  2731. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatHomingPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2732. public static extern UInt32 IMC_SetEcatHomingPara(Int16 cardIndex, Int16 axNo, Int16 method, UInt32 highVel, UInt32 lowVel, UInt32 acc, Int32 offset);
  2733. /// @brief 将EtherCAT类型轴设置为回零模式
  2734. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatHomingMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2735. public static extern UInt32 IMC_SetEcatHomingMode(Int16 cardIndex, Int16 axNo);
  2736. /// @brief 控制EtherCAT类型轴开始402回零
  2737. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartEcatHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2738. public static extern UInt32 IMC_StartEcatHoming(Int16 cardIndex, Int16 axNo);
  2739. /// @brief 控制EtherCAT类型轴停止402回零
  2740. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopEcatHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2741. public static extern UInt32 IMC_StopEcatHoming(Int16 cardIndex, Int16 axNo);
  2742. /// @brief 控制EtherCAT类型轴退出回零模式
  2743. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ExitEcatHomingMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2744. public static extern UInt32 IMC_ExitEcatHomingMode(Int16 cardIndex, Int16 axNo);
  2745. /// @brief 获取EtherCAT类型轴的402回零状态
  2746. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetHomingStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2747. public static extern UInt32 IMC_GetHomingStatus(Int16 cardIndex, Int16 axNo, ref Int16 pStatus);
  2748. /// @brief EtherCAT类型轴402回零合成函数, 包含设定回零参数, 切回零模式以及启动回零运动
  2749. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2750. public static extern UInt32 IMC_StartHoming(Int16 cardIndex, Int16 axNo, ref THomingPara pHomingPara);
  2751. /// @brief 完成402回零动作合成函数, 包含停止回零, 退出ecat回零模式, 暂默认切到CSP模式
  2752. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_FinishHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2753. public static extern UInt32 IMC_FinishHoming(Int16 cardIndex, Int16 axNo);
  2754. #endregion
  2755. ///@defgroup EcatCSPHoming EcatCSPHoming
  2756. ///@brief 板卡ECAT轴CSP模式规划回零功能功能
  2757. #region EcatCSPHoming
  2758. /// @brief 设置 CSP 模式下回原点中 DI 触发对应 0x60FD(digitalInput)中的 bit 位置
  2759. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxProbeMaskBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2760. public static extern UInt32 IMC_SetEcatAxProbeMaskBit(Int16 cardIndex, Int16 axNo, Int16 prbDiBitNo);
  2761. /// @brief 获取 CSP 模式下回原点中 DI 触发对应 0x60FD(digitalInput)中的 bit 位置
  2762. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxProbeMaskBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2763. public static extern UInt32 IMC_GetEcatAxProbeMaskBit(Int16 cardIndex, Int16 axNo, ref Int16 pPrbDiBitNo);
  2764. /// @brief 开始EtherCAT类型轴CSP模式规划回零
  2765. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartEcatAxCSPHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2766. public static extern UInt32 IMC_StartEcatAxCSPHoming(Int16 cardIndex, Int16 axNo, Int16 method, Int16 dir, Int16 level, double hVel, double lVel, double acc, double offset);
  2767. /// @brief 停止EtherCAT类型轴CSP模式规划回零
  2768. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopEcatAxCSPHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2769. public static extern UInt32 IMC_StopEcatAxCSPHoming(Int16 cardIndex, Int16 axNo, Int16 stopMode);
  2770. /// @brief 获取EtherCAT类型轴CSP模式规划回零状态
  2771. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxCSPHomingSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2772. public static extern UInt32 IMC_GetEcatAxCSPHomingSts(Int16 cardIndex, Int16 axNo, ref Int16 pHomingMethod, ref Int16 pHomingState);
  2773. /// @brief 完成EtherCAT类型轴CSP模式规划回零
  2774. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_FinishEcatAxCSPHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2775. public static extern UInt32 IMC_FinishEcatAxCSPHoming(Int16 cardIndex, Int16 axNo);
  2776. #endregion
  2777. ///@defgroup PTP PTP
  2778. ///@brief PTP运动模式相关接口
  2779. #region PTP
  2780. /// @brief 启动单轴PTP运动
  2781. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartPtpMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2782. public static extern UInt32 IMC_StartPtpMove(Int16 cardIndex, Int16 axNo, double tgtPos, Int16 posType = 0);
  2783. /// @brief 启动多轴PTP的运动
  2784. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartMultiPtpMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2785. public static extern UInt32 IMC_StartMultiPtpMove(Int16 cardIndex, Int16 axNum, Int16[] pAxNoArray, double[] pTgtPosArray, Int16[] pPosTypeArray);
  2786. /// @brief 在线更新PTP目标位置
  2787. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpTgtPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2788. public static extern UInt32 IMC_UpdatePtpTgtPos(Int16 cardIndex, Int16 axNo, double tgtPos);
  2789. /// @brief 获取PTP目标位置
  2790. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtpTgtPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2791. public static extern UInt32 IMC_GetPtpTgtPos(Int16 cardIndex, Int16 axNo, ref double pTgtPos);
  2792. /// @brief 在线更新PTP运动参数
  2793. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpMvPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2794. public static extern UInt32 IMC_UpdatePtpMvPara(Int16 cardIndex, Int16 axNo, double tgtVel, double acc, double dec);
  2795. /// @brief 在线更新PTP目标速度
  2796. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpTgtVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2797. public static extern UInt32 IMC_UpdatePtpTgtVel(Int16 cardIndex, Int16 axNo, double tgtVel);
  2798. /// @brief 切换PTP规划模式
  2799. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PtpPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2800. public static extern UInt32 IMC_PtpPrf(Int16 cardIndex, Int16 axNo);
  2801. #endregion
  2802. ///@defgroup Jog Jog
  2803. ///@brief Jog运动模式相关接口
  2804. #region Jog
  2805. /// @brief 启动单轴JOG运动
  2806. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartJogMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2807. public static extern UInt32 IMC_StartJogMove(Int16 cardIndex, Int16 axNo, double tgVel);
  2808. /// @brief 启动多轴JOG运动
  2809. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartMultiJogMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2810. public static extern UInt32 IMC_StartMultiJogMove(Int16 cardIndex, Int16 axNum, Int16[] pAxNoArray, double[] pTgtVelArray);
  2811. /// @brief 在线更新JOG目标速度
  2812. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdateJogTgtVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2813. public static extern UInt32 IMC_UpdateJogTgtVel(Int16 cardIndex, Int16 axNo, double tgVel);
  2814. /// @brief 在线更新JOG运动参数
  2815. /// 注意:JOG规划减速度仅作用于JOG在线变速
  2816. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdateJogMvPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2817. public static extern UInt32 IMC_UpdateJogMvPara(Int16 cardIndex, Int16 axNo, double tgVel, double acc, double dec);
  2818. /// @brief 切换JOG规划模式
  2819. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_JogPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2820. public static extern UInt32 IMC_JogPrf(Int16 cardIndex, Int16 axNo);
  2821. #endregion
  2822. ///@defgroup PTPS PTPS
  2823. ///@brief PTPS运动模式相关接口
  2824. #region PTPS
  2825. /// @brief 切换PTPS规划模式
  2826. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PrfPtps", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2827. public static extern UInt32 IMC_PrfPtps(Int16 cardIndex, Int16 axNo);
  2828. /// @brief 设置PTPS运动启动速度
  2829. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPtpsBeginVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2830. public static extern UInt32 IMC_SetPtpsBeginVel(Int16 cardIndex, Int16 axNo, double beginVel);
  2831. /// @brief 设置PTPS运动结束速度
  2832. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPtpsEndVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2833. public static extern UInt32 IMC_SetPtpsEndVel(Int16 cardIndex, Int16 axNo, double endVel);
  2834. /// @brief 设置PTPS运动参数
  2835. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPtpsMovePara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2836. public static extern UInt32 IMC_SetPtpsMovePara(Int16 cardIndex, Int16 axNo, double tgVel, double acc, double dec);
  2837. /// @brief 设置PTPS运动参数
  2838. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPtpsMoveParaEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2839. public static extern UInt32 IMC_SetPtpsMoveParaEx(Int16 cardIndex, Int16 axNo, double tgtVel, double tgtAcc, double tgtDec, double prfAcc, double prfDec);
  2840. /// @brief 启动单轴PTPS快速规划
  2841. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartPtpsMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2842. public static extern UInt32 IMC_StartPtpsMove(Int16 cardIndex, Int16 axNo, double tgtPos, short posType);
  2843. /// @brief 启动单轴PTPS软启动规划
  2844. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartPtpsMoveA", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2845. public static extern UInt32 IMC_StartPtpsMoveA(Int16 cardIndex, Int16 axNo, double tgtPos, double startSlowPos, double startSlowVel, short posType);
  2846. /// @brief 启动单轴PTPS软着陆规划
  2847. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartPtpsMoveD", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2848. public static extern UInt32 IMC_StartPtpsMoveD(Int16 cardIndex, Int16 axNo, double tgtPos, double stopSlowPos, double stopSlowVel, short posType);
  2849. /// @brief 启动单轴PTPS多段运动规划,可实现软启动及软着陆
  2850. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartPtpsMoveM", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2851. public static extern UInt32 IMC_StartPtpsMoveM(Int16 cardIndex, Int16 axNo, double tgtPos, double startSlowPos, double startSlowVel, double stopSlowPos, double stopSlowVel, short posType);
  2852. /// @brief 在线更新PTPS目标位置,无法实现软着陆
  2853. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpsMovePos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2854. public static extern UInt32 IMC_UpdatePtpsMovePos(Int16 cardIndex, Int16 axNo, double tgtPos);
  2855. /// @brief 在线更新PTPS目标速度,无法实现软着陆
  2856. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpsMoveVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2857. public static extern UInt32 IMC_UpdatePtpsMoveVel(Int16 cardIndex, Int16 axNo, double tgtVel);
  2858. /// @brief 在线更新PTPS运动参数,无法实现软着陆
  2859. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpsMovePara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2860. public static extern UInt32 IMC_UpdatePtpsMovePara(Int16 cardIndex, Int16 axNo, double tgVel, double acc, double dec);
  2861. /// @brief 在线更新PTPS软着陆规划,实现软着陆
  2862. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpsMoveD", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2863. public static extern UInt32 IMC_UpdatePtpsMoveD(Int16 cardIndex, Int16 axNo, double tgtPos, double stopSlowPos, double stopSlowVel);
  2864. /// @brief 获取PTPS运动启动速度
  2865. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtpsBeginVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2866. public static extern UInt32 IMC_GetPtpsBeginVel(Int16 cardIndex, Int16 axNo, ref double pBeginVel);
  2867. /// @brief 获取PTPS运动结束速度
  2868. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtpsEndVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2869. public static extern UInt32 IMC_GetPtpsEndVel(Int16 cardIndex, Int16 axNo, ref double pEendVel);
  2870. /// @brief 获取PTPS运动参数
  2871. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtpsMovePara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2872. public static extern UInt32 IMC_GetPtpsMovePara(Int16 cardIndex, Int16 axNo, ref double pTgtVel, ref double pAcc, ref double pDec);
  2873. /// @brief 获取PTPS运动参数
  2874. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtpsMoveParaEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2875. public static extern UInt32 IMC_GetPtpsMoveParaEx(Int16 cardIndex, Int16 axNo, double pTgtVel, double pTgtAcc, double pTgtDec, double tPrfAcc, double tPrfDec);
  2876. #endregion
  2877. ///@defgroup Gear Gear
  2878. ///@brief Gear运动模式相关接口
  2879. #region Gear
  2880. /// @brief 切换为电子齿轮模式
  2881. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2882. public static extern UInt32 IMC_GearPrf(Int16 cardIndex, Int16 axNo);
  2883. /// @brief 设置电子齿轮参数
  2884. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearSetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2885. public static extern UInt32 IMC_GearSetParam(Int16 cardIndex, Int16 axNo, ref TGearParam pGearParam);
  2886. /// @brief 获取电子齿轮参数
  2887. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearGetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2888. public static extern UInt32 IMC_GearGetParam(Int16 cardIndex, Int16 axNo, ref TGearParam pGearParam);
  2889. /// @brief 启动电子齿轮运动
  2890. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2891. public static extern UInt32 IMC_GearStart(Int16 cardIndex, Int16 axNo);
  2892. /// @brief 停止电子齿轮运动
  2893. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearStop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2894. public static extern UInt32 IMC_GearStop(Int16 cardIndex, Int16 axNo, Int16 stopType);
  2895. /// @brief 获取电子齿轮状态
  2896. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearGetStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2897. public static extern UInt32 IMC_GearGetStatus(Int16 cardIndex, Int16 axNo, ref Int16 pStatus, ref Int16 pErr);
  2898. /// @brief 更新电子齿轮比
  2899. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearUpdateScale", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2900. public static extern UInt32 IMC_GearUpdateScale(Int16 cardIndex, Int16 axNo, Int32 masterScale, Int32 slaveScale, Int32 masterDis);
  2901. #endregion
  2902. ///@defgroup Pvt Pvt
  2903. ///@brief Pvt运动模式相关接口
  2904. #region Pvt
  2905. /// @brief 切换为PVT模式
  2906. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2907. public static extern UInt32 IMC_PvtPrf(Int16 cardIndex, Int16 axNo);
  2908. /// @brief 选择PVT数据表
  2909. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtTableSelect", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2910. public static extern UInt32 IMC_PvtTableSelect(Int16 cardIndex, Int16 axNo, Int16 tableId);
  2911. /// @brief 启动PVT运动
  2912. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2913. public static extern UInt32 IMC_PvtStart(Int16 cardIndex, Int16 axNum, Int16[] pAxArray);
  2914. /// @brief 获取PVT状态
  2915. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtGetStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2916. public static extern UInt32 IMC_PvtGetStatus(Int16 cardIndex, Int16 axNo, Int16[] pTableId, double[] pTime, Int16 count = 1);
  2917. /// @brief 设置PVT循环
  2918. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtSetLoop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2919. public static extern UInt32 IMC_PvtSetLoop(Int16 cardIndex, Int16 axNo, Int32 loop);
  2920. /// @brief 获取PVT循环
  2921. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtGetLoop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2922. public static extern UInt32 IMC_PvtGetLoop(Int16 cardIndex, Int16 axNo, ref Int32 pCurLoop, ref Int32 pLoop);
  2923. /// @brief 向PVT的指定数据表传送PT数据
  2924. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtTablePt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2925. public static extern UInt32 IMC_PvtTablePt(Int16 cardIndex, Int16 tableId, Int32 count, double[] P, double[] T);
  2926. /// @brief 向PVT的指定数据表传送数据, 采用PVT描述方式
  2927. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtTablePvt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2928. public static extern UInt32 IMC_PvtTablePvt(Int16 cardIndex, Int16 tableId, Int32 count, double[] P, double[] V, double[] T);
  2929. /// @brief 向PVT的指定数据表传送数据, 采用Percent描述方式(1段Percent描述方式消耗1~3个缓存空间)
  2930. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtTablePercent", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2931. public static extern UInt32 IMC_PvtTablePercent(Int16 cardIndex, Int16 tableId, Int32 count, double[] P, double[] T, double[] percent, double startVel = 0);
  2932. /// @brief 向PVT的指定数据表传送数据, 采用Complete描述方式
  2933. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtTableComplete", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2934. public static extern UInt32 IMC_PvtTableComplete(Int16 cardIndex, Int16 tableId, Int32 count, double[] P, double[] T, double startVel = 0, double endVel = 0);
  2935. #endregion
  2936. ///@defgroup Cam Cam
  2937. ///@brief Cam运动模式相关接口
  2938. #region Cam
  2939. /// @brief 设置凸轮规划模式
  2940. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2941. public static extern UInt32 IMC_CamPrf(Int16 cardIndex, Int16 axNo);
  2942. /// @brief 凸轮参数设置
  2943. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamSetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2944. public static extern UInt32 IMC_CamSetParam(Int16 cardIndex, Int16 axNo, Int16 masterType, Int16 masterNo, Int16 dirMode = 0);
  2945. /// @brief 凸轮参数获取
  2946. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamGetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2947. public static extern UInt32 IMC_CamGetParam(Int16 cardIndex, Int16 axNo, ref Int16 pMasterType, ref Int16 pMasterNo, ref Int16 pDirMode);
  2948. /// @brief 凸轮表选择
  2949. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableSelect", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2950. public static extern UInt32 IMC_CamTableSelect(Int16 cardIndex, Int16 axNo, Int16 tableId);
  2951. /// @brief 启动凸轮运动
  2952. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2953. public static extern UInt32 IMC_CamStart(Int16 cardIndex, Int16 axNo);
  2954. /// @brief 停止凸轮运动
  2955. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamStop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2956. public static extern UInt32 IMC_CamStop(Int16 cardIndex, Int16 axNo, Int16 stopType);
  2957. /// @brief 获取凸轮状态
  2958. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamGetStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2959. public static extern UInt32 IMC_CamGetStatus(Int16 cardIndex, Int16 axNo, ref Int16 pStatus, ref Int16 pTableId, ref Int32 pCurUserID);
  2960. /// @brief 获取凸轮在表中的主轴位置和从轴位置
  2961. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamGetCurPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2962. public static extern UInt32 IMC_CamGetCurPos(Int16 cardIndex, Int16 axNo, ref double pMasterPos, ref double pSlavePos);
  2963. /// @brief 设置凸轮循环次数
  2964. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamSetLoop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2965. public static extern UInt32 IMC_CamSetLoop(Int16 cardIndex, Int16 axNo, UInt32 loop);
  2966. /// @brief 获取凸轮循环次数
  2967. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamGetLoop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2968. public static extern UInt32 IMC_CamGetLoop(Int16 cardIndex, Int16 axNo, ref UInt32 pCurLoop, ref UInt32 pLoop);
  2969. /// @brief 设置凸轮启动方式
  2970. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamSetEvent", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2971. public static extern UInt32 IMC_CamSetEvent(Int16 cardIndex, Int16 axNo, Int16 type, Int32 masterPos);
  2972. /// @brief 获取凸轮启动方式
  2973. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamGetEvent", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2974. public static extern UInt32 IMC_CamGetEvent(Int16 cardIndex, Int16 axNo, ref Int16 pType, ref Int32 pMasterPos);
  2975. /// @brief 主轴相位偏移(由速度参数指定)
  2976. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamPhasing", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2977. public static extern UInt32 IMC_CamPhasing(Int16 cardIndex, Int16 axNo, double phaseShift, double phaseVel, double phaseAcc, double phaseDec, Int16 phaseShiftType = 0);
  2978. /// @brief 主轴相位偏移(指定主轴位移完成偏移)
  2979. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamPhasingDist", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2980. public static extern UInt32 IMC_CamPhasingDist(Int16 cardIndex, Int16 axNo, double phaseShift, double masterDist, double accDistRatio, double decDistRatio, Int16 phaseShiftType = 0);
  2981. /// @brief 停止主轴相位偏移
  2982. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamStopPhasing", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2983. public static extern UInt32 IMC_CamStopPhasing(Int16 cardIndex, Int16 axNo);
  2984. /// @brief 获取主轴相位偏移状态
  2985. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamGetPhasing", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2986. public static extern UInt32 IMC_CamGetPhasing(Int16 cardIndex, Int16 axNo, ref Int16 phasingSts, ref double pPhase, ref double pPhaseVel);
  2987. /// @brief 清除凸轮表数据
  2988. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableClrData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2989. public static extern UInt32 IMC_CamTableClrData(Int16 cardIndex, Int16 tableId);
  2990. /// @brief 获取凸轮表剩余空间
  2991. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableGetSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2992. public static extern UInt32 IMC_CamTableGetSpace(Int16 cardIndex, Int16 tableId, ref Int32 pSpace);
  2993. /// @brief 重新分配凸轮表数量和大小(总深度为8*2048)
  2994. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableResize", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2995. public static extern UInt32 IMC_CamTableResize(Int16 cardIndex, Int16 tableNum);
  2996. /// @brief 获取凸轮表数量和大小信息
  2997. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableGetInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  2998. public static extern UInt32 IMC_CamTableGetInfo(Int16 cardIndex, ref Int16 pTableNum, ref Int32 pTableSize);
  2999. /// @brief 凸轮表数据压入指令-通用压入指令
  3000. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3001. public static extern UInt32 IMC_CamTableData(Int16 cardIndex, Int16 tableId, Int32 count, Int16[] pCurveType, double[] pKeyPointParam, Int32[] pUserID = null);
  3002. /// @brief 凸轮表获取关键点之间指定相位的位移
  3003. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableGetDist", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3004. public static extern UInt32 IMC_CamTableGetDist(Int16 cardIndex, Int32 count, Int16[] pCurveType, double[] pKeyPointParam, double x, double[] pOutput);
  3005. #endregion
  3006. #endregion
  3007. ///@defgroup AdvMotion AdvMotion
  3008. ///@brief 高级运动功能
  3009. #region AdvMotion
  3010. ///@defgroup Crd Crd
  3011. ///@brief Crd坐标系插补运动模式相关接口
  3012. #region Crd
  3013. /// @brief 创建插补坐标系, 配置坐标系插补参数
  3014. /// @attention 注意!用户必须定义长度为 3 的数组进行传值
  3015. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetMtSys", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3016. public static extern UInt32 IMC_CrdSetMtSys(Int16 cardIndex, Int16 crdNo, Int16[] pMaskAxNoArray, Int16 lookAheadLen, double estopDec);
  3017. /// @brief 获取插补坐标系配置参数
  3018. /// @attention 注意!用户必须定义长度为 3 的数组进行传值
  3019. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetMtSysParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3020. public static extern UInt32 IMC_CrdGetMtSysParam(Int16 cardIndex, Int16 crdNo, Int16[] pMaskAxNoArray, ref Int16 pLookAheadLen, ref double pEstopDec);
  3021. /// @brief 删除插补坐标系
  3022. /// @attention 需对创建的坐标系进行删除, 否则接口报错
  3023. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdDeleteMtSys", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3024. public static extern UInt32 IMC_CrdDeleteMtSys(Int16 cardIndex, Int16 crdNo);
  3025. /// @brief 设置插补坐标系高级参数
  3026. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetAdvParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3027. public static extern UInt32 IMC_CrdSetAdvParam(Int16 cardIndex, Int16 crdNo, ref TCrdAdvParam pCrdAdvParam);
  3028. /// @brief 获取插补坐标系高级参数
  3029. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetAdvParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3030. public static extern UInt32 IMC_CrdGetAdvParam(Int16 cardIndex, Int16 crdNo, ref TCrdAdvParam pCrdAdvParam);
  3031. /// @brief 插补运动指令用户模式下的运动段的始末速度设置
  3032. /// @details 该指令主要用于用户规划模式下, 指定每段运动, 段的起始和段末的速度。一般情况下, 运动段的起始速度等于上一段的段末速度
  3033. /// @todo 插补模式用户速度功能待完成, 速度参数范围待补充
  3034. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetUserVelPlan", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3035. public static extern UInt32 IMC_CrdSetUserVelPlan(Int16 cardIndex, Int16 crdNo, double uStartVel, double uEndVel);
  3036. /// @brief 插补运动指令在用户规划模式下设置的运动段的始末速度的获取
  3037. /// @todo 插补模式用户速度功能待完成, 速度参数范围待补充
  3038. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetUserVelPlan", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3039. public static extern UInt32 IMC_CrdGetUserVelPlan(Int16 cardIndex, Int16 crdNo, ref double pUStartVel, ref double pUEndVel);
  3040. /// @brief 设置插补平滑参数。通过设置平滑等级和平滑精度, 使插补运动轨迹更平滑
  3041. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetSmoothParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3042. public static extern UInt32 IMC_CrdSetSmoothParam(Int16 cardIndex, Int16 crdNo, Int32 smoothLevel, double smoothTol);
  3043. /// @brief 获取插补平滑参数。通过设置平滑等级和平滑精度, 使插补运动轨迹更平滑
  3044. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetSmoothParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3045. public static extern UInt32 IMC_CrdGetSmoothParam(Int16 cardIndex, Int16 crdNo, ref Int32 pSmoothLevel, ref double pSmoothTol);
  3046. /// @brief 设置插补轨迹速度
  3047. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetTrajVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3048. public static extern UInt32 IMC_CrdSetTrajVel(Int16 cardIndex, Int16 crdNo, double tgtVel);
  3049. /// @brief 获取插补轨迹速度
  3050. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetTrajVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3051. public static extern UInt32 IMC_CrdGetTrajVel(Int16 cardIndex, Int16 crdNo, ref double pTgtVel);
  3052. /// @brief 设置插补轨迹加速度和减速度
  3053. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetTrajAccAndDec", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3054. public static extern UInt32 IMC_CrdSetTrajAccAndDec(Int16 cardIndex, Int16 crdNo, double tgtAcc, double tgtDec);
  3055. /// @brief 获取插补轨迹加速度和减速度
  3056. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetTrajAccAndDec", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3057. public static extern UInt32 IMC_CrdGetTrajAccAndDec(Int16 cardIndex, Int16 crdNo, ref double pTgtAcc, ref double pTgtDec);
  3058. /// @brief 设置插补强制规划末速度降为 0 标识
  3059. /// @details 如果将强制规划末速度降为 0, 则下面所有线段末速度为 0
  3060. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetZeroFlag", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3061. public static extern UInt32 IMC_CrdSetZeroFlag(Int16 cardIndex, Int16 crdNo, Int16 ZeroFlag);
  3062. /// @brief 获取插补强制规划末速度降为 0 标识
  3063. /// @details 如果将强制规划末速度降为 0, 则下面所有线段末速度为 0
  3064. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetZeroFlag", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3065. public static extern UInt32 IMC_CrdGetZeroFlag(Int16 cardIndex, Int16 crdNo, ref Int16 pZeroFlag);
  3066. /// @brief 设置插补运动指令的位置编程模式
  3067. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetIncMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3068. public static extern UInt32 IMC_CrdSetIncMode(Int16 cardIndex, Int16 crdNo, Int16 mode);
  3069. /// @brief 获取插补运动指令的位置编程模式
  3070. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetIncMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3071. public static extern UInt32 IMC_CrdGetIncMode(Int16 cardIndex, Int16 crdNo, ref Int16 pMode);
  3072. /// @brief 设置插补同步跟随轴的速度模式
  3073. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetFolVelMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3074. public static extern UInt32 IMC_CrdSetFolVelMode(Int16 cardIndex, Int16 crdNo, Int16 mode);
  3075. /// @brief 获取插补同步跟随轴的速度模式
  3076. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetFolVelMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3077. public static extern UInt32 IMC_CrdGetFolVelMode(Int16 cardIndex, Int16 crdNo, ref Int16 pMode);
  3078. /// @brief 设置插补运动指令的过渡精度
  3079. /// @details 该指令属于高级参数指令, 只有在启动过渡模式才生效
  3080. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetTrajTol", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3081. public static extern UInt32 IMC_CrdSetTrajTol(Int16 cardIndex, Int16 crdNo, double tol);
  3082. /// @brief 设置插补运动指令的拐弯系数。
  3083. /// @details 该指令属于高级参数指令, 只有在启动过渡模式才生效, 该参数越 小, 在过渡拐弯时速度降至越低, 参数越大, 则拐弯速度越高, 默认参数为 1
  3084. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetTrajTurnCoef", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3085. public static extern UInt32 IMC_CrdSetTrajTurnCoef(Int16 cardIndex, Int16 crdNo, double turnCoef);
  3086. /// @brief 三维直线插补运动
  3087. /// @attention[]]pEndPosArray 应传入长度为 3 的数组指针
  3088. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdLineXYZ", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3089. public static extern UInt32 IMC_CrdLineXYZ(Int16 cardIndex, Int16 crdNo, double[] pEndPosArray, Int32 userID = 0);
  3090. /// @brief XY平面内直线插补运动
  3091. /// @attention[]]pEndPosArray 应传入长度为 2 的数组指针
  3092. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdLineXY", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3093. public static extern UInt32 IMC_CrdLineXY(Int16 cardIndex, Int16 crdNo, double[] pEndPosArray, Int32 userID = 0);
  3094. /// @brief XZ平面内直线插补运动
  3095. /// @attention[]]pEndPosArray 应传入长度为 2 的数组指针
  3096. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdLineZX", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3097. public static extern UInt32 IMC_CrdLineZX(Int16 cardIndex, Int16 crdNo, double[] pEndPosArray, Int32 userID = 0);
  3098. /// @brief YZ平面内直线插补运动
  3099. /// @attention[]]pEndPosArray 应传入长度为 2 的数组指针
  3100. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdLineYZ", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3101. public static extern UInt32 IMC_CrdLineYZ(Int16 cardIndex, Int16 crdNo, double[] pEndPosArray, Int32 userID = 0);
  3102. /// @brief 给定三点的三维圆弧插补
  3103. /// @details 如果输入三点共线会导致圆弧几何错误, 此函数只能画小于一圈的圆不能画整圆和多圈圆
  3104. /// @attention pMidPos 、pEndPos 应传入长度为 3 的数组指针
  3105. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcThreePoint", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3106. public static extern UInt32 IMC_CrdArcThreePoint(Int16 cardIndex, Int16 crdNo, double[] pMidPosArray, double[] pEndPosArray, Int32 userID);
  3107. /// @brief 给定圆心, 末点法向量的三维圆弧插补
  3108. /// @details 当 height 不为 0 的时候可衍生为螺旋线插补。当起点和终点重合的时候几何参数错误。
  3109. /// @attention[]]pCenterArray[] pEndPosArray[] pNormalArray 应传入长度为 3 的数组指针
  3110. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Crd3DArcCenterNormal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3111. public static extern UInt32 IMC_Crd3DArcCenterNormal(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double[] pEndPosArray, double[] pNormalArray, double height = 0, Int32 turn = 0, Int32 userID = 0);
  3112. /// @brief 给定圆弧半径, 圆弧末点和圆弧法向量的三维圆弧插补
  3113. /// @details 当 height 不为 0 的时候可衍生为螺旋线插补。 此函数无法插补整圆
  3114. /// @attention[]]pEndPosArray[] pNormalArray 应传入长度为 3 的数组指针
  3115. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Crd3DArcRadiusNormal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3116. public static extern UInt32 IMC_Crd3DArcRadiusNormal(Int16 cardIndex, Int16 crdNo, double radius, double[] pEndPosArray, double[] pNormalArray, double height = 0, Int32 turn = 0, Int32 userID = 0);
  3117. /// @brief 给定圆弧圆心, 圆弧角度和圆弧法向量的三维圆弧插补
  3118. /// @details 当 height 不为 0 的时候可衍生为螺旋线插补。此函数可以画整圆
  3119. /// @attention[]]pCenterArray[] pNormalArray 应传入长度为 3 的数组指针
  3120. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Crd3DArcAngleNormal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3121. public static extern UInt32 IMC_Crd3DArcAngleNormal(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double angle, double[] pNormalArray, double height = 0, Int32 userID = 0);
  3122. /// @brief 给定圆弧圆心和圆弧末点, XY平面内的圆弧插补
  3123. /// @attention[]]pCenterArray[] pEndPosArray 应传入长度为 2 的数组指针
  3124. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcCenterXYPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3125. public static extern UInt32 IMC_CrdArcCenterXYPlane(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double[] pEndPosArray, Int16 dir, double height = 0, Int32 turn = 0, Int32 userID = 0);
  3126. /// @brief 给定圆弧圆心和圆弧末点, YZ平面内的圆弧插补
  3127. /// @attention[]]pCenterArray[] pEndPosArray 应传入长度为 2 的数组指针
  3128. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcCenterYZPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3129. public static extern UInt32 IMC_CrdArcCenterYZPlane(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double[] pEndPosArray, Int16 dir, double height = 0, Int32 turn = 0, Int32 userID = 0);
  3130. /// @brief 给定圆弧圆心和圆弧末点, ZX平面内的圆弧插补
  3131. /// @attention[]]pCenterArray[] pEndPosArray 应传入长度为 2 的数组指针
  3132. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcCenterZXPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3133. public static extern UInt32 IMC_CrdArcCenterZXPlane(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double[] pEndPosArray, Int16 dir, double height = 0, Int32 turn = 0, Int32 userID = 0);
  3134. /// @brief 给定圆弧半径和圆弧末点, XY平面内的圆弧插补
  3135. /// @attention[]]pEndPosArray 应传入长度为 2 的数组指针
  3136. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcRadiusXYPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3137. public static extern UInt32 IMC_CrdArcRadiusXYPlane(Int16 cardIndex, Int16 crdNo, double radius, double[] pEndPosArray, Int16 dir, double height = 0, Int32 turn = 0, Int32 userID = 0);
  3138. /// @brief 给定圆弧半径和圆弧末点, YZ平面内的圆弧插补
  3139. /// @attention[]]pEndPosArray 应传入长度为 2 的数组指针
  3140. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcRadiusYZPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3141. public static extern UInt32 IMC_CrdArcRadiusYZPlane(Int16 cardIndex, Int16 crdNo, double radius, double[] pEndPosArray, Int16 dir, double height = 0, Int32 turn = 0, Int32 userID = 0);
  3142. /// @brief 给定圆弧半径和圆弧末点, ZX平面内的圆弧插补
  3143. /// @attention[]]pEndPosArray 应传入长度为 2 的数组指针
  3144. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcRadiusZXPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3145. public static extern UInt32 IMC_CrdArcRadiusZXPlane(Int16 cardIndex, Int16 crdNo, double radius, double[] pEndPosArray, Int16 dir, double height = 0, Int32 turn = 0, Int32 userID = 0);
  3146. /// @brief 给定圆弧圆心和和圆弧角度, XY平面内的圆弧插补
  3147. /// @attention[]]pCenterArray 应传入长度为 2 的数组指针
  3148. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcAngleXYPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3149. public static extern UInt32 IMC_CrdArcAngleXYPlane(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double angle, double height = 0, Int32 userID = 0);
  3150. /// @brief 给定圆弧圆心和和圆弧角度, YZ平面内的圆弧插补
  3151. /// @attention[]]pCenterArray 应传入长度为 2 的数组指针
  3152. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcAngleYZPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3153. public static extern UInt32 IMC_CrdArcAngleYZPlane(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double angle, double height = 0, Int32 userID = 0);
  3154. /// @brief 给定圆弧圆心和和圆弧角度, ZX平面内的圆弧插补
  3155. /// @attention[]]pCenterArray 应传入长度为 2 的数组指针
  3156. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcAngleZXPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3157. public static extern UInt32 IMC_CrdArcAngleZXPlane(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double angle, double height = 0, Int32 userID = 0);
  3158. /// @brief 给定圆心, 末点法向量的三维涡旋线插补
  3159. /// @details 当 height 不为 0 的时候可衍生为螺旋线插补。当起点和终点重合的时候几何参数错误。
  3160. /// @attention[]]pCenterArray[] pEndPosArray[] pNormalArray 应传入长度为 3 的数组指针
  3161. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Crd3DVortexCenterNormal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3162. public static extern UInt32 IMC_Crd3DVortexCenterNormal(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double[] pEndPosArray, double[] pNormalArray, double height = 0, Int32 turn = 0, Int32 userID = 0);
  3163. /// @brief 给定涡旋线圆心和涡旋线末点, XY平面内的涡旋线插补
  3164. /// @attention[]]pCenterArray[] pEndPosArray 应传入长度为 2 的数组指针
  3165. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdVortexCenterXYPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3166. public static extern UInt32 IMC_CrdVortexCenterXYPlane(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double[] pEndPosArray, Int16 dir, double height = 0, Int32 turn = 0, Int32 userID = 0);
  3167. /// @brief 给定涡旋线圆心和涡旋线末点, YZ平面内的涡旋线插补
  3168. /// @attention[]]pCenterArray[] pEndPosArray 应传入长度为 2 的数组指针
  3169. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdVortexCenterYZPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3170. public static extern UInt32 IMC_CrdVortexCenterYZPlane(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double[] pEndPosArray, Int16 dir, double height = 0, Int32 turn = 0, Int32 userID = 0);
  3171. /// @brief 给定涡旋线圆心和涡旋线末点, ZX平面内的涡旋线插补
  3172. /// @attention[]]pCenterArray[] pEndPosArray 应传入长度为 2 的数组指针
  3173. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdVortexCenterZXPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3174. public static extern UInt32 IMC_CrdVortexCenterZXPlane(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double[] pEndPosArray, Int16 dir, double height = 0, Int32 turn = 0, Int32 userID = 0);
  3175. /// @brief 插补缓冲区等待延时
  3176. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdWaitTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3177. public static extern UInt32 IMC_CrdWaitTime(Int16 cardIndex, Int16 crdNo, Int32 waitTime, Int32 userID = 0);
  3178. /// @brief 插补缓冲区等待 DI
  3179. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdWaitDI", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3180. public static extern UInt32 IMC_CrdWaitDI(Int16 cardIndex, Int16 crdNo, Int16 diNO, Int16 diType, Int16 diLevel, Int32 userID = 0);
  3181. /// @brief 插补缓冲区等待 DI
  3182. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdWaitTimeDI", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3183. public static extern UInt32 IMC_CrdWaitTimeDI(Int16 cardIndex, Int16 crdNo, Int16 diNO, Int16 diType, Int16 diLevel, Int32 waitTime, Int32 userID = 0);
  3184. /// @brief 插补缓冲区输出 DO
  3185. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetDO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3186. public static extern UInt32 IMC_CrdSetDO(Int16 cardIndex, Int16 crdNo, Int16 doNO, Int16 doType, Int16 doLevel, Int32 userID = 0);
  3187. /// @brief 插补缓冲区指令, 执行到该段时, 以该段为起始, 在 waitPos 距离处输出指定的 DO 信号
  3188. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetDistanceDO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3189. public static extern UInt32 IMC_CrdSetDistanceDO(Int16 cardIndex, Int16 crdNo, double waitPos, Int16 doNO, Int16 doType, Int16 doLevel, Int32 userID = 0);
  3190. /// @brief 插补缓冲区指令, 执行到该段时, 以该段为起始, 延时设定时间, 输出指定的 DO 信号
  3191. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetTimeDO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3192. public static extern UInt32 IMC_CrdSetTimeDO(Int16 cardIndex, Int16 crdNo, Int32 waitTime, Int16 doNO, Int16 doType, Int16 doLevel, Int32 userID = 0);
  3193. /// @brief 插补缓冲区启动插补轴以外的轴 PTP 运动
  3194. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdPTPMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3195. public static extern UInt32 IMC_CrdPTPMove(Int16 cardIndex, Int16 crdNo, Int16 axNo, double tgtPos, double tgtVel, double acc, Int16 mvType, Int16 waitFlag, Int32 userID = 0);
  3196. /// @brief 插补缓冲区中启动插补轴之外的轴同步运动(相对位移)
  3197. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSyncMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3198. public static extern UInt32 IMC_CrdSyncMove(Int16 cardIndex, Int16 crdNo, Int16 axNo, double syncPos, Int32 userID = 0);
  3199. /// @brief 插补缓冲区中启动插补轴之外的轴同步运动(绝对位移)
  3200. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSyncMoveAbs", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3201. public static extern UInt32 IMC_CrdSyncMoveAbs(Int16 cardIndex, Int16 crdNo, Int16 axNo, double syncTgtPos, Int32 userID = 0);
  3202. /// @brief 插补缓冲区等待上一条运动指令到位
  3203. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdWaitInPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3204. public static extern UInt32 IMC_CrdWaitInPos(Int16 cardIndex, Int16 crdNo, Int32 userID = 0);
  3205. /// @brief 缓冲区插补轴外的多轴(两轴)同步运动
  3206. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdMultiSyncMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3207. public static extern UInt32 IMC_CrdMultiSyncMove(Int16 cardIndex, Int16 crdNo, Int16 axNum, Int16[] pAxNo, double[] pTgtPos, double tgtVel, double tgtAcc, Int16 contiFlag, Int32 userID = 0);
  3208. /// @brief 插补缓存运动停止
  3209. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdBufStop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3210. public static extern UInt32 IMC_CrdBufStop(Int16 cardIndex, Int16 crdNo, Int32 userID = 0);
  3211. /// @brief 插补缓存区设置全局变量
  3212. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetUserVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3213. public static extern UInt32 IMC_CrdSetUserVal(Int16 cardIndex, Int16 crdNo, Int16 index, Int32 value, Int32 userID = 0);
  3214. /// @brief 插补缓存区等待全局变量
  3215. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdWaitUserVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3216. public static extern UInt32 IMC_CrdWaitUserVal(Int16 cardIndex, Int16 crdNo, Int16 index, Int16 condition, Int32 compareValue, Int32 waitTime, Int32 userID = 0);
  3217. /// @brief 一次性往 DSP 队列发送 PC 部分的队列数据
  3218. /// @details 每次发送若干条, 如果完全发送完成, pIsFinished 标 识记为 1
  3219. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdEndData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3220. public static extern UInt32 IMC_CrdEndData(Int16 cardIndex, Int16 crdNo, ref Int16 pIsFinished);
  3221. /// @brief 插补运动使能函数, 调用此函数后, 会开始插补运动。如果停止插补运动, 需要调用停止运动函数 进行去插补使能
  3222. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3223. public static extern UInt32 IMC_CrdStart(Int16 cardIndex, Int16 crdNo);
  3224. /// @brief 多个插补坐标系同时运动使能函数, 调用此函数后, 会开始插补运动。如果停止插补运动, 需要调用停止运动函数 进行去插补使能
  3225. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdMultiStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3226. public static extern UInt32 IMC_CrdMultiStart(Int16 cardIndex, Int16[] pCrdNo, Int16 count);
  3227. /// @brief 调用此函数进行插补停止, 用户可以选择正常平滑停止和急停。
  3228. /// @details 正常平滑停止按照用户设定的轨迹加速度进行减速停止。急停是利用用户在建立坐标系设定的急停加速度进行停止, 停止后系统不会清空队列, 需要用户自己清空队列。
  3229. /// @attention 急停停止后, 插补会报出急停错误号, 需要手动清除此错误才能再次运行
  3230. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdStop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3231. public static extern UInt32 IMC_CrdStop(Int16 cardIndex, Int16 crdNo, Int16 stopType);
  3232. /// @brief 清除缓存区压入曲线数据
  3233. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdClrData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3234. public static extern UInt32 IMC_CrdClrData(Int16 cardIndex, Int16 crdNo);
  3235. /// @brief 清除插补错误号。可以清除 IMC_CrdGetStatus 获取到的故障号
  3236. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdClrError", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3237. public static extern UInt32 IMC_CrdClrError(Int16 cardIndex, Int16 crdNo);
  3238. /// @brief 插补倍率设定函数。插补实际进给速度 = 用户插补进给速度 × 倍率值。
  3239. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetRatio", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3240. public static extern UInt32 IMC_CrdSetRatio(Int16 cardIndex, Int16 crdNo, double ratio);
  3241. /// @brief 插补倍率获取函数
  3242. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetRatio", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3243. public static extern UInt32 IMC_CrdGetRatio(Int16 cardIndex, Int16 crdNo, ref double pRatio);
  3244. /// @brief 插补状态获取。bit0-bit7 是插补运行状态。bi8-bit15 是插补故障状态
  3245. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3246. public static extern UInt32 IMC_CrdGetStatus(Int16 cardIndex, Int16 crdNo, ref Int16 pStatus);
  3247. /// @brief 获取插补运动执行缓冲区最后一段的运动状态
  3248. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetArrivalSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3249. public static extern UInt32 IMC_CrdGetArrivalSts(Int16 cardIndex, Int16 crdNo, ref Int16 pSts);
  3250. /// @brief 获取插补目标位置。目标位置指的是最后压入曲线的末点位置
  3251. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetTargetPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3252. public static extern UInt32 IMC_CrdGetTargetPos(Int16 cardIndex, Int16 crdNo, double[] pPosArray);
  3253. /// @brief 获取插补暂停运动的位置。该位置一般用于当用户使用单轴移动过插补轴后, 需要返回继续加工时使用
  3254. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetPausePos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3255. public static extern UInt32 IMC_CrdGetPausePos(Int16 cardIndex, Int16 crdNo, double[] pPosArray);
  3256. /// @brief 当前插补坐标系坐标读取函数
  3257. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3258. public static extern UInt32 IMC_CrdGetPos(Int16 cardIndex, Int16 crdNo, double[] pCrdPosArray);
  3259. /// @brief 插补轨迹速度读取函数
  3260. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3261. public static extern UInt32 IMC_CrdGetVel(Int16 cardIndex, Int16 crdNo, ref double pCrdVel);
  3262. /// @brief 插补当前运动曲线用户索引获取
  3263. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetUserID", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3264. public static extern UInt32 IMC_CrdGetUserID(Int16 cardIndex, Int16 crdNo, ref Int32 pUserID);
  3265. /// @brief 获取队列当前的剩余余量
  3266. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3267. public static extern UInt32 IMC_CrdGetSpace(Int16 cardIndex, Int16 crdNo, ref Int32 pSpace);
  3268. /// @brief 获取 CPU 缓存队列当前的剩余空间
  3269. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetBufSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3270. public static extern UInt32 IMC_CrdGetBufSpace(Int16 cardIndex, Int16 crdNo, ref Int32 pSpace);
  3271. /// @brief 获取前瞻缓存队列当前的剩余空间
  3272. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetLookAheadSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3273. public static extern UInt32 IMC_CrdGetLookAheadSpace(Int16 cardIndex, Int16 crdNo, ref Int32 pSpace);
  3274. /// @brief 插补缓冲区模式设置
  3275. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetBufferMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3276. public static extern UInt32 IMC_CrdSetBufferMode(Int16 cardIndex, Int16 crdNo, Int16 bufferMode);
  3277. /// @brief 获取插补缓冲区模式
  3278. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetBufferMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3279. public static extern UInt32 IMC_CrdGetBufferMode(Int16 cardIndex, Int16 crdNo, ref Int16 pBufferMode);
  3280. /// @brief 插补数据恢复
  3281. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetDataRestore", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3282. public static extern UInt32 IMC_CrdSetDataRestore(Int16 cardIndex, Int16 crdNo);
  3283. #endregion
  3284. ///@defgroup MultiCrd MultiCrd
  3285. ///@brief MultiCrd 多轴插补运动模式相关接口
  3286. #region MultiCrd
  3287. /// @brief 建立多轴插补系统
  3288. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiSetupSys", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3289. public static extern UInt32 IMC_MultiSetupSys(Int16 cardIndex, Int16 groupNo, Int16[] pAxNo, Int16 maxAxNum);
  3290. /// @brief 销毁多轴插补系统
  3291. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiDeleteSys", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3292. public static extern UInt32 IMC_MultiDeleteSys(Int16 cardIndex, Int16 groupNo);
  3293. /// @brief 启动多轴插补运动
  3294. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3295. public static extern UInt32 IMC_MultiStart(Int16 cardIndex, Int16 groupNo);
  3296. /// @brief 停止多轴插补运动
  3297. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiStop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3298. public static extern UInt32 IMC_MultiStop(Int16 cardIndex, Int16 groupNo, Int16 stopType);
  3299. /// @brief 获取多轴插补数据剩余空间
  3300. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3301. public static extern UInt32 IMC_MultiGetSpace(Int16 cardIndex, Int16 groupNo, ref Int32 pSpace);
  3302. /// @brief 清除多轴插补系统错误状态
  3303. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiClrData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3304. public static extern UInt32 IMC_MultiClrData(Int16 cardIndex, Int16 groupNo);
  3305. /// @brief 清除多轴插补数据队列
  3306. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiClrError", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3307. public static extern UInt32 IMC_MultiClrError(Int16 cardIndex, Int16 groupNo);
  3308. /// @brief 设置多轴插补位置类型
  3309. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiSetPosType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3310. public static extern UInt32 IMC_MultiSetPosType(Int16 cardIndex, Int16 groupNo, Int16 posType);
  3311. /// @brief 获取多轴插补位置类型
  3312. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetPosType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3313. public static extern UInt32 IMC_MultiGetPosType(Int16 cardIndex, Int16 groupNo, ref Int16 pPosType);
  3314. /// @brief 获取多轴插补当前段UserID
  3315. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetUserID", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3316. public static extern UInt32 IMC_MultiGetUserID(Int16 cardIndex, Int16 groupNo, ref Int32 pUserID);
  3317. /// @brief 获取多轴插补系统运行状态
  3318. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3319. public static extern UInt32 IMC_MultiGetSts(Int16 cardIndex, Int16 groupNo, ref Int16 pSts, ref Int16 pErrocode);
  3320. /// @brief 获取多轴插补运动到位状态
  3321. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetArrivalSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3322. public static extern UInt32 IMC_MultiGetArrivalSts(Int16 cardIndex, Int16 groupNo, ref Int16 pArrivalSts);
  3323. /// @brief 设置多轴插补系统运动速度倍率
  3324. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiSetRatio", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3325. public static extern UInt32 IMC_MultiSetRatio(Int16 cardIndex, Int16 groupNo, double ratio);
  3326. /// @brief 获取多轴插补系统运动速度倍率
  3327. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetRatio", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3328. public static extern UInt32 IMC_MultiGetRatio(Int16 cardIndex, Int16 groupNo, ref double pRatio);
  3329. /// @brief 获取多轴插补运动轨迹位置
  3330. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetTrajPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3331. public static extern UInt32 IMC_MultiGetTrajPos(Int16 cardIndex, Int16 groupNo, double[] pPos);
  3332. /// @brief 获取多轴插补运动轨迹速度
  3333. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetTrajVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3334. public static extern UInt32 IMC_MultiGetTrajVel(Int16 cardIndex, Int16 groupNo, ref double pVel);
  3335. /// @brief 多轴插补直线运动
  3336. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiLineMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3337. public static extern UInt32 IMC_MultiLineMove(Int16 cardIndex, Int16 groupNo, double[] pEndPos, double trajVel, double trajAcc, double trajDec, Int16 blendType, double blendRatio, Int32 userID = 0);
  3338. /// @brief 多轴插补等待事件
  3339. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiWaitTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3340. public static extern UInt32 IMC_MultiWaitTime(Int16 cardIndex, Int16 groupNo, Int32 waitTime, Int32 userID);
  3341. /// @brief 多轴插补等待DI输入事件
  3342. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiWaitDI", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3343. public static extern UInt32 IMC_MultiWaitDI(Int16 cardIndex, Int16 groupNo, Int16 diIndex, Int16 diType, Int16 diLevel, Int32 waitTime, Int32 userID);
  3344. /// @brief 多轴插补设置DO输出事件
  3345. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiSetDO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3346. public static extern UInt32 IMC_MultiSetDO(Int16 cardIndex, Int16 groupNo, Int16 doIndex, Int16 doType, Int16 doLevel, Int32 userID);
  3347. /// @brief 多轴插补设置翻转DO输出事件
  3348. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiSetReverseDO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3349. public static extern UInt32 IMC_MultiSetReverseDO(Int16 cardIndex, Int16 groupNo, Int16 doIndex, Int16 doType, Int16 doLevel, Int32 waitTime, Int32 userID);
  3350. #endregion
  3351. ///@defgroup BandPt BandPt
  3352. ///@brief BandPt 缓冲区插补运动模式相关接口
  3353. #region BandPt
  3354. /// @brief 建立多轴捆绑 PT 运行系统
  3355. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetupPtPackSys", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3356. public static extern UInt32 IMC_SetupPtPackSys(Int16 cardIndex, Int16 sysNo, Int16[] pMaskAxNoArray, Int16 maxAxNum);
  3357. /// @brief 销毁捆绑 PT 运动系统
  3358. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_DeletePtPackSys", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3359. public static extern UInt32 IMC_DeletePtPackSys(Int16 cardIndex, Int16 sysNo);
  3360. /// @brief 设置捆绑 PT 运动位置的编程类型
  3361. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPtPackIncMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3362. public static extern UInt32 IMC_SetPtPackIncMode(Int16 cardIndex, Int16 sysNo, Int16 incMode);
  3363. /// @brief 获取捆绑 PT 运动位置的编程类型
  3364. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtPackIncMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3365. public static extern UInt32 IMC_GetPtPackIncMode(Int16 cardIndex, Int16 sysNo, ref Int16 pIncMode);
  3366. /// @brief 使能捆绑 PT 运动数据断流保护。当使能后, 根据缓冲区是否有数据, 同时判断各轴的速度是否大 于设定的阈值。
  3367. /// @details 如果系统中有任意一个轴的速度大于了设定的阈值, 则进行断流保护, 按照设定的 平滑停加速度进行停止。
  3368. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_EnablePtPackNoDataProtect", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3369. public static extern UInt32 IMC_EnablePtPackNoDataProtect(Int16 cardIndex, Int16 sysNo, double[] pThresholdVelArray);
  3370. /// @brief 取消捆绑 PT 运动数据断流保护
  3371. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_DisablePtPackNoDataProtect", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3372. public static extern UInt32 IMC_DisablePtPackNoDataProtect(Int16 cardIndex, Int16 sysNo);
  3373. /// @brief 获取捆绑 PT 运动数据断流保护的设置状态
  3374. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtPackNoDataProtectStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3375. public static extern UInt32 IMC_GetPtPackNoDataProtectStatus(Int16 cardIndex, Int16 sysNo, ref Int16 pEnSts, double[] pThresholdVelArray);
  3376. /// @brief 添加捆绑 PT 运动数据
  3377. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_AddMotionPointPtPack", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3378. public static extern UInt32 IMC_AddMotionPointPtPack(Int16 cardIndex, Int16 sysNo, double[] pPosArray, Int16[] pTypeArray, double T, Int16 dataNum);
  3379. /// @brief 添加捆绑 PT 中的 DO 输出事件
  3380. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_AddDoPointPtPack", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3381. public static extern UInt32 IMC_AddDoPointPtPack(Int16 cardIndex, Int16 sysNo, Int16 doNo, Int16 doType, Int16 doLevel);
  3382. /// @brief 启动捆绑 PT 运动
  3383. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartPtPack", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3384. public static extern UInt32 IMC_StartPtPack(Int16 cardIndex, Int16 sysNo);
  3385. /// @brief 停止捆绑 PT 运动
  3386. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopPtPack", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3387. public static extern UInt32 IMC_StopPtPack(Int16 cardIndex, Int16 sysNo, Int16 type);
  3388. /// @brief 清除捆绑 PT 运动数据
  3389. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClrPtPackData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3390. public static extern UInt32 IMC_ClrPtPackData(Int16 cardIndex, Int16 sysNo);
  3391. /// @brief 清除捆绑 PT 运动错误
  3392. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClrPtPackError", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3393. public static extern UInt32 IMC_ClrPtPackError(Int16 cardIndex, Int16 sysNo);
  3394. /// @brief 获取捆绑 PT 运动数据的空间
  3395. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtPackRestSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3396. public static extern UInt32 IMC_GetPtPackRestSpace(Int16 cardIndex, Int16 sysNo, ref Int16 pSpace);
  3397. /// @brief 获取捆绑 PT 运动的状态
  3398. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtPackStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3399. public static extern UInt32 IMC_GetPtPackStatus(Int16 cardIndex, Int16 sysNo, ref Int16 pStatus);
  3400. /// @brief 获取捆绑 PT 运动错误
  3401. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtPackError", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3402. public static extern UInt32 IMC_GetPtPackError(Int16 cardIndex, Int16 sysNo, ref Int16 pErr);
  3403. /// @brief 获取捆绑 PT 运动到位状态
  3404. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtPackArrivalSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3405. public static extern UInt32 IMC_GetPtPackArrivalSts(Int16 cardIndex, Int16 sysNo, ref Int16 pSts);
  3406. #endregion
  3407. #endregion
  3408. #endregion
  3409. ///@defgroup Compensation Compensation
  3410. ///@brief 运动补偿功能
  3411. #region Compensation
  3412. ///@defgroup ScrewComp ScrewComp
  3413. ///@brief 螺距误差补偿
  3414. #region ScrewComp
  3415. /// @brief 设置螺距误差补偿表
  3416. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxScrewCompTable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3417. public static extern UInt32 IMC_SetAxScrewCompTable(Int16 cardIndex, Int16 tableId, Int16 cnt, Int32[] pPosCompArray, Int32[] pNegCompArray);
  3418. /// @brief 获取螺距误差补偿表
  3419. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxScrewCompTable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3420. public static extern UInt32 IMC_GetAxScrewCompTable(Int16 cardIndex, Int16 tableId, ref Int16 pCnt, Int32[] pPosCompArray, Int32[] pNegCompArray);
  3421. /// @brief 设置螺距误差补偿参数
  3422. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxScrewCompParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3423. public static extern UInt32 IMC_SetAxScrewCompParam(Int16 cardIndex, Int16 axNo, Int16 pointCnt, Int32 startPos, Int32 len);
  3424. /// @brief 获取螺距误差补偿参数
  3425. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxScrewCompParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3426. public static extern UInt32 IMC_GetAxScrewCompParam(Int16 cardIndex, Int16 axNo, ref Int16 pPointCnt, ref Int32 pStartPos, ref Int32 pLen);
  3427. /// @brief 使能螺距误差补偿
  3428. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_EnableAxScrewComp", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3429. public static extern UInt32 IMC_EnableAxScrewComp(Int16 cardIndex, Int16 axNo, Int16 enable);
  3430. /// @brief 获取螺距误差补偿状态
  3431. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxScrewCompSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3432. public static extern UInt32 IMC_GetAxScrewCompSts(Int16 cardIndex, Int16 axNo, ref Int16 pEnable, ref double pCompVal);
  3433. #endregion
  3434. ///@defgroup TableComp TableComp
  3435. ///@brief 表补偿功能
  3436. #region TableComp
  3437. /// @brief 设置表补偿的数据表
  3438. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompSetTable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3439. public static extern UInt32 IMC_TableCompSetTable(Int16 cardIndex, Int16 tableId, Int32 cnt, Int32[] pDataArray);
  3440. /// @brief 获取表补偿的数据表
  3441. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompGetTable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3442. public static extern UInt32 IMC_TableCompGetTable(Int16 cardIndex, Int16 tableId, ref Int32 pCnt, Int32[] pDataArray);
  3443. /// @brief 设置表补偿参数
  3444. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompSetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3445. public static extern UInt32 IMC_TableCompSetParam(Int16 cardIndex, Int16 axNo, ref TTableCompParam pTTableCompParam);
  3446. /// @brief 获取表补偿参数
  3447. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompGetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3448. public static extern UInt32 IMC_TableCompGetParam(Int16 cardIndex, Int16 axNo, ref TTableCompParam pTTableCompParam);
  3449. /// @brief 使能表补偿
  3450. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompEnable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3451. public static extern UInt32 IMC_TableCompEnable(Int16 cardIndex, Int16 axNo, Int16 enable);
  3452. /// @brief 获取表补偿状态
  3453. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompGetSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3454. public static extern UInt32 IMC_TableCompGetSts(Int16 cardIndex, Int16 axNo, ref Int16 pEnable, ref double pCompVal);
  3455. /// @brief 重新分配表补偿的表数量和大小(总大小为40000)
  3456. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompTableResize", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3457. public static extern UInt32 IMC_TableCompTableResize(Int16 cardIndex, Int16 tableNum);
  3458. /// @brief 获取表补偿的表数量和大小信息
  3459. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompTableGetInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3460. public static extern UInt32 IMC_TableCompTableGetInfo(Int16 cardIndex, ref Int16 pTableNum, ref Int32 pTableSize);
  3461. #endregion
  3462. ///@defgroup AxPrfComp AxPrfComp
  3463. ///@brief 轴规划补偿功能
  3464. #region AxPrfComp
  3465. /// @brief 设置轴规划补偿
  3466. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxCompPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3467. public static extern UInt32 IMC_SetAxCompPos(Int16 cardIndex, Int16 axNo, double compPos, double compTime, Int16 posType);
  3468. /// @brief 获取轴规划补偿状态
  3469. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxCompSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3470. public static extern UInt32 IMC_GetAxCompSts(Int16 cardIndex, Int16 axNo, ref Int16 pSts, ref double pCompPos);
  3471. #endregion
  3472. #endregion
  3473. ///@defgroup Virtual Resource
  3474. ///@brief 板卡虚拟功能
  3475. #region VirtualResource
  3476. ///@defgroup UserVal
  3477. ///@brief 全局变量功能
  3478. #region UserVal
  3479. /// @brief 设置全局变量
  3480. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetUserVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3481. public static extern UInt32 IMC_SetUserVal(Int16 cardIndex, Int16 index, Int32 value);
  3482. /// @brief 读取全局变量
  3483. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetUserVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3484. public static extern UInt32 IMC_GetUserVal(Int16 cardIndex, Int16 index, ref Int32 pValue);
  3485. #endregion
  3486. #endregion
  3487. ///@defgroup Sample Sample
  3488. ///@brief 板卡采样功能相关接口
  3489. #region Sample
  3490. /// @brief 配置数据采集的参数
  3491. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ConfigSamplePara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3492. public static extern UInt32 IMC_ConfigSamplePara(Int16 cardIndex, ref TSamplePara pSamplePara);
  3493. /// @brief 配置数据采集的采集对象
  3494. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ConfigSampleData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3495. public static extern UInt32 IMC_ConfigSampleData(Int16 cardIndex, Int16 count, Int16[] pDataTypeArray, Int32[] pDataIndexArray);
  3496. /// @brief 使能数据采集
  3497. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ConfigSampleEnable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3498. public static extern UInt32 IMC_ConfigSampleEnable(Int16 cardIndex, Int16 enable);
  3499. /// @brief 获取数据采集的状态
  3500. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetSampleStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3501. public static extern UInt32 IMC_GetSampleStatus(Int16 cardIndex, ref Int16 pStatus, ref Int32 pLen, ref Int32 pLeakageCount);
  3502. /// @brief 获取数据采集的速度
  3503. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetSampleData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3504. public static extern UInt32 IMC_GetSampleData(Int16 cardIndex, ref Int16 pPackNum, Int16[] pDataArray);
  3505. #endregion
  3506. ///@defgroup MultiAxCmp MultiAxCmp
  3507. ///@brief 板卡多轴位置比较功能相关接口
  3508. #region MultiAxCmp
  3509. /// @brief 配置多轴比较输入源
  3510. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiAxCmpSrcCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3511. public static extern UInt32 IMC_MultiAxCmpSrcCfg(Int16 cardIndex, Int16 groupNo, Int16 cmpDimNum, Int16 cmpSrcType, Int16[] pCmpSrcArray, Int32 errorLmt);
  3512. /// @brief 使能多轴比较
  3513. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiAxCmpEnable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3514. public static extern UInt32 IMC_MultiAxCmpEnable(Int16 cardIndex, Int16 groupNo, Int16 enable);
  3515. /// @brief 压入多轴比较数据
  3516. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiAxCmpPushData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3517. public static extern UInt32 IMC_MultiAxCmpPushData(Int16 cardIndex, Int16 groupNo, Int16 cmpDimNum, Int16 eventIndex, Int32[] pCmpPosArray, ref Int16 pSpace);
  3518. /// @brief 清除多轴比较缓冲区数据
  3519. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiAxCmpClrData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3520. public static extern UInt32 IMC_MultiAxCmpClrData(Int16 cardIndex, Int16 groupNo);
  3521. /// @brief 获取多轴比较剩余空间
  3522. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiAxCmpGetSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3523. public static extern UInt32 IMC_MultiAxCmpGetSpace(Int16 cardIndex, Int16 groupNo, ref Int16 pSpace);
  3524. /// @brief 获取多轴比较状态
  3525. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiAxCmpGetSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3526. public static extern UInt32 IMC_MultiAxCmpGetSts(Int16 cardIndex, Int16 groupNo, ref Int16 pStatus, ref Int16 pCmpCnt, ref Int16 pCmpIndex);
  3527. #endregion
  3528. ///@defgroup PLC PLC
  3529. ///@brief 板卡PLC功能相关接口
  3530. #region PLC
  3531. /// @brief 编译参数结构体
  3532. [StructLayout(LayoutKind.Sequential)]
  3533. public struct TCompileInfo
  3534. {
  3535. public IntPtr pFileName;
  3536. public IntPtr pLineNo;
  3537. public IntPtr pMessage;
  3538. };
  3539. /// @brief 编译参数结构体
  3540. [StructLayout(LayoutKind.Sequential)]
  3541. public struct TVarInfo
  3542. {
  3543. public Int16 id;
  3544. public Int16 dataType;
  3545. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
  3546. public char[] name;
  3547. //public string name;
  3548. };
  3549. /// @brief 状态参数结构体
  3550. [StructLayout(LayoutKind.Sequential)]
  3551. public struct TThreadSts
  3552. {
  3553. public Int16 run;
  3554. public Int16 error;
  3555. public double result;
  3556. public Int16 line;
  3557. };
  3558. [StructLayout(LayoutKind.Sequential)]
  3559. public struct TBindDi
  3560. {
  3561. public Int16 diType;
  3562. public Int16 index; //绑定索引从1 开始
  3563. public Int16 reverse;
  3564. };
  3565. [StructLayout(LayoutKind.Sequential)]
  3566. public struct TBindDo
  3567. {
  3568. public Int16 doType;
  3569. public Int16 index; //绑定索引从1 开始
  3570. public Int16 reverse;
  3571. };
  3572. [StructLayout(LayoutKind.Sequential)]
  3573. public struct TBindTimer
  3574. {
  3575. public Int16 timerType; // 0 TT 1:TF 2:TTF
  3576. public Int32 delay; // 单位:ms
  3577. public Int16 inputVarId; //输入控制变量
  3578. };
  3579. [StructLayout(LayoutKind.Sequential)]
  3580. public struct TBindCounter
  3581. {
  3582. public Int16 counterType; //计数器类型:0-等于输出1 1-小于等于输出1 2-大于等于输出1
  3583. public Int16 edge; //计数沿: 0-上升沿 1-下降沿 2-双边沿
  3584. public Int32 init; //计数初值:复位变量为1时,内部计数恢复初值,(起点,终点)
  3585. public Int32 target; //计数器目标值
  3586. public Int32 begin; //计数器起点
  3587. public Int32 end; //计数器终点
  3588. public Int16 dir; //计数方向: 1-正向计数 -1-负向计数
  3589. public Int32 unit; //计数单位:计数器累加1次需要输入端出现边沿的次数
  3590. public Int16 inputVarId; //计数器输入变量
  3591. public Int16 resetVarId; //计数器复位变量
  3592. };
  3593. [StructLayout(LayoutKind.Sequential)]
  3594. public struct TBindFlank
  3595. {
  3596. public Int16 flankType; //边沿触发器类型:0-下降沿触发 1-上升沿触发 2-双边沿触发
  3597. public Int16 inputVarId; //边沿触发器输入变量,触发后保持到执行周期结束
  3598. };
  3599. [StructLayout(LayoutKind.Sequential)]
  3600. public struct TBindSrff
  3601. {
  3602. public Int16 setVarId; //置位变量 置位为1,输出1
  3603. public Int16 resetVarId; //复位变量 复位为1,置位为0,输出0
  3604. };
  3605. /// @brief 编译
  3606. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Compile", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3607. public static extern UInt32 IMC_Compile(string pFileName, ref TCompileInfo pWrongInfo);
  3608. /// @brief 下载
  3609. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Download", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3610. public static extern UInt32 IMC_Download(Int16 cardIndex, string pFileName);
  3611. /// @brief 获取函数id
  3612. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetFunId", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3613. public static extern UInt32 IMC_GetFunId(Int16 cardIndex, string pFunName, ref Int16 pFunId);
  3614. /// @brief 获取变量id
  3615. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetVarId", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3616. public static extern UInt32 IMC_GetVarId(Int16 cardIndex, string pFunName, string pVarName, ref TVarInfo pVarInfo);
  3617. /// @brief 绑定线程
  3618. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Bind", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3619. public static extern UInt32 IMC_Bind(Int16 cardIndex, Int16 thread, Int16 funId, Int16 page);
  3620. /// @brief 运行线程
  3621. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_RunThread", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3622. public static extern UInt32 IMC_RunThread(Int16 cardIndex, Int16 thread);
  3623. /// @brief 按周期运行线程
  3624. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_RunThreadPeriod", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3625. public static extern UInt32 IMC_RunThreadPeriod(Int16 cardIndex, Int16 thread, Int16 period, Int16 priority);
  3626. /// @brief 按断点运行线程
  3627. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_RunThreadToBreakpoint", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3628. public static extern UInt32 IMC_RunThreadToBreakpoint(Int16 cardIndex, Int16 thread, Int16 line);
  3629. /// @brief 单步运行线程
  3630. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StepThread", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3631. public static extern UInt32 IMC_StepThread(Int16 cardIndex, Int16 thread);
  3632. /// @brief 停止线程
  3633. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopThread", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3634. public static extern UInt32 IMC_StopThread(Int16 cardIndex, Int16 thread);
  3635. /// @brief 暂停线程
  3636. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PauseThread", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3637. public static extern UInt32 IMC_PauseThread(Int16 cardIndex, Int16 thread);
  3638. /// @brief 获取线程状态
  3639. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetThreadSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3640. public static extern UInt32 IMC_GetThreadSts(Int16 cardIndex, Int16 thread, ref TThreadSts pThreadSts);
  3641. /// @brief 获取线程运行周期
  3642. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetThreadTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3643. public static extern UInt32 IMC_GetThreadTime(Int16 cardIndex, Int16 thread, ref Int16 pPeriod, ref UInt32 pExecuteTime, ref UInt32 pExecuteTimeMax);
  3644. /// @brief 获取线程运行时间
  3645. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetThreadRunTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3646. public static extern UInt32 IMC_GetThreadRunTime(Int16 cardIndex, Int16 thread, ref UInt32 pExecuteTime, ref UInt32 pExecuteTimeMax);
  3647. /// @brief 设置变量值
  3648. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetVarValue", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3649. public static extern UInt32 IMC_SetVarValue(Int16 cardIndex, Int16 page, ref TVarInfo pVarInfo, double[] pValue, Int16 count);
  3650. /// @brief 获取变量值
  3651. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetVarValue", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3652. public static extern UInt32 IMC_GetVarValue(Int16 cardIndex, Int16 page, ref TVarInfo pVarInfo, double[] pValue, Int16 count);
  3653. /// @brief 解除绑定
  3654. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UnbindVar", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3655. public static extern UInt32 IMC_UnbindVar(Int16 cardIndex, Int16 thread);
  3656. /// @brief 绑定DI
  3657. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_BindDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3658. public static extern UInt32 IMC_BindDi(Int16 cardIndex, Int16 thread, ref TVarInfo pVarInfo, ref TBindDi pBindDi);
  3659. /// @brief 绑定DO
  3660. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_BindDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3661. public static extern UInt32 IMC_BindDo(Int16 cardIndex, Int16 thread, ref TVarInfo pVarInfo, ref TBindDo pBindDo);
  3662. /// @brief 绑定Timer
  3663. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_BindTimer", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3664. public static extern UInt32 IMC_BindTimer(Int16 cardIndex, Int16 thread, ref TVarInfo pVarInfo, ref TBindTimer pBindTimer);
  3665. /// @brief 绑定计数器
  3666. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_BindCounter", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3667. public static extern UInt32 IMC_BindCounter(Int16 cardIndex, Int16 thread, ref TVarInfo pVarInfo, ref TBindCounter pBindCounter);
  3668. /// @brief 绑定触发器Flank
  3669. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_BindFlank", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3670. public static extern UInt32 IMC_BindFlank(Int16 cardIndex, Int16 thread, ref TVarInfo pVarInfo, ref TBindFlank pBindFlank);
  3671. /// @brief 绑定置位器
  3672. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_BindSrff", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3673. public static extern UInt32 IMC_BindSrff(Int16 cardIndex, Int16 thread, ref TVarInfo pVarInfo, ref TBindSrff pBindSrff);
  3674. /// @brief 获取绑定DI输入状态
  3675. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3676. public static extern UInt32 IMC_GetBindDi(Int16 cardIndex, ref TVarInfo pVarInfo, ref TBindDi pBindDi);
  3677. /// @brief 获取绑定DO输出状态
  3678. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3679. public static extern UInt32 IMC_GetBindDo(Int16 cardIndex, ref TVarInfo pVarInfo, ref TBindDo pBindDo);
  3680. /// @brief 获取绑定Timer输出状态
  3681. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindTimer", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3682. public static extern UInt32 IMC_GetBindTimer(Int16 cardIndex, ref TVarInfo pVarInfo, ref TBindTimer pBindTimer, ref Int32 pCount);
  3683. /// @brief 获取绑定计数器输出状态
  3684. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindCounter", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3685. public static extern UInt32 IMC_GetBindCounter(Int16 cardIndex, ref TVarInfo pVarInfo, ref TBindCounter pBindCounter, ref Int32 pUnitCount, ref Int32 pCount);
  3686. /// @brief 获取绑定触发器Flank输出状态
  3687. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindFlank", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3688. public static extern UInt32 IMC_GetBindFlank(Int16 cardIndex, ref TVarInfo pVarInfo, ref TBindFlank pBindFlank);
  3689. /// @brief 获取绑定置位器Srff输出状态
  3690. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindSrff", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3691. public static extern UInt32 IMC_GetBindSrff(Int16 cardIndex, ref TVarInfo pVarInfo, ref TBindSrff pBindSrff);
  3692. /// @brief 获取绑定Di数量
  3693. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindDiCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3694. public static extern UInt32 IMC_GetBindDiCount(Int16 cardIndex, Int16 thread, ref Int16 pCount);
  3695. /// @brief 获取绑定Do数量
  3696. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindDoCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3697. public static extern UInt32 IMC_GetBindDoCount(Int16 cardIndex, Int16 thread, ref Int16 pCount);
  3698. /// @brief 获取绑定Timer数量
  3699. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindTimerCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3700. public static extern UInt32 IMC_GetBindTimerCount(Int16 cardIndex, Int16 thread, ref Int16 pCount);
  3701. /// @brief 获取绑定Counter数量
  3702. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindCounterCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3703. public static extern UInt32 IMC_GetBindCounterCount(Int16 cardIndex, Int16 thread, ref Int16 pCount);
  3704. /// @brief 获取绑定Flank数量
  3705. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindFlankCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3706. public static extern UInt32 IMC_GetBindFlankCount(Int16 cardIndex, Int16 thread, ref Int16 pCount);
  3707. /// @brief 获取绑定Srff数量
  3708. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindSrffCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3709. public static extern UInt32 IMC_GetBindSrffCount(Int16 cardIndex, Int16 thread, ref Int16 pCount);
  3710. /// @brief 获取绑定DI信息
  3711. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindDiInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3712. public static extern UInt32 IMC_GetBindDiInfo(Int16 cardIndex, Int16 thread, Int16 index, ref Int16 pVar, ref TBindDi pBindDi);
  3713. /// @brief 获取绑定DO信息
  3714. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindDoInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3715. public static extern UInt32 IMC_GetBindDoInfo(Int16 cardIndex, Int16 thread, Int16 index, ref Int16 pVar, ref TBindDo pBindDo);
  3716. /// @brief 获取绑定Timer信息
  3717. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindTimerInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3718. public static extern UInt32 IMC_GetBindTimerInfo(Int16 cardIndex, Int16 thread, Int16 index, ref Int16 pVar, ref TBindTimer pBindTimer);
  3719. /// @brief 获取绑定计数器信息
  3720. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindCounterInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3721. public static extern UInt32 IMC_GetBindCounterInfo(Int16 cardIndex, Int16 thread, Int16 index, ref Int16 pVar, ref TBindCounter pBindCounter);
  3722. /// @brief 获取绑定触发器Flank信息
  3723. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindFlankInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3724. public static extern UInt32 IMC_GetBindFlankInfo(Int16 cardIndex, Int16 thread, Int16 index, ref Int16 pVar, ref TBindFlank pBindFlank);
  3725. /// @brief 获取绑定置位器Srff信息
  3726. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindSrffInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3727. public static extern UInt32 IMC_GetBindSrffInfo(Int16 cardIndex, Int16 thread, Int16 index, ref Int16 pVar, ref TBindSrff pBindSrff);
  3728. #endregion
  3729. ///@defgroup PulseDO PulseDO
  3730. ///@brief 板卡脉冲DO输出功能相关接口
  3731. #region PulseDO
  3732. /// @brief 设置脉冲DO输出映射
  3733. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPulseDoMap", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3734. public static extern UInt32 IMC_SetPulseDoMap(Int16 cardIndex, Int16 index, Int16 doIndex);
  3735. /// @brief 获取脉冲DO输出映射
  3736. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPulseDoMap", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3737. public static extern UInt32 IMC_GetPulseDoMap(Int16 cardIndex, Int16 index, ref Int16 pDoIndex);
  3738. /// @brief 设置脉冲DO输出通道参数
  3739. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPulseDoOutputParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3740. public static extern UInt32 IMC_SetPulseDoOutputParam(Int16 cardIndex, Int16 index, UInt16 highLevelTime, UInt16 lowLevTime, Int16 firstLevel, Int16 pulseNum);
  3741. /// @brief 使能脉冲DO输出
  3742. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_EnablePulseDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3743. public static extern UInt32 IMC_EnablePulseDo(Int16 cardIndex, Int16 index, UInt16 highLevelTime, UInt16 lowLevTime, Int16 firstLevel, Int16 pulseNum);
  3744. /// @brief 停止脉冲DO输出
  3745. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_DisablePulseDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3746. public static extern UInt32 IMC_DisablePulseDo(Int16 cardIndex, Int16 index);
  3747. /// @brief 获取脉冲DO输出状态
  3748. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPulseDoStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3749. public static extern UInt32 IMC_GetPulseDoStatus(Int16 cardIndex, Int16 index, ref Int16 pStatus);
  3750. #endregion
  3751. ///@defgroup Event Event
  3752. ///@brief 板卡事件功能相关接口
  3753. #region Event
  3754. /// @brief 设置事件
  3755. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEvent", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3756. public static extern UInt32 IMC_SetEvent(Int16 cardIndex, Int16 eventIndex, ref TEvent pEvent);
  3757. /// @brief 设置任务
  3758. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetTask", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3759. public static extern UInt32 IMC_SetTask(Int16 cardIndex, Int16 taskIndex, Int16 taskType, IntPtr pTask);
  3760. /// @brief 设置事件与任务连接
  3761. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEventTaskLink", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3762. public static extern UInt32 IMC_SetEventTaskLink(Int16 cardIndex, Int16 eventIndex, Int16[] taskIndexArray, Int16 count);
  3763. /// @brief 事件开启
  3764. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_EventOn", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3765. public static extern UInt32 IMC_EventOn(Int16 cardIndex, Int16 eventIndex, Int16 count = 1);
  3766. /// @brief 事件关闭
  3767. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_EventOff", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3768. public static extern UInt32 IMC_EventOff(Int16 cardIndex, Int16 eventIndex, Int16 count = 1);
  3769. /// @brief 事件强制触发
  3770. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_EventForceTrigger", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3771. public static extern UInt32 IMC_EventForceTrigger(Int16 cardIndex, Int16 eventIndex, Int16 count = 1);
  3772. /// @brief 清除事件
  3773. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClearEvent", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3774. public static extern UInt32 IMC_ClearEvent(Int16 cardIndex, Int16 eventIndex, Int16 count = 1);
  3775. /// @brief 清除任务
  3776. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClearTask", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3777. public static extern UInt32 IMC_ClearTask(Int16 cardIndex, Int16 taskIndex, Int16 count = 1);
  3778. /// @brief 清除事件与任务的连接
  3779. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClearEventTaskLink", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3780. public static extern UInt32 IMC_ClearEventTaskLink(Int16 cardIndex, Int16 eventIndex, Int16 count = 1);
  3781. /// @brief 获取设置的事件数量
  3782. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEventCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3783. public static extern UInt32 IMC_GetEventCount(Int16 cardIndex, ref Int16 pCount);
  3784. /// @brief 获取设置的事件
  3785. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEvent", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3786. public static extern UInt32 IMC_GetEvent(Int16 cardIndex, Int16 eventIndex, ref TEvent pEvent);
  3787. /// @brief 获取事件的触发次数
  3788. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEventTriggerCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3789. public static extern UInt32 IMC_GetEventTriggerCount(Int16 cardIndex, Int16 eventIndex, ref Int16 pTriggerCount);
  3790. /// @brief 获取设置的任务数量
  3791. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetTaskCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3792. public static extern UInt32 IMC_GetTaskCount(Int16 cardIndex, ref Int16 pCount);
  3793. /// @brief 获取任务
  3794. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetTask", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3795. public static extern UInt32 IMC_GetTask(Int16 cardIndex, Int16 taskIndex, ref Int16 pTaskType, IntPtr pTaskData);
  3796. /// @brief 获取设置的事件与任务连接数量
  3797. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEventTaskLinkCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3798. public static extern UInt32 IMC_GetEventTaskLinkCount(Int16 cardIndex, Int16 eventIndex, ref Int16 pCount);
  3799. /// @brief 获取任务执行结果
  3800. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetTaskResult", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3801. public static extern UInt32 IMC_GetTaskResult(Int16 cardIndex, Int16 taskIndex, ref Int16 pResult);
  3802. #endregion
  3803. ///@defgroup CmdList CmdList
  3804. ///@brief 板卡指令缓存输出功能相关接口
  3805. #region CmdList
  3806. /// @brief 启动缓存区指令执行
  3807. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3808. public static extern UInt32 IMC_CmdListStart(Int16 cardIndex, Int16 index, Int16 type);
  3809. /// @brief 停止指令缓存区执行
  3810. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListStop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3811. public static extern UInt32 IMC_CmdListStop(Int16 cardIndex, Int16 index);
  3812. /// @brief 设置指令缓存区运行模式
  3813. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListSetMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3814. public static extern UInt32 IMC_CmdListSetMode(Int16 cardIndex, Int16 index, Int16 mode);
  3815. /// @brief 获取指令缓存区运行模式
  3816. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListGetMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3817. public static extern UInt32 IMC_CmdListGetMode(Int16 cardIndex, Int16 index, ref Int16 mode);
  3818. /// @brief 获取指令缓存区运行状态、错误码和当前执行段号
  3819. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListGetStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3820. public static extern UInt32 IMC_CmdListGetStatus(Int16 cardIndex, Int16 index, ref Int16 pStatus, ref Int16 pErrorCode, ref Int32 pCurrentId);
  3821. /// @brief 获取指令缓存区剩余空间
  3822. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListGetSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3823. public static extern UInt32 IMC_CmdListGetSpace(Int16 cardIndex, Int16 index, ref Int16 pSpace);
  3824. /// @brief 清除指令缓存区数据
  3825. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListClearData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3826. public static extern UInt32 IMC_CmdListClearData(Int16 cardIndex, Int16 index);
  3827. /// @brief 清除指令缓存区错误
  3828. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListClearError", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3829. public static extern UInt32 IMC_CmdListClearError(Int16 cardIndex, Int16 index);
  3830. /// @brief 设置指令缓存区循环执行次数
  3831. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListSetLoop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3832. public static extern UInt32 IMC_CmdListSetLoop(Int16 cardIndex, Int16 index, Int32 setCount);
  3833. /// @brief 获取指令缓存区循环执行次数
  3834. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListGetLoop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3835. public static extern UInt32 IMC_CmdListGetLoop(Int16 cardIndex, Int16 index, ref Int32 setCount, ref Int32 doneCount);
  3836. /// @brief 缓存区运动指令,执行轴PTP运动
  3837. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListAxMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3838. public static extern UInt32 IMC_CmdListAxMove(Int16 cardIndex, Int16 index, Int16 axNo, double tgtPos, Int32 userID);
  3839. /// @brief 缓存区运动指令,在线更新ptp运动目标位置
  3840. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListUpdateAxMovePos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3841. public static extern UInt32 IMC_CmdListUpdateAxMovePos(Int16 cardIndex, Int16 index, Int16 axNo, double tgtPos, Int32 userID);
  3842. /// @brief 缓存区运动指令,在线更新轴运动速度参数
  3843. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListUpdateAxMovePara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3844. public static extern UInt32 IMC_CmdListUpdateAxMovePara(Int16 cardIndex, Int16 index, Int16 axNo, double tgtVel, double tgtAcc, double tgtDec, Int32 userID);
  3845. /// @brief 缓存区运动指令,执行轴ptp运动,目标位置来源为全局变量值
  3846. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListAxMoveUserVar", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3847. public static extern UInt32 IMC_CmdListAxMoveUserVar(Int16 cardIndex, Int16 index, Int16 axNo, Int16 eventIndex, Int32 userID);
  3848. /// @brief 缓存区等待指令,延时等待一段时间
  3849. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListWaitTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3850. public static extern UInt32 IMC_CmdListWaitTime(Int16 cardIndex, Int16 index, Int16 waitTime, Int32 userID);
  3851. /// @brief 缓存区等待指令,等待DI触发
  3852. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListWaitDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3853. public static extern UInt32 IMC_CmdListWaitDi(Int16 cardIndex, Int16 index, Int16 diNo, Int16 diLevel, Int16 diType, Int32 userID);
  3854. /// @brief 缓存区等待指令,等待轴运动到位
  3855. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListWaitAxMoveDone", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3856. public static extern UInt32 IMC_CmdListWaitAxMoveDone(Int16 cardIndex, Int16 index, Int16 axNo, Int16 arrvType, Int32 userID);
  3857. /// @brief 缓存区等待指令,等待轴位置穿越位置
  3858. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListWaitAxPosCross", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3859. public static extern UInt32 IMC_CmdListWaitAxPosCross(Int16 cardIndex, Int16 index, Int16 axNo, Int32 Pos, Int16 crossType, Int32 userID);
  3860. /// @brief 缓存区等待指令,等待全局变量值
  3861. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListWaitUserVar", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3862. public static extern UInt32 IMC_CmdListWaitUserVar(Int16 cardIndex, Int16 index, Int16 varIndex, Int32 varValue, Int32 userID);
  3863. /// @brief 缓存区等待指令,等待事件执行完成
  3864. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListWaitEventDone", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3865. public static extern UInt32 IMC_CmdListWaitEventDone(Int16 cardIndex, Int16 index, Int16 eventIndex, Int32 userID);
  3866. /// @brief 缓存区设置指令,设置DO输出
  3867. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListSetDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3868. public static extern UInt32 IMC_CmdListSetDo(Int16 cardIndex, Int16 index, Int16 doNo, Int16 doLevel, Int16 doType, Int32 userID);
  3869. /// @brief 缓存区设置指令,设置脉冲DO输出
  3870. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListSetPulseDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3871. public static extern UInt32 IMC_CmdListSetPulseDo(Int16 cardIndex, Int16 index, Int16 outIndex, Int32 userID);
  3872. /// @brief 缓存区设置指令,设置事件启动
  3873. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListSetUserVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3874. public static extern UInt32 IMC_CmdListSetUserVal(Int16 cardIndex, Int16 index, Int16 varIndex, Int32 varValue, Int32 userID);
  3875. /// @brief 缓存区设置指令,设置全局变量值
  3876. [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListSetEventTrigger", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
  3877. public static extern UInt32 IMC_CmdListSetEventTrigger(Int16 cardIndex, Int16 index, Int16 eventIndex, Int32 userID);
  3878. #endregion
  3879. }
  3880. }