aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c
blob: 8f1de2c1c16fb375117fc7acf900ccf2ebbf5ceb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/************************************************************************************************************************
 **************************************************************************************************************************/

#include <DataDef.h>
#include "include.h"

#include "ids.h"
#include "PMR/common/MessageContainer.pb-c.h"
#include "PMR/Hardware/HardwareDispenser.pb-c.h"
#include "PMR/Hardware/HardwarePidControl.pb-c.h"
#include "PMR/Printing/JobSpool.pb-c.h"
#include "PMR/Printing/JobSpoolType.pb-c.h"

#include "drivers/Motors/Motor.h"
#include "drivers/ADC_Sampling/adc.h"
#include "drivers/valves/valve.h"

#define MAX_CONTROL_SAMPLES 10

//HardwareDispenser DispensersCfg[ MAX_SYSTEM_DISPENSERS];

TimerMotors_t DispenserIdToMotorId[MAX_SYSTEM_DISPENSERS] = {HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1,HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_2,HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_3,HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_4,HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_5,HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_6,HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_7,HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_8};

float GetDispenserPressure(int DispenserId)
{
    return DispenserPressure[DispenserId];
}
bool isDispenserInConfig(int DispenserId)
{
    TimerMotors_t  HW_Motor_Id;
    HW_Motor_Id = DispenserIdToMotorId[DispenserId];
    if (MotorsCfg[HW_Motor_Id].hardwaremotortype != DispenserIdToMotorId[DispenserId])
        return false;
    else
        return true;

}


