Selaa lähdekoodia

ft: 初始化提交

master
lijie 2 vuotta sitten
commit
3c34b23431
14 muutettua tiedostoa jossa 213 lisäystä ja 0 poistoa
  1. +35
    -0
      .gitignore
  2. +21
    -0
      LICENSE
  3. +9
    -0
      README.md
  4. +37
    -0
      c_src/HJpsNif/eHJps.c
  5. +21
    -0
      c_src/HJpsNif/eHJpsAtom.h
  6. +8
    -0
      c_src/HJpsNif/rebar.config
  7. BIN
      c_src/eNpc
  8. +4
    -0
      c_src/eNpc.cmd
  9. +5
    -0
      include/eHJps.hrl
  10. BIN
      priv/eHJps.so
  11. +15
    -0
      rebar.config
  12. +10
    -0
      src/eHJps.app.src
  13. +44
    -0
      src/eHJps.erl
  14. +4
    -0
      src/user_default.erl

+ 35
- 0
.gitignore Näytä tiedosto

@ -0,0 +1,35 @@
.eunit
*.o
*.beam
*.plt
erl_crash.dump
.concrete/DEV_MODE
# rebar 2.x
.rebar
rel/example_project
ebin/*
deps
# rebar 3
.rebar3
_build/
_checkouts/
rebar.lock
# idea
.idea
*.iml
cmake-build*
CMakeLists.txt
# nif compile temp file
*.pdb
*.d
compile_commands.json
# vs
.vs
x64
*.vcx*
*.sln

+ 21
- 0
LICENSE Näytä tiedosto

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 AICells
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

+ 9
- 0
README.md Näytä tiedosto

@ -0,0 +1,9 @@
eHJps
=====
An OTP Lib of hexagon jps implementation.
设计模型
nif 层采用单线程更新地图数据多线程寻路的模型
erlang层相关请求采用队列模型 更新地图线程和寻路线程 分别从两个不同的任务队列获取新的请求并处理

+ 37
- 0
c_src/HJpsNif/eHJps.c Näytä tiedosto

@ -0,0 +1,37 @@
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<stdatomic.h>
#include<erl_nif.h>
#include "eHJpsAtom.h"
typedef struct Node_r {
bool IsBarrier; //
} Node;
int nifLoad(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info) {
enif_fprintf(stdout, "IMY*************nifload00000\n");
NIF_ATOMS(NIF_ATOM_INIT)
enif_fprintf(stdout, "IMY*************nifload00001\n");
*priv_data = NULL;
return 0;
}
int nifUpgrade(ErlNifEnv* env, void** priv_data, void** old_priv_data, ERL_NIF_TERM load_info) {
*priv_data = *old_priv_data;
enif_fprintf(stdout, "IMY*************nifUpgrade %p %T\n", old_priv_data, load_info);
return 0;
}
void nifUnload(ErlNifEnv* env, void* priv_data) {
enif_fprintf(stdout, "IMY*************nifUnload0000 \n");
return;
}
static ErlNifFunc nifFuns[] = {
};
ERL_NIF_INIT(eQuic, nifFuns, nifLoad, NULL, nifUpgrade, nifUnload)

+ 21
- 0
c_src/HJpsNif/eHJpsAtom.h Näytä tiedosto

@ -0,0 +1,21 @@
#ifndef __QUIC_ATOM_H_
#define __QUIC_ATOM_H_
#include<erl_nif.h>
#define NIF_ATOM_DECL(a) ERL_NIF_TERM atom_ ## a;
#define NIF_ATOM_INIT(a) atom_ ## a = enif_make_atom(env, #a);
#define NIF_ATOMS(A) \
/* atom of common */ \
A(ok) \
A(quic) \
A(error) \
A(true) \
A(false) \
A(undefined) \
A(freed)
NIF_ATOMS(NIF_ATOM_DECL)
#endif

+ 8
- 0
c_src/HJpsNif/rebar.config Näytä tiedosto

@ -0,0 +1,8 @@
{port_specs, [
{"../../priv/eHJps.so", ["eHJps.c"]}
]}.
{port_env, []}.

BIN
c_src/eNpc Näytä tiedosto


+ 4
- 0
c_src/eNpc.cmd Näytä tiedosto

@ -0,0 +1,4 @@
@echo off
setlocal
set rebarscript=%~f0
escript.exe "%rebarscript:.cmd=%" %*

+ 5
- 0
include/eHJps.hrl Näytä tiedosto

@ -0,0 +1,5 @@
-ifndef(eHJps_H).
-define(eHJps_H, true).
-endif.

BIN
priv/eHJps.so Näytä tiedosto


+ 15
- 0
rebar.config Näytä tiedosto

@ -0,0 +1,15 @@
{erl_opts, [no_debug_info, {i, "include"}]}.
{deps, [
{eSync, ".*", {git, "http://sismaker.tpddns.cn:53000/SisMaker/eSync.git", {branch, "master"}}}
]}.
{shell, [
% {config, "config/sys.config"},
{apps, [eHJps]}
]}.
{pre_hooks,
[{"", compile, "escript c_src/eNpc compile"}]}.
{post_hooks,
[{"", clean, "escript c_src/eNpc clean"}]}.

+ 10
- 0
src/eHJps.app.src Näytä tiedosto

@ -0,0 +1,10 @@
{application, eHJps,
[{description, "An library of hexagon jps"},
{vsn, "0.1.0"},
{registered, []},
{applications, [kernel, stdlib, eSync]},
{env,[]},
{modules, []},
{licenses, ["MIT"]},
{links, []}
]}.

+ 44
- 0
src/eHJps.erl Näytä tiedosto

@ -0,0 +1,44 @@
-module(eHJps).
-include("eHJps.hrl").
-nifs ([
initMap/1
, updateMap/3
, findPath/5
]).
-on_load(init/0).
-export([
initMap/1
, updateMap/3
, findPath/5
]).
init() ->
case code:priv_dir(?MODULE) of
{error, _} ->
case code:which(?MODULE) of
Filename when is_list(Filename) ->
SoName = filename:join([filename:dirname(Filename), "../priv", atom_to_list(?MODULE)]);
_ ->
SoName = filename:join("../priv", atom_to_list(?MODULE))
end;
Dir ->
SoName = filename:join(Dir, atom_to_list(?MODULE))
end,
erlang:load_nif(SoName, 0).
-define(NOT_LOADED, erlang:nif_error({not_loaded, {module, ?MODULE}, {line, ?LINE}})).
initMap(_Data) ->
?NOT_LOADED.
updateMap(_X, _Y, _NodeInfo) ->
?NOT_LOADED.
findPath(_StartX, _StartY, _EndX, _EndY, _UpdateInfo) ->
?NOT_LOADED.

+ 4
- 0
src/user_default.erl Näytä tiedosto

@ -0,0 +1,4 @@
-module(user_default).
-compile([export_all, nowarn_export_all]).

Ladataan…
Peruuta
Tallenna