| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using TeamAAS;
- using TeamAAS.Global.Devices;
- using TeamAAS.Motion.Models;
- using System.Runtime.InteropServices;
- namespace TeamAAS.Motion.Motions
- {
- /// <summary>
- /// 汇川 IMC60G 运动控制卡(对接 IMC_Library_x64.dll)。
- /// 流程层用索引 API;调试层用 <see cref="InovanceAxis"/>。
- /// </summary>
- public class InovanceMotionCard : IMotionCard, IMasterFollowHost, IMotionSafetyHost, IMotionIoHost
- {
- private const short StopSmooth = 0;
- private const short StopAbrupt = 1;
- private const uint EcatMasterOp = 6;
- private readonly MotionDeviceConfig _cfg;
- private readonly object _sync = new object();
- private readonly MasterFollowSession _follow = new MasterFollowSession();
- private readonly MotionSafetyGuard _guard;
- private short _card;
- private int _axisCount;
- private IAxis[] _axes = Array.Empty<IAxis>();
- private Dictionary<int, IAxis> _axisMap = new Dictionary<int, IAxis>();
- private Dictionary<int, InovanceAxis> _hwAxes = new Dictionary<int, InovanceAxis>();
- private Dictionary<int, MotionAxisConfig> _axisCfgs = new Dictionary<int, MotionAxisConfig>();
- private bool _crdReady;
- private int _crdDim;
- private int _ecatDiCnt;
- private int _ecatDoCnt;
- public string Name => _cfg.Name;
- public bool IsConnected { get; private set; }
- public int AxisCount => _axisCount;
- public bool IsEstopActive => _guard.EstopActive;
- public bool IsStopActive => _guard.StopActive;
- internal MotionDeviceConfig DeviceConfig => _cfg;
- public event EventHandler<MotionConnectionStateChangedEventArgs> ConnectionStateChanged;
- public event EventHandler<MotionErrorEventArgs> ErrorOccurred;
- public event EventHandler SafetyChanged;
- public InovanceMotionCard(MotionDeviceConfig cfg)
- {
- _cfg = cfg ?? new MotionDeviceConfig();
- _card = (short)_cfg.BoardIndex;
- _axisCount = Math.Max(1, _cfg.AxisCount);
- RebuildAxes();
- _guard = new MotionSafetyGuard(
- () => _cfg,
- ReadDI,
- OnSafetyEstopRise,
- OnSafetyEstopHold,
- OnSafetyStopRise);
- _guard.Changed += (_, __) =>
- {
- try { SafetyChanged?.Invoke(this, EventArgs.Empty); }
- catch { }
- };
- }
- public bool AllowEnable(out string reason) => _guard.AllowEnable(out reason);
- public bool AllowMotion(out string reason) => _guard.AllowMotion(out reason);
- private bool RejectEnable()
- {
- if (_guard.AllowEnable(out var reason)) return false;
- RaiseError(reason);
- return true;
- }
- private bool RejectMotion()
- {
- if (_guard.AllowMotion(out var reason)) return false;
- RaiseError(reason);
- return true;
- }
- private void OnSafetyEstopRise()
- {
- if (!IsConnected) return;
- EmergencyStop();
- }
- private void OnSafetyEstopHold()
- {
- if (!IsConnected) return;
- lock (_sync)
- {
- if (!IsConnected) return;
- foreach (var hw in _hwAxes.Values)
- {
- try { Imc60.IMC_ServoOff(_card, (short)hw.AxisNo, 1); }
- catch { }
- }
- }
- }
- private void OnSafetyStopRise()
- {
- if (!IsConnected) return;
- Stop(-1);
- }
- public bool Open()
- {
- lock (_sync)
- {
- if (IsConnected) return true;
- try
- {
- uint ret = Imc60.IMC_OpenCard(_card);
- if (!Ok(ret, "开卡")) return false;
- ParseConfigPaths(out var deviceCfg, out var systemCfg);
- if (!string.IsNullOrEmpty(deviceCfg))
- {
- if (!File.Exists(deviceCfg))
- {
- RaiseError("设备配置不存在: " + deviceCfg);
- return FailOpen();
- }
- if (!Ok(Imc60.IMC_DownLoadDeviceConfig(_card, deviceCfg), "下载设备配置"))
- return FailOpen();
- }
- short masterCfg = 0;
- Imc60.IMC_GetMasterCfgXml(_card, ref masterCfg);
- if ((masterCfg & 0x1) != 0)
- {
- uint sts = 0;
- Imc60.IMC_GetEcatMasterSts(_card, ref sts);
- if (sts != EcatMasterOp)
- {
- if (!Ok(Imc60.IMC_ScanCardEcat(_card), "EtherCAT0 扫描"))
- return FailOpen();
- }
- if (!string.IsNullOrEmpty(systemCfg))
- {
- if (!File.Exists(systemCfg))
- {
- RaiseError("系统配置不存在: " + systemCfg);
- return FailOpen();
- }
- if (!Ok(Imc60.IMC_DownLoadSystemConfig(_card, systemCfg), "下载系统配置"))
- return FailOpen();
- }
- }
- if ((masterCfg & 0x2) != 0)
- {
- uint sts = 0;
- Imc60.IMC_H_GetEcatMasterSts(_card, ref sts);
- if (sts != EcatMasterOp)
- {
- if (!Ok(Imc60.IMC_H_ScanCardEcat(_card), "EtherCAT1 扫描"))
- return FailOpen();
- }
- }
- bool userAxes = _cfg.Axes != null && _cfg.Axes.Count > 0;
- var info = new Imc60.TMasterInfo();
- bool haveInfo = Imc60.IMC_GetEcatMasterInfo(_card, ref info) == Imc60.EXE_SUCCESS;
- if (haveInfo)
- {
- _ecatDiCnt = Math.Max(0, (int)info.diCnt);
- _ecatDoCnt = Math.Max(0, (int)info.doCnt);
- }
- if (!userAxes)
- {
- if (haveInfo && info.axisCnt > 0)
- _axisCount = info.axisCnt;
- else
- _axisCount = Math.Max(1, _cfg.AxisCount);
- }
- RebuildAxes();
- ApplyAxisBonds();
- ApplySafetyLimits();
- foreach (var hw in _hwAxes.Values)
- {
- Imc60.IMC_SetAxMvPara(_card, (short)hw.AxisNo, hw.Velocity, hw.Acceleration, hw.Deceleration);
- Imc60.IMC_SetAxStopDec(_card, (short)hw.AxisNo, hw.Deceleration, hw.Deceleration * 4);
- }
- IsConnected = true;
- }
- catch (DllNotFoundException)
- {
- RaiseError("未找到 IMC_Library_x64.dll,请放到程序运行目录");
- return false;
- }
- catch (Exception ex)
- {
- RaiseError("开卡异常: " + ex.Message);
- return FailOpen();
- }
- }
- _guard.Start();
- ConnectionStateChanged?.Invoke(this, new MotionConnectionStateChangedEventArgs(true));
- return true;
- }
- public void Close()
- {
- _guard.Stop();
- lock (_sync)
- {
- if (!IsConnected) return;
- try
- {
- foreach (var hw in _hwAxes.Values)
- Imc60.IMC_ServoOff(_card, (short)hw.AxisNo, 1);
- if (_crdReady)
- {
- Imc60.IMC_CrdStop(_card, 0, StopAbrupt);
- Imc60.IMC_CrdDeleteMtSys(_card, 0);
- _crdReady = false;
- }
- Imc60.IMC_DelEcatComm(_card);
- Imc60.IMC_CloseCard(_card);
- }
- catch { }
- _follow.Clear();
- IsConnected = false;
- }
- ConnectionStateChanged?.Invoke(this, new MotionConnectionStateChangedEventArgs(false));
- }
- void IMasterFollowHost.BeginSoloMasterFollow(int masterAxisNo, IEnumerable<IAxis> slaves)
- => _follow.Begin(masterAxisNo, slaves);
- void IMasterFollowHost.ReleaseMasterFollow() => _follow.Release();
- IDisposable IMasterFollowHost.SuspendFollowRelease() => _follow.Suspend();
- private void ReleaseFollowIfIndependent(int axis)
- {
- if (_follow.Suspended || _follow.IsReleasing) return;
- if (axis >= 0 && TryCombined(axis, out _)) return;
- _follow.Release();
- }
- public bool SetEnable(int axis, bool enable)
- {
- if (enable && RejectEnable()) return false;
- if (!IsConnected) return false;
- lock (_sync)
- {
- if (axis < 0)
- {
- bool ok = true;
- foreach (var hw in _hwAxes.Values)
- {
- if (enable)
- Imc60.IMC_ClrAxSts(_card, (short)hw.AxisNo, 1);
- uint r = enable
- ? Imc60.IMC_ServoOn(_card, (short)hw.AxisNo, 1)
- : Imc60.IMC_ServoOff(_card, (short)hw.AxisNo, 1);
- if (!Ok(r, enable ? $"轴{hw.AxisNo}使能" : $"轴{hw.AxisNo}下使能"))
- ok = false;
- }
- return ok;
- }
- if (TryCombined(axis, out var combined))
- {
- if (enable) combined.Enable(); else combined.Disable();
- return true;
- }
- if (!IsHardware(axis)) return false;
- if (enable)
- Imc60.IMC_ClrAxSts(_card, (short)axis, 1);
- uint ret = enable
- ? Imc60.IMC_ServoOn(_card, (short)axis, 1)
- : Imc60.IMC_ServoOff(_card, (short)axis, 1);
- return Ok(ret, enable ? $"轴{axis}使能" : $"轴{axis}下使能");
- }
- }
- public bool Home(int axis, int mode = 0)
- {
- if (RejectMotion()) return false;
- if (!IsConnected || !IsValidAxis(axis)) return false;
- lock (_sync)
- {
- if (TryCombined(axis, out var combined))
- {
- combined.Home((HomeMode)mode);
- return true;
- }
- ReleaseFollowIfIndependent(axis);
- if (!_hwAxes.TryGetValue(axis, out var a)) return false;
- var para = new Imc60.THomingPara
- {
- homeMethod = MapHomeMethod(mode),
- highVel = ToUInt(Math.Abs(a.Velocity)),
- lowVel = ToUInt(Math.Abs(a.Velocity) * 0.2),
- acc = ToUInt(Math.Max(1, a.Acceleration)),
- offset = 0
- };
- if (!Ok(Imc60.IMC_StartHoming(_card, (short)axis, ref para), $"轴{axis}回零"))
- return false;
- a.MarkHoming();
- return true;
- }
- }
- public bool IsHomed(int axis)
- {
- if (!IsValidAxis(axis)) return false;
- RefreshHomeFlag(axis);
- return _axisMap[axis].IsHomed;
- }
- public bool MoveAbsolute(int axis, double position, double velocity)
- {
- if (RejectMotion()) return false;
- if (!IsConnected || !IsValidAxis(axis)) return false;
- lock (_sync)
- {
- if (TryCombined(axis, out var combined))
- {
- combined.Velocity = velocity;
- combined.MoveTo(position);
- return true;
- }
- ReleaseFollowIfIndependent(axis);
- position = ClampAxisPosition(axis, position);
- velocity = Math.Abs(ClampAxisVelocity(axis, velocity));
- if (!ApplyMovePara(axis, velocity)) return false;
- return Ok(Imc60.IMC_StartPtpMove(_card, (short)axis, position, 0), $"轴{axis}绝对定位");
- }
- }
- public bool MoveRelative(int axis, double distance, double velocity)
- {
- if (RejectMotion()) return false;
- if (!IsConnected || !IsValidAxis(axis)) return false;
- lock (_sync)
- {
- if (TryCombined(axis, out var combined))
- {
- combined.Velocity = velocity;
- combined.MoveBy(distance);
- return true;
- }
- ReleaseFollowIfIndependent(axis);
- double current = ReadPrfPos(axis);
- double target = ClampAxisPosition(axis, current + distance);
- velocity = Math.Abs(ClampAxisVelocity(axis, velocity));
- if (!ApplyMovePara(axis, velocity)) return false;
- return Ok(Imc60.IMC_StartPtpMove(_card, (short)axis, target, 0), $"轴{axis}相对定位");
- }
- }
- public bool JogStart(int axis, int direction, double velocity)
- {
- if (RejectMotion()) return false;
- if (!IsConnected || !IsValidAxis(axis)) return false;
- lock (_sync)
- {
- double vel = (direction >= 0 ? 1 : -1) * Math.Abs(velocity);
- if (TryCombined(axis, out var combined))
- {
- combined.Jog(vel);
- return true;
- }
- ReleaseFollowIfIndependent(axis);
- vel = ClampAxisJog(axis, vel, ReadPrfPos(axis));
- if (Math.Abs(vel) < 1e-9)
- return Stop(axis);
- if (!ApplyMovePara(axis, Math.Abs(vel))) return false;
- if (_hwAxes.TryGetValue(axis, out var hw))
- hw.MarkJogging(true);
- return Ok(Imc60.IMC_StartJogMove(_card, (short)axis, vel), $"轴{axis}点动");
- }
- }
- public bool JogStop(int axis) => Stop(axis);
- public bool Stop(int axis = -1)
- {
- if (!IsConnected) return false;
- lock (_sync)
- {
- if (axis < 0)
- {
- _follow.Release();
- bool ok = true;
- foreach (var hw in _hwAxes.Values)
- {
- hw.AbortHome();
- if (!Ok(Imc60.IMC_StopMove(_card, (short)hw.AxisNo, StopSmooth), $"轴{hw.AxisNo}停止"))
- ok = false;
- hw.MarkJogging(false);
- }
- return ok;
- }
- if (TryCombined(axis, out var combined))
- {
- combined.Stop();
- return true;
- }
- ReleaseFollowIfIndependent(axis);
- if (!IsHardware(axis)) return false;
- if (_hwAxes.TryGetValue(axis, out var a))
- {
- a.AbortHome();
- a.MarkJogging(false);
- }
- return Ok(Imc60.IMC_StopMove(_card, (short)axis, StopSmooth), $"轴{axis}停止");
- }
- }
- public AxisStatus GetAxisStatus(int axis)
- {
- if (!IsValidAxis(axis)) return null;
- var logical = _axisMap[axis];
- if (logical is CombinedMotionAxis)
- {
- return new AxisStatus
- {
- Index = axis,
- Name = logical.Name,
- Position = logical.ActualPosition,
- Velocity = logical.ActualVelocity,
- IsMoving = logical.IsMoving,
- IsHomed = logical.IsHomed,
- IsEnabled = logical.IsEnabled
- };
- }
- RefreshHomeFlag(axis);
- if (logical is InovanceAxis inv)
- inv.SyncState();
- int sts = ReadSts(axis);
- return new AxisStatus
- {
- Index = axis,
- Name = logical.Name,
- Position = ReadEncPos(axis),
- Velocity = ReadEncVel(axis),
- IsMoving = logical.IsMoving,
- IsHomed = logical.IsHomed,
- IsEnabled = logical.IsEnabled,
- PositiveLimit = Has(sts, Imc60.AX_POSLMT_BIT) || Has(sts, Imc60.AX_SOFT_POSLMT_BIT),
- NegativeLimit = Has(sts, Imc60.AX_NEGLMT_BIT) || Has(sts, Imc60.AX_SOFT_NEGLMT_BIT),
- Alarm = Has(sts, Imc60.AX_ALARM_BIT) || Has(sts, Imc60.AX_UNLINK_BIT) || Has(sts, Imc60.AX_ERRPOS_BIT)
- };
- }
- public List<AxisStatus> GetAllAxisStatus()
- {
- var list = new List<AxisStatus>(_axes.Length);
- foreach (var a in _axes)
- list.Add(GetAxisStatus(a.AxisNo));
- return list;
- }
- public IAxis GetAxis(int axisNo)
- {
- if (!IsValidAxis(axisNo))
- throw new ArgumentOutOfRangeException(nameof(axisNo), "轴号超出范围");
- return _axisMap[axisNo];
- }
- public IList<IAxis> GetAxes() => _axes.ToList();
- public bool MoveLinear(double[] targetPositions, double velocity)
- {
- if (RejectMotion()) return false;
- if (!IsConnected || targetPositions == null || targetPositions.Length < 2) return false;
- lock (_sync)
- {
- _follow.Release();
- int dim = targetPositions.Length >= 3 ? 3 : 2;
- velocity = ClampInterpVelocity(velocity, dim);
- if (!EnsureCrd(dim)) return false;
- if (!PrepareCrd(velocity)) return false;
- if (dim >= 3)
- {
- var ends = new[]
- {
- ClampAxisPosition(0, targetPositions[0]),
- ClampAxisPosition(1, targetPositions[1]),
- ClampAxisPosition(2, targetPositions[2])
- };
- if (!Ok(Imc60.IMC_CrdLineXYZ(_card, 0, ends), "插补直线XYZ")) return false;
- }
- else
- {
- var ends = new[]
- {
- ClampAxisPosition(0, targetPositions[0]),
- ClampAxisPosition(1, targetPositions[1])
- };
- if (!Ok(Imc60.IMC_CrdLineXY(_card, 0, ends), "插补直线XY")) return false;
- }
- return Ok(Imc60.IMC_CrdStart(_card, 0), "启动插补");
- }
- }
- public bool MoveArc(double[] centerPoint, double[] targetPositions, double velocity)
- {
- if (RejectMotion()) return false;
- if (!IsConnected || centerPoint == null || targetPositions == null) return false;
- if (centerPoint.Length < 2 || targetPositions.Length < 2) return false;
- lock (_sync)
- {
- _follow.Release();
- velocity = ClampInterpVelocity(velocity, 2);
- if (!EnsureCrd(2)) return false;
- if (!PrepareCrd(velocity)) return false;
- var center = new[] { centerPoint[0], centerPoint[1] };
- var ends = new[]
- {
- ClampAxisPosition(0, targetPositions[0]),
- ClampAxisPosition(1, targetPositions[1])
- };
- if (!Ok(Imc60.IMC_CrdArcCenterXYPlane(_card, 0, center, ends, 0), "插补圆弧")) return false;
- return Ok(Imc60.IMC_CrdStart(_card, 0), "启动插补");
- }
- }
- public bool EmergencyStop()
- {
- if (!IsConnected) return false;
- lock (_sync)
- {
- _follow.Clear();
- Imc60.IMC_CrdStop(_card, 0, StopAbrupt);
- bool ok = true;
- foreach (var hw in _hwAxes.Values)
- {
- hw.AbortHome();
- if (!Ok(Imc60.IMC_StopMove(_card, (short)hw.AxisNo, StopAbrupt), $"轴{hw.AxisNo}急停"))
- ok = false;
- hw.MarkJogging(false);
- }
- return ok;
- }
- }
- public bool CanSimulateDi => false;
- public int GetDiCount(MotionIoBank bank)
- {
- if (bank == MotionIoBank.EtherCat)
- return _ecatDiCnt > 0 ? _ecatDiCnt : Math.Max(0, _cfg.InputCount);
- int n = _cfg.LocalInputCount > 0 ? _cfg.LocalInputCount : 16;
- return n;
- }
- public int GetDoCount(MotionIoBank bank)
- {
- if (bank == MotionIoBank.EtherCat)
- return _ecatDoCnt > 0 ? _ecatDoCnt : Math.Max(0, _cfg.OutputCount);
- int n = _cfg.LocalOutputCount > 0 ? _cfg.LocalOutputCount : 16;
- return n;
- }
- public bool ReadDI(int portIndex) => ReadDI(MotionIoBank.Local, portIndex);
- public bool ReadDI(MotionIoBank bank, int index)
- {
- if (!IsConnected || index < 0) return false;
- short v = 0;
- uint ret = bank == MotionIoBank.EtherCat
- ? Imc60.IMC_GetEcatDiBit(_card, (short)index, ref v)
- : Imc60.IMC_GetLocalDiBit(_card, (short)index, ref v);
- return ret == Imc60.EXE_SUCCESS && v != 0;
- }
- public bool ReadDO(MotionIoBank bank, int index)
- {
- if (!IsConnected || index < 0) return false;
- short v = 0;
- uint ret = bank == MotionIoBank.EtherCat
- ? Imc60.IMC_GetEcatDoBit(_card, (short)index, ref v)
- : Imc60.IMC_GetLocalDoBit(_card, (short)index, ref v);
- return ret == Imc60.EXE_SUCCESS && v != 0;
- }
- public bool WriteDO(int portIndex, bool value) => WriteDO(MotionIoBank.Local, portIndex, value);
- public bool WriteDO(MotionIoBank bank, int index, bool value)
- {
- if (!IsConnected || index < 0) return false;
- short bit = (short)(value ? 1 : 0);
- uint ret = bank == MotionIoBank.EtherCat
- ? Imc60.IMC_SetEcatDoBit(_card, (short)index, bit)
- : Imc60.IMC_SetLocalDoBit(_card, (short)index, bit);
- return Ok(ret, bank == MotionIoBank.EtherCat ? $"写 EtherCAT DO{index}" : $"写本地 DO{index}");
- }
- public bool WriteDI(MotionIoBank bank, int index, bool value) => false;
- internal bool ApplyMovePara(int axis, double velocity)
- {
- if (!_hwAxes.TryGetValue(axis, out var a)) return false;
- if (velocity > 0) a.Velocity = velocity;
- return Ok(Imc60.IMC_SetAxMvPara(_card, (short)axis, a.Velocity, a.Acceleration, a.Deceleration), $"轴{axis}运动参数");
- }
- internal bool HardwareSetEnable(int axis, bool enable)
- {
- if (enable && RejectEnable()) return false;
- if (!IsConnected || !_hwAxes.ContainsKey(axis)) return false;
- lock (_sync)
- {
- if (enable)
- Imc60.IMC_ClrAxSts(_card, (short)axis, 1);
- uint ret = enable
- ? Imc60.IMC_ServoOn(_card, (short)axis, 1)
- : Imc60.IMC_ServoOff(_card, (short)axis, 1);
- return Ok(ret, enable ? $"轴{axis}使能" : $"轴{axis}下使能");
- }
- }
- internal bool HardwareMoveAbsolute(int axis, double position, double velocity)
- {
- if (RejectMotion()) return false;
- if (!IsConnected || !_hwAxes.ContainsKey(axis)) return false;
- lock (_sync)
- {
- position = ClampAxisPosition(axis, position);
- velocity = Math.Abs(ClampAxisVelocity(axis, velocity));
- if (!ApplyMovePara(axis, velocity)) return false;
- return Ok(Imc60.IMC_StartPtpMove(_card, (short)axis, position, 0), $"轴{axis}绝对定位");
- }
- }
- internal bool HardwareMoveRelative(int axis, double distance, double velocity)
- {
- if (RejectMotion()) return false;
- if (!IsConnected || !_hwAxes.ContainsKey(axis)) return false;
- lock (_sync)
- {
- double target = ClampAxisPosition(axis, ReadPrfPos(axis) + distance);
- velocity = Math.Abs(ClampAxisVelocity(axis, velocity));
- if (!ApplyMovePara(axis, velocity)) return false;
- return Ok(Imc60.IMC_StartPtpMove(_card, (short)axis, target, 0), $"轴{axis}相对定位");
- }
- }
- internal bool HardwareJog(int axis, double velocity)
- {
- if (RejectMotion()) return false;
- if (!IsConnected || !_hwAxes.TryGetValue(axis, out var hw)) return false;
- lock (_sync)
- {
- velocity = ClampAxisJog(axis, velocity, ReadPrfPos(axis));
- if (Math.Abs(velocity) < 1e-9)
- {
- hw.MarkJogging(false);
- return Ok(Imc60.IMC_StopMove(_card, (short)axis, StopSmooth), $"轴{axis}停止");
- }
- if (!ApplyMovePara(axis, Math.Abs(velocity))) return false;
- hw.MarkJogging(true);
- return Ok(Imc60.IMC_StartJogMove(_card, (short)axis, velocity), $"轴{axis}点动");
- }
- }
- internal bool HardwareStop(int axis)
- {
- if (!IsConnected || !_hwAxes.TryGetValue(axis, out var hw)) return false;
- lock (_sync)
- {
- hw.AbortHome();
- hw.MarkJogging(false);
- return Ok(Imc60.IMC_StopMove(_card, (short)axis, StopSmooth), $"轴{axis}停止");
- }
- }
- internal bool HardwareHome(int axis, int mode)
- {
- if (RejectMotion()) return false;
- if (!IsConnected || !_hwAxes.TryGetValue(axis, out var a)) return false;
- lock (_sync)
- {
- var para = new Imc60.THomingPara
- {
- homeMethod = MapHomeMethod(mode),
- highVel = ToUInt(Math.Abs(a.Velocity)),
- lowVel = ToUInt(Math.Abs(a.Velocity) * 0.2),
- acc = ToUInt(Math.Max(1, a.Acceleration)),
- offset = 0
- };
- if (!Ok(Imc60.IMC_StartHoming(_card, (short)axis, ref para), $"轴{axis}回零"))
- return false;
- a.MarkHoming();
- return true;
- }
- }
- internal bool SetCurrentPosition(int axis, double position)
- => Ok(Imc60.IMC_SetAxCurPos(_card, (short)axis, position), $"轴{axis}位置清零");
- internal int ReadSts(int axis)
- {
- var arr = new int[1];
- return Imc60.IMC_GetAxSts(_card, (short)axis, arr, 1) == Imc60.EXE_SUCCESS ? arr[0] : 0;
- }
- internal double ReadEncPos(int axis)
- {
- var arr = new double[1];
- return Imc60.IMC_GetAxEncPos(_card, (short)axis, arr, 1) == Imc60.EXE_SUCCESS ? arr[0] : 0;
- }
- internal double ReadPrfPos(int axis)
- {
- var arr = new double[1];
- return Imc60.IMC_GetAxPrfPos(_card, (short)axis, arr, 1) == Imc60.EXE_SUCCESS ? arr[0] : 0;
- }
- internal double ReadEncVel(int axis)
- {
- var arr = new double[1];
- return Imc60.IMC_GetAxEncVel(_card, (short)axis, arr, 1) == Imc60.EXE_SUCCESS ? arr[0] : 0;
- }
- internal short ReadHomeStatus(int axis)
- {
- short sts = 0;
- Imc60.IMC_GetHomingStatus(_card, (short)axis, ref sts);
- return sts;
- }
- internal void FinishHome(int axis)
- {
- Imc60.IMC_FinishHoming(_card, (short)axis);
- }
- internal void RefreshHomeFlag(int axis)
- {
- if (!IsConnected) return;
- if (_hwAxes.TryGetValue(axis, out var hw))
- hw.PollHome(this);
- }
- private bool PrepareCrd(double velocity)
- {
- double acc = Math.Max(100, Math.Abs(velocity) * 5);
- if (!Ok(Imc60.IMC_CrdClrData(_card, 0), "清空插补缓冲")) return false;
- if (!Ok(Imc60.IMC_CrdSetIncMode(_card, 0, 0), "插补绝对模式")) return false;
- if (!Ok(Imc60.IMC_CrdSetTrajVel(_card, 0, velocity), "插补速度")) return false;
- return Ok(Imc60.IMC_CrdSetTrajAccAndDec(_card, 0, acc, acc), "插补加减速");
- }
- private bool EnsureCrd(int dim)
- {
- dim = Math.Max(2, Math.Min(3, dim));
- if (_hwAxes.Count < dim) return false;
- if (_crdReady && _crdDim == dim) return true;
- if (_crdReady)
- {
- Imc60.IMC_CrdStop(_card, 0, StopAbrupt);
- Imc60.IMC_CrdDeleteMtSys(_card, 0);
- _crdReady = false;
- }
- var mask = new short[3];
- mask[0] = 0;
- mask[1] = 1;
- mask[2] = (short)(dim > 2 ? 2 : -1);
- var hw = _hwAxes.Values.FirstOrDefault();
- double eStopDec = Math.Max(1000, hw != null ? hw.Deceleration * 4 : 1000);
- if (!Ok(Imc60.IMC_CrdSetMtSys(_card, 0, mask, 100, eStopDec), "建立插补坐标系"))
- return false;
- _crdDim = dim;
- _crdReady = true;
- return true;
- }
- public void ReloadFromConfig()
- {
- lock (_sync)
- {
- RebuildAxes();
- if (IsConnected)
- {
- ApplyAxisBonds();
- ApplySafetyLimits();
- }
- }
- }
- private void ApplyAxisBonds()
- {
- var cfgs = MotionAxisCatalog.GetEffective(_cfg);
- foreach (var cfg in cfgs)
- {
- short axType;
- short ch = (short)Math.Max(0, cfg.OutputChannel);
- switch (cfg.Kind)
- {
- case MotionAxisKind.Physical:
- axType = 1;
- break;
- default:
- axType = -1;
- ch = 0;
- break;
- }
- Ok(Imc60.IMC_SetAxBondCfg(_card, (short)cfg.AxisNo, axType, ch),
- $"轴{cfg.AxisNo}绑定({cfg.KindText})");
- }
- }
- internal MotionAxisConfig GetAxisConfig(int axisNo)
- {
- if (_axisCfgs.TryGetValue(axisNo, out var cfg) && cfg != null)
- return cfg;
- return new MotionAxisConfig { AxisNo = axisNo };
- }
- internal double ClampAxisPosition(int axis, double position)
- => GetAxisConfig(axis).ClampPosition(position);
- internal double ClampAxisVelocity(int axis, double velocity)
- => GetAxisConfig(axis).ClampVelocity(velocity);
- internal double ClampAxisJog(int axis, double velocity, double currentPosition)
- => GetAxisConfig(axis).ClampJog(velocity, currentPosition);
- private double ClampInterpVelocity(double velocity, int dim)
- {
- velocity = Math.Abs(velocity);
- int n = Math.Max(1, dim);
- for (int i = 0; i < n; i++)
- velocity = Math.Abs(ClampAxisVelocity(i, velocity));
- return velocity;
- }
- private void ApplySafetyLimits()
- {
- foreach (var cfg in MotionAxisCatalog.GetEffective(_cfg))
- {
- short en = (short)(cfg.SoftLimitEnabled ? 1 : 0);
- if (cfg.SoftLimitEnabled)
- {
- int pos = (int)Math.Round(Math.Max(cfg.SoftLimitNeg, cfg.SoftLimitPos));
- int neg = (int)Math.Round(Math.Min(cfg.SoftLimitNeg, cfg.SoftLimitPos));
- Ok(Imc60.IMC_SetAxSoftLimit(_card, (short)cfg.AxisNo, pos, neg),
- $"轴{cfg.AxisNo}软限位");
- }
- Ok(Imc60.IMC_SetAxSoftLmtsCheck(_card, (short)cfg.AxisNo, en),
- $"轴{cfg.AxisNo}软限位检查");
- if (cfg.MaxVelocity <= 0) continue;
- var para = new Imc60.TMtPara
- {
- bgVel = 0,
- maxVel = cfg.MaxVelocity,
- maxAcc = Math.Max(1, cfg.Acceleration),
- maxDec = Math.Max(1, cfg.Deceleration),
- maxJerk = Math.Max(1, cfg.Jerk),
- stopDec = Math.Max(1, cfg.Deceleration),
- eStopDec = Math.Max(1, cfg.Deceleration * 4)
- };
- Ok(Imc60.IMC_SetAxMaxMtPara(_card, (short)cfg.AxisNo, ref para),
- $"轴{cfg.AxisNo}最高速度");
- }
- }
- private void RebuildAxes()
- {
- _follow.Clear();
- var oldHw = _hwAxes;
- var cfgs = MotionAxisCatalog.GetEffective(_cfg);
- _axisCfgs = new Dictionary<int, MotionAxisConfig>();
- _hwAxes = new Dictionary<int, InovanceAxis>();
- _axisMap = new Dictionary<int, IAxis>();
- var view = new List<IAxis>(cfgs.Count);
- foreach (var cfg in cfgs)
- {
- var axis = new InovanceAxis(this, cfg.AxisNo)
- {
- Name = string.IsNullOrWhiteSpace(cfg.Name) ? $"Axis-{cfg.AxisNo}" : cfg.Name,
- Velocity = cfg.Velocity,
- Acceleration = cfg.Acceleration,
- Deceleration = cfg.Deceleration,
- Jerk = cfg.Jerk
- };
- if (oldHw != null && oldHw.TryGetValue(cfg.AxisNo, out var prev))
- {
- axis.Name = string.IsNullOrWhiteSpace(cfg.Name) ? prev.Name : cfg.Name;
- axis.Velocity = cfg.Velocity > 0 ? cfg.Velocity : prev.Velocity;
- axis.Acceleration = cfg.Acceleration > 0 ? cfg.Acceleration : prev.Acceleration;
- axis.Deceleration = cfg.Deceleration > 0 ? cfg.Deceleration : prev.Deceleration;
- axis.Jerk = cfg.Jerk > 0 ? cfg.Jerk : prev.Jerk;
- }
- _hwAxes[cfg.AxisNo] = axis;
- _axisMap[cfg.AxisNo] = axis;
- _axisCfgs[cfg.AxisNo] = cfg;
- }
- foreach (var cfg in cfgs)
- {
- if (cfg.IsGrouped && _hwAxes.TryGetValue(cfg.AxisNo, out var master))
- {
- var combined = new CombinedMotionAxis(this, cfg, master, no =>
- _hwAxes.TryGetValue(no, out var a) ? a : null);
- _axisMap[cfg.AxisNo] = combined;
- view.Add(combined);
- }
- else if (_axisMap.TryGetValue(cfg.AxisNo, out var hw))
- {
- view.Add(hw);
- }
- }
- _axes = view.ToArray();
- _axisCount = _axes.Length;
- }
- private bool TryCombined(int axis, out CombinedMotionAxis combined)
- {
- combined = null;
- if (_axisMap.TryGetValue(axis, out var a) && a is CombinedMotionAxis c)
- {
- combined = c;
- return true;
- }
- return false;
- }
- private bool IsHardware(int axis) => _hwAxes.ContainsKey(axis);
- private void ParseConfigPaths(out string deviceCfg, out string systemCfg)
- {
- deviceCfg = "";
- systemCfg = "";
- var raw = _cfg.ConnectionString?.Trim();
- if (string.IsNullOrEmpty(raw)) return;
- var parts = raw.Split(new[] { '|', ';' }, StringSplitOptions.RemoveEmptyEntries);
- if (parts.Length > 0) deviceCfg = ResolvePath(parts[0].Trim());
- if (parts.Length > 1) systemCfg = ResolvePath(parts[1].Trim());
- }
- private static string ResolvePath(string path)
- {
- if (string.IsNullOrWhiteSpace(path)) return "";
- path = path.Trim().Trim('"');
- if (File.Exists(path)) return Path.GetFullPath(path);
- var baseDir = AppDomain.CurrentDomain.BaseDirectory ?? "";
- var combined = Path.Combine(baseDir, path);
- if (File.Exists(combined)) return Path.GetFullPath(combined);
- var inConfig = Path.Combine(baseDir, "Config", path);
- if (File.Exists(inConfig)) return Path.GetFullPath(inConfig);
- return Path.IsPathRooted(path) ? path : Path.GetFullPath(combined);
- }
- private static short MapHomeMethod(int mode)
- {
- if (mode > 3) return (short)mode;
- switch ((HomeMode)mode)
- {
- case HomeMode.LimitSwitch: return (short)Imc60.HOME_NLIMT;
- case HomeMode.HomeSwitch: return (short)Imc60.HOME_NHOME_FEDGE;
- case HomeMode.ZPhase: return (short)Imc60.HOME_NEGZINDEX;
- default: return (short)Imc60.HOME_NLIMT_ZINDEX;
- }
- }
- private static uint ToUInt(double v) => (uint)Math.Max(1, Math.Min(uint.MaxValue, v));
- private static bool Has(int sts, uint bit) => (sts & (int)bit) != 0;
- private bool IsValidAxis(int axis) => _axisMap.ContainsKey(axis);
- private bool Ok(uint ret, string what)
- {
- if (ret == Imc60.EXE_SUCCESS) return true;
- RaiseError($"{what}失败 (0x{ret:X8})");
- return false;
- }
- private bool FailOpen()
- {
- try { Imc60.IMC_DelEcatComm(_card); } catch { }
- try { Imc60.IMC_CloseCard(_card); } catch { }
- IsConnected = false;
- return false;
- }
- private void RaiseError(string message)
- {
- try { AppLogger.Error(message, null, nameof(InovanceMotionCard)); } catch { }
- ErrorOccurred?.Invoke(this, new MotionErrorEventArgs(message));
- }
- }
- /// <summary>汇川卡单轴门面:实时读 SDK 状态,指令转发到卡。</summary>
- public class InovanceAxis : IAxis
- {
- private readonly InovanceMotionCard _card;
- private bool _homed;
- private bool _homing;
- private bool _jogging;
- private AxisState _lastState = AxisState.Off;
- public int AxisNo { get; }
- public string Name { get; set; }
- public double Velocity { get; set; } = 100;
- public double Acceleration { get; set; } = 500;
- public double Deceleration { get; set; } = 500;
- public double Jerk { get; set; } = 1000;
- public AxisState State
- {
- get
- {
- if (!_card.IsConnected) return AxisState.Off;
- int sts = _card.ReadSts(AxisNo);
- if ((sts & (int)Imc60.AX_ALARM_BIT) != 0 || (sts & (int)Imc60.AX_UNLINK_BIT) != 0)
- return AxisState.Error;
- if ((sts & (int)Imc60.AX_SVON_BIT) == 0) return AxisState.Off;
- if (_homing) return AxisState.Homing;
- if (_jogging) return AxisState.ContinuousMotion;
- if ((sts & (int)Imc60.AX_BUSY_BIT) != 0) return AxisState.DiscreteMotion;
- return AxisState.StandStill;
- }
- }
- public bool IsEnabled => _card.IsConnected && (_card.ReadSts(AxisNo) & (int)Imc60.AX_SVON_BIT) != 0;
- public bool IsMoving => _card.IsConnected && ((_card.ReadSts(AxisNo) & (int)Imc60.AX_BUSY_BIT) != 0 || _jogging || _homing);
- public bool IsHomed => _homed;
- public double CommandPosition => _card.IsConnected ? _card.ReadPrfPos(AxisNo) : 0;
- public double ActualPosition => _card.IsConnected ? _card.ReadEncPos(AxisNo) : 0;
- public double ActualVelocity => _card.IsConnected ? _card.ReadEncVel(AxisNo) : 0;
- public event EventHandler<AxisMotionEventArgs> MotionStarted;
- public event EventHandler<AxisMotionEventArgs> MotionCompleted;
- public event EventHandler<AxisStateChangedEventArgs> StateChanged;
- public event EventHandler<AxisErrorEventArgs> ErrorOccurred;
- public InovanceAxis(InovanceMotionCard card, int axisNo)
- {
- _card = card;
- AxisNo = axisNo;
- Name = $"Axis-{axisNo}";
- }
- internal void MarkHoming()
- {
- _homing = true;
- _homed = false;
- NotifyState();
- }
- internal void MarkJogging(bool on)
- {
- _jogging = on;
- NotifyState();
- }
- internal void AbortHome()
- {
- if (!_homing) return;
- try { _card.FinishHome(AxisNo); } catch { }
- _homing = false;
- NotifyState();
- }
- internal void PollHome(InovanceMotionCard card)
- {
- if (!_homing) return;
- short hs = card.ReadHomeStatus(AxisNo);
- if (hs == Imc60.HOME_IN_PROGRESS || hs == Imc60.HOME_INTERRUPTED_OR_NOT_START)
- return;
- if (hs == Imc60.HOME_SUCESS || hs == Imc60.HOME_ATTAINED_BUT_NOT_REACH)
- {
- card.FinishHome(AxisNo);
- _homing = false;
- _homed = true;
- NotifyState();
- MotionCompleted?.Invoke(this, new AxisMotionEventArgs(AxisNo, 0, ActualPosition));
- return;
- }
- card.FinishHome(AxisNo);
- _homing = false;
- NotifyState();
- OnError($"回零失败 (状态 {hs})");
- }
- public void Enable()
- {
- if (!_card.AllowEnable(out var reason))
- {
- ErrorOccurred?.Invoke(this, new AxisErrorEventArgs(AxisNo, reason));
- return;
- }
- if (!_card.SetEnable(AxisNo, true))
- ErrorOccurred?.Invoke(this, new AxisErrorEventArgs(AxisNo, "使能失败"));
- NotifyState();
- }
- public void Disable()
- {
- _jogging = false;
- AbortHome();
- _card.Stop(AxisNo);
- if (!_card.SetEnable(AxisNo, false))
- ErrorOccurred?.Invoke(this, new AxisErrorEventArgs(AxisNo, "下使能失败"));
- NotifyState();
- }
- public void MoveTo(double position)
- {
- if (!_card.IsConnected) { OnError("运动卡未连接"); return; }
- if (!_card.AllowMotion(out var reason)) { OnError(reason); return; }
- if (!IsEnabled) { OnError("轴未使能,无法运动"); return; }
- if (_card.MoveAbsolute(AxisNo, position, Velocity))
- {
- NotifyState();
- MotionStarted?.Invoke(this, new AxisMotionEventArgs(AxisNo, position, ActualPosition));
- }
- else
- OnError("绝对定位失败");
- }
- public void MoveBy(double distance)
- {
- if (!_card.IsConnected) { OnError("运动卡未连接"); return; }
- if (!_card.AllowMotion(out var reason)) { OnError(reason); return; }
- if (!IsEnabled) { OnError("轴未使能,无法运动"); return; }
- if (_card.MoveRelative(AxisNo, distance, Velocity))
- {
- NotifyState();
- MotionStarted?.Invoke(this, new AxisMotionEventArgs(AxisNo, ActualPosition + distance, ActualPosition));
- }
- else
- OnError("相对定位失败");
- }
- public void Jog(double velocity)
- {
- if (!_card.IsConnected) { OnError("运动卡未连接"); return; }
- if (!_card.AllowMotion(out var reason)) { OnError(reason); return; }
- if (!IsEnabled) { OnError("轴未使能,无法点动"); return; }
- int dir = velocity >= 0 ? 1 : -1;
- if (_card.JogStart(AxisNo, dir, Math.Abs(velocity)))
- {
- NotifyState();
- MotionStarted?.Invoke(this, new AxisMotionEventArgs(AxisNo, double.NaN, ActualPosition));
- }
- else
- OnError("点动失败");
- }
- public void Stop()
- {
- AbortHome();
- _jogging = false;
- _card.Stop(AxisNo);
- NotifyState();
- MotionCompleted?.Invoke(this, new AxisMotionEventArgs(AxisNo, CommandPosition, ActualPosition));
- }
- public void Home(HomeMode mode = HomeMode.Default)
- {
- if (!_card.IsConnected) { OnError("运动卡未连接"); return; }
- if (!_card.AllowMotion(out var reason)) { OnError(reason); return; }
- if (!IsEnabled) { OnError("轴未使能,无法回零"); return; }
- if (_card.Home(AxisNo, (int)mode))
- {
- NotifyState();
- MotionStarted?.Invoke(this, new AxisMotionEventArgs(AxisNo, 0, ActualPosition));
- }
- else
- OnError("回零失败");
- }
- public void SetPosition(double position)
- {
- if (!_card.SetCurrentPosition(AxisNo, position))
- OnError("设置当前位置失败");
- }
- public void SetMotionParams(MotionParams parameters)
- {
- if (parameters == null) return;
- Velocity = parameters.Velocity;
- Acceleration = parameters.Acceleration;
- Deceleration = parameters.Deceleration;
- Jerk = parameters.Jerk;
- _card.ApplyMovePara(AxisNo, Velocity);
- }
- private void OnError(string message) => ErrorOccurred?.Invoke(this, new AxisErrorEventArgs(AxisNo, message));
- internal void SyncState() => NotifyState();
- private void NotifyState()
- {
- var now = State;
- if (now == _lastState) return;
- var old = _lastState;
- _lastState = now;
- StateChanged?.Invoke(this, new AxisStateChangedEventArgs(AxisNo, old, now));
- }
- }
- public class Imc60
- {
- #region STATIC
- public const string Imc60ApiDllName = "IMC_Library_x64.dll";
- #endregion
- #region FUNCTION RETURN DEFINE
- public const uint EXE_SUCCESS = 0x00000000;
- public const uint ERR_HANDLE = 0xFFFFFFFF;
- #endregion
- /// @brief 主站信息结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct TMasterInfo
- {
- public UInt32 cycleTime; // 规划周期
- public Int16 sysHwCfg; // 系统类型: 0: Ecat+端子板, 1 Ecat, 2: 端子板
- public Int16 aliasMode; // 别名模式: 0 未开启, 1 开启
- public Int16 pdoLen; // pdo总长度
- public Int16 slaveCnt; // 从站个数
- public Int16 axisCnt; // 轴个数
- public Int16 dioModuleCnt; // dio模块个数
- public Int16 aioModuleCnt; // aio模块个数
- public Int16 regModuleCnt; // reg模块个数
- public Int16 diCnt; // di数量
- public Int16 doCnt; // do数量
- public Int16 aiCnt; // ai,AD数量
- public Int16 aoCnt; // ao, DA数量
- public Int16 regInCnt; // reg输入数量
- public Int16 regOutCnt; // reg输出数量
- public Int16 encCnt; // enc通道数量
- public Int16 align;
- };
- /// @brief 从站信息结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct TSlaveInfo
- {
- public Int16 devType; // 设备类型
- public UInt32 vendorId; // 设备ID
- public UInt32 productCode; // 产品编码
- public UInt32 revisionNo; // 版本号
- public Int16 axChn; // 从站起始通道号
- public Int16 axisCnt; // 当前从站轴数
- public Int16 actStation; // 当前从站对应的实际站号
- public UInt32 aliasNo; // 别名
- public UInt32 align;
- };
- /// @brief PdoEntry结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct TPdoEntry
- {
- public UInt16 Index; // 索引
- public Byte SubIndex; // 子索引
- public Byte DevType; // entry类型
- public Int16 BitOfs; // 位偏移
- public UInt32 BitLen; // 位长度
- };
- /// @brief 回零参数结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct THomingPara
- {
- public Int16 homeMethod; // 回原点方法
- public UInt32 highVel; // 高速搜索减速点速度 pulse/s
- public UInt32 lowVel; // 搜索原点低 pulse/s
- public UInt32 acc; // 加速度 pulse/s^2
- public Int32 offset; // 回原点后的零点偏执 pulse
- };
- /// @brief 多维位置比较数据结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct TMultiCmpData
- {
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
- public Int32[] compareData; // 比较的位置
- };
- /// @brief 规划运动限制参数结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct TMtPara
- {
- public double bgVel; // 起始速度值 unit/s
- public double maxVel; // 最大速度 unit/s
- public double maxAcc; // 最大加速度 unit/s^2
- public double maxDec; // 最大减速度 unit/s^2
- public double maxJerk; // 最大加加速度 unit/s^3
- public double stopDec; // 平滑停止减速度 unit/s^2
- public double eStopDec; // 急停减速度 unit/s^2
- };
- /// @brief 轴属性配置结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct TAxAttriPara
- {
- public Int16 arrivalBand; // 到位误差 pulse
- public UInt16 arrivalTime; // 到位保持时间 周期
- public Int32 errorLmt; // 最大跟随误差 pulse
- public Int32 softPosLimitPos; // 软正限位 pulse
- public Int32 softNegLimitPos; // 软负限位 pulse
- };
- /// @brief 轴安全检查配置结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct TAxCheckEn
- {
- public Int16 alarmEn; // 报警是否有效标志
- public Int16 softLmtEn; // 软限位是否有效标志
- public Int16 hwLmtEn; // 硬限位是否有效标志
- public Int16 errorLmtEn; // 跟随误差是否检查标志
- };
- /// @brief 插补高级参数结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct TCrdAdvParam
- {
- public Int16 userVelMode; // 用户速度规划模式: 0 系统前瞻速度规划, 1 用户设定速度规划(默认: 0)
- public Int16 transMode; // 过渡模式 0: 无过渡 1: 圆弧过渡 (默认:1)
- public Int16 noDataProtect; // 数据断流保护: 0不保护, 1保护 (默认: 1)
- public Int16 circAccChangeEn; // 圆弧变加速使能: 0不变加速, 1变加速 (默认: 0)
- public Int16 noCoplaneCircOptm; // 异面圆弧优化: 0不开启, 1开启
- public double turnCoef; // 拐弯系数:[0.01,100](默认:1.0)
- public double tol; // 插补精度:[0,1e9](默认:0 , 单位取决于设置的当量)
- };
- /// @brief 电子齿轮参数结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct TGearParam
- {
- public Int32 masterScale; // 主轴齿数: (0,intMax]
- public Int32 slaveScale; // 从轴齿数: [intMin,0) || (0,intMax]
- public Int16 masterNo; // 主轴轴号: [0,63]
- public Int16 masterType; // 主轴类型: 0 轴规划, 1 轴编码器, 10 端子板编码器, 11 EtherCAT编码器
- public Int16 dirMode; // 方向模式: 0 跟随方向不限制, 1 正向绝对位置跟随, 2 负向绝对位置跟随, 3 正向相对位置跟随, 4 负向相对位置跟随
- public Int32 masterSlopeDis; // 主轴离合区:[0,intMax], 0表示没有加速过程,直接跟随
- };
- /// @brief 表补偿参数结构体
- public struct TTableCompParam
- {
- public Int16 tableId; // 表索引:[0,0]
- public Int16 dimension; // 补偿维数:{1,2,3}
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
- public Int16[] srcAxNo; // 参考轴号:[0,63],数组有效的元素与补偿维数有关,如补偿维数=1,仅用到srcAxNo[0], 下同
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
- public Int16[] srcType; // 参考轴类型:0 轴规划, 1 轴编码器
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
- public Int32[] startPos; // 补偿起始位置:[intMin,intMax]
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
- public Int32[] count; // 补偿点个数:[2,40000] (有效的元素的乘积不得超过40000,且各不小于2)
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
- public Int32[] step; // 补偿间隔:[1,intMax]
- };
- /// @brief 采样配置参数结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct TSamplePara
- {
- public Int16 interval; // 采样时间间隔
- public Int16 trigType; // 触发采样类型: 0 立即 1 延时 2 本地di 3 ECAT di
- public Int16 delay; // 延时时间 单位:周期
- public Int16 diNo; // di输入号
- public Int16 diLevel; // di的触发输入值 0或1
- };
- /// @brief 事件配置参数结构体
- ///
- #region Event
- [StructLayout(LayoutKind.Sequential)]
- public struct TEvent
- {
- public Int16 type; //事件类型
- public Int16 index; //事件变量索引
- public UInt32 loop; //事件最大允许触发次数
- public double value; //设置比较值
- public Int16 condition; //事件条件
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskCrdStart
- {
- public Int16 crdNo;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskStartPtp
- {
- public Int16 axNo;
- public Int16 posType;
- public double tgtPos;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskStartJog
- {
- public Int16 axNo;
- public double tgtVel;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskStartGear
- {
- public Int16 axNo;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskStartPt
- {
- public Int16 sysNo;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskStartPvt
- {
- public Int16 axNum;
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
- public Int16[] axArray;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskUpdatePtpMvPara
- {
- public Int16 axNo;
- public double tgtVel;
- public double tgtAcc;
- public double tgtDec;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskUpdateJogMvPara
- {
- public Int16 axNo;
- public double tgtVel;
- public double tgtAcc;
- public double tgtDec;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskUpdatePtpTgtPos
- {
- public Int16 axNo;
- public double tgtPos;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskSetEcatDoBit
- {
- public Int16 doNo;
- public Int16 value;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskSetEcatGrpDo
- {
- public Int16 groupNo;
- public Int16 value;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskSetEcatDoBitInverse
- {
- public Int16 doIndex;
- public Int16 value;
- public Int16 inverseTime;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskSetEcatDaVal
- {
- public Int16 daIndex;
- public Int16 value;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskStopMove
- {
- public Int16 axNo;
- public Int16 stopType;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TTaskPulseDo
- {
- public Int16 taskPulseDoIndex;
- public Int16 firstLevel;
- public Int32 highLevelTime;
- public Int32 lowLevelTime;
- public Int16 pulseNum;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct UTask
- {
- public TTaskCrdStart taskCrdStart;
- public TTaskStartPtp taskStartPtp;
- public TTaskStartJog taskStartJog;
- public TTaskStartGear taskStartGear;
- public TTaskStartPt taskStartPt;
- public TTaskStartPvt taskStartPvt;
- public TTaskUpdatePtpMvPara taskUpdatePtpMvPara;
- public TTaskUpdateJogMvPara taskUpdateJogMvPara;
- public TTaskSetEcatDoBit taskSetEcatDoBit;
- public TTaskSetEcatGrpDo taskSetEcatGrpDo;
- public TTaskSetEcatDoBitInverse taskSetEcatDoBitInverse;
- public TTaskSetEcatDaVal taskSetEcatDaVal;
- public TTaskUpdatePtpTgtPos taskUpdatePtpTgtPos;
- public TTaskPulseDo taskPulseDo;
- public TTaskStopMove taskStopMove;
- };
- #endregion
- /// @defgroup EcatDef EtherCAT相关宏定义
- /// @brief EtherCAT相关宏定义
- #region
- /// @defgroup MasterSts 主站状态码
- /// @brief 板卡ECAT主站状态定义
- #region
- public const uint EC_MASTER_IDLE = (0); ///< EtherCat主站尚未初始化
- public const uint EC_MASTER_INIT = (1); ///< EtherCat主站初始化
- public const uint EC_MASTER_SCAN_SLAVE = (2); ///< EtherCat主站正在扫描从站设备
- public const uint EC_MASTER_SCAN_SLAVE_END = (3); ///< EtherCat主站扫描从站设备结束
- public const uint EC_MASTER_SCAN_MODULES = (4); ///< EtherCat主站正在扫描从站设备MODULES
- public const uint EC_MASTER_SCAN_MODULES_END = (5); ///< EtherCat主站扫描从站设备MODULES结束
- public const uint EC_MASTER_OP = (6); ///< EtherCat主站进入OP状态
- public const uint EC_MASTER_ERR = (7); ///< EtherCat主站链路状态有错误
- #endregion
- /// @defgroup SlaveSts 从站状态码
- /// @brief 板卡EtherCAT从站状态定义
- #region
- public const uint EC_SLAVE_STATE_UNKNOWN = (0x00); ///< EtherCat从站在未知状态
- public const uint EC_SLAVE_STATE_INIT = (0x01); ///< EtherCat从站在初始状态
- public const uint EC_SLAVE_STATE_PREOP = (0x02); ///< EtherCat从站在PREOP状态
- public const uint EC_SLAVE_STATE_BOOT = (0x03); ///< EtherCat从站在BOOT状态
- public const uint EC_SLAVE_STATE_SAFEOP = (0x04); ///< EtherCat从站在SAVEOP状态
- public const uint EC_SLAVE_STATE_OP = (0x08); ///< EtherCat从站在OP状态
- public const uint EC_SLAVE_STATE_ACK_ERR = (0x10); ///< EtherCat从站有错误
- #endregion
- /// @defgroup EcatError 协议栈错误码
- /// @brief 协议栈错误码EcatErrorCode定义
- #region
- public const uint ERROR_CODE_NO_SUCH_SLAVE = (0x0003); ///< 配置阶段, 没有这个从站, 处理方法: 检查从站是否掉线, 重新扫描配置
- public const uint ERROR_CODE_INVALID_PDO = (0x0004); ///< 配置阶段, 非法PDO, 处理方法: 检查从站厂家是否更新xml配置文件, 与汇川默认配置不一致
- public const uint ERROR_CODE_INVALID_SDO = (0x0005); ///< 配置阶段, 非法SDO, 处理方法: 检查从站厂家是否更新xml配置文件, 与汇川默认配置不一致
- public const uint ERROR_CODE_INVALID_ENTRY = (0x0006); ///< 配置阶段, 非法ENTRY, 处理方法: 检查从站厂家是否更新xml配置文件, 与汇川默认配置不一致
- public const uint ERROR_CODE_PASECFGFAIL = (0x000D); ///< 解析XML设备配置失败, 处理方法: 设备配置文件已经被破坏, 重新扫描配置
- public const uint ERROR_CODE_CFGREGISTFAIL = (0x0015); ///< 配置reg失败, 处理方法: 检查从站厂家是否更新xml配置文件, 与汇川默认配置不一致
- public const uint ERROR_CODE_CFGDIFFONLINE = (0x0016); ///< 在线从站与配置不一致, 处理方法: 检查从站是否掉线, 重新扫描配置
- public const uint ERROR_CODE_AXIS_NUM_BEYOND = (0x0017); ///< 轴配置数量超过板卡最大支持轴数;
- public const uint ERROR_CODE_SLAVE_OFFLINE = (0x001a); ///< 从站掉线错误, 高8位为从站号, 即bit[15:8]-轴号, 处理方法: 检查从高8位数字开始从站是否掉线, 或者重新扫描配置
- public const uint ERROR_CODE_SDOBF_NONECAT = (0x001b); ///< SDO缓冲区收到非ECAT帧错误, 处理方法: 检查线路是否接错, 是否有其他非Ethercat设备接入
- public const uint ERROR_CODE_PORT0_NOTLINK = (0x001c); ///< 端口未接ECAT设备错误, 处理方法: 检查板卡端线路是否正常接线, 是否接线不可靠
- public const uint ERROR_CODE_SET_CYCLETIME_PARA_ERR = (0x001e); ///< 设置周期时间参数错误, 处理方法: 错误的DC时钟配置, 只支持125us, 250us, 500us, 125us, 1000us, 2000us, 4000us, 8000us周期
- public const uint ERROR_CODE_COE_SDO_INIT_ERR = (0x001f); ///< 在初始化阶段coe配置错误, 处理方法: 检查从站厂家是否更新xml配置文件, 与汇川默认配置不一致; 或者可能例如RTU模块配置错误
- public const uint ERROR_CODE_SLAVE_STATE_ERR = (0x0020); ///< 从站状态错误, 高8位为轴号, 即bit[15:8]-轴号, 处理方法: 检查从高8位数字从站状态, 检查从站设备异常原因
- public const uint ERROR_CODE_SLAVE_SII_ERR = (0x0037); ///< E2ROM 信息有误, 处理方法: 一般为从站保存的e2rom信息有误, 可以使用twincat确认并联系厂家
- public const uint ERROR_CODE_SLAVE_NUM_BEYOND = (0x003b); ///< 从站在线超过最大64个站
- #endregion
- /// @defgroup AbortCode SDO访问舍弃码
- /// @brief 以下宏定义针对IIMC_GetEcatSdo, IMC_SetEcatSdo函数
- #region
- public const uint ABORT_CODE1 = (0x05030000); ///< 从站Toggle bit 没有变化
- public const uint ABORT_CODE2 = (0x05040000); ///< SDO 访问超时
- public const uint ABORT_CODE3 = (0x05040001); ///< 客户端/服务器 命令非法或未知
- public const uint ABORT_CODE4 = (0x05040005); ///< 内存溢出
- public const uint ABORT_CODE5 = (0x06010000); ///< 不支持访问该对象
- public const uint ABORT_CODE6 = (0x06010001); ///< 尝试去读一个只写对象
- public const uint ABORT_CODE7 = (0x06010002); ///< 尝试去写一个只读对象
- public const uint ABORT_CODE8 = (0x06020000); ///< 对象字典中不存在该对象
- public const uint ABORT_CODE9 = (0x06040041); ///< 该对象不能映射成PDO
- public const uint ABORT_CODE10 = (0x06040042); ///< 对象映射成PDO超出 PDO长度
- public const uint ABORT_CODE11 = (0x06040043); ///< 通用参数非法
- public const uint ABORT_CODE12 = (0x06040047); ///< 设备内不兼容
- public const uint ABORT_CODE13 = (0x06060000); ///< 由于硬件原因访问失败
- public const uint ABORT_CODE14 = (0x06070010); ///< 数据类型不匹配, 长度参数
- public const uint ABORT_CODE15 = (0x06070012); ///< 数据类型不匹配, 长度太大
- public const uint ABORT_CODE16 = (0x06070013); ///< 数据类型不匹配, 长度太小
- public const uint ABORT_CODE17 = (0x06090011); ///< 该对象子索引不存在
- public const uint ABORT_CODE18 = (0x06090030); ///< 参数超出范围
- public const uint ABORT_CODE19 = (0x06090031); ///< 参数超出范围太大
- public const uint ABORT_CODE20 = (0x06090032); ///< 参数超出范围太小
- public const uint ABORT_CODE21 = (0x06090036); ///< 最大值小于最小值
- public const uint ABORT_CODE22 = (0x08000000); ///< 一般错误
- public const uint ABORT_CODE23 = (0x08000020); ///< 数据不能被传输或被保存
- public const uint ABORT_CODE24 = (0x08000021); ///< 数据不能被传输或被保存由于本地控制
- public const uint ABORT_CODE25 = (0x08000022); ///< 数据不能被传输或被保存由于当前状态
- public const uint ABORT_CODE26 = (0x08000023); ///< 缺乏对象字典或者对象字典创建失败
- #endregion
- /// @defgroup ServoOpMode 伺服操作模式定义
- /// @brief 定义了伺服402协议中的控制模式
- #region
- public const Int16 TQ_OP_MODE = (4); ///< TQ模式
- public const Int16 HM_OP_MODE = (6); ///< 回零模式
- public const Int16 CSP_OP_MODE = (8); ///< CSP模式
- public const Int16 CSV_OP_MODE = (9); ///< CSV模式
- public const Int16 CST_OP_MODE = (10); ///< CST模式
- #endregion
- /// @defgroup EcatHomingMethod 402回零方法定义
- /// @brief 定义了伺服402回零模式的回零方法类型
- #region
- public const uint HOME_NLIMT_ZINDEX = (1); ///< 负限位+Z信号
- public const uint HOME_PLIMT_ZINDEX = (2); ///< 正限位+Z信号
- public const uint HOME_PHOME_FEDGE_ZINDEX = (3); ///< 正原点开关下降沿+Z信号
- public const uint HOME_PHOME_REDGE_ZINDEX = (4); ///< 正原点开关上升沿+Z信号
- public const uint HOME_NHOME_FEDGE_ZINDEX = (5); ///< 负原点开关下降沿+Z信号
- public const uint HOME_NHOME_REDGE_ZINDEX = (6); ///< 负原点开关上升沿+Z信号
- public const uint HOME_PLIMT_PHOME_FEDGE_ZINDEX = (7); ///< 正限位+正原点开关下降沿+Z信号
- public const uint HOME_PLIMT_PHOME_REDGE_ZINDEX = (8); ///< 正限位+正原点开关上升沿+Z信号
- public const uint HOME_PLIMT_NHOME_REDGE_ZINDEX = (9); ///< 正限位+负原点开关上升沿+Z信号
- public const uint HOME_PLIMT_NHOME_FEDGE_ZINDEX = (10); ///< 正限位+负原点开关下降沿+Z信号
- public const uint HOME_NLIMT_NHOME_FEDGE_ZINDEX = (11); ///< 负限位+负原点开关下降沿+Z信号
- public const uint HOME_NLIMT_NHOME_REDGE_ZINDEX = (12); ///< 负限位+负原点开关上升沿+Z信号
- public const uint HOME_NLIMT_PHOME_REDGE_ZINDEX = (13); ///< 负限位+正原点开关上升沿+Z信号
- public const uint HOME_NLIMT_PHOME_FEDGE_ZINDEX = (14); ///< 负限位+正原点开关下降沿+Z信号
- public const uint HOME_NLIMT = (17); ///< 负限位
- public const uint HOME_PLIMT = (18); ///< 正限位
- public const uint HOME_PHOME_FEDGE = (19); ///< 正原点开关下降沿
- public const uint HOME_PHOME_REDGE = (20); ///< 正原点开关上升沿
- public const uint HOME_NHOME_FEDGE = (21); ///< 负原点开关下降沿
- public const uint HOME_NHOME_REDGE = (22); ///< 负原点开关上升沿
- public const uint HOME_PLIMT_PHOME_FEDGE = (23); ///< 正限位+正原点开关下降沿
- public const uint HOME_PLIMT_PHOME_REDGE = (24); ///< 正限位+正原点开关上升沿
- public const uint HOME_PLIMT_NHOME_REDGE = (25); ///< 正限位+负原点开关上升沿
- public const uint HOME_PLIMT_NHOME_FEDGE = (26); ///< 正限位+负原点开关下降沿
- public const uint HOME_NLIMT_NHOME_FEDGE = (27); ///< 负限位+负原点开关下降沿
- public const uint HOME_NLIMT_NHOME_REDGE = (28); ///< 负限位+负原点开关上升沿
- public const uint HOME_NLIMT_PHOME_REDGE = (29); ///< 负限位+正原点开关上升沿
- public const uint HOME_NLIMT_PHOME_FEDGE = (30); ///< 负限位+正原点开关下降沿
- public const uint HOME_NEGZINDEX = (33); ///< 负向Z信号
- public const uint HOME_POSZINDEX = (34); ///< 正向Z信号
- public const uint HOME_CURRENT_POS = (35); ///< 当前位置
- #endregion
- /// @defgroup EcatHomingSts 402回零状态定义
- /// @brief 定义了伺服402回零模式下的工作状态
- #region
- public const Int16 HOME_IN_PROGRESS = (0); ///< 正在回零中
- public const Int16 HOME_INTERRUPTED_OR_NOT_START = (1); ///< 回零中断或者没有开始启动
- public const Int16 HOME_ATTAINED_BUT_NOT_REACH = (2); ///< 回零结束, 但没有到设定的目标位置
- public const Int16 HOME_SUCESS = (3); ///< 回零成功
- public const Int16 HOME_ERR_VEL_NOT_ZERO = (4); ///< 回零中发生错误, 同时速度不为0
- public const Int16 HOME_ERR_VEL_ZERO = (5); ///< 回零中发生错误, 同时速度为0
- #endregion
- /// @defgroup CSPHomingMethod CSP回零方法定义
- /// @brief 定义了板卡CSP回零模式的回零方法
- #region
- public const Int32 HOMING_ECAT_CSP_METHOD_NONE = (-1); ///< 非回零模式
- public const Int32 HOMING_ECAT_CSP_METHOD_DI = (0); ///< DI回零方式
- public const Int32 HOMING_ECAT_CSP_METHOD_INDEX = (1); ///< Index回零方式
- public const Int32 HOMING_ECAT_CSP_METHOD_LIMIT_INDEX = (2); ///< 限位+Index回零方式
- public const Int32 HOMING_ECAT_CSP_METHOD_LIMIT_DI = (3); ///< 限位+Di回零方式
- #endregion
- /// @defgroup CSPHomingSts CSP回零状态定义
- /// @brief 定义了板卡CSP回零模式下的工作状态
- #region
- public const Int16 HOME_CSP_STS_RUNING = (0x01); ///< CSP回零中
- public const Int16 HOME_CSP_STS_STOPPING = (0x02); ///< CSP回零停止中
- public const Int16 HOME_CSP_STS_STOPPED = (0x03); ///< CSP回零已停止
- public const Int16 HOME_CSP_STS_FINISH = (0x04); ///< CSP回零已完成
- public const Int16 HOME_CSP_STS_ERROR = (0x05); ///< CSP回零错误
- #endregion
- #endregion
- /// @defgroup CardSysDef 板卡系统相关宏定义
- #region
- /// @defgroup CardResType 资源类型宏定义
- /// @brief 以下宏定义针对IMC_GetResCount函数
- #region
- public const uint MC_ECAT_DO = (0); ///< ecat的通用do
- public const uint MC_LOCAL_DO = (1); ///< localBus的通用do
- public const uint MC_ECAT_DI = (11); ///< ecat的通用DI
- public const uint MC_ECAT_AD = (12); ///< ecat的通用AD
- public const uint MC_ECAT_DA = (13); ///< ecat的通用DA
- public const uint MC_ECAT_AXIS = (15); ///< ecat的通用AXIS
- public const uint MC_ECAT_REG_IN = (16); ///< ecat的通用RegIn
- public const uint MC_ECAT_REG_OUT = (17); ///< ecat的通用RegOut
- public const uint MC_ECAT_ENC = (18); ///< ecat的通用RegOut
- public const uint MC_AXIS = (30); ///< 板卡最大轴数
- public const uint MC_PROFILE = (31); ///< 板卡规划轴数
- public const uint MC_CRD_MAX_CNT = (60); ///< 坐标系最大个数
- public const uint MC_CRD_BUF_LEN = (61); ///< 坐标系缓冲区长度
- #endregion
- /// @defgroup CardVersionType 板卡系统版本类型定义
- /// @brief 以下宏定义针对IMC_GetImcCardVersion函数
- #region
- public const uint SOFT_VERSION = (0); // 总软件版本
- public const uint DSP_VERSION = (1); // HAL2软件版本
- public const uint ARM_VERSION = (2); // ARM软件版本
- public const uint API_VERSION = (3); // API软件版本
- public const uint FPGA_VERSION = (4); // FPGA固件版本
- public const uint DSP2_VERSION = (5); // HAL3固件版本
- public const uint LOCAL_VERSION = (6); // 端子板固件版本
- public const uint OS_ARM_VERSION = (11); // ARM系统版本
- public const uint LIB_DSP_VERSION = (12); // LibInfo软件版本
- public const uint LIB_ECAT_BOARD_APP_VERSION = (20); // 协议栈软件版本1
- public const uint LIB_ECAT_APP_VERSION = (21); // 协议栈软件版本2
- public const uint LIB_ECAT_VERSION = (22); // 协议栈软件版本3
- public const uint LIB_ECAT_PARSER_ENI_VERSION = (23); // 协议栈软件版本4
- #endregion
- #endregion
- /// @defgroup AxDiStopType 轴DI停止类型定义
- /// @brief 以下宏定义针对IMC_SetAxStopTrigPara、IMC_GetAxStopTrigPara函数
- #region
- public const uint CNST_DI_STOP_TYPE_ECATDI = (0); ///< EcatDI停止类型
- public const uint CNST_DI_STOP_TYPE_PROBLE1_RF = (1); ///< 探针1上升沿或下降沿停止
- public const uint CNST_DI_STOP_TYPE_PROBLE1_R = (2); ///< 探针1上升沿停止
- public const uint CNST_DI_STOP_TYPE_PROBLE1_F = (3); ///< 探针1下降沿停止
- #endregion
- /// @defgroup AxStsBit 轴状态位定义
- /// @brief 以下宏定义针对IMC_GetAxSts函数
- #region
- public const uint AX_ALARM_BIT = (0x00000001); ///< 轴驱动报警
- public const uint AX_SVON_BIT = (0x00000002); ///< 伺服使能
- public const uint AX_BUSY_BIT = (0x00000004); ///< 轴忙状态
- public const uint AX_ARRIVE_BIT = (0x00000008); ///< 轴到位状态
- public const uint AX_POSLMT_BIT = (0x00000010); ///< 正硬限位报警
- public const uint AX_NEGLMT_BIT = (0x00000020); ///< 负硬限位报警
- public const uint AX_SOFT_POSLMT_BIT = (0x00000040); ///< 正软限位报警
- public const uint AX_SOFT_NEGLMT_BIT = (0x00000080); ///< 负软限位报警
- public const uint AX_ERRPOS_BIT = (0x00000100); ///< 轴位置误差越限标志
- public const uint AX_EMG_STOP_BIT = (0x00000200); ///< 运动急停标志
- public const uint AX_ECAT_BIT = (0x00000400); ///< 总线轴标志
- public const uint AX_SW_ABNOR_BIT = (0x00000800); ///< 轴异常报警=(龙门);
- public const uint AX_WARING_BIT = (0x00001000); ///< 轴警告
- public const uint AX_HM_BIT = (0x00002000); ///< 原点信号状态
- public const uint AX_UNLINK_BIT = (0x00004000); ///< 轴掉线状态
- public const uint AX_ECAT_TGTREACH_BIT = (0x00008000); ///< 状态字里的到位状态
- #endregion
- /******************采集数据类型 定义***************************/
- // 单轴数据类型
- public const Int16 SAMPLE_ADDRESS_TYPE_AX_PRF_POS = (0x01); ///< 轴规划位置
- public const Int16 SAMPLE_ADDRESS_TYPE_AX_ENC_POS = (0x02); ///< 轴编码器位置
- public const Int16 SAMPLE_ADDRESS_TYPE_AX_PRF_VEL = (0x03); ///< 轴规划速度
- public const Int16 SAMPLE_ADDRESS_TYPE_AX_ENC_VEL = (0x04); ///< 轴编码器速度
- public const Int16 SAMPLE_ADDRESS_TYPE_AX_PRF_ACC = (0x05); ///< 轴规划加速度
- public const Int16 SAMPLE_ADDRESS_TYPE_AX_ENC_ACC = (0x06); ///< 轴编码器加速度
- public const Int16 SAMPLE_ADDRESS_TYPE_PRF_POS = (0x07); ///< 规划位置
- public const Int16 SAMPLE_ADDRESS_TYPE_PRF_CMPPOS = (0x08); ///< 比较位置
- public const Int16 SAMPLE_ADDRESS_TYPE_AX_TORQ = (0x0a); ///< 轴扭矩
- public const Int16 SAMPLE_ADDRESS_TYPE_AX_STS = (0x0b); ///< 轴状态
- // 资源信号数据类型
- public const Int16 SAMPLE_ADDRESS_TYPE_ECAT_DI = (0x30); ///< ECAT通用DI
- public const Int16 SAMPLE_ADDRESS_TYPE_ECAT_DO = (0x31); ///< ECAT通用DO
- public const Int16 SAMPLE_ADDRESS_TYPE_LOCAL_DI = (0x32); ///< 端子板DI
- public const Int16 SAMPLE_ADDRESS_TYPE_LOCAL_DO = (0x33); ///< 端子板DO
- public const Int16 SAMPLE_ADDRESS_TYPE_ECAT_AD = (0x34); ///< ECAT AD
- public const Int16 SAMPLE_ADDRESS_TYPE_ECAT_DA = (0x35); ///< ECAT DA
- // 总线对象字典采集
- public const Int16 SAMPLE_ADDRESS_TYPE_RXPDO_2 = (0x40); ///< pdo通用, 2字节, 写
- public const Int16 SAMPLE_ADDRESS_TYPE_RXPDO_4 = (0x41); ///< pdo通用, 4字节, 写
- public const Int16 SAMPLE_ADDRESS_TYPE_6040 = (0x42); ///< 控制字
- public const Int16 SAMPLE_ADDRESS_TYPE_607a = (0x43); ///< 目标位置
- public const Int16 SAMPLE_ADDRESS_TYPE_60ff = (0x44); ///< 目标速度
- public const Int16 SAMPLE_ADDRESS_TYPE_6071 = (0x45); ///< 目标力矩
- public const Int16 SAMPLE_ADDRESS_TYPE_6060 = (0x46); ///< 模式控制
- public const Int16 SAMPLE_ADDRESS_TYPE_60fe = (0x47); ///< 数字量输出
- public const Int16 SAMPLE_ADDRESS_TYPE_60b8 = (0x48); ///< 探针控制字
- public const Int16 SAMPLE_ADDRESS_TYPE_TXPDO_2 = (0x50); ///< pdo通用, 2字节, 读
- public const Int16 SAMPLE_ADDRESS_TYPE_TXPDO_4 = (0x51); ///< pdo通用, 4字节, 读
- public const Int16 SAMPLE_ADDRESS_TYPE_6041 = (0x52); ///< 状态字
- public const Int16 SAMPLE_ADDRESS_TYPE_6064 = (0x53); ///< 实际位置
- public const Int16 SAMPLE_ADDRESS_TYPE_606c = (0x54); ///< 实际速度
- public const Int16 SAMPLE_ADDRESS_TYPE_6077 = (0x55); ///< 实际力矩
- public const Int16 SAMPLE_ADDRESS_TYPE_60f4 = (0x56); ///< 跟随误差
- public const Int16 SAMPLE_ADDRESS_TYPE_603f = (0x57); ///< 错误码
- public const Int16 SAMPLE_ADDRESS_TYPE_60fd = (0x58); ///< 数字量输入
- public const Int16 SAMPLE_ADDRESS_TYPE_60b9 = (0x59); ///< 探针状态字
- public const Int16 SAMPLE_ADDRESS_TYPE_60ba = (0x60); ///< 探针位置1
- public const Int16 SAMPLE_ADDRESS_TYPE_60bb = (0x61); ///< 探针位置2
- // 插补数据类型
- public const Int16 SAMPLE_ADDRESS_TYPE_CRD_POSX = (0x100); ///< 插补坐标系, X轴位置
- public const Int16 SAMPLE_ADDRESS_TYPE_CRD_POSY = (0x101); ///< 插补坐标系, Y轴位置
- public const Int16 SAMPLE_ADDRESS_TYPE_CRD_POSZ = (0x102); ///< 插补坐标系, Z轴位置
- public const Int16 SAMPLE_ADDRESS_TYPE_CRD_VEL = (0x110); ///< 插补坐标系, 合成速度
- // 采集触发类型
- public const Int16 SAMPLE_TRIG_IMMEDIATE = (0); ///< 立即采集
- public const Int16 SAMPLE_TRIG_DELAY = (1); ///< 延时采集
- public const Int16 SAMPLE_TRIG_LOCAL_DI = (2); ///< 本地DI触发
- public const Int16 SAMPLE_TRIG_ECAT_DI = (3); ///< ECAT 的DI 触发
- //事件类型定义
- public const Int16 EVENT_TYPE_PRFPOS = (1);
- public const Int16 EVENT_TYPE_PRFVEL = (2);
- public const Int16 EVENT_TYPE_ENCPOS = (3);
- public const Int16 EVENT_TYPE_ENCVEL = (4);
- public const Int16 EVENT_TYPE_CRDPOS_X = (5);
- public const Int16 EVENT_TYPE_CRDPOS_Y = (6);
- public const Int16 EVENT_TYPE_CRDPOS_Z = (7);
- public const Int16 EVENT_TYPE_CRDVEL = (8);
- public const Int16 EVENT_TYPE_AXSTS_ALARM = (9);
- public const Int16 EVENT_TYPE_AXSTS_SVON = (10);
- public const Int16 EVENT_TYPE_AXSTS_BUSY = (11);
- public const Int16 EVENT_TYPE_AXSTS_ARRIVE = (12);
- public const Int16 EVENT_TYPE_AXSTS_POSLMT = (13);
- public const Int16 EVENT_TYPE_AXSTS_NEGLMT = (14);
- public const Int16 EVENT_TYPE_AXSTS_SOFT_POSLMT = (15);
- public const Int16 EVENT_TYPE_AXSTS_SOFT_NEGLMT = (16);
- public const Int16 EVENT_TYPE_AXSTS_ERRPOS = (17);
- public const Int16 EVENT_TYPE_AXSTS_EMGSTOP = (18);
- public const Int16 EVENT_TYPE_AXSTS_ECAT = (19);
- public const Int16 EVENT_TYPE_AXSTS_SW_ABNOR = (20);
- public const Int16 EVENT_TYPE_AXSTS_WARING = (21);
- public const Int16 EVENT_TYPE_AXSTS_HM = (22);
- public const Int16 EVENT_TYPE_AXSTS_UNLINK = (23);
- public const Int16 EVENT_TYPE_AXSTS_TGTREACH = (24);
- public const Int16 EVENT_TYPE_CRDSTS = (25);
- public const Int16 EVENT_TYPE_CRDID = (26);
- public const Int16 EVENT_TYPE_DI = (27);
- public const Int16 EVENT_TYPE_AD = (28);
- public const Int16 EVENT_TYPE_GLOBALVAL = (29);
- //事件条件定义
- public const Int16 EVENT_CONDITION_EQ = (1); ///< 变量值等于设定值
- public const Int16 EVENT_CONDITION_NE = (2); ///< 变量值不等于设定值
- public const Int16 EVENT_CONDITION_GT = (3); ///< 变量值大于设定值
- public const Int16 EVENT_CONDITION_LT = (4); ///< 变量值小于设定值
- public const Int16 EVENT_CONDITION_CHANGE_TO = (5); ///< 变量值改变为设定值
- public const Int16 EVENT_CONDITION_CHANGE = (6); ///< 变量值改变
- public const Int16 EVENT_CONDITION_UP = (7); ///< 变量值增大
- public const Int16 EVENT_CONDITION_DOWN = (8); ///< 变量值减小
- public const Int16 EVENT_CONDITION_REMAIN_AT = (9); ///< 变量值保持为设定值
- public const Int16 EVENT_CONDITION_REMAIN = (10); ///< 变量值保持不变
- public const Int16 EVENT_CONDITION_CROSS_POSITIVE = (11); ///< 变量值正向穿越设定值
- public const Int16 EVENT_CONDITION_CROSS_NEGATIVE = (12); ///< 变量值负向穿越设定值
- //事件功能中任务类型定义
- public const Int16 TASK_TYPE_CRDSTART = (1);
- public const Int16 TASK_TYPE_STARTPTPMOVE = (2);
- public const Int16 TASK_TYPE_STARTJOGMOVE = (3);
- public const Int16 TASK_TYPE_STARTGEARMOVE = (4);
- public const Int16 TASK_TYPE_STARTPTMOVE = (5);
- public const Int16 TASK_TYPE_STARTPVTMOVE = (6);
- public const Int16 TASK_TYPE_UPDATEPTPMOVEPARA = (7);
- public const Int16 TASK_TYPE_UPDATEJOGMOVEPARA = (8);
- public const Int16 TASK_TYPE_SETECATDOBIT = (9);
- public const Int16 TASK_TYPE_SETECATGRPDO = (10);
- public const Int16 TASK_TYPE_SETECATDOBITINVERSE = (11);
- public const Int16 TASK_TYPE_SETECATDAVAL = (12);
- public const Int16 TASK_TYPE_UPDATEPTPTGTPOS = (13);
- public const Int16 TASK_TYPE_PLUSEDO = (14);
- public const Int16 TASK_TYPE_STOPMOVE = (15);
- ///@defgroup CardBasic CardBasic
- ///@brief 板卡基本操作
- #region CardBasic
- ///@defgroup CardOpen CardOpen
- ///@brief 板卡开启与关闭
- #region CardOpen
- /// @brief 获取板卡数量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetCardsNum", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetCardsNum(ref Int16 pCardsNum, Int16[] pCardIndexArray);
- /// @brief 按卡号开启控制卡
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_OpenCard", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_OpenCard(Int16 cardIndex);
- /// @brief 按卡号关闭控制卡
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CloseCard", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CloseCard(Int16 cardIndex);
- #endregion
- ///@defgroup CardConfigFile CardConfigFile
- ///@brief 板卡配置文件操作
- #region CardConfigFile
- /// @brief 上传控制卡的设备配置文件(包括主站使能, 规划周期, EtherCAT对象以及偏置等), 上传文件的路径在设定目录下
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpLoadDeviceConfig", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_UpLoadDeviceConfig(Int16 cardIndex, string pathName);
- /// @brief 下载控制器的设备配置文件(包括主站使能, 规划周期, EtherCAT对象以及偏置等), 下载文件的路径在设定目录下
- /// @attention 当次下载下去之后, 非立即生效, 需要调用扫描板卡指令才能生效
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_DownLoadDeviceConfig", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_DownLoadDeviceConfig(Int16 cardIndex, string pathName);
- /// @brief 下载控制器的系统配置文件(包括轴映射、轴运动参数、IO取反滤波等硬件信号配置参数)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_DownLoadSystemConfig", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_DownLoadSystemConfig(Int16 cardIndex, string pathName);
- #endregion
- #endregion
- ///@defgroup CardSysConfig CardSysConfig
- ///@brief 板卡系统配置相关函数
- #region CardSysConfig
- ///@defgroup EmgConfig EmgConfig
- ///@brief 急停参数配置函数
- #region EmgConfig
- /// @brief 设置停止信号的滤波系数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEmgFilter", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEmgFilter(Int16 cardIndex, Int16 filter);
- /// @brief 获取停止信号的滤波系数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEmgFilter", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEmgFilter(Int16 cardIndex, ref Int16 pFilter);
- /// @brief 设置急停信号触发的电平取反
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEmgTrigLevelInv", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEmgTrigLevelInv(Int16 cardIndex, Int16 inverse);
- /// @brief 获取急停信号触发的电平取反
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEmgTrigLevelInv", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEmgTrigLevelInv(Int16 cardIndex, ref Int16 pInverse);
- /// @brief 获取急停状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEmgSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEmgSts(Int16 cardIndex, ref Int16 pSts);
- /// @brief 设置急停时是否复位所有 DO 输出的开关使能
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEmgDoResetFlag", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEmgDoResetFlag(Int16 cardIndex, Int16 enable);
- /// @brief 读取急停时是否复位所有 DO 输出的开关使能
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEmgDoResetFlag", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEmgDoResetFlag(Int16 cardIndex, ref Int16 pEnable);
- /// @brief 设置是否忽略板卡的ECAT连接状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatLinkStsIgnore", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatLinkStsIgnore(Int16 cardIndex, Int16 flag);
- #endregion
- ///@defgroup Watchdog Watchdog
- ///@brief 看门狗参数配置函数
- #region Watchdog
- /// @brief 设置看门狗, 在报警时, 进行急停动作。主要用于检查应用层软件是否卡死。
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_OpenWatchDog", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_OpenWatchDog(Int16 cardIndex, Int32 feedTime);
- /// @brief 喂看门狗操作
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_FeedWatchDog", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_FeedWatchDog(Int16 cardIndex);
- /// @brief 关闭看门狗检查
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CloseWatchDog", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CloseWatchDog(Int16 cardIndex);
- #endregion
- ///@defgroup CardTimeInfo CardTimeInfo
- ///@brief 板卡内部时钟信息
- #region CardTimeInfo
- /// @brief 获取板卡的CPU负载
- /// @warning 建议负载率不要超过60%
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetCalcLoadRatio", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetCalcLoadRatio(Int16 cardIndex, ref double pLoadRatio);
- /// @brief 根据Type类型, 获取板卡对应的固件版本
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetVersion", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetVersion(Int16 cardIndex, Int16 type, Int16[] pVersion);
- #endregion
- ///@defgroup CardMasterInfo CardMasterInfo
- ///@brief 板卡主站配置信息
- #region CardMasterInfo
- /// @brief 获取主站启用配置, 从xml配置文件获取
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetMasterCfgXml", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetMasterCfgXml(Int16 cardIndex, ref Int16 pHwCfg);
- /// @brief 获取板卡的网口硬件连接状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetHwPortLinkSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetHwPortLinkSts(Int16 cardIndex, ref Int16 pLinkSts);
- /// @brief 获取板卡的网口硬件连接状态,Ex指令
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetHwPortLinkStsEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetHwPortLinkStsEx(Int16 cardIndex, ref Int16 pLinkSts);
- #endregion
- ///@defgroup CardReset CardReset
- ///@brief 板卡复位功能
- #region CardReset
- /// @brief 复位控制卡系统参数
- /// @details 控制卡规划层软件资源复位
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ResetSysPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ResetSysPara(Int16 cardIndex);
- #endregion
- ///@defgroup UserCode UserCode
- ///@brief 用户配置
- #region UserCode
- /// @brief 设置用户密码
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_WriteUserCode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_WriteUserCode(Int16 cardIndex, Byte[] pCode, Int16 len);
- /// @brief 检验设置的用户密码
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CheckUserCode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CheckUserCode(Int16 cardIndex, Byte[] pCode, Int16 len);
- /// @brief 写入用户数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_WriteUserData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_WriteUserData(Int16 cardIndex, Int16 offset, Byte[] pData, Int16 len);
- /// @brief 读取用户数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ReadUserData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ReadUserData(Int16 cardIndex, Int16 offset, Byte[] pData, Int16 len);
- #endregion
- #endregion
- ///@defgroup EtherCAT EtherCAT
- ///@brief 板卡ECAT功能
- #region EtherCAT
- ///@defgroup EcatInit EcatInit
- ///@brief 板卡ECAT初始化功能
- #region EcatInit
- /// @brief 初始化板卡通讯, 主站进入OP状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_InitEcatComm", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_InitEcatComm(Int16 cardIndex);
- /// @brief 开启板卡通讯, 获取EtherCAT总线资源, 建立主站与各从站之间的通讯
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartEcatComm", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartEcatComm(Int16 cardIndex);
- /// @brief 关闭板卡通讯, 主站退出OP状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_DelEcatComm", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_DelEcatComm(Int16 cardIndex);
- /// @brief 初始化总线, 直到主站进入OP状态, 随后扫描EtherCAT总线资源, 并建立主站与各从站之间的通讯 (该函数会阻塞在EtherCAT的总线扫描同步阶段)
- /// @warning 该指令阻塞执行
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ScanCardEcat", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ScanCardEcat(Int16 cardIndex, Int16 waitTime = 40);
- #endregion
- ///@defgroup EcatInfo EcatInfo
- ///@brief 板卡ECAT主站信息获取函数
- #region EcatInfo
- /// @brief 获取EtherCAT主站的状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatMasterSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatMasterSts(Int16 cardIndex, ref UInt32 pStatus);
- /// @brief 获取EtherCAT协议栈通讯错误码
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatErrCode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatErrCode(Int16 cardIndex, ref UInt32 pErrCode);
- /// @brief 获取EtherCAT主站的状态,Ex指令
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatMasterStsEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatMasterStsEx(Int16 cardIndex, ref UInt32 pStatus);
- /// @brief 获取EtherCAT协议栈通讯错误码,Ex指令
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatErrCodeEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatErrCodeEx(Int16 cardIndex, ref UInt32 pErrCode);
- /// @brief 获取EtherCAT从站当前通讯阶段INIT、PreOP、SafeOp、OP
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlaveSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatSlaveSts(Int16 cardIndex, Int16 slave, ref Int16 pCurStatus, ref Int16 pReqStatus, ref Int16 pErrCode);
- /// @brief 获取EtherCAT主站信息(包含通讯周期, 从站个数, 资源数量等)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatMasterInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatMasterInfo(Int16 cardIndex, ref TMasterInfo ptMasterInfo);
- /// @brief 获取EtherCAT从站信息(包含设备类型, 对应轴号, 从站别名等)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlaveInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatSlaveInfo(Int16 cardIndex, Int16 slave, ref TSlaveInfo ptSlaveInfo);
- /// @brief 获取从站连接状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlaveOpSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatSlaveOpSts(Int16 cardIndex, ref UInt16 pSts, UInt32[] pMask);
- #endregion
- ///@defgroup EcatPDO EcatPDO
- ///@brief 板卡ECAT主站PDO功能
- #region EcatPDO
- /// @brief 根据站号读取EtherCAT从站的PDO数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlavePdoData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatSlavePdoData(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData);
- /// @brief 根据站号写入EtherCAT从站的PDO数据, 仅支持非轴从站, 非DIO, AIO, RegInOut类型Pdo
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatSlavePdoData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatSlavePdoData(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData);
- /// @brief 根据轴号获取EtherCAT从站的PDO数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxPdoData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxPdoData(Int16 cardIndex, Int16 axNo, UInt16 index, Byte[] pData);
- /// @brief 根据轴号写入EtherCAT从站的PDO数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxPdoData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxPdoData(Int16 cardIndex, Int16 axNo, UInt16 index, Byte[] pData);
- /// @brief 根据索引和子索引读取从站的PdoEntry结构体信息
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlavePdoEntry", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatSlavePdoEntry(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, ref TPdoEntry ptPdoEntry);
- #endregion
- ///@defgroup EcatSDO EcatSDO
- ///@brief 板卡ECAT主站SDO功能
- #region EcatSDO
- /// @brief 根据站号获取EtherCAT从站的SDO数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlaveSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatSlaveSdo(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pResultSize, ref UInt32 pAbortCode);
- /// @brief 根据站号写入EtherCAT从站的SDO数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatSlaveSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatSlaveSdo(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pAbortCode);
- /// @brief 根据轴号获取EtherCAT从站的SDO数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxSdo(Int16 cardIndex, Int16 axNo, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pResultSize, ref UInt32 pAbortCode);
- /// @brief 根据轴号写入EtherCAT从站的SDO数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxSdo(Int16 cardIndex, Int16 axNo, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pAbortCode);
- #endregion
- ///@defgroup EcatAxisMap EcatAxisMap
- ///@brief 板卡ECAT主站轴映射功能
- #region EcatAxisMap
- /// @brief 根据轴号获取轴所在从站的站号以及Slot号
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxStation", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxStation(Int16 cardIndex, Int16 axNo, ref Int16 pSlave, ref Int16 pSlotIndex);
- /// @brief 根据从站号以及Slot号获取对应的轴通道号
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatSlaveAxChn", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatSlaveAxChn(Int16 cardIndex, Int16 slave, Int16 slotIndex, ref Int16 pAxChn);
- #endregion
- ///@defgroup EcatAlias EcatAlias
- ///@brief 板卡ECAT从站别名功能
- #region EcatAlias
- /// @brief 根据从站别名获取从站的SDO数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAliasSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAliasSdo(Int16 cardIndex, UInt32 aliasNo, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pResultSize, ref UInt32 pAbortCode);
- /// @brief 根据从站别名设定从站的SDO数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAliasSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAliasSdo(Int16 cardIndex, UInt32 aliasNo, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pAbortCode);
- /// @brief 设置EtherCAT的DO输出状态保持, 断线后复位总线保持上一次状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatDoStsHold", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatDoStsHold(Int16 cardIndex, Int16 isHold);
- #endregion
- /// @brief 获取EtherCAT的DI输入状态, 按16bits为一组进行获取
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatDi(Int16 cardIndex, Int16 packIndex, UInt16[] pValue, Int16 packCnt);
- /// @brief 设置EtherCAT的DO输出状态, 按16bits为一组进行设置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatDo(Int16 cardIndex, Int16 packIndex, UInt16[] pValue, Int16 packCnt);
- /// @brief 获取EtherCAT的DO输出状态, 按16bits为一组进行获取
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatDo(Int16 cardIndex, Int16 packIndex, UInt16[] pValue, Int16 packCnt);
- /// @brief 获取EtherCAT的DI输入状态, 按位进行获取
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatDiBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatDiBit(Int16 cardIndex, Int16 diIndex, ref Int16 pValue);
- /// @brief 获取EtherCAT的DO输出状态, 按位进行获取
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatDoBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatDoBit(Int16 cardIndex, Int16 doIndex, ref Int16 pValue);
- /// @brief 设置EtherCAT的DO输出状态, 按位进行设置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatDoBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatDoBit(Int16 cardIndex, Int16 doIndex, Int16 value);
- /// @brief 设置EtherCAT的DO输出状态以及生效延时, 按位进行设置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatDoBitInverse", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatDoBitInverse(Int16 cardIndex, Int16 doIndex, Int16 value, Int16 inverseTime);
- #endregion
- ///@defgroup EcatAD EcatAD
- ///@brief 板卡ECAT主站AD/DA/Reg32寄存器功能
- #region EcatAD
- /// @brief 根据通道号获取EtherCAT对应通道的AD值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAdVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAdVal(Int16 cardIndex, Int16 adIndex, ref Int16 pValue);
- /// @brief 根据通道号设置EtherCAT对应通道的DA值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatDaVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatDaVal(Int16 cardIndex, Int16 daIndex, Int16 Value);
- /// @brief 根据通道号获取EtherCAT对应通道的DA值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatDaVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatDaVal(Int16 cardIndex, Int16 daIndex, ref Int16 pValue);
- /// @brief 根据通道号获取EtherCAT对应通道的RegIn值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatRegInVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatRegInVal(Int16 cardIndex, Int16 regIndex, ref float pValue);
- /// @brief 根据通道号设置EtherCAT对应通道的RegOut值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatRegOutVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatRegOutVal(Int16 cardIndex, Int16 regIndex, float Value);
- /// @brief 根据通道号获取EtherCAT对应通道的RegOut值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatRegOutVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatRegOutVal(Int16 cardIndex, Int16 regIndex, ref float pValue);
- /// @brief 根据通道号获取EtherCAT对应通道的AD值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAd", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAd(Int16 cardIndex, Int16 adIndex, Int16[] pValueArray, Int16 count);
- /// @brief 根据通道号设置EtherCAT对应通道的DA值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatDa", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatDa(Int16 cardIndex, Int16 daIndex, Int16[] pValueArray, Int16 count);
- /// @brief 根据通道号获取EtherCAT对应通道的DA值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatDa", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatDa(Int16 cardIndex, Int16 daIndex, Int16[] pValueArray, Int16 count);
- /// @brief 根据通道号获取EtherCAT对应通道的RegIn值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatRegIn", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatRegIn(Int16 cardIndex, Int16 regIndex, float[] pValueArray, Int16 count);
- /// @brief 根据通道号设置EtherCAT对应通道的RegOut值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatRegOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatRegOut(Int16 cardIndex, Int16 regIndex, float[] pValueArray, Int16 count);
- /// @brief 根据通道号获取EtherCAT对应通道的RegOut值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatRegOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatRegOut(Int16 cardIndex, Int16 regIndex, float[] pValueArray, Int16 count);
- #endregion
- ///@defgroup EcatEnc EcatEnc
- ///@brief 板卡ECAT主站Enc资源操作
- #region EcatEnc
- /// @brief 设置Ecat编码器计数方向
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatEncDir", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatEncDir(Int16 cardIndex, Int16 encIndex, Int16[] pDirArray, Int16 count = 1);
- /// @brief 读取Ecat编码器计数方向
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatEncDir", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatEncDir(Int16 cardIndex, Int16 encIndex, Int16[] pDirArray, Int16 count = 1);
- /// @brief 设置Ecat编码器值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatEncPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatEncPos(Int16 cardIndex, Int16 encIndex, Int32[] pEncPosArray, Int16 count = 1);
- /// @brief 读取Ecat编码器值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatEncPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatEncPos(Int16 cardIndex, Int16 encIndex, Int32[] pEncPosArray, Int16 count = 1);
- /// @brief 读取Ecat编码器原始值(PDO原始编码数据)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatEncPosRaw", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatEncPosRaw(Int16 cardIndex, Int16 encIndex, Int32[] pEncPosArray, Int16 count = 1);
- /// @brief 读取Ecat编码器速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatEncVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatEncVel(Int16 cardIndex, Int16 encIndex, Int32[] pEncVelArray, Int16 count = 1);
- #endregion
- ///@defgroup EcatAxis EcatAxis
- ///@brief 板卡ECAT相关函数
- #region EcatAxis
- ///@defgroup EcatAxisPDO EcatAxisPDO
- ///@brief 板卡ECAT轴PDO功能
- #region EcatAxisPDO
- /// @brief 设置EtherCAT类型轴控制模式0x6060
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxMode(Int16 cardIndex, Int16 axNo, Int16 ctrlMode);
- /// @brief 读取EtherCAT类型轴控制模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxMode(Int16 cardIndex, Int16 axNo, ref Int16 pCtrlMode);
- /// @brief 获取EtherCAT类型轴的对应的数字量输入,pdo必须配置0x60fd
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxDi(Int16 cardIndex, Int16 axNo, ref UInt32 pDiVal);
- /// @brief 设置EtherCAT类型轴的对应的数字量输出,pdo必须配置0x60fe:01
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxDo(Int16 cardIndex, Int16 axNo, UInt32 doVal);
- /// @brief 获取EtherCAT类型轴的对应的数字量输输出,pdo必须配置0x60fe:01
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxDo(Int16 cardIndex, Int16 axNo, ref UInt32 pDoVal);
- /// @brief 获取EtherCAT类型轴的对应的错误码,pdo必须配置0x603f
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxErrCode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxErrCode(Int16 cardIndex, Int16 axNo, ref UInt16 pErrCode);
- /// @brief 设置EtherCAT类型轴的最大速度限制,pdo必须配置0x607f
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxMaxVelLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxMaxVelLmt(Int16 cardIndex, Int16 axNo, UInt32 maxVel);
- /// @brief 获取EtherCAT类型轴的最大速度限制,pdo必须配置0x607f
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxMaxVelLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxMaxVelLmt(Int16 cardIndex, Int16 axNo, ref UInt32 pMaxVel);
- /// @brief 设置 EtherCAT 类型轴的对应的正向力矩限制,pdo必须配置0x60e0
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxPosTorqLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxPosTorqLmt(Int16 cardIndex, Int16 axNo, UInt16 posTorqLmt);
- /// @brief 获取 EtherCAT 类型轴的对应的正向力矩限制,pdo必须配置0x60e0
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxPosTorqLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxPosTorqLmt(Int16 cardIndex, Int16 axNo, ref UInt16 pPosTorqLmt);
- /// @brief 设置 EtherCAT 类型轴的对应的负向力矩限制,pdo必须配置0x60e1
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxNegTorqLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxNegTorqLmt(Int16 cardIndex, Int16 axNo, UInt16 negTorqLmt);
- /// @brief 获取 EtherCAT 类型轴的对应的负向力矩限制,pdo必须配置0x60e1
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxNegTorqLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxNegTorqLmt(Int16 cardIndex, Int16 axNo, ref UInt16 pNegTorqLmt);
- /// @brief 设置 EtherCAT 类型轴的最大力矩限制,pdo必须配置0x6072
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxMaxTorqLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxMaxTorqLmt(Int16 cardIndex, Int16 axNo, UInt16 maxTorqLmt);
- /// @brief 获取 EtherCAT 类型轴的最大力矩限制,pdo必须配置0x6072
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxMaxTorqLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxMaxTorqLmt(Int16 cardIndex, Int16 axNo, ref UInt16 pMaxTorqLmt);
- #endregion
- ///@defgroup EcatAxisThreshold EcatAxisThreshold
- ///@brief 板卡ECAT轴急停保持参数配置函数
- #region EcatAxisThreshold
- /// @brief 设置EtherCAT轴使能控制延时时间, 主要用于特殊场合, 使能控制字输出, 驱动器寻相后, 才能给出使能状态字
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxOnThreshold", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxOnThreshold(Int16 cardIndex, Int16 axNo, UInt16 waitPeriod);
- /// @brief 获取EtherCAT轴使能控制延时时间
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxOnThreshold", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxOnThreshold(Int16 cardIndex, Int16 axNo, ref UInt16 pWaitPeriod);
- #endregion
- ///@defgroup EcatAxisCSV EcatAxisCSV
- ///@brief 板卡ECAT轴CSV模式功能
- #region EcatAxisCSV
- /// @brief 启动 CSV 速度规划
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartEcatAxCsvPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartEcatAxCsvPrf(Int16 cardIndex, Int16 axNo, Int32 tgtVel, Int32 acc, Int16 prfType);
- /// @brief 更新 CSV 速度规划的目标速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdateEcatAxCsvPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_UpdateEcatAxCsvPrf(Int16 cardIndex, Int16 axNo, Int32 tgtVel);
- /// @brief 获取 CSV 速度规划的状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxCsvPrfSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxCsvPrfSts(Int16 cardIndex, Int16 axNo, ref Int16 pStatus);
- #endregion
- ///@defgroup EcatAxisCST EcatAxisCST
- ///@brief 板卡ECAT轴CST模式功能
- #region EcatAxisCST
- /// @brief 启动 CST 线性转矩规划
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartEcatAxTorqPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartEcatAxTorqPrf(Int16 cardIndex, Int16 axNo, Int16 tgtTorq, Int16 time);
- /// @brief 获取 EtherCAT 类型轴的实际转矩, 根据count值可一次获取多个轴的扭矩
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxActTorq", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxActTorq(Int16 cardIndex, Int16 axNo, Int16[] pActTorqArray, Int16 count = 1);
- /// @brief 设置 EtherCAT 类型轴的对应的转矩斜坡值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxTorqSlope", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxTorqSlope(Int16 cardIndex, Int16 axNo, UInt32 torqSlope);
- /// @brief 获取 EtherCAT 类型轴的对应的转矩斜坡值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxTorqSlope", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxTorqSlope(Int16 cardIndex, Int16 axNo, ref UInt32 pTorqSlope);
- /// @brief 设置 EtherCAT 类型轴的对应的目标转矩
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxTgtTorq", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxTgtTorq(Int16 cardIndex, Int16 axNo, Int16 tgtTorq);
- /// @brief 获取 EtherCAT 类型轴的对应的目标转矩
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxTgtTorq", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxTgtTorq(Int16 cardIndex, Int16 axNo, ref Int16 pTgtTorq);
- #endregion
- ///@defgroup EcatAxisCapt EcatAxisCapt
- ///@brief 板卡ECAT轴捕获功能功能
- #region EcatAxisCapt
- /// @brief 设置 EtherCAT 类型轴的位置捕获类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxCapt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxCapt(Int16 cardIndex, Int16 axNo, Int16 trigType, Int16 edge);
- /// @brief 获取 EtherCAT 类型轴的位置捕获类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxCapt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxCapt(Int16 cardIndex, Int16 axNo, ref Int16 pTrigType, ref Int16 pEdge);
- /// @brief 获取 EtherCAT 类型轴的位置捕获状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxCaptStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxCaptStatus(Int16 cardIndex, Int16 axNo, ref Int16 pSts, ref Int32 pPosVal, ref Int32 pNegVal);
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxProbeFun", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxProbeFun(Int16 cardIndex, Int16 axNo, Int16 probeFun);
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxProbeFun", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxProbeFun(Int16 cardIndex, Int16 axNo, ref Int16 pProbeFun);
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxProbeSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxProbeContinousCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxProbeContinousCount(Int16 cardIndex, Int16 axNo, Int16[] pCountArray);
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxProbeContinousCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxProbeContinousCount(Int16 cardIndex, Int16 axNo, Int16[] pCountArray, Int16[] pTrigArray, Int16[] pRestArray);
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxProbeContinousData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxProbeContinousData(Int16 cardIndex, Int16 axNo, Int16 probeType, Int32[] pPosArray, Int16 count);
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxProbeContinousTable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxProbeContinousTable(Int16 cardIndex, Int16 axNo, Int16 tableIndex);
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxProbeContinousTable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxProbeContinousTable(Int16 cardIndex, Int16 axNo, ref Int16 pTableIndex);
- /// @brief 清除 EtherCAT 类型轴的连续位置捕获状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClrEcatAxCaptStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ClrEcatAxCaptStatus(Int16 cardIndex, Int16 axNo);
- #endregion
- #endregion
- ///@defgroup HEcatFunc HEcatFunc
- ///@brief H主站函数
- #region HEcatFunc
- ///@defgroup H-MasterCfg H-MasterCfg
- ///@brief H主站系统配置函数
- #region H
- /// @brief 获取板卡的CPU负载
- /// @warning 建议负载率不要超过60%
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetCalcLoadRatio", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetCalcLoadRatio(Int16 cardIndex, ref double pLoadRatio);
- /// @brief 复位控制卡系统参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_ResetSysPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_ResetSysPara(Int16 cardIndex);
- #endregion
- ///@defgroup H-EtherCAT H-EtherCAT
- ///@brief 板卡H主站功能
- #region H
- /// @brief 初始化板卡通讯, 主站进入OP状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_InitEcatComm", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_InitEcatComm(Int16 cardIndex);
- /// @brief 开启板卡通讯, 初始化EtherCAT总线资源, 建立主站与各从站之间的通讯
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_StartEcatComm", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_StartEcatComm(Int16 cardIndex);
- /// @brief 关闭板卡通讯, 主站退出OP状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_DelEcatComm", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_DelEcatComm(Int16 cardIndex);
- /// @brief 初始化总线, 直到主站进入OP状态, 随后扫描EtherCAT总线资源, 并建立主站与各从站之间的通讯 (该函数会阻塞在EtherCAT的总线扫描同步阶段)
- /// @warning 该指令阻塞执行
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_ScanCardEcat", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_ScanCardEcat(Int16 cardIndex, Int16 waitTime = 40);
- /// @brief 获取EtherCAT主站的状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatMasterSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatMasterSts(Int16 cardIndex, ref UInt32 pStatus);
- /// @brief 获取EtherCAT协议栈通讯错误码
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatErrCode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatErrCode(Int16 cardIndex, ref UInt32 pErrCode);
- /// @brief 获取EtherCAT主站的状态,Ex指令
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatMasterStsEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatMasterStsEx(Int16 cardIndex, ref UInt32 pStatus);
- /// @brief 获取EtherCAT协议栈通讯错误码,Ex指令
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatErrCodeEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatErrCodeEx(Int16 cardIndex, ref UInt32 pErrCode);
- /// @brief 获取EtherCAT从站当前通讯阶段, INIT, PerOP, SafeOP, OP
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatSlaveSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatSlaveSts(Int16 cardIndex, Int16 slave, ref Int16 pCurStatus, ref Int16 pReqStatus, ref Int16 pErrCode);
- /// @brief 获取EtherCAT主站信息(包含通讯周期, 从站个数, 资源数量等)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatMasterInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatMasterInfo(Int16 cardIndex, ref TMasterInfo ptMasterInfo);
- /// @brief 获取EtherCAT从站信息(包含设备类型, 对应轴号, 从站别名等)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatSlaveInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatSlaveInfo(Int16 cardIndex, Int16 slave, ref TSlaveInfo ptSlaveInfo);
- /// @brief 根据站号读取EtherCAT从站的PDO数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatSlavePdoData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatSlavePdoData(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData);
- /// @brief 根据站号写入EtherCAT从站的PDO数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatSlavePdoData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_SetEcatSlavePdoData(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData);
- /// @brief 根据站号获取EtherCAT从站的SDO数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatSlaveSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 根据站号写入EtherCAT从站的SDO数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatSlaveSdo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_SetEcatSlaveSdo(Int16 cardIndex, Int16 slave, UInt16 index, UInt16 subIndex, Byte[] pData, UInt32 dataSize, ref UInt32 pAbortCode);
- /// @brief 获取EtherCAT的DI输入状态, 按16bits为一组进行获取
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatDi(Int16 cardIndex, Int16 packIndex, UInt16[] pValue, Int16 packCnt);
- /// @brief 设置EtherCAT的DO输出状态, 按16bits为一组进行设置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_SetEcatDo(Int16 cardIndex, Int16 packIndex, UInt16[] pValue, Int16 packCnt);
- /// @brief 获取EtherCAT的DO输出状态, 按16bits为一组进行获取
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatDo(Int16 cardIndex, Int16 packIndex, UInt16[] pValue, Int16 packCnt);
- /// @brief 获取EtherCAT的DI输入状态, 按位进行获取
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatDiBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatDiBit(Int16 cardIndex, Int16 diIndex, ref Int16 pValue);
- /// @brief 获取EtherCAT的DO输出状态, 按位进行获取
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatDoBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatDoBit(Int16 cardIndex, Int16 doIndex, ref Int16 pValue);
- /// @brief 设置EtherCAT的DO输出状态, 按位进行设置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatDoBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_SetEcatDoBit(Int16 cardIndex, Int16 doIndex, Int16 value);
- /// @brief 根据通道号获取EtherCAT对应通道的AD值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatAdVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatAdVal(Int16 cardIndex, Int16 adIndex, ref Int16 pValue);
- /// @brief 根据通道号设置EtherCAT对应通道的DA值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatDaVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_SetEcatDaVal(Int16 cardIndex, Int16 daIndex, Int16 Value);
- /// @brief 根据通道号获取EtherCAT对应通道的DA值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatDaVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatDaVal(Int16 cardIndex, Int16 daIndex, ref Int16 pValue);
- /// @brief 根据通道号获取EtherCAT对应通道的RegIn值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatRegInVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatRegInVal(Int16 cardIndex, Int16 regIndex, ref float pValue);
- /// @brief 根据通道号设置EtherCAT对应通道的RegOut值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatRegOutVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_SetEcatRegOutVal(Int16 cardIndex, Int16 regIndex, float Value);
- /// @brief 根据通道号获取EtherCAT对应通道的RegOut值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatRegOutVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatRegOutVal(Int16 cardIndex, Int16 regIndex, ref float pValue);
- /// @brief 根据通道号获取EtherCAT对应通道的AD值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatAd", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatAd(Int16 cardIndex, Int16 adIndex, Int16[] pValueArray, Int16 count);
- /// @brief 根据通道号设置EtherCAT对应通道的DA值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatDa", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_SetEcatDa(Int16 cardIndex, Int16 daIndex, Int16[] pValueArray, Int16 count);
- /// @brief 根据通道号获取EtherCAT对应通道的DA值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatDa", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatDa(Int16 cardIndex, Int16 daIndex, Int16[] pValueArray, Int16 count);
- /// @brief 根据通道号获取EtherCAT对应通道的RegIn值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatRegIn", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatRegIn(Int16 cardIndex, Int16 regIndex, float[] pValueArray, Int16 count);
- /// @brief 根据通道号设置EtherCAT对应通道的RegOut值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_SetEcatRegOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_SetEcatRegOut(Int16 cardIndex, Int16 regIndex, float[] pValueArray, Int16 count);
- /// @brief 根据通道号获取EtherCAT对应通道的RegOut值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_H_GetEcatRegOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_H_GetEcatRegOut(Int16 cardIndex, Int16 regIndex, float[] pValueArray, Int16 count);
- #endregion
- #endregion
- ///@defgroup LocalBus LocalBus
- ///@brief 板卡端子板功能
- #region LocalBus
- ///@defgroup LocalInfo LocalInfo
- ///@brief 板卡端子板信息获取
- #region LocalInfo
- /// @brief 获取端子板的工作状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalBoardWorkSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalBoardWorkSts(Int16 cardIndex, ref Int16 pValue);
- #endregion
- ///@defgroup LocalParam LocalParam
- ///@brief 板卡端子板参数设置
- #region LocalParam
- /// @brief 设置端子板 DI 滤波时间
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalDiFilterTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalDiFilterTime(Int16 cardIndex, UInt16 filterTime);
- /// @brief 读取端子板 DI 滤波时间
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalDiFilterTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalDiFilterTime(Int16 cardIndex, ref UInt16 pFilterTime);
- /// @brief 设置端子板编码器滤波参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalEncFilterPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalEncFilterPara(Int16 cardIndex, Int16 filterDepth, Int16 filterCoef);
- /// @brief 读取端子板编码器滤波参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalEncFilterPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalEncFilterPara(Int16 cardIndex, ref Int16 pFilterDepth, ref Int16 pFilterCoef);
- /// @brief 设置端子板编码器计数方向
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalEncDir", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalEncDir(Int16 cardIndex, Int16 encIndex, Int16[] pDirArray, Int16 count = 1);
- /// @brief 读取端子板编码器计数方向
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalEncDir", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalEncDir(Int16 cardIndex, Int16 encIndex, Int16[] pDirArray, Int16 count = 1);
- #endregion
- ///@defgroup LocalDIO LocalDIO
- ///@brief 板卡端子板IO操作
- #region LocalDIO
- /// @brief 获取本地 DI 值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalDi(Int16 cardIndex, ref Int16 pValue);
- /// @brief 设置本地 DO 值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalDo(Int16 cardIndex, Int16 value);
- /// @brief 读取本地 DO 值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalDo(Int16 cardIndex, ref Int16 pValue);
- #endregion
- /// @brief 按位获取本地第 diIndex 个 DI 值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalDiBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalDiBit(Int16 cardIndex, Int16 diIndex, ref Int16 pValue);
- /// @brief 按位设置本地第 doIndex 个 DO 值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalDoBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalDoBit(Int16 cardIndex, Int16 doIndex, Int16 value);
- /// @brief 按位设置本地第 doIndex 个 DO 值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalDoBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalDoBit(Int16 cardIndex, Int16 doIndex, ref Int16 pValue);
- /// @brief 按位脉冲输出本地第 doIndex 个 DO
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalDoBitPulse", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalDoBitPulse(Int16 cardIndex, Int16 doIndex, Int16 enable, UInt16 highLevelTime, UInt16 lowLevelTime, Int16 pulseNum, Int16 firstLevel);
- ///@defgroup LocalEnc LocalEnc
- ///@brief 板卡端子板编码器操作
- #region LocalEnc
- /// @brief 设置编码器值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalEncPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalEncPos(Int16 cardIndex, Int16 encIndex, Int32 encPos);
- /// @brief 读取编码器值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalEncPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalEncPos(Int16 cardIndex, Int16 encIndex, Int32[] pEncPosArray, Int16 count = 1);
- /// @brief 读取编码器速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalEncVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalEncVel(Int16 cardIndex, Int16 encIndex, Int32[] pEncVelArray, Int16 count = 1);
- #endregion
- ///@defgroup LocalCapt LocalCapt
- ///@brief 板卡端子板捕获功能
- #region LocalCapt
- /// @brief 设置端子板编码器位置捕获模式, 配置捕获参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCaptMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalCaptMode(Int16 cardIndex, Int16 encIndex, Int16 trigType, Int16 edge);
- /// @brief 获取端子板编码器位置捕获模式配置参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCaptMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalCaptMode(Int16 cardIndex, Int16 encIndex, ref Int16 pTrigType, ref Int16 pEdge);
- /// @brief 获取端子板编码器位置捕获状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCaptStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalCaptStatus(Int16 cardIndex, Int16 encIndex, ref Int16 pSts, ref Int32 pPosVal, ref Int32 pNegVal);
- /// @brief 设置端子板编码器连续位置捕获模式, 配置连续捕获参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCaptRepeatMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalCaptRepeatMode(Int16 cardIndex, Int16 encIndex, Int16 trigType, Int16 edge, Int16 captCount);
- /// @brief 设置端子板编码器连续位置捕获模式配置参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCaptRepeatMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalCaptRepeatMode(Int16 cardIndex, Int16 encIndex, ref Int16 pTrigType, ref Int16 pEdge, ref Int16 pCaptCount);
- /// @brief 获取端子板编码器连续位置捕获状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCaptRepeatStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalCaptRepeatStatus(Int16 cardIndex, Int16 encIndex, ref Int16 pCaptSts, ref Int16 pCaptCount);
- /// @brief 获取端子板编码器连续位置捕获位置
- /// @attention 双沿沿捕获时, 开辟存储数组长度应为 IMC_SetLocalCaptRepeatMode 设置 的 captCount 的 2 倍
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCaptRepeatPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalCaptRepeatPos(Int16 cardIndex, Int16 encIndex, Int16 startNo, Int16 count, Int32[] pCaptPosArray);
- #endregion
- ///@defgroup LocalPWM LocalPWM
- ///@brief 板卡端子板PWM功能
- #region LocalPWM
- /// @brief 设置端子板PWM的输出参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalPwmPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalPwmPara(Int16 cardIndex, Int16 chn, Int32 frequency, double dutyRatio);
- /// @brief 获取端子板PWM的输出参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalPwmPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalPwmPara(Int16 cardIndex, Int16 chn, ref Int32 pFrequency, ref double pDutyRatio);
- /// @brief 设置端子板PWM的输出频率
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalPwmFrq", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalPwmFrq(Int16 cardIndex, Int16 chn, Int32 frequency);
- /// @brief 设置端子板PWM的输出占空比
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalPwmDuty", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalPwmDuty(Int16 cardIndex, Int16 chn, double dutyRatio);
- /// @brief 设置端子板PWM输出的开关及延时时间
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalPwmOnOffDelay", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalPwmOnOffDelay(Int16 cardIndex, Int16 chn, Int16 onOff, UInt16 delay);
- #endregion
- ///@defgroup LocalCompare LocalCompare
- ///@brief 板卡端子板位置比较功能
- #region LocalCompare
- /// @brief 设置端子板位置比较输出源的配置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpSrcCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalCmpSrcCfg(Int16 cardIndex, Int16 chn, Int16 compSrc);
- /// @brief 设置端子板比较物理信号输出的配置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpOutputCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalCmpOutputCfg(Int16 cardIndex, Int16 chn, Int16 ctrlMode, Int16 stLevel, Int16 outputType, UInt16 pulseWidth);
- /// @brief 设置端子板比较数据的类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpDataType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalCmpDataType(Int16 cardIndex, Int16 chn, Int16 type);
- /// @brief 获取端子板比较数据的类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCmpDataType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalCmpDataType(Int16 cardIndex, Int16 chn, ref Int16 pType);
- /// @brief 设置端子板位置比较的位置类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpPosType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalCmpPosType(Int16 cardIndex, Int16 chn, Int16 type);
- /// @brief 获取端子板位置比较的位置类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCmpPosType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalCmpPosType(Int16 cardIndex, Int16 chn, ref Int16 pType);
- /// @brief 设置本地输出 EX-O bit0 ~ 3 位位置比较输出类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalGpoType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalGpoType(Int16 cardIndex, Int16 doIndex, Int16 type);
- /// @brief 获取本地输出 EX-O bit0 ~ 3 位位置比较输出类型配置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalGpoType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalGpoType(Int16 cardIndex, Int16 doIndex, ref Int16 pType);
- /// @brief 获取端子板位置比较的状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalCmpSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalCmpSts(Int16 cardIndex, Int16 chn, ref Int16 pCmpSts, ref Int32 pCmpCount);
- /// @brief 设置端子板手动输出脉冲或电平
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpManualOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalCmpManualOut(Int16 cardIndex, Int16 chn, Int16 outval);
- /// @brief 设置端子板多脉冲手动输出
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpManualMultiOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalCmpManualMultiOut(Int16 cardIndex, Int16 chn, UInt16 pulseNum, UInt16 pulseCycle);
- /// @brief 设置端子板等间距线性比较输出
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpLinearOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalCmpLinearOut(Int16 cardIndex, Int16 chn, Int32 intrvalLen, Int32 cmpCount);
- /// @brief 停止端子板比较输出
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopLocalCmpOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StopLocalCmpOut(Int16 cardIndex, Int16 chn);
- /// @brief 启动端子板比较输出
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartLocalCmpOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartLocalCmpOut(Int16 cardIndex, Int16 chn);
- /// @brief 设置端子板一维位置比较输出数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalCmpData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalCmpData(Int16 cardIndex, Int16 chn, Int16 compCount, Int32[] pPosBufArray);
- #endregion
- ///@defgroup LocalMultCompare LocalMultCompare
- ///@brief 板卡端子板多维位置比较功能
- #region LocalMultCompare
- /// @brief 设置端子板位置比较输出源的配置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalMultiCmpSrcCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalMultiCmpSrcCfg(Int16 cardIndex, Int16 chn, Int16 dimension, Int16[] pCompSrcArray);
- /// @brief 设置端子板比较物理信号输出的配置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalMultiCmpOutputCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalMultiCmpOutputCfg(Int16 cardIndex, Int16 chn, Int16 stLevel, Int16 outputType, UInt16 pulseWidth);
- /// @brief 获取端子板位置比较的状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalMultiCmpSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalMultiCmpSts(Int16 cardIndex, Int16 chn, ref Int16 pCmpSts, ref Int32 pCmpCount);
- /// @brief 设置端子板比较数据的类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalMultiCmpDataType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalMultiCmpDataType(Int16 cardIndex, Int16 chn, Int16 type);
- /// @brief 获取端子板比较数据的类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalMultiCmpDataType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalMultiCmpDataType(Int16 cardIndex, Int16 chn, ref Int16 pType);
- /// @brief 设置端子板多维位置比较参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalMultiCmpPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalMultiCmpPara(Int16 cardIndex, Int16 chn, UInt16 syncDeltaPos, Int16 outPinType);
- /// @brief 获取端子板多维位置比较参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalMultiCmpPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalMultiCmpPara(Int16 cardIndex, Int16 chn, ref UInt16 pSyncDeltaPos, ref Int16 pOutPinType);
- /// @brief 设置多维比较位置点
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalMultiCmpData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalMultiCmpData(Int16 cardIndex, Int16 chn, TMultiCmpData[] pComparaDataArray, Int16 count);
- /// @brief 启动端子板比较输出
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartLocalMultiCmpOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartLocalMultiCmpOut(Int16 cardIndex, Int16 chn);
- /// @brief 停止端子板比较输出
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopLocalMultiCmpOut", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StopLocalMultiCmpOut(Int16 cardIndex, Int16 chn);
- #endregion
- ///@defgroup LocalPSO LocalPSO
- ///@brief 板卡端子板PSO功能
- #region LocalPSO
- /// @brief 设置端子板PSO功能参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalPSOPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalPSOPara(Int16 cardIndex, Int16 chn, Int16 dimension, Int16 pinType, Int16[] pPsoPosIndexArray, UInt16 outPlsWidth, Int32 syncDeltaPos);
- /// @brief 获取端子板PSO功能参数配置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalPSOPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalPSOPara(Int16 cardIndex, Int16 chn, ref Int16 pDimension, ref Int16 pPinType, Int16[] pPsoPosIndexArray, ref UInt16 pOutPlsWidth, ref Int32 pSyncDeltaPos);
- /// @brief 设置PSO基频
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetLocalPSOBaseFrq", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetLocalPSOBaseFrq(Int16 cardIndex, Int16 chn, Int16 baseFrq);
- /// @brief 获取PSO基频
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalPSOBaseFrq", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalPSOBaseFrq(Int16 cardIndex, Int16 chn, ref Int16 pBaseFrq);
- /// @brief 启动PSO输出
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartLocalPSO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartLocalPSO(Int16 cardIndex, Int16 chn);
- /// @brief 停止PSO输出
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopLocalPSO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StopLocalPSO(Int16 cardIndex, Int16 chn);
- /// @brief 获取PSO输出状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetLocalPSOSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetLocalPSOSts(Int16 cardIndex, Int16 chn, ref Int16 pSts, ref UInt16 pPsoCount);
- #endregion
- #endregion
- ///@defgroup Axis Axis
- ///@brief 板卡轴操作相关函数
- #region Axis
- ///@defgroup AxisConfig AxisConfig
- ///@brief 板卡轴配置函数
- #region AxisConfig
- /// @brief 设置轴激活状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxActive", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxActive(Int16 cardIndex, Int16 axNo, Int16 active);
- /// @brief 读取轴激活状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxActive", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxActive(Int16 cardIndex, Int16 axNo, ref Int16 pActive);
- /// @brief 设置控制器单轴安全运行参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxMaxMtPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxMaxMtPara(Int16 cardIndex, Int16 axNo, ref TMtPara pMtPara);
- /// @brief 读取控制器单轴安全运行参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxMaxMtPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxMaxMtPara(Int16 cardIndex, Int16 axNo, ref TMtPara pMtPara);
- /// @brief 设置轴当量参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxEquiv", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxEquiv(Int16 cardIndex, Int16 axNo, double[] pAxEquArray, Int16 count = 1);
- /// @brief 获取轴当量参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEquiv", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxEquiv(Int16 cardIndex, Int16 axNo, double[] pAxEquArray, Int16 count = 1);
- /// @brief 设置轴输出绑定
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxBondCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxBondCfg(Int16 cardIndex, Int16 axNo, Int16 axType, Int16 outputChn);
- /// @brief 获取轴输出绑定
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxBondCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxBondCfg(Int16 cardIndex, Int16 axNo, ref Int16 pAxType, ref Int16 pOutputChn);
- /// @brief 复位轴绑定状态, 让所有轴恢复到虚轴状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ResetAxBondCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ResetAxBondCfg(Int16 cardIndex);
- /// @brief 设置轴属性参数, 包含软限位、到位误差、最大跟随误差
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxAttriPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxAttriPara(Int16 cardIndex, Int16 axNo, ref TAxAttriPara pAxAttriPara);
- /// @brief 获取轴属性参数, 包含软限位、到位误差、最大跟随误差
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxAttriPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxAttriPara(Int16 cardIndex, Int16 axNo, ref TAxAttriPara pAxAttriPara);
- /// @brief 设置轴软限位
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxSoftLimit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxSoftLimit(Int16 cardIndex, Int16 axNo, Int32 positive, Int32 negative);
- /// @brief 获取轴软限位
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxSoftLimit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxSoftLimit(Int16 cardIndex, Int16 axNo, ref Int32 pPositive, ref Int32 pNegative);
- /// @brief 设置轴到位检查参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxArrivalBand", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxArrivalBand(Int16 cardIndex, Int16 axNo, Int16 arrivalBand, UInt16 arrivalTime);
- /// @brief 获取轴到位检查参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxArrivalBand", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxArrivalBand(Int16 cardIndex, Int16 axNo, ref Int16 pArrivalBand, ref UInt16 pArrivalTime);
- /// @brief 设置轴最大跟随误差
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxErrorPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxErrorPos(Int16 cardIndex, Int16 axNo, Int32 errorPos);
- /// @brief 获取轴最大跟随误差
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxErrorPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxErrorPos(Int16 cardIndex, Int16 axNo, ref Int32 pErrorPos);
- /// @brief 设置轴反向间隙补偿
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxBacklash", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxBacklash(Int16 cardIndex, Int16 axNo, Int32 wholeCmpVal, Int32 cmpVel, Int16 cmpDir);
- /// @brief 获取轴反向间隙补偿
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxBacklash", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxBacklash(Int16 cardIndex, Int16 axNo, ref Int32 pWholeCmpVal, ref Int32 pCmpVel, ref Int16 pCmpDir);
- /// @brief 设置轴安全检查使能综合配置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxSafeCheck", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxSafeCheck(Int16 cardIndex, Int16 axNo, ref TAxCheckEn pAxCheckEn);
- /// @brief 获取轴安全检查使能综合配置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxSafeCheck", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxSafeCheck(Int16 cardIndex, Int16 axNo, ref TAxCheckEn pAxCheckEn);
- /// @brief 设置轴报警检查使能配置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxAlarmCheck", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxAlarmCheck(Int16 cardIndex, Int16 axNo, Int16 enable, Int16 count = 1);
- /// @brief 设置轴软限位检查使能配置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxSoftLmtsCheck", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxSoftLmtsCheck(Int16 cardIndex, Int16 axNo, Int16 enable, Int16 count = 1);
- /// @brief 设置轴硬限位检查使能配置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetHwLmtsCheck", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetHwLmtsCheck(Int16 cardIndex, Int16 axNo, Int16 enable, Int16 count = 1);
- /// @brief 设置轴跟随误差位检查使能配置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxErrPosCheck", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxErrPosCheck(Int16 cardIndex, Int16 axNo, Int16 enable, Int16 count = 1);
- /// @brief 设定轴停止的平滑停止减速度和急停减速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxStopDec", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxStopDec(Int16 cardIndex, Int16 axNo, double decSmoothStop, double decAbruptStop);
- /// @brief 获取轴停止的平滑停止减速度和急停减速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxStopDec", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxStopDec(Int16 cardIndex, Int16 axNo, ref double pDecSmoothStop, ref double pDecAbruptStop);
- /// @brief 设定轴急停减速限制时间
- /// @details 急停时根据当前速度和设定的急停减速度计算停止时间, 若超过设定的限制时间, 则按照当前限制时间重新计算减速度, 否则按照设定的减速度执行
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxEmgMaxDecLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxEmgMaxDecLmt(Int16 cardIndex, Int16 axNo, UInt16 decLmtTime);
- /// @brief 获取轴急停减速限制时间
- /// @details 急停时根据当前速度和设定的急停减速度计算停止时间, 若超过设定的限制时间, 则按照当前限制时间重新计算加速度, 否则按照设定的加速度执行
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEmgMaxDecLmt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxEmgMaxDecLmt(Int16 cardIndex, Int16 axNo, ref UInt16 pDecLmtTime);
- /// @brief 设置轴的结束速度
- /// @details 点位运动时,运动规划结束速度可以不为0,注意合理设置结束速度值,运动规划完成后,结束速度直接突跳速度为0,可能引起机台抖动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxEndVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxEndVel(Int16 cardIndex, Int16 axNo, double endVel);
- /// @brief 获取轴的结束速度设定
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEndVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxEndVel(Int16 cardIndex, Int16 axNo, ref double pEndVel);
- /// @brief 设置圆形软限位参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ArcZoneLmtSetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ArcZoneLmtSetParam(Int16 cardIndex, Int16[] pAxNoArray, Int32[] pCenterArray, Int32 radius, Int16 sourceType);
- /// @brief 获取圆形软限位参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ArcZoneLmtGetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ArcZoneLmtGetParam(Int16 cardIndex, Int16[] pAxNoArray, Int32[] pCenterArray, ref Int32 pRadius, ref Int16 pSourceType);
- /// @brief 使能圆形软限位
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ArcZoneLmtEnable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ArcZoneLmtEnable(Int16 cardIndex, Int16 enable);
- /// @brief 设置分段软限位参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SegLmtSetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SegLmtSetParam(Int16 cardIndex, Int16[] pAxNoArray, Int16 sourceType, Int32[] pPointXArray, Int32[] pPointYArray, Int16 pointCount, Int16 yLmtDir);
- /// @brief 获取分段软限位参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SegLmtGetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SegLmtGetParam(Int16 cardIndex, Int16[] pAxNoArray, ref Int16 pSourceType, Int32[] pPointXArray, Int32[] pPointYArray, ref Int16 pPointCount, ref Int16 pYLmtDir);
- /// @brief 使能分段软限位
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SegLmtEnable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SegLmtEnable(Int16 cardIndex, Int16 enable);
- #endregion
- ///@defgroup AxisStatus AxisStatus
- ///@brief 轴状态监控
- #region AxisStatus
- /// @brief 获取轴规划模式, 该值中包含单轴模式和多轴模式的信息
- /// @todo 是否取消单轴多轴状态分区, 底层需要做修改
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxPrfMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxPrfMode(Int16 cardIndex, Int16 axNo, Int16[] pPrfModeArray, Int16 count = 1);
- /// @brief 获取轴状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxSts(Int16 cardIndex, Int16 axNo, Int32[] pAxStsArray, Int16 count = 1);
- /// @brief 清除轴的错误状态, 当发生报警时, 需要调用该指令进行清除, 但如果实际物理报警还在, 则无法清除
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClrAxSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ClrAxSts(Int16 cardIndex, Int16 axNo, Int16 count = 1);
- /// @brief 获取轴规划位置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxPrfPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxPrfPos(Int16 cardIndex, Int16 axNo, double[] pPrfPosArray, Int16 count = 1);
- /// @brief 获取轴规划速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxPrfVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxPrfVel(Int16 cardIndex, Int16 axNo, double[] pPrfVelArray, Int16 count = 1);
- /// @brief 获取轴规划加速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxPrfAcc", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxPrfAcc(Int16 cardIndex, Int16 axNo, double[] pPrfAccArray, Int16 count = 1);
- /// @brief 获取轴编码器反馈位置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEncPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxEncPos(Int16 cardIndex, Int16 axNo, double[] pEncPosArray, Int16 count = 1);
- /// @brief 获取轴编码器反馈速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEncVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxEncVel(Int16 cardIndex, Int16 axNo, double[] pEncVelArray, Int16 count = 1);
- /// @brief 获取轴编码器反馈加速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEncAcc", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxEncAcc(Int16 cardIndex, Int16 axNo, double[] pEncAccArray, Int16 count = 1);
- /// @brief 获取指定轴是否均已到位的状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetMultiAxArrivalSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetMultiAxArrivalSts(Int16 cardIndex, UInt32 axMask, ref Int16 pSts, Int16 groupNo);
- /// @brief 获取轴反向间隙差值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxBacklashCmpVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxBacklashCmpVal(Int16 cardIndex, Int16 axNo, ref Int32 pCmpVal);
- /// @brief 获取轴规划位置(32位整形指令)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxPrfPos32", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxPrfPos32(Int16 cardIndex, Int16 axNo, Int32[] pPrfPosArray, Int16 count = 1);
- /// @brief 获取轴编码器反馈位置(32位整形指令)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEncPos32", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxEncPos32(Int16 cardIndex, Int16 axNo, Int32[] pEncPosArray, Int16 count = 1);
- /// @brief 获取轴规划位置(脉冲位置指令)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPrfPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPrfPos(Int16 cardIndex, Int16 axNo, double[] pPrfPosArray, Int16 count = 1);
- /// @brief 获取轴编码器原点位置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxOrgEncPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxOrgEncPos(Int16 cardIndex, Int16 axNo, Int32[] pOrgEncPosArray, Int16 count = 1);
- /// @brief 获取轴停止原因
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxStopReason", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxStopReason(Int16 cardIndex, Int16 axNo, Int16[] pAxStopReason, Int16 count = 1);
- /// @brief 获取轴状态(Ex指令)
- /// @todo 补充ex类型指令描述
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxStsEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxStsEx(Int16 cardIndex, Int16 axNo, Int32[] pAxStsArray, Int16 count = 1);
- /// @brief 获取轴规划位置(Ex指令)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxPrfPosEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxPrfPosEx(Int16 cardIndex, Int16 axNo, double[] pPrfPosArray, Int16 count = 1);
- /// @brief 获取轴编码器反馈位置(Ex指令)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxEncPosEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxEncPosEx(Int16 cardIndex, Int16 axNo, double[] pEncPosArray, Int16 count = 1);
- /// @brief 获取 EtherCAT 类型轴的实际转矩, 根据count值可一次获取多个轴的扭矩(Ex类型指令)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxActTorqEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxActTorqEx(Int16 cardIndex, Int16 axNo, Int16[] pActTorqArray, Int16 count = 1);
- #endregion
- ///@defgroup AxisControl AxisControl
- ///@brief 轴功能控制
- #region AxisControl
- /// @brief 使能伺服
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ServoOn", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ServoOn(Int16 cardIndex, Int16 axNo, Int16 count = 1);
- /// @brief 关闭伺服
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ServoOff", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ServoOff(Int16 cardIndex, Int16 axNo, Int16 count = 1);
- /// @brief 停止单轴轴运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StopMove(Int16 cardIndex, Int16 axNo, Int16 stopType);
- /// @brief 按位停止单轴轴运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopMoveBits", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StopMoveBits(Int16 cardIndex, UInt32 axMask, UInt32 stopTypeBits);
- /// @brief 设置轴的触发停止参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxStopTrigPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxStopTrigPara(Int16 cardIndex, Int16 axNo, Int16 uselessFlag, Int16 bitNo, Int16 stopType, Int16 diType);
- /// @brief 获取轴的触发停止参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxStopTrigPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxStopTrigPara(Int16 cardIndex, Int16 axNo, ref Int16 pUselessFlag, ref Int16 pBitNo, ref Int16 pStopType, ref Int16 pDiType);
- /// @brief 设置当前轴位置为用户指定位置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxCurPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxCurPos(Int16 cardIndex, Int16 axNo, double setPos);
- /// @brief 同步轴位置, 将轴的规划位置与编码器位置同步
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SyncAxPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SyncAxPos(Int16 cardIndex, Int16 axNo);
- #endregion
- #endregion
- ///@defgroup MotionControl MotionControl
- ///@brief 板卡运动模式
- #region MotionControl
- ///@defgroup MotionPara MotionPara
- ///@brief 全局运动参数相关接口
- #region MotionPara
- /// @brief 设置单轴运动参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxMvPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxMvPara(Int16 cardIndex, Int16 axNo, double vel, double acc, double dec);
- /// @brief 获取单轴运动参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxMvPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxMvPara(Int16 cardIndex, Int16 axNo, ref double pVel, ref double pAcc, ref double pDec);
- /// @brief 设定单轴速度规划类型
- /// @details ratio 越大, 则 S 越接近 T 型速度规划, 冲击也越大; 反之, ratio 越小, 则规划越平顺, 冲击越小
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxVelType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxVelType(Int16 cardIndex, Int16 axNo, Int16 velType, double ratio);
- /// @brief 获取单轴速度规划类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxVelType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxVelType(Int16 cardIndex, Int16 axNo, ref Int16 pVelType, ref double pRatio);
- #endregion
- ///@defgroup BasicMotion BasicMotion
- ///@brief 基础运动功能
- #region BasicMotion
- ///@defgroup EcatAxisHoming EcatAxisHoming
- ///@brief 板卡ECAT轴402回零功能功能
- #region EcatAxisHoming
- /// @brief 设置EtherCAT类型轴402回零参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatHomingPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatHomingPara(Int16 cardIndex, Int16 axNo, Int16 method, UInt32 highVel, UInt32 lowVel, UInt32 acc, Int32 offset);
- /// @brief 将EtherCAT类型轴设置为回零模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatHomingMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatHomingMode(Int16 cardIndex, Int16 axNo);
- /// @brief 控制EtherCAT类型轴开始402回零
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartEcatHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartEcatHoming(Int16 cardIndex, Int16 axNo);
- /// @brief 控制EtherCAT类型轴停止402回零
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopEcatHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StopEcatHoming(Int16 cardIndex, Int16 axNo);
- /// @brief 控制EtherCAT类型轴退出回零模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ExitEcatHomingMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ExitEcatHomingMode(Int16 cardIndex, Int16 axNo);
- /// @brief 获取EtherCAT类型轴的402回零状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetHomingStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetHomingStatus(Int16 cardIndex, Int16 axNo, ref Int16 pStatus);
- /// @brief EtherCAT类型轴402回零合成函数, 包含设定回零参数, 切回零模式以及启动回零运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartHoming(Int16 cardIndex, Int16 axNo, ref THomingPara pHomingPara);
- /// @brief 完成402回零动作合成函数, 包含停止回零, 退出ecat回零模式, 暂默认切到CSP模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_FinishHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_FinishHoming(Int16 cardIndex, Int16 axNo);
- #endregion
- ///@defgroup EcatCSPHoming EcatCSPHoming
- ///@brief 板卡ECAT轴CSP模式规划回零功能功能
- #region EcatCSPHoming
- /// @brief 设置 CSP 模式下回原点中 DI 触发对应 0x60FD(digitalInput)中的 bit 位置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEcatAxProbeMaskBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEcatAxProbeMaskBit(Int16 cardIndex, Int16 axNo, Int16 prbDiBitNo);
- /// @brief 获取 CSP 模式下回原点中 DI 触发对应 0x60FD(digitalInput)中的 bit 位置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxProbeMaskBit", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxProbeMaskBit(Int16 cardIndex, Int16 axNo, ref Int16 pPrbDiBitNo);
- /// @brief 开始EtherCAT类型轴CSP模式规划回零
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartEcatAxCSPHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartEcatAxCSPHoming(Int16 cardIndex, Int16 axNo, Int16 method, Int16 dir, Int16 level, double hVel, double lVel, double acc, double offset);
- /// @brief 停止EtherCAT类型轴CSP模式规划回零
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopEcatAxCSPHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StopEcatAxCSPHoming(Int16 cardIndex, Int16 axNo, Int16 stopMode);
- /// @brief 获取EtherCAT类型轴CSP模式规划回零状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEcatAxCSPHomingSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEcatAxCSPHomingSts(Int16 cardIndex, Int16 axNo, ref Int16 pHomingMethod, ref Int16 pHomingState);
- /// @brief 完成EtherCAT类型轴CSP模式规划回零
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_FinishEcatAxCSPHoming", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_FinishEcatAxCSPHoming(Int16 cardIndex, Int16 axNo);
- #endregion
- ///@defgroup PTP PTP
- ///@brief PTP运动模式相关接口
- #region PTP
- /// @brief 启动单轴PTP运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartPtpMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartPtpMove(Int16 cardIndex, Int16 axNo, double tgtPos, Int16 posType = 0);
- /// @brief 启动多轴PTP的运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartMultiPtpMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartMultiPtpMove(Int16 cardIndex, Int16 axNum, Int16[] pAxNoArray, double[] pTgtPosArray, Int16[] pPosTypeArray);
- /// @brief 在线更新PTP目标位置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpTgtPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_UpdatePtpTgtPos(Int16 cardIndex, Int16 axNo, double tgtPos);
- /// @brief 获取PTP目标位置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtpTgtPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPtpTgtPos(Int16 cardIndex, Int16 axNo, ref double pTgtPos);
- /// @brief 在线更新PTP运动参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpMvPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_UpdatePtpMvPara(Int16 cardIndex, Int16 axNo, double tgtVel, double acc, double dec);
- /// @brief 在线更新PTP目标速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpTgtVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_UpdatePtpTgtVel(Int16 cardIndex, Int16 axNo, double tgtVel);
- /// @brief 切换PTP规划模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PtpPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_PtpPrf(Int16 cardIndex, Int16 axNo);
- #endregion
- ///@defgroup Jog Jog
- ///@brief Jog运动模式相关接口
- #region Jog
- /// @brief 启动单轴JOG运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartJogMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartJogMove(Int16 cardIndex, Int16 axNo, double tgVel);
- /// @brief 启动多轴JOG运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartMultiJogMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartMultiJogMove(Int16 cardIndex, Int16 axNum, Int16[] pAxNoArray, double[] pTgtVelArray);
- /// @brief 在线更新JOG目标速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdateJogTgtVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_UpdateJogTgtVel(Int16 cardIndex, Int16 axNo, double tgVel);
- /// @brief 在线更新JOG运动参数
- /// 注意:JOG规划减速度仅作用于JOG在线变速
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdateJogMvPara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_UpdateJogMvPara(Int16 cardIndex, Int16 axNo, double tgVel, double acc, double dec);
- /// @brief 切换JOG规划模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_JogPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_JogPrf(Int16 cardIndex, Int16 axNo);
- #endregion
- ///@defgroup PTPS PTPS
- ///@brief PTPS运动模式相关接口
- #region PTPS
- /// @brief 切换PTPS规划模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PrfPtps", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_PrfPtps(Int16 cardIndex, Int16 axNo);
- /// @brief 设置PTPS运动启动速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPtpsBeginVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetPtpsBeginVel(Int16 cardIndex, Int16 axNo, double beginVel);
- /// @brief 设置PTPS运动结束速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPtpsEndVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetPtpsEndVel(Int16 cardIndex, Int16 axNo, double endVel);
- /// @brief 设置PTPS运动参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPtpsMovePara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetPtpsMovePara(Int16 cardIndex, Int16 axNo, double tgVel, double acc, double dec);
- /// @brief 设置PTPS运动参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPtpsMoveParaEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetPtpsMoveParaEx(Int16 cardIndex, Int16 axNo, double tgtVel, double tgtAcc, double tgtDec, double prfAcc, double prfDec);
- /// @brief 启动单轴PTPS快速规划
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartPtpsMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartPtpsMove(Int16 cardIndex, Int16 axNo, double tgtPos, short posType);
- /// @brief 启动单轴PTPS软启动规划
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartPtpsMoveA", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartPtpsMoveA(Int16 cardIndex, Int16 axNo, double tgtPos, double startSlowPos, double startSlowVel, short posType);
- /// @brief 启动单轴PTPS软着陆规划
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartPtpsMoveD", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartPtpsMoveD(Int16 cardIndex, Int16 axNo, double tgtPos, double stopSlowPos, double stopSlowVel, short posType);
- /// @brief 启动单轴PTPS多段运动规划,可实现软启动及软着陆
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartPtpsMoveM", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartPtpsMoveM(Int16 cardIndex, Int16 axNo, double tgtPos, double startSlowPos, double startSlowVel, double stopSlowPos, double stopSlowVel, short posType);
- /// @brief 在线更新PTPS目标位置,无法实现软着陆
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpsMovePos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_UpdatePtpsMovePos(Int16 cardIndex, Int16 axNo, double tgtPos);
- /// @brief 在线更新PTPS目标速度,无法实现软着陆
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpsMoveVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_UpdatePtpsMoveVel(Int16 cardIndex, Int16 axNo, double tgtVel);
- /// @brief 在线更新PTPS运动参数,无法实现软着陆
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpsMovePara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_UpdatePtpsMovePara(Int16 cardIndex, Int16 axNo, double tgVel, double acc, double dec);
- /// @brief 在线更新PTPS软着陆规划,实现软着陆
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UpdatePtpsMoveD", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_UpdatePtpsMoveD(Int16 cardIndex, Int16 axNo, double tgtPos, double stopSlowPos, double stopSlowVel);
- /// @brief 获取PTPS运动启动速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtpsBeginVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPtpsBeginVel(Int16 cardIndex, Int16 axNo, ref double pBeginVel);
- /// @brief 获取PTPS运动结束速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtpsEndVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPtpsEndVel(Int16 cardIndex, Int16 axNo, ref double pEendVel);
- /// @brief 获取PTPS运动参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtpsMovePara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPtpsMovePara(Int16 cardIndex, Int16 axNo, ref double pTgtVel, ref double pAcc, ref double pDec);
- /// @brief 获取PTPS运动参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtpsMoveParaEx", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPtpsMoveParaEx(Int16 cardIndex, Int16 axNo, double pTgtVel, double pTgtAcc, double pTgtDec, double tPrfAcc, double tPrfDec);
- #endregion
- ///@defgroup Gear Gear
- ///@brief Gear运动模式相关接口
- #region Gear
- /// @brief 切换为电子齿轮模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GearPrf(Int16 cardIndex, Int16 axNo);
- /// @brief 设置电子齿轮参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearSetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GearSetParam(Int16 cardIndex, Int16 axNo, ref TGearParam pGearParam);
- /// @brief 获取电子齿轮参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearGetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GearGetParam(Int16 cardIndex, Int16 axNo, ref TGearParam pGearParam);
- /// @brief 启动电子齿轮运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GearStart(Int16 cardIndex, Int16 axNo);
- /// @brief 停止电子齿轮运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearStop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GearStop(Int16 cardIndex, Int16 axNo, Int16 stopType);
- /// @brief 获取电子齿轮状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearGetStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GearGetStatus(Int16 cardIndex, Int16 axNo, ref Int16 pStatus, ref Int16 pErr);
- /// @brief 更新电子齿轮比
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GearUpdateScale", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GearUpdateScale(Int16 cardIndex, Int16 axNo, Int32 masterScale, Int32 slaveScale, Int32 masterDis);
- #endregion
- ///@defgroup Pvt Pvt
- ///@brief Pvt运动模式相关接口
- #region Pvt
- /// @brief 切换为PVT模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_PvtPrf(Int16 cardIndex, Int16 axNo);
- /// @brief 选择PVT数据表
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtTableSelect", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_PvtTableSelect(Int16 cardIndex, Int16 axNo, Int16 tableId);
- /// @brief 启动PVT运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_PvtStart(Int16 cardIndex, Int16 axNum, Int16[] pAxArray);
- /// @brief 获取PVT状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtGetStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_PvtGetStatus(Int16 cardIndex, Int16 axNo, Int16[] pTableId, double[] pTime, Int16 count = 1);
- /// @brief 设置PVT循环
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtSetLoop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_PvtSetLoop(Int16 cardIndex, Int16 axNo, Int32 loop);
- /// @brief 获取PVT循环
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtGetLoop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_PvtGetLoop(Int16 cardIndex, Int16 axNo, ref Int32 pCurLoop, ref Int32 pLoop);
- /// @brief 向PVT的指定数据表传送PT数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtTablePt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_PvtTablePt(Int16 cardIndex, Int16 tableId, Int32 count, double[] P, double[] T);
- /// @brief 向PVT的指定数据表传送数据, 采用PVT描述方式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtTablePvt", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_PvtTablePvt(Int16 cardIndex, Int16 tableId, Int32 count, double[] P, double[] V, double[] T);
- /// @brief 向PVT的指定数据表传送数据, 采用Percent描述方式(1段Percent描述方式消耗1~3个缓存空间)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtTablePercent", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_PvtTablePercent(Int16 cardIndex, Int16 tableId, Int32 count, double[] P, double[] T, double[] percent, double startVel = 0);
- /// @brief 向PVT的指定数据表传送数据, 采用Complete描述方式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PvtTableComplete", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_PvtTableComplete(Int16 cardIndex, Int16 tableId, Int32 count, double[] P, double[] T, double startVel = 0, double endVel = 0);
- #endregion
- ///@defgroup Cam Cam
- ///@brief Cam运动模式相关接口
- #region Cam
- /// @brief 设置凸轮规划模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamPrf", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamPrf(Int16 cardIndex, Int16 axNo);
- /// @brief 凸轮参数设置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamSetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamSetParam(Int16 cardIndex, Int16 axNo, Int16 masterType, Int16 masterNo, Int16 dirMode = 0);
- /// @brief 凸轮参数获取
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamGetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamGetParam(Int16 cardIndex, Int16 axNo, ref Int16 pMasterType, ref Int16 pMasterNo, ref Int16 pDirMode);
- /// @brief 凸轮表选择
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableSelect", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamTableSelect(Int16 cardIndex, Int16 axNo, Int16 tableId);
- /// @brief 启动凸轮运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamStart(Int16 cardIndex, Int16 axNo);
- /// @brief 停止凸轮运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamStop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamStop(Int16 cardIndex, Int16 axNo, Int16 stopType);
- /// @brief 获取凸轮状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamGetStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamGetStatus(Int16 cardIndex, Int16 axNo, ref Int16 pStatus, ref Int16 pTableId, ref Int32 pCurUserID);
- /// @brief 获取凸轮在表中的主轴位置和从轴位置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamGetCurPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamGetCurPos(Int16 cardIndex, Int16 axNo, ref double pMasterPos, ref double pSlavePos);
- /// @brief 设置凸轮循环次数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamSetLoop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamSetLoop(Int16 cardIndex, Int16 axNo, UInt32 loop);
- /// @brief 获取凸轮循环次数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamGetLoop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamGetLoop(Int16 cardIndex, Int16 axNo, ref UInt32 pCurLoop, ref UInt32 pLoop);
- /// @brief 设置凸轮启动方式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamSetEvent", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamSetEvent(Int16 cardIndex, Int16 axNo, Int16 type, Int32 masterPos);
- /// @brief 获取凸轮启动方式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamGetEvent", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamGetEvent(Int16 cardIndex, Int16 axNo, ref Int16 pType, ref Int32 pMasterPos);
- /// @brief 主轴相位偏移(由速度参数指定)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamPhasing", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamPhasing(Int16 cardIndex, Int16 axNo, double phaseShift, double phaseVel, double phaseAcc, double phaseDec, Int16 phaseShiftType = 0);
- /// @brief 主轴相位偏移(指定主轴位移完成偏移)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamPhasingDist", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamPhasingDist(Int16 cardIndex, Int16 axNo, double phaseShift, double masterDist, double accDistRatio, double decDistRatio, Int16 phaseShiftType = 0);
- /// @brief 停止主轴相位偏移
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamStopPhasing", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamStopPhasing(Int16 cardIndex, Int16 axNo);
- /// @brief 获取主轴相位偏移状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamGetPhasing", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamGetPhasing(Int16 cardIndex, Int16 axNo, ref Int16 phasingSts, ref double pPhase, ref double pPhaseVel);
- /// @brief 清除凸轮表数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableClrData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamTableClrData(Int16 cardIndex, Int16 tableId);
- /// @brief 获取凸轮表剩余空间
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableGetSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamTableGetSpace(Int16 cardIndex, Int16 tableId, ref Int32 pSpace);
- /// @brief 重新分配凸轮表数量和大小(总深度为8*2048)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableResize", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamTableResize(Int16 cardIndex, Int16 tableNum);
- /// @brief 获取凸轮表数量和大小信息
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableGetInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamTableGetInfo(Int16 cardIndex, ref Int16 pTableNum, ref Int32 pTableSize);
- /// @brief 凸轮表数据压入指令-通用压入指令
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamTableData(Int16 cardIndex, Int16 tableId, Int32 count, Int16[] pCurveType, double[] pKeyPointParam, Int32[] pUserID = null);
- /// @brief 凸轮表获取关键点之间指定相位的位移
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CamTableGetDist", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CamTableGetDist(Int16 cardIndex, Int32 count, Int16[] pCurveType, double[] pKeyPointParam, double x, double[] pOutput);
- #endregion
- #endregion
- ///@defgroup AdvMotion AdvMotion
- ///@brief 高级运动功能
- #region AdvMotion
- ///@defgroup Crd Crd
- ///@brief Crd坐标系插补运动模式相关接口
- #region Crd
- /// @brief 创建插补坐标系, 配置坐标系插补参数
- /// @attention 注意!用户必须定义长度为 3 的数组进行传值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetMtSys", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetMtSys(Int16 cardIndex, Int16 crdNo, Int16[] pMaskAxNoArray, Int16 lookAheadLen, double estopDec);
- /// @brief 获取插补坐标系配置参数
- /// @attention 注意!用户必须定义长度为 3 的数组进行传值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetMtSysParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetMtSysParam(Int16 cardIndex, Int16 crdNo, Int16[] pMaskAxNoArray, ref Int16 pLookAheadLen, ref double pEstopDec);
- /// @brief 删除插补坐标系
- /// @attention 需对创建的坐标系进行删除, 否则接口报错
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdDeleteMtSys", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdDeleteMtSys(Int16 cardIndex, Int16 crdNo);
- /// @brief 设置插补坐标系高级参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetAdvParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetAdvParam(Int16 cardIndex, Int16 crdNo, ref TCrdAdvParam pCrdAdvParam);
- /// @brief 获取插补坐标系高级参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetAdvParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetAdvParam(Int16 cardIndex, Int16 crdNo, ref TCrdAdvParam pCrdAdvParam);
- /// @brief 插补运动指令用户模式下的运动段的始末速度设置
- /// @details 该指令主要用于用户规划模式下, 指定每段运动, 段的起始和段末的速度。一般情况下, 运动段的起始速度等于上一段的段末速度
- /// @todo 插补模式用户速度功能待完成, 速度参数范围待补充
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetUserVelPlan", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetUserVelPlan(Int16 cardIndex, Int16 crdNo, double uStartVel, double uEndVel);
- /// @brief 插补运动指令在用户规划模式下设置的运动段的始末速度的获取
- /// @todo 插补模式用户速度功能待完成, 速度参数范围待补充
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetUserVelPlan", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetUserVelPlan(Int16 cardIndex, Int16 crdNo, ref double pUStartVel, ref double pUEndVel);
- /// @brief 设置插补平滑参数。通过设置平滑等级和平滑精度, 使插补运动轨迹更平滑
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetSmoothParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetSmoothParam(Int16 cardIndex, Int16 crdNo, Int32 smoothLevel, double smoothTol);
- /// @brief 获取插补平滑参数。通过设置平滑等级和平滑精度, 使插补运动轨迹更平滑
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetSmoothParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetSmoothParam(Int16 cardIndex, Int16 crdNo, ref Int32 pSmoothLevel, ref double pSmoothTol);
- /// @brief 设置插补轨迹速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetTrajVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetTrajVel(Int16 cardIndex, Int16 crdNo, double tgtVel);
- /// @brief 获取插补轨迹速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetTrajVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetTrajVel(Int16 cardIndex, Int16 crdNo, ref double pTgtVel);
- /// @brief 设置插补轨迹加速度和减速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetTrajAccAndDec", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetTrajAccAndDec(Int16 cardIndex, Int16 crdNo, double tgtAcc, double tgtDec);
- /// @brief 获取插补轨迹加速度和减速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetTrajAccAndDec", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetTrajAccAndDec(Int16 cardIndex, Int16 crdNo, ref double pTgtAcc, ref double pTgtDec);
- /// @brief 设置插补强制规划末速度降为 0 标识
- /// @details 如果将强制规划末速度降为 0, 则下面所有线段末速度为 0
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetZeroFlag", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetZeroFlag(Int16 cardIndex, Int16 crdNo, Int16 ZeroFlag);
- /// @brief 获取插补强制规划末速度降为 0 标识
- /// @details 如果将强制规划末速度降为 0, 则下面所有线段末速度为 0
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetZeroFlag", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetZeroFlag(Int16 cardIndex, Int16 crdNo, ref Int16 pZeroFlag);
- /// @brief 设置插补运动指令的位置编程模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetIncMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetIncMode(Int16 cardIndex, Int16 crdNo, Int16 mode);
- /// @brief 获取插补运动指令的位置编程模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetIncMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetIncMode(Int16 cardIndex, Int16 crdNo, ref Int16 pMode);
- /// @brief 设置插补同步跟随轴的速度模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetFolVelMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetFolVelMode(Int16 cardIndex, Int16 crdNo, Int16 mode);
- /// @brief 获取插补同步跟随轴的速度模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetFolVelMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetFolVelMode(Int16 cardIndex, Int16 crdNo, ref Int16 pMode);
- /// @brief 设置插补运动指令的过渡精度
- /// @details 该指令属于高级参数指令, 只有在启动过渡模式才生效
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetTrajTol", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetTrajTol(Int16 cardIndex, Int16 crdNo, double tol);
- /// @brief 设置插补运动指令的拐弯系数。
- /// @details 该指令属于高级参数指令, 只有在启动过渡模式才生效, 该参数越 小, 在过渡拐弯时速度降至越低, 参数越大, 则拐弯速度越高, 默认参数为 1
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetTrajTurnCoef", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetTrajTurnCoef(Int16 cardIndex, Int16 crdNo, double turnCoef);
- /// @brief 三维直线插补运动
- /// @attention[]]pEndPosArray 应传入长度为 3 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdLineXYZ", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdLineXYZ(Int16 cardIndex, Int16 crdNo, double[] pEndPosArray, Int32 userID = 0);
- /// @brief XY平面内直线插补运动
- /// @attention[]]pEndPosArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdLineXY", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdLineXY(Int16 cardIndex, Int16 crdNo, double[] pEndPosArray, Int32 userID = 0);
- /// @brief XZ平面内直线插补运动
- /// @attention[]]pEndPosArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdLineZX", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdLineZX(Int16 cardIndex, Int16 crdNo, double[] pEndPosArray, Int32 userID = 0);
- /// @brief YZ平面内直线插补运动
- /// @attention[]]pEndPosArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdLineYZ", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdLineYZ(Int16 cardIndex, Int16 crdNo, double[] pEndPosArray, Int32 userID = 0);
- /// @brief 给定三点的三维圆弧插补
- /// @details 如果输入三点共线会导致圆弧几何错误, 此函数只能画小于一圈的圆不能画整圆和多圈圆
- /// @attention pMidPos 、pEndPos 应传入长度为 3 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcThreePoint", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdArcThreePoint(Int16 cardIndex, Int16 crdNo, double[] pMidPosArray, double[] pEndPosArray, Int32 userID);
- /// @brief 给定圆心, 末点法向量的三维圆弧插补
- /// @details 当 height 不为 0 的时候可衍生为螺旋线插补。当起点和终点重合的时候几何参数错误。
- /// @attention[]]pCenterArray[] pEndPosArray[] pNormalArray 应传入长度为 3 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Crd3DArcCenterNormal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 给定圆弧半径, 圆弧末点和圆弧法向量的三维圆弧插补
- /// @details 当 height 不为 0 的时候可衍生为螺旋线插补。 此函数无法插补整圆
- /// @attention[]]pEndPosArray[] pNormalArray 应传入长度为 3 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Crd3DArcRadiusNormal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 给定圆弧圆心, 圆弧角度和圆弧法向量的三维圆弧插补
- /// @details 当 height 不为 0 的时候可衍生为螺旋线插补。此函数可以画整圆
- /// @attention[]]pCenterArray[] pNormalArray 应传入长度为 3 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Crd3DArcAngleNormal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_Crd3DArcAngleNormal(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double angle, double[] pNormalArray, double height = 0, Int32 userID = 0);
- /// @brief 给定圆弧圆心和圆弧末点, XY平面内的圆弧插补
- /// @attention[]]pCenterArray[] pEndPosArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcCenterXYPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 给定圆弧圆心和圆弧末点, YZ平面内的圆弧插补
- /// @attention[]]pCenterArray[] pEndPosArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcCenterYZPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 给定圆弧圆心和圆弧末点, ZX平面内的圆弧插补
- /// @attention[]]pCenterArray[] pEndPosArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcCenterZXPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 给定圆弧半径和圆弧末点, XY平面内的圆弧插补
- /// @attention[]]pEndPosArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcRadiusXYPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 给定圆弧半径和圆弧末点, YZ平面内的圆弧插补
- /// @attention[]]pEndPosArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcRadiusYZPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 给定圆弧半径和圆弧末点, ZX平面内的圆弧插补
- /// @attention[]]pEndPosArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcRadiusZXPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 给定圆弧圆心和和圆弧角度, XY平面内的圆弧插补
- /// @attention[]]pCenterArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcAngleXYPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdArcAngleXYPlane(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double angle, double height = 0, Int32 userID = 0);
- /// @brief 给定圆弧圆心和和圆弧角度, YZ平面内的圆弧插补
- /// @attention[]]pCenterArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcAngleYZPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdArcAngleYZPlane(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double angle, double height = 0, Int32 userID = 0);
- /// @brief 给定圆弧圆心和和圆弧角度, ZX平面内的圆弧插补
- /// @attention[]]pCenterArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdArcAngleZXPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdArcAngleZXPlane(Int16 cardIndex, Int16 crdNo, double[] pCenterArray, double angle, double height = 0, Int32 userID = 0);
- /// @brief 给定圆心, 末点法向量的三维涡旋线插补
- /// @details 当 height 不为 0 的时候可衍生为螺旋线插补。当起点和终点重合的时候几何参数错误。
- /// @attention[]]pCenterArray[] pEndPosArray[] pNormalArray 应传入长度为 3 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Crd3DVortexCenterNormal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 给定涡旋线圆心和涡旋线末点, XY平面内的涡旋线插补
- /// @attention[]]pCenterArray[] pEndPosArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdVortexCenterXYPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 给定涡旋线圆心和涡旋线末点, YZ平面内的涡旋线插补
- /// @attention[]]pCenterArray[] pEndPosArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdVortexCenterYZPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 给定涡旋线圆心和涡旋线末点, ZX平面内的涡旋线插补
- /// @attention[]]pCenterArray[] pEndPosArray 应传入长度为 2 的数组指针
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdVortexCenterZXPlane", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 插补缓冲区等待延时
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdWaitTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdWaitTime(Int16 cardIndex, Int16 crdNo, Int32 waitTime, Int32 userID = 0);
- /// @brief 插补缓冲区等待 DI
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdWaitDI", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdWaitDI(Int16 cardIndex, Int16 crdNo, Int16 diNO, Int16 diType, Int16 diLevel, Int32 userID = 0);
- /// @brief 插补缓冲区等待 DI
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdWaitTimeDI", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdWaitTimeDI(Int16 cardIndex, Int16 crdNo, Int16 diNO, Int16 diType, Int16 diLevel, Int32 waitTime, Int32 userID = 0);
- /// @brief 插补缓冲区输出 DO
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetDO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetDO(Int16 cardIndex, Int16 crdNo, Int16 doNO, Int16 doType, Int16 doLevel, Int32 userID = 0);
- /// @brief 插补缓冲区指令, 执行到该段时, 以该段为起始, 在 waitPos 距离处输出指定的 DO 信号
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetDistanceDO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetDistanceDO(Int16 cardIndex, Int16 crdNo, double waitPos, Int16 doNO, Int16 doType, Int16 doLevel, Int32 userID = 0);
- /// @brief 插补缓冲区指令, 执行到该段时, 以该段为起始, 延时设定时间, 输出指定的 DO 信号
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetTimeDO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetTimeDO(Int16 cardIndex, Int16 crdNo, Int32 waitTime, Int16 doNO, Int16 doType, Int16 doLevel, Int32 userID = 0);
- /// @brief 插补缓冲区启动插补轴以外的轴 PTP 运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdPTPMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 插补缓冲区中启动插补轴之外的轴同步运动(相对位移)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSyncMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSyncMove(Int16 cardIndex, Int16 crdNo, Int16 axNo, double syncPos, Int32 userID = 0);
- /// @brief 插补缓冲区中启动插补轴之外的轴同步运动(绝对位移)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSyncMoveAbs", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSyncMoveAbs(Int16 cardIndex, Int16 crdNo, Int16 axNo, double syncTgtPos, Int32 userID = 0);
- /// @brief 插补缓冲区等待上一条运动指令到位
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdWaitInPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdWaitInPos(Int16 cardIndex, Int16 crdNo, Int32 userID = 0);
- /// @brief 缓冲区插补轴外的多轴(两轴)同步运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdMultiSyncMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 插补缓存运动停止
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdBufStop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdBufStop(Int16 cardIndex, Int16 crdNo, Int32 userID = 0);
- /// @brief 插补缓存区设置全局变量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetUserVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetUserVal(Int16 cardIndex, Int16 crdNo, Int16 index, Int32 value, Int32 userID = 0);
- /// @brief 插补缓存区等待全局变量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdWaitUserVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdWaitUserVal(Int16 cardIndex, Int16 crdNo, Int16 index, Int16 condition, Int32 compareValue, Int32 waitTime, Int32 userID = 0);
- /// @brief 一次性往 DSP 队列发送 PC 部分的队列数据
- /// @details 每次发送若干条, 如果完全发送完成, pIsFinished 标 识记为 1
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdEndData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdEndData(Int16 cardIndex, Int16 crdNo, ref Int16 pIsFinished);
- /// @brief 插补运动使能函数, 调用此函数后, 会开始插补运动。如果停止插补运动, 需要调用停止运动函数 进行去插补使能
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdStart(Int16 cardIndex, Int16 crdNo);
- /// @brief 多个插补坐标系同时运动使能函数, 调用此函数后, 会开始插补运动。如果停止插补运动, 需要调用停止运动函数 进行去插补使能
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdMultiStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdMultiStart(Int16 cardIndex, Int16[] pCrdNo, Int16 count);
- /// @brief 调用此函数进行插补停止, 用户可以选择正常平滑停止和急停。
- /// @details 正常平滑停止按照用户设定的轨迹加速度进行减速停止。急停是利用用户在建立坐标系设定的急停加速度进行停止, 停止后系统不会清空队列, 需要用户自己清空队列。
- /// @attention 急停停止后, 插补会报出急停错误号, 需要手动清除此错误才能再次运行
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdStop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdStop(Int16 cardIndex, Int16 crdNo, Int16 stopType);
- /// @brief 清除缓存区压入曲线数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdClrData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdClrData(Int16 cardIndex, Int16 crdNo);
- /// @brief 清除插补错误号。可以清除 IMC_CrdGetStatus 获取到的故障号
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdClrError", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdClrError(Int16 cardIndex, Int16 crdNo);
- /// @brief 插补倍率设定函数。插补实际进给速度 = 用户插补进给速度 × 倍率值。
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetRatio", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetRatio(Int16 cardIndex, Int16 crdNo, double ratio);
- /// @brief 插补倍率获取函数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetRatio", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetRatio(Int16 cardIndex, Int16 crdNo, ref double pRatio);
- /// @brief 插补状态获取。bit0-bit7 是插补运行状态。bi8-bit15 是插补故障状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetStatus(Int16 cardIndex, Int16 crdNo, ref Int16 pStatus);
- /// @brief 获取插补运动执行缓冲区最后一段的运动状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetArrivalSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetArrivalSts(Int16 cardIndex, Int16 crdNo, ref Int16 pSts);
- /// @brief 获取插补目标位置。目标位置指的是最后压入曲线的末点位置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetTargetPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetTargetPos(Int16 cardIndex, Int16 crdNo, double[] pPosArray);
- /// @brief 获取插补暂停运动的位置。该位置一般用于当用户使用单轴移动过插补轴后, 需要返回继续加工时使用
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetPausePos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetPausePos(Int16 cardIndex, Int16 crdNo, double[] pPosArray);
- /// @brief 当前插补坐标系坐标读取函数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetPos(Int16 cardIndex, Int16 crdNo, double[] pCrdPosArray);
- /// @brief 插补轨迹速度读取函数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetVel(Int16 cardIndex, Int16 crdNo, ref double pCrdVel);
- /// @brief 插补当前运动曲线用户索引获取
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetUserID", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetUserID(Int16 cardIndex, Int16 crdNo, ref Int32 pUserID);
- /// @brief 获取队列当前的剩余余量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetSpace(Int16 cardIndex, Int16 crdNo, ref Int32 pSpace);
- /// @brief 获取 CPU 缓存队列当前的剩余空间
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetBufSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetBufSpace(Int16 cardIndex, Int16 crdNo, ref Int32 pSpace);
- /// @brief 获取前瞻缓存队列当前的剩余空间
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetLookAheadSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetLookAheadSpace(Int16 cardIndex, Int16 crdNo, ref Int32 pSpace);
- /// @brief 插补缓冲区模式设置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetBufferMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetBufferMode(Int16 cardIndex, Int16 crdNo, Int16 bufferMode);
- /// @brief 获取插补缓冲区模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdGetBufferMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdGetBufferMode(Int16 cardIndex, Int16 crdNo, ref Int16 pBufferMode);
- /// @brief 插补数据恢复
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CrdSetDataRestore", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CrdSetDataRestore(Int16 cardIndex, Int16 crdNo);
- #endregion
- ///@defgroup MultiCrd MultiCrd
- ///@brief MultiCrd 多轴插补运动模式相关接口
- #region MultiCrd
- /// @brief 建立多轴插补系统
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiSetupSys", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiSetupSys(Int16 cardIndex, Int16 groupNo, Int16[] pAxNo, Int16 maxAxNum);
- /// @brief 销毁多轴插补系统
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiDeleteSys", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiDeleteSys(Int16 cardIndex, Int16 groupNo);
- /// @brief 启动多轴插补运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiStart(Int16 cardIndex, Int16 groupNo);
- /// @brief 停止多轴插补运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiStop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiStop(Int16 cardIndex, Int16 groupNo, Int16 stopType);
- /// @brief 获取多轴插补数据剩余空间
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiGetSpace(Int16 cardIndex, Int16 groupNo, ref Int32 pSpace);
- /// @brief 清除多轴插补系统错误状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiClrData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiClrData(Int16 cardIndex, Int16 groupNo);
- /// @brief 清除多轴插补数据队列
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiClrError", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiClrError(Int16 cardIndex, Int16 groupNo);
- /// @brief 设置多轴插补位置类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiSetPosType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiSetPosType(Int16 cardIndex, Int16 groupNo, Int16 posType);
- /// @brief 获取多轴插补位置类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetPosType", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiGetPosType(Int16 cardIndex, Int16 groupNo, ref Int16 pPosType);
- /// @brief 获取多轴插补当前段UserID
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetUserID", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiGetUserID(Int16 cardIndex, Int16 groupNo, ref Int32 pUserID);
- /// @brief 获取多轴插补系统运行状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiGetSts(Int16 cardIndex, Int16 groupNo, ref Int16 pSts, ref Int16 pErrocode);
- /// @brief 获取多轴插补运动到位状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetArrivalSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiGetArrivalSts(Int16 cardIndex, Int16 groupNo, ref Int16 pArrivalSts);
- /// @brief 设置多轴插补系统运动速度倍率
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiSetRatio", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiSetRatio(Int16 cardIndex, Int16 groupNo, double ratio);
- /// @brief 获取多轴插补系统运动速度倍率
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetRatio", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiGetRatio(Int16 cardIndex, Int16 groupNo, ref double pRatio);
- /// @brief 获取多轴插补运动轨迹位置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetTrajPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiGetTrajPos(Int16 cardIndex, Int16 groupNo, double[] pPos);
- /// @brief 获取多轴插补运动轨迹速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiGetTrajVel", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiGetTrajVel(Int16 cardIndex, Int16 groupNo, ref double pVel);
- /// @brief 多轴插补直线运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiLineMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- 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);
- /// @brief 多轴插补等待事件
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiWaitTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiWaitTime(Int16 cardIndex, Int16 groupNo, Int32 waitTime, Int32 userID);
- /// @brief 多轴插补等待DI输入事件
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiWaitDI", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiWaitDI(Int16 cardIndex, Int16 groupNo, Int16 diIndex, Int16 diType, Int16 diLevel, Int32 waitTime, Int32 userID);
- /// @brief 多轴插补设置DO输出事件
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiSetDO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiSetDO(Int16 cardIndex, Int16 groupNo, Int16 doIndex, Int16 doType, Int16 doLevel, Int32 userID);
- /// @brief 多轴插补设置翻转DO输出事件
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiSetReverseDO", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiSetReverseDO(Int16 cardIndex, Int16 groupNo, Int16 doIndex, Int16 doType, Int16 doLevel, Int32 waitTime, Int32 userID);
- #endregion
- ///@defgroup BandPt BandPt
- ///@brief BandPt 缓冲区插补运动模式相关接口
- #region BandPt
- /// @brief 建立多轴捆绑 PT 运行系统
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetupPtPackSys", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetupPtPackSys(Int16 cardIndex, Int16 sysNo, Int16[] pMaskAxNoArray, Int16 maxAxNum);
- /// @brief 销毁捆绑 PT 运动系统
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_DeletePtPackSys", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_DeletePtPackSys(Int16 cardIndex, Int16 sysNo);
- /// @brief 设置捆绑 PT 运动位置的编程类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPtPackIncMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetPtPackIncMode(Int16 cardIndex, Int16 sysNo, Int16 incMode);
- /// @brief 获取捆绑 PT 运动位置的编程类型
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtPackIncMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPtPackIncMode(Int16 cardIndex, Int16 sysNo, ref Int16 pIncMode);
- /// @brief 使能捆绑 PT 运动数据断流保护。当使能后, 根据缓冲区是否有数据, 同时判断各轴的速度是否大 于设定的阈值。
- /// @details 如果系统中有任意一个轴的速度大于了设定的阈值, 则进行断流保护, 按照设定的 平滑停加速度进行停止。
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_EnablePtPackNoDataProtect", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_EnablePtPackNoDataProtect(Int16 cardIndex, Int16 sysNo, double[] pThresholdVelArray);
- /// @brief 取消捆绑 PT 运动数据断流保护
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_DisablePtPackNoDataProtect", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_DisablePtPackNoDataProtect(Int16 cardIndex, Int16 sysNo);
- /// @brief 获取捆绑 PT 运动数据断流保护的设置状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtPackNoDataProtectStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPtPackNoDataProtectStatus(Int16 cardIndex, Int16 sysNo, ref Int16 pEnSts, double[] pThresholdVelArray);
- /// @brief 添加捆绑 PT 运动数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_AddMotionPointPtPack", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_AddMotionPointPtPack(Int16 cardIndex, Int16 sysNo, double[] pPosArray, Int16[] pTypeArray, double T, Int16 dataNum);
- /// @brief 添加捆绑 PT 中的 DO 输出事件
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_AddDoPointPtPack", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_AddDoPointPtPack(Int16 cardIndex, Int16 sysNo, Int16 doNo, Int16 doType, Int16 doLevel);
- /// @brief 启动捆绑 PT 运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StartPtPack", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StartPtPack(Int16 cardIndex, Int16 sysNo);
- /// @brief 停止捆绑 PT 运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopPtPack", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StopPtPack(Int16 cardIndex, Int16 sysNo, Int16 type);
- /// @brief 清除捆绑 PT 运动数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClrPtPackData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ClrPtPackData(Int16 cardIndex, Int16 sysNo);
- /// @brief 清除捆绑 PT 运动错误
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClrPtPackError", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ClrPtPackError(Int16 cardIndex, Int16 sysNo);
- /// @brief 获取捆绑 PT 运动数据的空间
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtPackRestSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPtPackRestSpace(Int16 cardIndex, Int16 sysNo, ref Int16 pSpace);
- /// @brief 获取捆绑 PT 运动的状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtPackStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPtPackStatus(Int16 cardIndex, Int16 sysNo, ref Int16 pStatus);
- /// @brief 获取捆绑 PT 运动错误
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtPackError", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPtPackError(Int16 cardIndex, Int16 sysNo, ref Int16 pErr);
- /// @brief 获取捆绑 PT 运动到位状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPtPackArrivalSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPtPackArrivalSts(Int16 cardIndex, Int16 sysNo, ref Int16 pSts);
- #endregion
- #endregion
- #endregion
- ///@defgroup Compensation Compensation
- ///@brief 运动补偿功能
- #region Compensation
- ///@defgroup ScrewComp ScrewComp
- ///@brief 螺距误差补偿
- #region ScrewComp
- /// @brief 设置螺距误差补偿表
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxScrewCompTable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxScrewCompTable(Int16 cardIndex, Int16 tableId, Int16 cnt, Int32[] pPosCompArray, Int32[] pNegCompArray);
- /// @brief 获取螺距误差补偿表
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxScrewCompTable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxScrewCompTable(Int16 cardIndex, Int16 tableId, ref Int16 pCnt, Int32[] pPosCompArray, Int32[] pNegCompArray);
- /// @brief 设置螺距误差补偿参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxScrewCompParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxScrewCompParam(Int16 cardIndex, Int16 axNo, Int16 pointCnt, Int32 startPos, Int32 len);
- /// @brief 获取螺距误差补偿参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxScrewCompParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxScrewCompParam(Int16 cardIndex, Int16 axNo, ref Int16 pPointCnt, ref Int32 pStartPos, ref Int32 pLen);
- /// @brief 使能螺距误差补偿
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_EnableAxScrewComp", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_EnableAxScrewComp(Int16 cardIndex, Int16 axNo, Int16 enable);
- /// @brief 获取螺距误差补偿状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxScrewCompSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxScrewCompSts(Int16 cardIndex, Int16 axNo, ref Int16 pEnable, ref double pCompVal);
- #endregion
- ///@defgroup TableComp TableComp
- ///@brief 表补偿功能
- #region TableComp
- /// @brief 设置表补偿的数据表
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompSetTable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_TableCompSetTable(Int16 cardIndex, Int16 tableId, Int32 cnt, Int32[] pDataArray);
- /// @brief 获取表补偿的数据表
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompGetTable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_TableCompGetTable(Int16 cardIndex, Int16 tableId, ref Int32 pCnt, Int32[] pDataArray);
- /// @brief 设置表补偿参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompSetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_TableCompSetParam(Int16 cardIndex, Int16 axNo, ref TTableCompParam pTTableCompParam);
- /// @brief 获取表补偿参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompGetParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_TableCompGetParam(Int16 cardIndex, Int16 axNo, ref TTableCompParam pTTableCompParam);
- /// @brief 使能表补偿
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompEnable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_TableCompEnable(Int16 cardIndex, Int16 axNo, Int16 enable);
- /// @brief 获取表补偿状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompGetSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_TableCompGetSts(Int16 cardIndex, Int16 axNo, ref Int16 pEnable, ref double pCompVal);
- /// @brief 重新分配表补偿的表数量和大小(总大小为40000)
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompTableResize", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_TableCompTableResize(Int16 cardIndex, Int16 tableNum);
- /// @brief 获取表补偿的表数量和大小信息
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_TableCompTableGetInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_TableCompTableGetInfo(Int16 cardIndex, ref Int16 pTableNum, ref Int32 pTableSize);
- #endregion
- ///@defgroup AxPrfComp AxPrfComp
- ///@brief 轴规划补偿功能
- #region AxPrfComp
- /// @brief 设置轴规划补偿
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetAxCompPos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetAxCompPos(Int16 cardIndex, Int16 axNo, double compPos, double compTime, Int16 posType);
- /// @brief 获取轴规划补偿状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetAxCompSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetAxCompSts(Int16 cardIndex, Int16 axNo, ref Int16 pSts, ref double pCompPos);
- #endregion
- #endregion
- ///@defgroup Virtual Resource
- ///@brief 板卡虚拟功能
- #region VirtualResource
- ///@defgroup UserVal
- ///@brief 全局变量功能
- #region UserVal
- /// @brief 设置全局变量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetUserVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetUserVal(Int16 cardIndex, Int16 index, Int32 value);
- /// @brief 读取全局变量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetUserVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetUserVal(Int16 cardIndex, Int16 index, ref Int32 pValue);
- #endregion
- #endregion
- ///@defgroup Sample Sample
- ///@brief 板卡采样功能相关接口
- #region Sample
- /// @brief 配置数据采集的参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ConfigSamplePara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ConfigSamplePara(Int16 cardIndex, ref TSamplePara pSamplePara);
- /// @brief 配置数据采集的采集对象
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ConfigSampleData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ConfigSampleData(Int16 cardIndex, Int16 count, Int16[] pDataTypeArray, Int32[] pDataIndexArray);
- /// @brief 使能数据采集
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ConfigSampleEnable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ConfigSampleEnable(Int16 cardIndex, Int16 enable);
- /// @brief 获取数据采集的状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetSampleStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetSampleStatus(Int16 cardIndex, ref Int16 pStatus, ref Int32 pLen, ref Int32 pLeakageCount);
- /// @brief 获取数据采集的速度
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetSampleData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetSampleData(Int16 cardIndex, ref Int16 pPackNum, Int16[] pDataArray);
- #endregion
- ///@defgroup MultiAxCmp MultiAxCmp
- ///@brief 板卡多轴位置比较功能相关接口
- #region MultiAxCmp
- /// @brief 配置多轴比较输入源
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiAxCmpSrcCfg", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiAxCmpSrcCfg(Int16 cardIndex, Int16 groupNo, Int16 cmpDimNum, Int16 cmpSrcType, Int16[] pCmpSrcArray, Int32 errorLmt);
- /// @brief 使能多轴比较
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiAxCmpEnable", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiAxCmpEnable(Int16 cardIndex, Int16 groupNo, Int16 enable);
- /// @brief 压入多轴比较数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiAxCmpPushData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiAxCmpPushData(Int16 cardIndex, Int16 groupNo, Int16 cmpDimNum, Int16 eventIndex, Int32[] pCmpPosArray, ref Int16 pSpace);
- /// @brief 清除多轴比较缓冲区数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiAxCmpClrData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiAxCmpClrData(Int16 cardIndex, Int16 groupNo);
- /// @brief 获取多轴比较剩余空间
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiAxCmpGetSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiAxCmpGetSpace(Int16 cardIndex, Int16 groupNo, ref Int16 pSpace);
- /// @brief 获取多轴比较状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_MultiAxCmpGetSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_MultiAxCmpGetSts(Int16 cardIndex, Int16 groupNo, ref Int16 pStatus, ref Int16 pCmpCnt, ref Int16 pCmpIndex);
- #endregion
- ///@defgroup PLC PLC
- ///@brief 板卡PLC功能相关接口
- #region PLC
- /// @brief 编译参数结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct TCompileInfo
- {
- public IntPtr pFileName;
- public IntPtr pLineNo;
- public IntPtr pMessage;
- };
- /// @brief 编译参数结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct TVarInfo
- {
- public Int16 id;
- public Int16 dataType;
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
- public char[] name;
- //public string name;
- };
- /// @brief 状态参数结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct TThreadSts
- {
- public Int16 run;
- public Int16 error;
- public double result;
- public Int16 line;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TBindDi
- {
- public Int16 diType;
- public Int16 index; //绑定索引从1 开始
- public Int16 reverse;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TBindDo
- {
- public Int16 doType;
- public Int16 index; //绑定索引从1 开始
- public Int16 reverse;
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TBindTimer
- {
- public Int16 timerType; // 0 TT 1:TF 2:TTF
- public Int32 delay; // 单位:ms
- public Int16 inputVarId; //输入控制变量
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TBindCounter
- {
- public Int16 counterType; //计数器类型:0-等于输出1 1-小于等于输出1 2-大于等于输出1
- public Int16 edge; //计数沿: 0-上升沿 1-下降沿 2-双边沿
- public Int32 init; //计数初值:复位变量为1时,内部计数恢复初值,(起点,终点)
- public Int32 target; //计数器目标值
- public Int32 begin; //计数器起点
- public Int32 end; //计数器终点
- public Int16 dir; //计数方向: 1-正向计数 -1-负向计数
- public Int32 unit; //计数单位:计数器累加1次需要输入端出现边沿的次数
- public Int16 inputVarId; //计数器输入变量
- public Int16 resetVarId; //计数器复位变量
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TBindFlank
- {
- public Int16 flankType; //边沿触发器类型:0-下降沿触发 1-上升沿触发 2-双边沿触发
- public Int16 inputVarId; //边沿触发器输入变量,触发后保持到执行周期结束
- };
- [StructLayout(LayoutKind.Sequential)]
- public struct TBindSrff
- {
- public Int16 setVarId; //置位变量 置位为1,输出1
- public Int16 resetVarId; //复位变量 复位为1,置位为0,输出0
- };
- /// @brief 编译
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Compile", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_Compile(string pFileName, ref TCompileInfo pWrongInfo);
- /// @brief 下载
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Download", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_Download(Int16 cardIndex, string pFileName);
- /// @brief 获取函数id
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetFunId", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetFunId(Int16 cardIndex, string pFunName, ref Int16 pFunId);
- /// @brief 获取变量id
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetVarId", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetVarId(Int16 cardIndex, string pFunName, string pVarName, ref TVarInfo pVarInfo);
- /// @brief 绑定线程
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_Bind", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_Bind(Int16 cardIndex, Int16 thread, Int16 funId, Int16 page);
- /// @brief 运行线程
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_RunThread", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_RunThread(Int16 cardIndex, Int16 thread);
- /// @brief 按周期运行线程
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_RunThreadPeriod", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_RunThreadPeriod(Int16 cardIndex, Int16 thread, Int16 period, Int16 priority);
- /// @brief 按断点运行线程
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_RunThreadToBreakpoint", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_RunThreadToBreakpoint(Int16 cardIndex, Int16 thread, Int16 line);
- /// @brief 单步运行线程
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StepThread", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StepThread(Int16 cardIndex, Int16 thread);
- /// @brief 停止线程
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_StopThread", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_StopThread(Int16 cardIndex, Int16 thread);
- /// @brief 暂停线程
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_PauseThread", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_PauseThread(Int16 cardIndex, Int16 thread);
- /// @brief 获取线程状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetThreadSts", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetThreadSts(Int16 cardIndex, Int16 thread, ref TThreadSts pThreadSts);
- /// @brief 获取线程运行周期
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetThreadTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetThreadTime(Int16 cardIndex, Int16 thread, ref Int16 pPeriod, ref UInt32 pExecuteTime, ref UInt32 pExecuteTimeMax);
- /// @brief 获取线程运行时间
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetThreadRunTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetThreadRunTime(Int16 cardIndex, Int16 thread, ref UInt32 pExecuteTime, ref UInt32 pExecuteTimeMax);
- /// @brief 设置变量值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetVarValue", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetVarValue(Int16 cardIndex, Int16 page, ref TVarInfo pVarInfo, double[] pValue, Int16 count);
- /// @brief 获取变量值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetVarValue", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetVarValue(Int16 cardIndex, Int16 page, ref TVarInfo pVarInfo, double[] pValue, Int16 count);
- /// @brief 解除绑定
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_UnbindVar", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_UnbindVar(Int16 cardIndex, Int16 thread);
- /// @brief 绑定DI
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_BindDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_BindDi(Int16 cardIndex, Int16 thread, ref TVarInfo pVarInfo, ref TBindDi pBindDi);
- /// @brief 绑定DO
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_BindDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_BindDo(Int16 cardIndex, Int16 thread, ref TVarInfo pVarInfo, ref TBindDo pBindDo);
- /// @brief 绑定Timer
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_BindTimer", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_BindTimer(Int16 cardIndex, Int16 thread, ref TVarInfo pVarInfo, ref TBindTimer pBindTimer);
- /// @brief 绑定计数器
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_BindCounter", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_BindCounter(Int16 cardIndex, Int16 thread, ref TVarInfo pVarInfo, ref TBindCounter pBindCounter);
- /// @brief 绑定触发器Flank
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_BindFlank", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_BindFlank(Int16 cardIndex, Int16 thread, ref TVarInfo pVarInfo, ref TBindFlank pBindFlank);
- /// @brief 绑定置位器
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_BindSrff", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_BindSrff(Int16 cardIndex, Int16 thread, ref TVarInfo pVarInfo, ref TBindSrff pBindSrff);
- /// @brief 获取绑定DI输入状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindDi(Int16 cardIndex, ref TVarInfo pVarInfo, ref TBindDi pBindDi);
- /// @brief 获取绑定DO输出状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindDo(Int16 cardIndex, ref TVarInfo pVarInfo, ref TBindDo pBindDo);
- /// @brief 获取绑定Timer输出状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindTimer", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindTimer(Int16 cardIndex, ref TVarInfo pVarInfo, ref TBindTimer pBindTimer, ref Int32 pCount);
- /// @brief 获取绑定计数器输出状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindCounter", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindCounter(Int16 cardIndex, ref TVarInfo pVarInfo, ref TBindCounter pBindCounter, ref Int32 pUnitCount, ref Int32 pCount);
- /// @brief 获取绑定触发器Flank输出状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindFlank", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindFlank(Int16 cardIndex, ref TVarInfo pVarInfo, ref TBindFlank pBindFlank);
- /// @brief 获取绑定置位器Srff输出状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindSrff", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindSrff(Int16 cardIndex, ref TVarInfo pVarInfo, ref TBindSrff pBindSrff);
- /// @brief 获取绑定Di数量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindDiCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindDiCount(Int16 cardIndex, Int16 thread, ref Int16 pCount);
- /// @brief 获取绑定Do数量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindDoCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindDoCount(Int16 cardIndex, Int16 thread, ref Int16 pCount);
- /// @brief 获取绑定Timer数量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindTimerCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindTimerCount(Int16 cardIndex, Int16 thread, ref Int16 pCount);
- /// @brief 获取绑定Counter数量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindCounterCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindCounterCount(Int16 cardIndex, Int16 thread, ref Int16 pCount);
- /// @brief 获取绑定Flank数量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindFlankCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindFlankCount(Int16 cardIndex, Int16 thread, ref Int16 pCount);
- /// @brief 获取绑定Srff数量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindSrffCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindSrffCount(Int16 cardIndex, Int16 thread, ref Int16 pCount);
- /// @brief 获取绑定DI信息
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindDiInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindDiInfo(Int16 cardIndex, Int16 thread, Int16 index, ref Int16 pVar, ref TBindDi pBindDi);
- /// @brief 获取绑定DO信息
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindDoInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindDoInfo(Int16 cardIndex, Int16 thread, Int16 index, ref Int16 pVar, ref TBindDo pBindDo);
- /// @brief 获取绑定Timer信息
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindTimerInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindTimerInfo(Int16 cardIndex, Int16 thread, Int16 index, ref Int16 pVar, ref TBindTimer pBindTimer);
- /// @brief 获取绑定计数器信息
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindCounterInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindCounterInfo(Int16 cardIndex, Int16 thread, Int16 index, ref Int16 pVar, ref TBindCounter pBindCounter);
- /// @brief 获取绑定触发器Flank信息
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindFlankInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindFlankInfo(Int16 cardIndex, Int16 thread, Int16 index, ref Int16 pVar, ref TBindFlank pBindFlank);
- /// @brief 获取绑定置位器Srff信息
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetBindSrffInfo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetBindSrffInfo(Int16 cardIndex, Int16 thread, Int16 index, ref Int16 pVar, ref TBindSrff pBindSrff);
- #endregion
- ///@defgroup PulseDO PulseDO
- ///@brief 板卡脉冲DO输出功能相关接口
- #region PulseDO
- /// @brief 设置脉冲DO输出映射
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPulseDoMap", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetPulseDoMap(Int16 cardIndex, Int16 index, Int16 doIndex);
- /// @brief 获取脉冲DO输出映射
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPulseDoMap", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPulseDoMap(Int16 cardIndex, Int16 index, ref Int16 pDoIndex);
- /// @brief 设置脉冲DO输出通道参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetPulseDoOutputParam", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetPulseDoOutputParam(Int16 cardIndex, Int16 index, UInt16 highLevelTime, UInt16 lowLevTime, Int16 firstLevel, Int16 pulseNum);
- /// @brief 使能脉冲DO输出
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_EnablePulseDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_EnablePulseDo(Int16 cardIndex, Int16 index, UInt16 highLevelTime, UInt16 lowLevTime, Int16 firstLevel, Int16 pulseNum);
- /// @brief 停止脉冲DO输出
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_DisablePulseDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_DisablePulseDo(Int16 cardIndex, Int16 index);
- /// @brief 获取脉冲DO输出状态
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetPulseDoStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetPulseDoStatus(Int16 cardIndex, Int16 index, ref Int16 pStatus);
- #endregion
- ///@defgroup Event Event
- ///@brief 板卡事件功能相关接口
- #region Event
- /// @brief 设置事件
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEvent", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEvent(Int16 cardIndex, Int16 eventIndex, ref TEvent pEvent);
- /// @brief 设置任务
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetTask", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetTask(Int16 cardIndex, Int16 taskIndex, Int16 taskType, IntPtr pTask);
- /// @brief 设置事件与任务连接
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_SetEventTaskLink", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_SetEventTaskLink(Int16 cardIndex, Int16 eventIndex, Int16[] taskIndexArray, Int16 count);
- /// @brief 事件开启
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_EventOn", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_EventOn(Int16 cardIndex, Int16 eventIndex, Int16 count = 1);
- /// @brief 事件关闭
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_EventOff", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_EventOff(Int16 cardIndex, Int16 eventIndex, Int16 count = 1);
- /// @brief 事件强制触发
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_EventForceTrigger", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_EventForceTrigger(Int16 cardIndex, Int16 eventIndex, Int16 count = 1);
- /// @brief 清除事件
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClearEvent", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ClearEvent(Int16 cardIndex, Int16 eventIndex, Int16 count = 1);
- /// @brief 清除任务
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClearTask", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ClearTask(Int16 cardIndex, Int16 taskIndex, Int16 count = 1);
- /// @brief 清除事件与任务的连接
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_ClearEventTaskLink", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_ClearEventTaskLink(Int16 cardIndex, Int16 eventIndex, Int16 count = 1);
- /// @brief 获取设置的事件数量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEventCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEventCount(Int16 cardIndex, ref Int16 pCount);
- /// @brief 获取设置的事件
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEvent", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEvent(Int16 cardIndex, Int16 eventIndex, ref TEvent pEvent);
- /// @brief 获取事件的触发次数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEventTriggerCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEventTriggerCount(Int16 cardIndex, Int16 eventIndex, ref Int16 pTriggerCount);
- /// @brief 获取设置的任务数量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetTaskCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetTaskCount(Int16 cardIndex, ref Int16 pCount);
- /// @brief 获取任务
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetTask", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetTask(Int16 cardIndex, Int16 taskIndex, ref Int16 pTaskType, IntPtr pTaskData);
- /// @brief 获取设置的事件与任务连接数量
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetEventTaskLinkCount", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetEventTaskLinkCount(Int16 cardIndex, Int16 eventIndex, ref Int16 pCount);
- /// @brief 获取任务执行结果
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_GetTaskResult", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_GetTaskResult(Int16 cardIndex, Int16 taskIndex, ref Int16 pResult);
- #endregion
- ///@defgroup CmdList CmdList
- ///@brief 板卡指令缓存输出功能相关接口
- #region CmdList
- /// @brief 启动缓存区指令执行
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListStart", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListStart(Int16 cardIndex, Int16 index, Int16 type);
- /// @brief 停止指令缓存区执行
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListStop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListStop(Int16 cardIndex, Int16 index);
- /// @brief 设置指令缓存区运行模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListSetMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListSetMode(Int16 cardIndex, Int16 index, Int16 mode);
- /// @brief 获取指令缓存区运行模式
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListGetMode", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListGetMode(Int16 cardIndex, Int16 index, ref Int16 mode);
- /// @brief 获取指令缓存区运行状态、错误码和当前执行段号
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListGetStatus", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListGetStatus(Int16 cardIndex, Int16 index, ref Int16 pStatus, ref Int16 pErrorCode, ref Int32 pCurrentId);
- /// @brief 获取指令缓存区剩余空间
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListGetSpace", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListGetSpace(Int16 cardIndex, Int16 index, ref Int16 pSpace);
- /// @brief 清除指令缓存区数据
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListClearData", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListClearData(Int16 cardIndex, Int16 index);
- /// @brief 清除指令缓存区错误
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListClearError", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListClearError(Int16 cardIndex, Int16 index);
- /// @brief 设置指令缓存区循环执行次数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListSetLoop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListSetLoop(Int16 cardIndex, Int16 index, Int32 setCount);
- /// @brief 获取指令缓存区循环执行次数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListGetLoop", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListGetLoop(Int16 cardIndex, Int16 index, ref Int32 setCount, ref Int32 doneCount);
- /// @brief 缓存区运动指令,执行轴PTP运动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListAxMove", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListAxMove(Int16 cardIndex, Int16 index, Int16 axNo, double tgtPos, Int32 userID);
- /// @brief 缓存区运动指令,在线更新ptp运动目标位置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListUpdateAxMovePos", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListUpdateAxMovePos(Int16 cardIndex, Int16 index, Int16 axNo, double tgtPos, Int32 userID);
- /// @brief 缓存区运动指令,在线更新轴运动速度参数
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListUpdateAxMovePara", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListUpdateAxMovePara(Int16 cardIndex, Int16 index, Int16 axNo, double tgtVel, double tgtAcc, double tgtDec, Int32 userID);
- /// @brief 缓存区运动指令,执行轴ptp运动,目标位置来源为全局变量值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListAxMoveUserVar", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListAxMoveUserVar(Int16 cardIndex, Int16 index, Int16 axNo, Int16 eventIndex, Int32 userID);
- /// @brief 缓存区等待指令,延时等待一段时间
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListWaitTime", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListWaitTime(Int16 cardIndex, Int16 index, Int16 waitTime, Int32 userID);
- /// @brief 缓存区等待指令,等待DI触发
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListWaitDi", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListWaitDi(Int16 cardIndex, Int16 index, Int16 diNo, Int16 diLevel, Int16 diType, Int32 userID);
- /// @brief 缓存区等待指令,等待轴运动到位
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListWaitAxMoveDone", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListWaitAxMoveDone(Int16 cardIndex, Int16 index, Int16 axNo, Int16 arrvType, Int32 userID);
- /// @brief 缓存区等待指令,等待轴位置穿越位置
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListWaitAxPosCross", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListWaitAxPosCross(Int16 cardIndex, Int16 index, Int16 axNo, Int32 Pos, Int16 crossType, Int32 userID);
- /// @brief 缓存区等待指令,等待全局变量值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListWaitUserVar", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListWaitUserVar(Int16 cardIndex, Int16 index, Int16 varIndex, Int32 varValue, Int32 userID);
- /// @brief 缓存区等待指令,等待事件执行完成
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListWaitEventDone", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListWaitEventDone(Int16 cardIndex, Int16 index, Int16 eventIndex, Int32 userID);
- /// @brief 缓存区设置指令,设置DO输出
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListSetDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListSetDo(Int16 cardIndex, Int16 index, Int16 doNo, Int16 doLevel, Int16 doType, Int32 userID);
- /// @brief 缓存区设置指令,设置脉冲DO输出
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListSetPulseDo", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListSetPulseDo(Int16 cardIndex, Int16 index, Int16 outIndex, Int32 userID);
- /// @brief 缓存区设置指令,设置事件启动
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListSetUserVal", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListSetUserVal(Int16 cardIndex, Int16 index, Int16 varIndex, Int32 varValue, Int32 userID);
- /// @brief 缓存区设置指令,设置全局变量值
- [DllImport(Imc60ApiDllName, EntryPoint = "IMC_CmdListSetEventTrigger", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- public static extern UInt32 IMC_CmdListSetEventTrigger(Int16 cardIndex, Int16 index, Int16 eventIndex, Int32 userID);
- #endregion
- }
- }
|