/*uint32_t DispenserConfigMessage(HardwareDispenser * request)
{
    uint32_t status = PASSED;
    int Dispenser_i;

    Dispenser_i = request->hardwaredispensertype;
    if (Dispenser_i< MAX_SYSTEM_DISPENSERS)
    {
        memcpy (&DispensersCfg[Dispenser_i],request,sizeof(HardwareDispenser));
        return status;
    }
    else return Dispenser_i;

}*/
void IDS_ModuleInit(void)
{
    Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste);
    //Calculateinit();
    //IDS_Dispenser_Content_Init();

}
ass="o">.. "/sessions" local session_default = session_dir .. "/default.vim" if not vim.uv.fs_stat(session_dir) then vim.uv.fs_mkdir(session_dir, tonumber("755", 8)) vim.notify("Sessions save directory created at " .. session_dir, vim.log.levels.INFO) end ---------------------------------------------------------------------------------------------------- -- Sidecar providers ---------------------------------------------------------------------------------------------------- -- Capture each tab's t:tabname (:mksession drops tab-local variables). Stored positionally because -- :mksession recreates tabs in their original order, making the index stable across reloads. local function save_tabnames() local names = {} for i, tp in ipairs(vim.api.nvim_list_tabpages()) do -- pcall: nvim_tabpage_get_var errors when the variable isn't set on that tab local ok, name = pcall(vim.api.nvim_tabpage_get_var, tp, "tabname") names[i] = (ok and type(name) == "string") and name or "" end return names end -- Reapply the saved names to the recreated tabs by position, then redraw so they show at once. local function restore_tabnames(names) for i, tp in ipairs(vim.api.nvim_list_tabpages()) do if names[i] and names[i] ~= "" then vim.api.nvim_tabpage_set_var(tp, "tabname", names[i]) end end vim.cmd.redrawtabline() end -- man:// windows: :mksession can't restore them (they're :buftype=nofile, not backed by a file), so -- we record them ourselves, nested as tab index -> window number -> { buffer name, cursor line }. -- Both indices are positional for the same reason as tab names above: :mksession recreates tabs and -- their windows in order, so the ordinals are stable across reloads. Nesting by tab matters because -- window numbers restart at 1 in each tabpage and would otherwise collide. The indices are -- stringified so the sparse table encodes as a JSON object, not a null-padded array. -- -- Limitation: the cursor line is an index into the *rendered* man page, whose line wrapping depends -- on MANWIDTH. If MANWIDTH differs on load, the page re-wraps and the saved line points elsewhere. -- (It never changes in this setup, but the dependency is real.) local function save_manpages() local pages = {} for ti, tp in ipairs(vim.api.nvim_list_tabpages()) do for _, win in ipairs(vim.api.nvim_tabpage_list_wins(tp)) do local name = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(win)) if name:match("^man://") then local tk = tostring(ti) pages[tk] = pages[tk] or {} pages[tk][tostring(vim.api.nvim_win_get_number(win))] = { name = name, line = vim.api.nvim_win_get_cursor(win)[1] } end end end return pages end -- Reopen the man:// buffers recorded by save_manpages(). Keys come back from JSON as strings, hence -- the tonumber(). :edit man://... re-renders the page via the man plugin's BufReadCmd; we run it -- window-scoped so the layout restored by :mksession is left untouched, then clamp the saved cursor -- line to the (possibly re-wrapped) page. local function restore_manpages(pages) local tabpages = vim.api.nvim_list_tabpages() for tk, wins in pairs(pages) do local tp = tabpages[tonumber(tk)] if tp then local by_number = {} for _, win in ipairs(vim.api.nvim_tabpage_list_wins(tp)) do by_number[vim.api.nvim_win_get_number(win)] = win end for wk, info in pairs(wins) do local win = by_number[tonumber(wk)] if win then vim.api.nvim_win_call(win, function() vim.cmd.edit({ args = { info.name } }) end) local buf = vim.api.nvim_win_get_buf(win) local line = math.max(1, math.min(info.line or 1, vim.api.nvim_buf_line_count(buf))) vim.api.nvim_win_set_cursor(win, { line, 0 }) end end end end end session.register("tabnames", save_tabnames, restore_tabnames) session.register("manpages", save_manpages, restore_manpages) ---------------------------------------------------------------------------------------------------- -- Session operations ---------------------------------------------------------------------------------------------------- local function save_session(path) vim.cmd.mksession({ path, bang = true }) session.write(path) end local function load_session(path) vim.cmd.source(path) session.read(path) end local function reload_session(path) save_session(path) vim.cmd.restart({ args = { "+qall", "SessionLoad", path } }) end local function delete_session(path) vim.fs.rm(path) session.remove(path) end -- Complete session names (without the .vim extension) from the sessions directory. local function session_completefunc(arg_lead, _, _) local completions = {} for path in vim.fs.dir(session_dir) do if string.match(path, "^" .. arg_lead) and string.match(path, ".vim$") then completions[#completions + 1] = path:sub(1, -5) end end return completions end -- Resolve a session name (or empty for the default) to an absolute `.vim` path, then run `op` on it. local function session_op(base, op) local path = #base > 0 and base or session_default if not string.match(path, "^" .. session_dir) then path = session_dir .. "/" .. path end if not string.match(path, "%.vim$") then path = path .. ".vim" end op(path) end ---------------------------------------------------------------------------------------------------- -- User commands ---------------------------------------------------------------------------------------------------- local function cmd_session_save(ev) session_op(ev.args, save_session) end local function cmd_session_load(ev) session_op(ev.args, load_session) end local function cmd_session_delete(ev) session_op(ev.args, delete_session) end local function cmd_session_restart(ev) session_op(ev.args, reload_session) end local function cmd_session_exit_save(ev) session_op(ev.args, save_session) vim.cmd.qall() end local function cmd_session_exit_no_save() vim.cmd.qall() end vim.api.nvim_create_user_command( "SessionSave", cmd_session_save, { desc = "Save session", nargs = "?", complete = session_completefunc } ) vim.api.nvim_create_user_command( "SessionLoad", cmd_session_load, { desc = "Load session", nargs = "?", complete = session_completefunc } ) vim.api.nvim_create_user_command( "SessionDelete", cmd_session_delete, { desc = "Delete session", nargs = "?", complete = session_completefunc } ) vim.api.nvim_create_user_command( "SessionRestart", cmd_session_restart, { desc = "Reload session", nargs = "?", complete = session_completefunc } ) vim.api.nvim_create_user_command( "SessionExitSave", cmd_session_exit_save, { desc = "Save session and exit", nargs = "?", complete = session_completefunc } ) vim.api.nvim_create_user_command( "SessionExitNoSave", cmd_session_exit_no_save, { desc = "Exit without saving session", nargs = "?", complete = session_completefunc } )